diff --git a/Kernel/Bus/VirtIO/ConsolePort.cpp b/Kernel/Bus/VirtIO/ConsolePort.cpp index d05b5d7193..8dd8840769 100644 --- a/Kernel/Bus/VirtIO/ConsolePort.cpp +++ b/Kernel/Bus/VirtIO/ConsolePort.cpp @@ -158,11 +158,6 @@ KResultOr ConsolePort::write(OpenFileDescription& desc, u64, const UserO return total_bytes_copied; } -String ConsolePort::device_name() const -{ - return String::formatted("hvc{}p{}", m_console.device_id(), m_port); -} - KResultOr> ConsolePort::open(int options) { if (!m_open) diff --git a/Kernel/Bus/VirtIO/ConsolePort.h b/Kernel/Bus/VirtIO/ConsolePort.h index 041a5c54a1..7b511087ac 100644 --- a/Kernel/Bus/VirtIO/ConsolePort.h +++ b/Kernel/Bus/VirtIO/ConsolePort.h @@ -40,10 +40,6 @@ private: virtual KResultOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; virtual KResultOr> open(int options) override; - mode_t required_mode() const override { return 0666; } - - String device_name() const override; - void init_receive_buffer(); static unsigned next_device_id; diff --git a/Kernel/ConsoleDevice.h b/Kernel/ConsoleDevice.h index c27cc0d3f7..9bcd5f1160 100644 --- a/Kernel/ConsoleDevice.h +++ b/Kernel/ConsoleDevice.h @@ -33,10 +33,6 @@ public: const CircularQueue& logbuffer() const { return m_logbuffer; } - // ^Device - virtual mode_t required_mode() const override { return 0666; } - virtual String device_name() const override { return "console"; } - private: CircularQueue m_logbuffer; }; diff --git a/Kernel/Devices/Device.cpp b/Kernel/Devices/Device.cpp index 38da7d3790..ac418c3abc 100644 --- a/Kernel/Devices/Device.cpp +++ b/Kernel/Devices/Device.cpp @@ -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 diff --git a/Kernel/Devices/Device.h b/Kernel/Devices/Device.h index 776dfa2dac..4be7c40ac6 100644 --- a/Kernel/Devices/Device.h +++ b/Kernel/Devices/Device.h @@ -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); diff --git a/Kernel/Devices/FullDevice.h b/Kernel/Devices/FullDevice.h index 10bde83ac2..ded36209de 100644 --- a/Kernel/Devices/FullDevice.h +++ b/Kernel/Devices/FullDevice.h @@ -16,10 +16,6 @@ public: static NonnullRefPtr 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(); diff --git a/Kernel/Devices/HID/KeyboardDevice.h b/Kernel/Devices/HID/KeyboardDevice.h index 6065474523..05353fe345 100644 --- a/Kernel/Devices/HID/KeyboardDevice.h +++ b/Kernel/Devices/HID/KeyboardDevice.h @@ -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 arg) override; - virtual String device_name() const override { return String::formatted("keyboard{}", minor()); } - void update_modifier(u8 modifier, bool state) { if (state) diff --git a/Kernel/Devices/HID/MouseDevice.h b/Kernel/Devices/HID/MouseDevice.h index 73105f9e89..6df59de9d7 100644 --- a/Kernel/Devices/HID/MouseDevice.h +++ b/Kernel/Devices/HID/MouseDevice.h @@ -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 diff --git a/Kernel/Devices/KCOVDevice.cpp b/Kernel/Devices/KCOVDevice.cpp index 3dbf1fcf71..712d5df7b9 100644 --- a/Kernel/Devices/KCOVDevice.cpp +++ b/Kernel/Devices/KCOVDevice.cpp @@ -141,9 +141,4 @@ KResultOr KCOVDevice::mmap(Process& process, OpenFileDescriptio range, *kcov_instance->vmobject(), offset, {}, prot, shared); } -String KCOVDevice::device_name() const -{ - return "kcov"sv; -} - } diff --git a/Kernel/Devices/KCOVDevice.h b/Kernel/Devices/KCOVDevice.h index bde9f3ce24..56002ac545 100644 --- a/Kernel/Devices/KCOVDevice.h +++ b/Kernel/Devices/KCOVDevice.h @@ -25,10 +25,6 @@ public: KResultOr mmap(Process&, OpenFileDescription&, Memory::VirtualRange const&, u64 offset, int prot, bool shared) override; KResultOr> 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"; } diff --git a/Kernel/Devices/MemoryDevice.h b/Kernel/Devices/MemoryDevice.h index 4c4b14acab..875ff434de 100644 --- a/Kernel/Devices/MemoryDevice.h +++ b/Kernel/Devices/MemoryDevice.h @@ -21,10 +21,6 @@ public: virtual KResultOr 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"; } diff --git a/Kernel/Devices/NullDevice.h b/Kernel/Devices/NullDevice.h index 143e31b4f2..d10729c44c 100644 --- a/Kernel/Devices/NullDevice.h +++ b/Kernel/Devices/NullDevice.h @@ -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 read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override; diff --git a/Kernel/Devices/RandomDevice.h b/Kernel/Devices/RandomDevice.h index 29986d30ba..52dfcce0bd 100644 --- a/Kernel/Devices/RandomDevice.h +++ b/Kernel/Devices/RandomDevice.h @@ -16,10 +16,6 @@ public: static NonnullRefPtr 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(); diff --git a/Kernel/Devices/SB16.h b/Kernel/Devices/SB16.h index c886c0ef16..32a90b9928 100644 --- a/Kernel/Devices/SB16.h +++ b/Kernel/Devices/SB16.h @@ -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) override; private: diff --git a/Kernel/Devices/SerialDevice.cpp b/Kernel/Devices/SerialDevice.cpp index 1fb506d8b7..623c8cc7fc 100644 --- a/Kernel/Devices/SerialDevice.cpp +++ b/Kernel/Devices/SerialDevice.cpp @@ -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); diff --git a/Kernel/Devices/SerialDevice.h b/Kernel/Devices/SerialDevice.h index 48c1091a95..9e39a902f3 100644 --- a/Kernel/Devices/SerialDevice.h +++ b/Kernel/Devices/SerialDevice.h @@ -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; diff --git a/Kernel/Devices/ZeroDevice.h b/Kernel/Devices/ZeroDevice.h index 46cdbd04d0..cf68501324 100644 --- a/Kernel/Devices/ZeroDevice.h +++ b/Kernel/Devices/ZeroDevice.h @@ -16,10 +16,6 @@ public: static NonnullRefPtr 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 diff --git a/Kernel/Graphics/FramebufferDevice.cpp b/Kernel/Graphics/FramebufferDevice.cpp index 1969d424ad..03b8b760eb 100644 --- a/Kernel/Graphics/FramebufferDevice.cpp +++ b/Kernel/Graphics/FramebufferDevice.cpp @@ -84,11 +84,6 @@ void FramebufferDevice::activate_writes() m_graphical_writes_enabled = true; } -String FramebufferDevice::device_name() const -{ - return String::formatted("fb{}", minor()); -} - UNMAP_AFTER_INIT KResult FramebufferDevice::initialize() { // FIXME: Would be nice to be able to unify this with mmap above, but this diff --git a/Kernel/Graphics/FramebufferDevice.h b/Kernel/Graphics/FramebufferDevice.h index 2a7aecb359..00b57226c6 100644 --- a/Kernel/Graphics/FramebufferDevice.h +++ b/Kernel/Graphics/FramebufferDevice.h @@ -25,10 +25,6 @@ public: virtual KResult ioctl(OpenFileDescription&, unsigned request, Userspace arg) override; virtual KResultOr 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; - virtual void deactivate_writes(); virtual void activate_writes(); size_t framebuffer_size_in_bytes() const; diff --git a/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.h b/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.h index 9f0a3433dd..a47f601250 100644 --- a/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.h +++ b/Kernel/Graphics/VirtIOGPU/FrameBufferDevice.h @@ -68,9 +68,6 @@ private: virtual KResultOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override { return EINVAL; }; virtual void start_request(AsyncBlockDeviceRequest& request) override { request.complete(AsyncDeviceRequest::Failure); } - virtual mode_t required_mode() const override { return 0666; } - virtual String device_name() const override { return String::formatted("fb{}", minor()); } - static bool is_valid_buffer_index(int buffer_index) { return buffer_index == 0 || buffer_index == 1; diff --git a/Kernel/Storage/PATADiskDevice.cpp b/Kernel/Storage/PATADiskDevice.cpp index 0f7d9cda4c..015ff71d9c 100644 --- a/Kernel/Storage/PATADiskDevice.cpp +++ b/Kernel/Storage/PATADiskDevice.cpp @@ -41,7 +41,7 @@ void PATADiskDevice::start_request(AsyncBlockDeviceRequest& request) m_channel->start_request(request, is_slave(), m_capabilities); } -String PATADiskDevice::device_name() const +String PATADiskDevice::storage_name() const { return String::formatted("hd{:c}", 'a' + minor()); } diff --git a/Kernel/Storage/PATADiskDevice.h b/Kernel/Storage/PATADiskDevice.h index 504c3a4f57..4aadb24893 100644 --- a/Kernel/Storage/PATADiskDevice.h +++ b/Kernel/Storage/PATADiskDevice.h @@ -42,7 +42,7 @@ public: // ^BlockDevice virtual void start_request(AsyncBlockDeviceRequest&) override; - virtual String device_name() const override; + virtual String storage_name() const override; private: PATADiskDevice(const IDEController&, IDEChannel&, DriveType, InterfaceType, u16, u64); diff --git a/Kernel/Storage/Partition/DiskPartition.cpp b/Kernel/Storage/Partition/DiskPartition.cpp index 4ba56aa3ca..367a3b3a4f 100644 --- a/Kernel/Storage/Partition/DiskPartition.cpp +++ b/Kernel/Storage/Partition/DiskPartition.cpp @@ -68,13 +68,6 @@ bool DiskPartition::can_write(const OpenFileDescription& fd, size_t offset) cons return m_device->can_write(fd, offset + adjust); } -String DiskPartition::device_name() const -{ - // FIXME: Try to not hardcode a maximum of 16 partitions per drive! - size_t partition_index = minor() % 16; - return String::formatted("{}{}", m_device->device_name(), partition_index + 1); -} - StringView DiskPartition::class_name() const { return "DiskPartition"; diff --git a/Kernel/Storage/Partition/DiskPartition.h b/Kernel/Storage/Partition/DiskPartition.h index 1c4896ff4d..0352ee2883 100644 --- a/Kernel/Storage/Partition/DiskPartition.h +++ b/Kernel/Storage/Partition/DiskPartition.h @@ -25,10 +25,6 @@ public: virtual KResultOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; virtual bool can_write(const OpenFileDescription&, size_t) const override; - // ^Device - virtual mode_t required_mode() const override { return 0600; } - virtual String device_name() const override; - const DiskPartitionMetadata& metadata() const; private: diff --git a/Kernel/Storage/RamdiskDevice.cpp b/Kernel/Storage/RamdiskDevice.cpp index 0ddb4e9160..283767b148 100644 --- a/Kernel/Storage/RamdiskDevice.cpp +++ b/Kernel/Storage/RamdiskDevice.cpp @@ -55,7 +55,7 @@ void RamdiskDevice::start_request(AsyncBlockDeviceRequest& request) } } -String RamdiskDevice::device_name() const +String RamdiskDevice::storage_name() const { // FIXME: Try to not hardcode a maximum of 16 partitions per drive! size_t drive_index = minor() / 16; diff --git a/Kernel/Storage/RamdiskDevice.h b/Kernel/Storage/RamdiskDevice.h index 0767e96c89..a55c3fd026 100644 --- a/Kernel/Storage/RamdiskDevice.h +++ b/Kernel/Storage/RamdiskDevice.h @@ -26,7 +26,7 @@ public: // ^DiskDevice virtual StringView class_name() const override; - virtual String device_name() const override; + virtual String storage_name() const override; bool is_slave() const; diff --git a/Kernel/Storage/SATADiskDevice.cpp b/Kernel/Storage/SATADiskDevice.cpp index 9e7464ed4d..ff9ba79597 100644 --- a/Kernel/Storage/SATADiskDevice.cpp +++ b/Kernel/Storage/SATADiskDevice.cpp @@ -37,7 +37,7 @@ void SATADiskDevice::start_request(AsyncBlockDeviceRequest& request) m_port->start_request(request); } -String SATADiskDevice::device_name() const +String SATADiskDevice::storage_name() const { return String::formatted("hd{:c}", 'a' + minor()); } diff --git a/Kernel/Storage/SATADiskDevice.h b/Kernel/Storage/SATADiskDevice.h index 1f51eebfd8..da1755e05f 100644 --- a/Kernel/Storage/SATADiskDevice.h +++ b/Kernel/Storage/SATADiskDevice.h @@ -30,7 +30,7 @@ public: // ^StorageDevice // ^BlockDevice virtual void start_request(AsyncBlockDeviceRequest&) override; - virtual String device_name() const override; + virtual String storage_name() const override; private: SATADiskDevice(const AHCIController&, const AHCIPort&, size_t sector_size, u64 max_addressable_block); diff --git a/Kernel/Storage/StorageDevice.h b/Kernel/Storage/StorageDevice.h index 7bc2eb4e08..ce1f989018 100644 --- a/Kernel/Storage/StorageDevice.h +++ b/Kernel/Storage/StorageDevice.h @@ -29,8 +29,8 @@ public: virtual KResultOr write(OpenFileDescription&, u64, const UserOrKernelBuffer&, size_t) override; virtual bool can_write(const OpenFileDescription&, size_t) const override; - // ^Device - virtual mode_t required_mode() const override { return 0600; } + // FIXME: This is being used only during early boot, find a better way to find devices... + virtual String storage_name() const = 0; protected: StorageDevice(const StorageController&, size_t, u64); diff --git a/Kernel/Storage/StorageManagement.cpp b/Kernel/Storage/StorageManagement.cpp index fd8fa9b23a..8e2f8b9a22 100644 --- a/Kernel/Storage/StorageManagement.cpp +++ b/Kernel/Storage/StorageManagement.cpp @@ -126,15 +126,12 @@ UNMAP_AFTER_INIT void StorageManagement::determine_boot_device() { VERIFY(!m_controllers.is_empty()); if (m_boot_argument.starts_with("/dev/")) { - StringView device_name = m_boot_argument.substring_view(5); - Device::for_each([&](Device& device) { - if (device.is_block_device()) { - auto& block_device = static_cast(device); - if (device.device_name() == device_name) { - m_boot_block_device = block_device; - } + StringView storage_name = m_boot_argument.substring_view(5); + for (auto& storage_device : m_storage_devices) { + if (storage_device.storage_name() == storage_name) { + m_boot_block_device = storage_device; } - }); + } } if (m_boot_block_device.is_null()) { diff --git a/Kernel/TTY/MasterPTY.cpp b/Kernel/TTY/MasterPTY.cpp index 20b5573927..bb6ad80228 100644 --- a/Kernel/TTY/MasterPTY.cpp +++ b/Kernel/TTY/MasterPTY.cpp @@ -130,9 +130,4 @@ String MasterPTY::absolute_path(const OpenFileDescription&) const return String::formatted("ptm:{}", m_pts_name); } -String MasterPTY::device_name() const -{ - return String::formatted("{}", minor()); -} - } diff --git a/Kernel/TTY/MasterPTY.h b/Kernel/TTY/MasterPTY.h index 0763654ed6..20d87af7ba 100644 --- a/Kernel/TTY/MasterPTY.h +++ b/Kernel/TTY/MasterPTY.h @@ -28,10 +28,6 @@ public: virtual String absolute_path(const OpenFileDescription&) const override; - // ^Device - virtual mode_t required_mode() const override { return 0640; } - virtual String device_name() const override; - private: explicit MasterPTY(unsigned index, NonnullOwnPtr buffer); // ^CharacterDevice diff --git a/Kernel/TTY/PTYMultiplexer.h b/Kernel/TTY/PTYMultiplexer.h index e6cbacb925..9401f3c7e3 100644 --- a/Kernel/TTY/PTYMultiplexer.h +++ b/Kernel/TTY/PTYMultiplexer.h @@ -35,10 +35,6 @@ public: void notify_master_destroyed(Badge, unsigned index); - // ^Device - virtual mode_t required_mode() const override { return 0666; } - virtual String device_name() const override { return "ptmx"; } - private: // ^CharacterDevice virtual StringView class_name() const override { return "PTYMultiplexer"; } diff --git a/Kernel/TTY/SlavePTY.cpp b/Kernel/TTY/SlavePTY.cpp index c25c6bef0b..5a4e63ef96 100644 --- a/Kernel/TTY/SlavePTY.cpp +++ b/Kernel/TTY/SlavePTY.cpp @@ -107,11 +107,6 @@ KResult SlavePTY::close() return KSuccess; } -String SlavePTY::device_name() const -{ - return String::formatted("{}", minor()); -} - FileBlockerSet& SlavePTY::blocker_set() { return m_master->blocker_set(); diff --git a/Kernel/TTY/SlavePTY.h b/Kernel/TTY/SlavePTY.h index 438ed87209..d4dd4d8e7d 100644 --- a/Kernel/TTY/SlavePTY.h +++ b/Kernel/TTY/SlavePTY.h @@ -38,9 +38,6 @@ private: virtual StringView class_name() const override { return "SlavePTY"; } virtual KResult close() override; - // ^Device - virtual String device_name() const override; - friend class MasterPTY; SlavePTY(MasterPTY&, unsigned index); diff --git a/Kernel/TTY/TTY.h b/Kernel/TTY/TTY.h index 60a4b9579c..87b5bc5f40 100644 --- a/Kernel/TTY/TTY.h +++ b/Kernel/TTY/TTY.h @@ -49,9 +49,6 @@ public: void set_default_termios(); void hang_up(); - // ^Device - virtual mode_t required_mode() const override { return 0620; } - protected: virtual KResultOr on_tty_write(const UserOrKernelBuffer&, size_t) = 0; void set_size(unsigned short columns, unsigned short rows); diff --git a/Kernel/TTY/VirtualConsole.cpp b/Kernel/TTY/VirtualConsole.cpp index 6e36145290..69935ad69a 100644 --- a/Kernel/TTY/VirtualConsole.cpp +++ b/Kernel/TTY/VirtualConsole.cpp @@ -359,11 +359,6 @@ void VirtualConsole::set_cursor_style(VT::CursorStyle) // Do nothing } -String VirtualConsole::device_name() const -{ - return String::formatted("tty{}", minor()); -} - void VirtualConsole::echo(u8 ch) { m_console_impl.on_input(ch); diff --git a/Kernel/TTY/VirtualConsole.h b/Kernel/TTY/VirtualConsole.h index 0aa58d1402..7f1e17db96 100644 --- a/Kernel/TTY/VirtualConsole.h +++ b/Kernel/TTY/VirtualConsole.h @@ -107,9 +107,6 @@ private: // ^CharacterDevice virtual StringView class_name() const override { return "VirtualConsole"; } - // ^Device - virtual String device_name() const override; - void set_active(bool); void flush_dirty_lines();