summaryrefslogtreecommitdiff
path: root/source3/modules
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2013-04-09 10:43:53 -0700
committerJeremy Allison <jra@samba.org>2013-04-11 09:49:41 -0700
commit6ae58dd153e3a53af52d896fff83ec76f40984d6 (patch)
tree91b1ad755f2f16bfd99ac075c83008281e77deb7 /source3/modules
parent770512e3bd785a977351ba82ab08c556573c79dd (diff)
downloadsamba-6ae58dd153e3a53af52d896fff83ec76f40984d6.tar.gz
samba-6ae58dd153e3a53af52d896fff83ec76f40984d6.tar.bz2
samba-6ae58dd153e3a53af52d896fff83ec76f40984d6.zip
Convert mtime from a time_t to a struct timespec.
In preparation for removing the dirfd and using fsp_stat() and VFS_STAT functions. 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.c41
1 files changed, 26 insertions, 15 deletions
diff --git a/source3/modules/vfs_dirsort.c b/source3/modules/vfs_dirsort.c
index e2c61dab17..3388d53ae4 100644
--- a/source3/modules/vfs_dirsort.c
+++ b/source3/modules/vfs_dirsort.c
@@ -31,7 +31,7 @@ struct dirsort_privates {
long pos;
struct dirent *directory_list;
unsigned int number_of_entries;
- time_t mtime;
+ struct timespec mtime;
DIR *source_directory;
int fd;
};
@@ -40,21 +40,35 @@ static void free_dirsort_privates(void **datap) {
TALLOC_FREE(*datap);
}
+static bool get_sorted_dir_mtime(vfs_handle_struct *handle,
+ struct dirsort_privates *data,
+ struct timespec *ret_mtime)
+{
+ int ret;
+ struct stat dir_stat;
+
+ ret = fstat(data->fd, &dir_stat);
+
+ if (ret == -1) {
+ return false;
+ }
+
+ ret_mtime->tv_sec = dir_stat.st_mtime;
+ ret_mtime->tv_nsec = 0;
+
+ return true;
+}
+
static bool open_and_sort_dir(vfs_handle_struct *handle,
struct dirsort_privates *data)
{
- struct stat dir_stat;
- unsigned int i;
+ unsigned int i = 0;
unsigned int total_count = 0;
- struct dirsort_privates *data = NULL;
-
- SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates,
- return false);
data->number_of_entries = 0;
- if (fstat(data->fd, &dir_stat) == 0) {
- data->mtime = dir_stat.st_mtime;
+ if (get_sorted_dir_mtime(handle, data, &data->mtime) == false) {
+ return false;
}
while (SMB_VFS_NEXT_READDIR(handle, data->source_directory, NULL)
@@ -179,20 +193,17 @@ static struct dirent *dirsort_readdir(vfs_handle_struct *handle,
SMB_STRUCT_STAT *sbuf)
{
struct dirsort_privates *data = NULL;
- time_t current_mtime;
- struct stat dir_stat;
+ struct timespec current_mtime;
SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates,
return NULL);
- if (fstat(data->fd, &dir_stat) == -1) {
+ if (get_sorted_dir_mtime(handle, data, &current_mtime) == false) {
return NULL;
}
- current_mtime = dir_stat.st_mtime;
-
/* throw away cache and re-read the directory if we've changed */
- if (current_mtime > data->mtime) {
+ if (timespec_compare(&current_mtime, &data->mtime) > 1) {
open_and_sort_dir(handle, data);
}