MAP_ANON replacement?

Hans Werner Strube strube at physik3.gwdg.de
Wed Jun 26 22:08:33 EST 2002


Here I would like to suggest a replacement for MAP_ANON on systems which
do not have it, such as Solaris < 8. In "man mmap" of Solaris 8:
     When MAP_ANON is set in flags, and fd is set to  -1,  mmap()
     provides  a  direct  path  to  return anonymous pages to the
     caller.  This operation is equivalent to passing  mmap()  an
     open  file descriptor on /dev/zero with MAP_ANON elided from
     the flags argument.
Thus, I suppose in monitor_mm.c (of 3.3p1), the lines 88-89
	address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_ANON|MAP_SHARED,
	    -1, 0);
could be replaced by
	{
	    static int mmfd = -1;
	    if(mmfd < 0)
		mmfd = open("/dev/zero", O_RDWR);
	    address = mmap(NULL, size, PROT_WRITE|PROT_READ, MAP_SHARED,
		mmfd, 0);
	}
Sorry, I have *not* tested it since I am running 3.1p1 and waiting for 3.4p1
announced for next week!

 Hans Werner Strube          strube at physik3.gwdg.de
 Drittes Physikalisches Institut,  Univ. Goettingen
 Buergerstr. 42-44,    37073 Goettingen,    Germany



More information about the openssh-unix-dev mailing list