From fead6f3f5b6012b47e78227605e50f16029c03eb Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Thu, 4 Apr 2002 16:40:11 +0000 Subject: [PATCH] Play catch up with the kernel. Sponsored by: DARPA & NAI Labs --- tools/regression/geom/geom_simdev.c | 4 ++-- tools/regression/geom/geom_simdisk.c | 8 ++++++-- tools/regression/geom/geom_simdisk.h | 1 + tools/regression/geom/geom_simdisk_xml.c | 6 +++++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/tools/regression/geom/geom_simdev.c b/tools/regression/geom/geom_simdev.c index 290c8c53ea66..8dd3da4ec726 100644 --- a/tools/regression/geom/geom_simdev.c +++ b/tools/regression/geom/geom_simdev.c @@ -47,6 +47,7 @@ #include #include +static g_orphan_t g_dev_orphan; static struct g_geom * dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused) @@ -63,6 +64,7 @@ dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused) } } gp = g_new_geomf(mp, pp->name); + gp->orphan = g_dev_orphan; cp = g_new_consumer(gp); g_attach(cp, pp); return (gp); @@ -91,8 +93,6 @@ static struct g_class dev_class = { "DEV-class", dev_taste, NULL, - g_dev_orphan, - NULL, G_CLASS_INITSTUFF }; diff --git a/tools/regression/geom/geom_simdisk.c b/tools/regression/geom/geom_simdisk.c index de5d1f951475..ddc51fd4f569 100644 --- a/tools/regression/geom/geom_simdisk.c +++ b/tools/regression/geom/geom_simdisk.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include "geom_simdisk.h" @@ -50,8 +51,6 @@ struct g_class g_simdisk_class = { "SIMDISK-class", NULL, - g_std_access, - NULL, NULL, G_CLASS_INITSTUFF }; @@ -140,8 +139,10 @@ g_simdisk_create(char *name, struct simdisk_softc *sc) gp = g_new_geomf(&g_simdisk_class, "%s", name); gp->start = g_simdisk_start; gp->softc = sc; + gp->access = g_std_access; pp = g_new_providerf(gp, "%s", name); + pp->mediasize=sc->mediasize; g_error_provider(pp, 0); unit++; g_topology_unlock(); @@ -152,12 +153,15 @@ struct g_geom * g_simdisk_new(char *name, char *path) { struct simdisk_softc *sc; + struct stat st; sc = calloc(1, sizeof *sc); sc->fd = open(path, O_RDONLY); if (sc->fd < 0) err(1, path); + fstat(sc->fd, &st); + sc->mediasize = st.st_size; sc->sectorsize = 512; LIST_INIT(&sc->sectors); TAILQ_INIT(&sc->sort); diff --git a/tools/regression/geom/geom_simdisk.h b/tools/regression/geom/geom_simdisk.h index cd5783699f6e..7b016788ce48 100644 --- a/tools/regression/geom/geom_simdisk.h +++ b/tools/regression/geom/geom_simdisk.h @@ -45,6 +45,7 @@ struct simdisk_softc { int fd; int sectorsize; off_t mediasize; + off_t lastsector; LIST_HEAD(,sector) sectors; struct sbuf *sbuf; struct sector *sp; diff --git a/tools/regression/geom/geom_simdisk_xml.c b/tools/regression/geom/geom_simdisk_xml.c index 93bcf9833656..54b6b9d566dd 100644 --- a/tools/regression/geom/geom_simdisk_xml.c +++ b/tools/regression/geom/geom_simdisk_xml.c @@ -124,6 +124,7 @@ endElement(void *userData, const char *name) char *p; u_char *q; int i, j; + off_t o; sc = userData; @@ -137,9 +138,11 @@ endElement(void *userData, const char *name) if (*p != '\0') errx(1, "strtoul croaked on sectorsize"); } else if (!strcasecmp(name, "mediasize")) { - sc->mediasize = strtoull(sbuf_data(sc->sbuf), &p, 0); + o = strtoull(sbuf_data(sc->sbuf), &p, 0); if (*p != '\0') errx(1, "strtoul croaked on mediasize"); + if (o > 0) + sc->mediasize = o; } else if (!strcasecmp(name, "fwsectors")) { sc->fwsectors = strtoul(sbuf_data(sc->sbuf), &p, 0); if (*p != '\0') @@ -219,6 +222,7 @@ g_simdisk_xml_load(char *name, char *file) sc = calloc(1, sizeof *sc); sc->fd = -1; sc->sbuf = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND); + sc->mediasize = 1024 * 1024 * 1024 * (off_t)1024; LIST_INIT(&sc->sectors); TAILQ_INIT(&sc->sort); XML_SetUserData(parser, sc);