Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Jan 2003 22:02:47 -0600
From:      Sean Kelly <smkelly@zombie.org>
To:        current@freebsd.org
Subject:   fdisk issues?
Message-ID:  <20030113040247.GA816@edgemaster.zombie.org>

next in thread | raw e-mail | index | archive | help

--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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030113040247.GA816>