]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: Add routine to get caps of file/fd
authorSam Lang <sam.lang@inktank.com>
Sat, 1 Dec 2012 22:54:44 +0000 (16:54 -0600)
committerSam Lang <sam.lang@inktank.com>
Fri, 7 Dec 2012 20:18:26 +0000 (10:18 -1000)
In order to properly validate the client capabilities,
we need to be able to access them from libcephfs.

Signed-off-by: Sam Lang <sam.lang@inktank.com>
src/client/Client.cc
src/client/Client.h
src/include/cephfs/libcephfs.h
src/libcephfs.cc

index 84438e79acc8547591ade033a9ef831e0cac4aa8..406723aa5f520274877d1ec650364a0180a193de 100644 (file)
@@ -6084,7 +6084,27 @@ int Client::rmsnap(const char *relpath, const char *name)
   return _rmdir(snapdir, name);
 }
 
+// =============================
+// expose caps
+
+int Client::get_caps_issued(int fd) {
+
+  Mutex::Locker lock(client_lock);
 
+  Fh *f = get_filehandle(fd);
+  return f->inode->caps_issued();
+}
+
+int Client::get_caps_issued(const char *path) {
+
+  Mutex::Locker lock(client_lock);
+  filepath p(path);
+  Inode *in;
+  int r = path_walk(p, &in, true);
+  if (r < 0)
+    return r;
+  return in->caps_issued();
+}
 
 // =========================================
 // low level
@@ -7395,3 +7415,4 @@ void Client::clear_filer_flags(int flags)
   assert(flags == CEPH_OSD_FLAG_LOCALIZE_READS);
   objecter->clear_global_op_flag(flags);
 }
+
index ae75d2df9fe13a2721a2599e252a7f463c2fb99c..9512a2d8861d3752f74e058e05c8d145464999d8 100644 (file)
@@ -670,6 +670,10 @@ public:
   int mksnap(const char *path, const char *name);
   int rmsnap(const char *path, const char *name);
 
+  // expose caps
+  int get_caps_issued(int fd);
+  int get_caps_issued(const char *path);
+
   // low-level interface
   int ll_lookup(vinodeno_t parent, const char *name, struct stat *attr, int uid = -1, int gid = -1);
   bool ll_forget(vinodeno_t vino, int count);
index 71bf25f6aed9eb61fab5ba3651b9f6b915ad7aad..9cf66049d4d6d04c10c25beb57061c0158838d27 100644 (file)
@@ -937,6 +937,26 @@ int ceph_get_local_osd(struct ceph_mount_info *cmount);
 
 /** @} default_filelayout */
 
+/**
+ * Get the capabilities currently issued to the client.
+ * 
+ * @param cmount the ceph mount handle to use.
+ * @param fd the file descriptor to get issued
+ * @returns the current capabilities issued to this client
+ *       for the open file 
+ */
+int ceph_debug_get_fd_caps(struct ceph_mount_info *cmount, int fd);
+
+/**
+ * Get the capabilities currently issued to the client.
+ * 
+ * @param cmount the ceph mount handle to use.
+ * @param the path to the file
+ * @returns the current capabilities issued to this client
+ *       for the file 
+ */
+int ceph_debug_get_file_caps(struct ceph_mount_info *cmount, const char *path);
+
 #ifdef __cplusplus
 }
 #endif
index 02cf0864972c95549c6b26015879c976d6e0fc9c..c33f6284afcd3964768a68b68ad6b60b6b70f297 100644 (file)
@@ -802,3 +802,17 @@ extern "C" CephContext *ceph_get_mount_context(struct ceph_mount_info *cmount)
 {
   return cmount->get_ceph_context();
 }
+
+extern "C" int ceph_debug_get_fd_caps(struct ceph_mount_info *cmount, int fd)
+{
+  if (!cmount->is_mounted())
+    return -ENOTCONN;
+  return cmount->get_client()->get_caps_issued(fd);
+}
+
+extern "C" int ceph_debug_get_file_caps(struct ceph_mount_info *cmount, const char *path)
+{
+  if (!cmount->is_mounted())
+    return -ENOTCONN;
+  return cmount->get_client()->get_caps_issued(path);
+}