Add option to lazy umount target mount point

This commit is contained in:
Antonio SJ Musumeci
2023-02-02 21:20:23 -05:00
parent 9a6b7835f4
commit 9adddfc66d
10 changed files with 103 additions and 9 deletions
+31 -1
View File
@@ -18,6 +18,7 @@
#include "syslog.hpp"
#include "fs_path.hpp"
#include "fs_umount2.hpp"
#include "mergerfs.hpp"
#include "option_parser.hpp"
#include "resources.hpp"
@@ -162,7 +163,7 @@ namespace l
(uint64_t)cfg_->branches_mount_timeout);
timeout = std::chrono::milliseconds(cfg_->branches_mount_timeout * 1000);
fs::wait_for_mount((std::string)cfg_->mount,
fs::wait_for_mount((std::string)cfg_->mountpoint,
paths,
timeout,
failed);
@@ -175,6 +176,32 @@ namespace l
failed.size());
}
static
void
lazy_umount(const std::string target_)
{
int rv;
rv = fs::umount_lazy(target_);
switch(rv)
{
case 0:
syslog_notice("%s has been successfully lazily unmounted",
target_.c_str());
break;
case -EINVAL:
syslog_notice("%s was not a mount point needing to be unmounted",
target_.c_str());
break;
default:
syslog_error("Error unmounting %s: %d - %s",
target_.c_str(),
-rv,
strerror(-rv));
break;
}
}
int
main(const int argc_,
char **argv_)
@@ -205,6 +232,9 @@ namespace l
l::setup_resources(cfg->scheduling_priority);
l::get_fuse_operations(ops,cfg->nullrw);
if(cfg->lazy_umount_mountpoint)
l::lazy_umount(cfg->mountpoint);
return fuse_main(args.argc,
args.argv,
&ops);