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,17 +27,17 @@
|
|||
// fileread/filewrite see T_DEV and dispatch through devsw themselves -- which
|
||||
// is why there is no read op below that does anything.
|
||||
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "param.h"
|
||||
#include "stat.h"
|
||||
#include "spinlock.h"
|
||||
#include "sleeplock.h"
|
||||
#include "proc.h"
|
||||
#include "fs.h"
|
||||
#include "file.h"
|
||||
#include "errno.h"
|
||||
#include "blkdev.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/param.h"
|
||||
#include "uapi/stat.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/sleeplock.h"
|
||||
#include "core/proc.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
#include "uapi/errno.h"
|
||||
#include "fs/blkdev.h"
|
||||
|
||||
// Inode numbering. Two directories and a flat table of nodes, so the number is
|
||||
// either a directory id or an index into devnodes[] offset past them.
|
||||
|
|
@ -99,10 +99,10 @@ static const struct devnode devnodes[] = {
|
|||
// a flag, because the minor is the one piece of per-open state a character
|
||||
// device already sees -- so which one you opened *is* the permission, and
|
||||
// nothing has to be remembered between the write and the read. See
|
||||
// include/dbg.h and cmd/schdbgd.
|
||||
// include/core/dbg.h and cmd/schdbgd.
|
||||
{ "dbgro", 10, 1, D_ROOT },
|
||||
{ "netdev", 11, 0, D_ROOT },
|
||||
// Audio, spelled the way UNIX spells it. See include/audio.h.
|
||||
// Audio, spelled the way UNIX spells it. See include/dev/audio.h.
|
||||
{ "dsp", 12, 0, D_ROOT },
|
||||
{ "mouse", 3, 1, D_ROOT },
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
#include "types.h"
|
||||
#include "traps.h"
|
||||
#include "param.h"
|
||||
#include "memlayout.h"
|
||||
#include "mmu.h"
|
||||
#include "proc.h"
|
||||
#include "defs.h"
|
||||
#include "x86.h"
|
||||
#include "elf.h"
|
||||
#include "fcntl.h"
|
||||
#include "errno.h"
|
||||
#include "x86.h"
|
||||
#include "fsstat.h"
|
||||
#include "spinlock.h"
|
||||
#include "sleeplock.h"
|
||||
#include "fs.h"
|
||||
#include "file.h"
|
||||
#include "uaccess.h"
|
||||
#include "core/types.h"
|
||||
#include "arch/traps.h"
|
||||
#include "core/param.h"
|
||||
#include "arch/memlayout.h"
|
||||
#include "arch/mmu.h"
|
||||
#include "core/proc.h"
|
||||
#include "core/defs.h"
|
||||
#include "arch/x86.h"
|
||||
#include "core/elf.h"
|
||||
#include "uapi/fcntl.h"
|
||||
#include "uapi/errno.h"
|
||||
#include "arch/x86.h"
|
||||
#include "fs/fsstat.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/sleeplock.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
#include "core/uaccess.h"
|
||||
|
||||
// Binaries with entry points at 0x100000+ are musl/Linux-ABI.
|
||||
// SchOS-native binaries (init) are linked at 0x4000.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
//
|
||||
// FAT12, FAT16 and FAT32, with VFAT long file names. See include/fat.h.
|
||||
// FAT12, FAT16 and FAT32, with VFAT long file names. See include/fs/fat.h.
|
||||
//
|
||||
// Written from Microsoft's FAT specification (the "FAT32 File System
|
||||
// Specification", 1.03) and matching Linux's vfat where the specification
|
||||
|
|
@ -41,18 +41,18 @@
|
|||
// Every operation that changes anything writes its dirty lines back before it
|
||||
// returns, so a stick pulled out between two commands holds both of them.
|
||||
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "param.h"
|
||||
#include "stat.h"
|
||||
#include "spinlock.h"
|
||||
#include "sleeplock.h"
|
||||
#include "proc.h"
|
||||
#include "fs.h"
|
||||
#include "file.h"
|
||||
#include "errno.h"
|
||||
#include "blkdev.h"
|
||||
#include "fat.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/param.h"
|
||||
#include "uapi/stat.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/sleeplock.h"
|
||||
#include "core/proc.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
#include "uapi/errno.h"
|
||||
#include "fs/blkdev.h"
|
||||
#include "fs/fat.h"
|
||||
|
||||
#define LINE 4096
|
||||
#define NLINE 64 // 256 KB of cache per volume
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "stat.h"
|
||||
#include "param.h"
|
||||
#include "fs.h"
|
||||
#include "spinlock.h"
|
||||
#include "sleeplock.h"
|
||||
#include "file.h"
|
||||
#include "fsstat.h"
|
||||
#include "posix.h"
|
||||
#include "errno.h"
|
||||
#include "kmem.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "uapi/stat.h"
|
||||
#include "core/param.h"
|
||||
#include "fs/fs.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/sleeplock.h"
|
||||
#include "fs/file.h"
|
||||
#include "fs/fsstat.h"
|
||||
#include "uapi/posix.h"
|
||||
#include "uapi/errno.h"
|
||||
#include "core/kmem.h"
|
||||
|
||||
extern struct devsw devsw[];
|
||||
|
||||
|
|
|
|||
|
|
@ -31,21 +31,21 @@
|
|||
// removed.
|
||||
// This FS is a joke lol, suck my dick chinese people lol
|
||||
|
||||
#include "types.h"
|
||||
#include "x86.h"
|
||||
#include "defs.h"
|
||||
#include "param.h"
|
||||
#include "stat.h"
|
||||
#include "spinlock.h"
|
||||
#include "proc.h"
|
||||
#include "sleeplock.h"
|
||||
#include "fs.h"
|
||||
#include "buf.h"
|
||||
#include "fsstat.h"
|
||||
#include "file.h"
|
||||
#include "fat.h"
|
||||
#include "errno.h"
|
||||
#include "kmem.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"
|
||||
#include "core/sleeplock.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/buf.h"
|
||||
#include "fs/fsstat.h"
|
||||
#include "fs/file.h"
|
||||
#include "fs/fat.h"
|
||||
#include "uapi/errno.h"
|
||||
#include "core/kmem.h"
|
||||
|
||||
extern uint uptime(void);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "param.h"
|
||||
#include "spinlock.h"
|
||||
#include "sleeplock.h"
|
||||
#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 "fs/fs.h"
|
||||
#include "fs/buf.h"
|
||||
|
||||
// Simple logging that allows concurrent FS system calls.
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "param.h"
|
||||
#include "mmu.h"
|
||||
#include "proc.h"
|
||||
#include "fs.h"
|
||||
#include "spinlock.h"
|
||||
#include "sleeplock.h"
|
||||
#include "file.h"
|
||||
#include "kmem.h"
|
||||
#include "posix.h"
|
||||
#include "errno.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/param.h"
|
||||
#include "arch/mmu.h"
|
||||
#include "core/proc.h"
|
||||
#include "fs/fs.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/sleeplock.h"
|
||||
#include "fs/file.h"
|
||||
#include "core/kmem.h"
|
||||
#include "uapi/posix.h"
|
||||
#include "uapi/errno.h"
|
||||
|
||||
#define PIPESIZE 512
|
||||
|
||||
|
|
|
|||
|
|
@ -19,21 +19,21 @@
|
|||
// reads over. That split is deliberate -- the generators are about content and
|
||||
// this file is about namespace, and they change for different reasons.
|
||||
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "klog.h"
|
||||
#include "param.h"
|
||||
#include "memlayout.h"
|
||||
#include "mmu.h"
|
||||
#include "proc.h"
|
||||
#include "spinlock.h"
|
||||
#include "sleeplock.h"
|
||||
#include "fs.h"
|
||||
#include "file.h"
|
||||
#include "kmem.h"
|
||||
#include "stat.h"
|
||||
#include "uaccess.h"
|
||||
#include "errno.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/klog.h"
|
||||
#include "core/param.h"
|
||||
#include "arch/memlayout.h"
|
||||
#include "arch/mmu.h"
|
||||
#include "core/proc.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/sleeplock.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
#include "core/kmem.h"
|
||||
#include "uapi/stat.h"
|
||||
#include "core/uaccess.h"
|
||||
#include "uapi/errno.h"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Inode numbering
|
||||
|
|
@ -96,7 +96,7 @@ static const struct global_file globals[] = {
|
|||
// "quiet" or "verbose" -- how this machine was booted. See cmd/schinitd.
|
||||
{ "bootmode", 19 },
|
||||
{ "bootdebug", 30 },
|
||||
// What the slab allocator is holding. See include/kmem.h.
|
||||
// What the slab allocator is holding. See include/core/kmem.h.
|
||||
{ "slab", 20 },
|
||||
// Disks and partitions, in Linux's format. See blkdev_info().
|
||||
{ "partitions", 21 },
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -24,22 +24,22 @@
|
|||
// from the live tables when asked, so a USB stick appears in /sys the moment
|
||||
// the hot-plug thread attaches it.
|
||||
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "param.h"
|
||||
#include "memlayout.h"
|
||||
#include "mmu.h"
|
||||
#include "spinlock.h"
|
||||
#include "sleeplock.h"
|
||||
#include "fs.h"
|
||||
#include "file.h"
|
||||
#include "kmem.h"
|
||||
#include "uaccess.h"
|
||||
#include "errno.h"
|
||||
#include "stat.h"
|
||||
#include "pci.h"
|
||||
#include "usb.h"
|
||||
#include "hwinfo.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/param.h"
|
||||
#include "arch/memlayout.h"
|
||||
#include "arch/mmu.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/sleeplock.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
#include "core/kmem.h"
|
||||
#include "core/uaccess.h"
|
||||
#include "uapi/errno.h"
|
||||
#include "uapi/stat.h"
|
||||
#include "dev/pci.h"
|
||||
#include "dev/usb.h"
|
||||
#include "core/hwinfo.h"
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Inode numbers: kind, index, file -- the whole identity, since iget gives
|
||||
|
|
|
|||
Loading…
Reference in a new issue