s3-build: only include memcache.h where needed.
[nivanova/samba-autobuild/.git] / source3 / smbd / statcache.c
index 72fed008a2a5ba0dda09e7137a808b6a2d3e68e6..ecadbdcdd40104742a94661fd83d2d793c730419 100644 (file)
@@ -21,6 +21,8 @@
 */
 
 #include "includes.h"
+#include "librpc/gen_ndr/messaging.h"
+#include "memcache.h"
 
 /****************************************************************************
  Stat cache code used in unix_convert.
@@ -175,6 +177,7 @@ bool stat_cache_lookup(connection_struct *conn,
        DATA_BLOB data_val;
        char *name;
        TALLOC_CTX *ctx = talloc_tos();
+       struct smb_filename smb_fname;
 
        *pp_dirpath = NULL;
        *pp_start = *pp_name;
@@ -205,7 +208,7 @@ bool stat_cache_lookup(connection_struct *conn,
        } else {
                chk_name = talloc_strdup_upper(ctx,name);
                if (!chk_name) {
-                       DEBUG(0, ("stat_cache_lookup: strdup_upper failed!\n"));
+                       DEBUG(0, ("stat_cache_lookup: talloc_strdup_upper failed!\n"));
                        return False;
                }
 
@@ -274,7 +277,10 @@ bool stat_cache_lookup(connection_struct *conn,
                  "-> [%s]\n", chk_name, translated_path ));
        DO_PROFILE_INC(statcache_hits);
 
-       if (SMB_VFS_STAT(conn, translated_path, pst) != 0) {
+       ZERO_STRUCT(smb_fname);
+       smb_fname.base_name = translated_path;
+
+       if (SMB_VFS_STAT(conn, &smb_fname) != 0) {
                /* Discard this entry - it doesn't exist in the filesystem. */
                memcache_delete(smbd_memcache(), STAT_CACHE,
                                data_blob_const(chk_name, strlen(chk_name)));
@@ -282,6 +288,7 @@ bool stat_cache_lookup(connection_struct *conn,
                TALLOC_FREE(translated_path);
                return False;
        }
+       *pst = smb_fname.st;
 
        if (!sizechanged) {
                memcpy(*pp_name, translated_path,
@@ -330,10 +337,11 @@ bool stat_cache_lookup(connection_struct *conn,
  Tell all smbd's to delete an entry.
 **************************************************************************/
 
-void send_stat_cache_delete_message(const char *name)
+void send_stat_cache_delete_message(struct messaging_context *msg_ctx,
+                                   const char *name)
 {
 #ifdef DEVELOPER
-       message_send_all(smbd_messaging_context(),
+       message_send_all(msg_ctx,
                        MSG_SMB_STAT_CACHE_DELETE,
                        name,
                        strlen(name)+1,