ladybird/Kernel/Devices/DiskPartition.h
Jesse 401c87a0cc Kernel: mount system call (#396)
It is now possible to mount ext2 `DiskDevice` devices under Serenity on
any folder in the root filesystem. Currently any user can do this with
any permissions. There's a fair amount of assumptions made here too,
that might not be too good, but can be worked on in the future. This is
a good start to allow more dynamic operation under the OS itself.

It is also currently impossible to unmount and such, and devices will
fail to mount in Linux as the FS 'needs to be cleaned'. I'll work on
getting `umount` done ASAP to rectify this (as well as working on less
assumption-making in the mount syscall. We don't want to just be able
to mount DiskDevices!). This could probably be fixed with some `-t`
flag or something similar.
2019-08-02 15:18:47 +02:00

31 lines
1.1 KiB
C++

#pragma once
#include <AK/RefPtr.h>
#include <Kernel/Devices/DiskDevice.h>
class DiskPartition final : public DiskDevice {
public:
static NonnullRefPtr<DiskPartition> create(NonnullRefPtr<DiskDevice>, unsigned block_offset);
virtual ~DiskPartition();
virtual unsigned block_size() const override;
virtual bool read_block(unsigned index, u8* out) const override;
virtual bool write_block(unsigned index, const u8*) override;
virtual bool read_blocks(unsigned index, u16 count, u8*) override;
virtual bool write_blocks(unsigned index, u16 count, const u8*) override;
// ^BlockDevice
virtual ssize_t read(FileDescription&, u8*, ssize_t) override { return 0; }
virtual bool can_read(FileDescription&) const override { return true; }
virtual ssize_t write(FileDescription&, const u8*, ssize_t) override { return 0; }
virtual bool can_write(FileDescription&) const override { return true; }
private:
virtual const char* class_name() const override;
DiskPartition(NonnullRefPtr<DiskDevice>, unsigned block_offset);
NonnullRefPtr<DiskDevice> m_device;
unsigned m_block_offset;
};