vfs_fruit: move fruit_unlink_internal() back into fruit_unlinkat()
authorRalph Boehme <slow@samba.org>
Thu, 19 Mar 2020 13:07:23 +0000 (14:07 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 24 Mar 2020 19:48:40 +0000 (19:48 +0000)
I think this makes fruit_unlinkat() easier to read. No change in behaviour.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_fruit.c

index dea34bd4ba1e5b8fd7b5542ae1c59c95ff0959b8..a7c9c29b50c4976d4c98d1e83da396bfa3e1adcc 100644 (file)
@@ -1975,68 +1975,6 @@ static int fruit_unlink_rsrc(vfs_handle_struct *handle,
        return rc;
 }
 
-static int fruit_unlink_internal(vfs_handle_struct *handle,
-                       struct files_struct *dirfsp,
-                       const struct smb_filename *smb_fname)
-{
-       int rc;
-       struct fruit_config_data *config = NULL;
-       struct smb_filename *rsrc_smb_fname = NULL;
-
-       SMB_VFS_HANDLE_GET_DATA(handle, config,
-                               struct fruit_config_data, return -1);
-
-       if (is_afpinfo_stream(smb_fname->stream_name)) {
-               return fruit_unlink_meta(handle,
-                               dirfsp,
-                               smb_fname);
-       } else if (is_afpresource_stream(smb_fname->stream_name)) {
-               return fruit_unlink_rsrc(handle,
-                               dirfsp,
-                               smb_fname,
-                               false);
-       } else if (is_named_stream(smb_fname)) {
-               return SMB_VFS_NEXT_UNLINKAT(handle,
-                               dirfsp,
-                               smb_fname,
-                               0);
-       } else if (is_adouble_file(smb_fname->base_name)) {
-               return SMB_VFS_NEXT_UNLINKAT(handle,
-                               dirfsp,
-                               smb_fname,
-                               0);
-       }
-
-       /*
-        * A request to delete the base file. Because 0 byte resource
-        * fork streams are not listed by fruit_streaminfo,
-        * delete_all_streams() can't remove 0 byte resource fork
-        * streams, so we have to cleanup this here.
-        */
-       rsrc_smb_fname = synthetic_smb_fname(talloc_tos(),
-                                            smb_fname->base_name,
-                                            AFPRESOURCE_STREAM_NAME,
-                                            NULL,
-                                            smb_fname->flags);
-       if (rsrc_smb_fname == NULL) {
-               return -1;
-       }
-
-       rc = fruit_unlink_rsrc(handle, dirfsp, rsrc_smb_fname, true);
-       if ((rc != 0) && (errno != ENOENT)) {
-               DBG_ERR("Forced unlink of [%s] failed [%s]\n",
-                       smb_fname_str_dbg(rsrc_smb_fname), strerror(errno));
-               TALLOC_FREE(rsrc_smb_fname);
-               return -1;
-       }
-       TALLOC_FREE(rsrc_smb_fname);
-
-       return SMB_VFS_NEXT_UNLINKAT(handle,
-                       dirfsp,
-                       smb_fname,
-                       0);
-}
-
 static int fruit_chmod(vfs_handle_struct *handle,
                       const struct smb_filename *smb_fname,
                       mode_t mode)
@@ -2086,6 +2024,10 @@ static int fruit_unlinkat(vfs_handle_struct *handle,
                        const struct smb_filename *smb_fname,
                        int flags)
 {
+       struct fruit_config_data *config = NULL;
+       struct smb_filename *rsrc_smb_fname = NULL;
+       int ret;
+
        SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp);
 
        if (flags & AT_REMOVEDIR) {
@@ -2094,9 +2036,59 @@ static int fruit_unlinkat(vfs_handle_struct *handle,
                                             smb_fname,
                                             AT_REMOVEDIR);
        }
-       return fruit_unlink_internal(handle,
-                                    dirfsp,
-                                    smb_fname);
+
+       SMB_VFS_HANDLE_GET_DATA(handle, config,
+                               struct fruit_config_data, return -1);
+
+       if (is_afpinfo_stream(smb_fname->stream_name)) {
+               return fruit_unlink_meta(handle,
+                               dirfsp,
+                               smb_fname);
+       } else if (is_afpresource_stream(smb_fname->stream_name)) {
+               return fruit_unlink_rsrc(handle,
+                               dirfsp,
+                               smb_fname,
+                               false);
+       } else if (is_named_stream(smb_fname)) {
+               return SMB_VFS_NEXT_UNLINKAT(handle,
+                               dirfsp,
+                               smb_fname,
+                               0);
+       } else if (is_adouble_file(smb_fname->base_name)) {
+               return SMB_VFS_NEXT_UNLINKAT(handle,
+                               dirfsp,
+                               smb_fname,
+                               0);
+       }
+
+       /*
+        * A request to delete the base file. Because 0 byte resource
+        * fork streams are not listed by fruit_streaminfo,
+        * delete_all_streams() can't remove 0 byte resource fork
+        * streams, so we have to cleanup this here.
+        */
+       rsrc_smb_fname = synthetic_smb_fname(talloc_tos(),
+                                            smb_fname->base_name,
+                                            AFPRESOURCE_STREAM_NAME,
+                                            NULL,
+                                            smb_fname->flags);
+       if (rsrc_smb_fname == NULL) {
+               return -1;
+       }
+
+       ret = fruit_unlink_rsrc(handle, dirfsp, rsrc_smb_fname, true);
+       if ((ret != 0) && (errno != ENOENT)) {
+               DBG_ERR("Forced unlink of [%s] failed [%s]\n",
+                       smb_fname_str_dbg(rsrc_smb_fname), strerror(errno));
+               TALLOC_FREE(rsrc_smb_fname);
+               return -1;
+       }
+       TALLOC_FREE(rsrc_smb_fname);
+
+       return SMB_VFS_NEXT_UNLINKAT(handle,
+                       dirfsp,
+                       smb_fname,
+                       0);
 }
 
 static ssize_t fruit_pread_meta_stream(vfs_handle_struct *handle,