diff options
Diffstat (limited to 'sbin/disklabel/disklabel.c')
-rw-r--r-- | sbin/disklabel/disklabel.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c index a3fc788..484f073 100644 --- a/sbin/disklabel/disklabel.c +++ b/sbin/disklabel/disklabel.c @@ -1346,10 +1346,17 @@ getvirginlabel(void) warn("cannot open %s", namebuf); return (NULL); } - if (ioctl(f, DIOCGDINFO, &lab) < 0) { - warn("ioctl DIOCGDINFO"); - close(f); - return (NULL); + + /* + * 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); + } } close(f); lab.d_boot0 = NULL; |