Module Name:    src
Committed By:   christos
Date:           Sun Nov 13 23:03:24 UTC 2011

Modified Files:
        src/sys/dev: cgd.c

Log Message:
use getdisksize() instead of homebrew()


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/dev/cgd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/cgd.c
diff -u src/sys/dev/cgd.c:1.75 src/sys/dev/cgd.c:1.76
--- src/sys/dev/cgd.c:1.75	Fri Oct 14 05:23:30 2011
+++ src/sys/dev/cgd.c	Sun Nov 13 18:03:24 2011
@@ -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 @@ cgd_ioctl_clr(struct cgd_softc *cs, stru
 }
 
 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 @@ cgdinit(struct cgd_softc *cs, const char
 
 	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

Reply via email to