From owner-freebsd-bugs@FreeBSD.ORG Thu Jul 1 16:23:31 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EB3A4106564A; Thu, 1 Jul 2010 16:23:31 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id B805F8FC22; Thu, 1 Jul 2010 16:23:31 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o61GNVdI058108; Thu, 1 Jul 2010 16:23:31 GMT (envelope-from jh@freefall.freebsd.org) Received: (from jh@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o61GNVNY058104; Thu, 1 Jul 2010 16:23:31 GMT (envelope-from jh) Date: Thu, 1 Jul 2010 16:23:31 GMT Message-Id: <201007011623.o61GNVNY058104@freefall.freebsd.org> To: martin.faxer@home.se, jh@FreeBSD.org, freebsd-bugs@FreeBSD.org, jh@FreeBSD.org From: jh@FreeBSD.org Cc: Subject: Re: bin/58390: bsdlabel(8) fails to display an error message if the label could not be written X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jul 2010 16:23:32 -0000 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