delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/02/25/10:21:07

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Fri, 25 Feb 2005 16:18:01 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: mmap and MAP_FIXED
Message-ID: <20050225151801.GT18314@cygbert.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <421E60A0 DOT 8000102 AT stambulchik DOT net> <20050225120045 DOT GO18314 AT cygbert DOT vinschen DOT de> <421F2987 DOT 3090307 AT byu DOT net>
Mime-Version: 1.0
In-Reply-To: <421F2987.3090307@byu.net>
User-Agent: Mutt/1.4.2i

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);
  close (fd);
  *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

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          mailto:cygwin AT cygwin DOT com
Red Hat, Inc.

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019