#pragma once #include "Log.h" #include class Device { public: virtual Result read(u8* buf, usize offset, usize length) const = 0; virtual Result write(const u8* buf, usize offset, usize length) = 0; virtual Result ioctl(int, void*) { return err(ENOTTY); } virtual usize size() const { return 0; } virtual bool is_block_device() const { return false; } virtual Result block_size() const { // Block devices should override this function. kwarnln("Device::block_size() was called on a character device or block device without block size"); return err(ENOTSUP); } // Path in devfs. virtual StringView device_path() const = 0; virtual bool blocking() const = 0; virtual ~Device() = default; };