1999-09-21 11:00:49 +00:00
|
|
|
/*
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
* "THE BEER-WARE LICENSE" (Revision 42):
|
|
|
|
* <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
|
|
|
|
* can do whatever you want with this stuff. If we meet some day, and you think
|
|
|
|
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1999-11-26 20:08:44 +00:00
|
|
|
#include "opt_mfs.h" /* We have adopted some tasks from MFS */
|
|
|
|
#include "opt_md.h" /* We have adopted some tasks from MFS */
|
|
|
|
|
1999-09-21 11:00:49 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/devicestat.h>
|
1999-09-22 21:23:21 +00:00
|
|
|
#include <sys/disk.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/sysctl.h>
|
1999-11-20 22:43:27 +00:00
|
|
|
#include <sys/linker.h>
|
1999-09-21 11:00:49 +00:00
|
|
|
|
1999-09-21 12:05:38 +00:00
|
|
|
#ifndef MDNSECT
|
|
|
|
#define MDNSECT (10000 * 2)
|
|
|
|
#endif
|
|
|
|
|
1999-09-21 11:00:49 +00:00
|
|
|
MALLOC_DEFINE(M_MD, "MD disk", "Memory Disk");
|
|
|
|
MALLOC_DEFINE(M_MDSECT, "MD sectors", "Memory Disk Sectors");
|
|
|
|
|
1999-11-26 20:08:44 +00:00
|
|
|
static int md_debug;
|
1999-09-21 11:00:49 +00:00
|
|
|
SYSCTL_INT(_debug, OID_AUTO, mddebug, CTLFLAG_RW, &md_debug, 0, "");
|
|
|
|
|
1999-11-26 20:08:44 +00:00
|
|
|
#if defined(MFS_ROOT) && !defined(MD_ROOT)
|
|
|
|
#define MD_ROOT MFS_ROOT
|
|
|
|
#warning "option MFS_ROOT has been superceeded by MD_ROOT"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(MFS_ROOT_SIZE) && !defined(MD_ROOT_SIZE)
|
|
|
|
#define MD_ROOT_SIZE MFS_ROOT_SIZE
|
|
|
|
#warning "option MFS_ROOT_SIZE has been superceeded by MD_ROOT_SIZE"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(MD_ROOT) && defined(MD_ROOT_SIZE)
|
|
|
|
/* Image gets put here: */
|
|
|
|
static u_char mfs_root[MD_ROOT_SIZE*1024] = "MFS Filesystem goes here";
|
|
|
|
static u_char end_mfs_root[] __unused = "MFS Filesystem had better STOP here";
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int mdrootready;
|
|
|
|
|
1999-09-21 11:00:49 +00:00
|
|
|
#define CDEV_MAJOR 95
|
|
|
|
#define BDEV_MAJOR 22
|
|
|
|
|
|
|
|
static d_strategy_t mdstrategy;
|
1999-11-26 20:08:44 +00:00
|
|
|
static d_strategy_t mdstrategy_preload;
|
|
|
|
static d_strategy_t mdstrategy_malloc;
|
1999-09-21 11:00:49 +00:00
|
|
|
static d_open_t mdopen;
|
|
|
|
static d_ioctl_t mdioctl;
|
|
|
|
|
|
|
|
static struct cdevsw md_cdevsw = {
|
|
|
|
/* open */ mdopen,
|
|
|
|
/* close */ nullclose,
|
|
|
|
/* read */ physread,
|
|
|
|
/* write */ physwrite,
|
|
|
|
/* ioctl */ mdioctl,
|
|
|
|
/* poll */ nopoll,
|
|
|
|
/* mmap */ nommap,
|
|
|
|
/* strategy */ mdstrategy,
|
|
|
|
/* name */ "md",
|
|
|
|
/* maj */ CDEV_MAJOR,
|
|
|
|
/* dump */ nodump,
|
|
|
|
/* psize */ nopsize,
|
1999-11-26 20:08:44 +00:00
|
|
|
/* flags */ D_DISK | D_CANFREE | D_MEMDISK,
|
1999-09-21 11:00:49 +00:00
|
|
|
/* bmaj */ BDEV_MAJOR
|
|
|
|
};
|
|
|
|
|
|
|
|
struct md_s {
|
|
|
|
int unit;
|
|
|
|
struct devstat stats;
|
2000-04-15 05:54:02 +00:00
|
|
|
struct bio_queue_head bio_queue;
|
1999-09-21 11:00:49 +00:00
|
|
|
struct disk disk;
|
|
|
|
dev_t dev;
|
1999-11-20 22:43:27 +00:00
|
|
|
int busy;
|
|
|
|
enum {MD_MALLOC, MD_PRELOAD} type;
|
1999-09-21 11:00:49 +00:00
|
|
|
unsigned nsect;
|
1999-11-26 20:08:44 +00:00
|
|
|
struct cdevsw devsw;
|
1999-11-20 22:43:27 +00:00
|
|
|
|
|
|
|
/* MD_MALLOC related fields */
|
1999-09-21 11:00:49 +00:00
|
|
|
unsigned nsecp;
|
|
|
|
u_char **secp;
|
|
|
|
|
1999-11-20 22:43:27 +00:00
|
|
|
/* MD_PRELOAD related fields */
|
|
|
|
u_char *pl_ptr;
|
|
|
|
unsigned pl_len;
|
1999-09-21 11:00:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int mdunits;
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdopen(dev_t dev, int flag, int fmt, struct proc *p)
|
|
|
|
{
|
|
|
|
struct md_s *sc;
|
|
|
|
struct disklabel *dl;
|
|
|
|
|
|
|
|
if (md_debug)
|
|
|
|
printf("mdopen(%s %x %x %p)\n",
|
|
|
|
devtoname(dev), flag, fmt, p);
|
|
|
|
|
|
|
|
sc = dev->si_drv1;
|
|
|
|
|
|
|
|
dl = &sc->disk.d_label;
|
|
|
|
bzero(dl, sizeof(*dl));
|
|
|
|
dl->d_secsize = DEV_BSIZE;
|
|
|
|
dl->d_nsectors = 1024;
|
|
|
|
dl->d_ntracks = 1;
|
1999-11-20 22:43:27 +00:00
|
|
|
dl->d_secpercyl = dl->d_nsectors * dl->d_ntracks;
|
1999-09-21 11:00:49 +00:00
|
|
|
dl->d_secperunit = sc->nsect;
|
|
|
|
dl->d_ncylinders = dl->d_secperunit / dl->d_secpercyl;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (md_debug)
|
|
|
|
printf("mdioctl(%s %lx %p %x %p)\n",
|
|
|
|
devtoname(dev), cmd, addr, flags, p);
|
|
|
|
|
|
|
|
return (ENOIOCTL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-04-15 05:54:02 +00:00
|
|
|
mdstrategy(struct bio *bp)
|
1999-11-26 20:08:44 +00:00
|
|
|
{
|
|
|
|
struct md_s *sc;
|
|
|
|
|
|
|
|
if (md_debug > 1)
|
2000-04-15 05:54:02 +00:00
|
|
|
printf("mdstrategy(%p) %s %x, %d, %ld, %p)\n",
|
|
|
|
bp, devtoname(bp->bio_dev), bp->bio_flags, bp->bio_blkno,
|
|
|
|
bp->bio_bcount / DEV_BSIZE, bp->bio_data);
|
1999-11-26 20:08:44 +00:00
|
|
|
|
2000-04-15 05:54:02 +00:00
|
|
|
sc = bp->bio_dev->si_drv1;
|
1999-11-26 20:08:44 +00:00
|
|
|
if (sc->type == MD_MALLOC) {
|
|
|
|
mdstrategy_malloc(bp);
|
|
|
|
} else {
|
|
|
|
mdstrategy_preload(bp);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2000-04-15 05:54:02 +00:00
|
|
|
mdstrategy_malloc(struct bio *bp)
|
1999-09-21 11:00:49 +00:00
|
|
|
{
|
|
|
|
int s, i;
|
|
|
|
struct md_s *sc;
|
|
|
|
devstat_trans_flags dop;
|
|
|
|
u_char *secp, **secpp, *dst;
|
|
|
|
unsigned secno, nsec, secval, uc;
|
|
|
|
|
|
|
|
if (md_debug > 1)
|
2000-04-15 05:54:02 +00:00
|
|
|
printf("mdstrategy_malloc(%p) %s %x, %d, %ld, %p)\n",
|
|
|
|
bp, devtoname(bp->bio_dev), bp->bio_flags, bp->bio_blkno,
|
|
|
|
bp->bio_bcount / DEV_BSIZE, bp->bio_data);
|
1999-09-21 11:00:49 +00:00
|
|
|
|
2000-04-15 05:54:02 +00:00
|
|
|
sc = bp->bio_dev->si_drv1;
|
1999-09-21 11:00:49 +00:00
|
|
|
|
|
|
|
s = splbio();
|
|
|
|
|
2000-04-15 05:54:02 +00:00
|
|
|
bioqdisksort(&sc->bio_queue, bp);
|
1999-09-21 11:00:49 +00:00
|
|
|
|
|
|
|
if (sc->busy) {
|
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sc->busy++;
|
|
|
|
|
|
|
|
while (1) {
|
2000-04-15 05:54:02 +00:00
|
|
|
bp = bioq_first(&sc->bio_queue);
|
1999-09-21 11:00:49 +00:00
|
|
|
if (bp)
|
2000-04-15 05:54:02 +00:00
|
|
|
bioq_remove(&sc->bio_queue, bp);
|
1999-09-21 11:00:49 +00:00
|
|
|
splx(s);
|
|
|
|
if (!bp)
|
|
|
|
break;
|
|
|
|
|
|
|
|
devstat_start_transaction(&sc->stats);
|
|
|
|
|
2000-04-15 05:54:02 +00:00
|
|
|
if (bp->bio_cmd == BIO_DELETE)
|
1999-09-21 11:00:49 +00:00
|
|
|
dop = DEVSTAT_NO_DATA;
|
2000-04-15 05:54:02 +00:00
|
|
|
else if (bp->bio_cmd == BIO_READ)
|
1999-09-21 11:00:49 +00:00
|
|
|
dop = DEVSTAT_READ;
|
|
|
|
else
|
|
|
|
dop = DEVSTAT_WRITE;
|
|
|
|
|
2000-04-15 05:54:02 +00:00
|
|
|
nsec = bp->bio_bcount / DEV_BSIZE;
|
|
|
|
secno = bp->bio_pblkno;
|
|
|
|
dst = bp->bio_data;
|
1999-11-26 20:08:44 +00:00
|
|
|
while (nsec--) {
|
|
|
|
|
|
|
|
if (secno < sc->nsecp) {
|
|
|
|
secpp = &sc->secp[secno];
|
|
|
|
if ((u_int)*secpp > 255) {
|
|
|
|
secp = *secpp;
|
|
|
|
secval = 0;
|
1999-09-21 11:00:49 +00:00
|
|
|
} else {
|
|
|
|
secp = 0;
|
1999-11-26 20:08:44 +00:00
|
|
|
secval = (u_int) *secpp;
|
1999-09-21 11:00:49 +00:00
|
|
|
}
|
1999-11-26 20:08:44 +00:00
|
|
|
} else {
|
|
|
|
secpp = 0;
|
|
|
|
secp = 0;
|
|
|
|
secval = 0;
|
|
|
|
}
|
|
|
|
if (md_debug > 2)
|
2000-04-15 05:54:02 +00:00
|
|
|
printf("%x %p %p %d\n",
|
|
|
|
bp->bio_flags, secpp, secp, secval);
|
1999-09-21 11:00:49 +00:00
|
|
|
|
2000-04-15 05:54:02 +00:00
|
|
|
if (bp->bio_cmd == BIO_DELETE) {
|
1999-11-26 20:08:44 +00:00
|
|
|
if (secpp) {
|
|
|
|
if (secp)
|
|
|
|
FREE(secp, M_MDSECT);
|
|
|
|
*secpp = 0;
|
|
|
|
}
|
2000-04-15 05:54:02 +00:00
|
|
|
} else if (bp->bio_cmd == BIO_READ) {
|
1999-11-26 20:08:44 +00:00
|
|
|
if (secp) {
|
|
|
|
bcopy(secp, dst, DEV_BSIZE);
|
|
|
|
} else if (secval) {
|
|
|
|
for (i = 0; i < DEV_BSIZE; i++)
|
|
|
|
dst[i] = secval;
|
1999-11-20 22:43:27 +00:00
|
|
|
} else {
|
1999-11-26 20:08:44 +00:00
|
|
|
bzero(dst, DEV_BSIZE);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
uc = dst[0];
|
|
|
|
for (i = 1; i < DEV_BSIZE; i++)
|
|
|
|
if (dst[i] != uc)
|
|
|
|
break;
|
|
|
|
if (i == DEV_BSIZE && !uc) {
|
|
|
|
if (secp)
|
|
|
|
FREE(secp, M_MDSECT);
|
|
|
|
if (secpp)
|
|
|
|
*secpp = (u_char *)uc;
|
|
|
|
} else {
|
|
|
|
if (!secpp) {
|
|
|
|
MALLOC(secpp, u_char **, (secno + nsec + 1) * sizeof(u_char *), M_MD, M_WAITOK);
|
|
|
|
bzero(secpp, (secno + nsec + 1) * sizeof(u_char *));
|
|
|
|
bcopy(sc->secp, secpp, sc->nsecp * sizeof(u_char *));
|
|
|
|
FREE(sc->secp, M_MD);
|
|
|
|
sc->secp = secpp;
|
|
|
|
sc->nsecp = secno + nsec + 1;
|
|
|
|
secpp = &sc->secp[secno];
|
|
|
|
}
|
|
|
|
if (i == DEV_BSIZE) {
|
1999-09-21 11:00:49 +00:00
|
|
|
if (secp)
|
|
|
|
FREE(secp, M_MDSECT);
|
1999-11-26 20:08:44 +00:00
|
|
|
*secpp = (u_char *)uc;
|
1999-09-21 11:00:49 +00:00
|
|
|
} else {
|
1999-11-26 20:08:44 +00:00
|
|
|
if (!secp)
|
|
|
|
MALLOC(secp, u_char *, DEV_BSIZE, M_MDSECT, M_WAITOK);
|
|
|
|
bcopy(dst, secp, DEV_BSIZE);
|
|
|
|
|
|
|
|
*secpp = secp;
|
1999-09-21 11:00:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-11-26 20:08:44 +00:00
|
|
|
secno++;
|
|
|
|
dst += DEV_BSIZE;
|
1999-09-21 11:00:49 +00:00
|
|
|
}
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_resid = 0;
|
|
|
|
devstat_end_transaction_bio(&sc->stats, bp);
|
1999-09-21 11:00:49 +00:00
|
|
|
biodone(bp);
|
|
|
|
s = splbio();
|
|
|
|
}
|
|
|
|
sc->busy = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-11-26 20:08:44 +00:00
|
|
|
|
1999-11-20 22:43:27 +00:00
|
|
|
static void
|
2000-04-15 05:54:02 +00:00
|
|
|
mdstrategy_preload(struct bio *bp)
|
1999-11-26 20:08:44 +00:00
|
|
|
{
|
|
|
|
int s;
|
|
|
|
struct md_s *sc;
|
|
|
|
devstat_trans_flags dop;
|
|
|
|
|
|
|
|
if (md_debug > 1)
|
2000-04-15 05:54:02 +00:00
|
|
|
printf("mdstrategy_preload(%p) %s %x, %d, %ld, %p)\n",
|
|
|
|
bp, devtoname(bp->bio_dev), bp->bio_flags, bp->bio_blkno,
|
|
|
|
bp->bio_bcount / DEV_BSIZE, bp->bio_data);
|
1999-11-26 20:08:44 +00:00
|
|
|
|
2000-04-15 05:54:02 +00:00
|
|
|
sc = bp->bio_dev->si_drv1;
|
1999-11-26 20:08:44 +00:00
|
|
|
|
|
|
|
s = splbio();
|
|
|
|
|
2000-04-15 05:54:02 +00:00
|
|
|
bioqdisksort(&sc->bio_queue, bp);
|
1999-11-26 20:08:44 +00:00
|
|
|
|
|
|
|
if (sc->busy) {
|
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
sc->busy++;
|
|
|
|
|
|
|
|
while (1) {
|
2000-04-15 05:54:02 +00:00
|
|
|
bp = bioq_first(&sc->bio_queue);
|
1999-11-26 20:08:44 +00:00
|
|
|
if (bp)
|
2000-04-15 05:54:02 +00:00
|
|
|
bioq_remove(&sc->bio_queue, bp);
|
1999-11-26 20:08:44 +00:00
|
|
|
splx(s);
|
|
|
|
if (!bp)
|
|
|
|
break;
|
|
|
|
|
|
|
|
devstat_start_transaction(&sc->stats);
|
|
|
|
|
2000-04-15 05:54:02 +00:00
|
|
|
if (bp->bio_cmd == BIO_DELETE) {
|
1999-11-26 20:08:44 +00:00
|
|
|
dop = DEVSTAT_NO_DATA;
|
2000-04-15 05:54:02 +00:00
|
|
|
} else if (bp->bio_cmd == BIO_READ) {
|
1999-11-26 20:08:44 +00:00
|
|
|
dop = DEVSTAT_READ;
|
2000-04-15 05:54:02 +00:00
|
|
|
bcopy(sc->pl_ptr + (bp->bio_pblkno << DEV_BSHIFT), bp->bio_data, bp->bio_bcount);
|
1999-11-26 20:08:44 +00:00
|
|
|
} else {
|
|
|
|
dop = DEVSTAT_WRITE;
|
2000-04-15 05:54:02 +00:00
|
|
|
bcopy(bp->bio_data, sc->pl_ptr + (bp->bio_pblkno << DEV_BSHIFT), bp->bio_bcount);
|
1999-11-26 20:08:44 +00:00
|
|
|
}
|
2000-04-15 05:54:02 +00:00
|
|
|
bp->bio_resid = 0;
|
|
|
|
devstat_end_transaction_bio(&sc->stats, bp);
|
1999-11-26 20:08:44 +00:00
|
|
|
biodone(bp);
|
|
|
|
s = splbio();
|
|
|
|
}
|
|
|
|
sc->busy = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct md_s *
|
|
|
|
mdcreate(struct cdevsw *devsw)
|
1999-09-21 11:00:49 +00:00
|
|
|
{
|
|
|
|
struct md_s *sc;
|
|
|
|
|
|
|
|
MALLOC(sc, struct md_s *,sizeof(*sc), M_MD, M_WAITOK);
|
|
|
|
bzero(sc, sizeof(*sc));
|
|
|
|
sc->unit = mdunits++;
|
2000-04-15 05:54:02 +00:00
|
|
|
bioq_init(&sc->bio_queue);
|
1999-11-20 22:43:27 +00:00
|
|
|
devstat_add_entry(&sc->stats, "md", sc->unit, DEV_BSIZE,
|
|
|
|
DEVSTAT_NO_ORDERED_TAGS,
|
1999-11-26 20:08:44 +00:00
|
|
|
DEVSTAT_TYPE_DIRECT | DEVSTAT_TYPE_IF_OTHER,
|
|
|
|
DEVSTAT_PRIORITY_OTHER);
|
|
|
|
sc->dev = disk_create(sc->unit, &sc->disk, 0, devsw, &sc->devsw);
|
1999-11-20 22:43:27 +00:00
|
|
|
sc->dev->si_drv1 = sc;
|
1999-11-26 20:08:44 +00:00
|
|
|
return (sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mdcreate_preload(u_char *image, unsigned length)
|
|
|
|
{
|
|
|
|
struct md_s *sc;
|
|
|
|
|
|
|
|
sc = mdcreate(&md_cdevsw);
|
1999-12-01 10:20:21 +00:00
|
|
|
sc->type = MD_PRELOAD;
|
1999-11-20 22:43:27 +00:00
|
|
|
sc->nsect = length / DEV_BSIZE;
|
|
|
|
sc->pl_ptr = image;
|
|
|
|
sc->pl_len = length;
|
1999-11-26 20:08:44 +00:00
|
|
|
|
|
|
|
if (sc->unit == 0)
|
|
|
|
mdrootready = 1;
|
1999-11-20 22:43:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mdcreate_malloc(void)
|
|
|
|
{
|
|
|
|
struct md_s *sc;
|
|
|
|
|
1999-11-26 20:08:44 +00:00
|
|
|
sc = mdcreate(&md_cdevsw);
|
1999-12-01 10:20:21 +00:00
|
|
|
sc->type = MD_MALLOC;
|
1999-09-21 11:00:49 +00:00
|
|
|
|
1999-09-21 12:05:38 +00:00
|
|
|
sc->nsect = MDNSECT; /* for now */
|
1999-09-21 11:00:49 +00:00
|
|
|
MALLOC(sc->secp, u_char **, sizeof(u_char *), M_MD, M_WAITOK);
|
|
|
|
bzero(sc->secp, sizeof(u_char *));
|
|
|
|
sc->nsecp = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
md_drvinit(void *unused)
|
|
|
|
{
|
|
|
|
|
1999-11-20 22:43:27 +00:00
|
|
|
caddr_t mod;
|
|
|
|
caddr_t c;
|
|
|
|
u_char *ptr, *name, *type;
|
|
|
|
unsigned len;
|
|
|
|
|
1999-11-26 20:08:44 +00:00
|
|
|
#ifdef MD_ROOT_SIZE
|
|
|
|
mdcreate_preload(mfs_root, MD_ROOT_SIZE*1024);
|
|
|
|
#endif
|
1999-11-20 22:43:27 +00:00
|
|
|
mod = NULL;
|
|
|
|
while ((mod = preload_search_next_name(mod)) != NULL) {
|
|
|
|
name = (char *)preload_search_info(mod, MODINFO_NAME);
|
|
|
|
type = (char *)preload_search_info(mod, MODINFO_TYPE);
|
|
|
|
if (name == NULL)
|
|
|
|
continue;
|
|
|
|
if (type == NULL)
|
|
|
|
continue;
|
1999-11-26 20:08:44 +00:00
|
|
|
if (strcmp(type, "md_image") && strcmp(type, "mfs_root"))
|
1999-11-20 22:43:27 +00:00
|
|
|
continue;
|
|
|
|
c = preload_search_info(mod, MODINFO_ADDR);
|
|
|
|
ptr = *(u_char **)c;
|
|
|
|
c = preload_search_info(mod, MODINFO_SIZE);
|
|
|
|
len = *(unsigned *)c;
|
|
|
|
printf("md%d: Preloaded image <%s> %d bytes at %p\n",
|
|
|
|
mdunits, name, len, ptr);
|
|
|
|
mdcreate_preload(ptr, len);
|
|
|
|
}
|
1999-12-01 10:20:21 +00:00
|
|
|
printf("md%d: Malloc disk\n", mdunits);
|
1999-11-20 22:43:27 +00:00
|
|
|
mdcreate_malloc();
|
1999-09-21 11:00:49 +00:00
|
|
|
}
|
|
|
|
|
1999-11-26 20:08:44 +00:00
|
|
|
SYSINIT(mddev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR, md_drvinit,NULL)
|
1999-09-21 11:00:49 +00:00
|
|
|
|
1999-11-26 20:08:44 +00:00
|
|
|
#ifdef MD_ROOT
|
|
|
|
static void
|
|
|
|
md_takeroot(void *junk)
|
|
|
|
{
|
|
|
|
if (mdrootready)
|
|
|
|
rootdevnames[0] = "ufs:/dev/md0c";
|
|
|
|
}
|
|
|
|
|
|
|
|
SYSINIT(md_root, SI_SUB_MOUNT_ROOT, SI_ORDER_FIRST, md_takeroot, NULL);
|
|
|
|
#endif
|