From 28c81a32aa59a9b2d39ddd7f86fb1d2677da32cc Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Sun, 15 Mar 2020 01:54:20 -0500 Subject: hscript: Mount /dev, /proc, /sys under /target --- hscript/script_e.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'hscript/script_e.cc') diff --git a/hscript/script_e.cc b/hscript/script_e.cc index acaffda..2b9f8f4 100644 --- a/hscript/script_e.cc +++ b/hscript/script_e.cc @@ -16,6 +16,7 @@ #include #ifdef HAS_INSTALL_ENV # include +# include #endif /* HAS_INSTALL_ENV */ #include "script.hh" @@ -155,6 +156,30 @@ bool Script::execute() const { } #ifdef HAS_INSTALL_ENV if(opts.test(InstallEnvironment)) ped_device_free_all(); + + if(!opts.test(Simulate)) { + if(!fs::exists(targetDirectory() + "/dev", ec)) { + fs::create_directory(targetDirectory() + "/dev", ec); + } + if(mount("/dev", "/target/dev", nullptr, MS_BIND, nullptr) != 0) { + output_warning("internal", "could not bind-mount /dev; " + "bootloader configuration may fail"); + } + + if(!fs::exists(targetDirectory() + "/proc", ec)) { + fs::create_directory(targetDirectory() + "/proc", ec); + } + if(mount("none", "/target/proc", "proc", 0, nullptr) != 0) { + output_warning("internal", "target procfs could not be mounted"); + } + + if(!fs::exists(targetDirectory() + "/sys", ec)) { + fs::create_directory(targetDirectory() + "/sys", ec); + } + if(mount("none", "/target/sys", "sysfs", 0, nullptr) != 0) { + output_warning("internal", "target sysfs could not be mounted"); + } + } #endif /* HAS_INSTALL_ENV */ output_step_end("disk"); -- cgit v1.2.3-60-g2f50