Discussion:
[fuse-devel] fuse can not be mounted by systemd
Anudorannador
2017-06-23 03:14:54 UTC
Permalink
Hi !
I wrote a program, and there is a pice of the code:
```
char *fa[] = { "-f", "-odefault_permissions", "-oallow_other", NULL};

struct fuse_args fuse_args = FUSE_ARGS_INIT(sizeof
(fa)/sizeof(gpointer) - 1, fa);

struct fuse_chan *fuse_chan = fuse_mount(CFSDIR, &fuse_args);
if (!fuse_chan) {
fprintf("fuse_mount error: %s", strerror(errno));
exit(-1);
}

if (!(fuse = fuse_new(fuse_chan, &fuse_args, &fuse_ops,
sizeof(fuse_ops), NULL))) {
fprintf("fuse_new error: %s", strerror(errno));
exit(-1);
}

fuse_set_signal_handlers(fuse_get_session(fuse));
...
while(1){ ... }
```
When I run the program by cmd, that is:
# ./myprog
It works well. CFSDIR, which is a macro of '/etc/xxx', is mounted:
# df -h | grep /etc/xxx
# /dev/fuse 30M 12K 30M 1% /etc/xxx
The question is when I use systemd to start it :
# systemctl start myprog.service
it seems fine, no error but dirctory /etc/xxx not be mounted.
And catch nothing with command `df -h | grep /etc/xxx`

Here is my service:
```
[Unit]
Description=xxx
ConditionPathIsMountPoint=!/etc/xxx
After=network.service

[Service]
Type=simple
ExecStart=/usr/bin/myprog
PrivateTmp=true

[Install]
WantedBy=multi-user.target
```

Could you please help me ? Thanks.
Nikolaus Rath
2017-06-23 17:14:22 UTC
Permalink
Post by Anudorannador
Hi !
```
char *fa[] = { "-f", "-odefault_permissions", "-oallow_other", NULL};
struct fuse_args fuse_args = FUSE_ARGS_INIT(sizeof
(fa)/sizeof(gpointer) - 1, fa);
struct fuse_chan *fuse_chan = fuse_mount(CFSDIR, &fuse_args);
if (!fuse_chan) {
fprintf("fuse_mount error: %s", strerror(errno));
exit(-1);
}
if (!(fuse = fuse_new(fuse_chan, &fuse_args, &fuse_ops,
sizeof(fuse_ops), NULL))) {
fprintf("fuse_new error: %s", strerror(errno));
exit(-1);
}
fuse_set_signal_handlers(fuse_get_session(fuse));
...
while(1){ ... }
```
# ./myprog
# df -h | grep /etc/xxx
# /dev/fuse 30M 12K 30M 1% /etc/xxx
# systemctl start myprog.service
it seems fine, no error but dirctory /etc/xxx not be mounted.
And catch nothing with command `df -h | grep /etc/xxx`
```
[Unit]
Description=xxx
ConditionPathIsMountPoint=!/etc/xxx
After=network.service
[Service]
Type=simple
ExecStart=/usr/bin/myprog
PrivateTmp=true
[Install]
WantedBy=multi-user.target
```
Could you please help me ? Thanks.
Your program seems to daemonize, yet your service file claims its of
Type=simple. You probably have to either define it as Type=forking or
(better) change your program to not daemonize.

Also, systemctl status myprogr.service should give you more details.

Best,
-Nikolaus
--
GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

»Time flies like an arrow, fruit flies like a Banana.«
Anudorannador
2017-06-26 03:14:11 UTC
Permalink
Oh, I've found the reason: remove `PrivateTmp=true' and solved. :)
Post by Nikolaus Rath
Post by Anudorannador
Hi !
```
char *fa[] = { "-f", "-odefault_permissions", "-oallow_other", NULL};
struct fuse_args fuse_args = FUSE_ARGS_INIT(sizeof
(fa)/sizeof(gpointer) - 1, fa);
struct fuse_chan *fuse_chan = fuse_mount(CFSDIR, &fuse_args);
if (!fuse_chan) {
fprintf("fuse_mount error: %s", strerror(errno));
exit(-1);
}
if (!(fuse = fuse_new(fuse_chan, &fuse_args, &fuse_ops,
sizeof(fuse_ops), NULL))) {
fprintf("fuse_new error: %s", strerror(errno));
exit(-1);
}
fuse_set_signal_handlers(fuse_get_session(fuse));
...
while(1){ ... }
```
# ./myprog
# df -h | grep /etc/xxx
# /dev/fuse 30M 12K 30M 1% /etc/xxx
# systemctl start myprog.service
it seems fine, no error but dirctory /etc/xxx not be mounted.
And catch nothing with command `df -h | grep /etc/xxx`
```
[Unit]
Description=xxx
ConditionPathIsMountPoint=!/etc/xxx
After=network.service
[Service]
Type=simple
ExecStart=/usr/bin/myprog
PrivateTmp=true
[Install]
WantedBy=multi-user.target
```
Could you please help me ? Thanks.
Your program seems to daemonize, yet your service file claims its of
Type=simple. You probably have to either define it as Type=forking or
(better) change your program to not daemonize.
Also, systemctl status myprogr.service should give you more details.
Best,
-Nikolaus
--
GPG Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F
»Time flies like an arrow, fruit flies like a Banana.«
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--
fuse-devel mailing list
To unsubscribe or subscribe, visit https://lists.sourceforge.net/lists/listinfo/fuse-devel
Loading...