Merge pull request #26693 from poettering/udev-loop-links

udev: add /dev/loop/by-inode/… + /dev/loop/by-ref/… loopback block device symlinks
This commit is contained in:
Lennart Poettering
2023-03-10 09:34:31 +01:00
committed by GitHub
10 changed files with 457 additions and 16 deletions
+22
View File
@@ -430,6 +430,28 @@ mount -t ddi "${image}.gpt" "$T" -o ro,X-mount.mkdir,discard
umount -R "$T"
rmdir "$T"
LOOP="$(systemd-dissect --attach --loop-ref=waldo "${image}.raw")"
# Wait until the symlinks we want to test are established
udevadm trigger -w "$LOOP"
# Check if the /dev/loop/* symlinks really reference the right device
test /dev/loop/by-ref/waldo -ef "$LOOP"
if [ "$(stat -c '%Hd:%Ld' "${image}.raw")" != '?d:?d' ] ; then
# Old stat didn't know the %Hd and %Ld specifiers and turned them into ?d
# instead. Let's simply skip the test on such old systems.
test "$(stat -c '/dev/loop/by-inode/%Hd:%Ld-%i' "${image}.raw")" -ef "$LOOP"
fi
# Detach by loopback device
systemd-dissect --detach "$LOOP"
# Detach by backing inode
systemd-dissect --attach --loop-ref=waldo "${image}.raw"
systemd-dissect --detach "${image}.raw"
(! systemd-dissect --detach "${image}.raw")
echo OK >/testok
exit 0