From: Tulio A M Mendes Date: Thu, 12 Feb 2026 04:05:00 +0000 (-0300) Subject: feat: flock() syscall (87) — advisory file locking no-op stub + ulibc wrapper X-Git-Url: https://projects.tadryanom.me/sitemap.xml?a=commitdiff_plain;h=85480faf9a155ccc280b817f5cfa76eafe082837;p=AdrOS.git feat: flock() syscall (87) — advisory file locking no-op stub + ulibc wrapper --- diff --git a/include/syscall.h b/include/syscall.h index 9f16ebc..33d63ba 100644 --- a/include/syscall.h +++ b/include/syscall.h @@ -110,6 +110,7 @@ enum { SYSCALL_TIMES = 84, SYSCALL_FUTEX = 85, SYSCALL_SIGALTSTACK = 86, + SYSCALL_FLOCK = 87, }; #endif diff --git a/src/kernel/syscall.c b/src/kernel/syscall.c index c2940b7..b876c4e 100644 --- a/src/kernel/syscall.c +++ b/src/kernel/syscall.c @@ -2272,6 +2272,16 @@ void syscall_handler(struct registers* regs) { return; } + if (syscall_no == SYSCALL_FLOCK) { + int fd = (int)regs->ebx; + if (!current_process || fd < 0 || fd >= PROCESS_MAX_FILES || !current_process->files[fd]) { + regs->eax = (uint32_t)-EBADF; + } else { + regs->eax = 0; /* advisory lock — no-op stub */ + } + return; + } + if (syscall_no == SYSCALL_SIGALTSTACK || syscall_no == SYSCALL_TIMES || syscall_no == SYSCALL_FUTEX) { posix_ext_syscall_dispatch(regs, syscall_no); diff --git a/user/ulibc/include/syscall.h b/user/ulibc/include/syscall.h index 568e79f..f322fdd 100644 --- a/user/ulibc/include/syscall.h +++ b/user/ulibc/include/syscall.h @@ -69,6 +69,7 @@ enum { SYS_TIMES = 84, SYS_FUTEX = 85, SYS_SIGALTSTACK = 86, + SYS_FLOCK = 87, }; /* Raw syscall wrappers — up to 5 args via INT 0x80 */ diff --git a/user/ulibc/include/unistd.h b/user/ulibc/include/unistd.h index e2bb132..e993417 100644 --- a/user/ulibc/include/unistd.h +++ b/user/ulibc/include/unistd.h @@ -43,6 +43,11 @@ int setgid(int gid); int truncate(const char* path, int length); int ftruncate(int fd, int length); unsigned int alarm(unsigned int seconds); +#define LOCK_SH 1 +#define LOCK_EX 2 +#define LOCK_UN 8 +#define LOCK_NB 4 +int flock(int fd, int operation); void* brk(void* addr); void _exit(int status) __attribute__((noreturn)); diff --git a/user/ulibc/src/unistd.c b/user/ulibc/src/unistd.c index 609de9f..8d6294c 100644 --- a/user/ulibc/src/unistd.c +++ b/user/ulibc/src/unistd.c @@ -126,6 +126,10 @@ unsigned int alarm(unsigned int seconds) { return (unsigned int)_syscall1(SYS_ALARM, (int)seconds); } +int flock(int fd, int operation) { + return __syscall_ret(_syscall2(SYS_FLOCK, fd, operation)); +} + void* brk(void* addr) { return (void*)_syscall1(SYS_BRK, (int)addr); }