This is the mail archive of the
mailing list for the Cygwin project.
Re: mmap and MAP_FIXED
On Feb 25 06:35, Eric Blake wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> According to Corinna Vinschen on 2/25/2005 5:00 AM:
> > The reason that MAP_FAILED only works on 64K boundaries so far is,
> > that I didn't handle this case. Usually there are not many good
> > reasons to use MAP_FIXED. However, I've checked in a patch which
> > tries to handle MAP_FIXED on 4K boundaries, but only in the anonymous
> > case.
> While you are at it, POSIX requires an update to underlying file's ctime
> sometime between mmap(... MAP_SHARED, PROT_WRITE ...) and the
> corresponding munmap() or msync() if the mapped region was written to. If
> Windows correctly updates mtime on a mapped file, then one possible way to
> do this might be: when munmap()ing, if mtime is newer than ctime (but less
> than or equal to now), adjust ctime to match mtime.
Well... no, not now. That's more tricky than you think. If you have
an open mmap to a file, there's not necessarily also an open file
descriptor available. This is perfectly fine:
fd = open ("foo", O_RDWR);
addr = mmap (NULL, getpagesize (), PROT_WRITE, MAP_SHARED, fd, 0);
*addr = 'x';
munmap (addr, getpagesize ());
The problem is that right now the mmap records don't keep track of the
file name, nor do they keep a file handle open since that was never
necessary for the mmap/munmap functionality. Adding this just for the
sake of setting st_ctime makes the code rather more complicated than
it already is. I have to think about this a while.
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader mailto:firstname.lastname@example.org
Red Hat, Inc.
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html