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:
Nexoniarz 2026-10-23 15:05:12 +02:00
commit a1c965da1e
267 changed files with 1560 additions and 1440 deletions

View file

@ -27,8 +27,8 @@
#ifdef SCHFS_HOSTED
#include <string.h>
#else
#include "types.h"
#include "defs.h"
#include "core/types.h"
#include "core/defs.h"
#endif
/* ------------------------------------------------------------------ */

View file

@ -22,8 +22,8 @@
#ifdef SCHFS_HOSTED
#include <string.h>
#else
#include "types.h"
#include "defs.h"
#include "core/types.h"
#include "core/defs.h"
#endif
/* ------------------------------------------------------------------ */

View file

@ -19,7 +19,7 @@
#ifndef SCHFS_BTREE_H
#define SCHFS_BTREE_H
#include "schfs.h"
#include "fs/schfs.h"
// Block device the tree lives on. The kernel supplies one backed by the buffer
// cache; the test harness supplies one backed by a plain file or by memory.

View file

@ -48,20 +48,20 @@
// for a bracket to save. Deferral is what makes batching worth anything, and
// batching is what makes deferral worth anything. Neither pays alone.
#include "types.h"
#include "defs.h"
#include "param.h"
#include "spinlock.h"
#include "sleeplock.h"
#include "proc.h" /* myproc() — transaction brackets are per-process */
#include "fs.h"
#include "buf.h"
#include "core/types.h"
#include "core/defs.h"
#include "core/param.h"
#include "core/spinlock.h"
#include "core/sleeplock.h"
#include "core/proc.h" /* myproc() — transaction brackets are per-process */
#include "fs/fs.h"
#include "fs/buf.h"
#include "file.h" /* SCHFS_DEV, SCHFS_SNAP_DEV */
#include "errno.h" /* mounting reports why it failed, not just that it did */
#include "x86.h"
#include "fsstat.h"
#include "blkdev.h" /* bgetblk */
#include "fs/file.h" /* SCHFS_DEV, SCHFS_SNAP_DEV */
#include "uapi/errno.h" /* mounting reports why it failed, not just that it did */
#include "arch/x86.h"
#include "fs/fsstat.h"
#include "fs/blkdev.h" /* bgetblk */
#include "schfs_int.h"
// How many buffer-cache blocks one filesystem block spans. BSIZE was 1024 when

View file

@ -19,8 +19,8 @@
#ifdef SCHFS_HOSTED
#include <string.h>
#else
#include "types.h"
#include "defs.h"
#include "core/types.h"
#include "core/defs.h"
#endif
// Point a cursor at the volume's current tree, keeping the caller's block

View file

@ -28,8 +28,8 @@
#ifdef SCHFS_HOSTED
#include <string.h>
#else
#include "types.h"
#include "defs.h"
#include "core/types.h"
#include "core/defs.h"
#endif
/* ------------------------------------------------------------------ */

View file

@ -39,8 +39,8 @@
#ifdef SCHFS_HOSTED
#include <string.h>
#else
#include "types.h"
#include "defs.h"
#include "core/types.h"
#include "core/defs.h"
#endif
/* ------------------------------------------------------------------ */

View file

@ -27,19 +27,19 @@
// names left. Two pieces of code counting links independently is precisely how
// a filesystem loses a file that is still referenced.
#include "types.h"
#include "x86.h"
#include "defs.h"
#include "param.h"
#include "stat.h"
#include "spinlock.h"
#include "proc.h" /* `proc` — copyin/copyout need the current pgdir */
#include "sleeplock.h"
#include "fs.h"
#include "buf.h"
#include "file.h"
#include "errno.h"
#include "fsstat.h"
#include "core/types.h"
#include "arch/x86.h"
#include "core/defs.h"
#include "core/param.h"
#include "uapi/stat.h"
#include "core/spinlock.h"
#include "core/proc.h" /* `proc` — copyin/copyout need the current pgdir */
#include "core/sleeplock.h"
#include "fs/fs.h"
#include "fs/buf.h"
#include "fs/file.h"
#include "uapi/errno.h"
#include "fs/fsstat.h"
#include "schfs_int.h"

View file

@ -18,8 +18,8 @@
#ifdef SCHFS_HOSTED
#include <string.h>
#else
#include "types.h"
#include "defs.h"
#include "core/types.h"
#include "core/defs.h"
#endif
// Checksum an uberblock with its own crc field zeroed, the same convention the