[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: kernel read/write



Quoting Michael Edward Christman (mec60@columbia.edu):
> I am modifying a current driver inoder to control it by using read/writes.
> I am trying to implement the memcpy_tofs/memcpy_fromfs.  My question is
> how do I find the pointer to the user space.

My previous reply assumed that you knew that already,
from your own assumption:

"am attempting to use memcpy_tofs and memcpy_fromfs, but am having
 some trouble.  If I use these functions in the application level,
 what do I use for the *to and *from variables.  I assume that you
 can use a FILE for whatever is in the user space,"

>  I have tried to use fopen()
> etc. but there are conflicts when I try to include "stdio.h".

You're not trying to fopen() in the driver, are you? You open the
device /dev/foo in the user program, and the driver catches the
read/writes on that file.

> As this is
> a previously created driver i don't want to start playing with it.

Ironically, you would do well to base your driver on an existing
driver in the kernel source. Otherwise, buy Rubini's Linux Device
Drivers (O'Reilly).

Not knowing what driver you're modifying and what you're trying to do
with it, it all seems a bit unusual. Most drivers will already contain
code to handle reads and writes as that's in the nature of drivers.
In-band control is usually undesirable because it interferes with
the primary data (like xon/xoff do in binary data). I would be
less surprised if you were trying to add ioctls to control it.

> Any ideas?

And to repeat what I said before, it's definitely worth seeing if
you can move on to 2.2 kernels (and Rubini's chapter 17) because
many of the macros and functions have been made cleverer.

Cheers,

-- 
Email:  d.wright@open.ac.uk   Tel: +44 1908 653 739  Fax: +44 1908 655 151
Snail:  David Wright, Earth Science Dept., Milton Keynes, England, MK7 6AA
Disclaimer:   These addresses are only for reaching me, and do not signify
official stationery. Views expressed here are either my own or plagiarised.


Reply to: