From: greg@kroah.com (Greg KH)
To: kernelnewbies@lists.kernelnewbies.org
Subject: How to get list of all files open in the system
Date: Sat, 14 Nov 2015 17:03:44 -0800 [thread overview]
Message-ID: <20151115010344.GA1811@kroah.com> (raw)
In-Reply-To: <8B70E6A77A644014ADEC93962391CDE4@userd2e90fe60c>
On Sat, Nov 14, 2015 at 08:13:26PM +0200, Sergei Starovoi wrote:
> Hi, all.
>
> I'm writing a kernel module. One of its tasks requires getting full paths of
> all open files in the system.
That's a very odd request, why would a kernel module ever care about
such a thing? And in what namespace do these files need to be in?
> My first solution essentially looks like:
> for_each_process_thread(process, thread)
> iterate_fd(files, 0, my_callback, NULL);
> my_callback calls d_path for passed file->f_path to get its full path.
>
> But this solution has obvious problems:
> A. It will skip files which were opened directly from kernel code (using
> filp_open for example);
You shouldn't care about those, but then again, you aren't saying why
you care about open files, so I can't judge that.
thanks,
greg k-h
prev parent reply other threads:[~2015-11-15 1:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-14 18:13 How to get list of all files open in the system Sergei Starovoi
2015-11-15 1:03 ` Greg KH [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151115010344.GA1811@kroah.com \
--to=greg@kroah.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).