cleanup
Some checks reported errors
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit
Some checks reported errors
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
@@ -614,10 +614,9 @@ public:
|
||||
return mount_location_;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto mount([[maybe_unused]] std::vector<std::string> orig_args,
|
||||
std::vector<std::string> args,
|
||||
[[maybe_unused]] provider_type prov,
|
||||
[[maybe_unused]] std::string_view unique_id) -> int;
|
||||
[[nodiscard]] auto mount(std::vector<std::string> orig_args,
|
||||
std::vector<std::string> args, provider_type prov,
|
||||
std::string_view unique_id) -> int;
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
|
@@ -397,12 +397,13 @@ auto fuse_base::mkdir_(const char *path, mode_t mode) -> int {
|
||||
});
|
||||
}
|
||||
|
||||
auto fuse_base::mount(std::vector<std::string> orig_args,
|
||||
std::vector<std::string> args, provider_type prov,
|
||||
std::string_view unique_id) -> int {
|
||||
auto res = parse_args(args);
|
||||
if (res != 0) {
|
||||
return res;
|
||||
auto fuse_base::mount([[maybe_unused]] std::vector<std::string> orig_args,
|
||||
std::vector<std::string> args,
|
||||
[[maybe_unused]] provider_type prov,
|
||||
[[maybe_unused]] std::string_view unique_id) -> int {
|
||||
auto ret{parse_args(args)};
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<const char *> fuse_argv(args.size());
|
||||
@@ -476,20 +477,13 @@ auto fuse_base::mount(std::vector<std::string> orig_args,
|
||||
|
||||
notify_fuse_args_parsed(args);
|
||||
|
||||
const auto main_func = [&]() -> int {
|
||||
auto ret = fuse_main(
|
||||
static_cast<int>(fuse_argv.size()),
|
||||
reinterpret_cast<char **>(const_cast<char **>(fuse_argv.data())),
|
||||
&fuse_ops_, this);
|
||||
notify_fuse_main_exit(ret);
|
||||
return ret;
|
||||
};
|
||||
ret = fuse_main(
|
||||
static_cast<int>(fuse_argv.size()),
|
||||
reinterpret_cast<char **>(const_cast<char **>(fuse_argv.data())),
|
||||
&fuse_ops_, this);
|
||||
notify_fuse_main_exit(ret);
|
||||
|
||||
if (foreground_) {
|
||||
return main_func();
|
||||
}
|
||||
|
||||
return utils::create_daemon(main_func);
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto fuse_base::open_(const char *path, struct fuse_file_info *f_info) -> int {
|
||||
|
@@ -225,6 +225,28 @@ void windows_create_to_unix(const UINT32 &create_options,
|
||||
}
|
||||
|
||||
auto create_daemon(std::function<int()> main_func) -> int {
|
||||
const auto recreate_handles = []() -> int {
|
||||
close(STDIN_FILENO);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
|
||||
auto file_desc = open("/dev/null", O_RDWR);
|
||||
if (file_desc < 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
dup2(file_desc, STDIN_FILENO);
|
||||
dup2(file_desc, STDOUT_FILENO);
|
||||
dup2(file_desc, STDERR_FILENO);
|
||||
|
||||
if (file_desc > STDERR_FILENO) {
|
||||
close(file_desc);
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
#if defined(__APPLE__)
|
||||
auto pid = fork();
|
||||
if (pid < 0) {
|
||||
return 1;
|
||||
@@ -247,31 +269,43 @@ auto create_daemon(std::function<int()> main_func) -> int {
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
close(STDIN_FILENO);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
|
||||
auto file_desc = open("/dev/null", O_RDWR);
|
||||
if (file_desc < 0) {
|
||||
if (recreate_handles() != 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
dup2(file_desc, STDIN_FILENO);
|
||||
dup2(file_desc, STDOUT_FILENO);
|
||||
dup2(file_desc, STDERR_FILENO);
|
||||
|
||||
if (file_desc > STDERR_FILENO) {
|
||||
close(file_desc);
|
||||
}
|
||||
|
||||
signal(SIGCHLD, SIG_DFL);
|
||||
signal(SIGHUP, SIG_DFL);
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
umask(0);
|
||||
chdir("/");
|
||||
|
||||
return main_func();
|
||||
#else // !defined(__APPLE__)
|
||||
auto pid = fork();
|
||||
if (pid < 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (pid == 0) {
|
||||
signal(SIGCHLD, SIG_DFL);
|
||||
|
||||
if (setsid() < 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (recreate_handles() != 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
umask(0);
|
||||
chdir("/");
|
||||
return main_func();
|
||||
}
|
||||
|
||||
signal(SIGCHLD, SIG_IGN);
|
||||
#endif // defined(__APPLE__)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(__APPLE__)
|
||||
|
Reference in New Issue
Block a user