]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: pass UserPerm to statfs() variants
authorGreg Farnum <gfarnum@redhat.com>
Sat, 30 Jul 2016 01:05:33 +0000 (18:05 -0700)
committerGreg Farnum <gfarnum@redhat.com>
Wed, 21 Sep 2016 23:33:50 +0000 (16:33 -0700)
Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/client/Client.cc
src/client/Client.h
src/client/SyntheticClient.cc
src/client/fuse_ll.cc
src/libcephfs.cc

index 35250d608cef37135b9df33dfab45fd17ed3f901..7b3bd23fe8b12368964802e14fef15c593f72836 100644 (file)
@@ -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)
index 0bdd6bc3142603605cb7705b3794c6f3470d3e6a..0a5ecb85656e25ac4ffd11d214951048ddb46aaa 100644 (file)
@@ -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);
index 17623d4cecd3a8074daa2f122c469b84ede471c7..7a7dacfb5eda64d0136a604e878f21a38244364c 100644 (file)
@@ -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);
     }
 
 
index 89ec8ee77d18f5890fb9b8b6e5555233ec454d4d..0749ed58c4c9187c7ee8f22c7c365878e0f49f55 100644 (file)
@@ -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
index 6c6bca40a6cd3dd2315d666a41c16af29120f3f8..527ba44672e23f380d363ab7debf1771286a0a91 100644 (file)
@@ -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,