Re: EFAULT (was: Re: bug in write(2) system call)

David Holland (dholland@cs.toronto.edu)
Tue, 20 Oct 1998 15:13:59 -0400


> >Hmm. The POSIX description of EFAULT is:
>
> >>[EFAULT]: Bad address
> >> The system detected an invalid address in attempting to use
> >> an argument of a call. The reliable detection of this error
> >> is implementation defined; however, implementations that do
> >> detect this condition shall use this value.
>
> This SysV errno value seems unnecessarily ambiguous. One would presume
> that EFAULT would be reserved for kernel internal use and EINVAL would be
> returned to user space when the page fault cannot be resolved by the
> kernel (it's not a swap, cache, or discarded page EFAULT, it's really an
> invalid address request).
>
> Just because Posix supports the old SysV silliness doesn't mean we can't
> set the more accurate errno value from within functions like write(2) that
> also support EINVAL in the Posix and Single Unix Spec standards.

Eh? EFAULT is a specific subset of "invalid value", and is therefore
*more* accurate.

Besides, as far as I'm concerned, passing (void *)0x1 to write() and
to fwrite() should have the same result - signal 11.

> It should return EINVAL for them (imho). Portable code tests for both
> of course, but why can't we set errno to the more sensible value?

What exactly is more sensible about it?

-- 
   - David A. Holland             | (please continue to send non-list mail to
     dholland@cs.utoronto.ca      | dholland@hcs.harvard.edu. yes, I moved.)

Any netkit mail should be sent to netbug@ftp.uk.linux.org, not me.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/