*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->Tru64 Unix man pages -> mprotect (2)              
Title
Content
Arch
Section
 

mprotect(2)

Contents


NAME    [Toc]    [Back]

       mprotect - Modify access protections of memory mapping

SYNOPSIS    [Toc]    [Back]

       #include <sys/mman.h>

       int mprotect(
               void *addr,
               size_t len,
               int prot );

       The  following  definitions  of  the addr parameter do not
       conform to current industry standards  and  are  supported
       only for backward compatibility:


               caddr_t addr,
               const void addr );

STANDARDS    [Toc]    [Back]

       Interfaces  documented  on  this reference page conform to
       industry standards as follows:

       mprotect(): XSH4.2, XSH5.0

       Refer to the standards(5) reference page for more information
 about industry standards and associated tags.

PARAMETERS    [Toc]    [Back]

       Points to the address of the region to be modified.  Specifies
 the length in bytes of the region  to  be  modified.
       Specifies  access permissions as PROT_NONE or any combination
  of  PROT_READ,  PROT_WRITE,   and   PROT_EXEC   ORed
       together.

DESCRIPTION    [Toc]    [Back]

       The  mprotect() function modifies the access protection of
       a mapped file or shared memory region. The  addr  and  len
       parameters  specify the address and length in bytes of the
       region to be modified. The len parameter must be a  multiple
     of     the    page    size    as    returned    by
       sysconf(_SC_PAGE_SIZE). If len is not a  multiple  of  the
       page  size  as  returned  by  sysconf(_SC_PAGE_SIZE),  the
       length of the region will be rounded up to the next multiple
 of the page size.

       The prot parameter specifies the new access protection for
       the region. The <sys/mman.h> header file defines the  following
 access options: The mapped region can be read.  The
       mapped region can be written.  The mapped  region  can  be
       executed.  The mapped region cannot be accessed.

       The  prot parameter can be PROT_NONE or any combination of
       PROT_READ, PROT_WRITE, and  PROT_EXEC  ORed  together.  If
       PROT_NONE  is  not  specified,  access  permissions may be
       granted to the region  in  addition  to  those  explicitly
       requested,  except  that  write access will not be granted
       unless PROT_WRITE is specified.

       If the region is a  mapped  file  which  was  mapped  with
       MAP_SHARED, the mprotect() function grants read or execute
       access permission only if the file descriptor used to  map
       the file is open for reading, and grants write access permission
 only if the file descriptor used to map  the  file
       is  open for writing. If the region is a mapped file which
       was  mapped  with  MAP_PRIVATE,  the  mprotect()  function
       grants  read,  write, or execute access permission only if
       the file descriptor used to map the file is open for reading.
  If  the  region  is a shared memory region which was
       mapped with MAP_ANONYMOUS, the mprotect() function  grants
       all requested access permissions.

       The mprotect() function does not modify the access permission
 of any region which lies  outside  of  the  specified
       region,  except  that  the effect on addresses between the
       end of the region and the end of the page  containing  the
       end of the region is unspecified.

       If  the  mprotect() function fails under a condition other
       than that specified by [EINVAL], the access protection  of
       some of the pages in the range [addr, addr + len) may have
       been changed. For example, if the  error  occurs  on  some
       page  at  addr2,  mprotect() may have modified the protections
 of all whole pages in the range [addr, addr2).

RETURN VALUES    [Toc]    [Back]

       Upon  successful  completion,  the   mprotect()   function
       returns  0  (zero).  Otherwise,  mprotect() returns -1 and
       sets errno to indicate the error.

ERRORS    [Toc]    [Back]

       The mprotect() function sets errno to the specified values
       for the following conditions:

       The  prot  parameter specifies a protection that conflicts
       with the access permission set for  the  underlying  file.
       The prot parameter specifies PROT_WRITE over a MAP_PRIVATE
       mapping and there are  insufficient  memory  resources  to
       reserve  for locking the private page.  [Tru64 UNIX]  Some
       or all of the addresses in the range starting at addr  and
       continuing  for  len  bytes are locked.  [Tru64 UNIX]  The
       range [addr, addr + len) includes an invalid address.  One
       of  the  following  conditions  was  encountered: The addr
       parameter is not a multiple of the page size  as  returned
       by sysconf(_SC_PAGE_SIZE).  [Tru64 UNIX]  The prot parameter
 is invalid.   [Tru64  UNIX]  Addresses  in  the  range
       [addr,  addr + len) are invalid for the address space of a
       process, or they specify one or more unmapped pages.

SEE ALSO    [Toc]    [Back]

      
      
       Functions: getpagesize(2), mmap(2), msync(2), sysconf(3)

       Standards: standards(5)



                                                      mprotect(2)
[ Back ]
 Similar pages
Name OS Title
mman HP-UX memory mapping definitions
mprotect IRIX set protection of memory mapping
mprotect HP-UX set or check protection of memory mapping
st_cm_add Tru64 access and modify comment section information in an object file
st_cm_start Tru64 access and modify comment section information in an object file
st_cm_setup Tru64 access and modify comment section information in an object file
st_obj_cm_setup Tru64 access and modify comment section information in an object file
st_cm_print_one Tru64 access and modify comment section information in an object file
st_cm_print Tru64 access and modify comment section information in an object file
st_cm_next Tru64 access and modify comment section information in an object file
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service