diff options
author | Jeremy Allison <jra@samba.org> | 2013-04-09 10:50:55 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2013-04-11 09:49:41 -0700 |
commit | 353718c3f9fa49f6c3b5d6de2afd79fbfade4295 (patch) | |
tree | 0b126568370661018d13e64f1065ef0cc2693ec6 /source3/modules | |
parent | 6ae58dd153e3a53af52d896fff83ec76f40984d6 (diff) | |
download | samba-353718c3f9fa49f6c3b5d6de2afd79fbfade4295.tar.gz samba-353718c3f9fa49f6c3b5d6de2afd79fbfade4295.tar.bz2 samba-353718c3f9fa49f6c3b5d6de2afd79fbfade4295.zip |
Remove the use of dirfd inside the vfs_dirsort.c.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3/modules')
-rw-r--r-- | source3/modules/vfs_dirsort.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/source3/modules/vfs_dirsort.c b/source3/modules/vfs_dirsort.c index 3388d53ae4..53770ec177 100644 --- a/source3/modules/vfs_dirsort.c +++ b/source3/modules/vfs_dirsort.c @@ -33,7 +33,8 @@ struct dirsort_privates { unsigned int number_of_entries; struct timespec mtime; 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) { @@ -45,16 +46,21 @@ static bool get_sorted_dir_mtime(vfs_handle_struct *handle, 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; } @@ -113,6 +119,7 @@ static DIR *dirsort_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attr) { + NTSTATUS status; struct dirsort_privates *data = NULL; /* set up our private data about this directory */ @@ -124,6 +131,16 @@ static DIR *dirsort_opendir(vfs_handle_struct *handle, 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); @@ -133,8 +150,6 @@ static DIR *dirsort_opendir(vfs_handle_struct *handle, 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); @@ -162,6 +177,7 @@ static DIR *dirsort_fdopendir(vfs_handle_struct *handle, 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, @@ -172,8 +188,6 @@ static DIR *dirsort_fdopendir(vfs_handle_struct *handle, 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); |