summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/InodeMetadata.h
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2021-12-23 20:08:18 +0200
committerAndreas Kling <kling@serenityos.org>2021-12-23 23:02:39 +0100
commit9eb08bdb0f7460eb9874a5d16f6f3808f3d8a8f0 (patch)
tree79c20875f3cd0977fc809964f2e5f7a771ce1428 /Kernel/FileSystem/InodeMetadata.h
parent6d149400534643d2d4549853b257c136c3a8d47c (diff)
downloadserenity-9eb08bdb0f7460eb9874a5d16f6f3808f3d8a8f0.zip
Kernel: Make major and minor numbers to be DistinctNumerics
This helps avoid confusion in general, and make constructors, methods and code patterns much more clean and understandable.
Diffstat (limited to 'Kernel/FileSystem/InodeMetadata.h')
-rw-r--r--Kernel/FileSystem/InodeMetadata.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/Kernel/FileSystem/InodeMetadata.h b/Kernel/FileSystem/InodeMetadata.h
index 95bfba8367..1dc23b6d72 100644
--- a/Kernel/FileSystem/InodeMetadata.h
+++ b/Kernel/FileSystem/InodeMetadata.h
@@ -8,6 +8,7 @@
#include <AK/Error.h>
#include <AK/Span.h>
+#include <Kernel/FileSystem/DeviceFileTypes.h>
#include <Kernel/FileSystem/InodeIdentifier.h>
#include <Kernel/Forward.h>
#include <Kernel/UnixTypes.h>
@@ -16,12 +17,12 @@ namespace Kernel {
class Process;
-constexpr u32 encoded_device(unsigned major, unsigned minor)
+constexpr u64 encoded_device(MajorNumber major, MinorNumber minor)
{
- return (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12);
+ return (minor.value() & 0xff) | (major.value() << 8) | ((minor.value() & ~0xff) << 12);
}
-static inline unsigned int major_from_encoded_device(dev_t dev) { return (dev & 0xfff00u) >> 8u; }
-static inline unsigned int minor_from_encoded_device(dev_t dev) { return (dev & 0xffu) | ((dev >> 12u) & 0xfff00u); }
+static inline MajorNumber major_from_encoded_device(dev_t dev) { return (dev & 0xfff00u) >> 8u; }
+static inline MinorNumber minor_from_encoded_device(dev_t dev) { return (dev & 0xffu) | ((dev >> 12u) & 0xfff00u); }
inline bool is_directory(mode_t mode) { return (mode & S_IFMT) == S_IFDIR; }
inline bool is_character_device(mode_t mode) { return (mode & S_IFMT) == S_IFCHR; }
@@ -122,8 +123,8 @@ struct InodeMetadata {
time_t dtime { 0 };
blkcnt_t block_count { 0 };
blksize_t block_size { 0 };
- unsigned major_device { 0 };
- unsigned minor_device { 0 };
+ MajorNumber major_device { 0 };
+ MinorNumber minor_device { 0 };
};
}