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

Kernel: Strongly typed user & group ID's

Prior to this change, both uid_t and gid_t were typedef'ed to `u32`.
This made it easy to use them interchangeably. Let's not allow that.

This patch adds UserID and GroupID using the AK::DistinctNumeric
mechanism we've already been employing for pid_t/ProcessID.
This commit is contained in:
Andreas Kling 2021-08-28 22:11:16 +02:00
parent 59335bd8ea
commit ae197deb6b
44 changed files with 172 additions and 169 deletions

View file

@ -34,8 +34,8 @@ public:
virtual String absolute_path(const FileDescription&) const override;
virtual String absolute_path() const;
uid_t uid() const { return m_uid; }
uid_t gid() const { return m_gid; }
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;
@ -62,16 +62,16 @@ public:
protected:
Device(unsigned major, unsigned minor);
void set_uid(uid_t uid) { m_uid = uid; }
void set_gid(gid_t gid) { m_gid = gid; }
void set_uid(UserID uid) { m_uid = uid; }
void set_gid(GroupID gid) { m_gid = gid; }
static HashMap<u32, Device*>& all_devices();
private:
unsigned m_major { 0 };
unsigned m_minor { 0 };
uid_t m_uid { 0 };
gid_t m_gid { 0 };
UserID m_uid { 0 };
GroupID m_gid { 0 };
Spinlock<u8> m_requests_lock;
DoublyLinkedList<RefPtr<AsyncDeviceRequest>> m_requests;