]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: add a UserPerm param to mount
authorGreg Farnum <gfarnum@redhat.com>
Fri, 29 Jul 2016 21:08:52 +0000 (14:08 -0700)
committerGreg Farnum <gfarnum@redhat.com>
Wed, 21 Sep 2016 23:33:48 +0000 (16:33 -0700)
Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/ceph_fuse.cc
src/client/Client.cc
src/client/Client.h
src/client/SyntheticClient.cc
src/libcephfs.cc

index eeb0c29f20863a19e549201cf7639ce13f9e4345..5d54238acc61710374feae9af3f404dfce2f4686 100644 (file)
@@ -189,6 +189,7 @@ int main(int argc, const char **argv, const char *envp[]) {
     Messenger *messenger = NULL;
     Client *client;
     CephFuse *cfuse;
+    UserPerm perms;
 
     MonClient *mc = new MonClient(g_ceph_context);
     int r = mc->build_initial_monmap();
@@ -234,10 +235,11 @@ int main(int argc, const char **argv, const char *envp[]) {
     }
     
     client->update_metadata("mount_point", cfuse->get_mount_point());
-
+    perms = client->pick_my_perms();
     // start up fuse
     // use my argc, argv (make sure you pass a mount point!)
-    r = client->mount(g_conf->client_mountpoint.c_str(), g_ceph_context->_conf->fuse_require_active_mds);
+    r = client->mount(g_conf->client_mountpoint.c_str(), perms,
+                     g_ceph_context->_conf->fuse_require_active_mds);
     if (r < 0) {
       if (r == CEPH_FUSE_NO_MDS_UP)
         cerr << "ceph-fuse[" << getpid() << "]: probably no MDS server is up?" << std::endl;
index faed0da72421b195f7c5673da599df88e12c0187..8af7ddda3d648e28c4a7a22f627b402860689ae1 100644 (file)
@@ -5533,7 +5533,8 @@ void Client::handle_command_reply(MCommandReply *m)
 // -------------------
 // MOUNT
 
-int Client::mount(const std::string &mount_root, bool require_mds)
+int Client::mount(const std::string &mount_root, const UserPerm& perms,
+                 bool require_mds)
 {
   Mutex::Locker lock(client_lock);
 
@@ -5596,7 +5597,7 @@ int Client::mount(const std::string &mount_root, bool require_mds)
     MetaRequest *req = new MetaRequest(CEPH_MDS_OP_GETATTR);
     req->set_filepath(fp);
     req->head.args.getattr.mask = CEPH_STAT_CAP_INODE_ALL;
-    int res = make_request(req, -1, -1);
+    int res = make_request(req, perms);
     if (res < 0) {
       if (res == -EACCES && root) {
        ldout(cct, 1) << __func__ << " EACCES on parent of mount point; quotas may not work" << dendl;
index beaf40157bd5fa34d87675f2f74036347385e720..cf5d50ba09d5d3893562fec842b0bebaab13896c 100644 (file)
@@ -999,7 +999,8 @@ private:
   mds_rank_t _get_random_up_mds() const;
 
 public:
-  int mount(const std::string &mount_root, bool require_mds=false);
+  int mount(const std::string &mount_root, const UserPerm& perms,
+           bool require_mds=false);
   void unmount();
 
   int mds_command(
index d2fa9fc6df31c1f904ed83cabb1a647dd7c91551..e2c7ac6754b1b0ab2dfaf7541349385663edee96 100644 (file)
@@ -306,7 +306,8 @@ string SyntheticClient::get_sarg(int seq)
 }
 
 int SyntheticClient::run()
-{ 
+{
+  UserPerm perms = client->pick_my_perms();
   dout(15) << "initing" << dendl;
   int err = client->init();
   if (err < 0) {
@@ -315,7 +316,7 @@ int SyntheticClient::run()
   }
 
   dout(15) << "mounting" << dendl;
-  err = client->mount("");
+  err = client->mount("", perms);
   if (err < 0) {
     dout(0) << "failed to mount: " << cpp_strerror(err) << dendl;
     client->shutdown();
@@ -328,8 +329,6 @@ int SyntheticClient::run()
 
   int seq = 0;
 
-  UserPerm perms = client->pick_my_perms();
-
   for (list<int>::iterator it = modes.begin();
        it != modes.end();
        ++it) {
index 0ef9337980e76662d98f6ca7175eb7a33e8b2706..1b96861ebf217f140c61625ed69e70285d584676 100644 (file)
@@ -103,7 +103,7 @@ public:
     return ret;
   }
 
-  int mount(const std::string &mount_root)
+  int mount(const std::string &mount_root, const UserPerm& perms)
   {
     int ret;
     
@@ -117,7 +117,7 @@ public:
       }
     }
 
-    ret = client->mount(mount_root);
+    ret = client->mount(mount_root, perms);
     if (ret) {
       shutdown();
       return ret;
@@ -427,7 +427,8 @@ extern "C" int ceph_mount(struct ceph_mount_info *cmount, const char *root)
   std::string mount_root;
   if (root)
     mount_root = root;
-  return cmount->mount(mount_root);
+  UserPerm perms = cmount->get_client()->pick_my_perms();
+  return cmount->mount(mount_root, perms);
 }
 
 extern "C" int ceph_is_mounted(struct ceph_mount_info *cmount)