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.