Subject: Re: wrap up of pipe(2)
To: NetBSD Userlevel Technical Discussion List <tech-userlevel@NetBSD.ORG>
From: Greg A. Woods <woods@weird.com>
List: tech-userlevel
Date: 10/15/2001 19:37:43
[ On Tuesday, October 16, 2001 at 01:14:45 (+0200), Andreas Persson wrote: ]
> Subject: Re: wrap up of pipe(2)
>
> On Mon, Oct 15, 2001 at 01:07:38PM -0400, "Greg A. Woods" <woods@weird.com> wrote:
> > Maybe it should do what read(2) and readv(2) do and return with EINVAL
> > set when the value to be returned is larger than INT_MAX?
>
> I don't think so; EINVAL indicates to me that the programmer did something
> wrong. There is nothing wrong about trying to find out how much data you
> can read.
I agree that EINVAL is overloaded with diverse meanings.
However I don't see any other more appropriate error code, and read()
has already set the precedent for using this error for a very similar
purpose.
While it might be a nice project to eliminate all the overloaded uses of
errno codes that's a separate (and potentially standards breaking) issue
and in the mean time I don't see any problem with adding another
overloaded usage, especially not one with precedent elsewhere.
> I don't see a good solution to this problem...
Simply define a new ioctl() command with a new, larger piece of storage
required to return the value in.
In the mean time those places where FIONREAD's returned value can
overflow INT_MAX should probably immediately be fixed to cause the
ioctl() to fail with errno set to EINVAL since that's going to be the
better of all the poor ways to handle the situation.
--
Greg A. Woods
+1 416 218-0098 VE3TCP <gwoods@acm.org> <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>