Module Name:    src
Committed By:   christos
Date:           Wed Dec 31 19:50:14 UTC 2014

Modified Files:
        src/sys/kern: subr_disk_open.c

Log Message:
get the wedge info first if it exists, because this will support larger sizes.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/kern/subr_disk_open.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/kern/subr_disk_open.c
diff -u src/sys/kern/subr_disk_open.c:1.11 src/sys/kern/subr_disk_open.c:1.12
--- src/sys/kern/subr_disk_open.c:1.11	Sat Oct 27 13:18:39 2012
+++ src/sys/kern/subr_disk_open.c	Wed Dec 31 14:50:14 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_disk_open.c,v 1.11 2012/10/27 17:18:39 chs Exp $	*/
+/*	$NetBSD: subr_disk_open.c,v 1.12 2014/12/31 19:50:14 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_disk_open.c,v 1.11 2012/10/27 17:18:39 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_disk_open.c,v 1.12 2014/12/31 19:50:14 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -98,19 +98,25 @@ getdisksize(struct vnode *vp, uint64_t *
 	uint64_t numsec;
 	int error;
 
-	error = VOP_IOCTL(vp, DIOCGPART, &dpart, FREAD, NOCRED);
+	/*
+	 * We attempt to get the wedge information first if it exists,
+	 * because the label does not support larger size disks.
+	 */
+	error = VOP_IOCTL(vp, DIOCGWEDGEINFO, &dkw, FREAD, NOCRED);
 	if (error == 0) {
-		secsize = dpart.disklab->d_secsize;
-		numsec  = dpart.part->p_size;
-	} else {
-		error = VOP_IOCTL(vp, DIOCGWEDGEINFO, &dkw, FREAD, NOCRED);
+		pdk = disk_find(dkw.dkw_parent);
+		if (pdk != NULL) {
+			secsize = DEV_BSIZE << pdk->dk_blkshift;
+			numsec  = dkw.dkw_size;
+		} else
+			error = ENODEV;
+	}
+
+	if (error) {
+		error = VOP_IOCTL(vp, DIOCGPART, &dpart, FREAD, NOCRED);
 		if (error == 0) {
-			pdk = disk_find(dkw.dkw_parent);
-			if (pdk != NULL) {
-				secsize = DEV_BSIZE << pdk->dk_blkshift;
-				numsec  = dkw.dkw_size;
-			} else
-				error = ENODEV;
+			secsize = dpart.disklab->d_secsize;
+			numsec  = dpart.part->p_size;
 		}
 	}
 

Reply via email to