diff options
author | phk <phk@FreeBSD.org> | 2000-07-04 10:06:34 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2000-07-04 10:06:34 +0000 |
commit | 1624e20f39888e846831b8a8457c919d0cfa54c9 (patch) | |
tree | ec16b65e8773b7689bba163773e54349811a8e5b | |
parent | 775730e0ac8ee7261666a02c17fd3de3c868d350 (diff) | |
download | FreeBSD-src-1624e20f39888e846831b8a8457c919d0cfa54c9.zip FreeBSD-src-1624e20f39888e846831b8a8457c919d0cfa54c9.tar.gz |
Fix the "almost clone" semantics.
-rw-r--r-- | sys/dev/md/md.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 3543a06..1a89214 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -52,6 +52,8 @@ static u_char end_mfs_root[] __unused = "MFS Filesystem had better STOP here"; static int mdrootready; +static void mdcreate_malloc(void); + #define CDEV_MAJOR 95 #define BDEV_MAJOR 22 @@ -78,6 +80,8 @@ static struct cdevsw md_cdevsw = { /* bmaj */ BDEV_MAJOR }; +static struct cdevsw mddisk_cdevsw; + struct md_s { int unit; struct devstat stats; @@ -87,7 +91,6 @@ struct md_s { int busy; enum {MD_MALLOC, MD_PRELOAD} type; unsigned nsect; - struct cdevsw devsw; /* MD_MALLOC related fields */ unsigned nsecp; @@ -111,6 +114,8 @@ mdopen(dev_t dev, int flag, int fmt, struct proc *p) devtoname(dev), flag, fmt, p); sc = dev->si_drv1; + if (sc->unit + 1 == mdunits) + mdcreate_malloc(); dl = &sc->disk.d_label; bzero(dl, sizeof(*dl)); @@ -336,7 +341,7 @@ mdstrategy_preload(struct bio *bp) } static struct md_s * -mdcreate(struct cdevsw *devsw) +mdcreate(void) { struct md_s *sc; @@ -348,7 +353,7 @@ mdcreate(struct cdevsw *devsw) DEVSTAT_NO_ORDERED_TAGS, DEVSTAT_TYPE_DIRECT | DEVSTAT_TYPE_IF_OTHER, DEVSTAT_PRIORITY_OTHER); - sc->dev = disk_create(sc->unit, &sc->disk, 0, devsw, &sc->devsw); + sc->dev = disk_create(sc->unit, &sc->disk, 0, &md_cdevsw, &mddisk_cdevsw); sc->dev->si_drv1 = sc; return (sc); } @@ -358,7 +363,7 @@ mdcreate_preload(u_char *image, unsigned length) { struct md_s *sc; - sc = mdcreate(&md_cdevsw); + sc = mdcreate(); sc->type = MD_PRELOAD; sc->nsect = length / DEV_BSIZE; sc->pl_ptr = image; @@ -373,13 +378,14 @@ mdcreate_malloc(void) { struct md_s *sc; - sc = mdcreate(&md_cdevsw); + sc = mdcreate(); sc->type = MD_MALLOC; sc->nsect = MDNSECT; /* for now */ MALLOC(sc->secp, u_char **, sizeof(u_char *), M_MD, M_WAITOK); bzero(sc->secp, sizeof(u_char *)); sc->nsecp = 1; + printf("md%d: Malloc disk\n", sc->unit); } static void @@ -412,7 +418,6 @@ md_drvinit(void *unused) mdunits, name, len, ptr); mdcreate_preload(ptr, len); } - printf("md%d: Malloc disk\n", mdunits); mdcreate_malloc(); } |