From: Greg Farnum Date: Fri, 29 Jul 2016 21:08:52 +0000 (-0700) Subject: client: add a UserPerm param to mount X-Git-Tag: v11.0.1~36^2~69 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5c0627528aa9e2b2c1b961c90f64ef86e85e1d7f;p=ceph.git client: add a UserPerm param to mount Signed-off-by: Greg Farnum --- diff --git a/src/ceph_fuse.cc b/src/ceph_fuse.cc index eeb0c29f2086..5d54238acc61 100644 --- a/src/ceph_fuse.cc +++ b/src/ceph_fuse.cc @@ -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; diff --git a/src/client/Client.cc b/src/client/Client.cc index faed0da72421..8af7ddda3d64 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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; diff --git a/src/client/Client.h b/src/client/Client.h index beaf40157bd5..cf5d50ba09d5 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -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( diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index d2fa9fc6df31..e2c7ac6754b1 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -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::iterator it = modes.begin(); it != modes.end(); ++it) { diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 0ef9337980e7..1b96861ebf21 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -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)