From 46057cefc19f020be25a7cc7432b8e3c01315983 Mon Sep 17 00:00:00 2001 From: Pavani Rajula Date: Wed, 18 Jul 2018 20:07:55 +0530 Subject: [PATCH] Provided API to change umask Signed-off-by: Pavani Rajula --- src/include/cephfs/libcephfs.h | 3 +++ src/libcephfs.cc | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/include/cephfs/libcephfs.h b/src/include/cephfs/libcephfs.h index d1b39bc44002c..7a8a6801bde91 100644 --- a/src/include/cephfs/libcephfs.h +++ b/src/include/cephfs/libcephfs.h @@ -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 diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 364828ed1bd79..3524a2058bb42 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -34,9 +34,13 @@ #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) { -- 2.39.5