From c328d568d4bc2d9286b7441879cbcf8341b56dc3 Mon Sep 17 00:00:00 2001 From: manu Date: Mon, 4 May 2009 16:20:41 +0000 Subject: [PATCH] TFTPROOT loads the RAMdisk through TFTP at boot time. It needs the network to be functionnal, and therefore must be called after config_finalize(). Unfortunately, config_finalize() attaches md0 through mdattach(), and when tftproot_getfile() attempts to attach it later by calling mdattach() again, it gets a failure. This change checks for the RAMdisk size in mdattach(). If it is zero, then the RAMdisk has not been loaded yet, and nothing is done. It will be attached later when tftproot_getfile() will call mdattach() --- sys/dev/md.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sys/dev/md.c b/sys/dev/md.c index b4f9453a1096..8b0a16d219ba 100644 --- a/sys/dev/md.c +++ b/sys/dev/md.c @@ -1,4 +1,4 @@ -/* $NetBSD: md.c,v 1.57 2009/01/13 13:35:52 yamt Exp $ */ +/* $NetBSD: md.c,v 1.58 2009/05/04 16:20:41 manu Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross, Leo Weppelman. @@ -46,9 +46,10 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.57 2009/01/13 13:35:52 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.58 2009/05/04 16:20:41 manu Exp $"); #include "opt_md.h" +#include "opt_tftproot.h" #include #include @@ -118,6 +119,8 @@ extern struct cfdriver md_cd; CFATTACH_DECL_NEW(md, sizeof(struct md_softc), 0, md_attach, 0, NULL); +extern size_t md_root_size; + /* * This is called if we are configured as a pseudo-device */ @@ -127,6 +130,14 @@ mdattach(int n) int i; cfdata_t cf; +#ifdef TFTPROOT + /* + * Attachement of md0 must be done after md_root_setconf(), + * because the RAMdisk is not loaded yet. + */ + if (md_root_size == 0) + return; +#endif if (config_cfattach_attach("md", &md_ca)) { printf("md: cfattach_attach failed\n"); return;