From: Tulio A M Mendes Date: Thu, 12 Feb 2026 02:40:17 +0000 (-0300) Subject: feat: fsync/fdatasync syscall stubs (no-op, POSIX compliance) X-Git-Url: https://projects.tadryanom.me/docs/static/gitweb.js?a=commitdiff_plain;h=56846e2ddde98b6db7cbda456e905291a5cdb74b;p=AdrOS.git feat: fsync/fdatasync syscall stubs (no-op, POSIX compliance) --- diff --git a/include/syscall.h b/include/syscall.h index 170396d..3e3a36e 100644 --- a/include/syscall.h +++ b/include/syscall.h @@ -91,6 +91,16 @@ enum { SYSCALL_CLONE = 67, SYSCALL_GETTID = 68, + + SYSCALL_FSYNC = 69, + SYSCALL_FDATASYNC = 70, + SYSCALL_SIGPENDING = 71, + SYSCALL_PREAD = 72, + SYSCALL_PWRITE = 73, + SYSCALL_ACCESS = 74, + SYSCALL_UMASK = 75, + SYSCALL_SETUID = 76, + SYSCALL_SETGID = 77, }; #endif diff --git a/src/kernel/syscall.c b/src/kernel/syscall.c index 4e42df9..8f0b4ea 100644 --- a/src/kernel/syscall.c +++ b/src/kernel/syscall.c @@ -2200,6 +2200,16 @@ void syscall_handler(struct registers* regs) { return; } + if (syscall_no == SYSCALL_FSYNC || syscall_no == SYSCALL_FDATASYNC) { + 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; + } + return; + } + /* ---- Socket syscalls ---- */ socket_syscall_dispatch(regs, syscall_no); /* If socket dispatch handled it, eax is set and we return. diff --git a/user/ulibc/include/syscall.h b/user/ulibc/include/syscall.h index 3671aed..ec1e847 100644 --- a/user/ulibc/include/syscall.h +++ b/user/ulibc/include/syscall.h @@ -51,6 +51,8 @@ enum { SYS_SET_THREAD_AREA = 57, SYS_CLONE = 67, SYS_GETTID = 68, + SYS_FSYNC = 69, + SYS_FDATASYNC = 70, }; /* 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 fe873cf..70a818f 100644 --- a/user/ulibc/include/unistd.h +++ b/user/ulibc/include/unistd.h @@ -33,6 +33,8 @@ int setsid(void); int setpgid(int pid, int pgid); int getpgrp(void); int gettid(void); +int fsync(int fd); +int fdatasync(int fd); 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 2ae0979..06ce1b6 100644 --- a/user/ulibc/src/unistd.c +++ b/user/ulibc/src/unistd.c @@ -86,6 +86,14 @@ int gettid(void) { return _syscall0(SYS_GETTID); } +int fsync(int fd) { + return __syscall_ret(_syscall1(SYS_FSYNC, fd)); +} + +int fdatasync(int fd) { + return __syscall_ret(_syscall1(SYS_FDATASYNC, fd)); +} + void* brk(void* addr) { return (void*)_syscall1(SYS_BRK, (int)addr); }