2018-07-14 18:20:17 +01:00
|
|
|
"""List the paths of all inodes cached in a given filesystem"""
|
2018-07-03 07:59:39 +01:00
|
|
|
|
2019-03-29 08:59:53 +00:00
|
|
|
from drgn.helpers.linux.fs import for_each_mount, inode_path
|
|
|
|
from drgn.helpers.linux.list import list_for_each_entry
|
2018-07-03 07:59:39 +01:00
|
|
|
import os
|
|
|
|
import sys
|
2019-03-13 17:56:25 +00:00
|
|
|
import time
|
2018-07-03 07:59:39 +01:00
|
|
|
|
|
|
|
|
|
|
|
if len(sys.argv) == 1:
|
|
|
|
path = '/'
|
|
|
|
else:
|
|
|
|
path = sys.argv[1]
|
|
|
|
|
|
|
|
mnt = None
|
2019-04-11 23:11:36 +01:00
|
|
|
for mnt in for_each_mount(prog, dst=path):
|
2018-07-03 07:59:39 +01:00
|
|
|
pass
|
|
|
|
if mnt is None:
|
|
|
|
sys.exit(f'No filesystem mounted at {path}')
|
|
|
|
|
|
|
|
sb = mnt.mnt.mnt_sb
|
|
|
|
|
2019-04-11 23:11:36 +01:00
|
|
|
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
|