Pass the get_real_filename operation through the VFS
authorVolker Lendecke <vl@samba.org>
Wed, 10 Dec 2008 02:17:19 +0000 (03:17 +0100)
committerVolker Lendecke <vl@samba.org>
Wed, 10 Dec 2008 17:05:26 +0000 (18:05 +0100)
This is done to help file systems that can tell us about the real upper/lower
case combination given a case-insensitive file name. The sample I will soon
push is the gpfs module (recent gpfs has a get_real_filename function), others
might have a similar function to help alleviate the 1million files in a single
directory problem.

Jeremy, please comment!

Thanks,

Volker

source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/vfs_default.c
source3/smbd/filename.c

index 383cd327aef1bb82dcd413a75b03d9f7746ee2fb..d02d14b854c689379feec4ed813d2612d1bccb4c 100644 (file)
@@ -210,6 +210,7 @@ typedef enum _vfs_op_type {
        SMB_VFS_OP_CHFLAGS,
        SMB_VFS_OP_FILE_ID_CREATE,
        SMB_VFS_OP_STREAMINFO,
+       SMB_VFS_OP_GET_REAL_FILENAME,
 
        /* NT ACL operations. */
 
@@ -375,6 +376,12 @@ struct vfs_ops {
                                       unsigned int *num_streams,
                                       struct stream_struct **streams);
 
+               int (*get_real_filename)(struct vfs_handle_struct *handle,
+                                        const char *path,
+                                        const char *name,
+                                        TALLOC_CTX *mem_ctx,
+                                        char **found_name);
+
                /* NT ACL operations. */
 
                NTSTATUS (*fget_nt_acl)(struct vfs_handle_struct *handle,
@@ -510,6 +517,7 @@ struct vfs_ops {
                struct vfs_handle_struct *chflags;
                struct vfs_handle_struct *file_id_create;
                struct vfs_handle_struct *streaminfo;
+               struct vfs_handle_struct *get_real_filename;
 
                /* NT ACL operations. */
 
index fa5dad8781d5af78e968a0d877a5e059de99df08..b008d86b3ca624f716356babc1b1ac0f2fbfa566 100644 (file)
@@ -85,6 +85,7 @@
 #define SMB_VFS_CHFLAGS(conn, path, flags) ((conn)->vfs.ops.chflags((conn)->vfs.handles.chflags, (path), (flags)))
 #define SMB_VFS_FILE_ID_CREATE(conn, dev, inode) ((conn)->vfs.ops.file_id_create((conn)->vfs.handles.file_id_create, (dev), (inode)))
 #define SMB_VFS_STREAMINFO(conn, fsp, fname, mem_ctx, num_streams, streams) ((conn)->vfs.ops.streaminfo((conn)->vfs.handles.streaminfo, (fsp), (fname), (mem_ctx), (num_streams), (streams)))
+#define SMB_VFS_GET_REAL_FILENAME(conn, path, name, mem_ctx, found_name) ((conn)->vfs.ops.get_real_filename((conn)->vfs.handles.get_real_filename, (path), (name), (mem_ctx), (found_name)))
 
 /* NT ACL operations. */
 #define SMB_VFS_FGET_NT_ACL(fsp, security_info, ppdesc) ((fsp)->conn->vfs.ops.fget_nt_acl((fsp)->conn->vfs.handles.fget_nt_acl, (fsp), (security_info), (ppdesc)))
 #define SMB_VFS_OPAQUE_CHFLAGS(conn, path, flags) ((conn)->vfs_opaque.ops.chflags((conn)->vfs_opaque.handles.chflags, (path), (flags)))
 #define SMB_VFS_OPAQUE_FILE_ID_CREATE(conn, dev, inode) ((conn)->vfs.ops_opaque.file_id_create((conn)->vfs_opaque.handles.file_id_create, (dev), (inode)))
 #define SMB_VFS_OPAQUE_STREAMINFO(conn, fsp, fname, mem_ctx, num_streams, streams) ((conn)->vfs_opaque.ops.streaminfo((conn)->vfs_opaque.handles.streaminfo, (fsp), (fname), (mem_ctx), (num_streams), (streams)))
+#define SMB_VFS_OPAQUE_GET_REAL_FILENAME(conn, path, name, mem_ctx, found_name) ((conn)->vfs_opaque.ops.get_real_filename((conn)->vfs_opaque.handles.get_real_filename, (path), (name), (mem_ctx), (found_name)))
 
 /* NT ACL operations. */
 #define SMB_VFS_OPAQUE_FGET_NT_ACL(fsp, security_info, ppdesc) ((fsp)->conn->vfs_opaque.ops.fget_nt_acl((fsp)->conn->vfs_opaque.handles.fget_nt_acl, (fsp), (security_info), (ppdesc)))
 #define SMB_VFS_NEXT_CHFLAGS(handle, path, flags) ((handle)->vfs_next.ops.chflags((handle)->vfs_next.handles.chflags, (path), (flags)))
 #define SMB_VFS_NEXT_FILE_ID_CREATE(handle, dev, inode) ((handle)->vfs_next.ops.file_id_create((handle)->vfs_next.handles.file_id_create, (dev), (inode)))
 #define SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx, num_streams, streams) ((handle)->vfs_next.ops.streaminfo((handle)->vfs_next.handles.streaminfo, (fsp), (fname), (mem_ctx), (num_streams), (streams)))
+#define SMB_VFS_NEXT_GET_REAL_FILENAME(conn, path, name, mem_ctx, found_name) ((conn)->vfs_next.ops.get_real_filename((conn)->vfs_next.handles.get_real_filename, (path), (name), (mem_ctx), (found_name)))
 
 /* NT ACL operations. */
 #define SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc) ((handle)->vfs_next.ops.fget_nt_acl((handle)->vfs_next.handles.fget_nt_acl, (fsp), (security_info), (ppdesc)))
index 6d8d8f8065fbde0f85d84abc0bc36b0dde7c6566..8fa8f6ae0671bc51b9467dd2b078da702a8cf42b 100644 (file)
@@ -1038,6 +1038,16 @@ static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle,
        return NT_STATUS_OK;
 }
 
+static int vfswrap_get_real_filename(struct vfs_handle_struct *handle,
+                                    const char *path,
+                                    const char *name,
+                                    TALLOC_CTX *mem_ctx,
+                                    char **found_name)
+{
+       return get_real_filename(handle->conn, path, name, mem_ctx,
+                                found_name);
+}
+
 static NTSTATUS vfswrap_fget_nt_acl(vfs_handle_struct *handle,
                                    files_struct *fsp,
                                    uint32 security_info, SEC_DESC **ppdesc)
@@ -1459,6 +1469,8 @@ static vfs_op_tuple vfs_default_ops[] = {
         SMB_VFS_LAYER_OPAQUE},
        {SMB_VFS_OP(vfswrap_streaminfo),        SMB_VFS_OP_STREAMINFO,
         SMB_VFS_LAYER_OPAQUE},
+       {SMB_VFS_OP(vfswrap_get_real_filename), SMB_VFS_OP_GET_REAL_FILENAME,
+        SMB_VFS_LAYER_OPAQUE},
 
        /* NT ACL operations. */
 
index c803e406491585922c25b65fd6a0c94710c7813c..d240ecfa647ca8dfc34bb68772b76b3606cf6e9e 100644 (file)
@@ -26,9 +26,6 @@
 
 #include "includes.h"
 
-static int get_real_filename(connection_struct *conn, const char *path,
-                            const char *name, TALLOC_CTX *mem_ctx,
-                            char **found_name);
 static NTSTATUS build_stream_path(TALLOC_CTX *mem_ctx,
                                  connection_struct *conn,
                                  const char *orig_path,
@@ -434,7 +431,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
                         */
 
                        if (name_has_wildcard ||
-                           (get_real_filename(
+                           (SMB_VFS_GET_REAL_FILENAME(
                                     conn, dirpath, start,
                                     talloc_tos(), &found_name) == -1)) {
                                char *unmangled;