Files
ext4recovery/test/check_deleted_orphans.py
2026-04-30 11:04:05 +00:00

21 lines
806 B
Python

print(f"\nOrphaned roots: {len(true_roots)}")
print(f"{'inode':>12} {'parent':>12} {'status':>12} {'dtime':>12} reason")
print('-' * 75)
with open(DEV, 'rb') as f:
for inum, parent, reason in sorted(true_roots):
try:
idata, slot = read_inode(f, sb, gdt_data, inum)
status = classify_inode(idata, slot)
dtime = struct.unpack_from('<I', idata, slot + 20)[0]
# Format dtime as human readable if set
if dtime:
import datetime
dt = datetime.datetime.fromtimestamp(dtime).strftime('%Y-%m-%d %H:%M:%S')
else:
dt = 'never'
except Exception:
status, dt = 'unreadable', 'unknown'
print(f"{inum:>12} {parent:>12} {status:>12} {dt:>19} {reason}")