diff options
| author | Jeremy Allison <jra@samba.org> | 2014-12-05 15:37:11 -0800 |
|---|---|---|
| committer | Jeremy Allison <jra@samba.org> | 2014-12-08 02:59:43 +0100 |
| commit | 2845e1c29f8bce6306a73d546184c401bf89cfea (patch) | |
| tree | b217c4f973668cba1b9e85cd83be01e9d9519fef /source3/modules | |
| parent | cc1f91cec627cb3e4fc89b96aae1e7e4c539cd1c (diff) | |
s3: modules: Fix *allocate* calls to follow POSIX error return convention.
Fix up the ceph, fruit, 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>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Dec 8 02:59:43 CET 2014 on sn-devel-104
Diffstat (limited to 'source3/modules')
| -rw-r--r-- | source3/modules/vfs_ceph.c | 13 | ||||
| -rw-r--r-- | source3/modules/vfs_fruit.c | 5 | ||||
| -rw-r--r-- | source3/modules/vfs_streams_xattr.c | 5 | ||||
| -rw-r--r-- | source3/modules/vfs_time_audit.c | 8 |
4 files changed, 16 insertions, 15 deletions
diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index e402ff1141..b0a00249f1 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -795,15 +795,14 @@ static int strict_allocate_ftruncate(struct vfs_handle_struct *handle, files_str return ENOTSUP or EINVAL in cases like that. */ ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_EXTEND_SIZE, pst->st_ex_size, space_to_write); - if (ret == ENOSPC) { - errno = ENOSPC; + if (ret == -1 && errno == ENOSPC) { return -1; } if (ret == 0) { return 0; } DEBUG(10,("[CEPH] strict_allocate_ftruncate: SMB_VFS_FALLOCATE failed with " - "error %d. Falling back to slow manual allocation\n", ret)); + "error %d. Falling back to slow manual allocation\n", errno)); /* available disk space is enough or not? */ space_avail = get_dfree_info(fsp->conn, @@ -817,13 +816,7 @@ static int strict_allocate_ftruncate(struct vfs_handle_struct *handle, files_str } /* Write out the real space on disk. */ - ret = vfs_slow_fallocate(fsp, pst->st_ex_size, space_to_write); - if (ret != 0) { - errno = ret; - ret = -1; - } - - return 0; + return vfs_slow_fallocate(fsp, pst->st_ex_size, space_to_write); } static int cephwrap_ftruncate(struct vfs_handle_struct *handle, files_struct *fsp, off_t len) diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index 18a6823bb0..a8bf7b4fd6 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -3050,11 +3050,12 @@ static int fruit_fallocate(struct vfs_handle_struct *handle, } if (!fruit_fsp_recheck(ad, fsp)) { - return errno; + return -1; } /* Let the pwrite code path handle it. */ - return ENOSYS; + errno = ENOSYS; + return -1; } static int fruit_ftruncate(struct vfs_handle_struct *handle, diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index f0ab7321e0..5c5a9a17fa 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -1103,11 +1103,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; } diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c index 4ce9238a2c..a1e825aa09 100644 --- a/source3/modules/vfs_time_audit.c +++ b/source3/modules/vfs_time_audit.c @@ -1216,18 +1216,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; } |
