s3-build: only include memcache.h where needed.
[metze/samba/wip.git] / source3 / smbd / vfs.c
index 7df51cff95ecb226dd98befacb9d3962ea5b3e04..d561a6b94fba84f3dd7ee40451e88cf3b5e12bee 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "includes.h"
 #include "smbd/globals.h"
+#include "memcache.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
@@ -393,7 +394,7 @@ ssize_t vfs_write_data(struct smb_request *req,
                /* VFS_RECVFILE must drain the socket
                 * before returning. */
                req->unread_bytes = 0;
-               return SMB_VFS_RECVFILE(smbd_server_fd(),
+               return SMB_VFS_RECVFILE(req->sconn->sock,
                                        fsp,
                                        (SMB_OFF_T)-1,
                                        N);
@@ -426,7 +427,7 @@ ssize_t vfs_pwrite_data(struct smb_request *req,
                /* VFS_RECVFILE must drain the socket
                 * before returning. */
                req->unread_bytes = 0;
-               return SMB_VFS_RECVFILE(smbd_server_fd(),
+               return SMB_VFS_RECVFILE(req->sconn->sock,
                                        fsp,
                                        offset,
                                        N);
@@ -707,7 +708,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);
 }
 
 /*******************************************************************