From af63f9546ade194575238522dacd38cebe3b63f6 Mon Sep 17 00:00:00 2001 From: phk Date: Sun, 20 Oct 2002 20:28:24 +0000 Subject: 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. --- sys/geom/geom_dev.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'sys/geom/geom_dev.c') 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); } -- cgit v1.1