summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2006-11-19 20:17:12 +0000
committerkrw <krw@openbsd.org>2006-11-19 20:17:12 +0000
commit2e01c514dd46739e1ff48ab524a55dd1bc630355 (patch)
tree40f799d5409ffb9abc4a3535fc99ec9818a09f81
parentsome additional registers for the Artisea chipset operating in DPA mode. (diff)
downloadwireguard-openbsd-2e01c514dd46739e1ff48ab524a55dd1bc630355.tar.xz
wireguard-openbsd-2e01c514dd46739e1ff48ab524a55dd1bc630355.zip
Try DIOCGPDINFO before DIOCGDINFO when trying to determine the 'label'
geometry for a unit. DIOCGPDINFO avoids using the on-disk label or the cached copy of it and returns a 'spoofed' label that retains the geometry info placed in the label by the driver. Unfortunately DIOCGPDINFO is not universally implemented, though sd and wd do. This is what disklabel(8) does when it wants geometry so this makes fdisk a bit more consistant with disklabel. This fixes 'fdisk -i' and 'reinit' when trying to install from a miniroot on, e.g., landisk. i.e. no need to zero out the disklabel before doing 'fdisk -i'. 'get it in snaps' deraadt@
-rw-r--r--sbin/fdisk/disk.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sbin/fdisk/disk.c b/sbin/fdisk/disk.c
index 25b03a6e959..ba5b19f05a4 100644
--- a/sbin/fdisk/disk.c
+++ b/sbin/fdisk/disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disk.c,v 1.24 2005/12/18 03:42:23 krw Exp $ */
+/* $OpenBSD: disk.c,v 1.25 2006/11/19 20:17:12 krw Exp $ */
/*
* Copyright (c) 1997, 2001 Tobias Weingartner
@@ -89,7 +89,8 @@ DISK_getlabelmetrics(char *name)
if (lm == NULL)
err(1, NULL);
- if (ioctl(fd, DIOCGDINFO, &dl) == -1) {
+ if (ioctl(fd, DIOCGPDINFO, &dl) == -1 &&
+ ioctl(fd, DIOCGDINFO, &dl) == -1) {
warn("DIOCGDINFO");
free(lm);
lm = NULL;