From ed32ba0b15f63c345fe92fb19e469c83baa548c3 Mon Sep 17 00:00:00 2001 From: bongbui321 Date: Sun, 24 Mar 2024 23:02:59 -0400 Subject: [PATCH] test --- edlclient/Library/firehose.py | 89 ++++++++++++++++++++--------------- edlclient/Library/gpt.py | 1 + 2 files changed, 52 insertions(+), 38 deletions(-) diff --git a/edlclient/Library/firehose.py b/edlclient/Library/firehose.py index c58966e..4dc4d68 100755 --- a/edlclient/Library/firehose.py +++ b/edlclient/Library/firehose.py @@ -768,7 +768,7 @@ class firehose(metaclass=LogBase): return None, None data = resp.data magic = unpack(" 64: sectors = 64 - if primary: - data = self.cmd_read_buffer(lun, start_sector, sectors, False) - if data == b"": - self.error("data is empty") - return None, None - guid_gpt.parse(data.data, self.cfg.SECTOR_SIZE_IN_BYTES) - return data.data, guid_gpt - else: - num_part_sectors = (header.num_part_entries * header.part_entry_size)//self.cfg.SECTOR_SIZE_IN_BYTES - if num_part_sectors % self.cfg.SECTOR_SIZE_IN_BYTES != 0: - num_part_sectors += 1 - self.warning(f"{num_part_sectors}") - part_table = self.cmd_read_buffer(lun, header.part_entry_start_lba, num_part_sectors, False) - #self.warning("got here") - #self.warning(f"{data}") - parse_data = (b'0' * self.cfg.SECTOR_SIZE_IN_BYTES) + data + part_table.data - guid_gpt.parse(parse_data, self.cfg.SECTOR_SIZE_IN_BYTES) - return parse_data, guid_gpt + data = self.cmd_read_buffer(lun, start_sector, sectors, False) + if data == b"": + return None, None + guid_gpt.parse(data.data, self.cfg.SECTOR_SIZE_IN_BYTES) + return data.data, guid_gpt + #else: + # num_part_sectors = (header.num_part_entries * header.part_entry_size)//self.cfg.SECTOR_SIZE_IN_BYTES + # if num_part_sectors % self.cfg.SECTOR_SIZE_IN_BYTES != 0: + # num_part_sectors += 1 + # self.warning(f"{num_part_sectors}") + # part_table = self.cmd_read_buffer(lun, header.part_entry_start_lba, num_part_sectors, False) + # #self.warning("got here") + # #self.warning(f"{data}") + # parse_data = (b'0' * self.cfg.SECTOR_SIZE_IN_BYTES) + data + part_table.data + # guid_gpt.parse(parse_data, self.cfg.SECTOR_SIZE_IN_BYTES) + # return parse_data, guid_gpt else: - self.error(" in error efipart") return None, None except Exception as err: self.debug(str(err)) @@ -1488,20 +1501,20 @@ class firehose(metaclass=LogBase): # prim_start_sector_patch_a, prim_start_sector_patch_b, # prim_byte_offset_patch_a, prim_byte_offset_patch_b) - resp_a = self.cmd_read_buffer(lun_a, guid_gpt_a.header.backup_lba, 1, False) - if not (resp_a.resp): - self.error("Error in trying to retrieve backup gpt headers") - return False - backup_hdr_a = gpt.gpt_header(resp_a.data) - sectors = (backup_hdr_a.num_part_entries * backup_hdr_a.part_entry_size) // self.cfg.SECTOR_SIZE_IN_BYTES - part_table_a = self.cmd_read_buffer(lun_a, backup_hdr_a.part_entry_start_lba, sectors, False) - if lun_a == lun_b: - backup_hdr_b = backup_hdr_a - part_table_b = part_table_a - else: - resp_b = self.cmd_read_buffer(lun_b, guid_gpt_b.header.backup_lba, 1, False) - backup_hdr_b = gpt.gpt_header(resp_b.data) - part_table_b = self.cmd_read_buffer(lun_b, backup_hdr_b.part_entry_start_lba, sectors, False) + #resp_a = self.cmd_read_buffer(lun_a, guid_gpt_a.header.backup_lba, 1, False) + #if not (resp_a.resp): + # self.error("Error in trying to retrieve backup gpt headers") + # return False + #backup_hdr_a = gpt.gpt_header(resp_a.data) + #sectors = (backup_hdr_a.num_part_entries * backup_hdr_a.part_entry_size) // self.cfg.SECTOR_SIZE_IN_BYTES + #part_table_a = self.cmd_read_buffer(lun_a, backup_hdr_a.part_entry_start_lba, sectors, False) + #if lun_a == lun_b: + # backup_hdr_b = backup_hdr_a + # part_table_b = part_table_a + #else: + # resp_b = self.cmd_read_buffer(lun_b, guid_gpt_b.header.backup_lba, 1, False) + # backup_hdr_b = gpt.gpt_header(resp_b.data) + # part_table_b = self.cmd_read_buffer(lun_b, backup_hdr_b.part_entry_start_lba, sectors, False) #print(f"signature: {backup_hdr_a.signature}") @@ -1520,7 +1533,7 @@ class firehose(metaclass=LogBase): #print(f"crc32_part_entries: {backup_hdr_a.crc32_part_entries}") - #back_gpt_data_a, backup_guid_gpt_a = self.get_gpt(lun_a, 0, 0 , 0, start_sector=guid_gpt_a.header.backup_lba, primary=False) + back_gpt_data_a, backup_guid_gpt_a = self.get_gpt(lun_a, 0, 0 , 0, start_sector=guid_gpt_a.header.backup_lba, primary=False) #if (backup_guid_gpt_a is None): # self.error("error in backup") # return False diff --git a/edlclient/Library/gpt.py b/edlclient/Library/gpt.py index 070819c..d668090 100755 --- a/edlclient/Library/gpt.py +++ b/edlclient/Library/gpt.py @@ -351,6 +351,7 @@ class gpt(metaclass=LogBase): def parse(self, gptdata, sectorsize=512): + self.warning("got here") self.header = self.gpt_header(gptdata[sectorsize:sectorsize + 0x5C]) self.sectorsize = sectorsize if self.header.signature != b"EFI PART":