diff --git a/os/StarryOS/kernel/src/syscall/mod.rs b/os/StarryOS/kernel/src/syscall/mod.rs index f3ca2cc7bd..f2deb697ea 100644 --- a/os/StarryOS/kernel/src/syscall/mod.rs +++ b/os/StarryOS/kernel/src/syscall/mod.rs @@ -879,12 +879,16 @@ pub fn handle_syscall(uctx: &mut UserContext) { uctx.arg3() as _, ), + // The new mount API (fsopen/fsconfig/fsmount/move_mount, plus + // fspick/open_tree) is not implemented. Report ENOSYS instead of + // handing back a dummy fd: systemd probes this API and only falls back + // to the classic mount(2) — which we do support — when the entry point + // reports "not supported". A fake fd traps it into the new path, where + // the follow-up fsconfig then hard-fails and aborts the mount. + Sysno::fsopen | Sysno::fspick | Sysno::open_tree => Err(AxError::Unsupported), + // dummy fds - Sysno::userfaultfd - | Sysno::fsopen - | Sysno::fspick - | Sysno::open_tree - | Sysno::memfd_secret => sys_dummy_fd(sysno), + Sysno::userfaultfd | Sysno::memfd_secret => sys_dummy_fd(sysno), Sysno::bpf => crate::ebpf::sys_bpf(uctx.arg0() as _, uctx.arg1(), uctx.arg2() as _), Sysno::perf_event_open => crate::perf::sys_perf_event_open( diff --git a/test-suit/starryos/qemu-smp1/system/bugfix-bug-mount-api-enosys/CMakeLists.txt b/test-suit/starryos/qemu-smp1/system/bugfix-bug-mount-api-enosys/CMakeLists.txt new file mode 100644 index 0000000000..44a1589714 --- /dev/null +++ b/test-suit/starryos/qemu-smp1/system/bugfix-bug-mount-api-enosys/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.20) + +project(bug-new-mount-api-enosys C) + +set(CMAKE_C_STANDARD 11) +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_C_EXTENSIONS OFF) + +add_executable(bug-new-mount-api-enosys src/main.c) +target_compile_options(bug-new-mount-api-enosys PRIVATE -Wall -Wextra -Werror) + +install(TARGETS bug-new-mount-api-enosys RUNTIME DESTINATION usr/bin/starry-test-suit) diff --git a/test-suit/starryos/qemu-smp1/system/bugfix-bug-mount-api-enosys/src/main.c b/test-suit/starryos/qemu-smp1/system/bugfix-bug-mount-api-enosys/src/main.c new file mode 100644 index 0000000000..7e3252b064 --- /dev/null +++ b/test-suit/starryos/qemu-smp1/system/bugfix-bug-mount-api-enosys/src/main.c @@ -0,0 +1,70 @@ +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include + +#ifndef SYS_open_tree +#define SYS_open_tree 428 +#endif +#ifndef SYS_fsopen +#define SYS_fsopen 430 +#endif +#ifndef SYS_fspick +#define SYS_fspick 433 +#endif + +static int passed; +static int failed; + +static void check(int condition, const char *message) +{ + if (condition) { + ++passed; + printf("PASS: %s\n", message); + } else { + ++failed; + printf("FAIL: %s\n", message); + } +} + +static void expect_enosys(const char *name, long ret, int saved_errno) +{ + char message[128]; + + snprintf(message, sizeof(message), "%s fails with ENOSYS", name); + check(ret == -1 && saved_errno == ENOSYS, message); + if (ret >= 0) { + printf("INFO: %s unexpectedly returned fd %ld\n", name, ret); + close((int)ret); + } else if (saved_errno != ENOSYS) { + printf("INFO: %s errno: %s\n", name, strerror(saved_errno)); + } +} + +int main(void) +{ + long ret; + + errno = 0; + ret = syscall(SYS_fsopen, "tmpfs", 0); + expect_enosys("fsopen", ret, errno); + + errno = 0; + ret = syscall(SYS_fspick, AT_FDCWD, "/", 0); + expect_enosys("fspick", ret, errno); + + errno = 0; + ret = syscall(SYS_open_tree, AT_FDCWD, "/", 0); + expect_enosys("open_tree", ret, errno); + + printf("RESULT: %d passed / %d failed\n", passed, failed); + if (failed == 0) { + printf("TEST PASSED\n"); + return 0; + } + return 1; +}