refactor
This commit is contained in:
@@ -54,6 +54,9 @@ protected:
|
|||||||
bool atime_enabled_{true};
|
bool atime_enabled_{true};
|
||||||
bool console_enabled_{true};
|
bool console_enabled_{true};
|
||||||
bool foreground_{false};
|
bool foreground_{false};
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
std::string label_;
|
||||||
|
#endif // defined(__APPLE__)
|
||||||
std::optional<gid_t> forced_gid_;
|
std::optional<gid_t> forced_gid_;
|
||||||
std::optional<uid_t> forced_uid_;
|
std::optional<uid_t> forced_uid_;
|
||||||
std::optional<mode_t> forced_umask_;
|
std::optional<mode_t> forced_umask_;
|
||||||
@@ -608,7 +611,7 @@ public:
|
|||||||
|
|
||||||
static void display_version_information(std::vector<const char *> args);
|
static void display_version_information(std::vector<const char *> args);
|
||||||
|
|
||||||
static auto unmount(const std::string &mount_location) -> int;
|
auto unmount(const std::string &mount_location) -> int;
|
||||||
|
|
||||||
[[nodiscard]] auto get_mount_location() const -> std::string {
|
[[nodiscard]] auto get_mount_location() const -> std::string {
|
||||||
return mount_location_;
|
return mount_location_;
|
||||||
|
@@ -433,6 +433,8 @@ auto fuse_base::mount([[maybe_unused]] std::vector<std::string> orig_args,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
|
label_ = std::format("com.fifthgrid.blockstorage.repertory.{}.{}",
|
||||||
|
provider_type_to_string(prov), unique_id);
|
||||||
if (not foreground_) {
|
if (not foreground_) {
|
||||||
if (not utils::file::change_to_process_directory()) {
|
if (not utils::file::change_to_process_directory()) {
|
||||||
std::cerr << "Failed to change to process directory" << std::endl;
|
std::cerr << "Failed to change to process directory" << std::endl;
|
||||||
@@ -442,16 +444,14 @@ auto fuse_base::mount([[maybe_unused]] std::vector<std::string> orig_args,
|
|||||||
orig_args[0U] = utils::path::combine(".", {"repertory"});
|
orig_args[0U] = utils::path::combine(".", {"repertory"});
|
||||||
orig_args.insert(std::next(orig_args.begin()), "-f");
|
orig_args.insert(std::next(orig_args.begin()), "-f");
|
||||||
|
|
||||||
auto label = std::format("com.fifthgrid.blockstorage.repertory.{}.{}",
|
|
||||||
provider_type_to_string(prov), unique_id);
|
|
||||||
if (not utils::generate_launchd_plist(
|
if (not utils::generate_launchd_plist(
|
||||||
label, utils::path::combine("~", {"/Library/LaunchAgents"}),
|
label_, utils::path::combine("~", {"/Library/LaunchAgents"}),
|
||||||
orig_args, utils::path::absolute("."),
|
orig_args, utils::path::absolute("."),
|
||||||
fmt::format("/tmp/repertory_{}_{}.out",
|
fmt::format("/tmp/repertory_{}_{}.out",
|
||||||
provider_type_to_string(prov), unique_id),
|
provider_type_to_string(prov), unique_id),
|
||||||
fmt::format("/tmp/repertory_{}_{}.err",
|
fmt::format("/tmp/repertory_{}_{}.err",
|
||||||
provider_type_to_string(prov), unique_id))) {
|
provider_type_to_string(prov), unique_id))) {
|
||||||
std::cerr << fmt::format("Failed to generate plist|{}", label)
|
std::cerr << fmt::format("Failed to generate plist|{}", label_)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -461,7 +461,7 @@ auto fuse_base::mount([[maybe_unused]] std::vector<std::string> orig_args,
|
|||||||
utils::path::combine("~",
|
utils::path::combine("~",
|
||||||
{
|
{
|
||||||
"/Library/LaunchAgents",
|
"/Library/LaunchAgents",
|
||||||
fmt::format("{}.plist", label),
|
fmt::format("{}.plist", label_),
|
||||||
}))
|
}))
|
||||||
.c_str());
|
.c_str());
|
||||||
|
|
||||||
@@ -470,14 +470,14 @@ auto fuse_base::mount([[maybe_unused]] std::vector<std::string> orig_args,
|
|||||||
utils::path::combine("~",
|
utils::path::combine("~",
|
||||||
{
|
{
|
||||||
"/Library/LaunchAgents",
|
"/Library/LaunchAgents",
|
||||||
fmt::format("{}.plist", label),
|
fmt::format("{}.plist", label_),
|
||||||
}))
|
}))
|
||||||
.c_str());
|
.c_str());
|
||||||
|
|
||||||
ret = system(
|
ret = system(
|
||||||
fmt::format("launchctl kickstart gui/{}/{}", getuid(), label).c_str());
|
fmt::format("launchctl kickstart gui/{}/{}", getuid(), label_).c_str());
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
std::cerr << fmt::format("Failed to kickstart {}/{}", getuid(), label)
|
std::cerr << fmt::format("Failed to kickstart {}/{}", getuid(), label_)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -920,6 +920,19 @@ auto fuse_base::unlink_(const char *path) -> int {
|
|||||||
|
|
||||||
auto fuse_base::unmount(const std::string &mount_location) -> int {
|
auto fuse_base::unmount(const std::string &mount_location) -> int {
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
|
if (utils::file::file{
|
||||||
|
utils::path::combine("~", {"/Library/LaunchAgents", label_})}
|
||||||
|
.exists()) {
|
||||||
|
return system(
|
||||||
|
fmt::format("launchctl bootout gui/{} '{}' 1>/dev/null 2>&1", getuid(),
|
||||||
|
utils::path::combine("~",
|
||||||
|
{
|
||||||
|
"/Library/LaunchAgents",
|
||||||
|
fmt::format("{}.plist", label_),
|
||||||
|
}))
|
||||||
|
.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
auto cmd = "umount \"" + mount_location + "\" >/dev/null 2>&1";
|
auto cmd = "umount \"" + mount_location + "\" >/dev/null 2>&1";
|
||||||
#else // !defined(__APPLE__)
|
#else // !defined(__APPLE__)
|
||||||
#if FUSE_USE_VERSION >= 30
|
#if FUSE_USE_VERSION >= 30
|
||||||
|
Reference in New Issue
Block a user