]> 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)
commit16573e8a8d2e248ae40e179d4447d8b6488e941d
tree2b9de6d2a75298b46da374d84610b4d6abb21108
parentd72bf3598ea1b91b4ad8c3f272902922585ca35d
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]