diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2020-05-26 22:50:56 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2020-05-26 22:50:56 -0500 |
commit | f74c7b5a93c75e6b7518f2f34f3b662151277c84 (patch) | |
tree | 6606e96329638f026502184b393f3a6df40bf6c0 | |
parent | 8b00a5779ace2b919f6d9f31fb50d37086a78914 (diff) | |
download | horizon-f74c7b5a93c75e6b7518f2f34f3b662151277c84.tar.gz horizon-f74c7b5a93c75e6b7518f2f34f3b662151277c84.tar.bz2 horizon-f74c7b5a93c75e6b7518f2f34f3b662151277c84.tar.xz horizon-f74c7b5a93c75e6b7518f2f34f3b662151277c84.zip |
hscript: Ensure target mounts aren't hardcoded to /target
-rw-r--r-- | hscript/script_e.cc | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/hscript/script_e.cc b/hscript/script_e.cc index 829d672..8c857d7 100644 --- a/hscript/script_e.cc +++ b/hscript/script_e.cc @@ -162,25 +162,29 @@ bool Script::execute() const { if(opts.test(InstallEnvironment)) ped_device_free_all(); if(!opts.test(Simulate)) { - if(!fs::exists(targetDirectory() + "/dev", ec)) { - fs::create_directory(targetDirectory() + "/dev", ec); + const std::string devpath = targetDirectory() + "/dev"; + const std::string procpath = targetDirectory() + "/proc"; + const std::string syspath = targetDirectory() + "/sys"; + + if(!fs::exists(devpath, ec)) { + fs::create_directory(devpath, ec); } - if(mount("/dev", "/target/dev", nullptr, MS_BIND, nullptr) != 0) { + if(mount("/dev", devpath.c_str(), 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(!fs::exists(procpath, ec)) { + fs::create_directory(procpath, ec); } - if(mount("none", "/target/proc", "proc", 0, nullptr) != 0) { + if(mount("none", procpath.c_str(), "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(!fs::exists(syspath, ec)) { + fs::create_directory(syspath, ec); } - if(mount("none", "/target/sys", "sysfs", 0, nullptr) != 0) { + if(mount("none", syspath.c_str(), "sysfs", 0, nullptr) != 0) { output_warning("internal", "target sysfs could not be mounted"); } } |