Kernel: replaced is_partition/storage with kind
This commit is contained in:
@@ -12,9 +12,6 @@ namespace Kernel
|
|||||||
virtual ~Device() = default;
|
virtual ~Device() = default;
|
||||||
virtual void update() {}
|
virtual void update() {}
|
||||||
|
|
||||||
virtual bool is_partition() const { return false; }
|
|
||||||
virtual bool is_storage_device() const { return false; }
|
|
||||||
|
|
||||||
virtual BAN::ErrorOr<BAN::UniqPtr<MemoryRegion>> mmap_region(PageTable&, off_t offset, size_t len, AddressRange, MemoryRegion::Type, PageTable::flags_t, int status_flags)
|
virtual BAN::ErrorOr<BAN::UniqPtr<MemoryRegion>> 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;
|
(void)offset; (void)len; (void)status_flags;
|
||||||
|
|||||||
@@ -62,10 +62,12 @@ namespace Kernel
|
|||||||
mode_t mode;
|
mode_t mode;
|
||||||
};
|
};
|
||||||
enum InodeKind : uint8_t {
|
enum InodeKind : uint8_t {
|
||||||
DEVICE = 0x1,
|
DEVICE = 0x01,
|
||||||
EPOLL = 0x2,
|
EPOLL = 0x02,
|
||||||
PIPE = 0x4,
|
PIPE = 0x04,
|
||||||
TTY = 0x8,
|
TTY = 0x08,
|
||||||
|
PARTITION = 0x10,
|
||||||
|
STORAGE = 0x20,
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
virtual ~Inode() {}
|
virtual ~Inode() {}
|
||||||
@@ -88,10 +90,12 @@ namespace Kernel
|
|||||||
dev_t dev() const { return m_dev; }
|
dev_t dev() const { return m_dev; }
|
||||||
dev_t rdev() const { return m_rdev; }
|
dev_t rdev() const { return m_rdev; }
|
||||||
|
|
||||||
bool is_device() const { return m_kind & InodeKind::DEVICE; }
|
bool is_device() const { return m_kind & InodeKind::DEVICE; }
|
||||||
bool is_epoll() const { return m_kind & InodeKind::EPOLL; }
|
bool is_epoll() const { return m_kind & InodeKind::EPOLL; }
|
||||||
bool is_pipe() const { return m_kind & InodeKind::PIPE; }
|
bool is_pipe() const { return m_kind & InodeKind::PIPE; }
|
||||||
bool is_tty() const { return m_kind & InodeKind::TTY; }
|
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;
|
virtual const FileSystem* filesystem() const = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -42,9 +42,6 @@ namespace Kernel
|
|||||||
char m_label[36 * 4 + 1];
|
char m_label[36 * 4 + 1];
|
||||||
const BAN::String m_name;
|
const BAN::String m_name;
|
||||||
|
|
||||||
public:
|
|
||||||
virtual bool is_partition() const override { return true; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual BAN::ErrorOr<size_t> read_impl(off_t, BAN::ByteSpan) override;
|
virtual BAN::ErrorOr<size_t> read_impl(off_t, BAN::ByteSpan) override;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,10 @@ namespace Kernel
|
|||||||
public:
|
public:
|
||||||
StorageDevice()
|
StorageDevice()
|
||||||
: BlockDevice(0660, 0, 0)
|
: BlockDevice(0660, 0, 0)
|
||||||
{ }
|
{
|
||||||
|
m_kind |= InodeKind::STORAGE;
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~StorageDevice();
|
virtual ~StorageDevice();
|
||||||
|
|
||||||
BAN::ErrorOr<void> initialize_partitions(BAN::StringView name_prefix);
|
BAN::ErrorOr<void> initialize_partitions(BAN::StringView name_prefix);
|
||||||
@@ -35,7 +38,6 @@ namespace Kernel
|
|||||||
|
|
||||||
size_t drop_disk_cache();
|
size_t drop_disk_cache();
|
||||||
BAN::ErrorOr<void> sync_disk_cache();
|
BAN::ErrorOr<void> sync_disk_cache();
|
||||||
virtual bool is_storage_device() const override { return true; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual BAN::ErrorOr<void> read_sectors_impl(uint64_t lba, uint64_t sector_count, BAN::ByteSpan) = 0;
|
virtual BAN::ErrorOr<void> read_sectors_impl(uint64_t lba, uint64_t sector_count, BAN::ByteSpan) = 0;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ namespace Kernel
|
|||||||
, m_attributes(attr)
|
, m_attributes(attr)
|
||||||
, m_name(MUST(BAN::String::formatted("{}{}", name_prefix, index)))
|
, m_name(MUST(BAN::String::formatted("{}{}", name_prefix, index)))
|
||||||
{
|
{
|
||||||
|
m_kind |= InodeKind::PARTITION;
|
||||||
m_rdev = makedev(major(device->rdev()), index);
|
m_rdev = makedev(major(device->rdev()), index);
|
||||||
memcpy(m_label, label, sizeof(m_label));
|
memcpy(m_label, label, sizeof(m_label));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user