summaryrefslogtreecommitdiff
path: root/init/do_mounts.c
diff options
context:
space:
mode:
authorPierre Ossman <drzeus-list@drzeus.cx>2007-07-15 23:40:35 -0700
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-16 09:05:45 -0700
commitcc1ed7542c8c26af0f501da8006b9fce03e9aaca (patch)
treef618c959d3740151de50ba59b13c3af8d00a3b71 /init/do_mounts.c
parent4a19542e5f694cd408a32c3d9dc593ba9366e2d7 (diff)
downloadkernel-common-cc1ed7542c8c26af0f501da8006b9fce03e9aaca.tar.gz
kernel-common-cc1ed7542c8c26af0f501da8006b9fce03e9aaca.tar.bz2
kernel-common-cc1ed7542c8c26af0f501da8006b9fce03e9aaca.zip
init: wait for asynchronously scanned block devices
Some buses (e.g. USB and MMC) do their scanning of devices in the background, causing a race between them and prepare_namespace(). In order to be able to use these buses without an initrd, we now wait for the device specified in root= to actually show up. If the device never shows up than we will hang in an infinite loop. In order to not mess with setups that reboot on panic, the feature must be turned on via the command line option "rootwait". [bunk@stusta.de: root_wait can become static] Signed-off-by: Pierre Ossman <drzeus@drzeus.cx> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Adrian Bunk <bunk@stusta.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'init/do_mounts.c')
-rw-r--r--init/do_mounts.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 46fe407fb03e..4efa1e5385e3 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -25,6 +25,7 @@ int __initdata rd_doload; /* 1 = load RAM disk, 0 = don't load */
int root_mountflags = MS_RDONLY | MS_SILENT;
char * __initdata root_device_name;
static char __initdata saved_root_name[64];
+static int __initdata root_wait;
dev_t ROOT_DEV;
@@ -216,6 +217,16 @@ static int __init root_dev_setup(char *line)
__setup("root=", root_dev_setup);
+static int __init rootwait_setup(char *str)
+{
+ if (*str)
+ return 0;
+ root_wait = 1;
+ return 1;
+}
+
+__setup("rootwait", rootwait_setup);
+
static char * __initdata root_mount_data;
static int __init root_data_setup(char *str)
{
@@ -438,11 +449,20 @@ void __init prepare_namespace(void)
root_device_name += 5;
}
- is_floppy = MAJOR(ROOT_DEV) == FLOPPY_MAJOR;
-
if (initrd_load())
goto out;
+ /* wait for any asynchronous scanning to complete */
+ if ((ROOT_DEV == 0) && root_wait) {
+ printk(KERN_INFO "Waiting for root device %s...\n",
+ saved_root_name);
+ while (driver_probe_done() != 0 ||
+ (ROOT_DEV = name_to_dev_t(saved_root_name)) == 0)
+ msleep(100);
+ }
+
+ is_floppy = MAJOR(ROOT_DEV) == FLOPPY_MAJOR;
+
if (is_floppy && rd_doload && rd_load_disk(0))
ROOT_DEV = Root_RAM0;