From owner-freebsd-current Sun Jan 12 20: 2:52 2003 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 342A337B401 for ; Sun, 12 Jan 2003 20:02:49 -0800 (PST) Received: from area51.slashnet.org (area51.slashnet.org [209.150.98.86]) by mx1.FreeBSD.org (Postfix) with ESMTP id A7C8143F43 for ; Sun, 12 Jan 2003 20:02:48 -0800 (PST) (envelope-from smkelly@zombie.org) Received: from edgemaster.zombie.org (ip68-13-64-165.om.om.cox.net [68.13.64.165]) by area51.slashnet.org (Postfix) with ESMTP id 0E04A49F1F for ; Sun, 12 Jan 2003 23:02:48 -0500 (EST) Received: by edgemaster.zombie.org (Postfix, from userid 1001) id 7A0BA41608; Sun, 12 Jan 2003 22:02:47 -0600 (CST) Date: Sun, 12 Jan 2003 22:02:47 -0600 From: Sean Kelly To: current@freebsd.org Subject: fdisk issues? Message-ID: <20030113040247.GA816@edgemaster.zombie.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="mP3DRpeJDSE+ciuQ" Content-Disposition: inline User-Agent: Mutt/1.5.3i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --mP3DRpeJDSE+ciuQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hoping to be able to do a disklabel -B again, I just built a kernel with N O_GEOM. However, I ran into an interesting problem with 'fdisk' when trying to debug my other "Boot error" problems that boot1 is giving me. edgemaster# fdisk ad1 Floating exception (core dumped) In get_params, we have: =2E.. 780 error =3D ioctl(fd, DIOCGFWSECTORS, &u); 781 if (error =3D=3D 0) 782 sectors =3D dos_sectors =3D u; 783 error =3D ioctl(fd, DIOCGFWHEADS, &u); 784 if (error =3D=3D 0) 785 heads =3D dos_heads =3D u; 786 787 dos_cylsecs =3D cylsecs =3D heads * sectors; 788 disksecs =3D cyls * heads * sectors; =2E.. 794 error =3D ioctl(fd, DIOCGMEDIASIZE, &o); 795 if (error =3D=3D 0) { 796 disksecs =3D o / u; 797 cyls =3D dos_cyls =3D o / (u * dos_heads * dos_sect= ors); 798 } =2E.. What happens if the ioctls in lines 780 and/or 783 fail? When we get to line 797, we're snagged with division by zero. I shall demonstrate: Script started on Sun Jan 12 21:57:23 2003 (gdb) break get_parmams Breakpoint 1 at 0x8049666: file fdisk.c, line 780. (gdb) run ad1 Starting program: /usr/src/sbin/fdisk/fdisk ad1 Breakpoint 1, get_params () at fdisk.c:780 780 error =3D ioctl(fd, DIOCGFWSECTORS, &u); (gdb) s 781 if (error =3D=3D 0) (gdb) p error $1 =3D -1 (gdb) s 783 error =3D ioctl(fd, DIOCGFWHEADS, &u); (gdb) s 784 if (error =3D=3D 0) (gdb) p error $2 =3D -1 (gdb) s 787 dos_cylsecs =3D cylsecs =3D heads * sectors; (gdb) print heads $3 =3D 0 (gdb) p sectors $4 =3D 0 (gdb) s 788 disksecs =3D cyls * heads * sectors; (gdb) s 790 error =3D ioctl(fd, DIOCGSECTORSIZE, &u); (gdb) s 791 if (error !=3D 0) (gdb) p error $5 =3D 0 (gdb) s 794 error =3D ioctl(fd, DIOCGMEDIASIZE, &o); (gdb) p u $6 =3D 512 (gdb) s 795 if (error =3D=3D 0) { (gdb) p error $7 =3D 0 (gdb) p o $8 =3D 60022480896 (gdb) s 796 disksecs =3D o / u; (gdb) s 797 cyls =3D dos_cyls =3D o / (u * dos_heads * dos_sectors); (gdb) p disksecs $9 =3D 117231408 (gdb) s Program received signal SIGFPE, Arithmetic exception. 0x0804ac43 in __divdi3 () (gdb) p dos_heads $10 =3D 0 (gdb) p dos_sectors $11 =3D 0 (gdb) kill Kill the program being debugged? (y or n) y (gdb) quit Script done on Sun Jan 12 21:58:56 2003 I think I might just get out a small magnet and fix my booting problems manually. --=20 Sean Kelly | PGP KeyID: D2E5E296 smkelly@zombie.org | http://www.zombie.org --mP3DRpeJDSE+ciuQ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQE+IjpmPm7A9NLl4pYRAuimAJ43FOh1/V/fzIRj+9zFozqfTBuZhgCfYnrq Qbgy5/sYY5oTutGjIVDMLt8= =J2yV -----END PGP SIGNATURE----- --mP3DRpeJDSE+ciuQ-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message