1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:07:36 +00:00

Kernel/Devices: Remove required_mode and device_name methods

These methods are no longer needed because SystemServer is able to
populate the DevFS on its own.

Device absolute_path no longer assume a path to the /dev location,
because it really should not assume any path to a Device node.

Because StorageManagement still needs to know the storage name, we
declare a virtual method only for StorageDevices to override, but this
technique should really be removed later on.
This commit is contained in:
Liav A 2021-08-14 07:01:19 +03:00 committed by Andreas Kling
parent 4f04cb98c1
commit 21b6d84ff0
38 changed files with 18 additions and 141 deletions

View file

@ -51,8 +51,11 @@ Device::~Device()
String Device::absolute_path() const
{
// FIXME: Don't assume mount point for DevFs
return String::formatted("/dev/{}", device_name());
// FIXME: I assume we can't really provide a well known path in the kernel
// because this is a violation of abstraction layers between userland and the
// kernel, but maybe the whole name of "absolute_path" is just wrong as this
// is really not an "absolute_path".
return String::formatted("device:{},{}", major(), minor());
}
String Device::absolute_path(const OpenFileDescription&) const

View file

@ -37,9 +37,6 @@ public:
UserID uid() const { return m_uid; }
GroupID gid() const { return m_gid; }
virtual mode_t required_mode() const = 0;
virtual String device_name() const = 0;
virtual bool is_device() const override { return true; }
static void for_each(Function<void(Device&)>);

View file

@ -16,10 +16,6 @@ public:
static NonnullRefPtr<FullDevice> must_create();
virtual ~FullDevice() override;
// ^Device
virtual mode_t required_mode() const override { return 0666; }
virtual String device_name() const override { return "full"; }
private:
FullDevice();

View file

@ -33,14 +33,9 @@ public:
// ^HIDDevice
virtual Type instrument_type() const override { return Type::Keyboard; }
// ^Device
virtual mode_t required_mode() const override { return 0440; }
// ^File
virtual KResult ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg) override;
virtual String device_name() const override { return String::formatted("keyboard{}", minor()); }
void update_modifier(u8 modifier, bool state)
{
if (state)

View file

@ -31,11 +31,6 @@ public:
// ^HIDDevice
virtual Type instrument_type() const override { return Type::Mouse; }
// ^Device
virtual mode_t required_mode() const override { return 0440; }
virtual String device_name() const override { return String::formatted("mouse{}", minor()); }
protected:
MouseDevice();
// ^CharacterDevice

View file

@ -141,9 +141,4 @@ KResultOr<Memory::Region*> KCOVDevice::mmap(Process& process, OpenFileDescriptio
range, *kcov_instance->vmobject(), offset, {}, prot, shared);
}
String KCOVDevice::device_name() const
{
return "kcov"sv;
}
}

View file

@ -25,10 +25,6 @@ public:
KResultOr<Memory::Region*> mmap(Process&, OpenFileDescription&, Memory::VirtualRange const&, u64 offset, int prot, bool shared) override;
KResultOr<NonnullRefPtr<OpenFileDescription>> open(int options) override;
// ^Device
virtual mode_t required_mode() const override { return 0660; }
virtual String device_name() const override;
protected:
virtual StringView class_name() const override { return "KCOVDevice"; }

View file

@ -21,10 +21,6 @@ public:
virtual KResultOr<Memory::Region*> mmap(Process&, OpenFileDescription&, Memory::VirtualRange const&, u64 offset, int prot, bool shared) override;
// ^Device
virtual mode_t required_mode() const override { return 0660; }
virtual String device_name() const override { return "mem"; };
private:
MemoryDevice();
virtual StringView class_name() const override { return "MemoryDevice"; }

View file

@ -19,10 +19,6 @@ public:
static void initialize();
static NullDevice& the();
// ^Device
virtual mode_t required_mode() const override { return 0666; }
virtual String device_name() const override { return "null"; }
private:
// ^CharacterDevice
virtual KResultOr<size_t> read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override;

View file

@ -16,10 +16,6 @@ public:
static NonnullRefPtr<RandomDevice> must_create();
virtual ~RandomDevice() override;
// ^Device
virtual mode_t required_mode() const override { return 0666; }
virtual String device_name() const override { return "random"; }
private:
RandomDevice();

View file

@ -34,10 +34,6 @@ public:
virtual StringView purpose() const override { return class_name(); }
// ^Device
virtual mode_t required_mode() const override { return 0220; }
virtual String device_name() const override { return "audio"; }
virtual KResult ioctl(OpenFileDescription&, unsigned, Userspace<void*>) override;
private:

View file

@ -104,11 +104,6 @@ void SerialDevice::put_char(char ch)
m_last_put_char_was_carriage_return = (ch == '\r');
}
String SerialDevice::device_name() const
{
return String::formatted("ttyS{}", minor() - 64);
}
UNMAP_AFTER_INIT void SerialDevice::initialize()
{
set_interrupts(false);

View file

@ -102,10 +102,6 @@ public:
DataReady = 0x01 << 0
};
// ^Device
virtual mode_t required_mode() const override { return 0620; }
virtual String device_name() const override;
private:
friend class PCISerialDevice;

View file

@ -16,10 +16,6 @@ public:
static NonnullRefPtr<ZeroDevice> must_create();
virtual ~ZeroDevice() override;
// ^Device
virtual mode_t required_mode() const override { return 0666; }
virtual String device_name() const override { return "zero"; }
private:
ZeroDevice();
// ^CharacterDevice