summaryrefslogtreecommitdiffstats
path: root/sbin/bsdlabel
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2002-03-03 21:21:45 +0000
committerphk <phk@FreeBSD.org>2002-03-03 21:21:45 +0000
commit7b0ce36f943ee834a4976161135b0e49814b3a77 (patch)
tree0417a4f96b61be534e8ec9f28838ea3f3e041319 /sbin/bsdlabel
parent72b0228f1061e3df02b9afc0c326f61fdccbe6f7 (diff)
downloadFreeBSD-src-7b0ce36f943ee834a4976161135b0e49814b3a77.zip
FreeBSD-src-7b0ce36f943ee834a4976161135b0e49814b3a77.tar.gz
A bit of premptive GEOM POLA magic: If we don't get a virgin disklabel
from /dev/food0, then try from /dev/f00d0c, in strange cases this work.
Diffstat (limited to 'sbin/bsdlabel')
-rw-r--r--sbin/bsdlabel/bsdlabel.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/sbin/bsdlabel/bsdlabel.c b/sbin/bsdlabel/bsdlabel.c
index 5317a66..d496bcf 100644
--- a/sbin/bsdlabel/bsdlabel.c
+++ b/sbin/bsdlabel/bsdlabel.c
@@ -1613,13 +1613,23 @@ getvirginlabel(void)
* Try to use the new get-virgin-label ioctl. If it fails,
* fallback to the old get-disdk-info ioctl.
*/
- if (ioctl(f, DIOCGDVIRGIN, &lab) < 0) {
- if (ioctl(f, DIOCGDINFO, &lab) < 0) {
- warn("ioctl DIOCGDINFO");
- close(f);
- return (NULL);
- }
+ if (ioctl(f, DIOCGDVIRGIN, &lab) == 0)
+ goto out;
+ if (ioctl(f, DIOCGDINFO, &lab) == 0)
+ goto out;
+ close(f);
+ (void)snprintf(namebuf, BBSIZE, "%s%s%c", _PATH_DEV, dkname,
+ 'a' + RAW_PART);
+ if ((f = open(namebuf, O_RDONLY)) == -1) {
+ warn("cannot open %s", namebuf);
+ return (NULL);
}
+ if (ioctl(f, DIOCGDINFO, &lab) == 0)
+ goto out;
+ close(f);
+ warn("No virgin disklabel found %s", namebuf);
+ return (NULL);
+ out:
close(f);
lab.d_boot0 = NULL;
lab.d_boot1 = NULL;
OpenPOWER on IntegriCloud