mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-10-26 19:01:56 -04:00
Formatting: normalize brace style and parameter alignment
Some checks failed
mkdocs / deploy (push) Has been cancelled
Some checks failed
mkdocs / deploy (push) Has been cancelled
No functional change: libfuse/helper.cpp (fuse_daemonize, fuse_helper_opt_proc, fuse_parse_cmdline) and mergerfs fuse_init.cpp (_want helpers) reformatted to match the project's GNU-style brace placement and aligned parameter lists.
This commit is contained in:
parent
ec40866091
commit
da68cf3a85
2 changed files with 58 additions and 50 deletions
|
|
@ -45,7 +45,7 @@ _want(fuse_conn_info_t *conn_,
|
||||||
static
|
static
|
||||||
bool
|
bool
|
||||||
_capable(fuse_conn_info_t *conn_,
|
_capable(fuse_conn_info_t *conn_,
|
||||||
const int flag_)
|
const int flag_)
|
||||||
{
|
{
|
||||||
return !!(conn_->capable & flag_);
|
return !!(conn_->capable & flag_);
|
||||||
}
|
}
|
||||||
|
|
@ -53,7 +53,7 @@ _capable(fuse_conn_info_t *conn_,
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
_want_if_capable(fuse_conn_info_t *conn_,
|
_want_if_capable(fuse_conn_info_t *conn_,
|
||||||
const int flag_)
|
const int flag_)
|
||||||
{
|
{
|
||||||
if(::_capable(conn_,flag_))
|
if(::_capable(conn_,flag_))
|
||||||
::_want(conn_,flag_);
|
::_want(conn_,flag_);
|
||||||
|
|
@ -62,8 +62,8 @@ _want_if_capable(fuse_conn_info_t *conn_,
|
||||||
static
|
static
|
||||||
void
|
void
|
||||||
_want_if_capable(fuse_conn_info_t *conn_,
|
_want_if_capable(fuse_conn_info_t *conn_,
|
||||||
const int flag_,
|
const int flag_,
|
||||||
ConfigBOOL *want_)
|
ConfigBOOL *want_)
|
||||||
{
|
{
|
||||||
if(*want_ && ::_capable(conn_,flag_))
|
if(*want_ && ::_capable(conn_,flag_))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ fuse_helper_opt_proc(void *data,
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int add_default_subtype(const char *progname, struct fuse_args *args)
|
static int add_default_subtype(const char *progname, struct fuse_args *args)
|
||||||
|
|
@ -153,58 +153,66 @@ fuse_parse_cmdline(struct fuse_args *args_,
|
||||||
|
|
||||||
err:
|
err:
|
||||||
free(hopts.mountpoint);
|
free(hopts.mountpoint);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fuse_daemonize(int foreground)
|
int
|
||||||
|
fuse_daemonize(int foreground)
|
||||||
{
|
{
|
||||||
if (!foreground) {
|
if(!foreground)
|
||||||
int nullfd;
|
{
|
||||||
int waiter[2];
|
int nullfd;
|
||||||
char completed;
|
int waiter[2];
|
||||||
|
char completed;
|
||||||
|
|
||||||
if (pipe(waiter)) {
|
if(pipe(waiter))
|
||||||
perror("fuse_daemonize: pipe");
|
{
|
||||||
return -1;
|
perror("fuse_daemonize: pipe");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* demonize current process by forking it and killing the
|
||||||
|
* parent. This makes current process as a child of 'init'.
|
||||||
|
*/
|
||||||
|
switch(fork())
|
||||||
|
{
|
||||||
|
case -1:
|
||||||
|
perror("fuse_daemonize: fork");
|
||||||
|
return -1;
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
read(waiter[0], &completed, sizeof(completed));
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(setsid() == -1)
|
||||||
|
{
|
||||||
|
perror("fuse_daemonize: setsid");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
(void) chdir("/");
|
||||||
|
|
||||||
|
nullfd = open("/dev/null", O_RDWR, 0);
|
||||||
|
if(nullfd != -1)
|
||||||
|
{
|
||||||
|
(void) dup2(nullfd, 0);
|
||||||
|
(void) dup2(nullfd, 1);
|
||||||
|
(void) dup2(nullfd, 2);
|
||||||
|
if (nullfd > 2)
|
||||||
|
close(nullfd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Propagate completion of daemon initializatation */
|
||||||
|
completed = 1;
|
||||||
|
write(waiter[1], &completed, sizeof(completed));
|
||||||
|
close(waiter[0]);
|
||||||
|
close(waiter[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* demonize current process by forking it and killing the
|
|
||||||
* parent. This makes current process as a child of 'init'.
|
|
||||||
*/
|
|
||||||
switch(fork()) {
|
|
||||||
case -1:
|
|
||||||
perror("fuse_daemonize: fork");
|
|
||||||
return -1;
|
|
||||||
case 0:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
read(waiter[0], &completed, sizeof(completed));
|
|
||||||
_exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setsid() == -1) {
|
|
||||||
perror("fuse_daemonize: setsid");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
(void) chdir("/");
|
|
||||||
|
|
||||||
nullfd = open("/dev/null", O_RDWR, 0);
|
|
||||||
if (nullfd != -1) {
|
|
||||||
(void) dup2(nullfd, 0);
|
|
||||||
(void) dup2(nullfd, 1);
|
|
||||||
(void) dup2(nullfd, 2);
|
|
||||||
if (nullfd > 2)
|
|
||||||
close(nullfd);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Propagate completion of daemon initializatation */
|
|
||||||
completed = 1;
|
|
||||||
write(waiter[1], &completed, sizeof(completed));
|
|
||||||
close(waiter[0]);
|
|
||||||
close(waiter[1]);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue