Subject: Re: loaning for read() of regular files
To: Jason Thorpe <thorpej@shagadelic.org>
From: Chuck Silvers <chuq@chuq.com>
List: tech-kern
Date: 02/16/2005 09:15:17
On Wed, Feb 16, 2005 at 09:05:55AM -0800, Jason Thorpe wrote:
> 
> On Feb 16, 2005, at 6:57 AM, Chuck Silvers wrote:
> 
> >/* This provides functionality somewhat similar to mmap() but using 
> >read().
> > * It gives sliding window access to a file.  mmap() is not used 
> >because of
> > * the possibility of another program (such as a mailer) truncating the
> > * file thus giving us a SIGBUS. */
> >
> >so they were just being a bit lazy.
> 
> Not only are they lazy, on NetBSD that simply isn't true.  I wrote a 
> test case for this after discussing it with Luke Mewburn, who in turn 
> had discussed this very issue with the rsync/samba guys.  As far as I 
> can tell, they're working around a bug in Linux.

last I checked, linux had different behaviour that other systems in this area.
linux would allow accessing mappings of a file past EOF, and it would return
zeroed pages in this case.  I'm not sure what happened to modified data in
those page when they were paged out, I would guess that either the file's
size was increased or the data was thrown away.

solaris and the BSDs do not allow access to a file past EOF via mappings,
they generate signals (SIGBUS or SIGSEGV, depending on the implementation).

so while linux's behaviour was different, it's the non-linux behaviour
that I would have thought was what rsync was concerned about.  does linux
still work the way that I described?  could you post the test program
mentioned above?

-Chuck