From af0e199b31ea4132e369508d72888757887b3327 Mon Sep 17 00:00:00 2001 From: Steven Danneman Date: Thu, 22 Jan 2009 20:14:38 -0800 Subject: Add an optional SMB_STRUCT_SMB parameter to VFS_OP_READDIR * this allows VFS implementations that prefetch stat information on readdir to return it through one VFS call * backwards compatibility is maintained by passing in NULL * if the system readdir doesn't return stat info, the stat struct is set to invalid --- source3/modules/onefs_streams.c | 2 +- source3/modules/vfs_cap.c | 2 +- source3/modules/vfs_catia.c | 5 +++-- source3/modules/vfs_default.c | 8 +++++++- source3/modules/vfs_full_audit.c | 7 ++++--- source3/modules/vfs_shadow_copy.c | 4 ++-- source3/modules/vfs_shadow_copy2.c | 2 +- source3/modules/vfs_streams_depot.c | 2 +- 8 files changed, 20 insertions(+), 12 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/onefs_streams.c b/source3/modules/onefs_streams.c index 615edf379d..d0dd75f259 100644 --- a/source3/modules/onefs_streams.c +++ b/source3/modules/onefs_streams.c @@ -545,7 +545,7 @@ static NTSTATUS walk_onefs_streams(connection_struct *conn, files_struct *fsp, fake_fs.fsp_name = SMB_STRDUP(fname); /* Iterate over the streams in the ADS directory. */ - while ((dp = SMB_VFS_READDIR(conn, dirp)) != NULL) { + while ((dp = SMB_VFS_READDIR(conn, dirp, NULL)) != NULL) { /* Skip the "." and ".." entries */ if ((strcmp(dp->d_name, ".") == 0) || (strcmp(dp->d_name, "..") == 0)) diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c index ac85d3a804..e26d29d667 100644 --- a/source3/modules/vfs_cap.c +++ b/source3/modules/vfs_cap.c @@ -61,7 +61,7 @@ static SMB_STRUCT_DIRENT *cap_readdir(vfs_handle_struct *handle, SMB_STRUCT_DIR size_t newnamelen; DEBUG(3,("cap: cap_readdir\n")); - result = SMB_VFS_NEXT_READDIR(handle, dirp); + result = SMB_VFS_NEXT_READDIR(handle, dirp, NULL); if (!result) { return NULL; } diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c index d0c341fdd3..2870254bfb 100644 --- a/source3/modules/vfs_catia.c +++ b/source3/modules/vfs_catia.c @@ -105,11 +105,12 @@ static SMB_STRUCT_DIR *catia_opendir(vfs_handle_struct *handle, static SMB_STRUCT_DIRENT *catia_readdir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp) { - SMB_STRUCT_DIRENT *result = SMB_VFS_NEXT_READDIR(handle, dirp); - SMB_STRUCT_DIRENT *newdirent; + SMB_STRUCT_DIRENT *result = NULL; + SMB_STRUCT_DIRENT *newdirent = NULL; char *newname; size_t newnamelen; + result = SMB_VFS_NEXT_READDIR(handle, dirp, NULL); if (result == NULL) { return result; } diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 679be57558..7d61191a69 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -113,12 +113,18 @@ static SMB_STRUCT_DIR *vfswrap_opendir(vfs_handle_struct *handle, const char *f return result; } -static SMB_STRUCT_DIRENT *vfswrap_readdir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp) +static SMB_STRUCT_DIRENT *vfswrap_readdir(vfs_handle_struct *handle, + SMB_STRUCT_DIR *dirp, + SMB_STRUCT_STAT *sbuf) { SMB_STRUCT_DIRENT *result; START_PROFILE(syscall_readdir); result = sys_readdir(dirp); + /* Default Posix readdir() does not give us stat info. + * Set to invalid to indicate we didn't return this info. */ + if (sbuf) + SET_STAT_INVALID(*sbuf); END_PROFILE(syscall_readdir); return result; } diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index c6d62fdd87..e279772494 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -94,7 +94,8 @@ static int smb_full_audit_statvfs(struct vfs_handle_struct *handle, static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attr); static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle, - SMB_STRUCT_DIR *dirp); + SMB_STRUCT_DIR *dirp, + SMB_STRUCT_STAT *sbuf); static void smb_full_audit_seekdir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp, long offset); static long smb_full_audit_telldir(vfs_handle_struct *handle, @@ -1029,11 +1030,11 @@ static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle, } static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle, - SMB_STRUCT_DIR *dirp) + SMB_STRUCT_DIR *dirp, SMB_STRUCT_STAT *sbuf) { SMB_STRUCT_DIRENT *result; - result = SMB_VFS_NEXT_READDIR(handle, dirp); + result = SMB_VFS_NEXT_READDIR(handle, dirp, sbuf); /* This operation has no reasonable error condition * (End of dir is also failure), so always succeed. diff --git a/source3/modules/vfs_shadow_copy.c b/source3/modules/vfs_shadow_copy.c index fbd2960aba..4f5cedb3d4 100644 --- a/source3/modules/vfs_shadow_copy.c +++ b/source3/modules/vfs_shadow_copy.c @@ -93,7 +93,7 @@ static SMB_STRUCT_DIR *shadow_copy_opendir(vfs_handle_struct *handle, const char while (True) { SMB_STRUCT_DIRENT *d; - d = SMB_VFS_NEXT_READDIR(handle, p); + d = SMB_VFS_NEXT_READDIR(handle, p, NULL); if (d == NULL) { break; } @@ -176,7 +176,7 @@ static int shadow_copy_get_shadow_copy_data(vfs_handle_struct *handle, files_str SHADOW_COPY_LABEL *tlabels; SMB_STRUCT_DIRENT *d; - d = SMB_VFS_NEXT_READDIR(handle, p); + d = SMB_VFS_NEXT_READDIR(handle, p, NULL); if (d == NULL) { break; } diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 56dd6ea8d8..9eaf8ee851 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -524,7 +524,7 @@ static int shadow_copy2_get_shadow_copy2_data(vfs_handle_struct *handle, shadow_copy2_data->num_volumes = 0; shadow_copy2_data->labels = NULL; - while ((d = SMB_VFS_NEXT_READDIR(handle, p))) { + while ((d = SMB_VFS_NEXT_READDIR(handle, p, NULL))) { SHADOW_COPY_LABEL *tlabels; /* ignore names not of the right form in the snapshot directory */ diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c index 77efb277de..1c2c0e5f77 100644 --- a/source3/modules/vfs_streams_depot.c +++ b/source3/modules/vfs_streams_depot.c @@ -352,7 +352,7 @@ static NTSTATUS walk_streams(vfs_handle_struct *handle, return map_nt_error_from_unix(errno); } - while ((dirent = vfs_readdirname(handle->conn, dirhandle)) != NULL) { + while ((dirent = vfs_readdirname(handle->conn, dirhandle, NULL)) != NULL) { if (ISDOT(dirent) || ISDOTDOT(dirent)) { continue; -- cgit