11#include <cosmos/fs/DirEntry.hxx>
12#include <cosmos/fs/FileStatus.hxx>
13#include <cosmos/fs/filesystem.hxx>
14#include <cosmos/utils.hxx>
17#include <clues/items/fcntl.hxx>
18#include <clues/items/items.hxx>
19#include <clues/SystemCallItem.hxx>
20#include <clues/types.hxx>
22namespace clues::item {
24using AtSemantics = cosmos::NamedBool<struct at_semantics_t, false>;
39 const AtSemantics at_semantics = AtSemantics{
false},
40 const std::string_view short_name =
"fd",
41 const std::string_view long_name =
"file descriptor") :
43 m_at_semantics{at_semantics} {
46 std::string str()
const override;
57 const std::optional<FDInfo>&
info()
const {
63 void processValue(
const Tracee &)
override;
71 const AtSemantics m_at_semantics = AtSemantics{
false};
75class CLUES_API OpenFlagsValue :
82 std::string
str()
const override;
84 cosmos::OpenMode mode()
const {
88 cosmos::OpenFlags flags()
const {
98 cosmos::OpenMode m_mode;
99 cosmos::OpenFlags m_flags;
103class CLUES_API AtFlagsValue :
108 EMPTY_PATH = AT_EMPTY_PATH,
109 SYMLINK_NOFOLLOW = AT_SYMLINK_NOFOLLOW,
110 SYMLINK_FOLLOW = AT_SYMLINK_FOLLOW,
116 using AtFlags = cosmos::BitMask<AtFlag>;
124 std::string str()
const override;
126 AtFlags flags()
const {
132 void processValue(
const Tracee&)
override;
140class CLUES_API AccessModeParameter :
143 explicit AccessModeParameter() :
147 std::string
str()
const override;
149 cosmos::fs::AccessChecks checks()
const {
159 cosmos::fs::AccessChecks m_checks;
163class CLUES_API FileModeParameter :
167 FileModeParameter() :
171 std::string
str()
const override;
185 cosmos::FileMode m_mode;
189class CLUES_API StatParameter :
190 public PointerOutValue {
192 explicit StatParameter() :
193 PointerOutValue{
"stat",
"struct stat"} {
196 std::string
str()
const override;
203 const std::optional<cosmos::FileStatus>&
status()
const {
213 void updateData(
const Tracee &proc)
override;
216 bool isOldStat()
const;
219 bool isStat64()
const;
222 bool isRegularStat()
const;
226 std::optional<cosmos::FileStatus> m_stat;
230class CLUES_API DirEntries :
231 public PointerOutValue {
240 std::string_view name;
241 cosmos::DirEntry::Type type;
246 explicit DirEntries() :
247 PointerOutValue{
"dirent",
"struct linux_dirent"}
250 std::string str()
const override;
252 const auto& entries()
const {
263 void updateData(
const Tracee &proc)
override;
270 template <
typename DIRENT>
271 void parseEntries32(
const size_t bytes);
274 void parseEntries64(
const size_t bytes);
278 std::vector<Entry> m_entries;
Base class for any kind of system call parameter or return value.
OTHER valueAs() const
Helper to cast the strongly typed Word m_val to other strong enum types.
SystemCallItem(const ItemType type, const std::string_view short_name={}, const std::string_view long_name={})
Constructs a new SystemCallItem.
Base class for traced processes.
std::string str() const override
Returns a human readable string representation of the item.
void processValue(const Tracee &) override
Processes the value stored in m_val acc. to the actual item type.
Flags for system calls with at semantics like linkat(), faccessat().
@ EACCESS
only used with faccessat2
@ REMOVEDIR
only used with unlinkat
@ NO_AUTOMOUNT
only used with fstatat()
void processValue(const Tracee &) override
Processes the value stored in m_val acc. to the actual item type.
std::unique_ptr< char[]> m_buffer
the raw buffer backing m_entries
FileDescriptor(const ItemType type=ItemType::PARAM_IN, const AtSemantics at_semantics=AtSemantics{false}, const std::string_view short_name="fd", const std::string_view long_name="file descriptor")
const std::optional< FDInfo > & info() const
Returns optional extended file descriptor metadata.
std::optional< FDInfo > m_info
filled if FormatFlag::FD_INFO is set.
std::string str() const override
Returns a human readable string representation of the item.
void processValue(const Tracee &) override
Processes the value stored in m_val acc. to the actual item type.
std::string str() const override
Returns a human readable string representation of the item.
void processValue(const Tracee &) override
Processes the value stored in m_val acc. to the actual item type.
std::string str() const override
Returns a human readable string representation of the item.
void processValue(const Tracee &) override
Processes the value stored in m_val acc. to the actual item type.
const std::optional< cosmos::FileStatus > & status() const
Access to full FileStatus information.
Specialization of ValueParameter for PARAM_IN parameters.
ItemType
Basic type of a SystemCallItem.
@ PARAM_IN
An input parameter to the system call.