Remove redundant parameter fd from SMB_VFS_FTRUNCATE().
authorMichael Adam <obnox@samba.org>
Mon, 7 Jan 2008 14:55:09 +0000 (15:55 +0100)
committerMichael Adam <obnox@samba.org>
Mon, 7 Jan 2008 14:59:02 +0000 (15:59 +0100)
Michael

12 files changed:
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source/include/vfs.h
source/include/vfs_macros.h
source/modules/vfs_commit.c
source/modules/vfs_default.c
source/modules/vfs_full_audit.c
source/modules/vfs_prealloc.c
source/smbd/fileio.c
source/smbd/open.c
source/smbd/vfs.c
source/torture/cmd_vfs.c

index 185694f6fa0a529fdd7e28670766b1d077733caa..2ecfcf1b663f779a7bfb87d4c89960cc8ac08d31 100644 (file)
@@ -236,9 +236,9 @@ static int skel_ntimes(vfs_handle_struct *handle,  const char *path, const struc
        return vfswrap_ntimes(NULL,  path, ts);
 }
 
-static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T offset)
+static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T offset)
 {
-       return vfswrap_ftruncate(NULL, fsp, fd, offset);
+       return vfswrap_ftruncate(NULL, fsp, offset);
 }
 
 static bool skel_lock(vfs_handle_struct *handle, files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
index d4af67db5131ecc07b0e801cedcd7e4d4390383f..5d3103ee76ec5ba8b2c9d90232458f83dde600dd 100644 (file)
@@ -229,9 +229,9 @@ static int skel_ntimes(vfs_handle_struct *handle,  const char *path, const struc
        return SMB_VFS_NEXT_NTIMES(handle, path, ts);
 }
 
-static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T offset)
+static int skel_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T offset)
 {
-       return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, fd, offset);
+       return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset);
 }
 
 static bool skel_lock(vfs_handle_struct *handle, files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
index 88975302b28b3ddf356604b801832aa55d9da8fc..a36cd551eeff148b955865d1a6bdcf323aefcc2a 100644 (file)
@@ -86,6 +86,7 @@
 /* Leave at 22 - not yet released. Remove parameter fd from fstat. - obnox */
 /* Leave at 22 - not yet released. Remove parameter fd from fchmod. - obnox */
 /* Leave at 22 - not yet released. Remove parameter fd from fchown. - obnox */
+/* Leave at 22 - not yet released. Remove parameter fd from ftruncate. - obnox */
 
 
 #define SMB_VFS_INTERFACE_VERSION 22
@@ -297,7 +298,7 @@ struct vfs_ops {
                int (*chdir)(struct vfs_handle_struct *handle, const char *path);
                char *(*getwd)(struct vfs_handle_struct *handle, char *buf);
                int (*ntimes)(struct vfs_handle_struct *handle, const char *path, const struct timespec ts[2]);
-               int (*ftruncate)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, SMB_OFF_T offset);
+               int (*ftruncate)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_OFF_T offset);
                bool (*lock)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
                int (*kernel_flock)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, uint32 share_mode);
                int (*linux_setlease)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd, int leasetype);
index 366481039e4560e22b7c6646a0fcef2eaf4a1914..2fc0dda3c8c77d8716844eb94410728c8b9bd291 100644 (file)
@@ -69,7 +69,7 @@
 #define SMB_VFS_CHDIR(conn, path) ((conn)->vfs.ops.chdir((conn)->vfs.handles.chdir, (path)))
 #define SMB_VFS_GETWD(conn, buf) ((conn)->vfs.ops.getwd((conn)->vfs.handles.getwd, (buf)))
 #define SMB_VFS_NTIMES(conn, path, ts) ((conn)->vfs.ops.ntimes((conn)->vfs.handles.ntimes, (path), (ts)))
