1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:57:44 +00:00

Kernel: Make O_RDONLY non-zero

Sergey suggested that having a non-zero O_RDONLY would make some things
less confusing, and it seems like he's right about that.

We can now easily check read/write permissions separately instead of
dancing around with the bits.

This patch also fixes unveil() validation for O_RDWR which previously
forgot to check for "r" permission.
This commit is contained in:
Andreas Kling 2020-01-21 13:14:26 +01:00
parent efbd1620d9
commit 6081c76515
6 changed files with 24 additions and 33 deletions

View file

@ -59,16 +59,8 @@ public:
void set_rw_mode(int options)
{
if (options & O_WRONLY) {
set_readable(false);
set_writable(true);
} else if (options & O_RDWR) {
set_readable(true);
set_writable(true);
} else {
set_readable(true);
set_writable(false);
}
set_readable(options & O_RDONLY);
set_writable(options & O_WRONLY);
}
int close();