lkml.org 
[lkml]   [2003]   [Jun]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Bad address problem while reading from hard disk(using sys_read).
On Fri, 20 Jun 2003, BalaKrishna Mallipeddi wrote:

> Hi,
> I developed a kernel module. Within that i am
> dynamically allocating memory(using kmalloc and
> vmalloc) for a buffer to read data. After that while
> trying to read into this buffer from the hard disk
> using sys_read i am getting an error. And the same
> error i am getting while writing into another buffer,
> which was allocated in the same way, using sys_write.
> The error number set is -14(EFAULT) i.e., Bad address.
>
>
> Give me any idea to resolve the problem.
>
> If anyone help me i am gretful to them.

All sys_* functions expect user space addresses and you passing a kernel
space one. You need something like :

mm_segment_t oldfs;

oldfs = get_fs();
set_fs(KERNEL_DS);
nread = sys_read(fd, buf, cnt);
set_fs(oldfs);

(If you really want to do that)



- Davide

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

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