-#define SMB_VFS_FTRUNCATE(fsp, fd, offset) ((fsp)->conn->vfs.ops.ftruncate((fsp)->conn->vfs.handles.ftruncate, (fsp), (fd), (offset)))
+#define SMB_VFS_FTRUNCATE(fsp, offset) ((fsp)->conn->vfs.ops.ftruncate((fsp)->conn->vfs.handles.ftruncate, (fsp), (offset)))
 #define SMB_VFS_LOCK(fsp, fd, op, offset, count, type) ((fsp)->conn->vfs.ops.lock((fsp)->conn->vfs.handles.lock, (fsp), (fd) ,(op), (offset), (count), (type)))
 #define SMB_VFS_KERNEL_FLOCK(fsp, fd, share_mode) ((fsp)->conn->vfs.ops.kernel_flock((fsp)->conn->vfs.handles.kernel_flock, (fsp), (fd), (share_mode)))
 #define SMB_VFS_LINUX_SETLEASE(fsp, fd, leasetype) ((fsp)->conn->vfs.ops.linux_setlease((fsp)->conn->vfs.handles.linux_setlease, (fsp), (fd), (leasetype)))
 #define SMB_VFS_OPAQUE_CHDIR(conn, path) ((conn)->vfs_opaque.ops.chdir((conn)->vfs_opaque.handles.chdir, (path)))
 #define SMB_VFS_OPAQUE_GETWD(conn, buf) ((conn)->vfs_opaque.ops.getwd((conn)->vfs_opaque.handles.getwd, (buf)))
 #define SMB_VFS_OPAQUE_NTIMES(conn, path, ts) ((conn)->vfs_opaque.ops.ntimes((conn)->vfs_opaque.handles.ntimes, (path), (ts)))
-#define SMB_VFS_OPAQUE_FTRUNCATE(fsp, fd, offset) ((fsp)->conn->vfs_opaque.ops.ftruncate((fsp)->conn->vfs_opaque.handles.ftruncate, (fsp), (fd), (offset)))
+#define SMB_VFS_OPAQUE_FTRUNCATE(fsp, offset) ((fsp)->conn->vfs_opaque.ops.ftruncate((fsp)->conn->vfs_opaque.handles.ftruncate, (fsp), (offset)))
 #define SMB_VFS_OPAQUE_LOCK(fsp, fd, op, offset, count, type) ((fsp)->conn->vfs_opaque.ops.lock((fsp)->conn->vfs_opaque.handles.lock, (fsp), (fd) ,(op), (offset), (count), (type)))
 #define SMB_VFS_OPAQUE_FLOCK(fsp, fd, share_mode) ((fsp)->conn->vfs_opaque.ops.lock((fsp)->conn->vfs_opaque.handles.kernel_flock, (fsp), (fd), (share_mode)))
 #define SMB_VFS_OPAQUE_LINUX_SETLEASE(fsp, fd, leasetype) ((fsp)->conn->vfs_opaque.ops.linux_setlease((fsp)->conn->vfs_opaque.handles.linux_setlease, (fsp), (fd), (leasetype)))
 #define SMB_VFS_NEXT_CHDIR(handle, path) ((handle)->vfs_next.ops.chdir((handle)->vfs_next.handles.chdir, (path)))
 #define SMB_VFS_NEXT_GETWD(handle, buf) ((handle)->vfs_next.ops.getwd((handle)->vfs_next.handles.getwd, (buf)))
 #define SMB_VFS_NEXT_NTIMES(handle, path, ts) ((handle)->vfs_next.ops.ntimes((handle)->vfs_next.handles.ntimes, (path), (ts)))
-#define SMB_VFS_NEXT_FTRUNCATE(handle, fsp, fd, offset) ((handle)->vfs_next.ops.ftruncate((handle)->vfs_next.handles.ftruncate, (fsp), (fd), (offset)))
+#define SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset) ((handle)->vfs_next.ops.ftruncate((handle)->vfs_next.handles.ftruncate, (fsp), (offset)))
 #define SMB_VFS_NEXT_LOCK(handle, fsp, fd, op, offset, count, type) ((handle)->vfs_next.ops.lock((handle)->vfs_next.handles.lock, (fsp), (fd) ,(op), (offset), (count), (type)))
 #define SMB_VFS_NEXT_KERNEL_FLOCK(handle, fsp, fd, share_mode)((handle)->vfs_next.ops.kernel_flock((handle)->vfs_next.handles.kernel_flock, (fsp), (fd), (share_mode)))
 #define SMB_VFS_NEXT_LINUX_SETLEASE(handle, fsp, fd, leasetype)((handle)->vfs_next.ops.linux_setlease((handle)->vfs_next.handles.linux_setlease, (fsp), (fd), (leasetype)))
