drgn/examples/linux/fs_inodes.py
Omar Sandoval 772254af3f examples: fix fs_inodes.py
Commit 48c5f37d01 ("Make read_once() a method again, as
Object.read_()") mistakenly changed fs_inodes.py to a benchmark I was
running. Additionally, commit 393a1f3149 ("Document with Sphinx")
changed the for_each_mount() helper to only yield the struct mount *.
2019-04-11 15:11:36 -07:00

29 lines
653 B
Python
Executable File

"""List the paths of all inodes cached in a given filesystem"""
from drgn.helpers.linux.fs import for_each_mount, inode_path
from drgn.helpers.linux.list import list_for_each_entry
import os
import sys
import time
if len(sys.argv) == 1:
path = '/'
else:
path = sys.argv[1]
mnt = None
for mnt in for_each_mount(prog, dst=path):
pass
if mnt is None:
sys.exit(f'No filesystem mounted at {path}')
sb = mnt.mnt.mnt_sb
for inode in list_for_each_entry('struct inode', sb.s_inodes.address_of_(),
'i_sb_list'):
try:
print(os.fsdecode(inode_path(inode)))
except ValueError:
continue