Remove 'nonempty' argument

This makes it like all other filesystems and brings it into alignment
with libfuse3's behavior.
This commit is contained in:
Antonio SJ Musumeci 2023-01-16 23:33:36 -05:00
parent 0b2afda30e
commit 3ee93d4c56
8 changed files with 20 additions and 120 deletions

View File

@ -666,7 +666,7 @@ make LTO=1 - build with link time optimization
mergerfs can be upgraded live by mounting on top of the previous instance. Simply install the new version of mergerfs and follow the instructions below.
Add `nonempty` to your mergerfs option list and call mergerfs again or if using `/etc/fstab` call for it to mount again. Existing open files and such will continue to work fine though they won't see runtime changes since any such change would be the new mount. If you plan on changing settings with the new mount you should / could apply those before mounting the new version.
Run mergerfs again or if using `/etc/fstab` call for it to mount again. Existing open files and such will continue to work fine though they won't see runtime changes since any such change would be the new mount. If you plan on changing settings with the new mount you should / could apply those before mounting the new version.
```
$ sudo mount /mnt/mergerfs

View File

@ -90,7 +90,6 @@ static const struct fuse_opt fuse_mount_opts[] = {
* handle them
*/
FUSE_OPT_KEY("fsname=", KEY_KERN),
FUSE_OPT_KEY("nonempty", KEY_KERN),
FUSE_OPT_KEY("large_read", KEY_KERN),
FUSE_OPT_END
};

View File

@ -64,7 +64,6 @@ struct mount_opts {
int allow_other;
int ishelp;
int flags;
int nonempty;
int auto_unmount;
int blkdev;
char *fsname;
@ -79,13 +78,11 @@ struct mount_opts {
static const struct fuse_opt fuse_mount_opts[] = {
FUSE_MOUNT_OPT("allow_other", allow_other),
FUSE_MOUNT_OPT("nonempty", nonempty),
FUSE_MOUNT_OPT("blkdev", blkdev),
FUSE_MOUNT_OPT("auto_unmount", auto_unmount),
FUSE_MOUNT_OPT("fsname=%s", fsname),
FUSE_MOUNT_OPT("subtype=%s", subtype),
FUSE_OPT_KEY("allow_other", KEY_KERN_OPT),
FUSE_OPT_KEY("nonempty", KEY_FUSERMOUNT_OPT),
FUSE_OPT_KEY("auto_unmount", KEY_FUSERMOUNT_OPT),
FUSE_OPT_KEY("blkdev", KEY_FUSERMOUNT_OPT),
FUSE_OPT_KEY("fsname=", KEY_FUSERMOUNT_OPT),
@ -126,7 +123,6 @@ static void mount_help(void)
fprintf(stderr,
" -o allow_other allow access to other users\n"
" -o auto_unmount auto unmount on process termination\n"
" -o nonempty allow mounts over non-empty file/dir\n"
" -o default_permissions enable permission checking by kernel\n"
" -o fsname=NAME set filesystem name\n"
" -o subtype=NAME set filesystem type\n"
@ -424,13 +420,6 @@ static int fuse_mount_sys(const char *mnt, struct mount_opts *mo,
return -1;
}
if (!mo->nonempty) {
res = fuse_mnt_check_empty("fuse", mnt, stbuf.st_mode,
stbuf.st_size);
if (res == -1)
return -1;
}
if (mo->auto_unmount) {
/* Tell the caller to fallback to fusermount because
auto-unmount does not work otherwise. */

View File

@ -312,39 +312,6 @@ char *fuse_mnt_resolve_path(const char *progname, const char *orig)
return dst;
}
int fuse_mnt_check_empty(const char *progname, const char *mnt,
mode_t rootmode, off_t rootsize)
{
int isempty = 1;
if (S_ISDIR(rootmode)) {
struct dirent *ent;
DIR *dp = opendir(mnt);
if (dp == NULL) {
fprintf(stderr,
"%s: failed to open mountpoint for reading: %s\n",
progname, strerror(errno));
return -1;
}
while ((ent = readdir(dp)) != NULL) {
if (strcmp(ent->d_name, ".") != 0 &&
strcmp(ent->d_name, "..") != 0) {
isempty = 0;
break;
}
}
closedir(dp);
} else if (rootsize)
isempty = 0;
if (!isempty) {
fprintf(stderr, "%s: mountpoint is not empty\n", progname);
fprintf(stderr, "%s: if you are sure this is safe, use the 'nonempty' mount option\n", progname);
return -1;
}
return 0;
}
int fuse_mnt_check_fuseblk(void)
{
char buf[256];

View File

@ -16,6 +16,4 @@ int fuse_mnt_remove_mount(const char *progname, const char *mnt);
int fuse_mnt_umount(const char *progname, const char *abs_mnt,
const char *rel_mnt, int lazy);
char *fuse_mnt_resolve_path(const char *progname, const char *orig);
int fuse_mnt_check_empty(const char *progname, const char *mnt,
mode_t rootmode, off_t rootsize);
int fuse_mnt_check_fuseblk(void);

View File

@ -726,7 +726,6 @@ static int do_mount(const char *mnt, char **typep, mode_t rootmode,
char *subtype = NULL;
char *source = NULL;
char *type = NULL;
int check_empty = 1;
int blkdev = 0;
optbuf = (char *) malloc(strlen(opts) + 128);
@ -759,8 +758,6 @@ static int do_mount(const char *mnt, char **typep, mode_t rootmode,
goto err;
}
blkdev = 1;
} else if (opt_eq(s, len, "nonempty")) {
check_empty = 0;
} else if (opt_eq(s, len, "auto_unmount")) {
auto_unmount = 1;
} else if (!begins_with(s, "fd=") &&
@ -811,10 +808,6 @@ static int do_mount(const char *mnt, char **typep, mode_t rootmode,
sprintf(d, "fd=%i,rootmode=%o,user_id=%u,group_id=%u",
fd, rootmode, getuid(), getgid());
if (check_empty &&
fuse_mnt_check_empty(progname, mnt, rootmode, rootsize) == -1)
goto err;
source = malloc((fsname ? strlen(fsname) : 0) +
(subtype ? strlen(subtype) : 0) + strlen(dev) + 32);

View File

@ -312,39 +312,6 @@ char *fuse_mnt_resolve_path(const char *progname, const char *orig)
return dst;
}
int fuse_mnt_check_empty(const char *progname, const char *mnt,
mode_t rootmode, off_t rootsize)
{
int isempty = 1;
if (S_ISDIR(rootmode)) {
struct dirent *ent;
DIR *dp = opendir(mnt);
if (dp == NULL) {
fprintf(stderr,
"%s: failed to open mountpoint for reading: %s\n",
progname, strerror(errno));
return -1;
}
while ((ent = readdir(dp)) != NULL) {
if (strcmp(ent->d_name, ".") != 0 &&
strcmp(ent->d_name, "..") != 0) {
isempty = 0;
break;
}
}
closedir(dp);
} else if (rootsize)
isempty = 0;
if (!isempty) {
fprintf(stderr, "%s: mountpoint is not empty\n", progname);
fprintf(stderr, "%s: if you are sure this is safe, use the 'nonempty' mount option\n", progname);
return -1;
}
return 0;
}
int fuse_mnt_check_fuseblk(void)
{
char buf[256];

View File

@ -49,27 +49,6 @@ enum
};
namespace l
{
static
int
calculate_thread_count(int threads_)
{
int tc;
if(threads_ > 0)
return threads_;
tc = hw::cpu::logical_core_count();
if(threads_ < 0)
tc /= -threads_;
if(tc == 0)
tc = 1;
return tc;
}
}
static
void
set_option(const std::string &option_,
@ -134,6 +113,24 @@ set_default_options(fuse_args *args_)
set_option("default_permissions",args_);
}
static
bool
should_ignore(const std::string &key_)
{
static const std::set<std::string> IGNORED_KEYS =
{
"atomic_o_trunc",
"big_writes",
"cache.open",
"defaults",
"hard_remove",
"nonempty",
"use_ino"
};
return (IGNORED_KEYS.find(key_) != IGNORED_KEYS.end());
}
static
int
parse_and_process_kv_arg(Config::Write &cfg_,
@ -164,17 +161,7 @@ parse_and_process_kv_arg(Config::Write &cfg_,
val = "true";
ef(key == "sync_read" && val.empty())
{key = "async_read", val = "false";}
ef(key == "defaults")
return 0;
ef(key == "hard_remove")
return 0;
ef(key == "atomic_o_trunc")
return 0;
ef(key == "big_writes")
return 0;
ef(key == "cache.open")
return 0;
ef(key == "use_ino")
ef(::should_ignore(key_))
return 0;
if(cfg_->has_key(key) == false)