mirror of
https://github.com/openharmony/third_party_libfuse.git
synced 2026-07-19 21:43:34 -04:00
libfuse: allow setting ctime in ->setattr()
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 *
|
||||
|
||||
+4
-1
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user