[SCM] Samba Shared Repository - branch master updated -
21b9dec990b08a104600bf8e408e64e805a02835
Volker Lendecke
vlendec at samba.org
Wed Dec 10 17:07:20 GMT 2008
The branch, master has been updated
via 21b9dec990b08a104600bf8e408e64e805a02835 (commit)
via 31543640e6227e8dc808e365ba0bf6d2d5b08727 (commit)
via c7521b25e9f364ced3fbdee3ccb463e93e97a1c3 (commit)
via 6bb2fff0c14bd886a1d7995e5ce01f5938689372 (commit)
from 9ea4b5aac254bbe689c00c613db2b2288046be78 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 21b9dec990b08a104600bf8e408e64e805a02835
Author: Volker Lendecke <vl at samba.org>
Date: Wed Dec 10 03:17:19 2008 +0100
Pass the get_real_filename operation through the VFS
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
commit 31543640e6227e8dc808e365ba0bf6d2d5b08727
Author: Volker Lendecke <vl at samba.org>
Date: Wed Dec 10 03:03:51 2008 +0100
Change get_real_filename() to unix syscall conventions, make it non-static
It sets errno, so it might as well return 0/-1.
commit c7521b25e9f364ced3fbdee3ccb463e93e97a1c3
Author: Volker Lendecke <vl at samba.org>
Date: Tue Dec 9 13:50:22 2008 +0100
Apply some const
commit 6bb2fff0c14bd886a1d7995e5ce01f5938689372
Author: Volker Lendecke <vl at samba.org>
Date: Tue Dec 9 13:40:41 2008 +0100
Rename "scan_directory" to "get_real_filename"
-----------------------------------------------------------------------
Summary of changes:
source3/include/vfs.h | 8 ++++++++
source3/include/vfs_macros.h | 3 +++
source3/modules/vfs_default.c | 12 ++++++++++++
source3/smbd/filename.c | 32 +++++++++++++++-----------------
4 files changed, 38 insertions(+), 17 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 383cd32..d02d14b 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -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. */
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index fa5dad8..b008d86 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -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)))
@@ -211,6 +212,7 @@
#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)))
@@ -338,6 +340,7 @@
#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)))
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 6d8d8f8..8fa8f6a 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -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. */
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 392264b..d240ecf 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -26,8 +26,6 @@
#include "includes.h"
-static bool scan_directory(connection_struct *conn, const char *path,
- char *name, char **found_name);
static NTSTATUS build_stream_path(TALLOC_CTX *mem_ctx,
connection_struct *conn,
const char *orig_path,
@@ -433,8 +431,9 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
*/
if (name_has_wildcard ||
- !scan_directory(conn, dirpath,
- start, &found_name)) {
+ (SMB_VFS_GET_REAL_FILENAME(
+ conn, dirpath, start,
+ talloc_tos(), &found_name) == -1)) {
char *unmangled;
if (end) {
@@ -768,15 +767,15 @@ static bool fname_equal(const char *name1, const char *name2,
If the name looks like a mangled name then try via the mangling functions
****************************************************************************/
-static bool scan_directory(connection_struct *conn, const char *path,
- char *name, char **found_name)
+int get_real_filename(connection_struct *conn, const char *path,
+ const char *name, TALLOC_CTX *mem_ctx,
+ char **found_name)
{
struct smb_Dir *cur_dir;
const char *dname;
bool mangled;
char *unmangled_name = NULL;
long curpos;
- TALLOC_CTX *ctx = talloc_tos();
mangled = mangle_is_mangled(name, conn->params);
@@ -791,7 +790,7 @@ static bool scan_directory(connection_struct *conn, const char *path,
*/
if (!mangled && !(conn->fs_capabilities & FILE_CASE_SENSITIVE_SEARCH)) {
errno = ENOENT;
- return False;
+ return -1;
}
/*
@@ -810,10 +809,9 @@ static bool scan_directory(connection_struct *conn, const char *path,
*/
if (mangled && !conn->case_sensitive) {
- mangled = !mangle_lookup_name_from_8_3(ctx,
- name,
- &unmangled_name,
- conn->params);
+ mangled = !mangle_lookup_name_from_8_3(talloc_tos(), name,
+ &unmangled_name,
+ conn->params);
if (!mangled) {
/* Name is now unmangled. */
name = unmangled_name;
@@ -824,7 +822,7 @@ static bool scan_directory(connection_struct *conn, const char *path,
if (!(cur_dir = OpenDir(talloc_tos(), conn, path, NULL, 0))) {
DEBUG(3,("scan dir didn't open dir [%s]\n",path));
TALLOC_FREE(unmangled_name);
- return(False);
+ return -1;
}
/* now scan for matching names */
@@ -850,21 +848,21 @@ static bool scan_directory(connection_struct *conn, const char *path,
if ((mangled && mangled_equal(name,dname,conn->params)) ||
fname_equal(name, dname, conn->case_sensitive)) {
/* we've found the file, change it's name and return */
- *found_name = talloc_strdup(ctx,dname);
+ *found_name = talloc_strdup(mem_ctx, dname);
TALLOC_FREE(unmangled_name);
TALLOC_FREE(cur_dir);
if (!*found_name) {
errno = ENOMEM;
- return False;
+ return -1;
}
- return(True);
+ return 0;
}
}
TALLOC_FREE(unmangled_name);
TALLOC_FREE(cur_dir);
errno = ENOENT;
- return False;
+ return -1;
}
static NTSTATUS build_stream_path(TALLOC_CTX *mem_ctx,
--
Samba Shared Repository
More information about the samba-cvs
mailing list