Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 04 Nov 2002 01:07:22 -0700 (MST)
From:      "M. Warner Losh" <imp@bsdimp.com>
To:        jhay@icomtek.csir.co.za
Cc:        n_hibma@van-laarhoven.org, current@FreeBSD.ORG, phk@critter.freebsd.dk
Subject:   Re: umass CF geometry problems, was Re: fdisk -BI ob clean disk broken
Message-ID:  <20021104.010722.110976721.imp@bsdimp.com>
In-Reply-To: <200211040802.gA482oJj093121@zibbi.icomtek.csir.co.za>
References:  <20021104084214.D17734-100000@uitsmijter.van-laarhoven.org> <200211040802.gA482oJj093121@zibbi.icomtek.csir.co.za>

next in thread | previous in thread | raw e-mail | index | archive | help
In message: <200211040802.gA482oJj093121@zibbi.icomtek.csir.co.za>
            John Hay <jhay@icomtek.csir.co.za> writes:
: > What is the GET_GEOMETRY used for anyway?
: 
: Well the short version of the problem is that "fdisk -BI <disk>" works
: on -stable to get a FreeBSD partition on the Compact Flash. This does
: not work on -current anymore. I have traced that back to the commit
: in umass.c rev 1.61 that removed the fake geometry setting and just
: leave the cylinders, heads and sectors_per_track zero. This cause
: fdisk to coredump with a floating point error.

fdisk is using them, btw, to create a MBR which needs these fields to
be somewhat sane.  The floating point error likely is because we're
dividing by zero on this case:

#define RoundCyl(x) ((((x) + cylsecs - 1) / cylsecs) * cylsecs)

if cylsecs is 0, guess what happens.  We do similar things with
dos_cylsecs in init_sector0.  There's also code in get_params() that
devides by dos_heads * 512 * dos_sectors:

static int
get_params()
{
	int error;
	u_int u;
	off_t o;

	error = ioctl(fd, DIOCGFWSECTORS, &u);
	if (error == 0)
		sectors = dos_sectors = u;
	error = ioctl(fd, DIOCGFWHEADS, &u);
	if (error == 0)
		heads = dos_heads = u;

	dos_cylsecs = cylsecs = heads * sectors;
	disksecs = cyls * heads * sectors;

	error = ioctl(fd, DIOCGSECTORSIZE, &u);
	if (error != 0)
		u = 512;

	error = ioctl(fd, DIOCGMEDIASIZE, &o);
	if (error == 0) {
		disksecs = o / u;
		cyls = dos_cyls = o / (u * dos_heads * dos_sectors);
	}

	return (disksecs);
}

fdisk likely should do something sane in the face of such insanity,
but it is unclear what and fdisk is a royal pita to work on anyway :-(

Warner

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?20021104.010722.110976721.imp>