carta
lc_mmapfile(3)

lc_mmapfile3

Map or unmap files or devices into memory

Usage

Compile and link with -llibrecast.

Library

Librecast library (liblibrecast, -llibrecast)

Overview

The lc_mmapfile() function is a convenience wrapper for mmap(2) which open(2)s and maps a file in a single call. See mmap(2) for a full description.

If prot has the PROT_WRITE flag set, pathname is open(2)'ed with the O_RDWR and O_CREAT flags set (the file is created and opened read-write), otherwise it is opened O_RDONLY. The mode for the created file can be set by setting st_mode in sb when calling lc_mmapfile().

If len points to a value greater than zero, ftruncate(2) is called to truncate the file to the specified length. Otherwise, the variable len points to is set to the size of the file.

When done, the file can be unmapped and the memory freed by calling munmap(3).

Return value

On success, lc_mmapfile() returns a pointer to the mapped area. On error, the value MAP_FAILED (that is, (void*)-1 ) is returned, and errno is set to indicate the error.

Errors

ENODATA

File is zero length.

See also open(2), mmap(2), fstat(2), and ftruncate(2).

From liblibrecast-dev 0.9.1-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.