feat: make userspace StatusCodes positive; print status text along with code in shell exec; make init return BadInvocation on faulty launch

This commit is contained in:
daniel committed 2026-09-30 16:21:32 +02:00
1 parent 8a3ffb2be1
commit 5e4e8902c2
6 files changed
+96 -41

No files matched your search

+6 -17
View File
@@ -4,7 +4,6 @@
#
# Source of truth : programs/include/Api/Syscall.hpp (montauk::abi::SYS_*)
# kernel/src/Common/StatusCodes.hpp (enum StatusCodes)
# Mirrors : programs/include/montauk/statuscodes.h (must match exactly)
# Generated blocks: programs/include/libc/montauk.h (#define MTK_SYS_*,
# #define MTK_STATUS_*)
#
@@ -16,13 +15,11 @@
#
# Usage:
# montauk-syscalls.py check Verify every SYS_* has a matching MTK_SYS_* with
# the same number, and that both status code
# mirrors match the kernel enum. Exits non-zero on
# any drift. Run from the build so stale headers
# fail loudly.
# the same number, and that MTK_STATUS_* matches
# the kernel enum. Exits non-zero on any drift.
# Run from the build so stale headers fail loudly.
# montauk-syscalls.py gen Rewrite the MTK_SYS_* and MTK_STATUS_* blocks in
# montauk.h (numbers only; wrappers untouched).
# statuscodes.h is not generated; fix it by hand.
import os
import re
@@ -33,7 +30,6 @@ REPO_ROOT = os.path.dirname(SCRIPT_DIR)
ABI_HDR = os.path.join(REPO_ROOT, "programs/include/Api/Syscall.hpp")
C_HDR = os.path.join(REPO_ROOT, "programs/include/libc/montauk.h")
STATUS_HDR = os.path.join(REPO_ROOT, "kernel/src/Common/StatusCodes.hpp")
STATUS_MIRROR = os.path.join(REPO_ROOT, "programs/include/montauk/statuscodes.h")
BEGIN_MARKER = "/* @SYSCALLS-BEGIN"
END_MARKER = "/* @SYSCALLS-END */"
@@ -91,16 +87,9 @@ def status_macro(name):
def check_status(c_text):
"""Print drift between the kernel enum and its two mirrors; return count."""
"""Print drift between the kernel enum and MTK_STATUS_*; return count."""
canon = parse_status(STATUS_HDR)
problems = 0
mirror = parse_status(STATUS_MIRROR)
if mirror != canon:
problems += 1
print("montauk-syscalls: DRIFT between Common/StatusCodes.hpp and "
"montauk/statuscodes.h", file=sys.stderr)
print(" kernel: %s" % canon, file=sys.stderr)
print(" mirror: %s" % mirror, file=sys.stderr)
want = {status_macro(n): v for n, v in canon}
have = {n: int(v) for n, v in STATUS_DEF_RE.findall(c_text)}
if want != have:
@@ -132,8 +121,8 @@ def cmd_check():
status_problems = check_status(c_text)
if not (missing or mismatched or extra):
if status_problems:
print("\n Run 'make gen-syscalls' to regenerate MTK_STATUS_*; "
"montauk/statuscodes.h is fixed by hand.", file=sys.stderr)
print("\n Run 'make gen-syscalls' to regenerate MTK_STATUS_*.",
file=sys.stderr)
return 1
print("montauk-syscalls: OK (%d syscalls, %d status codes in sync)"
% (len(abi), len(parse_status(STATUS_HDR))))