libcosmos
Linux C++ System Programming Library
|
A specialized FileDescriptor for directory objects. More...
#include <DirFD.hxx>
Public Member Functions | |
constexpr | DirFD (FileNum fd=FileNum::INVALID) |
![]() | |
constexpr | FileDescriptor (FileNum fd) |
bool | valid () const |
Returns whether currently a valid file descriptor number is assigned. | |
bool | invalid () const |
void | setFD (const FileNum fd) |
Assigns a new primitive file descriptor to the object. | |
void | reset () |
Invalidates the stored file descriptor. | |
void | close () |
Explicitly close the contained FD. | |
void | duplicate (const FileDescriptor new_fd, const CloseOnExec cloexec=CloseOnExec{true}) const |
Get a duplicate file descriptor that will further be known as new_fd. | |
FileDescriptor | duplicate (const FileNum lowest=FileNum{0}, const CloseOnExec cloexec=CloseOnExec{true}) const |
Get a duplicate file descriptor using the lowest available free file descriptor number. | |
DescFlags | getFlags () const |
Retrieves the current file descriptor flags. | |
void | setFlags (const DescFlags flags) |
Changes the current file descriptor flags. | |
void | setCloseOnExec (bool on_off) |
convenience wrapper around setFlags to change CLOEXEC setting | |
std::tuple< OpenMode, OpenFlags > | getStatusFlags () const |
Retrieve the file's OpenMode and current OpenFlags. | |
void | setStatusFlags (const OpenFlags flags) |
Change certain file descriptor status flags. | |
void | sync () |
Flush oustanding writes to disk. | |
void | dataSync () |
Flush outstanding writes to disk except metadata. | |
void | addSeals (const SealFlags flags) |
Add a seal for memory file descriptors. | |
SealFlags | getSeals () const |
Get the currently set SealFlags for the file descriptor. | |
int | getPipeSize () const |
For pipe file descriptors return the size of the pipe buffer in the kernel. | |
int | setPipeSize (const int new_size) |
For pipe file descriptors this sets a new size for the pipe buffer in the kernel. | |
FileNum | raw () const |
Returns the primitive file descriptor contained in the object. | |
bool | operator== (const FileDescriptor &other) const |
bool | operator!= (const FileDescriptor &other) const |
bool | getLock (FileLock &lock) const |
Check lock availability for traditional process-wide POSIX locks. | |
bool | setLock (const FileLock &lock) const |
Release, or attempt to obtain, a traditional process-wide POSIX lock. | |
void | setLockWait (const FileLock &lock) const |
Blocking version of setLock(). | |
bool | getOFDLock (FileLock &lock) const |
Just like getLock() but using open-file-description locks. | |
bool | setOFDLock (const FileLock &lock) const |
Just like setLock() but using open-file-description locks. | |
void | setOFDLockWait (const FileLock &lock) const |
Just like setLockWait() but using open-file-description locks. | |
void | getOwner (Owner &owner) const |
Returns the current file descriptor owner settings. | |
void | setOwner (const Owner owner) |
Change the current file descriptor owner settings. | |
std::optional< Signal > | getSignal () const |
Returns the currently configured signal for asynchronous I/O. | |
void | setSignal (std::optional< Signal > sig) |
Configure the signal to be used for asynchronous I/O. | |
LeaseType | getLease () const |
Gets the lease type currently set, or required to resolve a lease break. | |
void | setLease (const LeaseType lease) |
Sets a new lease type on the file descriptor. | |
Additional Inherited Members | |
![]() | |
enum class | DescFlag : int { NONE = 0 , CLOEXEC = FD_CLOEXEC } |
Configurable per file-descriptors flags. More... | |
enum class | SealFlag : unsigned int { SEAL = F_SEAL_SEAL , SHRINK = F_SEAL_SHRINK , GROW = F_SEAL_GROW , WRITE = F_SEAL_WRITE , FUTURE_WRITE = F_SEAL_FUTURE_WRITE } |
Flags used in addSeals(). More... | |
enum class | LeaseType : int { READ = F_RDLCK , WRITE = F_WRLCK , UNLOCK = F_UNLCK } |
Different request types for managing file leases. More... | |
using | DescFlags = BitMask<DescFlag> |
Collection of OpenFlag used for opening files. | |
using | SealFlags = BitMask<SealFlag> |
Collection flags for applying seals in addSeals(). | |
![]() | |
int | fcntl (int cmd) const |
template<typename T > | |
int | fcntl (int cmd, T val) const |
![]() | |
FileNum | m_fd = FileNum::INVALID |
A specialized FileDescriptor for directory objects.
A file descriptor representing a directory node on the file system. These are needed in a number of situation like using the *at() file system calls to operate relative to a directory. Therefore it makes sense to have a dedicated strong type for this to avoid mixups.
|
inlineexplicitconstexpr |