Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev use getdisksize() instead of homebrew()
details: https://anonhg.NetBSD.org/src/rev/53ab3dc9e114
branches: trunk
changeset: 771197:53ab3dc9e114
user: christos <christos%NetBSD.org@localhost>
date: Sun Nov 13 23:03:24 2011 +0000
description:
use getdisksize() instead of homebrew()
diffstat:
sys/dev/cgd.c | 35 +++++++----------------------------
1 files changed, 7 insertions(+), 28 deletions(-)
diffs (76 lines):
diff -r 66211d419502 -r 53ab3dc9e114 sys/dev/cgd.c
--- a/sys/dev/cgd.c Sun Nov 13 23:02:46 2011 +0000
+++ b/sys/dev/cgd.c Sun Nov 13 23:03:24 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cgd.c,v 1.75 2011/10/14 09:23:30 hannken Exp $ */
+/* $NetBSD: cgd.c,v 1.76 2011/11/13 23:03:24 christos Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.75 2011/10/14 09:23:30 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgd.c,v 1.76 2011/11/13 23:03:24 christos Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -731,36 +731,15 @@
}
static int
-getsize(struct lwp *l, struct vnode *vp, size_t *size)
-{
- struct partinfo dpart;
- struct dkwedge_info dkw;
- int ret;
-
- if ((ret = VOP_IOCTL(vp, DIOCGWEDGEINFO, &dkw, FREAD,
- l->l_cred)) == 0) {
- *size = dkw.dkw_size;
- return 0;
- }
-
- if ((ret = VOP_IOCTL(vp, DIOCGPART, &dpart, FREAD, l->l_cred)) == 0) {
- *size = dpart.part->p_size;
- return 0;
- }
-
- return ret;
-}
-
-
-static int
cgdinit(struct cgd_softc *cs, const char *cpath, struct vnode *vp,
struct lwp *l)
{
struct dk_geom *pdg;
struct vattr va;
- size_t size;
int ret;
char *tmppath;
+ uint64_t psize;
+ unsigned secsize;
cs->sc_dksc.sc_size = 0;
cs->sc_tvn = vp;
@@ -781,15 +760,15 @@
cs->sc_tdev = va.va_rdev;
- if ((ret = getsize(l, vp, &size)) != 0)
+ if ((ret = getdisksize(vp, &psize, &secsize)) != 0)
goto bail;
- if (!size) {
+ if (psize == 0) {
ret = ENODEV;
goto bail;
}
- cs->sc_dksc.sc_size = size;
+ cs->sc_dksc.sc_size = psize;
/*
* XXX here we should probe the underlying device. If we
Home |
Main Index |
Thread Index |
Old Index