]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Optimization in non_widelink_open(). Don't need to vfs_ChDir(parent_dir_fna...
authorJeremy Allison <jra@samba.org>
Wed, 16 Jun 2021 22:10:37 +0000 (15:10 -0700)
committerRalph Boehme <slow@samba.org>
Fri, 18 Jun 2021 17:21:31 +0000 (17:21 +0000)
Save several system calls if we're operating at the root of the share.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Fri Jun 18 17:21:31 UTC 2021 on sn-devel-184

source3/smbd/open.c

index 3d7fea752528448eb6426eb6d843cc1eddbf3266..9527b939f880e3e4ef9b175ca7a07ae2770e1550 100644 (file)
@@ -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. */