unsigned int number_of_entries;
struct timespec mtime;
SMB_STRUCT_DIR *source_directory;
- int fd;
+ files_struct *fsp; /* If open via FDOPENDIR. */
+ struct smb_filename *smb_fname; /* If open via OPENDIR */
};
static void free_dirsort_privates(void **datap) {
struct timespec *ret_mtime)
{
int ret;
- struct stat dir_stat;
+ struct timespec mtime;
- ret = fstat(data->fd, &dir_stat);
+ if (data->fsp) {
+ ret = fsp_stat(data->fsp);
+ mtime = data->fsp->fsp_name->st.st_ex_mtime;
+ } else {
+ ret = SMB_VFS_STAT(handle->conn, data->smb_fname);
+ mtime = data->smb_fname->st.st_ex_mtime;
+ }
if (ret == -1) {
return false;
}
- ret_mtime->tv_sec = dir_stat.st_mtime;
- ret_mtime->tv_nsec = 0;
+ *ret_mtime = mtime;
return true;
}
const char *fname, const char *mask,
uint32 attr)
{
+ NTSTATUS status;
struct dirsort_privates *data = NULL;
/* set up our private data about this directory */
data->directory_list = NULL;
data->pos = 0;
+ status = create_synthetic_smb_fname(data,
+ fname,
+ NULL,
+ NULL,
+ &data->smb_fname);
+ if (!NT_STATUS_IS_OK(status)) {
+ TALLOC_FREE(data);
+ return NULL;
+ }
+
/* Open the underlying directory and count the number of entries */
data->source_directory = SMB_VFS_NEXT_OPENDIR(handle, fname, mask,
attr);
return NULL;
}
- data->fd = dirfd(data->source_directory);
-
if (!open_and_sort_dir(handle, data)) {
SMB_VFS_NEXT_CLOSEDIR(handle,data->source_directory);
TALLOC_FREE(data);
data->directory_list = NULL;
data->pos = 0;
+ data->fsp = fsp;
/* Open the underlying directory and count the number of entries */
data->source_directory = SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask,
return NULL;
}
- data->fd = dirfd(data->source_directory);
-
if (!open_and_sort_dir(handle, data)) {
SMB_VFS_NEXT_CLOSEDIR(handle,data->source_directory);
TALLOC_FREE(data);