Skip to content

system/nxinit: improve init.rc parser (per-cpu configs, --option fix) - #3737

Open
JianyuWang0623 wants to merge 2 commits into
apache:masterfrom
JianyuWang0623:nxinit-parser-enhancements
Open

system/nxinit: improve init.rc parser (per-cpu configs, --option fix)#3737
JianyuWang0623 wants to merge 2 commits into
apache:masterfrom
JianyuWang0623:nxinit-parser-enhancements

Conversation

@JianyuWang0623

@JianyuWang0623 JianyuWang0623 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Note: Please adhere to Contributing Guidelines.

Summary

This series improves the system/nxinit init.rc parser. It contains two
self-contained, independent commits:

  1. parse default cpu-specific configs — On top of the configured rc file
    (CONFIG_SYSTEM_NXINIT_RC_FILE_PATH, e.g. /etc/init.d/init.rc),
    init_parse_configs() now also loads an optional per-cpu config derived
    from that path (<rc-path>.cpu${CPUID}, e.g. /etc/init.d/init.cpu0.rc).
    The configurable rc path support is preserved and the unused directory
    scanning path is dropped.

  2. fix argument parser treating --option as -- separator
    init_parse_arguments() only compared the first two characters when
    detecting the -- separator, so options like --system / --nofork were
    mistaken for the standalone -- separator and the remaining arguments were
    truncated. Add an isblank() check on the third character so only a
    standalone -- followed by whitespace triggers the separator logic.

Both commits are independent parser improvements and can be reviewed in any
order.

Impact

  • Users: nxinit gains optional per-cpu init.rc support and correctly
    passes through long options (e.g. --system) to services/actions. Existing
    single-file init.rc setups are unaffected (the per-cpu file is optional).
  • Build: No new Kconfig options; no build-flag changes. Only
    system/nxinit/{parser.c,parser.h,init.c} are touched.
  • Hardware / compatibility: No ABI or on-flash format change. Behavior for
    configs that do not use per-cpu files or ---style options is unchanged.
  • Documentation / security: None.

Testing

Host:

  • OS: Linux (x86_64)
  • Compiler: xtensa-esp32s3-elf-gcc (ESP toolchain)

Target:

  • arch: xtensa
  • board:config: lckfb-szpi-esp32s3:adb

Verification:

  • ./tools/checkpatch.sh -f passes cleanly on all touched files
    (parser.c, parser.h, init.c) — All checks pass.
  • The full nxinit series (of which this is the first batch) builds and boots on
    the target above; init.rc is parsed and services start as expected.

On the basis of init.rc, add default parsing of cpu-specific configs.
- /etc/init.d/init.rc
- /etc/init.d/init.cpu${CPUID}.rc

Refactor function `init_parse_configs()` to parse files from the default path
instead of identifying and parsing directories or files, as the functionality
is unnecessary.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
The init_parse_arguments() function checked for '--' by only
comparing the first two characters, causing options like --system,
--nofork to be misinterpreted as the '--' argument separator. This
truncated the remaining arguments. Add an isblank() check on the
third character to ensure only standalone '--' followed by whitespace
triggers the separator logic.

Assisted-by: GitHubCopilot:claude-4.6-opus
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
@JianyuWang0623
JianyuWang0623 force-pushed the nxinit-parser-enhancements branch from f7eb424 to b5ff501 Compare August 21, 2026 04:49
@github-actions github-actions Bot added Size: S and removed Size: M labels Aug 21, 2026
@JianyuWang0623 JianyuWang0623 changed the title system/nxinit: improve init.rc parser (per-cpu configs, buffer parsing, -- fix) system/nxinit: improve init.rc parser (per-cpu configs, --option fix) Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant