diff options
| author | Jeremy Allison <jra@samba.org> | 2014-12-05 15:34:12 -0800 |
|---|---|---|
| committer | Jeremy Allison <jra@samba.org> | 2014-12-08 00:33:06 +0100 |
| commit | cc1f91cec627cb3e4fc89b96aae1e7e4c539cd1c (patch) | |
| tree | 78e4f38db55a0c275e6cd9980cfa361062619215 /source3 | |
| parent | c9235deee0fc49c99cfaf2329b7af526d9dd12d0 (diff) | |
| download | samba-cc1f91cec627cb3e4fc89b96aae1e7e4c539cd1c.tar.gz samba-cc1f91cec627cb3e4fc89b96aae1e7e4c539cd1c.tar.xz samba-cc1f91cec627cb3e4fc89b96aae1e7e4c539cd1c.zip | |
s3: smbd: Fix *allocate* calls to follow POSIX error return convention.
Fix vfs_allocate_file_space(), vfs_slow_fallocate(),
vfs_fill_sparse() to follow the -1,errno convention
for errors.
Standardize on the -1,errno convention.
Reported by Jones <jones.kstw@gmail.com> who provided the
initial patch. This patch tested and confirmed working
by him as well.
https://bugzilla.samba.org/show_bug.cgi?id=10982
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Diffstat (limited to 'source3')
| -rw-r--r-- | source3/smbd/vfs.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 51362c3c3b..d10e0d67e9 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -586,6 +586,10 @@ int vfs_allocate_file_space(files_struct *fsp, uint64_t len) return 0; } + if (ret == -1 && errno == ENOSPC) { + return -1; + } + len -= fsp->fsp_name->st.st_ex_size; len /= 1024; /* Len is now number of 1k blocks needed. */ space_avail = get_dfree_info(conn, fsp->fsp_name->base_name, false, @@ -640,7 +644,7 @@ int vfs_set_filelen(files_struct *fsp, off_t len) fails. Needs to be outside of the default version of SMB_VFS_FALLOCATE as this is also called from the default SMB_VFS_FTRUNCATE code. Always extends the file size. - Returns 0 on success, errno on failure. + Returns 0 on success, -1 on failure. ****************************************************************************/ #define SPARSE_BUF_WRITE_SIZE (32*1024) @@ -654,7 +658,7 @@ int vfs_slow_fallocate(files_struct *fsp, off_t offset, off_t len) sparse_buf = SMB_CALLOC_ARRAY(char, SPARSE_BUF_WRITE_SIZE); if (!sparse_buf) { errno = ENOMEM; - return ENOMEM; + return -1; } } @@ -663,10 +667,12 @@ int vfs_slow_fallocate(files_struct *fsp, off_t offset, off_t len) pwrite_ret = SMB_VFS_PWRITE(fsp, sparse_buf, curr_write_size, offset + total); if (pwrite_ret == -1) { + int saved_errno = errno; DEBUG(10,("vfs_slow_fallocate: SMB_VFS_PWRITE for file " "%s failed with error %s\n", - fsp_str_dbg(fsp), strerror(errno))); - return errno; + fsp_str_dbg(fsp), strerror(saved_errno))); + errno = saved_errno; + return -1; } total += pwrite_ret; } @@ -724,9 +730,7 @@ int vfs_fill_sparse(files_struct *fsp, off_t len) * return ENOTSUP or EINVAL in cases like that. */ ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_EXTEND_SIZE, offset, num_to_write); - if (ret == ENOSPC) { - errno = ENOSPC; - ret = -1; + if (ret == -1 && errno == ENOSPC) { goto out; } if (ret == 0) { @@ -737,10 +741,6 @@ int vfs_fill_sparse(files_struct *fsp, off_t len) } ret = vfs_slow_fallocate(fsp, offset, num_to_write); - if (ret != 0) { - errno = ret; - ret = -1; - } out: |
