Skip to content

Commit 8e7f843

Browse files
committed
improve logging for fakeudev, improve comments
Signed-off-by: Zen <[email protected]>
1 parent 27d14af commit 8e7f843

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/ugrd/fs/fakeudev.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,30 @@
1010

1111

1212
def fake_dm_udev(self) -> str:
13-
"""returns a shell function to fake udev for dm devices."""
13+
"""returns a shell function to fake udev for dm devices.
14+
Previously, ${dm}/uevent was sourced, but this has the potential to crash the shell
15+
16+
Checks for the existence of /sys/block/dm-* entries,
17+
for each entry, it checks if the device has a 'dev' and name file, it not, skips it.
18+
Fully initailzed deviecs should have a 'dm/name' file.
19+
20+
Reads the 'dev' file to get the device's major and minor numbers,
21+
uses these to create a udev database file in /run/udev/data/b<MAJOR>:<MINOR>.
22+
writes 'E:DM_UDEV_PRIMARY_SOURCE_FLAG=1\n' to this file, which signals to systemd that udev is functioning for this device.
23+
"""
1424
return r"""
1525
for dm in /sys/block/dm-*; do
1626
if [ ! -e "${dm}/dev" ]; then
27+
ewarn "Skipping fakeudev for device without 'dev' file: ${dm}"
1728
continue
1829
fi
1930
if [ ! -e "${dm}/dm/name" ]; then
31+
ewarn "Skipping fakeudev for device without 'dm/name' file: ${dm}"
2032
continue
2133
fi
2234
dev_name=$(cat ${dm}/dm/name)
2335
majmin=$(cat "${dm}/dev")
24-
einfo "Faking udev for: ${dev_name}"
36+
einfo "[${majmin}] Faking udev for: ${dev_name}"
2537
udev_db_file="/run/udev/data/b${majmin}"
2638
printf 'E:DM_UDEV_PRIMARY_SOURCE_FLAG=1\n' > "${udev_db_file}"
2739
done

0 commit comments

Comments
 (0)