]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs: Simplify fruit_unlink_rsrc_stream()
authorVolker Lendecke <vl@samba.org>
Sun, 2 Feb 2025 15:44:53 +0000 (16:44 +0100)
committerVolker Lendecke <vl@samba.org>
Tue, 2 Sep 2025 08:08:29 +0000 (08:08 +0000)
We have the dirfsp around, no need to do a full stat()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/modules/vfs_fruit.c

index 6f12c3c5d3ee9d1b8233b58391f6fadf14823da8..b274274d46c92bd22c0964248497b183c42d96a9 100644 (file)
@@ -2081,19 +2081,7 @@ static int fruit_unlink_rsrc_stream(vfs_handle_struct *handle,
        int ret;
 
        if (!force_unlink) {
-               struct smb_filename *full_fname = NULL;
-               off_t size;
-
-               /*
-                * TODO: use SMB_VFS_STATX() once we have it.
-                */
-
-               full_fname = full_path_from_dirfsp_atname(talloc_tos(),
-                                                         dirfsp,
-                                                         smb_fname);
-               if (full_fname == NULL) {
-                       return -1;
-               }
+               struct stat_ex st = {};
 
                /*
                 * 0 byte resource fork streams are not listed by
@@ -2101,18 +2089,17 @@ static int fruit_unlink_rsrc_stream(vfs_handle_struct *handle,
                 * deletion doesn't remove the resourcefork stream.
                 */
 
-               ret = SMB_VFS_NEXT_STAT(handle, full_fname);
+               ret = SMB_VFS_NEXT_FSTATAT(
+                       handle, dirfsp, smb_fname, &st, AT_SYMLINK_NOFOLLOW);
                if (ret != 0) {
-                       TALLOC_FREE(full_fname);
-                       DBG_ERR("stat [%s] failed [%s]\n",
-                               smb_fname_str_dbg(full_fname), strerror(errno));
+                       DBG_ERR("fstatat [%s%s] failed [%s]\n",
+                               dirfsp->fsp_name->base_name,
+                               smb_fname->base_name,
+                               strerror(errno));
                        return -1;
                }
 
-               size = full_fname->st.st_ex_size;
-               TALLOC_FREE(full_fname);
-
-               if (size > 0) {
+               if (st.st_ex_size > 0) {
                        /* OS X ignores resource fork stream delete requests */
                        return 0;
                }