summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2010-12-13 19:17:57 -0800
committerJeremy Allison <jra@samba.org>2010-12-14 05:05:50 +0100
commit0fe744078d1ce9c93759ffed3f27db82ec8922ff (patch)
treef733e6d658c53f1378afd19413ab34d1bf65a38b /source3/smbd
parent6510414ef0e48aaea9918cce87c0850d8f74fccd (diff)
downloadsamba-0fe744078d1ce9c93759ffed3f27db82ec8922ff.tar.gz
samba-0fe744078d1ce9c93759ffed3f27db82ec8922ff.tar.bz2
samba-0fe744078d1ce9c93759ffed3f27db82ec8922ff.zip
Ensure we use vfs_fsp_stat(), not VFS_STAT directly, and store into fsp->fsp_name->st
instead of a SMB_STRUCT_STAT on the stack. Jeremy. Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Tue Dec 14 05:05:50 CET 2010 on sn-devel-104
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/vfs.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index a35142eab1..3055e37663 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -455,10 +455,10 @@ ssize_t vfs_pwrite_data(struct smb_request *req,
int vfs_allocate_file_space(files_struct *fsp, uint64_t len)
{
int ret;
- SMB_STRUCT_STAT st;
connection_struct *conn = fsp->conn;
uint64_t space_avail;
uint64_t bsize,dfree,dsize;
+ NTSTATUS status;
/*
* Actually try and commit the space on disk....
@@ -474,19 +474,20 @@ int vfs_allocate_file_space(files_struct *fsp, uint64_t len)
return -1;
}
- ret = SMB_VFS_FSTAT(fsp, &st);
- if (ret == -1)
- return ret;
+ status = vfs_stat_fsp(fsp);
+ if (!NT_STATUS_IS_OK(status)) {
+ return -1;
+ }
- if (len == (uint64_t)st.st_ex_size)
+ if (len == (uint64_t)fsp->fsp_name->st.st_ex_size)
return 0;
- if (len < (uint64_t)st.st_ex_size) {
+ if (len < (uint64_t)fsp->fsp_name->st.st_ex_size) {
/* Shrink - use ftruncate. */
DEBUG(10,("vfs_allocate_file_space: file %s, shrink. Current "
"size %.0f\n", fsp_str_dbg(fsp),
- (double)st.st_ex_size));
+ (double)fsp->fsp_name->st.st_ex_size));
contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_ALLOC_SHRINK);
@@ -508,7 +509,7 @@ int vfs_allocate_file_space(files_struct *fsp, uint64_t len)
if (!lp_strict_allocate(SNUM(fsp->conn)))
return 0;
- len -= st.st_ex_size;
+ 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,
&bsize, &dfree, &dsize);
@@ -518,7 +519,7 @@ int vfs_allocate_file_space(files_struct *fsp, uint64_t len)
DEBUG(10,("vfs_allocate_file_space: file %s, grow. Current size %.0f, "
"needed blocks = %.0f, space avail = %.0f\n",
- fsp_str_dbg(fsp), (double)st.st_ex_size, (double)len,
+ fsp_str_dbg(fsp), (double)fsp->fsp_name->st.st_ex_size, (double)len,
(double)space_avail));
if (len > space_avail) {
@@ -605,36 +606,36 @@ int vfs_slow_fallocate(files_struct *fsp, SMB_OFF_T offset, SMB_OFF_T len)
int vfs_fill_sparse(files_struct *fsp, SMB_OFF_T len)
{
int ret;
- SMB_STRUCT_STAT st;
+ NTSTATUS status;
SMB_OFF_T offset;
size_t num_to_write;
- ret = SMB_VFS_FSTAT(fsp, &st);
- if (ret == -1) {
- return ret;
+ status = vfs_stat_fsp(fsp);
+ if (!NT_STATUS_IS_OK(status)) {
+ return -1;
}
- if (len <= st.st_ex_size) {
+ if (len <= fsp->fsp_name->st.st_ex_size) {
return 0;
}
#ifdef S_ISFIFO
- if (S_ISFIFO(st.st_ex_mode)) {
+ if (S_ISFIFO(fsp->fsp_name->st.st_ex_mode)) {
return 0;
}
#endif
DEBUG(10,("vfs_fill_sparse: write zeros in file %s from len %.0f to "
"len %.0f (%.0f bytes)\n", fsp_str_dbg(fsp),
- (double)st.st_ex_size, (double)len,
- (double)(len - st.st_ex_size)));
+ (double)fsp->fsp_name->st.st_ex_size, (double)len,
+ (double)(len - fsp->fsp_name->st.st_ex_size)));
contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_FILL_SPARSE);
flush_write_cache(fsp, SIZECHANGE_FLUSH);
- offset = st.st_ex_size;
- num_to_write = len - st.st_ex_size;
+ offset = fsp->fsp_name->st.st_ex_size;
+ num_to_write = len - fsp->fsp_name->st.st_ex_size;
/* Only do this on non-stream file handles. */
if (fsp->base_fsp == NULL) {