fuse can not be mounted by systemd

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

fuse can not be mounted by systemd

Anudorannador
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.

------------------------------------------------------------------------------
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: fuse can not be mounted by systemd

Nikolaus Rath
On Jun 23 2017, Anudorannador <[hidden email]> wrote:

> 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.

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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: fuse can not be mounted by systemd

Anudorannador
Oh, I've found the reason: remove `PrivateTmp=true' and solved. :)

2017-06-24 1:14 GMT+08:00 Nikolaus Rath <[hidden email]>:

> On Jun 23 2017, Anudorannador <[hidden email]> wrote:
>> 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.
>
> 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

------------------------------------------------------------------------------
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...