From: Greg Farnum Date: Sat, 30 Jul 2016 01:05:33 +0000 (-0700) Subject: client: pass UserPerm to statfs() variants X-Git-Tag: v11.0.1~36^2~55 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dfbac033ddd8729ea50781c333ff74cf57dfab72;p=ceph.git client: pass UserPerm to statfs() variants Signed-off-by: Greg Farnum --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 35250d608cef..7b3bd23fe8b1 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -8874,7 +8874,8 @@ void Client::getcwd(string& dir, const UserPerm& perms) dir += path.get_path(); } -int Client::statfs(const char *path, struct statvfs *stbuf) +int Client::statfs(const char *path, struct statvfs *stbuf, + const UserPerm& perms) { Mutex::Locker l(client_lock); tout(cct) << "statfs" << std::endl; @@ -9236,12 +9237,12 @@ int Client::_flock(Fh *fh, int cmd, uint64_t owner) return ret; } -int Client::ll_statfs(Inode *in, struct statvfs *stbuf) +int Client::ll_statfs(Inode *in, struct statvfs *stbuf, const UserPerm& perms) { /* Since the only thing this does is wrap a call to statfs, and statfs takes a lock, it doesn't seem we have a need to split it out. */ - return statfs(0, stbuf); + return statfs(0, stbuf, perms); } void Client::ll_register_callbacks(struct client_callback_args *args) diff --git a/src/client/Client.h b/src/client/Client.h index 0bdd6bc31426..0a5ecb85656e 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -1036,7 +1036,7 @@ public: bufferlist *poutbl, std::string *prs, Context *onfinish); // these shoud (more or less) mirror the actual system calls. - int statfs(const char *path, struct statvfs *stbuf); + int statfs(const char *path, struct statvfs *stbuf, const UserPerm& perms); // crap int chdir(const char *s, std::string &new_cwd, const UserPerm& perms); @@ -1242,7 +1242,7 @@ public: uint64_t snapseq, uint32_t sync); int ll_commit_blocks(Inode *in, uint64_t offset, uint64_t length); - int ll_statfs(Inode *in, struct statvfs *stbuf); + int ll_statfs(Inode *in, struct statvfs *stbuf, const UserPerm& perms); int ll_walk(const char* name, Inode **i, struct stat *attr); // XXX in? uint32_t ll_stripe_unit(Inode *in); int ll_file_layout(Inode *in, file_layout_t *layout); diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index 17623d4cecd3..7a7dacfb5eda 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -1217,7 +1217,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) client->chdir(a, ignore, perms); } else if (strcmp(op, "statfs") == 0) { struct statvfs stbuf; - client->statfs("/", &stbuf); + client->statfs("/", &stbuf, perms); } // low level ops --------------------- @@ -1437,7 +1437,7 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) } else if (strcmp(op, "ll_statfs") == 0) { int64_t i = t.get_int(); if (ll_inos.count(i)) - {} //client->ll_statfs(vinodeno_t(ll_inos[i],CEPH_NOSNAP)); + {} //client->ll_statfs(vinodeno_t(ll_inos[i],CEPH_NOSNAP), perms); } diff --git a/src/client/fuse_ll.cc b/src/client/fuse_ll.cc index 89ec8ee77d18..0749ed58c4c9 100644 --- a/src/client/fuse_ll.cc +++ b/src/client/fuse_ll.cc @@ -707,8 +707,10 @@ static void fuse_ll_statfs(fuse_req_t req, fuse_ino_t ino) struct statvfs stbuf; CephFuse::Handle *cfuse = fuse_ll_req_prepare(req); Inode *in = cfuse->iget(ino); + const struct fuse_ctx *ctx = fuse_req_ctx(req); + UserPerm perms(ctx->uid, ctx->gid); - int r = cfuse->client->ll_statfs(in, &stbuf); + int r = cfuse->client->ll_statfs(in, &stbuf, perms); if (r == 0) fuse_reply_statfs(req, &stbuf); else diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 6c6bca40a6cd..527ba44672e2 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -441,7 +441,8 @@ extern "C" int ceph_statfs(struct ceph_mount_info *cmount, const char *path, { if (!cmount->is_mounted()) return -ENOTCONN; - return cmount->get_client()->statfs(path, stbuf); + UserPerm perms = cmount->get_client()->pick_my_perms(); + return cmount->get_client()->statfs(path, stbuf, perms); } extern "C" int ceph_get_local_osd(struct ceph_mount_info *cmount) @@ -1632,7 +1633,8 @@ extern "C" int ceph_ll_unlink(class ceph_mount_info *cmount, extern "C" int ceph_ll_statfs(class ceph_mount_info *cmount, Inode *in, struct statvfs *stbuf) { - return (cmount->get_client()->ll_statfs(in, stbuf)); + UserPerm perms = cmount->get_client()->pick_my_perms(); + return (cmount->get_client()->ll_statfs(in, stbuf, perms)); } extern "C" int ceph_ll_readlink(class ceph_mount_info *cmount,