Coredump in disklabel with md device

From: Simon L. Nielsen <simon_at_nitro.dk>
Date: Wed, 7 May 2003 01:33:09 +0200
Hello

While trying to make a patch for docs/51897 and testing it I'm making
bsdlabel/disklabel coredump :

# dd if=/dev/zero of=somebackingfile bs=1k count=10k
# mdconfig -a -t vnode -f somebackingfile -u 0
# disklabel -w md0
# disklabel -e md0

I then add :

  d:    *       0       4.2BSD

and get a floating exception coredump. It seems the memory device
is reporting a sector size of 0 (if I read the code right) :

0x0804ad88 in getasciipartspec (tp=0x0, lp=0xbfbff9d0, part=134540284, lineno=5) at bsdlabel.c:999
999                             if (pp->p_size < 1024*1024*1024 / lp->d_secsize) {
(gdb) bt
#0  0x0804ad88 in getasciipartspec (tp=0x0, lp=0xbfbff9d0, part=134540284, lineno=5) at bsdlabel.c:999
#1  0x0804aa37 in getasciilabel (f=0x2816c6c0, lp=0xbfbff9d0) at bsdlabel.c:879
#2  0x08049f2f in edit () at bsdlabel.c:562
#3  0x0804934a in main (argc=1, argv=0xbfbffb74) at bsdlabel.c:234
#4  0x08049065 in _start ()
(gdb) print lp->d_secsize
$1 = 0

100% reproduceable on :
FreeBSD ford.nitro.dk 5.1-BETA FreeBSD 5.1-BETA #3: Tue May  6 22:49:47 CEST 2003     FreeBSD_at_trillian.nitro.dk:/usr/obj/data/FreeBSD/clean-CURRENT/sys/GENERIC  i386

If I hack bsdlabel to force 512 byte sectors (like below) everything
seems to work fine (I can newfs and mount the new device).

%%%
Index: bsdlabel.c
===================================================================
RCS file: /data/FreeBSD/ncvs/src/sbin/bsdlabel/bsdlabel.c,v
retrieving revision 1.90
diff -u -r1.90 bsdlabel.c
--- bsdlabel.c	4 May 2003 19:27:22 -0000	1.90
+++ bsdlabel.c	7 May 2003 01:29:13 -0000
_at__at_ -992,6 +992,10 _at__at_
 			pp->p_frag = v / pp->p_fsize;
 			NXTNUM(pp->p_cpg);
 		} else {
+			/* HACK: Check for odd sectorsize e.g. from md devices */
+			if(lp->d_secsize == 0)
+				lp->d_secsize = 512;
+
 			/*
 			 * FIX! poor attempt at adaptive
 			 */
%%%

-- 
Simon L. Nielsen

Received on Tue May 06 2003 - 14:33:12 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:06 UTC