smbd: Make get_real_filename_cache_key() static in files.c
authorVolker Lendecke <vl@samba.org>
Sat, 4 Nov 2023 15:17:36 +0000 (16:17 +0100)
committerVolker Lendecke <vl@samba.org>
Tue, 7 Nov 2023 13:58:07 +0000 (13:58 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Nov  7 13:58:07 UTC 2023 on atb-devel-224

source3/smbd/filename.c
source3/smbd/files.c
source3/smbd/proto.h

index 91d16e074953ecbc7eadeca996d9de5fba84f645..5219fcd721eeda4824395556467d9df5d79a1f0c 100644 (file)
@@ -404,52 +404,6 @@ NTSTATUS get_real_filename_at(struct files_struct *dirfsp,
        return status;
 }
 
-/*
- * Create the memcache-key for GETREALFILENAME_CACHE: This supplements
- * the stat cache for the last component to be looked up. Cache
- * contents is the correctly capitalized translation of the parameter
- * "name" as it exists on disk. This is indexed by inode of the dirfsp
- * and name, and contrary to stat_cahce_lookup() it does not
- * vfs_stat() the last component. This will be taken care of by an
- * attempt to do a openat_pathref_fsp().
- */
-bool get_real_filename_cache_key(TALLOC_CTX *mem_ctx,
-                                struct files_struct *dirfsp,
-                                const char *name,
-                                DATA_BLOB *_key)
-{
-       struct file_id fid = vfs_file_id_from_sbuf(
-               dirfsp->conn, &dirfsp->fsp_name->st);
-       char *upper = NULL;
-       uint8_t *key = NULL;
-       size_t namelen, keylen;
-
-       upper = talloc_strdup_upper(mem_ctx, name);
-       if (upper == NULL) {
-               return false;
-       }
-       namelen = talloc_get_size(upper);
-
-       keylen = namelen + sizeof(fid);
-       if (keylen < sizeof(fid)) {
-               TALLOC_FREE(upper);
-               return false;
-       }
-
-       key = talloc_size(mem_ctx, keylen);
-       if (key == NULL) {
-               TALLOC_FREE(upper);
-               return false;
-       }
-
-       memcpy(key, &fid, sizeof(fid));
-       memcpy(key + sizeof(fid), upper, namelen);
-       TALLOC_FREE(upper);
-
-       *_key = (DATA_BLOB) { .data = key, .length = keylen, };
-       return true;
-}
-
 /*
  * Lightweight function to just get last component
  * for rename / enumerate directory calls.
index b94468ad6afd7da1700115256cb771c2dedbe8ea..28a741c8b54d69dc7b533bbb5cf84273201cc996 100644 (file)
@@ -832,6 +832,55 @@ NTSTATUS create_open_symlink_err(TALLOC_CTX *mem_ctx,
        return NT_STATUS_OK;
 }
 
+/*
+ * Create the memcache-key for GETREALFILENAME_CACHE: This supplements
+ * the stat cache for the last component to be looked up. Cache
+ * contents is the correctly capitalized translation of the parameter
+ * "name" as it exists on disk. This is indexed by inode of the dirfsp
+ * and name, and contrary to stat_cahce_lookup() it does not
+ * vfs_stat() the last component. This will be taken care of by an
+ * attempt to do a openat_pathref_fsp().
+ */
+static bool get_real_filename_cache_key(TALLOC_CTX *mem_ctx,
+                                       struct files_struct *dirfsp,
+                                       const char *name,
+                                       DATA_BLOB *_key)
+{
+       struct file_id fid = vfs_file_id_from_sbuf(dirfsp->conn,
+                                                  &dirfsp->fsp_name->st);
+       char *upper = NULL;
+       uint8_t *key = NULL;
+       size_t namelen, keylen;
+
+       upper = talloc_strdup_upper(mem_ctx, name);
+       if (upper == NULL) {
+               return false;
+       }
+       namelen = talloc_get_size(upper);
+
+       keylen = namelen + sizeof(fid);
+       if (keylen < sizeof(fid)) {
+               TALLOC_FREE(upper);
+               return false;
+       }
+
+       key = talloc_size(mem_ctx, keylen);
+       if (key == NULL) {
+               TALLOC_FREE(upper);
+               return false;
+       }
+
+       memcpy(key, &fid, sizeof(fid));
+       memcpy(key + sizeof(fid), upper, namelen);
+       TALLOC_FREE(upper);
+
+       *_key = (DATA_BLOB){
+               .data = key,
+               .length = keylen,
+       };
+       return true;
+}
+
 static int smb_vfs_openat_ci(TALLOC_CTX *mem_ctx,
                             bool case_sensitive,
                             struct connection_struct *conn,
index e2902783efb15671e4bc97cad69c4212eb2309da..adc4be7755a21029ed1c02551a4e30ce12b2c761 100644 (file)
@@ -339,10 +339,6 @@ NTSTATUS get_real_filename_full_scan_at(struct files_struct *dirfsp,
                                        bool mangled,
                                        TALLOC_CTX *mem_ctx,
                                        char **found_name);
-bool get_real_filename_cache_key(TALLOC_CTX *mem_ctx,
-                                struct files_struct *dirfsp,
-                                const char *name,
-                                DATA_BLOB *_key);
 char *get_original_lcomp(TALLOC_CTX *ctx,
                        connection_struct *conn,
                        const char *filename_in,