index f79e68f49e429e36107f8f5908b79bdf6d99a12d..fe7324122f7403499d47717e23c1584dbac9bd90 100644 (file)
@@ -277,12 +277,11 @@ static int commit_close(
 static int commit_ftruncate(
         vfs_handle_struct * handle,
         files_struct *      fsp,
-        int                 fd,
         SMB_OFF_T           len)
 {
         int result;
 
-        result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, fd, len);
+        result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
         if (result == 0) {
                struct commit_info *c;
                if ((c = VFS_FETCH_FSP_EXTENSION(handle, fsp))) {
index f66f77cd47e776bd47e06bb86d46dc5a69f1da3d..6ac8cc5def658207c2efc8f09bff00dc7fc8b9df 100644 (file)
@@ -674,7 +674,7 @@ static int vfswrap_ntimes(vfs_handle_struct *handle, const char *path, const str
  allocate is set.
 **********************************************************************/
 
-static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T len)
+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);
@@ -699,7 +699,7 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs
 
        /* Shrink - just ftruncate. */
        if (st.st_size > len)
-               return sys_ftruncate(fd, len);
+               return sys_ftruncate(fsp->fh->fd, len);
 
        /* Write out the real space on disk. */
        if (SMB_VFS_LSEEK(fsp, st.st_size, SEEK_SET) != st.st_size)
@@ -726,7 +726,7 @@ static int strict_allocate_ftruncate(vfs_handle_struct *handle, files_struct *fs
        return 0;
 }
 
-static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_OFF_T len)
+static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, SMB_OFF_T len)
 {
        int result = -1;
        SMB_STRUCT_STAT st;
@@ -736,7 +736,7 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int f
        START_PROFILE(syscall_ftruncate);
 
        if (lp_strict_allocate(SNUM(fsp->conn))) {
-               result = strict_allocate_ftruncate(handle, fsp, fd, len);
+               result = strict_allocate_ftruncate(handle, fsp, fsp->fh->fd, len);
                END_PROFILE(syscall_ftruncate);
                return result;
        }
@@ -747,7 +747,7 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int f
           expansion and some that don't! On Linux fat can't do
           ftruncate extend but ext2 can. */
 
-       result = sys_ftruncate(fd, len);
+       result = sys_ftruncate(fsp->fh->fd, len);
        if (result == 0)
                goto done;
 
@@ -787,7 +787,7 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, int f
        if (SMB_VFS_LSEEK(fsp, len-1, SEEK_SET) != len -1)
                goto done;
 
-       if (SMB_VFS_WRITE(fsp, fd, &c, 1)!=1)
+       if (SMB_VFS_WRITE(fsp, fsp->fh->fd, &c, 1)!=1)
                goto done;
 
        /* Seek to where we were */
index f7796adba00d1febd80b5f743d37cef905b02347..1384c1629061a5d05a6b8f4a501a6cf2e9408d88 100644 (file)
@@ -159,7 +159,7 @@ static char *smb_full_audit_getwd(vfs_handle_struct *handle,
 static int smb_full_audit_ntimes(vfs_handle_struct *handle,
                       const char *path, const struct timespec ts[2]);
 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
-                          int fd, SMB_OFF_T len);
+                          SMB_OFF_T len);
 static bool smb_full_audit_lock(vfs_handle_struct *handle, files_struct *fsp, int fd,
                       int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
 static int smb_full_audit_kernel_flock(struct vfs_handle_struct *handle,
@@ -1353,11 +1353,11 @@ static int smb_full_audit_ntimes(vfs_handle_struct *handle,
 }
 
 static int smb_full_audit_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
-                          int fd, SMB_OFF_T len)
+                          SMB_OFF_T len)
 {
        int result;
 
-       result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, fd, len);
+       result = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
 
        do_log(SMB_VFS_OP_FTRUNCATE, (result >= 0), handle,
               "%s", fsp->fsp_name);
