HP-UX Reference (11i v2 07/12) - 2 System Calls (vol 5)
m
mvalid(2) mvalid(2)
NAME
mvalid() - check memory region for validity
SYNOPSIS
#include <sys/types.h>
#include <sys/mman.h>
int mvalid(
caddr_t
addr,
size_t
len,
int
prot
);
Parameters
addr The address of the region whose validity is to be checked.
len The length in bytes of the region specified by the addr parameter.
prot The desired access protection for the region.
DESCRIPTION
To use this function, compile with the option
-I/usr/include/ep
and link in the libcext library by
specifying
-lcext, for example:
cc -I/usr/include/ep [flag]... cfile[...] -lcext [...]
The mvalid() function checks the validity of a memory region. A region is considered to be valid if
accesses of the requested type are allowed to all addresses in the region.
The <sys/mman.h> header file defines the following access options:
PROT_READ The mapped region can be read.
PROT_WRITE The mapped region can be written.
PROT_EXEC The mapped region can be executed.
The prot parameter can be any combination of PROT_READ, PROT_WRITE, and PROT_EXEC, ORed
together.
RETURN VALUES
The
mvalid() function returns:
0 Success. Accesses requiring the specified protection are allowed to all addresses within the
specified range of addresses.
-1 Failure. errno is set to indicate the error.
ERRORS
If the mvalid() function fails, errno may be set to one of the following values:
[EACCES] The range specified by (addr, addr+len) is invalid for the process’s address space, or the
range specifies one or more unmapped pages, or one or more pages of the range disallows
accesses of the specified protection.
[EINVAL] The prot parameter is invalid, or the addr parameter is not a multiple of the page size as
returned by
sysconf(_SC_PAGE_SIZE).
[ENOMEM] The range specified by (addr, addr+len) is invalid for the process’s address space, or the
range specifies one or more unmapped pages.
WARNINGS
Users of mvalid() should note that the libcext library will not be available in future releases of HP-
UX. However this function will be available as part of the C library libc.
AUTHOR
mvalid() was developed by HP.
236 Hewlett-Packard Company − 1 − HP-UX 11i Version 2: December 2007 Update