what's with anonymous mapping and "MAP_ANONYMOUS"?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  i'm puzzled by something i read regarding do_mmap() and anonymous
mapping.

  as before, i'm reading love's kernel book, p. 264, which claims that
when you call do_mmap(), if the first arg (which is the struct file*
argument) is null, this is an anonymous mapping.  fair enough, that
makes perfect sense.

  but immediately afterwards, the book describes the possible page
protection flags, and includes MAP_ANONYMOUS.  does this mean you need
to specify the MAP_ANONYMOUS flag bit *in addition to* having that
initial null pointer to get an anonymous map?

  certainly, in a few places in the code, this is what's being done,
as in arch/ia64/ia32/sys_ia32.c:

  ...
  ret = do_mmap(NULL, PAGE_START(start), PAGE_SIZE, prot | PROT_WRITE,
                              flags | MAP_FIXED | MAP_ANONYMOUS, 0);
  ...

but if i read mm/mmap.c, that source file makes no reference
whatsoever to checking or setting that flag, so it doesn't seem to
care one way or the other -- all that seems to matter is if that first
pointer is NULL.

  add to that the fact that lots of code under arch checks for the
existence of that setting.  can someone explain what's happening here?
do you need to set that page protection flag or not when invoking
do_mmap()?

rday

p.s.  i'm also a bit puzzled by the fact that different architectures
define that macro differently:

include/asm-mips/mman.h:#define MAP_ANONYMOUS   0x0800          /* don't use a file */
include/asm-parisc/mman.h:#define MAP_ANONYMOUS 0x10            /* don't use a file */
include/asm-generic/mman.h:#define MAP_ANONYMOUS        0x20

  that just strikes me as kind of weird.

-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://www.fsdev.dreamhosters.com/wiki/index.php?title=Main_Page
========================================================================

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux