Module Name:    src
Committed By:   riz
Date:           Thu Jul  5 17:36:31 UTC 2012

Modified Files:
        src/sys/arch/atari/atari [netbsd-6]: autoconf.c
        src/sys/dev [netbsd-6]: md.c
        src/sys/fs/msdosfs [netbsd-6]: msdosfs_vfsops.c

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #395):
        sys/fs/msdosfs/msdosfs_vfsops.c: revision 1.95
        sys/arch/atari/atari/autoconf.c: revision 1.62
        sys/dev/md.c: revision 1.67
Add a dirty hack for atari's ancient installation ramdisk:
 Forcibly configure md0, md1, and md2 devices before setroot()
 for atari's traditional "auto-load from floppy on open" md_root device
 which loads installation ramdisk image from floppy.
 md(4) has been changed dynamically configured at first open after 5.0
 and md devices won't appear in "root device:" prompt without this hack.
Tested on TT030.
Should be pulled up to netbsd-6.
Make sure that disklabel of md(4) device is initialized
in the case where it's configured in MD md_open_hook().
Without this, msdosfs_mountfs() (which is called from msdosfs_mountroot())
will be called with uninitialized disklabel (d_secsize == 0) and
it gets "panic: buf mem pool index 23" later on atari.
This is because getdisksize() doesn't check returned d_secsize value
and msdosfs_mountfs() blindly calls bread(9) with size==0 in that case.
Should be pulled up to netbsd-6 (at least for atari).
Add a sanity check if secsize returned from getdisksize() isn't bogus.
This prevent possible panic "panic: buf mem pool index 23" later in
vfs_bio.c:buf_mempoolidx().
(I'm not sure if it's okay for getdisksize() to assume that
 partinfo taken from DIOCGPART is properly initialized
 on all disk(9) devices or not)
See also:
http://mail-index.NetBSD.org/source-changes/2012/06/30/msg035298.html


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.61.8.1 src/sys/arch/atari/atari/autoconf.c
cvs rdiff -u -r1.66 -r1.66.14.1 src/sys/dev/md.c
cvs rdiff -u -r1.93 -r1.93.6.1 src/sys/fs/msdosfs/msdosfs_vfsops.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/arch/atari/atari/autoconf.c
diff -u src/sys/arch/atari/atari/autoconf.c:1.61 src/sys/arch/atari/atari/autoconf.c:1.61.8.1
--- src/sys/arch/atari/atari/autoconf.c:1.61	Sun Jun  5 17:09:18 2011
+++ src/sys/arch/atari/atari/autoconf.c	Thu Jul  5 17:36:31 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: autoconf.c,v 1.61 2011/06/05 17:09:18 matt Exp $	*/
+/*	$NetBSD: autoconf.c,v 1.61.8.1 2012/07/05 17:36:31 riz Exp $	*/
 
 /*
  * Copyright (c) 1995 Leo Weppelman
@@ -31,7 +31,9 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.61 2011/06/05 17:09:18 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.61.8.1 2012/07/05 17:36:31 riz Exp $");
+
+#include "opt_md.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -41,10 +43,17 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
 #include <sys/device.h>
 #include <sys/disklabel.h>
 #include <sys/disk.h>
+#include <sys/malloc.h>
 #include <machine/disklabel.h>
 #include <machine/cpu.h>
 #include <atari/atari/device.h>
 
+#if defined(MEMORY_DISK_HOOKS)
+#include <dev/md.h>
+#endif
+
+#include "ioconf.h"
+
 static void findroot(void);
 int mbmatch(device_t, cfdata_t, void *);
 void mbattach(device_t, device_t, void *);
@@ -75,6 +84,41 @@ cpu_rootconf(void)
 {
 
 	findroot();
+#if defined(MEMORY_DISK_HOOKS)
+	/*
+	 * XXX
+	 * quick hacks for atari's traditional "auto-load from floppy on open"
+	 * installation md(4) ramdisk.
+	 * See sys/arch/atari/dev/md_root.c for details.
+	 */
+#define RAMD_NDEV	3	/* XXX */
+
+	if ((boothowto & RB_ASKNAME) != 0) {
+		int md_major, i;
+		dev_t md_dev;
+		cfdata_t cf;
+		struct md_softc *sc;
+
+		md_major = devsw_name2blk("md", NULL, 0);
+		if (md_major >= 0) {
+			for (i = 0; i < RAMD_NDEV; i++) {
+				md_dev = MAKEDISKDEV(md_major, i, RAW_PART);
+				cf = malloc(sizeof(*cf), M_DEVBUF,
+				    M_ZERO|M_WAITOK);
+				if (cf == NULL)
+					break;	/* XXX */
+				cf->cf_name = md_cd.cd_name;
+				cf->cf_atname = md_cd.cd_name;
+				cf->cf_unit = i;
+				cf->cf_fstate = FSTATE_STAR;
+				/* XXX mutex */
+				sc = device_private(config_attach_pseudo(cf));
+				if (sc == NULL)
+					break;	/* XXX */
+			}
+		}
+	}
+#endif
 	setroot(booted_device, booted_partition);
 }
 

