mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-26 02:20:51 +01:00
Add a couple of undocumented test options to MD(4) to aid in regression
testting of GEOM.
This commit is contained in:
parent
ce5b934709
commit
4e8bfe1482
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=113289
@ -54,7 +54,7 @@ main(int argc, char **argv)
|
||||
int cmdline = 0;
|
||||
|
||||
for (;;) {
|
||||
ch = getopt(argc, argv, "ab:df:lo:s:S:t:u:");
|
||||
ch = getopt(argc, argv, "ab:df:lo:s:S:t:u:x:y:");
|
||||
if (ch == -1)
|
||||
break;
|
||||
switch (ch) {
|
||||
@ -163,6 +163,16 @@ main(int argc, char **argv)
|
||||
errx(1, "bad unit: %s", optarg);
|
||||
mdio.md_options &= ~MD_AUTOUNIT;
|
||||
break;
|
||||
case 'x':
|
||||
if (cmdline != 2)
|
||||
usage();
|
||||
mdio.md_fwsectors = strtoul(optarg, &p, 0);
|
||||
break;
|
||||
case 'y':
|
||||
if (cmdline != 2)
|
||||
usage();
|
||||
mdio.md_fwheads = strtoul(optarg, &p, 0);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
|
@ -147,6 +147,8 @@ struct md_s {
|
||||
unsigned nsect;
|
||||
unsigned opencount;
|
||||
unsigned secsize;
|
||||
unsigned fwheads;
|
||||
unsigned fwsectors;
|
||||
unsigned flags;
|
||||
char name[20];
|
||||
struct proc *procp;
|
||||
@ -366,11 +368,6 @@ g_md_start(struct bio *bp)
|
||||
|
||||
sc = bp->bio_to->geom->softc;
|
||||
|
||||
switch(bp->bio_cmd) {
|
||||
case BIO_GETATTR:
|
||||
g_io_deliver(bp, EOPNOTSUPP);
|
||||
return;
|
||||
}
|
||||
bp->bio_blkno = bp->bio_offset >> DEV_BSHIFT;
|
||||
bp->bio_pblkno = bp->bio_offset / sc->secsize;
|
||||
bp->bio_bcount = bp->bio_length;
|
||||
@ -586,23 +583,33 @@ md_kthread(void *arg)
|
||||
continue;
|
||||
}
|
||||
mtx_unlock(&sc->queue_mtx);
|
||||
|
||||
switch (sc->type) {
|
||||
case MD_MALLOC:
|
||||
error = mdstart_malloc(sc, bp);
|
||||
break;
|
||||
case MD_PRELOAD:
|
||||
error = mdstart_preload(sc, bp);
|
||||
break;
|
||||
case MD_VNODE:
|
||||
error = mdstart_vnode(sc, bp);
|
||||
break;
|
||||
case MD_SWAP:
|
||||
error = mdstart_swap(sc, bp);
|
||||
break;
|
||||
default:
|
||||
panic("Impossible md(type)");
|
||||
break;
|
||||
if (bp->bio_cmd == BIO_GETATTR) {
|
||||
if (sc->fwsectors && sc->fwheads &&
|
||||
(g_handleattr_int(bp, "GEOM::fwsectors",
|
||||
sc->fwsectors) ||
|
||||
g_handleattr_int(bp, "GEOM::fwheads",
|
||||
sc->fwheads)))
|
||||
error = -1;
|
||||
else
|
||||
error = EOPNOTSUPP;
|
||||
} else {
|
||||
switch (sc->type) {
|
||||
case MD_MALLOC:
|
||||
error = mdstart_malloc(sc, bp);
|
||||
break;
|
||||
case MD_PRELOAD:
|
||||
error = mdstart_preload(sc, bp);
|
||||
break;
|
||||
case MD_VNODE:
|
||||
error = mdstart_vnode(sc, bp);
|
||||
break;
|
||||
case MD_SWAP:
|
||||
error = mdstart_swap(sc, bp);
|
||||
break;
|
||||
default:
|
||||
panic("Impossible md(type)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (error != -1) {
|
||||
@ -752,6 +759,10 @@ mdcreate_malloc(struct md_ioctl *mdio)
|
||||
sc->secsize = mdio->md_secsize;
|
||||
else
|
||||
sc->secsize = DEV_BSIZE;
|
||||
if (mdio->md_fwsectors != 0)
|
||||
sc->fwsectors = mdio->md_fwsectors;
|
||||
if (mdio->md_fwheads != 0)
|
||||
sc->fwheads = mdio->md_fwheads;
|
||||
sc->nsect = mdio->md_size;
|
||||
sc->nsect /= (sc->secsize / DEV_BSIZE);
|
||||
sc->flags = mdio->md_options & (MD_COMPRESS | MD_FORCE);
|
||||
|
@ -53,7 +53,7 @@ enum md_types {MD_MALLOC, MD_PRELOAD, MD_VNODE, MD_SWAP};
|
||||
* Ioctl definitions for memory disk pseudo-device.
|
||||
*/
|
||||
|
||||
#define MDNPAD 99
|
||||
#define MDNPAD 97
|
||||
struct md_ioctl {
|
||||
unsigned md_version; /* Structure layout version */
|
||||
unsigned md_unit; /* unit number */
|
||||
@ -63,6 +63,8 @@ struct md_ioctl {
|
||||
unsigned md_options; /* options */
|
||||
u_int64_t md_base; /* base address */
|
||||
int md_secsize; /* sectorsize */
|
||||
int md_fwheads; /* firmware heads */
|
||||
int md_fwsectors; /* firmware sectors */
|
||||
int md_pad[MDNPAD]; /* padding for future ideas */
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user