libfuse: allow setting ctime in ->setattr()
authorMiklos Szeredi <mszeredi@suse.cz>
Tue, 15 Jul 2014 15:41:02 +0000 (17:41 +0200)
committerMiklos Szeredi <mszeredi@suse.cz>
Tue, 15 Jul 2014 15:42:44 +0000 (17:42 +0200)
ChangeLog
include/fuse_kernel.h
include/fuse_lowlevel.h
lib/fuse_lowlevel.c
lib/fuse_misc.h

index 167ca7e5919f0deb287a33afa613b91fabecdfba..a5f611d8469d0b899b7a0048d422d99ab26d6da1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,8 @@
        specify the time granularity it supports when the kernel is
        responsible for updating times ("writeback_cache" option).
 
+       * libfuse: allow setting ctime in ->setattr()
+
 2014-03-26  Miklos Szeredi <miklos@szeredi.hu>
 
        * Initilaize stat buffer passed to ->getattr() and ->fgetattr() to
index d1b4e2ca9672e85f7e4093536844edc4bb92b269..e86a21acef75c485773b19fd48e9178f9dc83632 100644 (file)
@@ -98,6 +98,8 @@
  *  - add FUSE_WRITEBACK_CACHE
  *  - add time_gran to fuse_init_out
  *  - add reserved space to fuse_init_out
+ *  - add FATTR_CTIME
+ *  - add ctime and ctimensec to fuse_setattr_in
  */
 
 #ifndef _LINUX_FUSE_H
@@ -193,6 +195,7 @@ struct fuse_file_lock {
 #define FATTR_ATIME_NOW        (1 << 7)
 #define FATTR_MTIME_NOW        (1 << 8)
 #define FATTR_LOCKOWNER        (1 << 9)
+#define FATTR_CTIME    (1 << 10)
 
 /**
  * Flags returned by the OPEN request
@@ -440,10 +443,10 @@ struct fuse_setattr_in {
        uint64_t        lock_owner;
        uint64_t        atime;
        uint64_t        mtime;
-       uint64_t        unused2;
+       uint64_t        ctime;
        uint32_t        atimensec;
        uint32_t        mtimensec;
-       uint32_t        unused3;
+       uint32_t        ctimensec;
        uint32_t        mode;
        uint32_t        unused4;
        uint32_t        uid;
index 31ea87f45184f68c69cb828bb02bc2f8df4debde..8eef9b91e099e46b3a26fb4a3c1e062a8bf51d69 100644 (file)
@@ -135,6 +135,7 @@ struct fuse_forget_data {
 #define FUSE_SET_ATTR_MTIME    (1 << 5)
 #define FUSE_SET_ATTR_ATIME_NOW        (1 << 7)
 #define FUSE_SET_ATTR_MTIME_NOW        (1 << 8)
+#define FUSE_SET_ATTR_CTIME    (1 << 10)
 
 /* ----------------------------------------------------------- *
  * Request methods and replies                                *
index dc27cb534890745f691040e01210a4dec7889a02..91318119848f86e55a769c22705c4d7b04126875 100755 (executable)
@@ -79,8 +79,10 @@ static void convert_attr(const struct fuse_setattr_in *attr, struct stat *stbuf)
        stbuf->st_size         = attr->size;
        stbuf->st_atime        = attr->atime;
        stbuf->st_mtime        = attr->mtime;
+       stbuf->st_ctime        = attr->ctime;
        ST_ATIM_NSEC_SET(stbuf, attr->atimensec);
        ST_MTIM_NSEC_SET(stbuf, attr->mtimensec);
+       ST_CTIM_NSEC_SET(stbuf, attr->ctimensec);
 }
 
 static size_t iov_length(const struct iovec *iov, size_t count)
@@ -1173,7 +1175,8 @@ static void do_setattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
                        FUSE_SET_ATTR_ATIME     |
                        FUSE_SET_ATTR_MTIME     |
                        FUSE_SET_ATTR_ATIME_NOW |
-                       FUSE_SET_ATTR_MTIME_NOW;
+                       FUSE_SET_ATTR_MTIME_NOW |
+                       FUSE_SET_ATTR_CTIME;
 
                req->f->op.setattr(req, nodeid, &stbuf, arg->valid, fi);
        } else
index 8b7677561e700fa02187fd07867171e495035b39..1839a67041b94e11e143fe68c18ada92e42bb1a4 100644 (file)
@@ -28,6 +28,7 @@ static inline void fuse_mutex_init(pthread_mutex_t *mut)
 #define ST_CTIM_NSEC(stbuf) ((stbuf)->st_ctim.tv_nsec)
 #define ST_MTIM_NSEC(stbuf) ((stbuf)->st_mtim.tv_nsec)
 #define ST_ATIM_NSEC_SET(stbuf, val) (stbuf)->st_atim.tv_nsec = (val)
+#define ST_CTIM_NSEC_SET(stbuf, val) (stbuf)->st_ctim.tv_nsec = (val)
 #define ST_MTIM_NSEC_SET(stbuf, val) (stbuf)->st_mtim.tv_nsec = (val)
 #elif defined(HAVE_STRUCT_STAT_ST_ATIMESPEC)
 /* FreeBSD */
@@ -35,11 +36,13 @@ static inline void fuse_mutex_init(pthread_mutex_t *mut)
 #define ST_CTIM_NSEC(stbuf) ((stbuf)->st_ctimespec.tv_nsec)
 #define ST_MTIM_NSEC(stbuf) ((stbuf)->st_mtimespec.tv_nsec)
 #define ST_ATIM_NSEC_SET(stbuf, val) (stbuf)->st_atimespec.tv_nsec = (val)
+#define ST_CTIM_NSEC_SET(stbuf, val) (stbuf)->st_ctimespec.tv_nsec = (val)
 #define ST_MTIM_NSEC_SET(stbuf, val) (stbuf)->st_mtimespec.tv_nsec = (val)
 #else
 #define ST_ATIM_NSEC(stbuf) 0
 #define ST_CTIM_NSEC(stbuf) 0
 #define ST_MTIM_NSEC(stbuf) 0
 #define ST_ATIM_NSEC_SET(stbuf, val) do { } while (0)
+#define ST_CTIM_NSEC_SET(stbuf, val) do { } while (0)
 #define ST_MTIM_NSEC_SET(stbuf, val) do { } while (0)
 #endif