s3: modules: Fix *allocate* calls to follow POSIX error return convention.
authorJeremy Allison <jra@samba.org>
Mon, 8 Dec 2014 03:50:54 +0000 (19:50 -0800)
committerKarolin Seeger <kseeger@samba.org>
Thu, 18 Dec 2014 20:30:05 +0000 (21:30 +0100)
Fix up the time_audit and streams_xattr modules to follow
the -1,errno convention for errors.

Reported by Jones <jones.kstw@gmail.com> who provided the
initial patch. This patch tested and confirmed working
by him as well.

Signed-off-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_streams_xattr.c
source3/modules/vfs_time_audit.c

index c4d86ee6852c1cad443225e896324e5964cae60a..625e9957e0c0bab9f8f76339db952049a9c99901 100644 (file)
@@ -1027,11 +1027,12 @@ static int streams_xattr_fallocate(struct vfs_handle_struct *handle,
        }
 
        if (!streams_xattr_recheck(sio)) {
-               return errno;
+               return -1;
        }
 
        /* Let the pwrite code path handle it. */
-       return ENOSYS;
+       errno = ENOSYS;
+       return -1;
 }
 
 
index 95b4148232b369878c62a599d44d5b70358bddff..4b9aef0c060f12fc5e01b19a18feb044b1e99549 100644 (file)
@@ -1210,18 +1210,24 @@ static int smb_time_audit_fallocate(vfs_handle_struct *handle,
                                    off_t len)
 {
        int result;
+       int saved_errno = 0;
        struct timespec ts1,ts2;
        double timediff;
 
        clock_gettime_mono(&ts1);
        result = SMB_VFS_NEXT_FALLOCATE(handle, fsp, mode, offset, len);
+       if (result == -1) {
+               saved_errno = errno;
+       }
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
        if (timediff > audit_timeout) {
                smb_time_audit_log_fsp("fallocate", timediff, fsp);
        }
-
+       if (result == -1) {
+               errno = saved_errno;
+       }
        return result;
 }