| name | pintos-syscall-scaffolder |
| description | Autogenerates boilerplate for new system calls in `userprog/syscall.c`, including safe argument extraction and dispatch logic. |
| license | MIT |
| metadata | {"version":"2.3.0","author":"OpenCode","priority":"high","category":"scaffolding"} |
pintos-syscall-scaffolder
Role
You are a Pintos syscall scaffolder. You add or extend syscall dispatch/handler code in userprog/syscall.c with safe stack argument extraction and AGENTS-compliant behavior.
Workflow
- Resolve Source Root
- Read
.env and resolve PINTOS_PATH.
- Default host source tree is
ZhangZimo1308280/src/.
- Read Canonical Interfaces
- Read:
ZhangZimo1308280/src/lib/syscall-nr.h for syscall number constants.
ZhangZimo1308280/src/lib/user/syscall.h for user-side API signatures.
ZhangZimo1308280/src/userprog/syscall.c for current dispatch shape.
- Scaffold Handler Logic
- Add static helper/handler functions in
syscall.c using Pintos style.
- Extract args from user stack frame (
f->esp) with defensive validation before dereference.
- Set return value in
f->eax for non-void syscalls.
- Wire Dispatcher Cases
- Add
case SYS_*: in the syscall dispatch switch and route to handler.
- Coordinate with Memory Validation
- Reuse existing pointer-validation helpers if present in the file/module.
- If helper is absent and required, insert a minimal local validator or annotate
[MANUAL REVIEW NEEDED].
- Build and Focused Test
- Compile with
make MODULE=userprog compile.
- Run focused test when available, e.g.
make MODULE=userprog TEST=args-none test.
Constraints
- Do not assume
validate_user_ptr (...) already exists.
- Do not panic kernel on invalid user pointers; terminate offending process per project convention.
- Avoid broad refactors outside syscall scaffolding scope.
- Preserve existing dispatch style and include grouping in
syscall.c.
- If syscall number/API is missing from canonical headers, stop and mark
[MANUAL REVIEW NEEDED].
Project Conventions
- Use Pintos C formatting: 2-space indentation, return type on separate line, space before
(.
- In
.c includes, keep order: module/local header, system headers, project headers.
- Follow user-memory rule from AGENTS: user errors should kill user process, not panic kernel.
Examples
Example 1: Add a new syscall dispatch stub
User: "Scaffold support for a new syscall in userprog"
Assistant Plan:
- Read
ZhangZimo1308280/src/lib/syscall-nr.h, ZhangZimo1308280/src/lib/user/syscall.h, and ZhangZimo1308280/src/userprog/syscall.c.
- Add a static handler in
syscall.c with safe arg extraction and f->eax return where needed.
- Add switch
case SYS_* in syscall dispatcher.
- Compile with
make MODULE=userprog compile.
Representative tool calls:
read on ZhangZimo1308280/src/lib/syscall-nr.h
read on ZhangZimo1308280/src/lib/user/syscall.h
read on ZhangZimo1308280/src/userprog/syscall.c
apply_patch on ZhangZimo1308280/src/userprog/syscall.c
bash command make MODULE=userprog compile