4.4BSD/usr/share/man/cat2/mmap.0

Compare this file to the similar file:
Show the results in this format:

MMAP(2)                     BSD Programmer's Manual                    MMAP(2)

NNAAMMEE
     mmmmaapp - map files or devices into memory

SSYYNNOOPPSSIISS
     ##iinncclluuddee <<ssyyss//ttyyppeess..hh>>
     ##iinncclluuddee <<ssyyss//mmmmaann..hh>>

     _c_a_d_d_r___t
     mmmmaapp(_c_a_d_d_r___t _a_d_d_r, _s_i_z_e___t _l_e_n, _i_n_t _p_r_o_t, _i_n_t _f_l_a_g_s, _i_n_t _f_d,
             _o_f_f___t _o_f_f_s_e_t);

DDEESSCCRRIIPPTTIIOONN
     The mmmmaapp function causes the pages starting at _a_d_d_r and continuing for at
     most _l_e_n bytes to be mapped from the object described by _f_d, starting at
     byte offset _o_f_f_s_e_t. If _o_f_f_s_e_t or _l_e_n is not a multiple of the pagesize,
     the mapped region may extend past the specified range.

     If _a_d_d_r is non-zero, it is used as a hint to the system.  (As a conve-
     nience to the system, the actual address of the region may differ from
     the address supplied.)  If _a_d_d_r is zero, an address will be selected by
     the system.  The actual starting address of the region is returned.  A
     successful _m_m_a_p deletes any previous mapping in the allocated address
     range.

     The protections (region accessibility) are specified in the _p_r_o_t argument
     by _o_r'ing the following values:

     PROT_EXEC   Pages may be executed.

     PROT_READ   Pages may be read.

     PROT_WRITE  Pages may be written.

     The _f_l_a_g_s parameter specifies the type of the mapped object, mapping op-
     tions and whether modifications made to the mapped copy of the page are
     private to the process or are to be shared with other references.  Shar-
     ing, mapping type and options are specified in the _f_l_a_g_s argument by
     _o_r'ing the following values:

     MAP_ANON    Map anonymous memory not associated with any specific file.
                 The file descriptor used for creating MAP_ANON regions is
                 used only for naming, and may be specified as -1 if no name
                 is associated with the region.

     MAP_FIXED   Do not permit the system to select a different address than
                 the one specified.  If the specified address cannot be used,
                 mmmmaapp will fail.  If MAP_FIXED is specified, _a_d_d_r must be a
                 multiple of the pagesize.  Use of this option is discouraged.

     MAP_HASSEMAPHORE
                 Notify the kernel that the region may contain semaphores and
                 that special handling may be necessary.

     MAP_INHERIT
                 Permit regions to be inherited across exec(2) system calls.

     MAP_PRIVATE
                 Modifications are private.

     MAP_SHARED  Modifications are shared.

     The close(2) function does not unmap pages, see munmap(2) for further in-
     formation.

     The current design does not allow a process to specify the location of
     swap space.  In the future we may define an additional mapping type,
     MAP_SWAP, in which the file descriptor argument specifies a file or de-
     vice to which swapping should be done.

RREETTUURRNN VVAALLUUEESS
     Upon successful completion, mmmmaapp returns a pointer to the mapped region.
     Otherwise, a value of -1 is returned and _e_r_r_n_o is set to indicate the er-
     ror.

EERRRROORRSS
     MMmmaapp() will fail if:

     [EACCES]      The flag PROT_READ was specified as part of the _p_r_o_t param-
                   eter and _f_d was not open for reading.  The flags
                   PROT_WRITE, MAP_SHARED and MAP_WRITE were specified as part
                   of the _f_l_a_g_s and _p_r_o_t parameters and _f_d was not open for
                   writing.

     [EBADF]       _F_d is not a valid open file descriptor.  MAP_FIXED was
                   specified and the parameter was not page aligned.  _F_d did
                   not reference a regular or character special file.

     [ENOMEM]      MAP_FIXED was specified and the _a_d_d_r parameter wasn't
                   available.  MAP_ANON was specified and insufficient memory
                   was available.

SSEEEE AALLSSOO
     getpagesize(2),  msync(2),  munmap(2),  mprotect(2),  madvise(2),  min-
     core(2)

4th Berkeley Distribution        June 4, 1993                                2