From: "Darrick J. Wong" <djwong@kernel.org>
To: Bernd Schubert <bernd@bsbernd.com>
Cc: neal@gompa.dev, linux-fsdevel@vger.kernel.org,
joannelkoong@gmail.com, miklos@szeredi.hu,
fuse-devel@lists.linux.dev
Subject: Re: [PATCH 12/13] example/service: create a sample systemd service for a high-level fuse server
Date: Mon, 27 Apr 2026 08:13:29 -0700 [thread overview]
Message-ID: <20260427151329.GN7739@frogsfrogsfrogs> (raw)
In-Reply-To: <5b50e0a7-fe4b-4af4-a765-a91d21ab3852@bsbernd.com>
On Sun, Apr 26, 2026 at 11:21:21PM +0200, Bernd Schubert wrote:
>
>
> On 4/23/26 01:22, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> >
> > Create a simple high-level fuse server that can be run as a systemd
> > service.
> >
> > Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
> > ---
> > example/single_file.h | 38 ++++++
> > example/meson.build | 6 +
> > example/service_hl.c | 224 +++++++++++++++++++++++++++++++++++
> > example/service_hl.socket.in | 15 ++
> > example/service_hl@.service | 102 ++++++++++++++++
> > example/service_ll.c | 1
> > example/single_file.c | 271 +++++++++++++++++++++++++++++++++++++++---
> > 7 files changed, 640 insertions(+), 17 deletions(-)
> > create mode 100644 example/service_hl.c
> > create mode 100644 example/service_hl.socket.in
> > create mode 100644 example/service_hl@.service
> >
> >
> > diff --git a/example/single_file.h b/example/single_file.h
> > index d8a91adbf875ef..86edb51afb3384 100644
> > --- a/example/single_file.h
> > +++ b/example/single_file.h
> > @@ -124,6 +124,7 @@ ssize_t single_file_pread(char *buf, size_t count, off_t pos);
> >
> > /* low-level fuse operation handlers */
> >
> > +#ifdef USE_SINGLE_FILE_LL_API
> > bool is_single_file_child(fuse_ino_t parent, const char *name);
> > bool is_single_file_ino(fuse_ino_t ino);
> >
> > @@ -149,5 +150,42 @@ void single_file_ll_fsync(fuse_req_t req, fuse_ino_t ino, int datasync,
> >
> > int reply_buf_limited(fuse_req_t req, const char *buf, size_t bufsize,
> > off_t off, size_t maxsize);
> > +#endif
> > +
> > +/* high-level fuse operation handlers */
> > +
> > +#ifdef USE_SINGLE_FILE_HL_API
> > +bool is_single_open_file_path(const struct fuse_file_info *fi, const char *name);
> > +
> > +int single_file_hl_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
> > + off_t offset, struct fuse_file_info *fi,
> > + enum fuse_readdir_flags flags);
> > +
> > +int single_file_hl_statfs(const char *path, struct statvfs *buf);
> > +
> > +int single_file_hl_statx(const char *path, int statx_flags, int statx_mask,
> > + struct statx *stx, struct fuse_file_info *fi);
> > +
> > +int single_file_hl_getattr(const char *path, struct stat *stbuf,
> > + struct fuse_file_info *fi);
> > +int single_file_hl_chmod(const char *path, mode_t mode,
> > + struct fuse_file_info *fi);
> > +int single_file_hl_utimens(const char *path, const struct timespec ctv[2],
> > + struct fuse_file_info *fi);
> > +int single_file_hl_chown(const char *path, uid_t owner, gid_t group,
> > + struct fuse_file_info *fi);
> > +int single_file_hl_truncate(const char *path, off_t len,
> > + struct fuse_file_info *fi);
> > +
> > +int single_file_hl_opendir(const char *path, struct fuse_file_info *fi);
> > +int single_file_hl_open(const char *path, struct fuse_file_info *fi);
> > +
> > +int single_file_hl_fsync(const char *path, int datasync,
> > + struct fuse_file_info *fi);
> > +#endif
> > +
> > +#if !defined(USE_SINGLE_FILE_LL_API) && !defined(USE_SINGLE_FILE_HL_API)
> > +# warning USE_SINGLE_FILE_[HL]L_API not defined!
> > +#endif
> >
> > #endif /* FUSE_SINGLE_FILE_H_ */
> > diff --git a/example/meson.build b/example/meson.build
> > index e948f6ba74fdfa..19a383f7cd2c74 100644
> > --- a/example/meson.build
> > +++ b/example/meson.build
> > @@ -19,6 +19,12 @@ if platform.endswith('linux')
> > configure_file(input: 'service_ll.socket.in',
> > output: 'service_ll.socket',
> > configuration: private_cfg)
> > +
> > + single_file_examples += [ 'service_hl' ]
> > + configure_file(input: 'service_hl.socket.in',
> > + output: 'service_hl.socket',
> > + configuration: private_cfg)
> > +
> > endif
> >
> > threaded_examples = [ 'notify_inval_inode',
> > diff --git a/example/service_hl.c b/example/service_hl.c
> > new file mode 100644
> > index 00000000000000..9c4f3ae7a6cf3c
> > --- /dev/null
> > +++ b/example/service_hl.c
> > @@ -0,0 +1,224 @@
> > +/*
> > + * FUSE: Filesystem in Userspace
> > + * Copyright (C) 2026 Oracle.
> > + *
> > + * This program can be distributed under the terms of the GNU GPLv2.
> > + * See the file GPL2.txt.
> > + */
> > +
> > +/** @file
> > + *
> > + * minimal example filesystem using high-level API and systemd service api
>
> Could you add a bit more context?
>
> - Shows how to build a high level FUSE filesystems that can be managed
> by systemd
> - Enables on-demand filesystem mounting via socket activation
> - Allows running FUSE servers with minimal privileges (unlike
> traditional FUSE which needs mount permissions)
I will do that for both service_[hl]l.c files. Currently I have for the
lowlevel example:
* Minimal example filesystem using low-level API and systemd service API.
*
* - Shows how to build a low level FUSE filesystem server that can be managed
* by systemd
* - Enables on-demand filesystem mounting via socket activation
* - Demonstrates requesting resources from the mount-caller's environment
* - Allows running FUSE servers with minimal privileges; isolated mount,
* network, and pid namespaces; and a separate uid/gid (unlike traditional
* FUSE which needs mount permissions and runs in the caller's environment)
*
* Compile with:
*
* gcc -Wall single_file.c service_ll.c `pkg-config fuse3 --cflags --libs` -o service_ll
*
* Note: If the pkg-config command fails due to the absence of the fuse3.pc
* file, you should configure the path to the fuse3.pc file in the
* PKG_CONFIG_PATH variable.
*
* Change the ExecStart line in service_ll@.service:
*
* ExecStart=/path/to/service_ll
*
* to point to the actual path of the service_ll binary.
*
* Finally, install the service_ll@.service and service_ll.socket files to the
* systemd service directory, usually /run/systemd/system. Run these commands
* to activate:
*
* systemctl daemon-reload
* systemctl start service_ll.socket
*
* Then mount with:
*
* mount -t fuse.service_ll /dev/sda /mnt
and similar for service_hl.c.
--D
>
> Thanks,
> Bernd
>
next prev parent reply other threads:[~2026-04-27 15:13 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-22 23:15 [PATCHBOMB v5] fuse/libfuse/e2fsprogs/etc: containerize ext4 for safer operation Darrick J. Wong
2026-04-22 23:18 ` [PATCHSET v5] libfuse: run fuse servers as a contained service Darrick J. Wong
2026-04-22 23:19 ` [PATCH 01/13] Refactor mount code / move common functions to mount_util.c Darrick J. Wong
2026-04-22 23:19 ` [PATCH 02/13] mount_service: add systemd socket service mounting helper Darrick J. Wong
2026-04-28 18:08 ` Darrick J. Wong
2026-04-29 15:23 ` Darrick J. Wong
2026-04-22 23:20 ` [PATCH 03/13] mount_service: create high level fuse helpers Darrick J. Wong
2026-04-22 23:20 ` [PATCH 04/13] mount_service: use the new mount api for the mount service Darrick J. Wong
2026-04-22 23:20 ` [PATCH 05/13] mount_service: update mtab after a successful mount Darrick J. Wong
2026-04-22 23:20 ` [PATCH 06/13] util: hoist the fuse.conf parsing and setuid mode enforcement code Darrick J. Wong
2026-04-26 20:42 ` Bernd Schubert
2026-04-27 14:40 ` Darrick J. Wong
2026-04-22 23:21 ` [PATCH 07/13] util: fix checkpatch complaints in fuser_conf.[ch] Darrick J. Wong
2026-04-22 23:21 ` [PATCH 08/13] mount_service: enable unprivileged users in a similar manner as fusermount Darrick J. Wong
2026-04-22 23:21 ` [PATCH 09/13] mount.fuse3: integrate systemd service startup Darrick J. Wong
2026-04-28 18:10 ` Darrick J. Wong
2026-04-22 23:21 ` [PATCH 10/13] mount_service: allow installation as a setuid program Darrick J. Wong
2026-04-22 23:22 ` [PATCH 11/13] example/service_ll: create a sample systemd service fuse server Darrick J. Wong
2026-04-26 21:28 ` Bernd Schubert
2026-04-27 14:51 ` Darrick J. Wong
2026-04-22 23:22 ` [PATCH 12/13] example/service: create a sample systemd service for a high-level " Darrick J. Wong
2026-04-26 21:04 ` Bernd Schubert
2026-04-27 15:04 ` Darrick J. Wong
2026-04-26 21:21 ` Bernd Schubert
2026-04-27 15:13 ` Darrick J. Wong [this message]
2026-04-22 23:22 ` [PATCH 13/13] nullfs: support fuse systemd service mode Darrick J. Wong
2026-04-26 16:35 ` [PATCHSET v5] libfuse: run fuse servers as a contained service Bernd Schubert
2026-04-26 16:56 ` Darrick J. Wong
2026-04-26 19:35 ` Bernd Schubert
2026-04-26 20:23 ` Bernd Schubert
2026-04-22 23:19 ` [PATCHSET 1/2] libext2fs: fix some missed fsync calls Darrick J. Wong
2026-04-22 23:23 ` [PATCH 1/3] libext2fs: always fsync the device when flushing the cache Darrick J. Wong
2026-04-22 23:23 ` [PATCH 2/3] libext2fs: always fsync the device when closing the unix IO manager Darrick J. Wong
2026-04-22 23:23 ` [PATCH 3/3] libext2fs: only fsync the unix fd if we wrote to the device Darrick J. Wong
2026-04-22 23:19 ` [PATCHSET v5 2/2] fuse4fs: run servers as a contained service Darrick J. Wong
2026-04-22 23:23 ` [PATCH 01/10] libext2fs: make it possible to extract the fd from an IO manager Darrick J. Wong
2026-04-22 23:24 ` [PATCH 02/10] libext2fs: fix checking for valid fds in mmp.c Darrick J. Wong
2026-04-22 23:24 ` [PATCH 03/10] unix_io: allow passing /dev/fd/XXX paths to the unixfd IO manager Darrick J. Wong
2026-04-22 23:24 ` [PATCH 04/10] libext2fs: fix MMP code to work with " Darrick J. Wong
2026-04-22 23:24 ` [PATCH 05/10] libext2fs: bump libfuse API version to 3.19 Darrick J. Wong
2026-04-22 23:25 ` [PATCH 06/10] fuse4fs: hoist some code out of fuse4fs_main Darrick J. Wong
2026-04-22 23:25 ` [PATCH 07/10] fuse4fs: enable safe service mode Darrick J. Wong
2026-04-22 23:25 ` [PATCH 08/10] fuse4fs: set proc title when in fuse " Darrick J. Wong
2026-04-22 23:25 ` [PATCH 09/10] fuse4fs: make MMP work correctly in safe " Darrick J. Wong
2026-04-22 23:26 ` [PATCH 10/10] debian: update packaging for fuse4fs service Darrick J. Wong
2026-04-22 23:29 ` [RFC PATCH 1/4] fusefatfs: enable fuse systemd service mode Darrick J. Wong
2026-04-22 23:30 ` [RFC PATCH 2/4] exfat: " Darrick J. Wong
2026-04-22 23:32 ` [RFC PATCH 3/4] fuseiso: enable " Darrick J. Wong
2026-04-22 23:32 ` [RFC PATCH 4/4] httpdirfs: enable fuse " Darrick J. Wong
2026-04-23 8:44 ` [PATCHBOMB v5] fuse/libfuse/e2fsprogs/etc: containerize ext4 for safer operation Amir Goldstein
2026-04-23 14:50 ` Darrick J. Wong
-- strict thread matches above, loose matches on Subject: below --
2026-04-30 21:15 [PATCHSET v5.1] libfuse: run fuse servers as a contained service Darrick J. Wong
2026-04-30 21:18 ` [PATCH 12/13] example/service: create a sample systemd service for a high-level fuse server Darrick J. Wong
2026-04-09 22:20 [PATCHSET v4] libfuse: run fuse servers as a contained service Darrick J. Wong
2026-04-09 22:23 ` [PATCH 12/13] example/service: create a sample systemd service for a high-level fuse server Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260427151329.GN7739@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=bernd@bsbernd.com \
--cc=fuse-devel@lists.linux.dev \
--cc=joannelkoong@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=neal@gompa.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.