loader.rs (1366B)
1 use std::collections::{HashMap, HashSet}; 2 3 use kanit_unit::{RcUnit, UnitName, wrap_unit}; 4 5 use crate::oneshot::*; 6 use crate::services::GeTTY; 7 8 // use crate::services::*; 9 10 pub fn units() -> [RcUnit; 16] { 11 [ 12 wrap_unit(ProcFs), 13 wrap_unit(SysFs), 14 wrap_unit(Run), 15 wrap_unit(DevFs), 16 wrap_unit(MDev), 17 wrap_unit(HwDrivers), 18 wrap_unit(Modules), 19 wrap_unit(Clock), 20 wrap_unit(RootFs), 21 wrap_unit(Swap), 22 wrap_unit(LocalMount), 23 wrap_unit(Seed), 24 wrap_unit(Hostname), 25 wrap_unit(Cgroup), 26 // wrap_unit(Syslog::new()), 27 // TODO; getty kills init... as always 28 wrap_unit(GeTTY::new("tty1", false)), 29 wrap_unit(GeTTY::new("ttyS0", true)), 30 ] 31 } 32 33 pub fn default_enabled() -> HashMap<Box<str>, HashSet<UnitName>> { 34 let sysboot = units() 35 .iter() 36 .map(|n| n.borrow().name()) 37 .filter(|n| !n.starts_with("getty")) 38 .collect::<HashSet<_>>(); 39 #[cfg(not(feature = "testing"))] 40 let default = units() 41 .iter() 42 .map(|n| n.borrow().name()) 43 .filter(|n| n.starts_with("getty")) 44 .collect::<HashSet<_>>(); 45 #[cfg(feature = "testing")] 46 let default = HashSet::new(); 47 48 HashMap::from([ 49 (Box::from("sysboot"), sysboot), 50 (Box::from("default"), default), 51 ]) 52 }