MAP_ANON replacement?

Ben Lindstrom mouring at etoh.eviladmin.org
Thu Jun 27 00:06:59 EST 2002


This is one of the things on our list.  This seems to work for Solaris,
but fails for Linux 2.2 and maybe Linux 2.0.  Hopefully post 3.4p1 we can
get back and resolve this problem since we will not be trying to cram 10
CVS patches into the tree a minute.=)

- Ben

On Wed, 26 Jun 2002, Hans Werner Strube wrote:

> 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
> _______________________________________________
> openssh-unix-dev at mindrot.org mailing list
> http://www.mindrot.org/mailman/listinfo/openssh-unix-dev
>




More information about the openssh-unix-dev mailing list