#include <metal/utilities.h>
#include <metal/sys.h>
|
int | metal_open (const char *path, int shm) |
| Open (or create) a file.
|
|
int | metal_map (int fd, off_t offset, size_t size, int expand, int flags, void **result) |
| Map a segment of a file/device.
|
|
int | metal_unmap (void *mem, size_t size) |
| Unmap a segment of the process address space.
|
|
◆ metal_map()
int metal_map |
( |
int | fd, |
|
|
off_t | offset, |
|
|
size_t | size, |
|
|
int | expand, |
|
|
int | flags, |
|
|
void ** | result ) |
Map a segment of a file/device.
This function maps a segment of a file or device into the process address space, after optionally expanding the file if necessary. If required, the file is expanded to hold the requested map area. This is done under and advisory lock, and therefore the called must not have an advisory lock on the file being mmapped.
- Parameters
-
[in] | fd | File descriptor to map. |
[in] | offset | Offset in file to map. |
[in] | size | Size of region to map. |
[in] | expand | Allow file expansion via ftruncate if non-zero. |
[in] | flags | Flags for mmap(), MAP_SHARED included implicitly. |
[out] | result | Returned pointer to new memory map. |
- Returns
- 0 on success, or -errno on error.
◆ metal_open()
int metal_open |
( |
const char * | path, |
|
|
int | shm ) |
Open (or create) a file.
This function opens or creates a file with read/write permissions and the O_CLOEXEC flag set.
- Parameters
-
[in] | path | File path to open. |
[in] | shm | Open shared memory (via shm_open) if non-zero. |
- Returns
- File descriptor.
◆ metal_unmap()
int metal_unmap |
( |
void * | mem, |
|
|
size_t | size ) |
Unmap a segment of the process address space.
This function unmaps a segment of the process address space.
- Parameters
-
[in] | mem | Segment to unmap. |
[in] | size | Size of region to unmap. |
- Returns
- 0 on success, or -errno on error.