Skip to content

Commit

Permalink
Merge pull request #568 from ddiss/lklfuse_udev_systemd
Browse files Browse the repository at this point in the history
lkl: systemd: add example udev and systemd service files
  • Loading branch information
tavip authored Feb 20, 2025
2 parents e2b7eed + d95384a commit 7769847
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tools/lkl/systemd/61-lklfuse.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
SUBSYSTEM!="block", SUBSYSTEMS!="usb", GOTO="lklfuse_end"
#TAG+="lklfuse-dbg-block-filter"
# XXX remove should be handled by systemd service ConditionPathExists for %k
# device node, but it doesn't appear to work, so manually stop.
ACTION=="remove", TAG+="lklfuse-dbg-got-remove", \
RUN+="/usr/bin/systemctl stop lklfuse-mount@%k", GOTO="lklfuse_end"
#TAG+="lklfuse-dbg-remove-filter"

# only support a subset of filesystems on USB devices for now. Btrfs omitted
# from the default set, as lklfuse lacks multi-device support.
ENV{ID_FS_TYPE}!="vfat|exfat|xfs|ext4|ext3|ext2", GOTO="lklfuse_end"
#TAG+="lklfuse-dbg-fs-filter"

ACTION=="add", TAG+="systemd", \
OWNER="lklfuse", GROUP="lklfuse", ENV{UDISKS_IGNORE}="1", \
ENV{SYSTEMD_WANTS}+="lklfuse-mount@%k.service"

LABEL="lklfuse_end"
25 changes: 25 additions & 0 deletions tools/lkl/systemd/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[Unit]
Description=EXPERIMENTAL: Mount a storage device via lklfuse
ConditionPathExists=/dev/%I
After[email protected]
Requires[email protected]

[Service]
RuntimeDirectory=lklfuse-%i
# The "allow_other" mount option permits fuse mount access by users other than
# the lklfuse user, and requires a "user_allow_other" setting in fuse3.conf
Environment=LKLFUSE_ARGS="-s -oallow_other"
# Override LKLFUSE_ARGS in the EnvironmentFile if desired. See lklfuse --help
EnvironmentFile=-/etc/lklfuse.conf
# The following sandboxing works, but the mountpoint is in a new mount namespace
#ProtectSystem=strict
#ProtectHome=true
#PrivateNetwork=true
# run as unprivileged user
User=lklfuse
Group=lklfuse
ExecCondition=/bin/bash -c "udevadm info -q env -x --property=ID_FS_TYPE -n \"%I\" > ${RUNTIME_DIRECTORY}/udev.env"
ExecStart=/bin/bash -c ". ${RUNTIME_DIRECTORY}/udev.env; rm ${RUNTIME_DIRECTORY}/udev.env; /usr/bin/lklfuse -f -ofsname=\"/dev/%I\",subtype=\"lkl.$ID_FS_TYPE\",type=\"$ID_FS_TYPE\" $LKLFUSE_ARGS \"/dev/%I\" $RUNTIME_DIRECTORY"

[Install]
WantedBy=default.target

0 comments on commit 7769847

Please sign in to comment.