]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
eudev: create static-nodes in init script
authorChangqing Li <changqing.li@windriver.com>
Fri, 20 May 2022 11:05:09 +0000 (19:05 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 21 May 2022 07:37:23 +0000 (08:37 +0100)
dev in modules.devname should be populated in /dev on boot.  remove
create static mode from udevd will make these devices cannot be
populated. Since commit [1], when use sysVinit, devices like
/dev/net/tun will not be created.

more info:
udevd in systemd also remove create static mode in udevd, but using
service kmod-static-nodes.service and systemd-tmpfiles-setup-dev.service
in systemd to create these node, so systemd works well.

For sysV, parse kmod static-nodes and generate the device nodes in init

[1] https://gitweb.gentoo.org/proj/eudev.git/commit/?id=2b7abd5ec9cc47a8b895df6db77fb1537c6f1a39

Signed-off-by: Changqing Li <changqing.li@windriver.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/udev/eudev/init
meta/recipes-core/udev/eudev_3.2.11.bb

index c60dbbf6d512b6bbf4bc5cd1403e335aaa2750de..477a525b21212ad72d2661e27e1218fca9fee5db 100644 (file)
@@ -23,6 +23,42 @@ kill_udevd () {
     [ -n "$pid" ] && kill $pid
 }
 
+make_static_nodes () {
+    [ -e /lib/modules/$(uname -r)/modules.devname ] || return 0
+    [ -x @KMOD@ ] || return 0
+
+    #output to /proc/self/fd/1 since /dev/stdout not created by udevd yet
+    @KMOD@ static-nodes --format=tmpfiles --output=/proc/self/fd/1 |
+    while read TTYPE TPATH TMODE TUSER TGROUP TAGE TARG; do
+    case "${TTYPE}" in
+    'd')
+            test -d "${TPATH}" || mkdir -p -m "${TMODE}" "${TPATH}"
+            ;;
+
+    'c!')
+            if [ ! -c "${TPATH}" ]; then
+                    old_ifs="${IFS}"
+                    IFS=:
+                    set -- ${TARG}
+                    IFS="${old_ifs}"
+                    mknod -m "${TMODE}" "${TPATH}" c "$@"
+            fi
+            ;;
+
+    *)
+            echo "Unparseable line (${TTYPE} ${TPATH} ${TMODE} ${TUSER} ${TGROUP} ${TAGE} ${TARG})"
+            return 1
+            ;;
+    esac
+    if [ "${TUSER}" != "-" ]; then
+            chown "${TUSER}" "${TPATH}"
+    fi
+    if [ "${TGROUP}" != "-" ]; then
+            chgrp "${TGROUP}" "${TPATH}"
+    fi
+    done
+}
+
 case "$1" in
   start)
     export ACTION=add
@@ -51,6 +87,7 @@ case "$1" in
     # make_extra_nodes
     kill_udevd > "/dev/null" 2>&1
 
+    make_static_nodes
     # trigger the sorted events
     [ -e /proc/sys/kernel/hotplug ] && printf '\0\n' >/proc/sys/kernel/hotplug
     @UDEVD@ -d
index 841039f6d745fd223942c25cf16df047b4debf6f..a0a19e501d33e5a72999f8ea98760f6f92afb310 100644 (file)
@@ -41,6 +41,7 @@ do_install:append() {
        install -d ${D}${sysconfdir}/init.d
        install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/udev
        sed -i s%@UDEVD@%${base_sbindir}/udevd% ${D}${sysconfdir}/init.d/udev
+       sed -i s%@KMOD@%${base_bindir}/kmod% ${D}${sysconfdir}/init.d/udev
 
        install -d ${D}${sysconfdir}/udev/rules.d
        install -m 0644 ${WORKDIR}/local.rules ${D}${sysconfdir}/udev/rules.d/local.rules
@@ -73,6 +74,7 @@ FILES:libudev = "${base_libdir}/libudev.so.*"
 FILES:eudev-hwdb = "${sysconfdir}/udev/hwdb.d"
 
 RDEPENDS:eudev-hwdb += "eudev"
+RDEPENDS:eudev += "kmod"
 
 RPROVIDES:${PN} = "hotplug udev"
 RPROVIDES:eudev-hwdb += "udev-hwdb"