s3: Fix bug 7940 -- fall back for utimes calls
authorVolker Lendecke <vl@samba.org>
Sat, 29 Jan 2011 09:59:14 +0000 (10:59 +0100)
committerKarolin Seeger <kseeger@samba.org>
Sat, 5 Mar 2011 13:34:52 +0000 (14:34 +0100)
There are systems where ./configure has detected advanced utimes calls which
are then not available on other kernels. We should do a proper fallback.
(cherry picked from commit a50a0f438a928db9c2f25c779186611e40b2a960)

source3/modules/vfs_default.c

index 691fd7c463f0cafe37787991de477c551a095611..60b85d9730cd2eb3931d81c0fa8c9fcab17bbe32 100644 (file)
@@ -898,7 +898,11 @@ static int vfswrap_ntimes(vfs_handle_struct *handle,
        } else {
                result = utimensat(AT_FDCWD, smb_fname->base_name, NULL, 0);
        }
-#elif defined(HAVE_UTIMES)
+       if (!((result == -1) && (errno == ENOSYS))) {
+               goto out;
+       }
+#endif
+#if defined(HAVE_UTIMES)
        if (ft != NULL) {
                struct timeval tv[2];
                tv[0] = convert_timespec_to_timeval(ft->atime);
@@ -907,7 +911,11 @@ static int vfswrap_ntimes(vfs_handle_struct *handle,
        } else {
                result = utimes(smb_fname->base_name, NULL);
        }
-#elif defined(HAVE_UTIME)
+       if (!((result == -1) && (errno == ENOSYS))) {
+               goto out;
+       }
+#endif
+#if defined(HAVE_UTIME)
        if (ft != NULL) {
                struct utimbuf times;
                times.actime = convert_timespec_to_time_t(ft->atime);
@@ -916,10 +924,12 @@ static int vfswrap_ntimes(vfs_handle_struct *handle,
        } else {
                result = utime(smb_fname->base_name, NULL);
        }
-#else
+       if (!((result == -1) && (errno == ENOSYS))) {
+               goto out;
+       }
+#endif
        errno = ENOSYS;
        result = -1;
-#endif
 
  out:
        END_PROFILE(syscall_ntimes);