Skip to content

RFC: callbacks for rsinit - #22

Closed
KarlK90 wants to merge 1 commit into
pengutronix:mainfrom
KarlK90:feature/callback-experiment
Closed

KarlK90 wants to merge 1 commit into
pengutronix:mainfrom
KarlK90:feature/callback-experiment

Conversation

@KarlK90

@KarlK90 KarlK90 commented Dec 4, 2025 •

Copy link
Copy Markdown
Member

This is a quick demonstrator on how to implement the functionality of #21 as callbacks. More work needs to be done to truly separate the custom logic from the main rsinit crate, but the idea should be clear :-).

This is the output of this rsinit implementation run inside qemu:

Running /init...
[    2.576598]  rsinit: Custom option provided: wowowowowow
[    2.578203]  rsinit: Beep, beep! Post setup callback running... I'll just print the options: CmdlineOptions {
[    2.578203]     root: Some(
[    2.578203]         "/dev/vdb",
[    2.578203]     ),
[    2.578203]     rootfstype: Some(
[    2.578203]         "ext4",
[    2.578203]     ),
[    2.578203]     rootflags: None,
[    2.578203]     rootfsflags: MsFlags(
[    2.578203]         0x0,
[    2.578203]     ),
[    2.578203]     nfsroot: None,
[    2.578203]     init: "/sbin/init",
[    2.578203]     cleanup: true,
[    2.578203]     callbacks: CmdlineOptionsCallbacks {
[    2.578203]         callbacks_count: 0,
[    2.578203]     },
[    2.578203] }
[    2.624939] EXT4-fs (vdb): recovery complete
[    2.626477] EXT4-fs (vdb): mounted filesystem 59e66880-dd9c-430a-af55-52986ed24ac7 r/w with ordered data mode. Quota mode: none.
[    2.627301]  rsinit: I'm lucky, I was the first callback to be added!
[    2.627569]  rsinit: Let me show you the bind mounts collected so far: ["/lib/modules"]
[    2.628059]  rsinit: Bind mounting /lib/modules to /root/lib/modules

Signed-off-by: Stefan Kerkmann <karlk90@pm.me>
@KarlK90
KarlK90 force-pushed the feature/callback-experiment branch from 161bedc to 8614c2c Compare December 12, 2025 21:48
@michaelolbrich

Copy link
Copy Markdown
Member

Hmm, I think the callback for the commandline parser makes sense. But I'm not so sure about the callbacks in the init() function: init() is called from the (custom) main function anyways, so we can just call some other function that is a modified copy. And init() is basically four lines of code, so copying that is not really a problem.

@michaelolbrich

Copy link
Copy Markdown
Member

So I think we should split this up and get the commandline callback code in a state that can be merged.

@KarlK90

KarlK90 commented Jan 15, 2026

Copy link
Copy Markdown
Member Author

See #24

@KarlK90 KarlK90 closed this Feb 5, 2026
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.

2 participants