From 059ab1f0f4a786490d40030a78e225e3319dbfdb Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Tue, 30 Apr 2019 17:37:17 +0900 Subject: [PATCH] Update ctime during nocopyapi operations Follows on to 2c43b1e12b14fcbdc80bc45ff71733be05548cd7. Fixes #971. --- src/fdcache.cpp | 10 ++++++++++ src/fdcache.h | 1 + src/s3fs.cpp | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/src/fdcache.cpp b/src/fdcache.cpp index 4968cc1..29d3ac4 100644 --- a/src/fdcache.cpp +++ b/src/fdcache.cpp @@ -1025,6 +1025,16 @@ bool FdEntity::GetStats(struct stat& st) return true; } +int FdEntity::SetCtime(time_t time) +{ + if(-1 == time){ + return 0; + } + + orgmeta["x-amz-meta-ctime"] = str(time); + return 0; +} + int FdEntity::SetMtime(time_t time) { S3FS_PRN_INFO3("[path=%s][fd=%d][time=%jd]", path.c_str(), fd, (intmax_t)time); diff --git a/src/fdcache.h b/src/fdcache.h index 84d6f56..b7dec23 100644 --- a/src/fdcache.h +++ b/src/fdcache.h @@ -154,6 +154,7 @@ class FdEntity int GetFd(void) const { return fd; } bool GetStats(struct stat& st); + int SetCtime(time_t time); int SetMtime(time_t time); bool UpdateCtime(void); bool UpdateMtime(void); diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 7bbd5d7..641004d 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -1735,6 +1735,8 @@ static int s3fs_chmod_nocopy(const char* _path, mode_t mode) return -EIO; } + ent->SetCtime(time(NULL)); + // Change file mode ent->SetMode(mode); @@ -1891,6 +1893,8 @@ static int s3fs_chown_nocopy(const char* _path, uid_t uid, gid_t gid) return -EIO; } + ent->SetCtime(time(NULL)); + // Change owner ent->SetUId(uid); ent->SetGId(gid);