From: Libor Vanek <libor@conet.cz>
To: "Richard B. Johnson" <root@chaos.analogic.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Read from file fails
Date: Mon, 3 May 2004 17:06:06 +0200 [thread overview]
Message-ID: <20040503150606.GB6411@Loki> (raw)
In-Reply-To: <Pine.LNX.4.53.0405030852220.10896@chaos>
> I will explain for the Nth time. The kernel is a bunch of code
> that performs functions on behalf of a process. It does that in
> the context of that process. A file descriptor is a number that
> belongs to a process. It is worthless without a process with which
> to associate. If the kernel were to open a file, who owns the
> file descriptor? The kernel isn't a process, it's a big LIBRARY!
OK - speaking of this I just want call one public (exported) function of library from another.
> So, if you are lucky, you can steal the context from another
> unknowing process. This works unless there was a context-switch or
> if the process was asleep so it didn't access any files of
> its own. It leaves the kernel in a bad state because there
> is a wild file-descriptor that nobody owns that will never be
> closed because when your cludge closes that file-descriptor, you
> probably end up closing STDOUT_FILENO of some important task
> that you haven't discovered yet.
>
> The cludges that work involve creating a "kernel thread" which
> has a process context. That thread does the file I/O. However,
> it's certainly easier to create a user-mode task (program) that
> opens your module and, using an ioctl(), sends it anything from
> anywhere in the known universe. You can get data from a file or
> from anywhere.
OK - so speaking of kernel thread - what function should I use? Or do you think that only the difference of having process context and pid will cause read to work? (I'm willing to believe it ;-) - I'll try it later)
I think there are reasons (speed, speed, speed...) why some things should be done kernel-space. And I think that this is one of them. I know that I'll never want to "send data from anywhere in the known universe" (famous last words?) - I just need to create backup copy of file.
Libor
next prev parent reply other threads:[~2004-05-03 15:06 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-03 0:00 Read from file fails Libor Vanek
2004-05-03 13:11 ` Richard B. Johnson
2004-05-03 15:06 ` Libor Vanek [this message]
2004-05-04 0:47 ` Richard B. Johnson
2004-05-04 1:19 ` Libor Vanek
2004-05-04 13:49 ` Richard B. Johnson
2004-05-05 10:34 ` Libor Vanek
2004-05-04 14:31 ` Bart Samwel
2004-05-05 9:54 ` Libor Vanek
2004-05-05 10:04 ` Bart Samwel
2004-05-05 10:19 ` Libor Vanek
2004-05-05 10:45 ` Bart Samwel
2004-05-05 11:22 ` Libor Vanek
2004-05-05 11:50 ` Bart Samwel
2004-05-05 10:54 ` Denis Vlasenko
2004-05-05 11:58 ` Michael Clark
2004-05-04 18:45 ` Paulo Marques
2004-05-05 9:47 ` Libor Vanek
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=20040503150606.GB6411@Loki \
--to=libor@conet.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=root@chaos.analogic.com \
/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