Date: Wed, 15 Jan 2003 12:12:24 +0100 From: Dag-Erling Smorgrav <des@ofug.org> To: arch@freebsd.org Subject: Buglet in disklabel Message-ID: <xzp1y3e650n.fsf@flood.ping.uio.no>
next in thread | raw e-mail | index | archive | help
--=-=-= 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzp1y3e650n.fsf>