This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: apparent bug: incorrect file position after write()
- From: Brian Dessent <brian at dessent dot net>
- To: cygwin at cygwin dot com
- Date: Sat, 05 Mar 2005 01:28:00 -0800
- Subject: Re: apparent bug: incorrect file position after write()
- Organization: My own little world...
- References: <20050305090651.B2AB31CE32B@ws1-6.us4.outblaze.com>
- Reply-to: cygwin at cygwin dot com
"imaginate australiamail.com" wrote:
>
> I'm experiencing unexpected behaviour under cygwin that as far as I
> know doesn't happen under linux. I don't have access to linux to
> test at present.
>
> Some successful write()s to a file increment the file's position by
> more than the count argument. The extra byte(s) are added to the
> file's size and can be read by lseek()ing to the exact location
> where the extra byte(s) start. When reading from a location prior
> to this location the extra byte(s) become invisible although they
> can affect the values returned from read() and lseek().
You have textmode mounts. You write a single \n to the file as part of
your loop, "for (buf = 0; buf < LOOPMAX; buf++)". Two bytes (\r\n) are
actually written. That's the entire point of textmode mounts, to
silently translate \n into \r\n on write and the reverse on read. If
you don't want that, then don't use textmode mounts.
Brian
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/