libcamera  v0.3.1+12-19bbca3c
Supporting cameras in Linux since 2019
Public Types | Static Public Member Functions | List of all members
libcamera::MemFd Class Reference

Helper class to create anonymous files. More...

Public Types

enum  Seal { None = 0, Shrink = (1 << 0), Grow = (1 << 1) }
 Seals for the MemFd::create() function.
 
using Seals = Flags< Seal >
 A bitwise combination of MemFd::Seal values.
 

Static Public Member Functions

static UniqueFD create (const char *name, std::size_t size, Seals seals=Seal::None)
 Create an anonymous file. More...
 

Detailed Description

Helper class to create anonymous files.

Anonymous files behave like regular files, and can be modified, truncated, memory-mapped and so on. Unlike regular files, they however live in RAM and don't have permanent backing storage.

Member Function Documentation

◆ create()

UniqueFD libcamera::MemFd::create ( const char *  name,
std::size_t  size,
Seals  seals = Seal::None 
)
static

Create an anonymous file.

Parameters
[in]nameThe file name (displayed in symbolic links in /proc/self/fd/)
[in]sizeThe file size
[in]sealsThe file seals

This function is a helper that wraps anonymous file (memfd) creation and sets the file size and optional seals.

Returns
The descriptor of the anonymous file if creation succeeded, or an invalid UniqueFD otherwise

The documentation for this class was generated from the following files: