From: Greg Farnum Date: Wed, 27 Jul 2016 22:41:42 +0000 (-0700) Subject: client: always pass a UserPerm to chmod variants X-Git-Tag: v11.0.1~36^2~79 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ad1bd5749490a306c30abbad9b1b4ca62c59ea80;p=ceph.git client: always pass a UserPerm to chmod variants Signed-off-by: Greg Farnum --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 99f0bddca970..aa4d8ddee419 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -6717,7 +6717,7 @@ void Client::touch_dn(Dentry *dn) lru.lru_touch(dn); } -int Client::chmod(const char *relpath, mode_t mode) +int Client::chmod(const char *relpath, mode_t mode, const UserPerm& perms) { Mutex::Locker lock(client_lock); tout(cct) << "chmod" << std::endl; @@ -6725,15 +6725,15 @@ int Client::chmod(const char *relpath, mode_t mode) tout(cct) << mode << 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; attr.st_mode = mode; - return _setattr(in, &attr, CEPH_SETATTR_MODE); + return _setattr(in, &attr, CEPH_SETATTR_MODE, perms); } -int Client::fchmod(int fd, mode_t mode) +int Client::fchmod(int fd, mode_t mode, const UserPerm& perms) { Mutex::Locker lock(client_lock); tout(cct) << "fchmod" << std::endl; @@ -6748,10 +6748,10 @@ int Client::fchmod(int fd, mode_t mode) #endif struct stat attr; attr.st_mode = mode; - return _setattr(f->inode, &attr, CEPH_SETATTR_MODE); + return _setattr(f->inode, &attr, CEPH_SETATTR_MODE, perms); } -int Client::lchmod(const char *relpath, mode_t mode) +int Client::lchmod(const char *relpath, mode_t mode, const UserPerm& perms) { Mutex::Locker lock(client_lock); tout(cct) << "lchmod" << std::endl; @@ -6760,12 +6760,12 @@ int Client::lchmod(const char *relpath, mode_t mode) 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; attr.st_mode = mode; - return _setattr(in, &attr, CEPH_SETATTR_MODE); + return _setattr(in, &attr, CEPH_SETATTR_MODE, perms); } int Client::chown(const char *relpath, int uid, int gid) diff --git a/src/client/Client.h b/src/client/Client.h index 4db706f5e48f..e5fbbb8ab153 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -1072,9 +1072,9 @@ public: int setattr(const char *relpath, struct stat *attr, int mask, const UserPerm& perms); int fsetattr(int fd, struct stat *attr, int mask, const UserPerm& perms); - int chmod(const char *path, mode_t mode); - int fchmod(int fd, mode_t mode); - int lchmod(const char *path, mode_t mode); + int chmod(const char *path, mode_t mode, const UserPerm& perms); + int fchmod(int fd, mode_t mode, const UserPerm& perms); + int lchmod(const char *path, mode_t mode, const UserPerm& perms); int chown(const char *path, int uid, int gid); int fchown(int fd, int uid, int gid); int lchown(const char *path, int uid, int gid); diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index fa52f8ea849e..e2e06c3148bc 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -836,7 +836,7 @@ int SyntheticClient::run() struct stat st; for (int i=0; ilstat("test", &st); - client->chmod("test", 0777); + client->chmod("test", 0777, perms); } } did_run_me(); @@ -1109,7 +1109,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) } else if (strcmp(op, "chmod") == 0) { const char *a = t.get_string(buf, p); int64_t b = t.get_int(); - client->chmod(a, b); + client->chmod(a, b, perms); } else if (strcmp(op, "chown") == 0) { const char *a = t.get_string(buf, p); int64_t b = t.get_int(); @@ -2724,7 +2724,7 @@ int SyntheticClient::random_walk(int num_req) if (contents.empty()) op = CEPH_MDS_OP_READDIR; else - r = client->chmod( get_random_sub(), rand() & 0755 ); + r = client->chmod(get_random_sub(), rand() & 0755, perms); } if (op == CEPH_MDS_OP_CHOWN) { @@ -3316,7 +3316,7 @@ void SyntheticClient::import_find(const char *base, const char *find, bool data) } client->close(fd); - //client->chmod(f.c_str(), mode & 0777); + //client->chmod(f.c_str(), mode & 0777, perms); client->chown(f.c_str(), uid, gid); struct utimbuf ut; diff --git a/src/libcephfs.cc b/src/libcephfs.cc index c996e8db0aeb..2703710d9593 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -736,13 +736,15 @@ extern "C" int ceph_chmod(struct ceph_mount_info *cmount, const char *path, mode { if (!cmount->is_mounted()) return -ENOTCONN; - return cmount->get_client()->chmod(path, mode); + UserPerm perms = cmount->get_client()->pick_my_perms(); + return cmount->get_client()->chmod(path, mode, perms); } extern "C" int ceph_fchmod(struct ceph_mount_info *cmount, int fd, mode_t mode) { if (!cmount->is_mounted()) return -ENOTCONN; - return cmount->get_client()->fchmod(fd, mode); + UserPerm perms = cmount->get_client()->pick_my_perms(); + return cmount->get_client()->fchmod(fd, mode, perms); } extern "C" int ceph_chown(struct ceph_mount_info *cmount, const char *path, int uid, int gid)