1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:17:36 +00:00

Kernel: Use DistinctNumeric for filesystem ID's

This patch adds the FileSystemID type, which is a distinct u32.
This prevents accidental conversion from arbitrary integers.
This commit is contained in:
Andreas Kling 2021-11-18 15:11:31 +01:00
parent 7c57961c61
commit e08d213830
18 changed files with 36 additions and 35 deletions

View file

@ -15,12 +15,13 @@ namespace Kernel {
class FileSystem;
struct InodeMetadata;
TYPEDEF_DISTINCT_ORDERED_ID(u32, FileSystemID);
TYPEDEF_DISTINCT_ORDERED_ID(u64, InodeIndex);
class InodeIdentifier {
public:
InodeIdentifier() = default;
InodeIdentifier(u32 fsid, InodeIndex inode)
InodeIdentifier(FileSystemID fsid, InodeIndex inode)
: m_fsid(fsid)
, m_index(inode)
{
@ -28,7 +29,7 @@ public:
bool is_valid() const { return m_fsid != 0 && m_index != 0; }
u32 fsid() const { return m_fsid; }
FileSystemID fsid() const { return m_fsid; }
InodeIndex index() const { return m_index; }
FileSystem* fs();
@ -45,7 +46,7 @@ public:
}
private:
u32 m_fsid { 0 };
FileSystemID m_fsid { 0 };
InodeIndex m_index { 0 };
};