summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2020-12-25 19:01:19 +0200
committerAndreas Kling <kling@serenityos.org>2020-12-27 23:07:44 +0100
commit18e77aa28535d52eb6be9c2791a6d217433b1b68 (patch)
treeb63d9024593e11667884c8d9074aeb55bc20e823
parent092a13211a4216c19c08280bd5e5803e1030f087 (diff)
downloadserenity-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.
-rw-r--r--Kernel/Console.h3
-rw-r--r--Kernel/Devices/BXVGADevice.h3
-rw-r--r--Kernel/Devices/Device.h2
-rw-r--r--Kernel/Devices/DiskPartition.h3
-rw-r--r--Kernel/Devices/FullDevice.h3
-rw-r--r--Kernel/Devices/KeyboardDevice.h3
-rw-r--r--Kernel/Devices/MBVGADevice.h3
-rw-r--r--Kernel/Devices/NullDevice.h3
-rw-r--r--Kernel/Devices/PS2MouseDevice.h3
-rw-r--r--Kernel/Devices/RandomDevice.h3
-rw-r--r--Kernel/Devices/SB16.h3
-rw-r--r--Kernel/Devices/SerialDevice.h3
-rw-r--r--Kernel/Devices/ZeroDevice.h3
-rw-r--r--Kernel/Storage/StorageDevice.h3
-rw-r--r--Kernel/TTY/MasterPTY.h3
-rw-r--r--Kernel/TTY/PTYMultiplexer.h3
-rw-r--r--Kernel/TTY/TTY.h3
17 files changed, 50 insertions, 0 deletions
diff --git a/Kernel/Console.h b/Kernel/Console.h
index c37731e4f7..55ae0f1b54 100644
--- a/Kernel/Console.h
+++ b/Kernel/Console.h
@@ -51,6 +51,9 @@ public:
const CircularQueue<char, 16384>& logbuffer() const { return m_logbuffer; }
+ // ^Device
+ virtual mode_t required_mode() const override { return 0666; }
+
private:
CircularQueue<char, 16384> m_logbuffer;
};
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;
diff --git a/Kernel/Storage/StorageDevice.h b/Kernel/Storage/StorageDevice.h
index 8cc4f8fed9..21840b4d92 100644
--- a/Kernel/Storage/StorageDevice.h
+++ b/Kernel/Storage/StorageDevice.h
@@ -53,6 +53,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; }
+
protected:
StorageDevice(const StorageController&, int, int, size_t, size_t);
// ^DiskDevice
diff --git a/Kernel/TTY/MasterPTY.h b/Kernel/TTY/MasterPTY.h
index 69ba0a16dc..7744a58cdb 100644
--- a/Kernel/TTY/MasterPTY.h
+++ b/Kernel/TTY/MasterPTY.h
@@ -48,6 +48,9 @@ public:
virtual String absolute_path(const FileDescription&) const override;
+ // ^Device
+ virtual mode_t required_mode() const override { return 0640; }
+
private:
// ^CharacterDevice
virtual KResultOr<size_t> read(FileDescription&, size_t, UserOrKernelBuffer&, size_t) override;
diff --git a/Kernel/TTY/PTYMultiplexer.h b/Kernel/TTY/PTYMultiplexer.h
index bb20469f38..9402ae1136 100644
--- a/Kernel/TTY/PTYMultiplexer.h
+++ b/Kernel/TTY/PTYMultiplexer.h
@@ -55,6 +55,9 @@ public:
void notify_master_destroyed(Badge<MasterPTY>, unsigned index);
+ // ^Device
+ virtual mode_t required_mode() const override { return 0666; }
+
private:
// ^CharacterDevice
virtual const char* class_name() const override { return "PTYMultiplexer"; }
diff --git a/Kernel/TTY/TTY.h b/Kernel/TTY/TTY.h
index 8ba84a0dc6..a60526078c 100644
--- a/Kernel/TTY/TTY.h
+++ b/Kernel/TTY/TTY.h
@@ -67,6 +67,9 @@ public:
void set_default_termios();
void hang_up();
+ // ^Device
+ virtual mode_t required_mode() const override { return 0620; }
+
protected:
virtual ssize_t on_tty_write(const UserOrKernelBuffer&, ssize_t) = 0;
void set_size(unsigned short columns, unsigned short rows);