summaryrefslogtreecommitdiffstats
path: root/xlators/features/utime/src/utime-helpers.c
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2018-04-30 04:43:58 -0400
committerAmar Tumballi <amarts@redhat.com>2018-05-06 07:09:18 +0530
commit487aaafacac8af16c08eb44fe9bf178768d372fa (patch)
tree69a8ff6a8be0f40e129a71bf28ef5e4a558d5109 /xlators/features/utime/src/utime-helpers.c
parentf8fe0771f0b450713595a7d298ed5a758cf2ce3e (diff)
utime: ctime client side xlator
The client side utime xlator does two things. 1. Update unix epoch time in frame->root->ctime 2. Update the frame->root->flags based on the fop which indicates time attributes that should be updated for the parent/entry. Credits: Rafi KC <rkavunga@redhat.com> Updates: #208 Change-Id: I9cad297040c70798a0a8468a080eb4aeff73138d Signed-off-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'xlators/features/utime/src/utime-helpers.c')
-rw-r--r--xlators/features/utime/src/utime-helpers.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/xlators/features/utime/src/utime-helpers.c b/xlators/features/utime/src/utime-helpers.c
new file mode 100644
index 00000000000..d8632453e62
--- /dev/null
+++ b/xlators/features/utime/src/utime-helpers.c
@@ -0,0 +1,95 @@
+/*
+ Copyright (c) 2018 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#include "utime-helpers.h"
+
+void
+gl_timespec_get (struct timespec *ts)
+{
+ #ifdef TIME_UTC
+ timespec_get (ts, TIME_UTC);
+ #else
+ timespec_now (ts);
+ #endif
+}
+
+void
+utime_update_attribute_flags(call_frame_t *frame, glusterfs_fop_t fop)
+{
+
+ if (!frame) {
+ goto out;
+ }
+
+ switch (fop) {
+ case GF_FOP_SETXATTR:
+ case GF_FOP_FSETXATTR:
+ frame->root->flags |= MDATA_CTIME;
+ break;
+
+ case GF_FOP_FALLOCATE:
+ case GF_FOP_ZEROFILL:
+ frame->root->flags |= MDATA_MTIME;
+ frame->root->flags |= MDATA_ATIME;
+ break;
+
+ case GF_FOP_OPENDIR:
+ case GF_FOP_READLINK:
+ case GF_FOP_OPEN:
+ case GF_FOP_READ:
+ frame->root->flags |= MDATA_ATIME;
+ break;
+
+ case GF_FOP_MKNOD:
+ case GF_FOP_MKDIR:
+ case GF_FOP_SYMLINK:
+ case GF_FOP_CREATE:
+ frame->root->flags |= MDATA_ATIME;
+ frame->root->flags |= MDATA_CTIME;
+ frame->root->flags |= MDATA_MTIME;
+ frame->root->flags |= MDATA_PAR_CTIME;
+ frame->root->flags |= MDATA_PAR_MTIME;
+ break;
+
+ case GF_FOP_UNLINK:
+ case GF_FOP_RMDIR:
+ frame->root->flags |= MDATA_PAR_CTIME;
+ frame->root->flags |= MDATA_PAR_MTIME;
+ break;
+
+ case GF_FOP_WRITE:
+ frame->root->flags |= MDATA_MTIME;
+ frame->root->flags |= MDATA_CTIME;
+ break;
+
+ case GF_FOP_LINK:
+ case GF_FOP_RENAME:
+ frame->root->flags |= MDATA_CTIME;
+ frame->root->flags |= MDATA_PAR_CTIME;
+ frame->root->flags |= MDATA_PAR_MTIME;
+ break;
+
+ case GF_FOP_TRUNCATE:
+ case GF_FOP_FTRUNCATE:
+ frame->root->flags |= MDATA_CTIME;
+ frame->root->flags |= MDATA_MTIME;
+ break;
+
+ case GF_FOP_REMOVEXATTR:
+ case GF_FOP_FREMOVEXATTR:
+ frame->root->flags |= MDATA_CTIME;
+ break;
+
+ default:
+ frame->root->flags = 0;
+ }
+out:
+ return;
+}