Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Oct 2002 21:36:42 +0200
From:      Poul-Henning Kamp <phk@critter.freebsd.dk>
To:        Nate Lawson <nate@root.org>
Cc:        current@freebsd.org
Subject:   Re: GEOM/fdisk/USB drive problem 
Message-ID:  <31480.1034710602@critter.freebsd.dk>
In-Reply-To: Your message of "Tue, 15 Oct 2002 12:29:26 PDT." <Pine.BSF.4.21.0210151222400.36779-100000@root.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
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.

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.

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