filesystems - How to get all open file handles in kernel space code? -
i want write code in kernel space find open file handles in system , process id
holdes handles.
in user space can using utility "lsof
". similarly, want same in kernel space.
what's great linux kernel it's open source. if want understand how implement similar lsof
why not inspecting its' source code (i suggest the following implementation, android 4.2.2 source tree, @ simplified , easier understand) or strace
ing understand how magic happens?
if you'll so, @ point you'll encounter following lines
openat(at_fdcwd, "/proc/<pid>/fd", o_rdonly|o_nonblock|o_directory|o_cloexec)
which hint each pid running, procfs
able print information open file descriptors process holds. therefore, this start research , journey through code.
Comments
Post a Comment