1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:58:12 +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

@ -38,7 +38,7 @@ struct InodeMetadata {
bool may_write(const Process&) const;
bool may_execute(const Process&) const;
bool may_read(uid_t u, gid_t g, Span<const gid_t> eg) const
bool may_read(UserID u, GroupID g, Span<GroupID const> eg) const
{
if (u == 0)
return true;
@ -49,7 +49,7 @@ struct InodeMetadata {
return mode & S_IROTH;
}
bool may_write(uid_t u, gid_t g, Span<const gid_t> eg) const
bool may_write(UserID u, GroupID g, Span<GroupID const> eg) const
{
if (u == 0)
return true;
@ -60,7 +60,7 @@ struct InodeMetadata {
return mode & S_IWOTH;
}
bool may_execute(uid_t u, gid_t g, Span<const gid_t> eg) const
bool may_execute(UserID u, GroupID g, Span<GroupID const> eg) const
{
if (u == 0)
return true;
@ -91,8 +91,8 @@ struct InodeMetadata {
buffer.st_ino = inode.index().value();
buffer.st_mode = mode;
buffer.st_nlink = link_count;
buffer.st_uid = uid;
buffer.st_gid = gid;
buffer.st_uid = uid.value();
buffer.st_gid = gid.value();
buffer.st_dev = 0; // FIXME
buffer.st_size = size;
buffer.st_blksize = block_size;
@ -109,8 +109,8 @@ struct InodeMetadata {
InodeIdentifier inode;
off_t size { 0 };
mode_t mode { 0 };
uid_t uid { 0 };
gid_t gid { 0 };
UserID uid { 0 };
GroupID gid { 0 };
nlink_t link_count { 0 };
time_t atime { 0 };
time_t ctime { 0 };