From be2df26e3895a241a6c9d0f0ef4864b805e2cf2f Mon Sep 17 00:00:00 2001 From: illiliti Date: Wed, 15 Jul 2020 23:26:12 +0300 Subject: [PATCH] implement /proc hotplugger --- README.md | 2 +- config | 5 ++++- init | 14 +++++++++++++- tinyramfs | 5 ++--- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c17f62c..2a60bef 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/config b/config index 7cfef6a..160651c 100644 --- a/config +++ b/config @@ -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="" diff --git a/init b/init index 7d29a15..10173b7 100755 --- a/init +++ b/init @@ -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 diff --git a/tinyramfs b/tinyramfs index 32beccc..c19f1de 100755 --- a/tinyramfs +++ b/tinyramfs @@ -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