libcamera: libcamera::MemFd Class Reference

libcamera v0.7.1 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
libcamera::MemFd Class Reference

Helper class to create anonymous files. More...

## Public Types
enum class | Seal { None = 0 , Shrink = (1 << 0) , Grow = (1 << 1) }
| Seals for the MemFd::create() function. More...
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.

## 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 Enumeration Documentation

## ◆ Seal

enum class libcamera::MemFd::Seal
| strong

Seals for the MemFd::create() function.

Enumerator
None | No seals (used as default value).
Shrink | Prevent the memfd from shrinking.
Grow | Prevent the memfd from growing.

## 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] | name | The file name (displayed in symbolic links in /proc/self/fd/)
  [in] | size | The file size
  [in] | seals | The 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:

- include/libcamera/base/memfd.h
- src/libcamera/base/memfd.cpp