s3:vfs_gpfs: make "gpfs:ftruncate" a per share option
authorStefan Metzmacher <metze@samba.org>
Thu, 22 Dec 2011 14:54:41 +0000 (15:54 +0100)
committerChristian Ambach <ambi@samba.org>
Fri, 10 Feb 2012 16:54:10 +0000 (17:54 +0100)
metze

Signed-off-by: Christian Ambach <ambi@samba.org>
source3/modules/gpfs.c
source3/modules/vfs_gpfs.c

index b31d9b0d53e4677d0d8f61032d29b9b6207b616d..57a5a0c9fb9d0b8d5fd48c65675057f3999fe459 100644 (file)
@@ -26,7 +26,6 @@
 #include "vfs_gpfs.h"
 
 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);
@@ -135,7 +134,7 @@ int smbd_gpfs_putacl(char *pathname, int flags, void *acl)
 
 int smbd_gpfs_ftruncate(int fd, gpfs_off64_t length)
 {
-       if (!gpfs_do_ftruncate || (gpfs_ftruncate_fn == NULL)) {
+       if (gpfs_ftruncate_fn == NULL) {
                errno = ENOSYS;
                return -1;
        }
@@ -265,7 +264,6 @@ void init_gpfs(void)
 
        gpfs_getrealfilename = lp_parm_bool(-1, "gpfs", "getrealfilename",
                                            True);
-       gpfs_do_ftruncate = lp_parm_bool(-1, "gpfs", "ftruncate", True);
 
        return;
 }
index 0f084f8578a36eb64da47d79670523fb8159f550..088d8c0d6bf5405d184f225dafa69747c83f4bf4 100644 (file)
@@ -40,6 +40,7 @@ struct gpfs_config_data {
        bool hsm;
        bool syncio;
        bool winattr;
+       bool ftruncate;
 };
 
 
@@ -1246,6 +1247,15 @@ static int vfs_gpfs_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
                                SMB_OFF_T len)
 {
        int result;
+       struct gpfs_config_data *config;
+
+       SMB_VFS_HANDLE_GET_DATA(handle, config,
+                               struct gpfs_config_data,
+                               return -1);
+
+       if (!config->ftruncate) {
+               return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
+       }
 
        result = smbd_gpfs_ftruncate(fsp->fh->fd, len);
        if ((result == -1) && (errno == ENOSYS)) {
@@ -1350,6 +1360,9 @@ int vfs_gpfs_connect(struct vfs_handle_struct *handle, const char *service,
        config->winattr = lp_parm_bool(SNUM(handle->conn), "gpfs",
                                       "winattr", false);
 
+       config->ftruncate = lp_parm_bool(SNUM(handle->conn), "gpfs",
+                                        "ftruncate", true);
+
        SMB_VFS_HANDLE_SET_DATA(handle, config,
                                NULL, struct gpfs_config_data,
                                return -1);