Skip to contentSkip to conversation

udev: what's up with old /dev ?

DISCUSSION Zack Weinberg 1 participant 1 message Oct 11, 2004

lore
Share & tools
lore
#0 lore raw
Quoted 6 lines · Hacksaw
Quoted 2 lines · Zack Weinberg

The very first thing init does is open /dev/console, and if it doesn't exist the entire boot hangs.

This raises a question: Would it be a useful thing to make a modified init that could run udev before it does anything else?

It wouldn't help. The opening of /dev/console actually happens inside the kernel, near the bottom of init/main.c:

        if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
                printk("Warning: unable to open an initial console.\n");

        (void) sys_dup(0);
        (void) sys_dup(0);

That's not a fatal error, but the userspace startup process does get stuck not very long afterward. (I'm not sure precisely where. It hadn't mounted filesystems read-write yet.)

Control reaches the above code after an initramfs is unpacked, so including /dev/console in an initramfs will work. I do not think it will work to invoke udevstart from an initramfs or initrd *without* also including a static /dev/console -- I'm pretty darn sure that control reaches /init in an initramfs after the above code executes. I'm not sure whether control reaches /linuxrc in an initrd before or after the above code.

Being inside the kernel at this point, it seems to me there ought to be some way to open device <5,1> without going through the filesystem, but I could not find one.

[Tangentially, I thought kernel-side syscalls had been stamped out, but there's still a __KERNEL_SYSCALLS__ #define at the top of the file and a bare execve() in run_init_process()... which does in fact get compiled to int $0x80 on my boring old x86...]

zw