Re: problems in pread(2).

Tigran Aivazian (tigran@sco.COM)
Tue, 26 Jan 1999 07:51:22 +0000 (GMT)


http://www.opengroup.org/onlinepubs/7908799/xsh/read.html

The Single Unix v2 specs says:
The pread() function will fail, and the file pointer remains unchanged,
if:

[EOVERFLOW]
The file is a regular file and an attempt was made to read or
write at or beyond the offset maximum associated with the file.

The "offset maximum associated with the file" is the fancy way of saying
"current size of the file". Or, more precisely, (I assume) one is just
being careful in case in the future one will be able to read beyond the
end of file (e.g. to get a user-defined comments about the file, like "I
looked at this file and, behold, it was good!") but the Single UNIX v2
spec won't need modifying, just the term "offset maximum associated with
the file".

However, I think there is a typo in OpenGroup's document, where it says
"read or write" for indeed there is nothing wrong with writing beyond the
end of file, only reading is an abomination... Also, write(2)'s page does
not say that pwrite() should fail to write beyond the end of file.

Regards,
------
Tigran A. Aivazian | http://www.sco.com
Escalations Research Group | tel: +44-(0)1923-813796
Santa Cruz Operation Ltd | http://www.aivazian.demon.co.uk

On Mon, 25 Jan 1999, Itai Nahshon wrote:

> Look at <http://www.opengroup.org/onlinepubs/7908799/xsh/pread.html>.
>
> Pread should give exactly the same result as read. AFAIK read
> does (and has always) retrun 0 when trying to read at or beyond the EOF.
>
>
> The opengroup man page for read has this unclear clause about EOVERFLOW:
> [EOVERFLOW]
> The file is a regular file, nbyte is greater than 0, the
> starting position is before the end-of-file and the starting
> position is greater than or equal to the offset maximum
> established in the open file description associated with fildes.
>
> What is "open file description" (should I read descriptor ???) ?
> What is "the offset maximum established in the ..". Where does it
> exist (and how do I set it) in regular files.
>
> Notice that talks only about "regular file". This might have a meaning
> with some device files where there is no explicit EOF [lseek(fd, off, SEEK_END)
> cannot be used].
>
> Itai
>
>
> > Just to make my previous mail more concrete, the following program
> > illustrates a problem with current implementation of pread(2). Namely,
> > reading beyond the end of file should (by Single UNIX spec) set
> > errno=EOVERFLOW. Currently it returns 0, and sets errno =0 (Success),
> > whilst leaving the buffer intact.
>

-
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/