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 straceing 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

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -