From ec3c6667092c94b12be6b94340ee6007f987791f Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Sun, 23 Feb 2020 00:30:01 -0600 Subject: hscript: Handle Partition type codes --- hscript/disk.cc | 24 +++++++++++++++++++++++- hscript/disk.hh | 6 +++++- 2 files changed, 28 insertions(+), 2 deletions(-) (limited to 'hscript') diff --git a/hscript/disk.cc b/hscript/disk.cc index 4dbc471..bef0b73 100644 --- a/hscript/disk.cc +++ b/hscript/disk.cc @@ -458,11 +458,15 @@ Key *Partition::parseFromData(const std::string &data, int lineno, int *errors, type = Boot; } else if(typecode == "esp") { type = ESP; + } else if(typecode == "bios") { + type = BIOS; + } else if(typecode == "prep") { + type = PReP; } else { if(errors) *errors += 1; output_error("installfile:" + std::to_string(lineno), "partition: expected type code, got: " + typecode, - "valid type codes are 'boot' and 'esp'"); + "valid type codes are: boot esp bios prep"); return nullptr; } } @@ -558,6 +562,24 @@ bool Partition::execute(ScriptOptions opts) const { return false; } + switch(_type) { + case Boot: + ped_partition_set_flag(me, PED_PARTITION_BOOT, 1); + break; + case ESP: + ped_partition_set_flag(me, PED_PARTITION_ESP, 1); + break; + case BIOS: + ped_partition_set_flag(me, PED_PARTITION_BIOS_GRUB, 1); + break; + case PReP: + ped_partition_set_flag(me, PED_PARTITION_PREP, 1); + break; + case None: + /* we good */ + break; + } + int res = ped_disk_add_partition(disk, me, ped_constraint_any(dev)); if(res == 0) { output_error("installfile:" + std::to_string(this->lineno()), diff --git a/hscript/disk.hh b/hscript/disk.hh index 179807c..4adf8f5 100644 --- a/hscript/disk.hh +++ b/hscript/disk.hh @@ -83,7 +83,11 @@ public: /*! Bootable */ Boot, /*! EFI System Partition (GPT only) */ - ESP + ESP, + /*! GRUB BIOS (GPT only) */ + BIOS, + /*! PReP boot (MBR only) */ + PReP }; private: const std::string _block; -- cgit v1.2.3-70-g09d2