]> 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)
commit91ac99ad5171ad84e6667cb0e993f7979f68d0f8
tree5266f9a095cbede159faae2f5c4753d58ccf5190
parent7b2a137f90710449a5b16878ad019805534e4821
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