From d61a4e1ba1f888447683134e680e3a61f65e0592 Mon Sep 17 00:00:00 2001 From: bongbui321 Date: Thu, 28 Mar 2024 02:54:17 -0400 Subject: [PATCH 1/3] improve getactiveslot --- edlclient/Library/firehose_client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/edlclient/Library/firehose_client.py b/edlclient/Library/firehose_client.py index 1c8fcb5..358e4b1 100644 --- a/edlclient/Library/firehose_client.py +++ b/edlclient/Library/firehose_client.py @@ -646,7 +646,8 @@ class firehose_client(metaclass=LogBase): res = self.firehose.detect_partition(options, "boot_a") if res[0]: lun = res[1] - partition = res[2] + _, backup_guid_gpt = self.firehose.get_gpt(lun, 0, 0, 0) + partition = backup_guid_gpt.partentries["boot_a"] active = ((partition.flags >> (AB_FLAG_OFFSET*8))&0xFF) & AB_PARTITION_ATTR_SLOT_ACTIVE == AB_PARTITION_ATTR_SLOT_ACTIVE if active: self.printer("Current active slot: a") @@ -654,7 +655,8 @@ class firehose_client(metaclass=LogBase): res = self.firehose.detect_partition(options, "boot_b") if res[0]: lun = res[1] - partition = res[2] + _, backup_guid_gpt = self.firehose.get_gpt(lun, 0, 0, 0) + partition = backup_guid_gpt.partentries["boot_a"] active = ((partition.flags >> (AB_FLAG_OFFSET*8))&0xFF) & AB_PARTITION_ATTR_SLOT_ACTIVE == AB_PARTITION_ATTR_SLOT_ACTIVE if active: self.printer("Current active slot: b") From 3ba102a99535f6209fc3a4bbaf0ee7273d36b476 Mon Sep 17 00:00:00 2001 From: bongbui321 Date: Thu, 28 Mar 2024 03:03:01 -0400 Subject: [PATCH 2/3] backup --- edlclient/Library/firehose_client.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/edlclient/Library/firehose_client.py b/edlclient/Library/firehose_client.py index 358e4b1..a1b6342 100644 --- a/edlclient/Library/firehose_client.py +++ b/edlclient/Library/firehose_client.py @@ -643,19 +643,21 @@ class firehose_client(metaclass=LogBase): else: return self.firehose.cmd_setbootablestoragedrive(int(options[""])) elif cmd == "getactiveslot": - res = self.firehose.detect_partition(options, "boot_a") + res = self.firehose.detect_partition(options, "boot_a", send_full=True) if res[0]: lun = res[1] - _, backup_guid_gpt = self.firehose.get_gpt(lun, 0, 0, 0) + prim_guid_gpt = res[3] + _, backup_guid_gpt = self.firehose.get_gpt(lun, 0, 0, 0, prim_guid_gpt.header.backup_lba) partition = backup_guid_gpt.partentries["boot_a"] active = ((partition.flags >> (AB_FLAG_OFFSET*8))&0xFF) & AB_PARTITION_ATTR_SLOT_ACTIVE == AB_PARTITION_ATTR_SLOT_ACTIVE if active: self.printer("Current active slot: a") return True - res = self.firehose.detect_partition(options, "boot_b") + res = self.firehose.detect_partition(options, "boot_b", send_full=True) if res[0]: lun = res[1] - _, backup_guid_gpt = self.firehose.get_gpt(lun, 0, 0, 0) + prim_guid_gpt = res[3] + _, backup_guid_gpt = self.firehose.get_gpt(lun, 0, 0, 0, prim_guid_gpt.header.backup_lba) partition = backup_guid_gpt.partentries["boot_a"] active = ((partition.flags >> (AB_FLAG_OFFSET*8))&0xFF) & AB_PARTITION_ATTR_SLOT_ACTIVE == AB_PARTITION_ATTR_SLOT_ACTIVE if active: From 5748dd5b1ecc43d783d083f381d8f9be97160160 Mon Sep 17 00:00:00 2001 From: bongbui321 Date: Thu, 28 Mar 2024 03:04:58 -0400 Subject: [PATCH 3/3] b --- edlclient/Library/firehose_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/edlclient/Library/firehose_client.py b/edlclient/Library/firehose_client.py index a1b6342..8214f3d 100644 --- a/edlclient/Library/firehose_client.py +++ b/edlclient/Library/firehose_client.py @@ -658,7 +658,7 @@ class firehose_client(metaclass=LogBase): lun = res[1] prim_guid_gpt = res[3] _, backup_guid_gpt = self.firehose.get_gpt(lun, 0, 0, 0, prim_guid_gpt.header.backup_lba) - partition = backup_guid_gpt.partentries["boot_a"] + partition = backup_guid_gpt.partentries["boot_b"] active = ((partition.flags >> (AB_FLAG_OFFSET*8))&0xFF) & AB_PARTITION_ATTR_SLOT_ACTIVE == AB_PARTITION_ATTR_SLOT_ACTIVE if active: self.printer("Current active slot: b")