s3: VFS: Change SMB_VFS_SYMLINK to use const struct smb_filename * instead of const...
[sfrench/samba-autobuild/.git] / source3 / modules / vfs_syncops.c
index 99f6178457bbb80dbf867cd23681ff68c5055b62..f94588c60ed09edfe2b8f0feb320678613ab82b6 100644 (file)
@@ -108,19 +108,6 @@ static void syncops_two_names(const char *name1, const char *name2)
        talloc_free(tmp_ctx);
 }
 
-/*
-  sync two meta data changes for 1 names
- */
-static void syncops_name(const char *name)
-{
-       char *parent;
-       parent = parent_dir(NULL, name);
-       if (parent) {
-               syncops_sync_directory(parent);
-               talloc_free(parent);
-       }
-}
-
 /*
   sync two meta data changes for 1 names
  */
@@ -158,20 +145,6 @@ static int syncops_rename(vfs_handle_struct *handle,
        return ret;
 }
 
-/* handle the rest with a macro */
-#define SYNCOPS_NEXT(op, fname, args) do {   \
-       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->onmeta && !config->disable  \
-               && fname) syncops_name(fname); \
-       return ret; \
-} while (0)
-
 #define SYNCOPS_NEXT_SMB_FNAME(op, fname, args) do {   \
        int ret; \
        struct syncops_config_data *config; \
@@ -186,15 +159,41 @@ static int syncops_rename(vfs_handle_struct *handle,
 } while (0)
 
 static int syncops_symlink(vfs_handle_struct *handle,
-                          const char *oldname, const char *newname)
+                       const char *link_contents,
+                       const struct smb_filename *new_smb_fname)
 {
-       SYNCOPS_NEXT(SYMLINK, newname, (handle, oldname, newname));
+       int ret;
+       struct syncops_config_data *config;
+
+       SMB_VFS_HANDLE_GET_DATA(handle, config,
+                               struct syncops_config_data,
+                               return -1);
+
+       ret = SMB_VFS_NEXT_SYMLINK(handle, link_contents, new_smb_fname);
+       if (ret == 0 && config->onmeta && !config->disable) {
+               syncops_two_names(link_contents,
+                                 new_smb_fname->base_name);
+       }
+       return ret;
 }
 
 static int syncops_link(vfs_handle_struct *handle,
-                        const char *oldname, const char *newname)
+                       const struct smb_filename *old_smb_fname,
+                       const struct smb_filename *new_smb_fname)
 {
-       SYNCOPS_NEXT(LINK, newname, (handle, oldname, newname));
+       int ret;
+       struct syncops_config_data *config;
+
+       SMB_VFS_HANDLE_GET_DATA(handle, config,
+                               struct syncops_config_data,
+                               return -1);
+
+       ret = SMB_VFS_NEXT_LINK(handle, old_smb_fname, new_smb_fname);
+       if (ret == 0 && config->onmeta && !config->disable) {
+               syncops_two_names(old_smb_fname->base_name,
+                                 new_smb_fname->base_name);
+       }
+       return ret;
 }
 
 static int syncops_open(vfs_handle_struct *handle,
@@ -212,19 +211,25 @@ static int syncops_unlink(vfs_handle_struct *handle,
 }
 
 static int syncops_mknod(vfs_handle_struct *handle,
-                        const char *fname, mode_t mode, SMB_DEV_T dev)
+                       const struct smb_filename *smb_fname,
+                       mode_t mode,
+                       SMB_DEV_T dev)
 {
-        SYNCOPS_NEXT(MKNOD, fname, (handle, fname, mode, dev));
+        SYNCOPS_NEXT_SMB_FNAME(MKNOD,
+                       smb_fname, (handle, smb_fname, mode, dev));
 }
 
-static int syncops_mkdir(vfs_handle_struct *handle,  const char *fname, mode_t mode)
+static int syncops_mkdir(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       mode_t mode)
 {
-        SYNCOPS_NEXT(MKDIR, fname, (handle, fname, mode));
+        SYNCOPS_NEXT_SMB_FNAME(MKDIR, smb_fname, (handle, smb_fname, mode));
 }
 
-static int syncops_rmdir(vfs_handle_struct *handle,  const char *fname)
+static int syncops_rmdir(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname)
 {
-        SYNCOPS_NEXT(RMDIR, fname, (handle, fname));
+        SYNCOPS_NEXT_SMB_FNAME(RMDIR, smb_fname, (handle, smb_fname));
 }
 
 /* close needs to be handled specially */
@@ -292,7 +297,7 @@ static struct vfs_fn_pointers vfs_syncops_fns = {
 };
 
 static_decl_vfs;
-NTSTATUS vfs_syncops_init(void)
+NTSTATUS vfs_syncops_init(TALLOC_CTX *ctx)
 {
        NTSTATUS ret;