aboutsummaryrefslogtreecommitdiff
path: root/sbin/bsdlabel
diff options
context:
space:
mode:
authorAndrey V. Elsukov <ae@FreeBSD.org>2011-11-06 20:32:55 +0000
committerAndrey V. Elsukov <ae@FreeBSD.org>2011-11-06 20:32:55 +0000
commitfd4bbf84f2664e76f24ac27e3e7167f99252f80f (patch)
tree036e48c8d9b9b9ff10d3ec675e84d7deb1f4c835 /sbin/bsdlabel
parenta35353de88d75b241f455719b98a1ac4bbd9baf3 (diff)
downloadsrc-fd4bbf84f2664e76f24ac27e3e7167f99252f80f.tar.gz
src-fd4bbf84f2664e76f24ac27e3e7167f99252f80f.zip
Add recommendation to use gpart(8) when user tries write disklabel
or bootcode to already opened provider. MFC after: 1 week
Notes
Notes: svn path=/head/; revision=227270
Diffstat (limited to 'sbin/bsdlabel')
-rw-r--r--sbin/bsdlabel/bsdlabel.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/sbin/bsdlabel/bsdlabel.c b/sbin/bsdlabel/bsdlabel.c
index 50f576969fdc..6a5eeffe9d33 100644
--- a/sbin/bsdlabel/bsdlabel.c
+++ b/sbin/bsdlabel/bsdlabel.c
@@ -80,7 +80,7 @@ __FBSDID("$FreeBSD$");
#include "pathnames.h"
static void makelabel(const char *, struct disklabel *);
-static int geom_bsd_available(void);
+static int geom_class_available(const char *);
static int writelabel(void);
static int readlabel(int flag);
static void display(FILE *, const struct disklabel *);
@@ -355,7 +355,7 @@ readboot(void)
}
static int
-geom_bsd_available(void)
+geom_class_available(const char *name)
{
struct gclass *class;
struct gmesh mesh;
@@ -366,7 +366,7 @@ geom_bsd_available(void)
errc(1, error, "Cannot get GEOM tree");
LIST_FOREACH(class, &mesh.lg_class, lg_class) {
- if (strcmp(class->lg_name, "BSD") == 0) {
+ if (strcmp(class->lg_name, name) == 0) {
geom_deletetree(&mesh);
return (1);
}
@@ -411,8 +411,19 @@ writelabel(void)
} else
serrno = errno;
+ if (geom_class_available("PART") != 0) {
+ /* Since we weren't able open provider for
+ * writing, then recommend user to use gpart(8).
+ */
+ warnc(serrno,
+ "cannot open provider %s for writing label",
+ specname);
+ warnx("Try to use gpart(8).");
+ return (1);
+ }
+
/* Give up if GEOM_BSD is not available. */
- if (geom_bsd_available() == 0) {
+ if (geom_class_available("BSD") == 0) {
warnc(serrno, "%s", specname);
return (1);
}