protect#
Change the read/write/execute protection of a mapped region.
תקציר#
protect $map, '<'; # read-only
protect $map, '+<'; # read/write
protect $map, PROT_READ; # constants also work
ארגומנטים#
$lvalue- a currently mapped scalar.$mode- either a string in the same format asopen('<','+<','>','+>'), or a bitmask built from thePROT_*constants.
If the new protection includes write permission the scalar becomes writable; otherwise it is marked read-only and direct assignment raises an exception.
דוגמאות#
Load a file read/write, patch it, then lock it down:
map_file my $map, 'data.bin', '+<';
substr $map, 0, 4, "HEAD";
sync $map;
protect $map, '<'; # prevent further writes
מקרי קצה#
Protecting an unmapped scalar raises an exception.
Protecting an empty mapping updates the scalar’s read-only flag but performs no kernel call.
הבדלים מן ה-upstream#
Fully compatible with upstream File::Map 0.71.
ראו גם#
sys_map- set protection when creating the mapping.advise- hint access patterns rather than enforce permissions.