summaryrefslogtreecommitdiff
path: root/source3/smbd/vfs.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-12-04 03:12:09 +0000
committerJeremy Allison <jra@samba.org>2002-12-04 03:12:09 +0000
commitce4628c199f8e8ac84aa7f2afe2de1d9d23e6fab (patch)
treea6508c65d5fc7c26e73b95bc0b217412c69b147b /source3/smbd/vfs.c
parent9e962452d879edd6811ece18665a8601c70a27d5 (diff)
downloadsamba-ce4628c199f8e8ac84aa7f2afe2de1d9d23e6fab.tar.gz
samba-ce4628c199f8e8ac84aa7f2afe2de1d9d23e6fab.tar.bz2
samba-ce4628c199f8e8ac84aa7f2afe2de1d9d23e6fab.zip
Fix for 64 bit issues with oplocks and allocation size.
Jeremy. (This used to be commit 379e719e983fb71f94cd2b691f8b194c109496c3)
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;