libclues
Linux C++ Tracing Library
Loading...
Searching...
No Matches
clues::FDInfo Struct Reference

Contextual information about a file descriptor in a Tracee. More...

#include <types.hxx>

Public Types

enum class  Type {
  INVALID , FS_PATH , EVENT_FD , TIMER_FD ,
  SIGNAL_FD , SOCKET , EPOLL , PIPE ,
  INOTIFY , PID_FD , BPF_MAP , BPF_PROG ,
  PERF_EVENT , UNKNOWN
}
 Different types of file descriptors. More...
 

Public Member Functions

 FDInfo (const Type _type, const cosmos::FileNum _fd)
 
bool valid () const
 

Public Attributes

Type type = Type::INVALID
 
cosmos::FileNum fd = cosmos::FileNum::INVALID
 the actual file descriptor number.
 
std::string path
 path to the file, if applicable
 
std::optional< cosmos::OpenMode > mode
 
std::optional< cosmos::OpenFlags > flags
 
std::optional< cosmos::Inode > inode
 inode of the file, only filled by utils::get_fd_infos().
 

Detailed Description

Contextual information about a file descriptor in a Tracee.

Todo
For a fully-fledged implementation we will likely need specialized types e.g. for sockets, carrying additional context-sensitive data.

Definition at line 75 of file types.hxx.

Member Enumeration Documentation

◆ Type

enum class clues::FDInfo::Type
strong

Different types of file descriptors.

This distinguishes file types found in /proc/<pid>/fd. These are types more from a kernel point of view, i.e. the different kernel facilities that offer file descriptors, not the types from a stat(2) point of view. Directories, regular files and device files are all of Type::FS_PATH, for example.

Enumerator
FS_PATH 

a path opened on the file system (this can still be a device special file, named pipe, directory etc.)

EVENT_FD 

created by eventfd()

TIMER_FD 

created by timerfd()

SIGNAL_FD 

created by signalfd()

SOCKET 

created by socket()

EPOLL 

an epoll() file descriptor

PIPE 

created by pipe()

INOTIFY 

created by inotify_init()

PID_FD 

created by pidfd_open(), clone(), ...

BPF_MAP 

refers to a BPF type map

BPF_PROG 

refers to a BPF program validated and loaded

Definition at line 86 of file types.hxx.

86 {
87 INVALID,
88 FS_PATH,
89 EVENT_FD,
90 TIMER_FD,
91 SIGNAL_FD,
92 SOCKET,
93 EPOLL,
94 PIPE,
95 INOTIFY,
96 PID_FD,
97 BPF_MAP,
98 BPF_PROG,
99 PERF_EVENT,
100 UNKNOWN
101 };

Constructor & Destructor Documentation

◆ FDInfo()

clues::FDInfo::FDInfo ( const Type _type,
const cosmos::FileNum _fd )
inlineexplicit

Definition at line 107 of file types.hxx.

107 :
108 type{_type}, fd{_fd} {
109 }
cosmos::FileNum fd
the actual file descriptor number.
Definition types.hxx:118

Member Function Documentation

◆ valid()

bool clues::FDInfo::valid ( ) const
inline

Definition at line 111 of file types.hxx.

111 {
112 return type != Type::INVALID;
113 }

Member Data Documentation

◆ fd

cosmos::FileNum clues::FDInfo::fd = cosmos::FileNum::INVALID

the actual file descriptor number.

Definition at line 118 of file types.hxx.

◆ flags

std::optional<cosmos::OpenFlags> clues::FDInfo::flags

Definition at line 121 of file types.hxx.

◆ inode

std::optional<cosmos::Inode> clues::FDInfo::inode

inode of the file, only filled by utils::get_fd_infos().

Definition at line 122 of file types.hxx.

◆ mode

std::optional<cosmos::OpenMode> clues::FDInfo::mode

Definition at line 120 of file types.hxx.

◆ path

std::string clues::FDInfo::path

path to the file, if applicable

Definition at line 119 of file types.hxx.

◆ type

Type clues::FDInfo::type = Type::INVALID

Definition at line 117 of file types.hxx.


The documentation for this struct was generated from the following file: