]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: always pass a UserPerm to chmod variants
authorGreg Farnum <gfarnum@redhat.com>
Wed, 27 Jul 2016 22:41:42 +0000 (15:41 -0700)
committerGreg Farnum <gfarnum@redhat.com>
Wed, 31 Aug 2016 21:38:50 +0000 (14:38 -0700)
Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/client/Client.cc
src/client/Client.h
src/client/SyntheticClient.cc
src/libcephfs.cc

index 99f0bddca9701edd755f2b4e6a65b7666d1a26b7..aa4d8ddee4193d644e37ccc4c83a798bb8bbb1b8 100644 (file)
@@ -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)
index 4db706f5e48fdb001d24f6c0fea0788b1bfdb25f..e5fbbb8ab1538d5efc2e2e449e01bfc10ff90017 100644 (file)
@@ -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);
index fa52f8ea849e73408ce594b4e4ad759cbfc952df..e2e06c3148bc471202e9f5402f0a7c4a51ae9909 100644 (file)
@@ -836,7 +836,7 @@ int SyntheticClient::run()
          struct stat st;
          for (int i=0; i<count; i++) {
            client->lstat("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;
index c996e8db0aebcf15e490f470f94503a6492f85f3..2703710d9593f69c1f650371d6707463ed50a062 100644 (file)
@@ -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)