s3:gpfs: Add support for the gpfs_ftruncate call
authorVolker Lendecke <vl@samba.org>
Tue, 15 Sep 2009 00:19:14 +0000 (02:19 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 15 Sep 2009 14:53:15 +0000 (16:53 +0200)
source/modules/gpfs.c
source/modules/vfs_gpfs.c
source/modules/vfs_gpfs.h

index 96bce00ec45b41b4ef3d7de4f01a36355ceb2b7f..e15440239a08763a0faee06d845503861692762a 100644 (file)
@@ -27,6 +27,7 @@
 static bool gpfs_share_modes;
 static bool gpfs_leases;
 static bool gpfs_getrealfilename;
+static bool gpfs_do_ftruncate;
 
 static int (*gpfs_set_share_fn)(int fd, unsigned int allow, unsigned int deny);
 static int (*gpfs_set_lease_fn)(int fd, unsigned int leaseType);
@@ -34,6 +35,7 @@ static int (*gpfs_getacl_fn)(char *pathname, int flags, void *acl);
 static int (*gpfs_putacl_fn)(char *pathname, int flags, void *acl);
 static int (*gpfs_get_realfilename_path_fn)(char *pathname, char *filenamep,
                                            int *buflen);
+static int (*gpfs_ftruncate_fn)(int fd, gpfs_off64_t length);
 
 
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
@@ -137,6 +139,16 @@ int smbd_gpfs_putacl(char *pathname, int flags, void *acl)
        return gpfs_putacl_fn(pathname, flags, acl);
 }
 
+int smbd_gpfs_ftrunctate(int fd, gpfs_off64_t length)
+{
+       if (!gpfs_do_ftruncate || (gpfs_ftruncate_fn == NULL)) {
+               errno = ENOSYS;
+               return -1;
+       }
+
+       return gpfs_ftruncate_fn(fd, length);
+}
+
 int smbd_gpfs_get_realfilename_path(char *pathname, char *filenamep,
                                    int *buflen)
 {
@@ -207,11 +219,13 @@ void init_gpfs(void)
        init_gpfs_function(&gpfs_putacl_fn, "gpfs_putacl");
        init_gpfs_function(&gpfs_get_realfilename_path_fn,
                           "gpfs_get_realfilename_path");
+        init_gpfs_function(&gpfs_ftruncate_fn,"gpfs_ftruncate");
 
        gpfs_share_modes = lp_parm_bool(-1, "gpfs", "sharemodes", True);
        gpfs_leases      = lp_parm_bool(-1, "gpfs", "leases", True);
        gpfs_getrealfilename = lp_parm_bool(-1, "gpfs", "getrealfilename",
                                            True);
+       gpfs_do_ftruncate = lp_parm_bool(-1, "gpfs", "ftruncate", True);
 
        return;
 }
index 0b1f52cb0347f96d8b03650b119ca1ac9920069b..9e6f6ed918017583fd2fb1915022a6635d2f1f74 100644 (file)
@@ -888,6 +888,18 @@ static int vfs_gpfs_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t
                 return rc;
 }
 
+static int vfs_gpfs_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
+                             SMB_OFF_T len)
+{
+       int result;
+
+       result = smbd_gpfs_ftrunctate(fsp->fh->fd, len);
+       if ((result == -1) && (errno == ENOSYS)) {
+               return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
+       }
+       return result;
+}
+
 /* VFS operations structure */
 
 static vfs_op_tuple gpfs_op_tuples[] = {
@@ -952,6 +964,10 @@ static vfs_op_tuple gpfs_op_tuples[] = {
          SMB_VFS_OP_CLOSE,
          SMB_VFS_LAYER_TRANSPARENT },
 
+        { SMB_VFS_OP(vfs_gpfs_ftruncate),
+          SMB_VFS_OP_FTRUNCATE,
+          SMB_VFS_LAYER_TRANSPARENT },
+
         { SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP }
 
 };
index 3c499b0850b5ed1b37d13bd36b7e396f0253e2c4..a100bef3e87e647bf8624e79f35d8aa3d2d6e819 100644 (file)
@@ -29,4 +29,5 @@ bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
 int set_gpfs_lease(int fd, int leasetype);
 int smbd_gpfs_getacl(char *pathname, int flags, void *acl);
 int smbd_gpfs_putacl(char *pathname, int flags, void *acl);
+int smbd_gpfs_ftrunctate(int fd, gpfs_off64_t length);
 void init_gpfs(void);