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/?a=commitdiff_plain;h=51ecbb961109a7111e3119ae15c27aea52d70e1e;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 b8380e48..5ed6cf6d 100644 --- a/include/syscall.h +++ b/include/syscall.h @@ -119,6 +119,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 e346592c..bb27741c 100644 --- a/src/kernel/syscall.c +++ b/src/kernel/syscall.c @@ -2281,6 +2281,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 51ec5a77..9c0cfaf2 100644 --- a/user/ulibc/include/syscall.h +++ b/user/ulibc/include/syscall.h @@ -78,6 +78,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 6b480f84..2d170c09 100644 --- a/user/ulibc/include/unistd.h +++ b/user/ulibc/include/unistd.h @@ -52,6 +52,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 7ffeb054..c6a37787 100644 --- a/user/ulibc/src/unistd.c +++ b/user/ulibc/src/unistd.c @@ -135,6 +135,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); }