Revert "Remove the global char *LastDir."
authorJeremy Allison <jra@samba.org>
Tue, 13 Jul 2010 16:30:35 +0000 (09:30 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 13 Jul 2010 16:30:35 +0000 (09:30 -0700)
Volker pointed out I'd missed the "last directory" cache
part of this code. Return us to caching the directory we're
in (reduces sys call load).

Mea maxima culpa.

Jeremy.

This reverts commit 2f30aea3324f32f9b8555e961256fc1280da2871.

source3/smbd/globals.c
source3/smbd/globals.h
source3/smbd/vfs.c

index 5df835d1aa50fe9c3c022d9a263d193acc91dcd1..324d13a23941ec06c859d26837f01f89b73f1633 100644 (file)
@@ -105,6 +105,7 @@ int conn_ctx_stack_ndx = 0;
 
 struct vfs_init_function_entry *backends = NULL;
 char *sparse_buf = NULL;
+char *LastDir = NULL;
 
 /* Current number of oplocks we have outstanding. */
 int32_t exclusive_oplocks_open = 0;
index 9d9688f8a997514b78c1847224c71a2331cafe59..c618efad052dfd4dbfccceaf4f64bb4e14c210a3 100644 (file)
@@ -115,6 +115,7 @@ extern int conn_ctx_stack_ndx;
 struct vfs_init_function_entry;
 extern struct vfs_init_function_entry *backends;
 extern char *sparse_buf;
+extern char *LastDir;
 
 /* Current number of oplocks we have outstanding. */
 extern int32_t exclusive_oplocks_open;
index 7df51cff95ecb226dd98befacb9d3962ea5b3e04..d4e9f02a69de1629630b2d7006d315b72f967fbc 100644 (file)
@@ -707,7 +707,26 @@ const char *vfs_readdirname(connection_struct *conn, void *p,
 
 int vfs_ChDir(connection_struct *conn, const char *path)
 {
-       return SMB_VFS_CHDIR(conn,path);
+       int res;
+
+       if (!LastDir) {
+               LastDir = SMB_STRDUP("");
+       }
+
+       if (strcsequal(path,"."))
+               return(0);
+
+       if (*path == '/' && strcsequal(LastDir,path))
+               return(0);
+
+       DEBUG(4,("vfs_ChDir to %s\n",path));
+
+       res = SMB_VFS_CHDIR(conn,path);
+       if (!res) {
+               SAFE_FREE(LastDir);
+               LastDir = SMB_STRDUP(path);
+       }
+       return(res);
 }
 
 /*******************************************************************