]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Provided API to change umask 23157/head
authorPavani Rajula <rpavani1998@gmail.com>
Wed, 18 Jul 2018 14:37:55 +0000 (20:07 +0530)
committerPatrick Donnelly <pdonnell@redhat.com>
Sat, 28 Jul 2018 23:22:58 +0000 (16:22 -0700)
Signed-off-by: Pavani Rajula <rpavani1998@gmail.com>
src/include/cephfs/libcephfs.h
src/libcephfs.cc

index d1b39bc44002cd49dba122fe0f104707e9418c3c..7a8a6801bde912ad169c8169ae87ba98c3dbe4a8 100644 (file)
@@ -1738,6 +1738,9 @@ int ceph_set_deleg_timeout(struct ceph_mount_info *cmount, uint32_t timeout);
  */
 int ceph_ll_delegation(struct ceph_mount_info *cmount, Fh *fh,
                       unsigned int cmd, ceph_deleg_cb_t cb, void *priv);
+
+mode_t ceph_umask(struct ceph_mount_info *cmount, mode_t mode);
+
 #ifdef __cplusplus
 }
 #endif
index 364828ed1bd7979d7e502959020de9ef98e8b3fa..3524a2058bb42ced50dae76c6b479e17b808e9ca 100644 (file)
 
 #include "include/cephfs/libcephfs.h"
 
+#define DEFAULT_UMASK 002
+
+static mode_t umask_cb(void *);
 
 struct ceph_mount_info
 {
+  mode_t umask = DEFAULT_UMASK;
 public:
   explicit ceph_mount_info(CephContext *cct_)
     : default_perms(),
@@ -107,6 +111,13 @@ public:
     if (ret)
       goto fail;
 
+    {
+      client_callback_args args = {};
+      args.handle = this;
+      args.umask_cb = umask_cb;
+      client->ll_register_callbacks(&args);
+    }
+
     default_perms = Client::pick_my_perms(cct);
     inited = true;
     return 0;
@@ -192,6 +203,12 @@ public:
     return mounted;
   }
 
+  mode_t set_umask(mode_t umask)
+  {
+    this->umask = umask;
+    return umask;
+  }
+
   int conf_read_file(const char *path_list)
   {
     int ret = cct->_conf.parse_config_files(path_list, nullptr, 0);
@@ -268,6 +285,11 @@ private:
   std::string cwd;
 };
 
+static mode_t umask_cb(void *handle)
+{
+  return ((struct ceph_mount_info *)handle)->umask;
+}
+
 static void do_out_buffer(bufferlist& outbl, char **outbuf, size_t *outbuflen)
 {
   if (outbuf) {
@@ -390,6 +412,11 @@ extern "C" int ceph_conf_read_file(struct ceph_mount_info *cmount, const char *p
   return cmount->conf_read_file(path);
 }
 
+extern "C" mode_t ceph_umask(struct ceph_mount_info *cmount, mode_t mode)
+{
+  return cmount->set_umask(mode);
+}
+
 extern "C" int ceph_conf_parse_argv(struct ceph_mount_info *cmount, int argc,
                                     const char **argv)
 {