2023-09-09 22:46:15 +03:00
|
|
|
#include <kernel/Device/Device.h>
|
|
|
|
|
|
|
|
namespace Kernel
|
|
|
|
{
|
|
|
|
|
|
|
|
class ZeroDevice : public CharacterDevice
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static BAN::ErrorOr<BAN::RefPtr<ZeroDevice>> create(mode_t, uid_t, gid_t);
|
|
|
|
|
|
|
|
virtual dev_t rdev() const override { return m_rdev; }
|
|
|
|
|
2023-10-07 15:46:30 +03:00
|
|
|
virtual BAN::StringView name() const override { return "zero"sv; }
|
|
|
|
|
2023-09-09 22:46:15 +03:00
|
|
|
protected:
|
|
|
|
ZeroDevice(mode_t mode, uid_t uid, gid_t gid, dev_t rdev)
|
|
|
|
: CharacterDevice(mode, uid, gid)
|
|
|
|
, m_rdev(rdev)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual BAN::ErrorOr<size_t> read_impl(off_t, void*, size_t) override;
|
|
|
|
virtual BAN::ErrorOr<size_t> write_impl(off_t, const void*, size_t size) override { return size; };
|
2023-09-09 22:52:03 +03:00
|
|
|
|
2023-09-09 22:46:15 +03:00
|
|
|
private:
|
|
|
|
const dev_t m_rdev;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|