summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2020-03-15 01:54:20 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2020-03-15 01:54:20 -0500
commit28c81a32aa59a9b2d39ddd7f86fb1d2677da32cc (patch)
tree3ef9b9578812bd90cafa6164843e52f89c72c460
parenta42230d6351db5f3dab0ce2820006a84495200e3 (diff)
downloadhorizon-28c81a32aa59a9b2d39ddd7f86fb1d2677da32cc.tar.gz
horizon-28c81a32aa59a9b2d39ddd7f86fb1d2677da32cc.tar.bz2
horizon-28c81a32aa59a9b2d39ddd7f86fb1d2677da32cc.tar.xz
horizon-28c81a32aa59a9b2d39ddd7f86fb1d2677da32cc.zip
hscript: Mount /dev, /proc, /sys under /target
-rw-r--r--hscript/script_e.cc25
1 files changed, 25 insertions, 0 deletions
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 <string>
#ifdef HAS_INSTALL_ENV
# include <parted/parted.h>
+# include <sys/mount.h>
#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");