swroot.rs 581 B

123456789101112131415161718
  1. use crate::cfg;
  2. use crate::exec::unix_execv;
  3. use crate::log::logger;
  4. pub fn switch_root() {
  5. let new_root = cfg::CFG.get().get_cfg().get_new_root();
  6. let new_init = cfg::CFG.get().get_cfg().get_new_init();
  7. let mut args = Vec::<String>::new();
  8. args.push("switch_root".to_string());
  9. args.push(new_root.clone());
  10. args.push(new_init.clone());
  11. logger().info("switch-root", format!(
  12. "switching to new root '{}' with new init '{}'...",
  13. new_root.as_str(),
  14. new_init.as_str()
  15. ).as_str());
  16. unix_execv("/usr/sbin/switch_root", args)
  17. }