summaryrefslogtreecommitdiff
path: root/hscript
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-09 00:06:11 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-09 00:06:11 -0500
commit3eb6867efa16f891512710eb2bb852483337eb5c (patch)
tree726560275ea0a76a681ff7fe260c7ed1ddf8f14c /hscript
parent542e39743cd3fe85219bdb7fb00b385ac69f05c4 (diff)
downloadhorizon-3eb6867efa16f891512710eb2bb852483337eb5c.tar.gz
horizon-3eb6867efa16f891512710eb2bb852483337eb5c.tar.bz2
horizon-3eb6867efa16f891512710eb2bb852483337eb5c.tar.xz
horizon-3eb6867efa16f891512710eb2bb852483337eb5c.zip
hscript: Implement stub Mount parser
Diffstat (limited to 'hscript')
-rw-r--r--hscript/disk.cc27
-rw-r--r--hscript/disk.hh20
-rw-r--r--hscript/script.cc10
3 files changed, 55 insertions, 2 deletions
diff --git a/hscript/disk.cc b/hscript/disk.cc
index a1313f0..d491430 100644
--- a/hscript/disk.cc
+++ b/hscript/disk.cc
@@ -10,4 +10,31 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
+#include <algorithm>
+#include <string>
#include "disk.hh"
+#include "util/output.hh"
+
+using namespace Horizon::Keys;
+
+Key *Mount::parseFromData(const std::string data, int lineno, int *errors,
+ int *warnings) {
+ std::string dev, where, opt;
+ long spaces = std::count(data.cbegin(), data.cend(), ' ');
+ if(spaces < 1 || spaces > 2) {
+ if(errors) *errors += 1;
+ output_error("installfile:" + std::to_string(lineno),
+ "mount: expected either 2 or 3 elements, got: " +
+ std::to_string(spaces), "");
+ return nullptr;
+ }
+ return new Mount(lineno, dev, where, opt);
+}
+
+bool Mount::validate() const {
+ return false;
+}
+
+bool Mount::execute() const {
+ return false;
+}
diff --git a/hscript/disk.hh b/hscript/disk.hh
index ad9a046..475b1ab 100644
--- a/hscript/disk.hh
+++ b/hscript/disk.hh
@@ -43,6 +43,26 @@ class Filesystem : public Key {
};
class Mount : public Key {
+private:
+ const std::string _block;
+ const std::string _mountpoint;
+ const std::string _opts;
+
+ Mount(int _line, std::string my_block, std::string my_mountpoint,
+ std::string my_opts = "") : Key(_line), _block(my_block),
+ _mountpoint(my_mountpoint), _opts(my_opts) {}
+public:
+ /*! Retrieve the block device to which this mount pertains. */
+ const std::string device() const { return this->_block; }
+ /*! Retrieve the mountpoint for this mount. */
+ const std::string mountpoint() const { return this->_mountpoint; }
+ /*! Retrieve the mount options for this mount, if any. */
+ const std::string options() const { return this->_opts; }
+
+ static Key *parseFromData(const std::string data, int lineno, int *errors,
+ int *warnings);
+ bool validate() const override;
+ bool execute() const override;
};
}
diff --git a/hscript/script.cc b/hscript/script.cc
index 2bc7831..ddd6cd3 100644
--- a/hscript/script.cc
+++ b/hscript/script.cc
@@ -143,8 +143,11 @@ struct Script::ScriptPrivate {
this->rootpw = std::move(name);
return true;
} else if(key_name == "mount") {
- /*! TODO: implement */
- return false;
+ std::unique_ptr<Keys::Mount> mount(
+ dynamic_cast<Keys::Mount *>(key_obj)
+ );
+ this->mounts.push_back(std::move(mount));
+ return true;
} else {
return false;
}
@@ -309,6 +312,9 @@ bool Script::validate() const {
/* TODO: Runner.Validate.mount.Block. */
}
}
+
+ output_message("validator", "0", "installfile",
+ std::to_string(failures) + " failure(s).", "");
return (failures == 0);
}