lib: modules: Change XXX_init interface from XXX_init(void) to XXX_init(TALLOC_CTX *)
[sfrench/samba-autobuild/.git] / source3 / modules / vfs_netatalk.c
index a4573550fad7b07d753fb967745e68c150389f3c..5715c6dd6ac24c49242427f77f1434cb9fe0b2d3 100644 (file)
@@ -177,11 +177,14 @@ static void atalk_rrmdir(TALLOC_CTX *ctx, char *path)
 
 /* Directory operations */
 
-static DIR *atalk_opendir(struct vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attr)
+static DIR *atalk_opendir(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       const char *mask,
+                       uint32_t attr)
 {
        DIR *ret = 0;
 
-       ret = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
+       ret = SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
 
        /*
         * when we try to perform delete operation upon file which has fork
@@ -198,7 +201,7 @@ static DIR *atalk_opendir(struct vfs_handle_struct *handle, const char *fname, c
        return ret;
 }
 
-static DIR *atalk_fdopendir(struct vfs_handle_struct *handle, files_struct *fsp, const char *mask, uint32 attr)
+static DIR *atalk_fdopendir(struct vfs_handle_struct *handle, files_struct *fsp, const char *mask, uint32_t attr)
 {
        DIR *ret = 0;
 
@@ -223,13 +226,15 @@ static DIR *atalk_fdopendir(struct vfs_handle_struct *handle, files_struct *fsp,
        return ret;
 }
 
-static int atalk_rmdir(struct vfs_handle_struct *handle, const char *path)
+static int atalk_rmdir(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname)
 {
        bool add = False;
        TALLOC_CTX *ctx = 0;
+       const char *path = smb_fname->base_name;
        char *dpath;
 
-       if (!handle->conn->origpath || !path) goto exit_rmdir;
+       if (!handle->conn->cwd || !path) goto exit_rmdir;
 
        /* due to there is no way to change bDeleteVetoFiles variable
         * from this module, gotta use talloc stuff..
@@ -241,14 +246,14 @@ static int atalk_rmdir(struct vfs_handle_struct *handle, const char *path)
                goto exit_rmdir;
 
        if (!(dpath = talloc_asprintf(ctx, "%s/%s%s", 
-         handle->conn->origpath, path, add ? "/"APPLEDOUBLE : "")))
+         handle->conn->cwd, path, add ? "/"APPLEDOUBLE : "")))
                goto exit_rmdir;
 
        atalk_rrmdir(ctx, dpath);
 
 exit_rmdir:
        talloc_destroy(ctx);
-       return SMB_VFS_NEXT_RMDIR(handle, path);
+       return SMB_VFS_NEXT_RMDIR(handle, smb_fname);
 }
 
 /* File operations */
@@ -272,7 +277,7 @@ static int atalk_rename(struct vfs_handle_struct *handle,
                return ret;
        }
 
-       if (atalk_build_paths(talloc_tos(), handle->conn->origpath, oldname,
+       if (atalk_build_paths(talloc_tos(), handle->conn->cwd, oldname,
                              &adbl_path, &orig_path, &adbl_info,
                              &orig_info) != 0)
                goto exit_rename;
@@ -333,7 +338,7 @@ static int atalk_unlink(struct vfs_handle_struct *handle,
                }
        }
 
-       if (atalk_build_paths(talloc_tos(), handle->conn->origpath, path,
+       if (atalk_build_paths(talloc_tos(), handle->conn->cwd, path,
                              &adbl_path, &orig_path,
                              &adbl_info, &orig_info) != 0)
                goto exit_unlink;
@@ -352,25 +357,33 @@ exit_unlink:
        return ret;
 }
 
-static int atalk_chmod(struct vfs_handle_struct *handle, const char *path, mode_t mode)
+static int atalk_chmod(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       mode_t mode)
 {
        int ret = 0;
+       int ret1 = 0;
        char *adbl_path = 0;
        char *orig_path = 0;
        SMB_STRUCT_STAT adbl_info;
        SMB_STRUCT_STAT orig_info;
        TALLOC_CTX *ctx;
 
-       ret = SMB_VFS_NEXT_CHMOD(handle, path, mode);
-
-       if (!path) return ret;
+       ret = SMB_VFS_NEXT_CHMOD(handle, smb_fname, mode);
 
        if (!(ctx = talloc_init("chmod_file")))
                return ret;
 
-       if (atalk_build_paths(ctx, handle->conn->origpath, path, &adbl_path,
-                             &orig_path, &adbl_info, &orig_info) != 0)
+       ret1 = atalk_build_paths(ctx,
+                       handle->conn->cwd,
+                       smb_fname->base_name,
+                       &adbl_path,
+                       &orig_path,
+                       &adbl_info,
+                       &orig_info);
+       if (ret1 != 0) {
                goto exit_chmod;
+       }
 
        if (!S_ISDIR(orig_info.st_ex_mode) && !S_ISREG(orig_info.st_ex_mode)) {
                DEBUG(3, ("ATALK: %s has passed..\n", orig_path));              
@@ -384,7 +397,10 @@ exit_chmod:
        return ret;
 }
 
-static int atalk_chown(struct vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
+static int atalk_chown(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
        int ret = 0;
        char *adbl_path = 0;
@@ -393,14 +409,12 @@ static int atalk_chown(struct vfs_handle_struct *handle, const char *path, uid_t
        SMB_STRUCT_STAT orig_info;
        TALLOC_CTX *ctx;
 
-       ret = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
-
-       if (!path) return ret;
+       ret = SMB_VFS_NEXT_CHOWN(handle, smb_fname, uid, gid);
 
        if (!(ctx = talloc_init("chown_file")))
                return ret;
 
-       if (atalk_build_paths(ctx, handle->conn->origpath, path,
+       if (atalk_build_paths(ctx, handle->conn->cwd, smb_fname->base_name,
                              &adbl_path, &orig_path,
                              &adbl_info, &orig_info) != 0)
                goto exit_chown;
@@ -419,7 +433,10 @@ exit_chown:
        return ret;
 }
 
-static int atalk_lchown(struct vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid)
+static int atalk_lchown(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       uid_t uid,
+                       gid_t gid)
 {
        int ret = 0;
        char *adbl_path = 0;
@@ -428,14 +445,12 @@ static int atalk_lchown(struct vfs_handle_struct *handle, const char *path, uid_
        SMB_STRUCT_STAT orig_info;
        TALLOC_CTX *ctx;
 
-       ret = SMB_VFS_NEXT_CHOWN(handle, path, uid, gid);
-
-       if (!path) return ret;
+       ret = SMB_VFS_NEXT_LCHOWN(handle, smb_fname, uid, gid);
 
        if (!(ctx = talloc_init("lchown_file")))
                return ret;
 
-       if (atalk_build_paths(ctx, handle->conn->origpath, path,
+       if (atalk_build_paths(ctx, handle->conn->cwd, smb_fname->base_name,
                              &adbl_path, &orig_path,
                              &adbl_info, &orig_info) != 0)
                goto exit_lchown;
@@ -465,8 +480,8 @@ static struct vfs_fn_pointers vfs_netatalk_fns = {
        .lchown_fn = atalk_lchown,
 };
 
-NTSTATUS vfs_netatalk_init(void);
-NTSTATUS vfs_netatalk_init(void)
+NTSTATUS vfs_netatalk_init(TALLOC_CTX *);
+NTSTATUS vfs_netatalk_init(TALLOC_CTX *ctx)
 {
        return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "netatalk",
                                &vfs_netatalk_fns);