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>
Wed, 10 Mar 2010 12:22:08 +0000 (13:22 +0100)
source3/modules/gpfs.c
source3/modules/vfs_gpfs.c
source3/modules/vfs_gpfs.h

index a8b5576122a4ae594bdc6e93976423b9a4f2d0d1..20a26bcb44165361f12387fdf48442f05d6a9bd2 100644 (file)
@@ -28,6 +28,7 @@ static bool gpfs_share_modes;
 static bool gpfs_leases;
 static bool gpfs_getrealfilename;
 static bool gpfs_winattr;
+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);
@@ -38,6 +39,7 @@ static int (*gpfs_get_realfilename_path_fn)(char *pathname, char *filenamep,
 static int (*gpfs_set_winattrs_path_fn)(char *pathname, int flags, struct gpfs_winattr *attrs);
 static int (*gpfs_get_winattrs_path_fn)(char *pathname, struct gpfs_winattr *attrs);
 static int (*gpfs_get_winattrs_fn)(int fd, struct gpfs_winattr *attrs);
+static int (*gpfs_ftruncate_fn)(int fd, gpfs_off64_t length);
 
 
 bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
@@ -141,6 +143,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)
 {
@@ -248,12 +260,14 @@ void init_gpfs(void)
         init_gpfs_function(&gpfs_set_winattrs_path_fn,"gpfs_set_winattrs_path");
         init_gpfs_function(&gpfs_get_winattrs_fn,"gpfs_get_winattrs");
 
+        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_winattr = lp_parm_bool(-1, "gpfs", "winattr", False);
+       gpfs_do_ftruncate = lp_parm_bool(-1, "gpfs", "ftruncate", True);
 
        return;
 }
index a3088a9644dc9a2704dfd7c2c13f460cfef05a22..97f80d7c0900681f833035719c46e4cd6196a8de 100644 (file)
@@ -1030,6 +1030,18 @@ static int vfs_gpfs_lstat(struct vfs_handle_struct *handle, const char *path,
        return 0;
 }
 
+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[] = {
@@ -1108,6 +1120,10 @@ static vfs_op_tuple gpfs_op_tuples[] = {
 
         { SMB_VFS_OP(vfs_gpfs_lstat),
           SMB_VFS_OP_LSTAT,
+         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 d2899b5bc910cee85ee6fbd20e6a2fbd2a753106..0fccceb059e575f834dc71e6886e34c801575379 100644 (file)
@@ -34,4 +34,5 @@ int smbd_gpfs_get_realfilename_path(char *pathname, char *filenamep,
 int smbd_fget_gpfs_winattrs(int fd, struct gpfs_winattr *attrs);
 int get_gpfs_winattrs(char * pathname,struct gpfs_winattr *attrs);
 int set_gpfs_winattrs(char * pathname,int flags,struct gpfs_winattr *attrs);
+int smbd_gpfs_ftrunctate(int fd, gpfs_off64_t length);
 void init_gpfs(void);