Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 08 Jan 2003 13:15:50 -0800
From:      Terry Lambert <tlambert2@mindspring.com>
To:        omestre <omestre@SDF.LONESTAR.ORG>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: read in kernel mode...
Message-ID:  <3E1C9506.FD69C710@mindspring.com>
References:  <Pine.NEB.4.33.0301081946050.2678-100000@sdf.lonestar.org>

next in thread | previous in thread | raw e-mail | index | archive | help
omestre wrote:
>  Hello,
>  I need read some data in kernel mode... Somebody can help me?
>  I have tried with read function, but i got segmentation fault...
>  And i can't use the stdio.h :) then, how can i do this job???

The problem you are having is because you do not have a process
address space context for the copyout() to user space that's built
into the read(2) routine: you can not use the read(2) routine
directly from a kernel context, and you can only use it from an
adopted process context if you expend a great deal of effort.

You probably need to ask yourself three things:

1)	What problem are you really trying to solve here, that
	makes you think you need to do file I/O in the kernel?

2)	Have you considered other solutions to the problem, ones
	which do not require file I/O in the kernel?

3)	Have you looked at the mailing list archives, to see the
	three documented methods of doing this evil thing, which
	people have already hashed out?

-- Terry

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3E1C9506.FD69C710>