* Joshua Rosen <[EMAIL PROTECTED]> [010105 09:31] wrote:
>
> Alfred Perlstein writes:
>
> > So in Linux, if you have a "a+" file, you can
> > 1) seek somewhere (mid file)
> > 2) read some data (not until EOF)
> > 3) after the read you are at EOF again?
> >
> > this doesn't sound really intuative.
>
> No, it doesn't sound intuitive; luckily, that isn't what happens;)
> The issue concerns where the position is after a write (and where ftell
> reports it as being).
>
> Under glibc on Linux, you can:
> 1) fseek somewhere (non-EOF)
> 2) fwrite some data
> 3) after the *write*, you are at EOF again (ftell reports this, and any
> attempted fread, at this point, will hit EOF. any fseek, after a write,
> using SEEK_CUR will seek relative to EOF, also)
>
> I guess that the idea is, `bytes are read/written starting at the current
> position in the file', and, in order to do this in a system which always
> writes after EOF in append-mode, the current position must be changed
> before writing....
>
> my findings, under FreeBSD 4.2-STABLE, are
> 1) fseek somewhere (non-EOF, say 4 in a 50-byte-long file)
> 2) fwrite some data (say 3 bytes)
> 3) after the fwrite, ftell will report N + the last value pass'd to fseek
> (using our example numbers: 7), and fseek with SEEK_CUR will seek relative
> to that point, but fread will immediately hit EOF, and a ftell (or feof)
> after an attempted read will indicate that the position *is* EOF.
>
> Chris' findings (I believe) are that, under FreeBSD 4.2-STABLE, if you use
> fread before fwrite (say, step `1.1'), it acts just like it does with
> glibc/Linux.
Can you do a bit more research and let me know if this happens
when using open/read/write/lseek as well?
--
-Alfred Perlstein - [[EMAIL PROTECTED]|[EMAIL PROTECTED]]
"I have the heart of a child; I keep it in a jar on my desk."
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message