Print this page
12010 extra whitespace in mmap(2)

Split Close
Expand all
Collapse all
          --- old/usr/src/man/man2/mmap.2.man.txt
          +++ new/usr/src/man/man2/mmap.2.man.txt
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17         space and a file or shared memory object. The format of the call is as
  18   18         follows:
  19   19  
  20   20  
  21   21         pa = mmap(addr, len, prot, flags, fildes, off);
  22   22  
  23   23  
  24   24         The mmap() function establishes a mapping between the address space of
  25   25         the process at an address pa for len bytes to the memory object
  26   26         represented by the file descriptor fildes at offset off for len bytes.
  27      -       The value of pa is a function of the  addr argument and values of
  28      -       flags, further described below. A successful mmap() call returns pa as
  29      -       its result. The address range starting at pa and continuing for len
  30      -       bytes will be legitimate for the possible (not necessarily current)
  31      -       address space of the process. The range of bytes starting at off and
  32      -       continuing for len bytes will be legitimate for the possible (not
  33      -       necessarily current) offsets in the file or shared memory object
  34      -       represented by fildes.
       27 +       The value of pa is a function of the addr argument and values of flags,
       28 +       further described below. A successful mmap() call returns pa as its
       29 +       result. The address range starting at pa and continuing for len bytes
       30 +       will be legitimate for the possible (not necessarily current) address
       31 +       space of the process. The range of bytes starting at off and continuing
       32 +       for len bytes will be legitimate for the possible (not necessarily
       33 +       current) offsets in the file or shared memory object represented by
       34 +       fildes.
  35   35  
  36   36  
  37   37         The mmap() function allows [pa, pa + len) to extend beyond the end of
  38   38         the object both at the time of the mmap() and while the mapping
  39   39         persists, such as when the file is created prior to the mmap() call and
  40   40         has no contents, or when the file is truncated. Any reference to
  41   41         addresses beyond the end of the object, however, will result in the
  42   42         delivery of a SIGBUS or SIGSEGV signal. The mmap() function cannot be
  43   43         used to implicitly extend the length of files.
  44   44  
↓ open down ↓ 6 lines elided ↑ open up ↑
  51   51         If the size of the mapped file changes after the call to mmap() as a
  52   52         result of some other operation on the mapped file, the effect of
  53   53         references to portions of the mapped region that correspond to added or
  54   54         removed portions of the file is unspecified.
  55   55  
  56   56  
  57   57         The mmap() function is supported for regular files and shared memory
  58   58         objects. Support for any other type of file is unspecified.
  59   59  
  60   60  
  61      -       The  prot argument determines whether read, write, execute, or some
       61 +       The prot argument determines whether read, write, execute, or some
  62   62         combination of accesses are permitted to the data being mapped. The
  63   63         prot argument should be either PROT_NONE or the bitwise inclusive OR of
  64   64         one or more of the other flags in the following table, defined in the
  65   65         header <sys/mman.h>.
  66   66  
  67   67         PROT_READ
  68   68                       Data can be read.
  69   69  
  70   70  
  71   71         PROT_WRITE
↓ open down ↓ 19 lines elided ↑ open up ↑
  91   91         PROT_WRITE, and the inclusive OR of PROT_READ and PROT_WRITE. On some
  92   92         platforms, the PROT_WRITE protection option is implemented as
  93   93         PROT_READ|PROT_WRITE and PROT_EXEC as PROT_READ|PROT_EXEC. The file
  94   94         descriptor fildes is opened with read permission, regardless of the
  95   95         protection options specified.  If PROT_WRITE is specified, the
  96   96         application must have opened the file descriptor fildes with write
  97   97         permission unless MAP_PRIVATE is specified in the flags argument as
  98   98         described below.
  99   99  
 100  100  
 101      -       The  flags argument provides other information about the handling of
 102      -       the mapped data. The value of flags is the bitwise inclusive OR of
 103      -       these options, defined in <sys/mman.h>:
      101 +       The flags argument provides other information about the handling of the
      102 +       mapped data. The value of flags is the bitwise inclusive OR of these
      103 +       options, defined in <sys/mman.h>:
 104  104  
 105  105         MAP_SHARED
 106  106                          Changes are shared.
 107  107  
 108  108  
 109  109         MAP_PRIVATE
 110  110                          Changes are private.
 111  111  
 112  112  
 113  113         MAP_FIXED
