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
[-- Attachment #1 --]
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:
...
780 error = ioctl(fd, DIOCGFWSECTORS, &u);
781 if (error == 0)
782 sectors = dos_sectors = u;
783 error = ioctl(fd, DIOCGFWHEADS, &u);
784 if (error == 0)
785 heads = dos_heads = u;
786
787 dos_cylsecs = cylsecs = heads * sectors;
788 disksecs = cyls * heads * sectors;
...
794 error = ioctl(fd, DIOCGMEDIASIZE, &o);
795 if (error == 0) {
796 disksecs = o / u;
797 cyls = dos_cyls = o / (u * dos_heads * dos_sectors);
798 }
...
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 = ioctl(fd, DIOCGFWSECTORS, &u);
(gdb) s
781 if (error == 0)
(gdb) p error
$1 = -1
(gdb) s
783 error = ioctl(fd, DIOCGFWHEADS, &u);
(gdb) s
784 if (error == 0)
(gdb) p error
$2 = -1
(gdb) s
787 dos_cylsecs = cylsecs = heads * sectors;
(gdb) print heads
$3 = 0
(gdb) p sectors
$4 = 0
(gdb) s
788 disksecs = cyls * heads * sectors;
(gdb) s
790 error = ioctl(fd, DIOCGSECTORSIZE, &u);
(gdb) s
791 if (error != 0)
(gdb) p error
$5 = 0
(gdb) s
794 error = ioctl(fd, DIOCGMEDIASIZE, &o);
(gdb) p u
$6 = 512
(gdb) s
795 if (error == 0) {
(gdb) p error
$7 = 0
(gdb) p o
$8 = 60022480896
(gdb) s
796 disksecs = o / u;
(gdb) s
797 cyls = dos_cyls = o / (u * dos_heads * dos_sectors);
(gdb) p disksecs
$9 = 117231408
(gdb) s
Program received signal SIGFPE, Arithmetic exception.
0x0804ac43 in __divdi3 ()
(gdb) p dos_heads
$10 = 0
(gdb) p dos_sectors
$11 = 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.
--
Sean Kelly | PGP KeyID: D2E5E296
smkelly@zombie.org | http://www.zombie.org
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)
iD8DBQE+IjpmPm7A9NLl4pYRAuimAJ43FOh1/V/fzIRj+9zFozqfTBuZhgCfYnrq
Qbgy5/sYY5oTutGjIVDMLt8=
=J2yV
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030113040247.GA816>
