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()
This commit is contained in:
manu 2009-05-04 16:20:41 +00:00
parent 183ff8793d
commit c328d568d4
1 changed files with 13 additions and 2 deletions

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/kernel.h>
@ -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;