From 1fcd72e57885c39b0ad137c786ffe92d75bf49e8 Mon Sep 17 00:00:00 2001 From: DcraftBg Date: Fri, 15 May 2026 21:36:01 +0300 Subject: [PATCH] Kernel: replaced is_partition/storage with kind --- kernel/include/kernel/Device/Device.h | 3 --- kernel/include/kernel/FS/Inode.h | 20 +++++++++++-------- kernel/include/kernel/Storage/Partition.h | 3 --- kernel/include/kernel/Storage/StorageDevice.h | 6 ++++-- kernel/kernel/Storage/Partition.cpp | 1 + 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/kernel/include/kernel/Device/Device.h b/kernel/include/kernel/Device/Device.h index ffd3b517..265e3d39 100644 --- a/kernel/include/kernel/Device/Device.h +++ b/kernel/include/kernel/Device/Device.h @@ -12,9 +12,6 @@ namespace Kernel virtual ~Device() = default; virtual void update() {} - virtual bool is_partition() const { return false; } - virtual bool is_storage_device() const { return false; } - virtual BAN::ErrorOr> mmap_region(PageTable&, off_t offset, size_t len, AddressRange, MemoryRegion::Type, PageTable::flags_t, int status_flags) { (void)offset; (void)len; (void)status_flags; diff --git a/kernel/include/kernel/FS/Inode.h b/kernel/include/kernel/FS/Inode.h index a806bc3e..c534d7a7 100644 --- a/kernel/include/kernel/FS/Inode.h +++ b/kernel/include/kernel/FS/Inode.h @@ -62,10 +62,12 @@ namespace Kernel mode_t mode; }; enum InodeKind : uint8_t { - DEVICE = 0x1, - EPOLL = 0x2, - PIPE = 0x4, - TTY = 0x8, + DEVICE = 0x01, + EPOLL = 0x02, + PIPE = 0x04, + TTY = 0x08, + PARTITION = 0x10, + STORAGE = 0x20, }; public: virtual ~Inode() {} @@ -88,10 +90,12 @@ namespace Kernel dev_t dev() const { return m_dev; } dev_t rdev() const { return m_rdev; } - bool is_device() const { return m_kind & InodeKind::DEVICE; } - bool is_epoll() const { return m_kind & InodeKind::EPOLL; } - bool is_pipe() const { return m_kind & InodeKind::PIPE; } - bool is_tty() const { return m_kind & InodeKind::TTY; } + bool is_device() const { return m_kind & InodeKind::DEVICE; } + bool is_epoll() const { return m_kind & InodeKind::EPOLL; } + bool is_pipe() const { return m_kind & InodeKind::PIPE; } + bool is_tty() const { return m_kind & InodeKind::TTY; } + bool is_partition() const { return m_kind & InodeKind::PARTITION; } + bool is_storage_device() const { return m_kind & InodeKind::STORAGE; } virtual const FileSystem* filesystem() const = 0; diff --git a/kernel/include/kernel/Storage/Partition.h b/kernel/include/kernel/Storage/Partition.h index 197be51d..464b9eeb 100644 --- a/kernel/include/kernel/Storage/Partition.h +++ b/kernel/include/kernel/Storage/Partition.h @@ -42,9 +42,6 @@ namespace Kernel char m_label[36 * 4 + 1]; const BAN::String m_name; - public: - virtual bool is_partition() const override { return true; } - protected: virtual BAN::ErrorOr read_impl(off_t, BAN::ByteSpan) override; diff --git a/kernel/include/kernel/Storage/StorageDevice.h b/kernel/include/kernel/Storage/StorageDevice.h index d882ed77..30eff679 100644 --- a/kernel/include/kernel/Storage/StorageDevice.h +++ b/kernel/include/kernel/Storage/StorageDevice.h @@ -14,7 +14,10 @@ namespace Kernel public: StorageDevice() : BlockDevice(0660, 0, 0) - { } + { + m_kind |= InodeKind::STORAGE; + } + virtual ~StorageDevice(); BAN::ErrorOr initialize_partitions(BAN::StringView name_prefix); @@ -35,7 +38,6 @@ namespace Kernel size_t drop_disk_cache(); BAN::ErrorOr sync_disk_cache(); - virtual bool is_storage_device() const override { return true; } protected: virtual BAN::ErrorOr read_sectors_impl(uint64_t lba, uint64_t sector_count, BAN::ByteSpan) = 0; diff --git a/kernel/kernel/Storage/Partition.cpp b/kernel/kernel/Storage/Partition.cpp index 718e3422..036da0f6 100644 --- a/kernel/kernel/Storage/Partition.cpp +++ b/kernel/kernel/Storage/Partition.cpp @@ -25,6 +25,7 @@ namespace Kernel , m_attributes(attr) , m_name(MUST(BAN::String::formatted("{}{}", name_prefix, index))) { + m_kind |= InodeKind::PARTITION; m_rdev = makedev(major(device->rdev()), index); memcpy(m_label, label, sizeof(m_label)); }