summaryrefslogtreecommitdiff
path: root/source3/modules
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2010-12-02 17:26:00 -0800
committerJeremy Allison <jra@samba.org>2010-12-03 02:55:05 +0100
commitb8d7de319980f9efade92dd0721ed02efcb7e48d (patch)
treea37aff4ab5ececbf0ec6b4a9ee67a1de29cb65f4 /source3/modules
parent1f1491da5ae2a2b7fd3a195f950b9057a01db18c (diff)
downloadsamba-b8d7de319980f9efade92dd0721ed02efcb7e48d.tar.gz
samba-b8d7de319980f9efade92dd0721ed02efcb7e48d.tar.bz2
samba-b8d7de319980f9efade92dd0721ed02efcb7e48d.zip
Merge the two conflicting allocation codes into one function, vfs_slow_fallocate()
and use that from both the truncate and fill_sparse functions. Jeremy.
Diffstat (limited to 'source3/modules')
-rw-r--r--source3/modules/vfs_default.c26
1 files changed, 4 insertions, 22 deletions
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 0ec5b66df3..79f66db6d9 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -822,16 +822,11 @@ static int vfswrap_ntimes(vfs_handle_struct *handle,
static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T len)
{
SMB_STRUCT_STAT st;
- SMB_OFF_T currpos = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR);
- unsigned char zero_space[4096];
SMB_OFF_T space_to_write;
uint64_t space_avail;
uint64_t bsize,dfree,dsize;
int ret;
- if (currpos == -1)
- return -1;
-
if (SMB_VFS_FSTAT(fsp, &st) == -1)
return -1;
@@ -877,25 +872,12 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs
}
/* Write out the real space on disk. */
- if (SMB_VFS_LSEEK(fsp, st.st_ex_size, SEEK_SET) != st.st_ex_size)
- return -1;
-
- memset(zero_space, '\0', sizeof(zero_space));
- while ( space_to_write > 0) {
- SMB_OFF_T retlen;
- SMB_OFF_T current_len_to_write = MIN(sizeof(zero_space),space_to_write);
-
- retlen = SMB_VFS_WRITE(fsp,(char *)zero_space,current_len_to_write);
- if (retlen <= 0)
- return -1;
-
- space_to_write -= retlen;
+ ret = vfs_slow_fallocate(fsp, st.st_ex_size, space_to_write);
+ if (ret != 0) {
+ errno = ret;
+ ret = -1;
}
- /* Seek to where we were */
- if (SMB_VFS_LSEEK(fsp, currpos, SEEK_SET) != currpos)
- return -1;
-
return 0;
}