mirror of
https://github.com/samba-team/samba.git
synced 2025-02-02 09:47:23 +03:00
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 <vl@samba.org> Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
This commit is contained in:
parent
e166299b18
commit
6098724e8b
@ -1225,8 +1225,9 @@ const char *ReadDirName(struct smb_Dir *dir_hnd, char **ptalloced)
|
|||||||
* ignore tmp directories, see mkdir_internals()
|
* ignore tmp directories, see mkdir_internals()
|
||||||
*/
|
*/
|
||||||
if (IS_SMBD_TMPNAME(n, &unlink_flags)) {
|
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;
|
struct smb_filename *atname = NULL;
|
||||||
const char *fp = NULL;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
atname = synthetic_smb_fname(talloc_tos(),
|
atname = synthetic_smb_fname(talloc_tos(),
|
||||||
@ -1239,17 +1240,9 @@ const char *ReadDirName(struct smb_Dir *dir_hnd, char **ptalloced)
|
|||||||
TALLOC_FREE(talloced);
|
TALLOC_FREE(talloced);
|
||||||
continue;
|
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) {
|
if (unlink_flags == INT_MAX) {
|
||||||
DBG_NOTICE("ignoring %s\n", fp);
|
DBG_NOTICE("ignoring %s/%s\n", dirname, n);
|
||||||
TALLOC_FREE(atname);
|
TALLOC_FREE(atname);
|
||||||
TALLOC_FREE(talloced);
|
TALLOC_FREE(talloced);
|
||||||
continue;
|
continue;
|
||||||
@ -1259,18 +1252,23 @@ const char *ReadDirName(struct smb_Dir *dir_hnd, char **ptalloced)
|
|||||||
* We remove the stale tmpname
|
* We remove the stale tmpname
|
||||||
* as root and ignore any errors
|
* as root and ignore any errors
|
||||||
*/
|
*/
|
||||||
DBG_NOTICE("unlink stale %s\n", fp);
|
DBG_NOTICE("unlink stale %s/%s\n", dirname, n);
|
||||||
become_root();
|
become_root();
|
||||||
ret = SMB_VFS_UNLINKAT(conn,
|
ret = SMB_VFS_UNLINKAT(conn,
|
||||||
dir_hnd->fsp,
|
dirfsp,
|
||||||
atname,
|
atname,
|
||||||
unlink_flags);
|
unlink_flags);
|
||||||
unbecome_root();
|
unbecome_root();
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
DBG_NOTICE("unlinked stale %s\n", fp);
|
DBG_NOTICE("unlinked stale %s/%s\n",
|
||||||
|
dirname,
|
||||||
|
n);
|
||||||
} else {
|
} else {
|
||||||
DBG_WARNING("failed to unlink stale %s: %s\n",
|
DBG_WARNING(
|
||||||
fp, strerror(errno));
|
"failed to unlink stale %s/%s: %s\n",
|
||||||
|
dirname,
|
||||||
|
n,
|
||||||
|
strerror(errno));
|
||||||
}
|
}
|
||||||
TALLOC_FREE(atname);
|
TALLOC_FREE(atname);
|
||||||
TALLOC_FREE(talloced);
|
TALLOC_FREE(talloced);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user