Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Jul 2010 16:23:31 GMT
From:      jh@FreeBSD.org
To:        martin.faxer@home.se, jh@FreeBSD.org, freebsd-bugs@FreeBSD.org, jh@FreeBSD.org
Subject:   Re: bin/58390: bsdlabel(8) fails to display an error message if the label could not be written
Message-ID:  <201007011623.o61GNVNY058104@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
Synopsis: bsdlabel(8) fails to display an error message if the label could not be written

State-Changed-From-To: open->feedback
State-Changed-By: jh
State-Changed-When: Thu Jul 1 15:55:12 UTC 2010
State-Changed-Why: 
Is this still a problem for you?

On 8.0:

/dev/md1 on /mnt (ufs, local)
# bsdlabel -w /dev/md1
bsdlabel: Class not found

But this is because GEOM_BSD has been changed to GEOM_PART_BSD.
The error message is not very informative.

On 7.3 (uses GEOM_BSD):

# bsdlabel -w /dev/md1
bsdlabel: Geom not found: "md0"

Not very informative either.

This change makes the error message more understandable for me:

%%%
Index: sbin/bsdlabel/bsdlabel.c
===================================================================
--- sbin/bsdlabel/bsdlabel.c	(revision 209622)
+++ sbin/bsdlabel/bsdlabel.c	(working copy)
@@ -382,7 +382,7 @@ static int
 writelabel(void)
 {
 	uint64_t *p, sum;
-	int i, fd;
+	int i, fd, serrno;
 	struct gctl_req *grq;
 	char const *errstr;
 	struct disklabel *lp = &lab;
@@ -413,6 +413,7 @@ writelabel(void)
 
 	fd = open(specname, O_RDWR);
 	if (fd < 0) {
+		serrno = errno;
 		if (is_file) {
 			warn("cannot open file %s for writing label", specname);
 			return(1);
@@ -426,7 +427,7 @@ writelabel(void)
 			bootarea + labeloffset + labelsoffset * secsize);
 		errstr = gctl_issue(grq);
 		if (errstr != NULL) {
-			warnx("%s", errstr);
+			warnc(serrno, "%s", specname);
 			gctl_free(grq);
 			return(1);
 		}
%%%

With the patch applied:

# bsdlabel -w /dev/md1 
bsdlabel: /dev/md1: Operation not permitted



Responsible-Changed-From-To: freebsd-bugs->jh
Responsible-Changed-By: jh
Responsible-Changed-When: Thu Jul 1 15:55:12 UTC 2010
Responsible-Changed-Why: 
Track.

http://www.freebsd.org/cgi/query-pr.cgi?pr=58390



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007011623.o61GNVNY058104>