sys_map#

Low-level mapping with raw mmap(2) protection and flag constants.

Σύνοψη#

use File::Map qw(sys_map :constants);

sys_map my $map, $length, PROT_READ | PROT_WRITE,
        MAP_SHARED, $fh, 0;

sys_map my $buf, 4096, PROT_READ | PROT_WRITE,
        MAP_PRIVATE | MAP_ANONYMOUS;

Ορίσματα#

  • $lvalue - scalar to receive the mapping.

  • $length - size in bytes.

  • $protection - bitwise-or of PROT_NONE, PROT_READ, PROT_WRITE, PROT_EXEC.

  • $flags - bitwise-or of MAP_SHARED, MAP_PRIVATE, MAP_ANONYMOUS, MAP_ANON, MAP_FILE.

  • $filehandle - omitted or undef when MAP_ANONYMOUS is set.

  • $offset - byte offset into the file. Defaults to 0.

When to reach for it#

Use sys_map only when map_file, map_handle, or map_anonymous cannot express what you need - for example, to request PROT_EXEC on an executable page, or to combine flags that the convenience functions do not expose. If the mmap(2) man page does not feel familiar, map_file or map_anonymous is almost certainly the better choice.

Διαφορές από το upstream#

Fully compatible with upstream File::Map 0.71.

Δείτε επίσης#

  • map_file, map_handle, map_anonymous - the high-level alternatives.

  • protect - change protection after the mapping exists.