From 38a89f23f1ac5e317266c66d6c08c31213afeb54 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Wed, 10 Dec 2014 15:56:30 -0700 Subject: gpfs: Move smbd_gpfs_set_times_path to vfs_gpfs.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christof Schmitt Reviewed-by: Ralph Böhme --- source3/modules/vfs_gpfs.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'source3/modules/vfs_gpfs.c') diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index d7961701369..b91e377e94a 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -1736,6 +1736,44 @@ static int vfs_gpfs_lstat(struct vfs_handle_struct *handle, return 0; } +static void timespec_to_gpfs_time(struct timespec ts, gpfs_timestruc_t *gt, + int idx, int *flags) +{ + if (!null_timespec(ts)) { + *flags |= 1 << idx; + gt[idx].tv_sec = ts.tv_sec; + gt[idx].tv_nsec = ts.tv_nsec; + DEBUG(10, ("Setting GPFS time %d, flags 0x%x\n", idx, *flags)); + } +} + +static int smbd_gpfs_set_times_path(char *path, struct smb_file_time *ft) +{ + gpfs_timestruc_t gpfs_times[4]; + int flags = 0; + int rc; + + ZERO_ARRAY(gpfs_times); + timespec_to_gpfs_time(ft->atime, gpfs_times, 0, &flags); + timespec_to_gpfs_time(ft->mtime, gpfs_times, 1, &flags); + /* No good mapping from LastChangeTime to ctime, not storing */ + timespec_to_gpfs_time(ft->create_time, gpfs_times, 3, &flags); + + if (!flags) { + DEBUG(10, ("nothing to do, return to avoid EINVAL\n")); + return 0; + } + + rc = gpfswrap_set_times_path(path, flags, gpfs_times); + + if (rc != 0 && errno != ENOSYS) { + DEBUG(1,("gpfs_set_times() returned with error %s\n", + strerror(errno))); + } + + return rc; +} + static int vfs_gpfs_ntimes(struct vfs_handle_struct *handle, const struct smb_filename *smb_fname, struct smb_file_time *ft) -- cgit v1.2.1