diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2006-11-19 20:17:13 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2006-11-19 20:17:13 +0000 |
commit | 550422b45e68ef8e66f03299faa2ddb8625521a6 (patch) | |
tree | a1a692bdf5d4a0e6f1b0bd6757597bd7ce23fe97 /sbin | |
parent | ba835498dbc17253fcf550338a7be1c7fe6c86ed (diff) |
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@
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fdisk/disk.c | 5 |
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; |