diff options
author | Liav A <liavalb@gmail.com> | 2020-12-25 19:01:19 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-27 23:07:44 +0100 |
commit | 18e77aa28535d52eb6be9c2791a6d217433b1b68 (patch) | |
tree | b63d9024593e11667884c8d9074aeb55bc20e823 /Kernel/Devices | |
parent | 092a13211a4216c19c08280bd5e5803e1030f087 (diff) | |
download | serenity-18e77aa28535d52eb6be9c2791a6d217433b1b68.zip |
Kernel: Add a method to determine the desired permissions of a Device
This method will be used later in DevFS, to set the appropriate
permissions for each device node.
Diffstat (limited to 'Kernel/Devices')
-rw-r--r-- | Kernel/Devices/BXVGADevice.h | 3 | ||||
-rw-r--r-- | Kernel/Devices/Device.h | 2 | ||||
-rw-r--r-- | Kernel/Devices/DiskPartition.h | 3 | ||||
-rw-r--r-- | Kernel/Devices/FullDevice.h | 3 | ||||
-rw-r--r-- | Kernel/Devices/KeyboardDevice.h | 3 | ||||
-rw-r--r-- | Kernel/Devices/MBVGADevice.h | 3 | ||||
-rw-r--r-- | Kernel/Devices/NullDevice.h | 3 | ||||
-rw-r--r-- | Kernel/Devices/PS2MouseDevice.h | 3 | ||||
-rw-r--r-- | Kernel/Devices/RandomDevice.h | 3 | ||||
-rw-r--r-- | Kernel/Devices/SB16.h | 3 | ||||
-rw-r--r-- | Kernel/Devices/SerialDevice.h | 3 | ||||
-rw-r--r-- | Kernel/Devices/ZeroDevice.h | 3 |
12 files changed, 35 insertions, 0 deletions
diff --git a/Kernel/Devices/BXVGADevice.h b/Kernel/Devices/BXVGADevice.h index de3f4bfd72..9c24c107da 100644 --- a/Kernel/Devices/BXVGADevice.h +++ b/Kernel/Devices/BXVGADevice.h @@ -44,6 +44,9 @@ public: virtual int ioctl(FileDescription&, unsigned request, FlatPtr arg) override; virtual KResultOr<Region*> mmap(Process&, FileDescription&, VirtualAddress preferred_vaddr, size_t offset, size_t, int prot, bool shared) override; + // ^Device + virtual mode_t required_mode() const override { return 0660; } + private: virtual const char* class_name() const override { return "BXVGA"; } virtual bool can_read(const FileDescription&, size_t) const override { return true; } diff --git a/Kernel/Devices/Device.h b/Kernel/Devices/Device.h index 80a63e22a8..1ef8bcfa89 100644 --- a/Kernel/Devices/Device.h +++ b/Kernel/Devices/Device.h @@ -57,6 +57,8 @@ public: uid_t uid() const { return m_uid; } uid_t gid() const { return m_gid; } + virtual mode_t required_mode() const = 0; + virtual bool is_device() const override { return true; } virtual bool is_disk_device() const { return false; } diff --git a/Kernel/Devices/DiskPartition.h b/Kernel/Devices/DiskPartition.h index 7d37354960..acd9547c9a 100644 --- a/Kernel/Devices/DiskPartition.h +++ b/Kernel/Devices/DiskPartition.h @@ -44,6 +44,9 @@ public: virtual KResultOr<size_t> write(FileDescription&, size_t, const UserOrKernelBuffer&, size_t) override; virtual bool can_write(const FileDescription&, size_t) const override; + // ^Device + virtual mode_t required_mode() const override { return 0600; } + private: virtual const char* class_name() const override; diff --git a/Kernel/Devices/FullDevice.h b/Kernel/Devices/FullDevice.h index 43070686c1..8c7a9668d7 100644 --- a/Kernel/Devices/FullDevice.h +++ b/Kernel/Devices/FullDevice.h @@ -36,6 +36,9 @@ public: FullDevice(); virtual ~FullDevice() override; + // ^Device + virtual mode_t required_mode() const override { return 0600; } + private: // ^CharacterDevice virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override; diff --git a/Kernel/Devices/KeyboardDevice.h b/Kernel/Devices/KeyboardDevice.h index 4e943bf298..ba1749e82d 100644 --- a/Kernel/Devices/KeyboardDevice.h +++ b/Kernel/Devices/KeyboardDevice.h @@ -74,6 +74,9 @@ public: enable_irq(); } + // ^Device + virtual mode_t required_mode() const override { return 0440; } + private: // ^IRQHandler virtual void handle_irq(const RegisterState&) override; diff --git a/Kernel/Devices/MBVGADevice.h b/Kernel/Devices/MBVGADevice.h index 9ee9d762ae..16685cc9a4 100644 --- a/Kernel/Devices/MBVGADevice.h +++ b/Kernel/Devices/MBVGADevice.h @@ -43,6 +43,9 @@ public: virtual int ioctl(FileDescription&, unsigned request, FlatPtr arg) override; virtual KResultOr<Region*> mmap(Process&, FileDescription&, VirtualAddress preferred_vaddr, size_t offset, size_t, int prot, bool shared) override; + // ^Device + virtual mode_t required_mode() const override { return 0660; } + private: virtual const char* class_name() const override { return "MBVGA"; } virtual bool can_read(const FileDescription&, size_t) const override { return true; } diff --git a/Kernel/Devices/NullDevice.h b/Kernel/Devices/NullDevice.h index 4fcc9c0258..11e98b567c 100644 --- a/Kernel/Devices/NullDevice.h +++ b/Kernel/Devices/NullDevice.h @@ -39,6 +39,9 @@ public: static void initialize(); static NullDevice& the(); + // ^Device + virtual mode_t required_mode() const override { return 0666; } + private: // ^CharacterDevice virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override; diff --git a/Kernel/Devices/PS2MouseDevice.h b/Kernel/Devices/PS2MouseDevice.h index 386e690f09..a0e0eb0db5 100644 --- a/Kernel/Devices/PS2MouseDevice.h +++ b/Kernel/Devices/PS2MouseDevice.h @@ -61,6 +61,9 @@ public: enable_irq(); } + // ^Device + virtual mode_t required_mode() const override { return 0440; } + private: // ^IRQHandler void handle_vmmouse_absolute_pointer(); diff --git a/Kernel/Devices/RandomDevice.h b/Kernel/Devices/RandomDevice.h index c419934107..fbf5bbaf7b 100644 --- a/Kernel/Devices/RandomDevice.h +++ b/Kernel/Devices/RandomDevice.h @@ -36,6 +36,9 @@ public: RandomDevice(); virtual ~RandomDevice() override; + // ^Device + virtual mode_t required_mode() const override { return 0666; } + private: // ^CharacterDevice virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override; diff --git a/Kernel/Devices/SB16.h b/Kernel/Devices/SB16.h index c780618d62..5c0df448f2 100644 --- a/Kernel/Devices/SB16.h +++ b/Kernel/Devices/SB16.h @@ -53,6 +53,9 @@ public: virtual const char* purpose() const override { return class_name(); } + // ^Device + virtual mode_t required_mode() const override { return 0220; } + private: // ^IRQHandler virtual void handle_irq(const RegisterState&) override; diff --git a/Kernel/Devices/SerialDevice.h b/Kernel/Devices/SerialDevice.h index 5c76f5abdf..fb5785284c 100644 --- a/Kernel/Devices/SerialDevice.h +++ b/Kernel/Devices/SerialDevice.h @@ -123,6 +123,9 @@ public: DataReady = 0x01 << 0 }; + // ^Device + virtual mode_t required_mode() const override { return 0620; } + private: // ^CharacterDevice virtual const char* class_name() const override { return "SerialDevice"; } diff --git a/Kernel/Devices/ZeroDevice.h b/Kernel/Devices/ZeroDevice.h index f307c6f645..8140174e16 100644 --- a/Kernel/Devices/ZeroDevice.h +++ b/Kernel/Devices/ZeroDevice.h @@ -36,6 +36,9 @@ public: ZeroDevice(); virtual ~ZeroDevice() override; + // ^Device + virtual mode_t required_mode() const override { return 0666; } + private: // ^CharacterDevice virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override; |