Chapter Contents

Previous

Next
mprotect

mprotect



Change Protection of Memory Mapped to a File

Portability: UNIX compatible


SYNOPSIS
DESCRIPTION
RETURN VALUE
USAGE NOTES
EXAMPLE
RELATED FUNCTIONS


SYNOPSIS

#include <mman.h>
int mprotect(void *addr, 
             unsigned int len, 
             int prot);


DESCRIPTION

The mprotect function is used to change the protection status of one or more pages of memory mapped to an HFS file by a previous call to the mmap function.

The addr argument is the address of the first page of mapped memory for which the protection attributes are to be changed. The address must be on a page boundary, but need not be the first byte of the entire area mapped to a file.

The len argument specifies the number of bytes of memory whose protection attributes are to be changed. If the length does not specify an integral number of pages, it is rounded up to do so. The length need not specify the entire area of mapped memory.

The prot argument specifies the new protection status of the mapped memory. It should be specified as one of the symbolic constants described in the mmap function write-up.

You cannot specify PROT_WRITE if the file descriptor for the file does not permit writing.

Note:   See the IBM UNIX System Services Assembler Callable Services manual for additional information about the behavior of mprotect and the conditions under which it can be used.  [cautionend]


RETURN VALUE

mprotect returns 0 if successful, or -1 if unsuccessful.


USAGE NOTES

The mprotect function can only be used with MVS 5.2.2 or a later release.


EXAMPLE

Refer to mmap for an example.


RELATED FUNCTIONS

mmap , msync , munmap


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.