↓ open down ↓ 65 lines elided ↑ open up ↑
 179  179         value of addr is taken to be a suggestion of a process address near
 180  180         which the mapping should be placed. When the system selects a value for
 181  181         pa, it will never place a mapping at address 0, nor will it replace any
 182  182         extant mapping, nor map into areas considered part of the potential
 183  183         data or stack "segments".
 184  184  
 185  185  
 186  186         When MAP_ALIGN is set, the system is informed that the alignment of pa
 187  187         must be the same as addr. The alignment value in addr must be 0 or some
 188  188         power of two multiple of page size as returned by sysconf(3C). If addr
 189      -       is 0, the system will choose a suitable  alignment.
      189 +       is 0, the system will choose a suitable alignment.
 190  190  
 191  191  
 192  192         The MAP_NORESERVE option specifies that no swap space be reserved for a
 193  193         mapping. Without this flag, the creation of a writable MAP_PRIVATE
 194  194         mapping reserves swap space equal to the size of the mapping; when the
 195  195         mapping is written into, the reserved space is employed to hold private
 196  196         copies of the data. A write into a MAP_NORESERVE mapping produces
 197      -       results which depend on the current availability of swap  space in the
 198      -       system.  If space is available, the write succeeds and a  private copy
      197 +       results which depend on the current availability of swap space in the
      198 +       system.  If space is available, the write succeeds and a private copy
 199  199         of the written page is created; if space is not available, the write
 200  200         fails and a SIGBUS or SIGSEGV signal is delivered to the writing
 201      -       process.  MAP_NORESERVE mappings are inherited across  fork(); at the
      201 +       process.  MAP_NORESERVE mappings are inherited across fork(); at the
 202  202         time of the fork(), swap space is reserved in the child for all private
 203  203         pages that currently exist in the parent; thereafter the child's
 204  204         mapping behaves as described above.
 205  205  
 206  206  
 207  207         When MAP_ANON is set in flags, and fildes is set to -1, mmap() provides
 208  208         a direct path to return anonymous pages to the caller.  This operation
 209  209         is equivalent to passing mmap() an open file descriptor on /dev/zero
 210  210         with MAP_ANON elided from the flags argument.
 211  211  
↓ open down ↓ 23 lines elided ↑ open up ↑
 235  235         mapping assignment should be limited to the first 32 bits (4 Gbytes) of
 236  236         the caller's address space.  This flag is accepted in both 32-bit and
 237  237         64-bit process models, but does not alter the mapping strategy when
 238  238         used in a 32-bit process model.
 239  239  
 240  240  
 241  241         The off argument is constrained to be aligned and sized according to
 242  242         the value returned by sysconf() when passed _SC_PAGESIZE or
 243  243         _SC_PAGE_SIZE. When MAP_FIXED is specified, the addr argument must also
 244  244         meet these constraints. The system performs mapping operations over
 245      -       whole pages. Thus, while the  len argument need not meet a size or
      245 +       whole pages. Thus, while the len argument need not meet a size or
 246  246         alignment constraint, the system will include, in any mapping
 247  247         operation, any partial page specified by the range [pa, pa + len).
 248  248  
 249  249  
 250  250         The system will always zero-fill any partial page at the end of an
 251  251         object.  Further, the system will never write out any modified portions
 252  252         of the last page of an object which are beyond its end. References to
 253  253         whole pages following the end of an object will result in the delivery
 254  254         of a SIGBUS or SIGSEGV signal. SIGBUS signals may also be delivered on
 255  255         various file system conditions, including quota exceeded errors.
↓ open down ↓ 325 lines elided ↑ open up ↑
 581  581  
 582  582         Consider the following pseudo-code:
 583  583  
 584  584           fildes = open(...)
 585  585           lseek(fildes, offset, whence)
 586  586           read(fildes, buf, len)
 587  587           /* use data in buf */
 588  588  
 589  589  
 590  590  
 591      -       The following is a rewrite using  mmap():
      591 +       The following is a rewrite using mmap():
 592  592  
 593  593           fildes = open(...)
 594  594           address = mmap((caddr_t) 0, len, (PROT_READ | PROT_WRITE),
 595  595                     MAP_PRIVATE, fildes, offset)
 596  596           /* use data at address */
 597  597  
 598  598  
 599  599  ATTRIBUTES
 600  600         See attributes(5) for descriptions of the following attributes:
 601  601  
↓ open down ↓ 9 lines elided ↑ open up ↑
 611  611         +--------------------+-------------------+
 612  612  
 613  613  SEE ALSO
 614  614         close(2), exec(2), fcntl(2), fork(2), getrlimit(2), memcntl(2),
 615  615         mmapobj(2), mprotect(2), munmap(2), shmat(2), lockf(3C), mlockall(3C),
 616  616         msync(3C), plock(3C), sysconf(3C), attributes(5), lf64(5),
 617  617         standards(5), null(7D), zero(7D)
 618  618  
 619  619  
 620  620  
 621      -                                August 29, 2016                        MMAP(2)
      621 +                               November 19, 2019                       MMAP(2)
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX