Module Name: src Committed By: manu Date: Mon May 4 16:20:41 UTC 2009
Modified Files: src/sys/dev: md.c Log Message: 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() To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/sys/dev/md.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/md.c diff -u src/sys/dev/md.c:1.57 src/sys/dev/md.c:1.58 --- src/sys/dev/md.c:1.57 Tue Jan 13 13:35:52 2009 +++ src/sys/dev/md.c Mon May 4 16:20:41 2009 @@ -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 @@ 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 @@ 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;