This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: apparent bug: incorrect file position after write()


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]