]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
feat: real advisory file locking (flock) replacing no-op stub
authorTulio A M Mendes <[email protected]>
Sat, 14 Feb 2026 00:02:38 +0000 (21:02 -0300)
committerTulio A M Mendes <[email protected]>
Sat, 14 Feb 2026 00:02:38 +0000 (21:02 -0300)
commit7aedd44754ef8b6da6f3165cc6a6048425fc5dec
tree3e98e97c144d60ee2bc86b9709c6d9b2a5d1421b
parent7821d4365f4009534fb21229c4116efd147e3c5c
feat: real advisory file locking (flock) replacing no-op stub

- syscall.c: implemented flock_table (64 entries) with spinlock-protected
  advisory locking supporting LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB
- flock_do(): handles shared/exclusive acquisition with conflict detection,
  upgrade/downgrade of existing locks, blocking retry via process_sleep
- flock_release_pid(): releases all locks for a process on exit
- SYSCALL_EXIT: calls flock_release_pid before closing files
- errno.h: added ENOLCK=37, EWOULDBLOCK=EAGAIN (kernel + userland)
- sys/file.h: new userland header with LOCK_SH/EX/NB/UN defines

Previously flock() was a silent no-op returning 0. Now it provides
real advisory locking semantics needed by SQLite and daemons.

20/20 smoke tests pass.
include/errno.h
src/kernel/syscall.c
user/ulibc/include/errno.h
user/ulibc/include/sys/file.h [new file with mode: 0644]