#pragma once #include "Log.h" #include #include class Device : public Shareable { 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 query_shared_memory(off_t, usize) { return err(EACCES); } virtual Result ioctl(int, void*) { return err(ENOTTY); } virtual Result isatty() const { 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 will_block_if_read() const = 0; virtual ~Device() = default; protected: Option m_shmid; };