Index: src/sys/dev/md.c
diff -u src/sys/dev/md.c:1.66 src/sys/dev/md.c:1.66.14.1
--- src/sys/dev/md.c:1.66	Thu Nov 25 08:53:30 2010
+++ src/sys/dev/md.c	Thu Jul  5 17:36:31 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: md.c,v 1.66 2010/11/25 08:53:30 hannken Exp $	*/
+/*	$NetBSD: md.c,v 1.66.14.1 2012/07/05 17:36:31 riz Exp $	*/
 
 /*
  * Copyright (c) 1995 Gordon W. Ross, Leo Weppelman.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.66 2010/11/25 08:53:30 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: md.c,v 1.66.14.1 2012/07/05 17:36:31 riz Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_md.h"
@@ -243,6 +243,9 @@ mdopen(dev_t dev, int flag, int fmt, str
 	cfdata_t cf;
 	struct md_softc *sc;
 	struct disk *dk;
+#ifdef	MEMORY_DISK_HOOKS
+	bool configured;
+#endif
 
 	mutex_enter(&md_device_lock);
 	unit = MD_UNIT(dev);
@@ -274,7 +277,11 @@ mdopen(dev_t dev, int flag, int fmt, str
 
 #ifdef	MEMORY_DISK_HOOKS
 	/* Call the open hook to allow loading the device. */
+	configured = (sc->sc_type != MD_UNCONFIGURED);
 	md_open_hook(unit, &sc->sc_md);
+	/* initialize disklabel if the device is configured in open hook */
+	if (!configured && sc->sc_type != MD_UNCONFIGURED)
+		md_set_disklabel(sc);
 #endif
 
 	/*

Index: src/sys/fs/msdosfs/msdosfs_vfsops.c
diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.93 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.93.6.1
--- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.93	Mon Nov 14 18:35:13 2011
+++ src/sys/fs/msdosfs/msdosfs_vfsops.c	Thu Jul  5 17:36:31 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vfsops.c,v 1.93 2011/11/14 18:35:13 hannken Exp $	*/
+/*	$NetBSD: msdosfs_vfsops.c,v 1.93.6.1 2012/07/05 17:36:31 riz Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.93 2011/11/14 18:35:13 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.93.6.1 2012/07/05 17:36:31 riz Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -491,7 +491,7 @@ msdosfs_mountfs(struct vnode *devvp, str
 		goto error_exit;
 
 	error = getdisksize(devvp, &psize, &secsize);
-	if (error) {
+	if (error || secsize == 0) {
 		if (argp->flags & MSDOSFSMNT_GEMDOSFS)
 			goto error_exit;
 

Reply via email to