lkml.org 
[lkml]   [2000]   [Jul]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Reading a file inside the device driver.
On Wed, 26 Jul 2000, Theodore Y. Ts'o wrote:

> Date: Wed, 26 Jul 2000 20:09:15 +0100 (BST)
> From: Tigran Aivazian <tigran@veritas.com>
>
> > There are games you can play to get around this, but such approaches are
> > fragile and complicated, and not what I'd recommend.
>
> ok, then I'd recommend it instead :)
>
> Vinay, have a look at how fs/exec.c:sys_uselib() (uselib(2) system
> call) works by using name lookup and then dentry_open() and
> file->f_op->read().
>
> sys_uselib doesn't actually try to use f_op->read. For that, you have
> to look at kernel_read(); note the magic calls to set_fs(get_ds()) and
> setfs(old_fs). This does work, but it's not something which I suspect
> we want to encourage wide-spread usage of in the kernel.

I actually knew that fact and the reason for set_fs(get_ds()) - I was
pointing him to the idea (hence mentioning f_op->read) - if I just said
use kernel_read() that would appear as "yet another way to read the
file" but it isn't. So I just "skipped the middle man" :)

>
> In general, it's far better to do file i/o outside the kernel than
> inside the kernel, if it is at all possible.

I agree.

Regards,
Tigran


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:57    [W:0.045 / U:0.636 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site