Skip to content

coldplug: recreate device nodes before udevtrigger - #53

Open
fwerkor wants to merge 1 commit into
openwrt:mainfrom
fwerkor:fix/coldplug-devnodes
Open

fwerkor wants to merge 1 commit into
openwrt:mainfrom
fwerkor:fix/coldplug-devnodes

Conversation

@fwerkor

@fwerkor fwerkor commented Oct 9, 2026 •

Copy link
Copy Markdown

Summary

procd_coldplug() replaces /dev with a fresh tmpfs and then depends on asynchronous udevtrigger/hotplug processing to recreate device nodes. This leaves a window where devices already present in sysfs, including the active console tty, do not exist under /dev.

In repeated downstream x86_64 QEMU reboot tests on an older procd baseline this reaches STATE_UBUS before the console nodes are available, producing:

procd: failed to set stdio: No such file or directory

and the expected askconsole shell never appears.

Current procd already uses patch_stdio() after 615e929, so a missing /dev/console can fall back to /dev/null instead of emitting that exact error. That protects procd's stdio but does not recreate the tty named by console=, so the underlying coldplug race for askconsole remains.

Change

Reuse the existing mkdev("*") sysfs scanner immediately after remounting /dev, before launching udevtrigger. Devices that already exist in sysfs are therefore available synchronously.

Those precreated nodes initially use the scanner's restrictive mode. The normal hotplug pass remains authoritative: handle_makedev() now applies the requested mode when mknod() succeeds or returns EEXIST, then applies the configured group as before. This preserves the existing modes/groups for nodes such as tty, zero, random and urandom.

This follows the same underlying rationale as 6dafa86 (initd/coldplug: create /dev/null before running udevtrigger), while avoiding more per-device special cases.

@fwerkor
fwerkor force-pushed the fix/coldplug-devnodes branch from 3c56eb9 to b79e42e Compare October 9, 2026 05:01
coldplug replaces /dev with an empty tmpfs and then relies on asynchronous uevents to recreate device nodes. Reuse the existing mkdev scanner so devices already present in sysfs are available synchronously before the state machine can advance.

Because the normal hotplug mknod path may now encounter those nodes with EEXIST, explicitly apply the requested mode to existing nodes before applying any configured group. The regular udevtrigger/hotplug pass still remains authoritative for final permissions and handlers.

Signed-off-by: Cao Yuhang <caoyuhang@fwerkor.com>
@fwerkor
fwerkor force-pushed the fix/coldplug-devnodes branch from b79e42e to 9b4237a Compare October 9, 2026 05:04
@fwerkor
fwerkor marked this pull request as ready for review October 9, 2026 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant