1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-28 08:02:54 +00:00

Play catch up with the kernel.

Sponsored by:	DARPA & NAI Labs
This commit is contained in:
Poul-Henning Kamp 2002-04-04 16:40:11 +00:00
parent 2b814c7ea1
commit fead6f3f5b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=93792
4 changed files with 14 additions and 5 deletions

View File

@ -47,6 +47,7 @@
#include <sys/time.h>
#include <geom/geom.h>
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
};

View File

@ -43,6 +43,7 @@
#include <strings.h>
#include <err.h>
#include <sys/errno.h>
#include <sys/stat.h>
#include <geom/geom.h>
#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);

View File

@ -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;

View File

@ -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);