index cebf3a3933747a1281813ae6e67e2bbdbfbde0b9..2d64bc0184ded75357642f30c1881eb52e983fe4 100644 (file)
@@ -184,11 +184,10 @@ normal_open:
 
 static int prealloc_ftruncate(vfs_handle_struct * handle,
                        files_struct *  fsp,
-                       int             fd,
                        SMB_OFF_T       offset)
 {
        SMB_OFF_T *psize;
-       int ret = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, fd, offset);
+       int ret = SMB_VFS_NEXT_FTRUNCATE(handle, fsp, offset);
 
        /* Maintain the allocated space even in the face of truncates. */
        if ((psize = VFS_FETCH_FSP_EXTENSION(handle, fsp))) {
index 1258b73cada9cf0b786778052cde2e8f594f78dc..8cea4989f5b4dd16f5d3ad26208e951094a1e908 100644 (file)
@@ -184,7 +184,7 @@ static int wcp_file_size_change(files_struct *fsp)
        write_cache *wcp = fsp->wcp;
 
        wcp->file_size = wcp->offset + wcp->data_size;
-       ret = SMB_VFS_FTRUNCATE(fsp, fsp->fh->fd, wcp->file_size);
+       ret = SMB_VFS_FTRUNCATE(fsp, wcp->file_size);
        if (ret == -1) {
                DEBUG(0,("wcp_file_size_change (%s): ftruncate of size %.0f error %s\n",
                        fsp->fsp_name, (double)wcp->file_size, strerror(errno) ));
index 036e3e12a2db4ea9dbf162d0db9ed45f71a6891e..cc62e020da22c000996247dde46dc009368a743c 100644 (file)
@@ -1789,7 +1789,7 @@ NTSTATUS open_file_ntcreate(connection_struct *conn,
                 * We are modifing the file after open - update the stat
                 * struct..
                 */
-               if ((SMB_VFS_FTRUNCATE(fsp,fsp->fh->fd,0) == -1) ||
+               if ((SMB_VFS_FTRUNCATE(fsp, 0) == -1) ||
                    (SMB_VFS_FSTAT(fsp, psbuf)==-1)) {
                        status = map_nt_error_from_unix(errno);
                        TALLOC_FREE(lck);
index c7edac7b7a0a60a3d9858e0840f44c504c339f71..9a5e0aff60ccb9a78640483f6fe238e0c4399b0e 100644 (file)
@@ -539,7 +539,7 @@ int vfs_allocate_file_space(files_struct *fsp, SMB_BIG_UINT len)
                                fsp->fsp_name, (double)st.st_size ));
 
                flush_write_cache(fsp, SIZECHANGE_FLUSH);
-               if ((ret = SMB_VFS_FTRUNCATE(fsp, fsp->fh->fd, (SMB_OFF_T)len)) != -1) {
+               if ((ret = SMB_VFS_FTRUNCATE(fsp, (SMB_OFF_T)len)) != -1) {
                        set_filelen_write_cache(fsp, len);
                }
                return ret;
@@ -581,7 +581,7 @@ int vfs_set_filelen(files_struct *fsp, SMB_OFF_T len)
        release_level_2_oplocks_on_change(fsp);
        DEBUG(10,("vfs_set_filelen: ftruncate %s to len %.0f\n", fsp->fsp_name, (double)len));
        flush_write_cache(fsp, SIZECHANGE_FLUSH);
-       if ((ret = SMB_VFS_FTRUNCATE(fsp, fsp->fh->fd, len)) != -1) {
+       if ((ret = SMB_VFS_FTRUNCATE(fsp, len)) != -1) {
                set_filelen_write_cache(fsp, len);
                notify_fname(fsp->conn, NOTIFY_ACTION_MODIFIED,
                             FILE_NOTIFY_CHANGE_SIZE
index 3947c3dd3c0064f6e6ef5bdb5de2c4b6df270c31..17028fefc210bf6541f52495f01d6c59fe5201b4 100644 (file)
@@ -818,7 +818,7 @@ static NTSTATUS cmd_ftruncate(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int ar
                return NT_STATUS_OK;
        }
 
-       if (SMB_VFS_FTRUNCATE(vfs->files[fd], fd, off) == -1) {
+       if (SMB_VFS_FTRUNCATE(vfs->files[fd], off) == -1) {
                printf("ftruncate: error=%d (%s)\n", errno, strerror(errno));
                return NT_STATUS_UNSUCCESSFUL;
        }