Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions os/StarryOS/kernel/src/syscall/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#define _GNU_SOURCE

#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/syscall.h>
#include <unistd.h>

#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;
}