POSIX compliant type names

This commit is contained in:
snake-4
2024-06-15 17:48:41 +02:00
parent 1f2e9d34fc
commit d341cce3e7
5 changed files with 36 additions and 36 deletions

View File

@@ -6,10 +6,10 @@
namespace Parsers namespace Parsers
{ {
class map_entry_t class map_entry
{ {
public: public:
map_entry_t(uintptr_t address_start, uintptr_t address_end, uintptr_t offset, map_entry(uintptr_t address_start, uintptr_t address_end, uintptr_t offset,
const std::string &perms, const std::string &pathname, dev_t device, ino_t inode); const std::string &perms, const std::string &pathname, dev_t device, ino_t inode);
uintptr_t getAddressStart() const; uintptr_t getAddressStart() const;
@@ -27,5 +27,5 @@ namespace Parsers
ino_t inode; ino_t inode;
}; };
const std::vector<map_entry_t> &parseSelfMaps(bool cached = true); const std::vector<map_entry> &parseSelfMaps(bool cached = true);
} }

View File

@@ -6,10 +6,10 @@
namespace Parsers namespace Parsers
{ {
class mountinfo_entry_t class mountinfo_entry
{ {
public: public:
mountinfo_entry_t(int mount_id, int parent_id, dev_t device, mountinfo_entry(int mount_id, int parent_id, dev_t device,
const std::string &root, const std::string &mount_point, const std::string &root, const std::string &mount_point,
const std::string &mount_options, const std::string &optional_fields, const std::string &mount_options, const std::string &optional_fields,
const std::string &filesystem_type, const std::string &mount_source, const std::string &filesystem_type, const std::string &mount_source,
@@ -33,13 +33,13 @@ namespace Parsers
std::unordered_map<std::string, std::string> mount_options, super_options; std::unordered_map<std::string, std::string> mount_options, super_options;
}; };
const std::vector<mountinfo_entry_t> &parseSelfMountinfo(bool cached = true); const std::vector<mountinfo_entry> &parseSelfMountinfo(bool cached = true);
class mountinfo_root_resolver class mountinfo_root_resolver
{ {
public: public:
mountinfo_root_resolver(const std::vector<mountinfo_entry_t> &mount_infos); mountinfo_root_resolver(const std::vector<mountinfo_entry> &mount_infos);
std::string resolveRootOf(const mountinfo_entry_t &mount_info) const; std::string resolveRootOf(const mountinfo_entry &mount_info) const;
private: private:
std::unordered_map<dev_t, std::string> device_mount_map; std::unordered_map<dev_t, std::string> device_mount_map;

View File

@@ -9,21 +9,21 @@
using namespace Parsers; using namespace Parsers;
map_entry_t::map_entry_t(uintptr_t address_start, uintptr_t address_end, uintptr_t offset, const std::string &perms, const std::string &pathname, dev_t device, ino_t inode) map_entry::map_entry(uintptr_t address_start, uintptr_t address_end, uintptr_t offset, const std::string &perms, const std::string &pathname, dev_t device, ino_t inode)
: address_start(address_start), address_end(address_end), perms(perms), : address_start(address_start), address_end(address_end), perms(perms),
offset(offset), device(device), inode(inode), pathname(pathname) {} offset(offset), device(device), inode(inode), pathname(pathname) {}
uintptr_t map_entry_t::getAddressStart() const { return address_start; } uintptr_t map_entry::getAddressStart() const { return address_start; }
uintptr_t map_entry_t::getAddressEnd() const { return address_end; } uintptr_t map_entry::getAddressEnd() const { return address_end; }
const std::string &map_entry_t::getPerms() const { return perms; } const std::string &map_entry::getPerms() const { return perms; }
uintptr_t map_entry_t::getOffset() const { return offset; } uintptr_t map_entry::getOffset() const { return offset; }
dev_t map_entry_t::getDevice() const { return device; } dev_t map_entry::getDevice() const { return device; }
ino_t map_entry_t::getInode() const { return inode; } ino_t map_entry::getInode() const { return inode; }
const std::string &map_entry_t::getPathname() const { return pathname; } const std::string &map_entry::getPathname() const { return pathname; }
const std::vector<map_entry_t> &Parsers::parseSelfMaps(bool cached) const std::vector<map_entry> &Parsers::parseSelfMaps(bool cached)
{ {
static std::vector<map_entry_t> parser_cache; static std::vector<map_entry> parser_cache;
if (cached && !parser_cache.empty()) if (cached && !parser_cache.empty())
{ {
return parser_cache; return parser_cache;
@@ -59,7 +59,7 @@ const std::vector<map_entry_t> &Parsers::parseSelfMaps(bool cached)
// This operation can fail, it doesn't matter as it's an optional field. // This operation can fail, it doesn't matter as it's an optional field.
std::getline(iss >> std::ws, pathname); std::getline(iss >> std::ws, pathname);
parser_cache.emplace_back(map_entry_t(address_start, address_end, offset, perms, pathname, makedev(dev_major, dev_minor), inode)); parser_cache.emplace_back(map_entry(address_start, address_end, offset, perms, pathname, makedev(dev_major, dev_minor), inode));
} }
return parser_cache; return parser_cache;

View File

@@ -32,7 +32,7 @@ static const std::unordered_map<std::string, int> mount_flags_procfs = {
{"relatime", MS_RELATIME}, {"relatime", MS_RELATIME},
{"nosymfollow", MS_NOSYMFOLLOW}}; {"nosymfollow", MS_NOSYMFOLLOW}};
static bool shouldUnmount(const mountinfo_entry_t &mount, const mountinfo_root_resolver &root_resolver) static bool shouldUnmount(const mountinfo_entry &mount, const mountinfo_root_resolver &root_resolver)
{ {
const auto true_root = root_resolver.resolveRootOf(mount); const auto true_root = root_resolver.resolveRootOf(mount);
const auto &mount_point = mount.getMountPoint(); const auto &mount_point = mount.getMountPoint();

View File

@@ -30,7 +30,7 @@ static std::unordered_map<std::string, std::string> parseMountOptions(const std:
return ret; return ret;
} }
mountinfo_entry_t::mountinfo_entry_t(int mount_id, int parent_id, dev_t device, mountinfo_entry::mountinfo_entry(int mount_id, int parent_id, dev_t device,
const std::string &root, const std::string &mount_point, const std::string &root, const std::string &mount_point,
const std::string &mount_options, const std::string &optional_fields, const std::string &mount_options, const std::string &optional_fields,
const std::string &filesystem_type, const std::string &mount_source, const std::string &filesystem_type, const std::string &mount_source,
@@ -44,20 +44,20 @@ mountinfo_entry_t::mountinfo_entry_t(int mount_id, int parent_id, dev_t device,
this->super_options = parseMountOptions(super_options); this->super_options = parseMountOptions(super_options);
} }
int mountinfo_entry_t::getMountId() const { return mount_id; } int mountinfo_entry::getMountId() const { return mount_id; }
int mountinfo_entry_t::getParentId() const { return parent_id; } int mountinfo_entry::getParentId() const { return parent_id; }
dev_t mountinfo_entry_t::getDevice() const { return device; } dev_t mountinfo_entry::getDevice() const { return device; }
const std::string &mountinfo_entry_t::getRoot() const { return root; } const std::string &mountinfo_entry::getRoot() const { return root; }
const std::string &mountinfo_entry_t::getMountPoint() const { return mount_point; } const std::string &mountinfo_entry::getMountPoint() const { return mount_point; }
const std::unordered_map<std::string, std::string> &mountinfo_entry_t::getMountOptions() const { return mount_options; } const std::unordered_map<std::string, std::string> &mountinfo_entry::getMountOptions() const { return mount_options; }
const std::string &mountinfo_entry_t::getOptionalFields() const { return optional_fields; } const std::string &mountinfo_entry::getOptionalFields() const { return optional_fields; }
const std::string &mountinfo_entry_t::getFilesystemType() const { return filesystem_type; } const std::string &mountinfo_entry::getFilesystemType() const { return filesystem_type; }
const std::string &mountinfo_entry_t::getMountSource() const { return mount_source; } const std::string &mountinfo_entry::getMountSource() const { return mount_source; }
const std::unordered_map<std::string, std::string> &mountinfo_entry_t::getSuperOptions() const { return super_options; } const std::unordered_map<std::string, std::string> &mountinfo_entry::getSuperOptions() const { return super_options; }
const std::vector<mountinfo_entry_t> &Parsers::parseSelfMountinfo(bool cached) const std::vector<mountinfo_entry> &Parsers::parseSelfMountinfo(bool cached)
{ {
static std::vector<mountinfo_entry_t> parser_cache; static std::vector<mountinfo_entry> parser_cache;
if (cached && !parser_cache.empty()) if (cached && !parser_cache.empty())
{ {
return parser_cache; return parser_cache;
@@ -106,7 +106,7 @@ const std::vector<mountinfo_entry_t> &Parsers::parseSelfMountinfo(bool cached)
continue; continue;
} }
parser_cache.emplace_back(mountinfo_entry_t(mount_id, parent_id, makedev(_major, _minor), parser_cache.emplace_back(mountinfo_entry(mount_id, parent_id, makedev(_major, _minor),
root, mount_point, mount_options, root, mount_point, mount_options,
optional_fields, filesystem_type, mount_source, optional_fields, filesystem_type, mount_source,
super_options)); super_options));
@@ -115,7 +115,7 @@ const std::vector<mountinfo_entry_t> &Parsers::parseSelfMountinfo(bool cached)
return parser_cache; return parser_cache;
} }
mountinfo_root_resolver::mountinfo_root_resolver(const std::vector<mountinfo_entry_t> &mount_infos) mountinfo_root_resolver::mountinfo_root_resolver(const std::vector<mountinfo_entry> &mount_infos)
{ {
for (const auto &mount_info : mount_infos) for (const auto &mount_info : mount_infos)
{ {
@@ -126,7 +126,7 @@ mountinfo_root_resolver::mountinfo_root_resolver(const std::vector<mountinfo_ent
} }
} }
std::string mountinfo_root_resolver::resolveRootOf(const mountinfo_entry_t &mount_info) const std::string mountinfo_root_resolver::resolveRootOf(const mountinfo_entry &mount_info) const
{ {
auto dev = mount_info.getDevice(); auto dev = mount_info.getDevice();
if (device_mount_map.contains(dev)) if (device_mount_map.contains(dev))