mirror of
https://github.com/JakeHillion/drgn.git
synced 2024-12-23 09:43:06 +00:00
bbaf608af0
I used this to find some missing sockets that weren't showing up in lsof or ss. Signed-off-by: Omar Sandoval <osandov@osandov.com>
24 lines
648 B
Python
Executable File
24 lines
648 B
Python
Executable File
#!/usr/bin/env drgn
|
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
"""Find what process is using a struct file *, given as an address."""
|
|
|
|
import sys
|
|
|
|
from drgn import Object
|
|
from drgn.helpers.linux.fs import for_each_file
|
|
from drgn.helpers.linux.pid import for_each_task
|
|
|
|
file = Object(prog, "struct file *", int(sys.argv[1], 0))
|
|
for task in for_each_task(prog):
|
|
for fd, file2 in for_each_file(task):
|
|
if file2 == file:
|
|
break
|
|
else:
|
|
continue
|
|
break
|
|
else:
|
|
print("Not found:(")
|
|
print(f"PID {task.pid.value_()} COMM {task.comm.string_().decode()} FD {fd}")
|