Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Oct 2002 12:53:25 -0700 (PDT)
From:      Nate Lawson <nate@root.org>
To:        Poul-Henning Kamp <phk@critter.freebsd.dk>
Cc:        current@freebsd.org
Subject:   Re: GEOM/fdisk/USB drive problem 
Message-ID:  <Pine.BSF.4.21.0210151251250.37181-200000@root.org>
In-Reply-To: <31480.1034710602@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

--0-902143914-1034711605=:37181
Content-Type: TEXT/PLAIN; charset=US-ASCII

On Tue, 15 Oct 2002, Poul-Henning Kamp wrote:
> In message <Pine.BSF.4.21.0210151222400.36779-100000@root.org>, Nate Lawson wri
> tes:
> >fdisk against my USB flash drive crashes with divide by zero.  It turns
> >out that get_params() starts with some default values (since there is
> >no disklabel) and then runs some ioctls: DIOCGFWSECTORS and DIOCGFWHEADS.
> >
> >The problem is that fdisk checks the error from that ioctl and then
> >happily uses whatever parameters it returned.  My question is, should I
> >add the error checking in userland (error == 0 && sector != 0) or in
> >g_dev_ioctl?  IMO, it should be in g_dev_ioctl so that we only have to
> >validate the data in one place instead of multiple utilities (fdisk,
> >disklabel, ...?)
> 
> I really think it belongs in userland and not in the kernel.
> 
> The "FW" values are advisory, and if they are not there or not
> sensible, userland should cope.
> 
> I could agree to make g_dev_ioctl fail the ioctl with some errno
> if they came back as zero, but not substituting another value.

The attached patch makes everything work fine for my drive (64 MB USB
flash).

-Nate

fdisk: can't get disk parameters on /dev/da0; supplying dummy ones
******* Working on device /dev/da0 *******
parameters extracted from in-core disklabel are:
cylinders=129024 heads=1 sectors/track=1 (1 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=129024 heads=1 sectors/track=1 (1 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 6 (0x06),(Primary 'big' DOS (>= 32MB))
    start 32, size 128480 (62 Meg), flag 80 (active)
        beg: cyl 0/ head 1/ sector 1;
        end: cyl 250/ head 15/ sector 32
The data for partition 2 is:
<UNUSED>
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
<UNUSED>


--0-902143914-1034711605=:37181
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="geom.patch"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.BSF.4.21.0210151253251.37181@root.org>
Content-Description: 
Content-Disposition: attachment; filename="geom.patch"

SW5kZXg6IHN5cy9nZW9tL2dlb21fZGV2LmMNCj09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT0NClJDUyBmaWxlOiAvaG9tZS9uY3ZzL3NyYy9zeXMvZ2VvbS9nZW9t
X2Rldi5jLHYNCnJldHJpZXZpbmcgcmV2aXNpb24gMS4yNQ0KZGlmZiAtdSAt
cjEuMjUgZ2VvbV9kZXYuYw0KLS0tIHN5cy9nZW9tL2dlb21fZGV2LmMJNyBP
Y3QgMjAwMiAwNjoyNToyNiAtMDAwMAkxLjI1DQorKysgc3lzL2dlb20vZ2Vv
bV9kZXYuYwkxNSBPY3QgMjAwMiAxMjo0NjozNSAtMDAwMA0KQEAgLTI0NSwx
NSArMjQ1LDIzIEBADQogCXN3aXRjaCAoY21kKSB7DQogCWNhc2UgRElPQ0dT
RUNUT1JTSVpFOg0KIAkJZXJyb3IgPSBnX2lvX2dldGF0dHIoIkdFT006OnNl
Y3RvcnNpemUiLCBjcCwgJmksIGRhdGEpOw0KKwkJaWYgKGVycm9yID09IDAg
JiYgKih1X2ludCAqKWRhdGEgPT0gMCkNCisJCQllcnJvciA9IEVJTlZBTDsN
CiAJCWJyZWFrOw0KIAljYXNlIERJT0NHTUVESUFTSVpFOg0KIAkJZXJyb3Ig
PSBnX2lvX2dldGF0dHIoIkdFT006Om1lZGlhc2l6ZSIsIGNwLCAmaSwgZGF0
YSk7DQorCQlpZiAoZXJyb3IgPT0gMCAmJiAqKHVfaW50ICopZGF0YSA9PSAw
KQ0KKwkJCWVycm9yID0gRUlOVkFMOw0KIAkJYnJlYWs7DQogCWNhc2UgRElP
Q0dGV1NFQ1RPUlM6DQogCQllcnJvciA9IGdfaW9fZ2V0YXR0cigiR0VPTTo6
ZndzZWN0b3JzIiwgY3AsICZpLCBkYXRhKTsNCisJCWlmIChlcnJvciA9PSAw
ICYmICoodV9pbnQgKilkYXRhID09IDApDQorCQkJZXJyb3IgPSBFSU5WQUw7
DQogCQlicmVhazsNCiAJY2FzZSBESU9DR0ZXSEVBRFM6DQogCQllcnJvciA9
IGdfaW9fZ2V0YXR0cigiR0VPTTo6ZndoZWFkcyIsIGNwLCAmaSwgZGF0YSk7
DQorCQlpZiAoZXJyb3IgPT0gMCAmJiAqKHVfaW50ICopZGF0YSA9PSAwKQ0K
KwkJCWVycm9yID0gRUlOVkFMOw0KIAkJYnJlYWs7DQogCWNhc2UgRElPQ0dG
Uk9OVFNUVUZGOg0KIAkJZXJyb3IgPSBnX2lvX2dldGF0dHIoIkdFT006OmZy
b250c3R1ZmYiLCBjcCwgJmksIGRhdGEpOw0K
--0-902143914-1034711605=:37181--

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?Pine.BSF.4.21.0210151251250.37181-200000>