#[init_component]Expand description
Register a function as a kernel component initializer.
§Syntax
#[init_component]
#[init_component(bootstrap)]
#[init_component(bootstrap, priority = 1)]
#[init_component(kthread, priority = 2, depends_on = vfs_init)]
#[init_component(kthread, priority = 3, depends_on = [vfs_init, ipc_init])]| Argument | Type | Default | Description |
|---|---|---|---|
| stage | positional ident | bootstrap | bootstrap, kthread, or process |
priority | integer | 0 | Lower = earlier (tiebreaker within topo level) |
depends_on | ident or list | [] | Functions that must complete before this one |
§Example
#[init_component(bootstrap, priority = 1)]
fn vfs_init() -> Result<(), component::ComponentInitError> {
vfs::init();
Ok(())
}
#[init_component(kthread, priority = 2, depends_on = vfs_init)]
fn fs_ext4_init() -> Result<(), component::ComponentInitError> {
fs_ext4::init();
Ok(())
}The annotated function is emitted unchanged; a companion #[used] static is
placed in .component_entries so component::init_all() can discover,
topologically sort, and call all registered components at runtime.