2#include <clues/logger.hxx>
3#include <clues/syscalls/fs.hxx>
4#include <clues/Tracee.hxx>
42 auto setExtraParameter = [
this](
auto &extra_par) {
43 addParameters(extra_par);
45 auto setNewReturnItem = [
this](
auto &new_ret) {
51 switch (operation.operation()) {
52 case Oper::DUPFD: [[fallthrough]];
53 case Oper::DUPFD_CLOEXEC: {
55 "lowest_fd",
"lowest dup file descriptor number"});
57 "dupfd",
"duplicated file descriptor"});
77 }
case Oper::SETLK: [[fallthrough]];
78 case Oper::SETLKW: [[fallthrough]];
79 case Oper::GETLK: [[fallthrough]];
80 case Oper::SETLK64: [[fallthrough]];
81 case Oper::SETLKW64: [[fallthrough]];
82 case Oper::GETLK64: [[fallthrough]];
83 case Oper::OFD_SETLK: [[fallthrough]];
84 case Oper::OFD_SETLKW: [[fallthrough]];
85 case Oper::OFD_GETLK: {
93 }
case Oper::GETOWN: {
97 }
case Oper::SETOWN: {
101 }
case Oper::GETOWN_EX: {
105 }
case Oper::SETOWN_EX: {
109 }
case Oper::GETSIG: {
113 }
case Oper::SETSIG: {
117 }
case Oper::GETLEASE: {
121 }
case Oper::SETLEASE: {
125 }
case Oper::NOTIFY: {
129 }
case Oper::SETPIPE_SZ: {
130 pipe_size_arg.emplace(item::IntValue{
"pipe size",
"pipe buffer size"});
136 }
case Oper::GETPIPE_SZ: {
140 }
case Oper::ADD_SEALS: {
144 }
case Oper::GET_SEALS: {
148 }
case Oper::GET_RW_HINT: [[fallthrough]];
149 case Oper::GET_FILE_RW_HINT: {
153 }
case Oper::SET_RW_HINT: [[fallthrough]];
154 case Oper::SET_FILE_RW_HINT: {
170 if (cosmos::in_list(operation.operation(), {DUPFD, DUPFD_CLOEXEC})) {
172 if (
auto it = info_map.find(fd.fd()); it != info_map.end()) {
173 auto info = it->second;
175 trackFD(proc, std::move(info));
177 LOG_WARN(
"[" << cosmos::to_integral(proc.pid()) <<
"]"
178 <<
"Couldn't find dup source FD "
179 << cosmos::to_integral(fd.fd())
192 using enum cosmos::OpenFlag;
194 if (
const auto _flags = flags.flags(); _flags[CREATE] || _flags[TMPFILE]) {
196 addParameters(*mode);
205 info.
path = filename.str();
206 info.mode = flags.mode();
207 info.flags = flags.flags();
208 trackFD(proc, std::move(info));
217 using enum cosmos::OpenFlag;
219 if (
const auto _flags = flags.flags(); _flags[CREATE] || _flags[TMPFILE]) {
221 addParameters(*mode);
230 info.
path = filename.str();
231 info.mode = flags.mode();
232 info.flags = flags.flags();
233 trackFD(proc, std::move(info));
237 dropFD(proc, fd.fd());
void setReturnItem(SystemCallItem &ret)
Sets the return value system call item.
ParameterVector m_pars
The array of system call parameters, if any.
Base class for traced processes.
const FDInfoMap & fdInfoMap() const
Provides access to the current knowledge about file descriptors in the tracee.
The value used with F_NOTIFY fcntl() operations.
The structure used with the F_GETOWN_EX and F_SETOWN_EX fcntl() operations.
Corresponds to struct flock Used with fcntl() F_*LK operations.
Oper
All possible arguments for the op parameter to fcntl(2).
The value used with the F_GETOWN and F_SETOWN fcntl() operations.
Base class for file descriptor system call items.
File access mode passed e.g. to open(), chmod().
The enum value used with file seal operations in the fcntl() system call.
The value used with F_GETLEASE and F_SETLEASE fcntl() operations.
The flags passed to calls like open().
The read/write hint value used with R/W hint operations in the fcntl() system call.
A signal number specification.
An always-success return value.
@ PARAM_OUT
An output parameter filled by in by the system call.
@ PARAM_IN
An input parameter to the system call.
@ RETVAL
A system call return value.
void updateFDTracking(const Tracee &) override
Update file descriptor tracking.
Contextual information about a file descriptor in a Tracee.
@ FS_PATH
a path opened on the file system (this can still be a device special file, named pipe,...
std::string path
path to the file, if applicable
std::optional< item::FileDescriptor > dup_lowest
for DUPFD, DUPFD_CLOEXEC
std::optional< item::IntValue > pipe_size_arg
for SETPIPE_SZ
bool check2ndPass(const Tracee &) override
Check whether a second pass needs to be made processing parameters.
std::optional< item::OpenFlagsValue > ret_status_flags
for GETFL
std::optional< item::FileDescFlagsValue > ret_fd_flags
for GETFD
std::optional< item::FileDescFlagsValue > fd_flags_arg
for SETFD
void prepareNewSystemCall() override
Perform any necessary actions before processing a new system call entry event.
std::optional< item::SuccessResult > result
for all other cases
std::optional< item::FileDescOwner > owner_arg
for SETOWN
std::optional< item::LeaseType > ret_lease
for GETLEASE
std::optional< item::IntValue > ret_pipe_size
for GETPIPE_SZ, SETPIPE_SZ
std::optional< item::FileDescriptor > ret_dupfd
for DUPFD, DUPFD_CLOEXEC
std::optional< item::ReadWriteHint > rw_hint_arg
for {GET,SET}_[FILE]_RW_HINT
std::optional< item::FLockParameter > flock_arg
for F_SETLK, F_SETLKW, F_GETLK
std::optional< item::FileDescOwner > ret_owner
for GET_OWNER
std::optional< item::DNotifySettings > dnotify_arg
for NOTIFY
std::optional< item::FileSealSettings > file_seals_arg
for ADD_SEALS
std::optional< item::SignalNumber > io_signal_arg
for SETSIG
std::optional< item::SignalNumber > ret_io_signal
for GETSIG
std::optional< item::FileSealSettings > ret_seals
for GET_SEALS
void updateFDTracking(const Tracee &proc) override
Update file descriptor tracking.
std::optional< item::ExtFileDescOwner > ext_owner_arg
for SETOWN_EX, GETOWN_EX
std::optional< item::OpenFlagsValue > status_flags_arg
for SETFL
std::optional< item::LeaseType > lease_arg
for SETLEASE
bool check2ndPass(const Tracee &) override
Check whether a second pass needs to be made processing parameters.
void updateFDTracking(const Tracee &) override
Update file descriptor tracking.
void prepareNewSystemCall() override
Perform any necessary actions before processing a new system call entry event.
void updateFDTracking(const Tracee &) override
Update file descriptor tracking.
bool check2ndPass(const Tracee &) override
Check whether a second pass needs to be made processing parameters.
void prepareNewSystemCall() override
Perform any necessary actions before processing a new system call entry event.
Flags used with fcntl() to set and get file descriptor flags.