[gnome-build-meta/valentindavid/eos-installer: 4/5] eos-installer: Tweak detection of valid image
- From: Valentin David <valentindavid src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-build-meta/valentindavid/eos-installer: 4/5] eos-installer: Tweak detection of valid image
- Date: Wed, 8 Apr 2020 10:41:00 +0000 (UTC)
commit 7ab57f74c5c42bdd8d4d7f66978762e0aa6bde65
Author: Valentin David <valentin david codethink co uk>
Date: Thu Mar 26 16:53:53 2020 +0100
eos-installer: Tweak detection of valid image
elements/iso/eos-installer.bst | 2 +
files/eos-installer/two-partitions.patch | 63 ++++++++++++++++++++++++++++++++
2 files changed, 65 insertions(+)
---
diff --git a/elements/iso/eos-installer.bst b/elements/iso/eos-installer.bst
index adc3de78..45ae6fd7 100644
--- a/elements/iso/eos-installer.bst
+++ b/elements/iso/eos-installer.bst
@@ -16,6 +16,8 @@ sources:
path: files/eos-installer/xattr-path.patch
- kind: patch
path: files/eos-installer/vfat-eosimages.patch
+- kind: patch
+ path: files/eos-installer/two-partitions.patch
depends:
- freedesktop-sdk.bst:bootstrap-import.bst
diff --git a/files/eos-installer/two-partitions.patch b/files/eos-installer/two-partitions.patch
new file mode 100644
index 00000000..c41181ec
--- /dev/null
+++ b/files/eos-installer/two-partitions.patch
@@ -0,0 +1,63 @@
+diff --git a/gnome-image-installer/util/gpt.c b/gnome-image-installer/util/gpt.c
+index c056769..8d23cf6 100644
+--- a/gnome-image-installer/util/gpt.c
++++ b/gnome-image-installer/util/gpt.c
+@@ -190,7 +190,7 @@ int is_eos_gpt_valid(struct ptable *pt, uint64_t *size)
+ // invalid partition size
+ return 0;
+ }
+- if(pt->header.ptable_count < 3 ) {
++ if(pt->header.ptable_count < 2 ) {
+ // need at least 3 partitions
+ return 0;
+ }
+@@ -200,12 +200,6 @@ int is_eos_gpt_valid(struct ptable *pt, uint64_t *size)
+ return 0;
+ }
+ }
+- uint64_t flags = 0;
+- memcpy(&flags, pt->partitions[2].attributes, 8);
+- if(!is_nth_flag_set(flags, 55)) {
+- // 55th flag must be 1 for EOS images
+- return 0;
+- }
+ // crc32 of header, with 'crc' field zero'ed
+ struct gpt_header testcrc_header;
+ memset(&testcrc_header, 0, GPT_HEADER_SIZE);
+@@ -234,17 +228,26 @@ int is_eos_gpt_valid(struct ptable *pt, uint64_t *size)
+ // invalid first partition GUID
+ return 0;
+ }
+- if(memcmp(&pt->partitions[1].type_guid, GPT_GUID_BOOT, 16)!=0) {
+- // invalid second partition GUID
+- return 0;
+- }
+- if(memcmp(&pt->partitions[2].type_guid, GPT_GUID_LINUX_DATA, 16)!=0
+- && memcmp(&pt->partitions[2].type_guid, GPT_GUID_LINUX_ROOTFS1, 16)!=0
+- && memcmp(&pt->partitions[2].type_guid, GPT_GUID_LINUX_ROOTFS2, 16)!=0
+- && memcmp(&pt->partitions[2].type_guid, GPT_GUID_LINUX_ROOTFS3, 16)!=0
+- && memcmp(&pt->partitions[2].type_guid, GPT_GUID_LINUX_ROOTFS4, 16)!=0) {
++ int has_root = 0;
++ for (i = 1; i < pt->header.ptable_count; ++i) {
++ if (memcmp(&pt->partitions[i].type_guid, GPT_GUID_LINUX_DATA, 16)==0
++ || memcmp(&pt->partitions[i].type_guid, GPT_GUID_LINUX_ROOTFS1, 16)==0
++ || memcmp(&pt->partitions[i].type_guid, GPT_GUID_LINUX_ROOTFS2, 16)==0
++ || memcmp(&pt->partitions[i].type_guid, GPT_GUID_LINUX_ROOTFS3, 16)==0
++ || memcmp(&pt->partitions[i].type_guid, GPT_GUID_LINUX_ROOTFS4, 16)==0) {
+ // invalid third partition GUID
+- return 0;
++ uint64_t flags = 0;
++ memcpy(&flags, pt->partitions[i].attributes, 8);
++ if(!is_nth_flag_set(flags, 55)) {
++ // 55th flag must be 1 for EOS images
++ continue ;
++ }
++ has_root=1;
++ break ;
++ }
++ }
++ if (!has_root) {
++ return 0;
+ }
+
+ if (size != NULL) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]