]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Convert smb_set_file_unix_hlink() to use filename_convert_dirfsp().
authorJeremy Allison <jra@samba.org>
Thu, 28 Jul 2022 19:23:36 +0000 (12:23 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 2 Aug 2022 19:49:32 +0000 (19:49 +0000)
One less use of filename_convert().

Later we should optimize this by passing in
the src_dirfsp from the caller.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/smbd/smb2_trans2.c

index e35dd29543c9e2057cd95e1eac2e4384c2cc5fd3..f465694a0bf4331613467a693b19a1256aeb4780 100644 (file)
@@ -4875,8 +4875,10 @@ static NTSTATUS smb_set_file_unix_hlink(connection_struct *conn,
                                        struct smb_filename *smb_fname_new)
 {
        char *oldname = NULL;
+       struct files_struct *src_dirfsp = NULL;
        struct smb_filename *smb_fname_old = NULL;
        uint32_t ucf_flags = ucf_flags_from_smb_request(req);
+       NTTIME old_twrp = 0;
        TALLOC_CTX *ctx = talloc_tos();
        NTSTATUS status = NT_STATUS_OK;
 
@@ -4911,12 +4913,16 @@ static NTSTATUS smb_set_file_unix_hlink(connection_struct *conn,
        DEBUG(10,("smb_set_file_unix_hlink: SMB_SET_FILE_UNIX_LINK doing hard link %s -> %s\n",
                smb_fname_str_dbg(smb_fname_new), oldname));
 
-       status = filename_convert(ctx,
-                               conn,
-                               oldname,
-                               ucf_flags,
-                               0,
-                               &smb_fname_old);
+       if (ucf_flags & UCF_GMT_PATHNAME) {
+               extract_snapshot_token(oldname, &old_twrp);
+       }
+       status = filename_convert_dirfsp(ctx,
+                                        conn,
+                                        oldname,
+                                        ucf_flags,
+                                        old_twrp,
+                                        &src_dirfsp,
+                                        &smb_fname_old);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -4925,7 +4931,7 @@ static NTSTATUS smb_set_file_unix_hlink(connection_struct *conn,
                                  conn,
                                  req,
                                  false,
-                                 NULL, /* old_dirfsp */
+                                 src_dirfsp,
                                  smb_fname_old,
                                  NULL, /* new_dirfsp */
                                  smb_fname_new);