Skip to content

Commit 5a7149c

Browse files
committed
lkl: systemd: use lklfuse lock parameter
Use an ID_FS_UUID based lock file to avoid duplicate mounts. If udev doesn't provide an id then use a static noid path, ensuring lock conflict with any other id-less mount. Signed-off-by: David Disseldorp <ddiss@suse.de>
1 parent 29e4402 commit 5a7149c

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

tools/lkl/systemd/lklfuse-mount@.service

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Requires=modprobe@fuse.service
66

77
[Service]
88
RuntimeDirectory=lklfuse-%i
9+
StateDirectory=lklfuse/fsid-mutex
910
# The "allow_other" mount option permits fuse mount access by users other than
1011
# the lklfuse user, and requires a "user_allow_other" setting in fuse3.conf
1112
Environment=LKLFUSE_ARGS="-s -oallow_other"
@@ -18,8 +19,11 @@ EnvironmentFile=-/etc/lklfuse.conf
1819
# run as unprivileged user
1920
User=lklfuse
2021
Group=lklfuse
21-
ExecCondition=/bin/bash -c "udevadm info -q env -x --property=ID_FS_TYPE -n \"%I\" > ${RUNTIME_DIRECTORY}/udev.env"
22-
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"
22+
ExecCondition=/bin/bash -xc "udevadm info -q env -x --property=ID_FS_TYPE,ID_FS_UUID -n \"%I\" > ${RUNTIME_DIRECTORY}/udev.env"
23+
# Use an ID_FS_UUID based lock file to avoid duplicate mounts.
24+
# If udev doesn't provide an id then use a static noid path, ensuring lock
25+
# conflict with any other id-less mount.
26+
ExecStart=/bin/bash -xc ". ${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\",lock=\"${STATE_DIRECTORY}/${ID_FS_UUID:-noid}\" $LKLFUSE_ARGS \"/dev/%I\" ${RUNTIME_DIRECTORY}"
2327

2428
[Install]
2529
WantedBy=default.target

0 commit comments

Comments
 (0)