⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mprotect.2

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 2
字号:
.\" SCCSID: @(#)mprotect.2	8.1	9/11/90.TH mprotect 2.\" Created by depp -- 14 Mar 86.\".SH Namemprotect \- memory protection control.SH Syntax.nf.ft B#include <sys/mman.h>#include <sys/types.h>.PP.ft Bint mprotect (addr, len, prot)caddr_t addr;int len, prot;.fi.SH Description.NXR "mprotect system call".NXR "data memory" "changing protection"The.PN mprotectsystem callchanges the protection of portions ofan application program's data memory.Protection is performed on page cluster boundaries.The default protection for data memory on process invocation is userREAD/WRITE.The.I addrargument is the beginning addressof the data block and must fall on a page clusterboundary..PPThe .I lenargument is the length of the data block, in bytes.The length of the block is rounded up to a cluster boundary, and the size of the block to be protected is returned..PPThe.I protargument is the requested protection for the block of memory.Protection values affect only the user process.Protection values are defined in <mman.h> as:.EX 0/* protections are chosen from these bits, ORed together */#define PROT_READ       0x1     /* pages can be read */#define PROT_WRITE      0x2     /* pages can be written */#define PROT_EXEC       0x4     /* pages can be executed */.EESetting the.I protargument to zero (0)indicates that the process cannot reference the memoryblock, without causing a fault..PPA protected page faults if the protection is violated, and a SIGBUSsignal is issued.If the process has a handler defined for the SIGBUS signal, the .I codeparameter, described in .MS sigvec 2and.MS signal 3 ,is used to pass in the virtual address that faulted..SH RestrictionsThe page cluster size may change in future versions of ULTRIX. As a result, .PN getpagesize should be used to determine the correct.I lenargument, and .PN sbrk or.PN malloc should be used to determine the correct.I addrargument..PPIf the user handles a SIGBUS signal, the signal handler must eitherabort the process or correct the condition that caused the protection fault (SIGBUS).If some corrective action is not taken, an infinite loop resultsbecause the faulting instruction is restarted.If the user permits the default SIGBUS handler to be used, the processaborts if a referenced page causes a fault..PPThe VAX architecture makes the following implications;PROT_WRITE implies(PROT_WRITE | PROT_READ | PROT_EXEC), and PROT_READ implies(PROT_READ | PROT_EXEC)..PPOnly the application can change the .PN mprotectcall's private data space.  This means that attempts to change text, shared memory, or stack space causes a EACCES failure..SH Return ValuesUpon successful completion,the size of the protected memory block, in bytes,is returned.Otherwise, a value of \-1 is returned and .I errnois set to indicate the error..SH DiagnosticsThe.PN mprotectcall fails under the following conditions:.TP 15[EALIGN]The.I addrargument is not on a cluster boundary..TP 15[EINVAL]The.I protargument is not a valid protection mask..TP 15[EACCES]The memory block is not fully contained within private data space..SH See Alsogetpagesize(2), sbrk(2), sigvec(2), malloc(3), signal(3)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -