diff options
author | Martin Pärtel <martin.partel@gmail.com> | 2021-01-24 09:34:19 +0200 |
---|---|---|
committer | Martin Pärtel <martin.partel@gmail.com> | 2021-01-24 09:35:41 +0200 |
commit | 1aec434177a70c65d5449455eaedcad8a3a96eaf (patch) | |
tree | 68ec498d633b3d973480c08212c05977ad80ac67 | |
parent | 87f17506747d84bc2caeebb6184a75bcc3016fa0 (diff) | |
download | bindfs-1aec434177a70c65d5449455eaedcad8a3a96eaf.tar.gz |
Added support for `-o fsname`
For #94
-rw-r--r-- | src/bindfs.1 | 5 | ||||
-rw-r--r-- | src/bindfs.c | 14 | ||||
-rwxr-xr-x | tests/test_bindfs.rb | 7 |
3 files changed, 23 insertions, 3 deletions
diff --git a/src/bindfs.1 b/src/bindfs.1 index c1450f2..b681e44 100644 --- a/src/bindfs.1 +++ b/src/bindfs.1 @@ -414,6 +414,11 @@ more efficent mount with \fBmount \-\-bind\fP and then \fBmount \-o remount,ro\f Enable debug output (implies \-f). .TP +.B \-o fsname=\fIname\fP +Sets the source directory name in /proc/mounts (returned by \fBmount\fP). +This is automatically set as long as the source path has no special characters. + +.TP .B \-f Foreground operation. diff --git a/src/bindfs.c b/src/bindfs.c index ecb158a..8868c29 100644 --- a/src/bindfs.c +++ b/src/bindfs.c @@ -2155,11 +2155,14 @@ int main(int argc, char *argv[]) char *forward_odirect; char *uid_offset; char *gid_offset; + char *fsname; } od; #define OPT2(one, two, key) \ FUSE_OPT_KEY(one, key), \ FUSE_OPT_KEY(two, key) + #define OPT_OFFSET(opt, offset, key) \ + {opt, offsetof(struct OptionData, offset), key} #define OPT_OFFSET2(one, two, offset, key) \ {one, offsetof(struct OptionData, offset), key}, \ {two, offsetof(struct OptionData, offset), key} @@ -2228,8 +2231,9 @@ int main(int argc, char *argv[]) OPT2("--enable-ioctl", "enable-ioctl", OPTKEY_ENABLE_IOCTL), OPT_OFFSET2("--multithreaded", "multithreaded", multithreaded, -1), OPT_OFFSET2("--forward-odirect=%s", "forward-odirect=%s", forward_odirect, -1), - OPT_OFFSET2("--uid-offset=%s", "uid-offset=%s", uid_offset, 0), - OPT_OFFSET2("--gid-offset=%s", "gid-offset=%s", gid_offset, 0), + OPT_OFFSET2("--uid-offset=%s", "uid-offset=%s", uid_offset, -1), + OPT_OFFSET2("--gid-offset=%s", "gid-offset=%s", gid_offset, -1), + OPT_OFFSET("fsname=%s", fsname, -1), FUSE_OPT_END }; @@ -2535,7 +2539,11 @@ int main(int argc, char *argv[]) (issue #47). The character blacklist is likely not complete, which is acceptable since this is not a security check. The aim is to avoid giving the user a confusing error. */ - if (strpbrk(settings.mntsrc, ", \t\n") == NULL) { + if (od.fsname != NULL) { + char *tmp = sprintf_new("-ofsname=%s", od.fsname); + fuse_opt_add_arg(&args, tmp); + free(tmp); + } else if (strpbrk(settings.mntsrc, ", \t\n") == NULL) { char *tmp = sprintf_new("-ofsname=%s", settings.mntsrc); fuse_opt_add_arg(&args, tmp); free(tmp); diff --git a/tests/test_bindfs.rb b/tests/test_bindfs.rb index ed33400..d9d616c 100755 --- a/tests/test_bindfs.rb +++ b/tests/test_bindfs.rb @@ -867,6 +867,13 @@ if `uname`.strip == 'Linux' end end +# Issue 94 +if `uname`.strip != 'FreeBSD' # -o fsname is not supported on FreeBSD + testenv("-o fsname=_bindfs_test_123_", :title => "fsname") do + assert { `mount` =~ /^_bindfs_test_123_\s+on\s+/m } + end +end + if `uname`.strip != 'FreeBSD' # -o dev is not supported on FreeBSD root_testenv("-odev") do system("mknod mnt/zero c 1 5") |