From: Volker Lendecke Date: Thu, 5 Dec 2024 10:37:15 +0000 (+0100) Subject: smbd: Simplify ReadDirName() X-Git-Tag: tdb-1.4.13~298 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6098724e8b8e815e10d08e2f892e2897fa9ecd18;p=thirdparty%2Fsamba.git smbd: Simplify ReadDirName() "fp" is only used for DBG messages where I don't think we need the full accuracy of full_path_from_dirfsp_at_basename(). Save a talloc. Signed-off-by: Volker Lendecke Reviewed-by: Pavel Filipenský --- diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index 8ec2b8b4ea3..0a67364a56a 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -1225,8 +1225,9 @@ const char *ReadDirName(struct smb_Dir *dir_hnd, char **ptalloced) * ignore tmp directories, see mkdir_internals() */ if (IS_SMBD_TMPNAME(n, &unlink_flags)) { + struct files_struct *dirfsp = dir_hnd->fsp; + const char *dirname = dirfsp->fsp_name->base_name; struct smb_filename *atname = NULL; - const char *fp = NULL; int ret; atname = synthetic_smb_fname(talloc_tos(), @@ -1239,17 +1240,9 @@ const char *ReadDirName(struct smb_Dir *dir_hnd, char **ptalloced) TALLOC_FREE(talloced); continue; } - fp = full_path_from_dirfsp_at_basename(atname, - dir_hnd->fsp, - n); - if (fp == NULL) { - TALLOC_FREE(atname); - TALLOC_FREE(talloced); - continue; - } if (unlink_flags == INT_MAX) { - DBG_NOTICE("ignoring %s\n", fp); + DBG_NOTICE("ignoring %s/%s\n", dirname, n); TALLOC_FREE(atname); TALLOC_FREE(talloced); continue; @@ -1259,18 +1252,23 @@ const char *ReadDirName(struct smb_Dir *dir_hnd, char **ptalloced) * We remove the stale tmpname * as root and ignore any errors */ - DBG_NOTICE("unlink stale %s\n", fp); + DBG_NOTICE("unlink stale %s/%s\n", dirname, n); become_root(); ret = SMB_VFS_UNLINKAT(conn, - dir_hnd->fsp, + dirfsp, atname, unlink_flags); unbecome_root(); if (ret == 0) { - DBG_NOTICE("unlinked stale %s\n", fp); + DBG_NOTICE("unlinked stale %s/%s\n", + dirname, + n); } else { - DBG_WARNING("failed to unlink stale %s: %s\n", - fp, strerror(errno)); + DBG_WARNING( + "failed to unlink stale %s/%s: %s\n", + dirname, + n, + strerror(errno)); } TALLOC_FREE(atname); TALLOC_FREE(talloced);