summaryrefslogtreecommitdiff
path: root/source3/modules/vfs_dirsort.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/modules/vfs_dirsort.c')
-rw-r--r--source3/modules/vfs_dirsort.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/source3/modules/vfs_dirsort.c b/source3/modules/vfs_dirsort.c
index 4869bc05a0..82a3a4bb98 100644
--- a/source3/modules/vfs_dirsort.c
+++ b/source3/modules/vfs_dirsort.c
@@ -122,6 +122,48 @@ static SMB_STRUCT_DIR *dirsort_opendir(vfs_handle_struct *handle,
return data->source_directory;
}
+static SMB_STRUCT_DIR *dirsort_fdopendir(vfs_handle_struct *handle,
+ files_struct *fsp,
+ const char *mask,
+ uint32 attr)
+{
+ struct dirsort_privates *data = NULL;
+
+ /* set up our private data about this directory */
+ data = (struct dirsort_privates *)SMB_MALLOC(
+ sizeof(struct dirsort_privates));
+
+ if (!data) {
+ return NULL;
+ }
+
+ data->directory_list = NULL;
+ data->pos = 0;
+
+ /* Open the underlying directory and count the number of entries */
+ data->source_directory = SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask,
+ attr);
+
+ if (data->source_directory == NULL) {
+ SAFE_FREE(data);
+ return NULL;
+ }
+
+ data->fd = dirfd(data->source_directory);
+
+ SMB_VFS_HANDLE_SET_DATA(handle, data, free_dirsort_privates,
+ struct dirsort_privates, return NULL);
+
+ if (!open_and_sort_dir(handle)) {
+ SMB_VFS_NEXT_CLOSEDIR(handle,data->source_directory);
+ /* fd is now closed. */
+ fsp->fh->fd = -1;
+ return NULL;
+ }
+
+ return data->source_directory;
+}
+
static SMB_STRUCT_DIRENT *dirsort_readdir(vfs_handle_struct *handle,
SMB_STRUCT_DIR *dirp,
SMB_STRUCT_STAT *sbuf)
@@ -179,6 +221,7 @@ static void dirsort_rewinddir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp)
static struct vfs_fn_pointers vfs_dirsort_fns = {
.opendir = dirsort_opendir,
+ .fdopendir = dirsort_fdopendir,
.readdir = dirsort_readdir,
.seekdir = dirsort_seekdir,
.telldir = dirsort_telldir,