From owner-freebsd-arch Wed Jan 15 3:12:32 2003 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 10AFE37B401 for ; Wed, 15 Jan 2003 03:12:30 -0800 (PST) Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id D8C8B43F65 for ; Wed, 15 Jan 2003 03:12:28 -0800 (PST) (envelope-from des@ofug.org) Received: by flood.ping.uio.no (Postfix, from userid 2602) id 893BE5374; Wed, 15 Jan 2003 12:12:25 +0100 (CET) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: arch@freebsd.org Subject: Buglet in disklabel From: Dag-Erling Smorgrav Date: Wed, 15 Jan 2003 12:12:24 +0100 Message-ID: Lines: 45 User-Agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.2 (i386--freebsd) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --=-=-= There's a bug in disklabel -e which manifests itself when you make a mistake and re-edit the label. Under certain circumstances, it will remember portions of an earlier version of the label, and reject a valid label because of conflicts with the earlier version. To demonstrate this problem, run 'disklabel -e' on a scratch disk and do the following: - add a 'd' partition with size * and an offset well within the size of the disk - add an 'e' partition with size * and a different offset well within the size of the disk. - save and exit; disklabel will complain: Warning, Too many '*' partitions (d and e) Warning, partition e: size 0, but offset 7843184 partitions d and e overlap! re-edit the label? [y]: - agree to re-edit the label - remove the 'e' partition - save and exit; disklabel will complain again: Warning, Too many '*' partitions (d and e) This happens because it remembers the 'e' partition from the previous round, even though you deleted it. In this case, nothing truly bad happens, but it is conceivable that it will actually write a label to disk which differs from the one you specified (if for instance you change the * in the specification for the 'd' partition to a fixed value which does not cause an overlap with the ghost 'e' partition) I believe the attached patch fixes this problem, but I'd like a review from someone more familiar with disklabel before I commit it. DES -- Dag-Erling Smorgrav - des@ofug.org --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=disklabel.diff Index: disklabel.c =================================================================== RCS file: /home/ncvs/src/sbin/disklabel/disklabel.c,v retrieving revision 1.65 diff -u -r1.65 disklabel.c --- disklabel.c 4 Jan 2003 08:50:47 -0000 1.65 +++ disklabel.c 15 Jan 2003 10:57:56 -0000 @@ -957,6 +957,7 @@ int lineno = 0, errors = 0; int i; + bzero(lp, sizeof *lp); lp->d_bbsize = BBSIZE; /* XXX */ lp->d_sbsize = 0; /* XXX */ while (fgets(line, sizeof(line) - 1, f)) { --=-=-=-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message