From: Jeremy Allison Date: Thu, 28 Jul 2022 19:23:36 +0000 (-0700) Subject: s3: smbd: Convert smb_set_file_unix_hlink() to use filename_convert_dirfsp(). X-Git-Tag: samba-4.17.0rc1~128 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3b3cab818842c8768b3ae3e5c30d01cce925b9e7;p=thirdparty%2Fsamba.git s3: smbd: Convert smb_set_file_unix_hlink() to use filename_convert_dirfsp(). 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 Reviewed-by: Volker Lendecke --- diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c index e35dd29543c..f465694a0bf 100644 --- a/source3/smbd/smb2_trans2.c +++ b/source3/smbd/smb2_trans2.c @@ -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);