34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
import subprocess, struct
|
|
|
|
CHUNK = 128*512
|
|
LV_START = 5120000*512
|
|
BSIZE = 4096
|
|
|
|
# Check istat for volumes dir (inode 1585918) - we know fls works on this
|
|
r = subprocess.run(['istat', '/dev/nbd0', '1585918'],
|
|
capture_output=True, text=True)
|
|
print('istat for volumes (inode 1585918):')
|
|
print(r.stdout)
|
|
|
|
# Check istat for pterodactyl dir (inode 1574102)
|
|
r2 = subprocess.run(['istat', '/dev/nbd0', '1574102'],
|
|
capture_output=True, text=True)
|
|
print('istat for pterodactyl (inode 1574102):')
|
|
print(r2.stdout)
|
|
|
|
# Check which chunk each data block falls in
|
|
def check_block(block_num):
|
|
virt = block_num * BSIZE
|
|
group = virt // (5*CHUNK)
|
|
in_group = virt % (5*CHUNK)
|
|
chunk_idx = in_group // CHUNK
|
|
return chunk_idx
|
|
|
|
# Parse direct blocks from istat output
|
|
for line in r.stdout.splitlines():
|
|
if 'Direct Blocks' in line or (line.strip() and line.strip()[0].isdigit()):
|
|
blocks = [int(x) for x in line.split() if x.isdigit()]
|
|
for b in blocks:
|
|
ci = check_block(b)
|
|
print(f' block {b}: chunk_idx={ci} {"METADATA" if ci==4 else "DATA"}')
|