From: Greg Farnum Date: Wed, 27 Jul 2016 23:07:30 +0000 (-0700) Subject: client: always pass a UserPerm to utime variants X-Git-Tag: v11.0.1~36^2~77 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=acec3d3ee87dad7fac87133d6568a7064132fcbb;p=ceph.git client: always pass a UserPerm to utime variants Signed-off-by: Greg Farnum --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 4e6699bdf1b3..2a91a78df2ae 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -6836,7 +6836,8 @@ int Client::lchown(const char *relpath, uid_t new_uid, gid_t new_gid, return _setattr(in, &attr, mask, perms); } -int Client::utime(const char *relpath, struct utimbuf *buf) +int Client::utime(const char *relpath, struct utimbuf *buf, + const UserPerm& perms) { Mutex::Locker lock(client_lock); tout(cct) << "utime" << std::endl; @@ -6845,7 +6846,7 @@ int Client::utime(const char *relpath, struct utimbuf *buf) tout(cct) << buf->actime << std::endl; filepath path(relpath); InodeRef in; - int r = path_walk(path, &in); + int r = path_walk(path, &in, perms); if (r < 0) return r; struct stat attr; @@ -6853,10 +6854,11 @@ int Client::utime(const char *relpath, struct utimbuf *buf) stat_set_mtime_nsec(&attr, 0); stat_set_atime_sec(&attr, buf->actime); stat_set_atime_nsec(&attr, 0); - return _setattr(in, &attr, CEPH_SETATTR_MTIME|CEPH_SETATTR_ATIME); + return _setattr(in, &attr, CEPH_SETATTR_MTIME|CEPH_SETATTR_ATIME, perms); } -int Client::lutime(const char *relpath, struct utimbuf *buf) +int Client::lutime(const char *relpath, struct utimbuf *buf, + const UserPerm& perms) { Mutex::Locker lock(client_lock); tout(cct) << "lutime" << std::endl; @@ -6866,7 +6868,7 @@ int Client::lutime(const char *relpath, struct utimbuf *buf) filepath path(relpath); InodeRef in; // don't follow symlinks - int r = path_walk(path, &in, false); + int r = path_walk(path, &in, perms, false); if (r < 0) return r; struct stat attr; @@ -6874,7 +6876,7 @@ int Client::lutime(const char *relpath, struct utimbuf *buf) stat_set_mtime_nsec(&attr, 0); stat_set_atime_sec(&attr, buf->actime); stat_set_atime_nsec(&attr, 0); - return _setattr(in, &attr, CEPH_SETATTR_MTIME|CEPH_SETATTR_ATIME); + return _setattr(in, &attr, CEPH_SETATTR_MTIME|CEPH_SETATTR_ATIME, perms); } int Client::flock(int fd, int operation, uint64_t owner) diff --git a/src/client/Client.h b/src/client/Client.h index 08c555871ddb..f25593c0454a 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -1080,8 +1080,8 @@ public: int fchown(int fd, uid_t new_uid, gid_t new_gid, const UserPerm& perms); int lchown(const char *path, uid_t new_uid, gid_t new_gid, const UserPerm& perms); - int utime(const char *path, struct utimbuf *buf); - int lutime(const char *path, struct utimbuf *buf); + int utime(const char *path, struct utimbuf *buf, const UserPerm& perms); + int lutime(const char *path, struct utimbuf *buf, const UserPerm& perms); int flock(int fd, int operation, uint64_t owner); int truncate(const char *path, loff_t size); diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index b46ed8b1ba1d..482992f18d8e 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -1122,7 +1122,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) struct utimbuf u; u.actime = b; u.modtime = c; - client->utime(a, &u); + client->utime(a, &u, perms); } else if (strcmp(op, "mknod") == 0) { const char *a = t.get_string(buf, p); int64_t b = t.get_int(); @@ -2737,9 +2737,9 @@ int SyntheticClient::random_walk(int num_req) struct utimbuf b; memset(&b, 1, sizeof(b)); if (contents.empty()) - r = client->utime( cwd.c_str(), &b ); + r = client->utime(cwd.c_str(), &b, perms); else - r = client->utime( get_random_sub(), &b ); + r = client->utime(get_random_sub(), &b, perms); } */ if (op == CEPH_MDS_OP_LINK) { @@ -3324,7 +3324,7 @@ void SyntheticClient::import_find(const char *base, const char *find, bool data) struct utimbuf ut; ut.modtime = mtime; ut.actime = mtime; - client->utime(f.c_str(), &ut); + client->utime(f.c_str(), &ut, perms); } } } diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 3ffada336b29..a66c145bedc4 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -777,7 +777,8 @@ extern "C" int ceph_utime(struct ceph_mount_info *cmount, const char *path, { if (!cmount->is_mounted()) return -ENOTCONN; - return cmount->get_client()->utime(path, buf); + UserPerm perms = cmount->get_client()->pick_my_perms(); + return cmount->get_client()->utime(path, buf, perms); } extern "C" int ceph_flock(struct ceph_mount_info *cmount, int fd, int operation,