<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=koi8-r">
<META content="MSHTML 6.00.2900.6347" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi, all.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I'm writing a kernel module. One of its tasks
requires getting full paths of all open files in the system.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>My first solution essentially looks
like:<BR> for_each_process_thread(process,
thread)<BR> iterate_fd(files, 0, my_callback, NULL);<BR>my_callback
calls d_path for passed file->f_path to get its full path.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>But this solution has obvious
problems:<BR> A. It will skip files which were opened directly from
kernel code (using filp_open for example);<BR> B. It iterates over
fd_table for each thread, performing a lot of unnecessary work (invoking
my_callback multiple times for one file).</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>My questions are:<BR>1) Is there any bettter way to
get full paths of all open files?<BR>2) If there is no better way, what kind of
locking should i use<BR> a) to protect access to task list when
invoking for_each_process_thread?<BR> b) to protect access to
thread's fd_table when invoking iterate_fd?</FONT></DIV></BODY></HTML>