]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
feat: fcntl record locking (F_GETLK/F_SETLK/F_SETLKW) + F_DUPFD_CLOEXEC
authorTulio A M Mendes <[email protected]>
Sat, 14 Feb 2026 00:23:03 +0000 (21:23 -0300)
committerTulio A M Mendes <[email protected]>
Sat, 14 Feb 2026 00:23:03 +0000 (21:23 -0300)
commit29c1545418d399f76c894c123d648d0d254a85ec
tree6a33af40a1b4bf4e14411cd49c1ab77802974eea
parent7aedd44754ef8b6da6f3165cc6a6048425fc5dec
feat: fcntl record locking (F_GETLK/F_SETLK/F_SETLKW) + F_DUPFD_CLOEXEC

POSIX byte-range advisory record locking via fcntl():

- syscall.c: rlock_table (64 entries) with spinlock-protected byte-range
  lock management supporting F_RDLCK (shared), F_WRLCK (exclusive), F_UNLCK
- rlock_conflicts(): detects overlapping conflicting locks from other pids
- rlock_setlk(): acquires/releases byte-range locks with optional blocking
- rlock_release_pid(): releases all record locks on process exit
- F_GETLK: returns conflicting lock info or F_UNLCK if no conflict
- F_SETLK: non-blocking lock acquisition (returns EAGAIN on conflict)
- F_SETLKW: blocking lock acquisition (sleeps until lock available)
- F_DUPFD_CLOEXEC: dup fd with close-on-exec flag set

Userland:
- fcntl.h: expanded with F_GETLK/F_SETLK/F_SETLKW, F_DUPFD_CLOEXEC,
  FD_CLOEXEC, O_CLOEXEC, F_RDLCK/F_WRLCK/F_UNLCK, struct flock

This completes the file locking infrastructure needed by SQLite and
POSIX-compliant applications.

20/20 smoke tests pass.
src/kernel/syscall.c
user/ulibc/include/fcntl.h