import struct CHUNK = 128*512 LV_START = 5120000*512 BSIZE = 4096 BPG = 32768 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) # Load GDT NUM_GROUPS = 35728 gdt_data = read_virt(BSIZE, NUM_GROUPS*64) def get_block_bitmap_block(group): entry = gdt_data[group*64:(group+1)*64] bb_lo = struct.unpack_from('