1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:18:12 +00:00

Kernel+LibC: Implement fcntl(2) advisory locks

Advisory locks don't actually prevent other processes from writing to
the file, but they do prevent other processes looking to acquire and
advisory lock on the file.

This implementation currently only adds non-blocking locks, which are
all I need for now.
This commit is contained in:
Peter Elliott 2021-07-18 23:29:56 -06:00 committed by Ali Mohammad Pur
parent fbc56461da
commit 3fa2816642
8 changed files with 186 additions and 7 deletions

View file

@ -43,6 +43,10 @@ KResultOr<FlatPtr> Process::sys$fcntl(int fd, int cmd, u32 arg)
break;
case F_ISTTY:
return description->is_tty();
case F_GETLK:
return description->get_flock(Userspace<flock*>(arg));
case F_SETLK:
return description->apply_flock(*Process::current(), Userspace<const flock*>(arg));
default:
return EINVAL;
}