summaryrefslogtreecommitdiff
path: root/source3/smbd/vfs.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-12-04 03:12:28 +0000
committerJeremy Allison <jra@samba.org>2002-12-04 03:12:28 +0000
commit9dc3ec5af335ffea93135129d22461cc66e310c9 (patch)
treecd5fcb72aed1e26c8eec0d94c27a7a6773d54358 /source3/smbd/vfs.c
parentf23eae814dc99273032f66b123c0084627539918 (diff)
downloadsamba-9dc3ec5af335ffea93135129d22461cc66e310c9.tar.gz
samba-9dc3ec5af335ffea93135129d22461cc66e310c9.tar.bz2
samba-9dc3ec5af335ffea93135129d22461cc66e310c9.zip
Fix for 64 bit issues with oplocks and allocation size.
Jeremy. (This used to be commit 4a9c995e50b24e6ee6ec58c46da32100a8197724)
Diffstat (limited to 'source3/smbd/vfs.c')
-rw-r--r--source3/smbd/vfs.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index f6dad7b6e7..7e60d3dacb 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -423,13 +423,13 @@ ssize_t vfs_write_data(files_struct *fsp,const char *buffer,size_t N)
Returns 0 on success, -1 on failure.
****************************************************************************/
-int vfs_allocate_file_space(files_struct *fsp, SMB_OFF_T len)
+int vfs_allocate_file_space(files_struct *fsp, SMB_BIG_UINT len)
{
int ret;
SMB_STRUCT_STAT st;
connection_struct *conn = fsp->conn;
struct vfs_ops *vfs_ops = &conn->vfs_ops;
- SMB_OFF_T space_avail;
+ SMB_BIG_UINT space_avail;
SMB_BIG_UINT bsize,dfree,dsize;
release_level_2_oplocks_on_change(fsp);
@@ -440,21 +440,26 @@ int vfs_allocate_file_space(files_struct *fsp, SMB_OFF_T len)
DEBUG(10,("vfs_allocate_file_space: file %s, len %.0f\n", fsp->fsp_name, (double)len ));
+ if (((SMB_OFF_T)len) < 0) {
+ DEBUG(0,("vfs_allocate_file_space: %s negative len requested.\n", fsp->fsp_name ));
+ return -1;
+ }
+
ret = vfs_fstat(fsp,fsp->fd,&st);
if (ret == -1)
return ret;
- if (len == st.st_size)
+ if (len == (SMB_BIG_UINT)st.st_size)
return 0;
- if (len < st.st_size) {
+ if (len < (SMB_BIG_UINT)st.st_size) {
/* Shrink - use ftruncate. */
DEBUG(10,("vfs_allocate_file_space: file %s, shrink. Current size %.0f\n",
fsp->fsp_name, (double)st.st_size ));
flush_write_cache(fsp, SIZECHANGE_FLUSH);
- if ((ret = vfs_ops->ftruncate(fsp, fsp->fd, len)) != -1) {
+ if ((ret = vfs_ops->ftruncate(fsp, fsp->fd, (SMB_OFF_T)len)) != -1) {
set_filelen_write_cache(fsp, len);
}
return ret;
@@ -467,10 +472,10 @@ int vfs_allocate_file_space(files_struct *fsp, SMB_OFF_T len)
len -= st.st_size;
len /= 1024; /* Len is now number of 1k blocks needed. */
- space_avail = (SMB_OFF_T)conn->vfs_ops.disk_free(conn,fsp->fsp_name,False,&bsize,&dfree,&dsize);
+ space_avail = conn->vfs_ops.disk_free(conn,fsp->fsp_name,False,&bsize,&dfree,&dsize);
- DEBUG(10,("vfs_allocate_file_space: file %s, grow. Current size %.0f, needed blocks = %lu, space avail = %lu\n",
- fsp->fsp_name, (double)st.st_size, (unsigned long)len, (unsigned long)space_avail ));
+ DEBUG(10,("vfs_allocate_file_space: file %s, grow. Current size %.0f, needed blocks = %.0f, space avail = %.0f\n",
+ fsp->fsp_name, (double)st.st_size, (double)len, (double)space_avail ));
if (len > space_avail) {
errno = ENOSPC;