s3/smbd: update some more DEBUG macros in smbd_smb2_create_send
[nivanova/samba-autobuild/.git] / source3 / smbd / statcache.c
index 2f7d16790d0caee200f4ebe06b7228f0d9ee8677..89a4a3d22373a40280330a9b33584a6c0ac013e3 100644 (file)
 */
 
 #include "includes.h"
+#include "../lib/util/memcache.h"
+#include "smbd/smbd.h"
+#include "messages.h"
+#include "serverid.h"
+#include "smbprofile.h"
+#include <tdb.h>
 
 /****************************************************************************
  Stat cache code used in unix_convert.
@@ -145,6 +151,7 @@ void stat_cache_add( const char *full_orig_name,
  * Look through the stat cache for an entry
  *
  * @param conn    A connection struct to do the stat() with.
+ * @param posix_paths Whether to lookup using stat() or lstat()
  * @param name    The path we are attempting to cache, modified by this routine
  *                to be correct as far as the cache can tell us. We assume that
  *               it is a talloc'ed string from top of stack, we free it if
@@ -161,6 +168,7 @@ void stat_cache_add( const char *full_orig_name,
  */
 
 bool stat_cache_lookup(connection_struct *conn,
+                       bool posix_paths,
                        char **pp_name,
                        char **pp_dirpath,
                        char **pp_start,
@@ -175,6 +183,8 @@ bool stat_cache_lookup(connection_struct *conn,
        DATA_BLOB data_val;
        char *name;
        TALLOC_CTX *ctx = talloc_tos();
+       struct smb_filename smb_fname;
+       int ret;
 
        *pp_dirpath = NULL;
        *pp_start = *pp_name;
@@ -274,7 +284,16 @@ 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 (posix_paths) {
+               ret = SMB_VFS_LSTAT(conn, &smb_fname);
+       } else {
+               ret = SMB_VFS_STAT(conn, &smb_fname);
+       }
+
+       if (ret != 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 +301,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 +350,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 smbd_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,