implement /proc hotplugger

This commit is contained in:
illiliti 2020-07-15 23:26:12 +03:00
parent 888cf4d878
commit be2df26e38
4 changed files with 20 additions and 6 deletions

View File

@ -25,7 +25,7 @@ Dependencies
- Optional
* `blkid`
- Required for UUID, LABEL, PARTUUID support
* `mdev` OR `mdevd` OR `eudev` OR `systemd-udevd`
* `mdev` OR `mdevd` OR `eudev` OR `systemd-udevd` OR CONFIG_UEVENT_HELPER
- systemd-udevd not tested
* `lvm2`
- Required for LVM support

5
config
View File

@ -46,7 +46,10 @@
#root_opts=""
# device manager
# supported - udev, mdev, mdevd
#
# supported - none, proc, udev, mdev, mdevd
# none means no device manager. requires monolithic kernel and you will unable to use UUID, LABEL, PARTUUID, /dev/mapper/*
# proc requires monolithic kernel and legacy CONFIG_UEVENT_HELPER
#
#devmgr=""

14
init
View File

@ -91,6 +91,16 @@ setup_devmgr()
[ "$break" = devmgr ] && { print "break before setup_devmgr()"; sh; }
case "$devmgr" in
proc)
command -v device-helper > /proc/sys/kernel/hotplug
# get ready for fork bomb. kek
find /sys/devices -name uevent |
while read -r uevent; do
printf add > "$uevent"
done
;;
udev)
udevd -N never & devmgr_pid="$!"
udevadm trigger -c add -t subsystems
@ -133,7 +143,9 @@ boot_system()
{
[ "$break" = boot ] && { print "break before boot_system()"; sh; }
kill "$devmgr_pid"
{
kill "$devmgr_pid" || printf '\n' > /proc/sys/kernel/hotplug
} 2> /dev/null || :
# temporary workaround until util-linux release a new version
# see https://github.com/karelzak/util-linux/issues/997

View File

@ -364,9 +364,8 @@ copy_devmgr()
# false positive
# shellcheck disable=2016
case "$devmgr" in
none)
# TODO implement mode without device manager using deprecated
# /sys/kernel/uevent_helper or /proc/sys/kernel/hotplug
proc)
copy_binary find
;;
mdev)
for _binary in mdev find; do