diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-10-25 04:35:58 -0500 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-10-25 04:35:58 -0500 |
commit | ec32bbe2c9a77ae150de08e14c0a30e33ac5e321 (patch) | |
tree | bb920df38fc77fbf21246a05e3569d9917184089 /hscript/disk.hh | |
parent | 4755175ad26eaff1765407bb01f8820f394f847b (diff) | |
download | horizon-ec32bbe2c9a77ae150de08e14c0a30e33ac5e321.tar.gz horizon-ec32bbe2c9a77ae150de08e14c0a30e33ac5e321.tar.bz2 horizon-ec32bbe2c9a77ae150de08e14c0a30e33ac5e321.tar.xz horizon-ec32bbe2c9a77ae150de08e14c0a30e33ac5e321.zip |
hscript: Implement Partition, add tests
Diffstat (limited to 'hscript/disk.hh')
-rw-r--r-- | hscript/disk.hh | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/hscript/disk.hh b/hscript/disk.hh index f8a9574..90deca4 100644 --- a/hscript/disk.hh +++ b/hscript/disk.hh @@ -64,7 +64,53 @@ public: bool execute(ScriptOptions) const override; }; +/*! The type of size a disk key has */ +enum SizeType { + /*! Sized in bytes */ + Bytes, + /*! Sized as a percentage of the whole disk */ + Percent, + /*! Fill the rest of the disk */ + Fill +}; + class Partition : public Key { +public: + /*! Valid partition type codes */ + enum PartitionType { + /*! None (default) */ + None = 0, + /*! Bootable */ + Boot, + /*! EFI System Partition (GPT only) */ + ESP + }; +private: + const std::string _block; + const int _partno; + const SizeType _size_type; + const uint64_t _size; + const PartitionType _type; + + Partition(int _line, const std::string &_b, const int _p, + const SizeType _st, const uint64_t _s, const PartitionType _pt) : + Key(_line), _block(_b), _partno(_p), _size_type(_st), _size(_s), + _type(_pt) {} +public: + /*! Retrieve the block device that this key identifies. */ + const std::string device() const { return this->_block; } + /*! Retrieve the partition number that this key identifies. */ + int partno() const { return this->_partno; } + /*! Retrieve the type of size that this partition uses. */ + SizeType size_type() const { return this->_size_type; } + /*! Retrieve the size of this partition. */ + uint64_t size() const { return this->_size; } + /*! Retrieve the Type Code of this partition, if any. */ + PartitionType type() const { return this->_type; } + + static Key *parseFromData(const std::string &, int, int*, int*); + bool validate(ScriptOptions) const override; + bool execute(ScriptOptions) const override; }; class Encrypt : public Key { |