From: Corey Minyard <minyard@acm.org>
To: linux-kernel@vger.kernel.org
Subject: How to open files a process has mmapped
Date: Fri, 05 Apr 2002 09:58:16 -0600 [thread overview]
Message-ID: <3CADC998.9060501@acm.org> (raw)
I'm trying to solve a problem where a customer needs to be able to open
a file a process has mmap-ed. The trouble is that the file might be
deleted (this is actually likely in this scenario) so I can't just open
the file listed in /proc/<pid>/maps.
I have looked some at this, and I haven't come up with a good solution
for this. I have come up with the following solutions:
Open /proc/<pid>/mem and get the memory directly. This has two problems:
* You have to ptrace() the process to do this. Actually, that seems
a little silly. Why do you have to ptrace() the process to do this?
* The whole file might not be mapped, thus the section of the file
that is interesting might not be in memory.
Another solution I thought of was to provide a /proc/<pid>/mapped_files
directory that works like the /proc/<pid>/fd directory. Unfortunately,
it looks very difficult to implement this because of the need to provide
consistent inodes. For fds, you have an easy way to generate inodes
with the fd number. For mmap-ed memory, you don't have a relatively
small number to do this with.
The last solution I could think of was to provide a way to open a file
with using the major/minor/inode (since these are listed for the mapped
files in the /proc/<pid>/maps file). This is kind of ugly, but it's
probably the best one I've thought of.
Any more ideas? Maybe there's an easy way to do this that I haven't found.
-Corey
next reply other threads:[~2002-04-05 15:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-04-05 15:58 Corey Minyard [this message]
2002-04-06 17:50 ` How to open files a process has mmapped Alan Cox
2002-04-07 20:19 ` Corey Minyard
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=3CADC998.9060501@acm.org \
--to=minyard@acm.org \
--cc=linux-kernel@vger.kernel.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