Skip to content

Refine headers and eliminate dead code - #6

Merged
jserv merged 2 commits into
mainfrom
refine
Mar 21, 2026
Merged

Refine headers and eliminate dead code#6
jserv merged 2 commits into
mainfrom
refine

Conversation

@jserv

@jserv jserv commented Mar 21, 2026

Copy link
Copy Markdown
Contributor

Header hygiene:

  • Move internal headers (fd-table.h, lkl-wrap.h, seccomp{,-defs}.h, shadow-fd.h, procmem.h, net.h, web.h, syscall-nr.h) from include/kbox to src/ to reduce public API surface
  • Delete dead util.h/util.c (zero callers)
  • Make file-local functions static in path.c, lkl-wrap.c, web-server.c
  • Add KBOX_FD_TABLE_CAPACITY macro, kbox_fd_table_count(), kbox_web_set_fd_used()
  • Refactor kbox_host_nrs to X-macro (KBOX_HOST_NR_FIELDS) for single source of truth between struct definition and syscall_name_from_nr()

Dead code elimination:

  • Delete dead static wrappers from lkl-wrap.c (kbox_ensure_dev_console, kbox_lkl_dup3, kbox_lkl_execve, kbox_lkl_exit, kbox_lkl_wait4, etc.)
  • Delete dead process-event pipeline (kbox_web_record_process, kbox_event_push_process, KBOX_EVT_PROCESS, struct kbox_process_event)
  • Delete dead KBOX_EVT_COUNTER_DELTA enum and handler
  • Delete dead forward_sendmsg (marked attribute((unused)))
  • Remove unused slow_sample_ms config field
  • Consolidate duplicate ELF parsing (kbox_parse_elf_interp delegates to kbox_find_elf_interp_loc)

Change-Id: I49da244c7d3c9eefd6abeed616f55dda064c3bbb


Summary by cubic

Reduces the public C header surface and strips dead code to simplify the build and maintenance. Also makes devtmpfs/devpts mount failures non‑fatal so image boot works on lean LKL builds.

  • Refactors

    • Moved internal headers from include/kbox to src/ (e.g., fd-table.h, lkl-wrap.h, seccomp{,-defs}.h, shadow-fd.h, procmem.h, net.h, web.h, syscall-nr.h); updated Makefile and pre-commit to include -Isrc.
    • Marked file-local functions static in path.c, lkl-wrap.c, and web-server.c.
    • Added KBOX_FD_TABLE_CAPACITY, kbox_fd_table_count(), and kbox_web_set_fd_used().
    • Converted kbox_host_nrs to the KBOX_HOST_NR_FIELDS X-macro and integrated with syscall_name_from_nr().
    • Consolidated ELF PT_INTERP parsing into a single code path.
    • Treat devtmpfs/devpts mount failures as warnings; proc, sysfs, and tmpfs remain fatal.
  • Dead Code Removal

    • Removed util.h/util.c and unused wrappers from lkl-wrap.c (e.g., kbox_ensure_dev_console, kbox_lkl_dup3, kbox_lkl_execve, kbox_lkl_exit, kbox_lkl_wait4, etc.).
    • Dropped the process-event pipeline and related enums/structs (KBOX_EVT_PROCESS, KBOX_EVT_COUNTER_DELTA, and handlers).
    • Deleted forward_sendmsg and the unused slow_sample_ms config.

Written for commit a2ba2d2. Summary will update on new commits.

cubic-dev-ai[bot]

This comment was marked as resolved.

jserv added 2 commits March 21, 2026 13:29
Header hygiene:
- Move internal headers (fd-table.h, lkl-wrap.h, seccomp{,-defs}.h,
  shadow-fd.h, procmem.h, net.h, web.h, syscall-nr.h) from include/kbox
  to src/ to reduce public API surface
- Delete dead util.h/util.c (zero callers)
- Make file-local functions static in path.c, lkl-wrap.c, web-server.c
- Add KBOX_FD_TABLE_CAPACITY macro, kbox_fd_table_count(),
  kbox_web_set_fd_used()
- Refactor kbox_host_nrs to X-macro (KBOX_HOST_NR_FIELDS) for single
  source of truth between struct definition and syscall_name_from_nr()

Dead code elimination:
- Delete dead static wrappers from lkl-wrap.c (kbox_ensure_dev_console,
  kbox_lkl_dup3, kbox_lkl_execve, kbox_lkl_exit, kbox_lkl_wait4, etc.)
- Delete dead process-event pipeline (kbox_web_record_process,
  kbox_event_push_process, KBOX_EVT_PROCESS, struct kbox_process_event)
- Delete dead KBOX_EVT_COUNTER_DELTA enum and handler
- Delete dead forward_sendmsg (marked __attribute__((unused)))
- Remove unused slow_sample_ms config field
- Consolidate duplicate ELF parsing (kbox_parse_elf_interp delegates to
  kbox_find_elf_interp_loc)

Change-Id: I49da244c7d3c9eefd6abeed616f55dda064c3bbb
The CI LKL nightly build may lack CONFIG_DEVTMPFS or CONFIG_DEVPTS_FS
(olddefconfig can silently drop configs when upstream dependencies
change). This caused boot-and-exit to fail with "mount(devtmpfs on
/dev): No such device", breaking the entire integration test suite.

Guest can operate without devtmpfs and devpts; warn instead of aborting.
proc, sysfs, and tmpfs remain fatal since they are required for core
kbox functionality.

Change-Id: Ief46d361d22c36cf2691786a770e371fc1d356ad
@jserv
jserv merged commit 6bc13b9 into main Mar 21, 2026
3 checks passed
@jserv
jserv deleted the refine branch March 21, 2026 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant