From 762c76300d6bdd90723334b4d41fd0e1079e1b4a Mon Sep 17 00:00:00 2001 From: bongbui321 Date: Tue, 5 Mar 2024 23:46:43 -0500 Subject: [PATCH 1/4] tmp fix --- edlclient/Library/firehose.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/edlclient/Library/firehose.py b/edlclient/Library/firehose.py index 1631fe6..2c29eb2 100755 --- a/edlclient/Library/firehose.py +++ b/edlclient/Library/firehose.py @@ -1303,6 +1303,21 @@ def cmd_getstorageinfo(self): return None def cmd_setactiveslot(self, slot: str): + def cmd_patch_multiple(lun, start_sector_patch, byte_offset_patch, headeroffset, pdata, header): + offset = 0 + header_size = len(header) + pdata_size = len(pdata) + write_size = pdata_size # with assumption pdata_size > header_size + patch_subset_size = 4 + for i in range(0, write_size, patch_subset_size): + pdata_subset = int(unpack(" Date: Wed, 6 Mar 2024 00:04:47 -0500 Subject: [PATCH 2/4] fix setactiveslot --- edlclient/Library/firehose.py | 27 ++++++++++++++++----------- edlclient/Library/gpt.py | 4 ++-- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/edlclient/Library/firehose.py b/edlclient/Library/firehose.py index 3022e53..724983e 100755 --- a/edlclient/Library/firehose.py +++ b/edlclient/Library/firehose.py @@ -1303,19 +1303,24 @@ def cmd_getstorageinfo(self): return None def cmd_setactiveslot(self, slot: str): - def cmd_patch_multiple(lun, start_sector_patch, byte_offset_patch, headeroffset, pdata, header): - offset = 0 + def cmd_patch_multiple(lun, start_sector_patch, byte_offset_patch, headeroffset, pdata, header): + offset = 0 header_size = len(header) - pdata_size = len(pdata) - write_size = pdata_size # with assumption pdata_size > header_size - patch_subset_size = 4 - for i in range(0, write_size, patch_subset_size): - pdata_subset = int(unpack(" Date: Wed, 6 Mar 2024 01:16:21 -0500 Subject: [PATCH 3/4] set every active partition --- edlclient/Library/firehose.py | 49 +++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/edlclient/Library/firehose.py b/edlclient/Library/firehose.py index 724983e..29e2650 100755 --- a/edlclient/Library/firehose.py +++ b/edlclient/Library/firehose.py @@ -1334,29 +1334,32 @@ def cmd_patch_multiple(lun, start_sector_patch, byte_offset_patch, headeroffset, partslots["_a"] = False partslots["_b"] = True fpartitions = {} - for lun in self.luns: - lunname = "Lun" + str(lun) - fpartitions[lunname] = [] - data, guid_gpt = self.get_gpt(lun, int(0), int(0), int(0)) - if guid_gpt is None: - break - else: - for partitionname in guid_gpt.partentries: - gp = gpt() - slot = partitionname.lower()[-2:] - if "_a" in slot or "_b" in slot: - pdata, poffset = gp.patch(data, partitionname, active=partslots[slot]) - data[poffset:poffset + len(pdata)] = pdata - wdata = gp.fix_gpt_crc(data) - if wdata is not None: - start_sector_patch = poffset // self.cfg.SECTOR_SIZE_IN_BYTES - byte_offset_patch = poffset % self.cfg.SECTOR_SIZE_IN_BYTES - headeroffset = gp.header.current_lba * gp.sectorsize - start_sector_hdr = headeroffset // self.cfg.SECTOR_SIZE_IN_BYTES - header = wdata[start_sector_hdr:start_sector_hdr + gp.header.header_size] - cmd_patch_multiple(lun, start_sector_patch, byte_offset_patch, headeroffset, pdata, header) - return True - return False + try: + for lun in self.luns: + lunname = "Lun" + str(lun) + fpartitions[lunname] = [] + data, guid_gpt = self.get_gpt(lun, int(0), int(0), int(0)) + if guid_gpt is None: + break + else: + for partitionname in guid_gpt.partentries: + gp = gpt() + slot = partitionname.lower()[-2:] + if "_a" in slot or "_b" in slot: + pdata, poffset = gp.patch(data, partitionname, active=partslots[slot]) + data[poffset:poffset + len(pdata)] = pdata + wdata = gp.fix_gpt_crc(data) + if wdata is not None: + start_sector_patch = poffset // self.cfg.SECTOR_SIZE_IN_BYTES + byte_offset_patch = poffset % self.cfg.SECTOR_SIZE_IN_BYTES + headeroffset = gp.header.current_lba * gp.sectorsize + start_sector_hdr = headeroffset // self.cfg.SECTOR_SIZE_IN_BYTES + header = wdata[start_sector_hdr:start_sector_hdr + gp.header.header_size] + cmd_patch_multiple(lun, start_sector_patch, byte_offset_patch, headeroffset, pdata, header) + except Exception as err: + self.error(str(err)) + return False + return True From 195a50c02e86d216a2c1448497a44a5b143b5cfb Mon Sep 17 00:00:00 2001 From: bongbui321 Date: Wed, 6 Mar 2024 01:52:56 -0500 Subject: [PATCH 4/4] fix indent --- edlclient/Library/firehose.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/edlclient/Library/firehose.py b/edlclient/Library/firehose.py index 29e2650..0f5c771 100755 --- a/edlclient/Library/firehose.py +++ b/edlclient/Library/firehose.py @@ -1316,8 +1316,8 @@ def cmd_patch_multiple(lun, start_sector_patch, byte_offset_patch, headeroffset, size_each_patch, True) if i < header_size: header_subset = int(unpack("