]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
feat: Linux-like kernel command line parser with /proc/cmdline
authorTulio A M Mendes <[email protected]>
Fri, 13 Feb 2026 09:15:09 +0000 (06:15 -0300)
committerTulio A M Mendes <[email protected]>
Fri, 13 Feb 2026 09:15:09 +0000 (06:15 -0300)
commit671e837f11860f980eb33695ca3a2bea8c675313
treeeb38d4792b353ce1aaea4f8a0d20dd8d85c3476c
parentdc05bd8d186e9b6316cf4903595ede013647771a
feat: Linux-like kernel command line parser with /proc/cmdline

Implement a proper kernel command line parsing system modeled after
Linux's cmdline triaging:

1. Kernel params: recognized 'key=value' tokens (init=, root=,
   console=, loglevel=) are consumed by the kernel.
2. Kernel flags: recognized plain tokens (quiet, ring3, nokaslr,
   single, noapic, nosmp) are consumed by the kernel.
3. Init envp: unrecognized 'key=value' tokens become environment
   variables for the init process.
4. Init argv: unrecognized plain tokens (no '=' or '.') become
   command-line arguments for the init process.
5. '--' separator: everything after it goes to init untouched.
6. First token (kernel path) is always skipped.

New files:
- include/kernel/cmdline.h: API (cmdline_parse, cmdline_get,
  cmdline_has, cmdline_init_path, cmdline_init_argv/envp, cmdline_raw)
- src/kernel/cmdline.c: implementation with static storage

Changes:
- init.c: calls cmdline_parse() early, uses cmdline_has('ring3')
  instead of the old cmdline_has_token() (removed)
- arch_platform.c: uses cmdline_init_path() for init binary path
  (supports 'init=/path/to/init' from GRUB cmdline)
- procfs.c: added /proc/cmdline file (readable by userspace)

The 'ring3' parameter is no longer required for stable boot (the
scheduler bug causing panics without it was fixed in the previous
commit). It now only controls the inline ring3 test.

Build: clean, cppcheck: clean, smoke: 19/19 pass
include/kernel/cmdline.h [new file with mode: 0644]
src/arch/x86/arch_platform.c
src/kernel/cmdline.c [new file with mode: 0644]
src/kernel/init.c
src/kernel/procfs.c