From: Erik Mouw <erik@harddisk-recovery.com>
To: Libor Vanek <libor@conet.cz>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Reading from file in module fails
Date: Mon, 3 May 2004 13:35:00 +0200 [thread overview]
Message-ID: <20040503113500.GB31513@harddisk-recovery.com> (raw)
In-Reply-To: <20040503105041.GA12023@Loki>
On Mon, May 03, 2004 at 12:50:41PM +0200, Libor Vanek wrote:
> I need to copy files (yes - I know that kernel shouldn't do this but
> I REALLY need).
This is ugly, but it should do the trick:
int rv;
char *argv[4] = {"/bin/cp", "/tmp/foo", "/tmp/bar", NULL};
char *envp[3] = {"HOME=/", "PATH=/sbin:/bin:/usr/sbin:/usr/bin", NULL};
rv = call_usermodehelper(argv[0], argv, envp, 1);
if(rv < 0) {
/* error handling */
}
Called from kernel, done in userspace. And if you want to access an SQL
database from kernel tomorrow, it's just a matter of changing the
usermode helper.
(BTW, if you need to copy files from kernel, it's usually a sign of bad
design)
Erik
--
+-- Erik Mouw -- www.harddisk-recovery.com -- +31 70 370 12 90 --
| Lab address: Delftechpark 26, 2628 XH, Delft, The Netherlands
next prev parent reply other threads:[~2004-05-03 11:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-03 10:50 Libor Vanek
2004-05-03 11:35 ` Erik Mouw [this message]
2004-05-03 11:43 ` Libor Vanek
2004-05-03 11:48 ` Erik Mouw
2004-05-03 12:07 ` root
2004-05-03 12:41 ` Jan-Benedict Glaw
[not found] <1RJl8-Eo-5@gated-at.bofh.it>
[not found] ` <1RJXT-19T-37@gated-at.bofh.it>
[not found] ` <1RK7v-1gJ-9@gated-at.bofh.it>
[not found] ` <1RL3A-23k-23@gated-at.bofh.it>
2004-05-03 16:55 ` Pascal Schmidt
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=20040503113500.GB31513@harddisk-recovery.com \
--to=erik@harddisk-recovery.com \
--cc=libor@conet.cz \
--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
all inboxes | Powered by JetHome®