diff options
author | phk <phk@FreeBSD.org> | 2002-10-20 20:28:24 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2002-10-20 20:28:24 +0000 |
commit | af63f9546ade194575238522dacd38cebe3b63f6 (patch) | |
tree | 4be4d44cd73707526477ac8dedf166de6841e46d /sys/geom/geom_dev.c | |
parent | f0693daa1f5896bbd37f2ad85ba732389ac99646 (diff) | |
download | FreeBSD-src-af63f9546ade194575238522dacd38cebe3b63f6.zip FreeBSD-src-af63f9546ade194575238522dacd38cebe3b63f6.tar.gz |
Now that the sectorsize and mediasize are properties of the provider,
don't take the detour over the I/O path to discover them using getattr(),
we can just pick them out directly.
Do note though, that for now they are only valid after the first open
of the underlying disk device due compatibility with the old disk_create()
API. This will change in the future so they will always be valid.
Sponsored by: DARPA & NAI Labs.
Diffstat (limited to 'sys/geom/geom_dev.c')
-rw-r--r-- | sys/geom/geom_dev.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c index b044111..bdd6670 100644 --- a/sys/geom/geom_dev.c +++ b/sys/geom/geom_dev.c @@ -245,13 +245,13 @@ g_dev_ioctl(dev_t dev, u_long cmd, caddr_t data, int fflag, struct thread *td) i = IOCPARM_LEN(cmd); switch (cmd) { case DIOCGSECTORSIZE: - error = g_io_getattr("GEOM::sectorsize", cp, &i, data); - if (error == 0 && *(u_int *)data == 0) + *(u_int *)data = cp->provider->sectorsize; + if (*(u_int *)data == 0) error = ENOENT; break; case DIOCGMEDIASIZE: - error = g_io_getattr("GEOM::mediasize", cp, &i, data); - if (error == 0 && *(off_t *)data == 0) + *(off_t *)data = cp->provider->mediasize; + if (*(off_t *)data == 0) error = ENOENT; break; case DIOCGFWSECTORS: @@ -329,15 +329,11 @@ static int g_dev_psize(dev_t dev) { struct g_consumer *cp; - int i, error; off_t mediasize; cp = dev->si_drv2; - i = sizeof mediasize; - error = g_io_getattr("GEOM::mediasize", cp, &i, &mediasize); - if (error) - return (-1); + mediasize = cp->provider->mediasize; return (mediasize >> DEV_BSHIFT); } |