include: one folder per subsystem, and includes that name it
Sixty-five headers sat side by side in include/, so `#include "irq.h"` said nothing about where irq.h was or what it belonged to, and errno.h, stat.h and fcntl.h at the top shadowed the system's for any host tool built with -I./include. They are in folders now -- arch/ core/ fs/ dev/ gfx/ net/ uapi/ (and ldls/ for the Linux driver layer) -- and every include names the folder, as Linux's do: "core/proc.h". Done mechanically and checked the hard way: the kernel built from this tree disassembles identically to the one built from the tree before it. The full image boots, and userland is the same set of programs. Paths in docs and comments follow; docs/guides/layout.md has a table of what is where, and tools/fix-includes.py rewrites old-style includes from the folders in the tree, for code written before this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S1giNvrHTrPMPw7V6x1kQ4
This commit is contained in:
parent
0e39e711f1
commit
a1c965da1e
267 changed files with 1560 additions and 1440 deletions
|
|
@ -27,10 +27,10 @@
|
|||
// Whatever the modifiers are, they also bind minus and equals to the previous
|
||||
// and next terminal in use -- AltGr+- and AltGr+= by default.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "fcntl.h"
|
||||
#include "posix.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/fcntl.h"
|
||||
#include "uapi/posix.h"
|
||||
|
||||
// No printf in lib/, and this needs one string and two small numbers.
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@
|
|||
// if it is the other way round, the reverse. Having both makes a failure say
|
||||
// which half broke.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "fcntl.h"
|
||||
#include "fb.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/fcntl.h"
|
||||
#include "gfx/fb.h"
|
||||
|
||||
#include "posix.h" /* PROT_*, MAP_* -- one definition, shared */
|
||||
#include "uapi/posix.h" /* PROT_*, MAP_* -- one definition, shared */
|
||||
|
||||
static void
|
||||
puts(const char *s)
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@
|
|||
// **The path check is the only security-relevant code here**, and it is done
|
||||
// by rejecting rather than by normalising. See resolve() below.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "fcntl.h"
|
||||
#include "stat.h"
|
||||
#include "socket.h"
|
||||
#include "posix.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/fcntl.h"
|
||||
#include "uapi/stat.h"
|
||||
#include "net/socket.h"
|
||||
#include "uapi/posix.h"
|
||||
|
||||
#define DEFAULT_PORT 80
|
||||
#define DEFAULT_ROOT "/srv"
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@
|
|||
// kernel does not publish them), and the MSDM and SLIC tables, which hold a
|
||||
// Windows licence key. A report is meant to be handed to somebody.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "fcntl.h"
|
||||
#include "posix.h"
|
||||
#include "stat.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/fcntl.h"
|
||||
#include "uapi/posix.h"
|
||||
#include "uapi/stat.h"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Small things a libc would have
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@
|
|||
// Prints one line per event: type, code and value, decoded where there is a
|
||||
// name for it.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "fcntl.h"
|
||||
#include "input.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/fcntl.h"
|
||||
#include "dev/input.h"
|
||||
|
||||
static void
|
||||
puts_(const char *s)
|
||||
|
|
|
|||
|
|
@ -19,16 +19,16 @@
|
|||
// is L3c. So the useful output here is the same as `ldls-run`'s: what the
|
||||
// driver asks for, in what order, and how far it gets.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "fcntl.h"
|
||||
#include "posix.h"
|
||||
#include "stat.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/fcntl.h"
|
||||
#include "uapi/posix.h"
|
||||
#include "uapi/stat.h"
|
||||
|
||||
#include "ko.h"
|
||||
#include "stub.h"
|
||||
#include "btf.h"
|
||||
#include "pciuser.h"
|
||||
#include "dev/pciuser.h"
|
||||
#include "kpi/kpi.h"
|
||||
extern void kpi_unregister_netdev(void *dev);
|
||||
extern void *kpi_skb_alloc(unsigned int len);
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@
|
|||
// The setting is machine-wide, not per-terminal: there is one keyboard, and
|
||||
// switching to tty3 does not move anybody's fingers.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "fcntl.h"
|
||||
#include "posix.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/fcntl.h"
|
||||
#include "uapi/posix.h"
|
||||
|
||||
// No printf, memset or strcpy in lib/; this needs a little of each.
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@
|
|||
// and the reason it had to wait for SCM_RIGHTS is that the *other* process
|
||||
// gets the same object by being handed the descriptor, not by naming it.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "fcntl.h"
|
||||
#include "stat.h"
|
||||
#include "posix.h"
|
||||
#include "socket.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/fcntl.h"
|
||||
#include "uapi/stat.h"
|
||||
#include "uapi/posix.h"
|
||||
#include "net/socket.h"
|
||||
|
||||
static int failures;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@
|
|||
// ARP (RFC 826), IPv4 (RFC 791), ICMP (RFC 792), DHCP (RFC 2131). All
|
||||
// published, all specifications, which is docs/licensing.md §5.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "fcntl.h"
|
||||
#include "netuser.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/fcntl.h"
|
||||
#include "net/netuser.h"
|
||||
|
||||
// Us, and the address we hand out. Numbers chosen not to collide with QEMU's
|
||||
// 10.0.2.0/24 user network, so both interfaces can be up at once.
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@
|
|||
// host$ nc -u -l -p 9000
|
||||
// guest# nettest -u 10.0.2.2 9000
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "socket.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "net/socket.h"
|
||||
|
||||
static void
|
||||
puts_(const char *s)
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@
|
|||
// like from the kernel's side, and the case that used to
|
||||
// leave a level-triggered line asserted with no handler
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "fcntl.h"
|
||||
#include "posix.h"
|
||||
#include "pciuser.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/fcntl.h"
|
||||
#include "uapi/posix.h"
|
||||
#include "dev/pciuser.h"
|
||||
|
||||
static void
|
||||
puts(const char *s)
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@
|
|||
// the IP header and the caller reads and writes the ICMP message alone. See
|
||||
// inet_icmp_recv_cb in kernel/net/inet.c.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "socket.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "net/socket.h"
|
||||
|
||||
#define ICMP_ECHO 8
|
||||
#define ICMP_ECHOREPLY 0
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@
|
|||
// Uses FICLONE, which is Linux's ioctl for exactly this, so the same call works
|
||||
// against any filesystem that supports cloning.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "fcntl.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/fcntl.h"
|
||||
|
||||
#define FICLONE 0x40049409
|
||||
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@
|
|||
// policy question. A machine with a hand-written one should keep it, which is
|
||||
// why -f exists and why it is not the default.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "fcntl.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/fcntl.h"
|
||||
|
||||
#define SRC "/proc/resolv.conf"
|
||||
#define DST "/etc/resolv.conf"
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@
|
|||
// Indexing covers values written *after* the index is declared. There is no
|
||||
// reindexing pass, so declare the index first.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
|
||||
static void
|
||||
puts_(const char *s)
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@
|
|||
// which is the point, and is what you fall back to on a system where this
|
||||
// program is one of the things that is broken.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "fcntl.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/fcntl.h"
|
||||
|
||||
static void
|
||||
puts_(const char *s)
|
||||
|
|
|
|||
|
|
@ -44,16 +44,16 @@
|
|||
// register, and arming one is a fine thing for a debugger to do and not a thing
|
||||
// for a stranger on a socket to do. The refusal is in the kernel, driven by the
|
||||
// view's own registration, so it cannot be got round from here and does not go
|
||||
// stale when a new view is added. See include/dbg.h.
|
||||
// stale when a new view is added. See include/core/dbg.h.
|
||||
//
|
||||
// One connection at a time, because /dev/dbg holds one answer at a time: two
|
||||
// clients would read each other's. A second caller waits rather than
|
||||
// interleaving.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "fcntl.h"
|
||||
#include "socket.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/fcntl.h"
|
||||
#include "net/socket.h"
|
||||
|
||||
#define DEFAULT_PORT 4444
|
||||
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@
|
|||
// nothing -- it comes back, reads /proc/schinit, and finds the world exactly
|
||||
// as it left it. A supervisor that forked its own jobs could not have that.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "fcntl.h"
|
||||
#include "posix.h"
|
||||
#include "socket.h"
|
||||
#include "schinit.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/fcntl.h"
|
||||
#include "uapi/posix.h"
|
||||
#include "net/socket.h"
|
||||
#include "uapi/schinit.h"
|
||||
|
||||
#define SUPERVISOR "/bin/schinitd"
|
||||
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@
|
|||
// either losing them to reparenting or racing the new copy to adopt them --
|
||||
// the split-brain failure docs/architecture/init.md rejects the two-init scheme for.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "fcntl.h"
|
||||
#include "posix.h"
|
||||
#include "socket.h"
|
||||
#include "schinit.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/fcntl.h"
|
||||
#include "uapi/posix.h"
|
||||
#include "net/socket.h"
|
||||
#include "uapi/schinit.h"
|
||||
|
||||
#define JOBDIR "/etc/schinit"
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ out(const char *s)
|
|||
static int verbose_boot;
|
||||
|
||||
// Whether the boot menu was asked for a network debugger. See
|
||||
// SCHBOOT_DEBUG_FLAG in include/schboot.h -- the kernel only publishes it, and
|
||||
// SCHBOOT_DEBUG_FLAG in include/arch/schboot.h -- the kernel only publishes it, and
|
||||
// this is what acts on it, because what it turns on is a job.
|
||||
static int debug_boot;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@
|
|||
// schmode 1024 768 set it
|
||||
// schmode 1024x768 the same
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "socket.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "net/socket.h"
|
||||
|
||||
#define VGPUD_SOCKET "/run/vgpud"
|
||||
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@
|
|||
//
|
||||
// Prints one line per check, and a final verdict a script can grep for.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "fcntl.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/fcntl.h"
|
||||
|
||||
#define PROT_READ 0x1
|
||||
#define PROT_WRITE 0x2
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@
|
|||
// Getting that backwards is a real bug this tree has had, so the masks below
|
||||
// are spelled out rather than built by a macro.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "posix.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/posix.h"
|
||||
|
||||
#define U_SIGCHLD_BIT (1ULL << (SIGCHLD - 1))
|
||||
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@
|
|||
//
|
||||
// Prints one line per check and a final verdict a script can grep for.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "socket.h"
|
||||
#include "stat.h"
|
||||
#include "fcntl.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "net/socket.h"
|
||||
#include "uapi/stat.h"
|
||||
#include "uapi/fcntl.h"
|
||||
|
||||
static int failures;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@
|
|||
// Deliberately not a WAV player. A player has to parse a header, and a header
|
||||
// is a second thing to get wrong while testing the first.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "fcntl.h"
|
||||
#include "audio.h"
|
||||
#include "errno.h"
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/fcntl.h"
|
||||
#include "dev/audio.h"
|
||||
#include "uapi/errno.h"
|
||||
|
||||
// A quarter-amplitude sine, from a table rather than a libm that does not
|
||||
// exist here. 64 points is audibly a sine and arithmetically exact.
|
||||
|
|
|
|||
|
|
@ -20,20 +20,20 @@
|
|||
// over a PCI device and this decided it was a GPU, which is the property that
|
||||
// makes the interface general rather than a hole shaped like one thing.
|
||||
|
||||
#include "types.h"
|
||||
#include "user.h"
|
||||
#include "fcntl.h"
|
||||
#include "posix.h"
|
||||
#include "pciuser.h"
|
||||
#include "virtio.h"
|
||||
#include "schinit.h"
|
||||
#include "socket.h"
|
||||
#include "theme.h" // SCH_BG, SCH_ACCENT -- one palette, see docs/branding
|
||||
#include "logo.h" // the mark, the same bytes the loader and console draw
|
||||
#include "fb.h" // the console framebuffer, which this mirrors
|
||||
#include "core/types.h"
|
||||
#include "uapi/user.h"
|
||||
#include "uapi/fcntl.h"
|
||||
#include "uapi/posix.h"
|
||||
#include "dev/pciuser.h"
|
||||
#include "dev/virtio.h"
|
||||
#include "uapi/schinit.h"
|
||||
#include "net/socket.h"
|
||||
#include "gfx/theme.h" // SCH_BG, SCH_ACCENT -- one palette, see docs/branding
|
||||
#include "gfx/logo.h" // the mark, the same bytes the loader and console draw
|
||||
#include "gfx/fb.h" // the console framebuffer, which this mirrors
|
||||
|
||||
// lib/glue.c has these -- they exist because the compiler emits calls to them
|
||||
// whether or not anything asks -- but include/user.h never declared them.
|
||||
// whether or not anything asks -- but include/uapi/user.h never declared them.
|
||||
void *memcpy(void *, const void *, unsigned long);
|
||||
int memcmp(const void *, const void *, unsigned long);
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ die(const char *why)
|
|||
// Not a failure: a report. There is no virtio-gpu here, or the kernel will not
|
||||
// give it up, and neither of those changes by trying again -- so this tells the
|
||||
// supervisor to stop, rather than being restarted every three seconds for the
|
||||
// rest of the uptime. See SCHINIT_EXIT_NORESTART in include/schinit.h.
|
||||
// rest of the uptime. See SCHINIT_EXIT_NORESTART in include/uapi/schinit.h.
|
||||
static void
|
||||
nothing_to_do(const char *why)
|
||||
{
|
||||
|
|
@ -625,7 +625,7 @@ present(void)
|
|||
//
|
||||
// The mark answers the same question a black screen cannot -- something is
|
||||
// driving this device -- and answers it as the system rather than as a test
|
||||
// rig. Same include/logo.h the loader splash and the kernel console draw, so
|
||||
// rig. Same include/gfx/logo.h the loader splash and the kernel console draw, so
|
||||
// there is one mark and one set of bytes.
|
||||
static void
|
||||
draw_mark(void)
|
||||
|
|
@ -812,7 +812,7 @@ mirror_pass(void)
|
|||
//
|
||||
// So the kernel is told, in advance, where to paint: it writes the report into
|
||||
// this framebuffer and asks the kernel driver it took this device from to
|
||||
// reset it and flush one frame. See PCIIOC_PANICFB in include/pciuser.h.
|
||||
// reset it and flush one frame. See PCIIOC_PANICFB in include/dev/pciuser.h.
|
||||
//
|
||||
// Called again after every modeset, because the size is half of what was
|
||||
// registered. Failing is not fatal to anything: it costs the crash screen on
|
||||
|
|
|
|||
Loading…
Reference in a new issue