]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Pass fsp instead of filename for parent to file_set_dosmode
authorVolker Lendecke <vl@samba.org>
Wed, 17 Sep 2025 13:46:51 +0000 (06:46 -0700)
committerRalph Boehme <slow@samba.org>
Tue, 21 Oct 2025 17:33:29 +0000 (17:33 +0000)
Avoids a call to PARENT_PATHNAME in copy_internals()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/dosmode.c
source3/smbd/open.c
source3/smbd/proto.h
source3/smbd/smb2_nttrans.c

index 331eac83ab80d132a6dba1adbc8c9c87a72d3075..3eed2bd362abf7f44db654fcfcfb83bae3e86e66 100644 (file)
@@ -924,7 +924,7 @@ NTSTATUS dos_mode_at_recv(struct tevent_req *req, uint32_t *dosmode)
 int file_set_dosmode(connection_struct *conn,
                     struct smb_filename *smb_fname,
                     uint32_t dosmode,
-                    struct smb_filename *parent_dir,
+                    struct files_struct *dirfsp,
                     bool newfile)
 {
        int mask=0;
@@ -995,11 +995,7 @@ int file_set_dosmode(connection_struct *conn,
        }
 
        /* Fall back to UNIX modes. */
-       unixmode = unix_mode(
-               conn,
-               dosmode,
-               smb_fname,
-               parent_dir != NULL ? parent_dir->fsp : NULL);
+       unixmode = unix_mode(conn, dosmode, smb_fname, dirfsp);
 
        /* preserve the file type bits */
        mask |= S_IFMT;
index a26cf653612ac04c0ee0c382999efc41b03e5b27..e62206c71e6da937221392699099ede445a86155 100644 (file)
@@ -3538,7 +3538,7 @@ static void possibly_set_archive(struct connection_struct *conn,
        ret = file_set_dosmode(conn,
                               smb_fname,
                               dosattrs | FILE_ATTRIBUTE_ARCHIVE,
-                              parent_dir_fname,
+                              parent_dir_fname->fsp,
                               true);
        if (ret != 0) {
                return;
@@ -4664,7 +4664,7 @@ mkdir_first:
                file_set_dosmode(conn,
                                 smb_dname,
                                 file_attributes | FILE_ATTRIBUTE_DIRECTORY,
-                                parent_dir_fname,
+                                parent_dir_fname->fsp,
                                 true);
        }
 
index 3529274c833248f5b505b3a89580b69187179b3a..853eb0e00b138b4d1616701524c7a44676f68a33 100644 (file)
@@ -221,7 +221,7 @@ NTSTATUS dos_mode_at_recv(struct tevent_req *req, uint32_t *dosmode);
 int file_set_dosmode(connection_struct *conn,
                     struct smb_filename *smb_fname,
                     uint32_t dosmode,
-                    struct smb_filename *parent_dir,
+                    struct files_struct *dirfsp,
                     bool newfile);
 NTSTATUS file_set_sparse(connection_struct *conn,
                         struct files_struct *fsp,
index 17eeb93fa366dc83af61aeb6bd6e4f49813645ea..32ec5a9b5c890499b571657743f57d229c5b52e0 100644 (file)
@@ -286,7 +286,6 @@ NTSTATUS copy_internals(TALLOC_CTX *ctx,
        int info;
        off_t ret=-1;
        NTSTATUS status = NT_STATUS_OK;
-       struct smb_filename *parent = NULL;
 
        if (!CAN_WRITE(conn)) {
                status = NT_STATUS_MEDIA_WRITE_PROTECTED;
@@ -404,18 +403,10 @@ NTSTATUS copy_internals(TALLOC_CTX *ctx,
           creates the file. This isn't the correct thing to do in the copy
           case. JRA */
 
-       status = SMB_VFS_PARENT_PATHNAME(conn,
-                                        talloc_tos(),
-                                        smb_fname_dst,
-                                        &parent,
-                                        NULL);
-       if (!NT_STATUS_IS_OK(status)) {
-               goto out;
-       }
        if (smb_fname_dst->fsp == NULL) {
                struct smb_filename *pathref = NULL;
 
-               status = synthetic_pathref(parent,
+               status = synthetic_pathref(ctx,
                                        conn->cwd_fsp,
                                        smb_fname_dst->base_name,
                                        smb_fname_dst->stream_name,
@@ -426,16 +417,15 @@ NTSTATUS copy_internals(TALLOC_CTX *ctx,
 
                /* should we handle NT_STATUS_OBJECT_NAME_NOT_FOUND specially here ???? */
                if (!NT_STATUS_IS_OK(status)) {
-                       TALLOC_FREE(parent);
                        goto out;
                }
-               file_set_dosmode(conn, pathref, fattr, parent, false);
+               file_set_dosmode(conn, pathref, fattr, dst_dirfsp, false);
                smb_fname_dst->st.st_ex_mode = pathref->st.st_ex_mode;
                TALLOC_FREE(pathref);
        } else {
-               file_set_dosmode(conn, smb_fname_dst, fattr, parent, false);
+               file_set_dosmode(
+                       conn, smb_fname_dst, fattr, dst_dirfsp, false);
        }
-       TALLOC_FREE(parent);
 
        if (ret < (off_t)smb_fname_src->st.st_ex_size) {
                status = NT_STATUS_DISK_FULL;