Project 4: Add a Custom System Call
A new system call,
uname_set_hostname, that allows a process (like a user-space utility) to change the system’s hostname. You will implement the syscall in the kernel and a utility to call it.
Quick Reference
| Attribute | Value |
|---|---|
| Primary Language | C++ |
| Alternative Languages | N/A |
| Difficulty | Level 3: Advanced |
| Time Estimate | 1-2 weeks |
| Knowledge Area | Kernel Development / System Calls |
| Tooling | SerenityOS Kernel |
| Prerequisites | Projects 1 & 3, solid C++ understanding, conceptual knowledge of what an OS kernel is. |
What You Will Build
A new system call, uname_set_hostname, that allows a process (like a user-space utility) to change the system’s hostname. You will implement the syscall in the kernel and a utility to call it.
Why It Matters
This project builds core skills that appear repeatedly in real-world systems and tooling.
Core Challenges
- Defining a new syscall → maps to modifying the
Syscall.tblfile and kernel headers - Implementing the syscall handler → maps to writing C++ code inside the
Kerneldirectory - Safely copying data from user-space → maps to understanding pointers and memory protection
- Calling the syscall from a user-space program → maps to using the
syscall()wrapper
Key Concepts
- Syscall Dispatch:
Kernel/Syscall/handlers.cpp - User/Kernel Boundary: “Operating Systems: Three Easy Pieces” Ch. 6
- Kernel Data Structures:
Kernel/utsname.hfor the hostname storage.
Real-World Outcome
Deliver a working demo with observable output that proves the feature is correct.
Implementation Guide
- Reproduce the simplest happy-path scenario.
- Build the smallest working version of the core feature.
- Add input validation and error handling.
- Add instrumentation/logging to confirm behavior.
- Refactor into clean modules with tests.
Milestones
- Milestone 1: Minimal working program that runs end-to-end.
- Milestone 2: Correct outputs for typical inputs.
- Milestone 3: Robust handling of edge cases.
- Milestone 4: Clean structure and documented usage.
Validation Checklist
- Output matches the real-world outcome example
- Handles invalid inputs safely
- Provides clear errors and exit codes
- Repeatable results across runs
References
- Main guide:
LEARN_SERENITYOS_DEEP_DIVE.md - “Operating Systems: Three Easy Pieces” by Arpaci-Dusseau