s3:vfs:syncops add option to disable module per share
authorChristian Ambach <christian.ambach@de.ibm.com>
Thu, 7 Oct 2010 14:56:19 +0000 (16:56 +0200)
committerVolker Lendecke <vlendec@samba.org>
Wed, 13 Oct 2010 12:53:16 +0000 (12:53 +0000)
add an option to disable the syncops module completely for a
share with
  syncops:disable = true

source3/modules/vfs_syncops.c

index 3f52741009f917a3b7ca6773652281848db2c5e1..2b7c2a34dac343cc95b731dacab732d4b37b3758 100644 (file)
      syncops:onclose = no
   that can be set either globally or per share.
 
+  you can also disable the module completely for a service with
+     syncops:disable = true
+
  */
 
 struct syncops_config_data {
        bool onclose;
+       bool disable;
 };
 
 /*
@@ -129,8 +133,16 @@ static int syncops_rename(vfs_handle_struct *handle,
                          const struct smb_filename *smb_fname_src,
                          const struct smb_filename *smb_fname_dst)
 {
-       int ret = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
-       if (ret == 0) {
+
+       int ret;
+       struct syncops_config_data *config;
+
+       SMB_VFS_HANDLE_GET_DATA(handle, config,
+                               struct syncops_config_data,
+                               return -1);
+
+       ret = SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst);
+       if (ret == 0 && !config->disable) {
                syncops_two_names(smb_fname_src->base_name,
                                  smb_fname_dst->base_name);
        }
@@ -139,14 +151,28 @@ static int syncops_rename(vfs_handle_struct *handle,
 
 /* handle the rest with a macro */
 #define SYNCOPS_NEXT(op, fname, args) do {   \
-       int ret = SMB_VFS_NEXT_ ## op args; \
-       if (ret == 0 && fname) syncops_name(fname); \
+       int ret; \
+       struct syncops_config_data *config; \
+       SMB_VFS_HANDLE_GET_DATA(handle, config, \
+                               struct syncops_config_data, \
+                               return -1); \
+       ret = SMB_VFS_NEXT_ ## op args; \
+       if (ret == 0 \
+               && !config->disable \
+               && fname) syncops_name(fname); \
        return ret; \
 } while (0)
 
 #define SYNCOPS_NEXT_SMB_FNAME(op, fname, args) do {   \
-       int ret = SMB_VFS_NEXT_ ## op args; \
-       if (ret == 0 && fname) syncops_smb_fname(fname); \
+       int ret; \
+       struct syncops_config_data *config; \
+       SMB_VFS_HANDLE_GET_DATA(handle, config, \
+                               struct syncops_config_data, \
+                               return -1); \
+       ret = SMB_VFS_NEXT_ ## op args; \
+       if (ret == 0 \
+       && !config->disable \
+       && fname) syncops_smb_fname(fname); \
        return ret; \
 } while (0)
 
@@ -229,6 +255,9 @@ int syncops_connect(struct vfs_handle_struct *handle, const char *service,
        config->onclose = lp_parm_bool(SNUM(handle->conn), "syncops",
                                        "onclose", true);
 
+       config->disable = lp_parm_bool(SNUM(handle->conn), "syncops",
+                                       "disable", false);
+
        SMB_VFS_HANDLE_SET_DATA(handle, config,
                                NULL, struct syncops_config_data,
                                return -1);