Revert "Remove the global char *LastDir."
[kamenim/samba.git] / source3 / smbd / vfs.c
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);
 }
 
 /*******************************************************************