From: Matt Benjamin Date: Sun, 10 Jan 2016 18:44:52 +0000 (-0500) Subject: librgw: set directory ctime and mtime X-Git-Tag: v10.1.0~382^2~47 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d18fe86b542152be264bbbdeedcd725312ba0ccb;p=ceph.git librgw: set directory ctime and mtime Adds method to RGWStatBucketRequest to access the creation_time of the returned bucket. (For now, that's the only timestamp we have.) Signed-off-by: Matt Benjamin --- diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 16817112ba52..34b92d16d1d0 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -52,6 +52,10 @@ namespace rgw { fhr = lookup_fh(parent, path, RGWFileHandle::FLAG_CREATE| RGWFileHandle::FLAG_BUCKET); + if (get<0>(fhr)) { + RGWFileHandle* rgw_fh = get<0>(fhr); + rgw_fh->set_times(req.get_ctime()); + } } return fhr; } @@ -109,8 +113,17 @@ namespace rgw { fhr = lookup_fh(parent, path, RGWFileHandle::FLAG_CREATE| ((req.is_dir) ? - RGWFileHandle::FLAG_DIRECTORY : - RGWFileHandle::FLAG_NONE)); + RGWFileHandle::FLAG_DIRECTORY : + RGWFileHandle::FLAG_NONE)); + /* XXX we don't have an object--in general, there need not + * be one (just a path segment in some other object). In + * actual leaf an object exists, but we'd need another round + * trip to get attrs */ + if (get<0>(fhr)) { + /* for now use the parent object's mtime */ + RGWFileHandle* rgw_fh = get<0>(fhr); + rgw_fh->set_mtime(parent->get_mtime()); + } } } } diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index c3953779986b..44cee94088c6 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -280,6 +280,8 @@ namespace rgw { RGWFileHandle* get_parent() { return parent; } + struct timespec get_mtime() const { return state.mtime; } + int stat(struct stat *st) { /* partial Unix attrs */ memset(st, 0, sizeof(struct stat)); @@ -1567,6 +1569,10 @@ public: return 0; } + time_t get_ctime() const { + return bucket.creation_time; + } + virtual int get_params() { return 0; }