From e0cf97261c029fe668f099452f3c80b0f39de9b7 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Mon, 14 Sep 2015 22:11:52 -0400 Subject: [PATCH] include default_permissions in default arguments closes #130 --- README.md | 2 +- src/getattr.cpp | 8 +++++--- src/init.cpp | 18 ------------------ src/ioctl.cpp | 6 +++--- src/listxattr.cpp | 2 +- src/option_parser.cpp | 11 ++++++----- src/setxattr.cpp | 13 ++++--------- 7 files changed, 20 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 71f2d406..31756e6b 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Why create **mergerfs** when those exist? **mhddfs** has not been updated in som ###options### -* **defaults** is a shortcut for **auto_cache**. **big_writes**, **atomic_o_trunc**, **splice_read**, **splice_write**, and **splice_move** are in effect also enabled (by asking **FUSE** internally for such features) but if unavailable will be ignored. These options seem to provide the best performance. +* **defaults** is a shortcut for FUSE's **atomic_o_trunc**, **auto_cache*, **big_writes**, **default_permissions**, **splice_move**, **splice_read**, and **splice_write**. These options seem to provide the best performance. * **minfreespace** (defaults to **4G**) is the minimum space value used for the **lfs**, **fwfs**, and **epmfs** policies. Understands 'K', 'M', and 'G' to represent kilobyte, megabyte, and gigabyte respectively. * All FUSE functions which have a category (see below) are option keys. The syntax being **func.<func>=<policy>**. Example: **func.getattr=newest**. * To set all function policies in a category use **category.<category>=<policy>**. Example: **category.create=mfs**. diff --git a/src/getattr.cpp b/src/getattr.cpp index c2a25409..7f20a678 100644 --- a/src/getattr.cpp +++ b/src/getattr.cpp @@ -45,14 +45,16 @@ static int _getattr_controlfile(struct stat &buf) { - time_t now = time(NULL); + static const uid_t uid = ::getuid(); + static const gid_t gid = ::getgid(); + static const time_t now = ::time(NULL); buf.st_dev = 0; buf.st_ino = 0; buf.st_mode = (S_IFREG|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH); buf.st_nlink = 1; - buf.st_uid = ::getuid(); - buf.st_gid = ::getgid(); + buf.st_uid = uid; + buf.st_gid = gid; buf.st_rdev = 0; buf.st_size = 0; buf.st_blksize = 1024; diff --git a/src/init.cpp b/src/init.cpp index b21818af..56511fa2 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -36,27 +36,9 @@ namespace mergerfs { ugid::init(); -#ifdef FUSE_CAP_ASYNC_READ - conn->want |= FUSE_CAP_ASYNC_READ; -#endif #ifdef FUSE_CAP_IOCTL_DIR conn->want |= FUSE_CAP_IOCTL_DIR; #endif -#ifdef FUSE_CAP_ATOMIC_O_TRUNC - conn->want |= FUSE_CAP_ATOMIC_O_TRUNC; -#endif -#ifdef FUSE_CAP_BIG_WRITES - conn->want |= FUSE_CAP_BIG_WRITES; -#endif -#ifdef FUSE_CAP_SPLICE_WRITE - conn->want |= FUSE_CAP_SPLICE_WRITE; -#endif -#ifdef FUSE_CAP_SPLICE_READ - conn->want |= FUSE_CAP_SPLICE_READ; -#endif -#ifdef FUSE_CAP_SPLICE_MOVE - conn->want |= FUSE_CAP_SPLICE_MOVE; -#endif return &Config::get_writable(); } diff --git a/src/ioctl.cpp b/src/ioctl.cpp index ee03a7ba..0d4b285a 100644 --- a/src/ioctl.cpp +++ b/src/ioctl.cpp @@ -41,9 +41,9 @@ using namespace mergerfs; static int -_ioctl(const int fd, - const int cmd, - void *data) +_ioctl(const int fd, + const int cmd, + void *data) { int rv; diff --git a/src/listxattr.cpp b/src/listxattr.cpp index 73f86c4d..8331b232 100644 --- a/src/listxattr.cpp +++ b/src/listxattr.cpp @@ -56,7 +56,7 @@ _listxattr_controlfile(char *list, ("user.mergerfs.policies") ("user.mergerfs.version"); - xattrs.reserve(512); + xattrs.reserve(1024); for(size_t i = 0; i < strs.size(); i++) xattrs += (strs[i] + '\0'); for(size_t i = Category::Enum::BEGIN; i < Category::Enum::END; i++) diff --git a/src/option_parser.cpp b/src/option_parser.cpp index b8fcf744..c06646c2 100644 --- a/src/option_parser.cpp +++ b/src/option_parser.cpp @@ -94,12 +94,13 @@ static void set_default_options(fuse_args &args) { - // set_option(args,"big_writes"); - // set_option(args,"splice_read"); - // set_option(args,"splice_write"); - // set_option(args,"splice_move"); + set_option(args,"atomic_o_trunc"); set_option(args,"auto_cache"); - // set_option(args,"atomic_o_trunc"); + set_option(args,"big_writes"); + set_option(args,"default_permissions"); + set_option(args,"splice_move"); + set_option(args,"splice_read"); + set_option(args,"splice_write"); } static diff --git a/src/setxattr.cpp b/src/setxattr.cpp index 03df2004..538c56c4 100644 --- a/src/setxattr.cpp +++ b/src/setxattr.cpp @@ -313,15 +313,10 @@ namespace mergerfs const Config &config = Config::get(fc); if(fusepath == config.controlfile) - { - if((fc->uid != ::getuid()) && (fc->gid != ::getgid())) - return -EPERM; - - return _setxattr_controlfile(Config::get_writable(), - attrname, - string(attrval,attrvalsize), - flags); - } + return _setxattr_controlfile(Config::get_writable(), + attrname, + string(attrval,attrvalsize), + flags); const ugid::Set ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock);