summaryrefslogtreecommitdiff
path: root/sbin/disklabel
diff options
context:
space:
mode:
authorbouyer <bouyer@NetBSD.org>2011-08-30 12:39:49 +0000
committerbouyer <bouyer@NetBSD.org>2011-08-30 12:39:49 +0000
commit509fd41bf376707c31e54f74c4303ef46d9e6c8c (patch)
treece692b9927b402603b18e657ba4f0422848f1490 /sbin/disklabel
parent01e23d8e1682b54e70da3f79ca6f5afca2db41d0 (diff)
Add getlabelusesmbr(), as proposed in
http://mail-index.netbsd.org/tech-userlevel/2011/08/25/msg005404.html This is used by disk tools such as disklabel(8) to dynamically decide is the undelyling platform uses a disklabel-in-mbr-partition or not (instead of using a compile-time list of ports). getlabelusesmbr() reads the sysctl kern.labelusesmbr, takes its value from the machdep #define LABELUSESMBR. For evbmips, make LABELUSESMBR 1 if the platform uses pmon as bootloader, and 0 (the previous value) otherwise.
Diffstat (limited to 'sbin/disklabel')
-rw-r--r--sbin/disklabel/Makefile32
-rw-r--r--sbin/disklabel/main.c14
2 files changed, 10 insertions, 36 deletions
diff --git a/sbin/disklabel/Makefile b/sbin/disklabel/Makefile
index c43f42c8317..c848815bd74 100644
--- a/sbin/disklabel/Makefile
+++ b/sbin/disklabel/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.68 2011/08/18 08:42:07 phx Exp $
+# $NetBSD: Makefile,v 1.69 2011/08/30 12:39:52 bouyer Exp $
# @(#)Makefile 8.2 (Berkeley) 3/17/94
PROG= disklabel
@@ -15,36 +15,6 @@ LDADD+= -lutil
CPPFLAGS+= -DSTRICT_CYLINDER_ALIGNMENT
.endif
-.if ( 0 \
- || ${MACHINE} == "acorn26" \
- || ${MACHINE} == "acorn32" \
- || ${MACHINE} == "amd64" \
- || ${MACHINE} == "arc" \
- || ${MACHINE} == "cats" \
- || ${MACHINE} == "cobalt" \
- || ${MACHINE} == "dreamcast" \
- || ${MACHINE} == "evbarm" \
- || ${MACHINE} == "evbsh3" \
- || ${MACHINE} == "hpcarm" \
- || ${MACHINE} == "hpcmips" \
- || ${MACHINE} == "hpcsh" \
- || ${MACHINE} == "i386" \
- || ${MACHINE} == "iyonix" \
- || ${MACHINE} == "landisk" \
- || ${MACHINE} == "macppc" \
- || ${MACHINE} == "mmeye" \
- || ${MACHINE} == "netwinder" \
- || ${MACHINE} == "ofppc" \
- || ${MACHINE} == "prep" \
- || ${MACHINE} == "shark" \
- || ${MACHINE} == "zaurus" \
- )
-# use MBR partition info
-CPPFLAGS+= -DUSE_MBR
-# do not recognize old MBR partition ID any more
-#CPPFLAGS+= -DCOMPAT_386BSD_MBRPART
-.endif
-
.if (${MACHINE} == "acorn32" || ${MACHINE} == "acorn26")
# Support FileCore boot block
CPPFLAGS+= -DUSE_ACORN
diff --git a/sbin/disklabel/main.c b/sbin/disklabel/main.c
index 54685072ca5..da9b4011409 100644
--- a/sbin/disklabel/main.c
+++ b/sbin/disklabel/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.25 2011/08/29 14:34:59 joerg Exp $ */
+/* $NetBSD: main.c,v 1.26 2011/08/30 12:39:52 bouyer Exp $ */
/*
* Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993\
static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95";
/* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */
#else
-__RCSID("$NetBSD: main.c,v 1.25 2011/08/29 14:34:59 joerg Exp $");
+__RCSID("$NetBSD: main.c,v 1.26 2011/08/30 12:39:52 bouyer Exp $");
#endif
#endif /* not lint */
@@ -186,9 +186,11 @@ static int set_writable_fd = -1;
#if HAVE_NBTOOL_CONFIG_H
#define GETLABELOFFSET() LABELOFFSET
#define GETLABELSECTOR() LABELSECTOR
+#define GETLABELUSESMBR() LABELUSESMBR
#else /* HAVE_NBTOOL_CONFIG_H */
#define GETLABELOFFSET() getlabeloffset()
#define GETLABELSECTOR() getlabelsector()
+#define GETLABELUSESMBR() getlabelusesmbr()
#endif
/* Default location for label - only used if we don't find one to update */
@@ -272,9 +274,11 @@ main(int argc, char *argv[])
WRITE, INTERACT, DELETE
} op = UNSPEC, old_op;
-#ifdef USE_MBR
- mflag = 1;
-#endif
+ mflag = GETLABELUSESMBR();
+ if (mflag < 0) {
+ warn("getlabelusesmbr() failed");
+ mflag = LABELUSESMBR;
+ }
#if HAVE_NBTOOL_CONFIG_H
/* We must avoid doing any ioctl requests */
Fflag = rflag = 1;