From: Ben Nizette <bn@niasdigital.com>
To: joseluismarchetti@yahoo.com.br
Cc: Robert Hancock <hancockr@shaw.ca>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
linux-kernel@vger.kernel.org
Subject: Re: How to access a regular file from within a module ?
Date: Tue, 13 Jan 2009 09:25:40 +1100 [thread overview]
Message-ID: <1231799141.2714.24.camel@linux-51e8.site> (raw)
In-Reply-To: <113881.9018.qm@web34408.mail.mud.yahoo.com>
On Mon, 2009-01-12 at 07:51 -0800, Jose Luis Marchetti wrote:
> OK, that is clear now.
> From all I read, it is possible to access files from within inside the kernel, but it would not be a good practice, thanks for the insights.
> >
I don't know why no-one's brought this up already but no, it usually
isn't even possible. As previously mentioned, you will hijack the
current user context to do your file operations. That context may be in
a different filesystem namespace (eg due to chroot'ing) and as such
*won't even be able to see the file you're trying to hit*.
Even if you create a new kernel thread which is parented to init you'll
get a consistent view of files but it's still very hard to know it's the
*right* view of files.
http://kernelnewbies.org/FAQ/WhyWritingFilesFromKernelIsBad
--Ben.
prev parent reply other threads:[~2009-01-12 22:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-11 3:44 How to access a regular file from within a module ? Jose Luis Marchetti
2009-01-11 5:35 ` Jon Masters
2009-01-11 6:13 ` H. Peter Anvin
2009-01-11 11:30 ` Alan Cox
2009-01-12 2:44 ` Jose Luis Marchetti
2009-01-12 4:36 ` Robert Hancock
2009-01-12 15:51 ` Jose Luis Marchetti
2009-01-12 22:25 ` Ben Nizette [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=1231799141.2714.24.camel@linux-51e8.site \
--to=bn@niasdigital.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=hancockr@shaw.ca \
--cc=joseluismarchetti@yahoo.com.br \
--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