From 5ae2d4e4d0fa3403bd571dbbbbf01cf84ddfa8f2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 16 Jun 2021 15:10:37 -0700 Subject: [PATCH] s3: smbd: Optimization in non_widelink_open(). Don't need to vfs_ChDir(parent_dir_fname) if parent is "." MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Save several system calls if we're operating at the root of the share. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme Autobuild-User(master): Ralph Böhme Autobuild-Date(master): Fri Jun 18 17:21:31 UTC 2021 on sn-devel-184 --- source3/smbd/open.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 3d7fea75252..9527b939f88 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -703,16 +703,18 @@ static NTSTATUS non_widelink_open(const struct files_struct *dirfsp, } } - oldwd_fname = vfs_GetWd(talloc_tos(), conn); - if (oldwd_fname == NULL) { - status = map_nt_error_from_unix(errno); - goto out; - } + if (!ISDOT(parent_dir_fname->base_name)) { + oldwd_fname = vfs_GetWd(talloc_tos(), conn); + if (oldwd_fname == NULL) { + status = map_nt_error_from_unix(errno); + goto out; + } - /* Pin parent directory in place. */ - if (vfs_ChDir(conn, parent_dir_fname) == -1) { - status = map_nt_error_from_unix(errno); - goto out; + /* Pin parent directory in place. */ + if (vfs_ChDir(conn, parent_dir_fname) == -1) { + status = map_nt_error_from_unix(errno); + goto out; + } } /* Ensure the relative path is below the share. */ -- 2.47.2