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.
BP

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17524 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Andreas Köhler 2008-09-15 13:13:40 +00:00
parent e803ad8245
commit d8c11a7c02

View File

@ -147,6 +147,12 @@ gnc_file_be_get_file_lock (FileBackend *be)
if (errno == EPERM if (errno == EPERM
# ifdef EOPNOTSUPP # ifdef EOPNOTSUPP
|| errno == EOPNOTSUPP || errno == EOPNOTSUPP
# endif
# ifdef ENOTSUP
|| errno == ENOTSUP
# endif
# ifdef ENOSYS
|| errno == ENOSYS
# endif # endif
) )
{ {
@ -395,6 +401,7 @@ copy_file(const char *orig, const char *bkup)
static gboolean static gboolean
gnc_int_link_or_make_backup(FileBackend *be, const char *orig, const char *bkup) gnc_int_link_or_make_backup(FileBackend *be, const char *orig, const char *bkup)
{ {
gboolean copy_success = FALSE;
int err_ret = int err_ret =
#ifdef HAVE_LINK #ifdef HAVE_LINK
link (orig, bkup) link (orig, bkup)
@ -408,14 +415,20 @@ gnc_int_link_or_make_backup(FileBackend *be, const char *orig, const char *bkup)
if(errno == EPERM if(errno == EPERM
# ifdef EOPNOTSUPP # ifdef EOPNOTSUPP
|| errno == EOPNOTSUPP || errno == EOPNOTSUPP
# endif
# ifdef ENOTSUP
|| errno == ENOTSUP
# endif
# ifdef ENOSYS
|| errno == ENOSYS
# endif # endif
) )
#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); qof_backend_set_error((QofBackend*)be, ERR_FILEIO_BACKUP_ERROR);
PWARN ("unable to make file backup from %s to %s: %s", PWARN ("unable to make file backup from %s to %s: %s",