import struct CHUNK = 128*512 LV_START = 5120000*512 BSIZE = 4096 IPG = 8192 def read_virt(virt_byte, length): result = bytearray(length) pos = virt_byte remaining = length with open('/dev/md0','rb') as f: while remaining > 0: group = pos // (5*CHUNK) in_group = pos % (5*CHUNK) chunk_idx = in_group // CHUNK intra = in_group % CHUNK seg_len = min(CHUNK-intra, remaining) dst_off = pos - virt_byte if chunk_idx != 4: phys = LV_START + group*4*CHUNK + chunk_idx*CHUNK + intra f.seek(phys) data = f.read(seg_len) result[dst_off:dst_off+len(data)] = data pos += seg_len remaining -= seg_len return bytes(result) NUM_GROUPS = 35728 gdt_data = read_virt(BSIZE, NUM_GROUPS*64) def get_inode_table_block(group): entry = gdt_data[group*64:(group+1)*64] it_lo = struct.unpack_from(' 0 and name_len > 0: name = blk_data[off2+8:off2+8+name_len].decode('utf-8',errors='replace') tname = {1:'file',2:'dir',7:'link'}.get(ftype,'?') print(f' entry: {tname} inode={ino} {name!r}') count += 1 off2 += rec_len if count == 0: print(f' No valid directory entries found') else: print(f' depth={eh_depth} - need to follow interior nodes') # Read interior node for i in range(min(eh_entries,4)): off = 52+i*12 ei_block = struct.unpack_from(' 0 and name_len > 0: name = blk_data[off3+8:off3+8+name_len].decode('utf-8',errors='replace') tname = {1:'file',2:'dir',7:'link'}.get(ftype,'?') print(f' entry: {tname} inode={ino} {name!r}') off3 += rec_len