From: Jeremy Allison Date: Wed, 16 Jun 2021 22:10:37 +0000 (-0700) Subject: s3: smbd: Optimization in non_widelink_open(). Don't need to vfs_ChDir(parent_dir_fna... X-Git-Tag: tevent-0.11.0~323 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ae2d4e4d0fa3403bd571dbbbbf01cf84ddfa8f2;p=thirdparty%2Fsamba.git s3: smbd: Optimization in non_widelink_open(). Don't need to vfs_ChDir(parent_dir_fname) if parent is "." 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 --- 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. */