2.4.22 init/do_mounts.c Bug when booting a devfs CD

From: Chris Lingard
Date: Thu Oct 09 2003 - 06:02:28 EST


Hope I have the right person; you may be interested in this.

I boot a CD using initrd; the RAMDISK uses devfs within the linuxrc script
to pivot_root/chroot as in the documentation. In the documentation it
is suggested that root=/dev/rd/0 is used, if using devfs.

A boot using root=/dev/ram0 works fine, root=/dev/rd/0 shows a bug
in init/do_mounts.c, in void prepare_namespace(void)

The test:
if (initrd_load() && ROOT_DEV != MKDEV(RAMDISK_MAJOR, 0))
is true, and handle_initrd() is wrongly called. This is a bug, (I assume
that this code is to relinquish the original boot). The call that is used
is at the end of main.c where linuxrc is called instead of /sbin/init.

This is because rd/0 is not in root_dev_names; a patch is attached to fix
this.

Strangly enough, it still boots, despite linuxrc being called twice :-)

An alternative would be to change the documentation of initrd, so
that only root=/dev/ram0 is mentioned, despite using devfs.

Chris Lingard
diff -Naur linux-2.4.22.old/init/do_mounts.c linux-2.4.22/init/do_mounts.c
--- linux-2.4.22.old/init/do_mounts.c 2003-09-10 12:18:55.000000000 +0100
+++ linux-2.4.22/init/do_mounts.c 2003-09-23 12:46:36.000000000 +0100
@@ -227,6 +227,11 @@
{ "ataraid/d13p",0x72D0 },
{ "ataraid/d14p",0x72E0 },
{ "ataraid/d15p",0x72F0 },
+#ifdef CONFIG_BLK_DEV_RAM
+#ifdef CONFIG_BLK_DEV_INITRD
+ { "rd/0", 0x0100 },
+#endif
+#endif
{ "rd/c0d0p",0x3000 },
{ "rd/c0d0p1",0x3001 },
{ "rd/c0d0p2",0x3002 },