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_;
|
return mount_location_;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto mount([[maybe_unused]] std::vector<std::string> orig_args,
|
[[nodiscard]] auto mount(std::vector<std::string> orig_args,
|
||||||
std::vector<std::string> args,
|
std::vector<std::string> args, provider_type prov,
|
||||||
[[maybe_unused]] provider_type prov,
|
std::string_view unique_id) -> int;
|
||||||
[[maybe_unused]] std::string_view unique_id) -> int;
|
|
||||||
};
|
};
|
||||||
} // namespace repertory
|
} // 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,
|
auto fuse_base::mount([[maybe_unused]] std::vector<std::string> orig_args,
|
||||||
std::vector<std::string> args, provider_type prov,
|
std::vector<std::string> args,
|
||||||
std::string_view unique_id) -> int {
|
[[maybe_unused]] provider_type prov,
|
||||||
auto res = parse_args(args);
|
[[maybe_unused]] std::string_view unique_id) -> int {
|
||||||
if (res != 0) {
|
auto ret{parse_args(args)};
|
||||||
return res;
|
if (ret != 0) {
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<const char *> fuse_argv(args.size());
|
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);
|
notify_fuse_args_parsed(args);
|
||||||
|
|
||||||
const auto main_func = [&]() -> int {
|
ret = fuse_main(
|
||||||
auto ret = fuse_main(
|
static_cast<int>(fuse_argv.size()),
|
||||||
static_cast<int>(fuse_argv.size()),
|
reinterpret_cast<char **>(const_cast<char **>(fuse_argv.data())),
|
||||||
reinterpret_cast<char **>(const_cast<char **>(fuse_argv.data())),
|
&fuse_ops_, this);
|
||||||
&fuse_ops_, this);
|
notify_fuse_main_exit(ret);
|
||||||
notify_fuse_main_exit(ret);
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (foreground_) {
|
return ret;
|
||||||
return main_func();
|
|
||||||
}
|
|
||||||
|
|
||||||
return utils::create_daemon(main_func);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fuse_base::open_(const char *path, struct fuse_file_info *f_info) -> int {
|
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 {
|
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();
|
auto pid = fork();
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
return 1;
|
return 1;
|
||||||
@@ -247,31 +269,43 @@ auto create_daemon(std::function<int()> main_func) -> int {
|
|||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
close(STDIN_FILENO);
|
if (recreate_handles() != 0) {
|
||||||
close(STDOUT_FILENO);
|
|
||||||
close(STDERR_FILENO);
|
|
||||||
|
|
||||||
auto file_desc = open("/dev/null", O_RDWR);
|
|
||||||
if (file_desc < 0) {
|
|
||||||
return 1;
|
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(SIGCHLD, SIG_DFL);
|
||||||
signal(SIGHUP, SIG_DFL);
|
signal(SIGHUP, SIG_DFL);
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
|
||||||
umask(0);
|
umask(0);
|
||||||
chdir("/");
|
chdir("/");
|
||||||
|
|
||||||
return main_func();
|
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__)
|
#if defined(__APPLE__)
|
||||||
|
Reference in New Issue
Block a user