r17550 - gnucash/branches/2.2/src/backend/file - [r17524] Bug #549595, #552306: Correct retval of gnc_int_link_or_make_backup(), add ENOSYS and ENOTSUP.

Andreas Köhler andi5 at cvs.gnucash.org
Wed Sep 17 13:36:19 EDT 2008


Author: andi5
Date: 2008-09-17 13:36:18 -0400 (Wed, 17 Sep 2008)
New Revision: 17550
Trac: http://svn.gnucash.org/trac/changeset/17550

Modified:
   gnucash/branches/2.2/src/backend/file/gnc-backend-file.c
Log:
[r17524] Bug #549595, #552306: Correct retval of gnc_int_link_or_make_backup(), add ENOSYS and ENOTSUP.

The return value of link(2) on files residing on sshfs will be ENOSYS, on
network hfsplus file systems on mac ENOTSUP, so add them to the list of those
errnos that trigger copy_file as fallback in gnc_int_link_or_make_backup() or
are allowed in gnc_file_be_get_file_lock() showing that hardlinks are not
supported.

To avoid silent data loss in the case of an unexpected errno in
gnc_int_link_or_make_backup(), correctly set the backend error.

Patches from Micha Lenk and Boris Zbarsky.

Modified: gnucash/branches/2.2/src/backend/file/gnc-backend-file.c
===================================================================
--- gnucash/branches/2.2/src/backend/file/gnc-backend-file.c	2008-09-17 17:36:10 UTC (rev 17549)
+++ gnucash/branches/2.2/src/backend/file/gnc-backend-file.c	2008-09-17 17:36:18 UTC (rev 17550)
@@ -146,9 +146,15 @@
         /* If hard links aren't supported, just allow the lock. */
         if (errno == EPERM
 # ifdef EOPNOTSUPP
-	    || errno == EOPNOTSUPP
+            || errno == EOPNOTSUPP
 # endif
-	    )
+# ifdef ENOTSUP
+            || errno == ENOTSUP
+# endif
+# ifdef ENOSYS
+            || errno == ENOSYS
+# endif
+            )
         {
             be->linkfile = NULL;
             return TRUE;
@@ -394,6 +400,7 @@
 static gboolean
 gnc_int_link_or_make_backup(FileBackend *be, const char *orig, const char *bkup)
 {
+    gboolean copy_success = FALSE;
     int err_ret = 
 #ifdef HAVE_LINK
       link (orig, bkup)
@@ -406,15 +413,21 @@
 #ifdef HAVE_LINK
         if(errno == EPERM
 # ifdef EOPNOTSUPP
-	   || errno == EOPNOTSUPP
+           || errno == EOPNOTSUPP
 # endif
-	   )
+# ifdef ENOTSUP
+           || errno == ENOTSUP
+# endif
+# ifdef ENOSYS
+           || errno == ENOSYS
+# endif
+            )
 #endif
         {
-            err_ret = copy_file(orig, bkup);
+            copy_success = copy_file(orig, bkup);
         }
 
-        if(!err_ret)
+        if(!copy_success)
         {
             qof_backend_set_error((QofBackend*)be, ERR_FILEIO_BACKUP_ERROR);
             PWARN ("unable to make file backup from %s to %s: %s", 



More information about the gnucash-changes mailing list