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

Re: passing variables to/from kernel space



On Tue, Jul 17, 2001 at 05:49:18PM +0530, Chirag Kantharia wrote:

> On Tue, Jul 17, 2001 at 01:01:45PM +0100, Oliver Ryan wrote:
> | 1.  How do I pass register values entered in user space to the module so 
> | that these values are loaded into the registers?  I've read up on 
> | copy_to/from_user and put/get_user but don't know how to implement them in 
> | working code.
> 
> I'd faced similar situation; I had a device entry in /dev, and a
> xxx_ioctl file operation registered. On receiving the ioctl from a user
> application, which would also pass as an argument to ioctl, an address
> to a buffer, which contained the values to be read (and written to the
> registers), one can use copy_from_user() to get those values, and then
> write it to the registers. For passing multiple values (of same kind),
> you would need to pass address of array; and for passing multiple values
> of different kinds, an address to an struct.

If I may chip in - please don't use ioctl(). It's really ugly interface. Instead
just read/write to a misc. char device, use sysctl(), or use module parms, whichever
seems to fit best.

regards
john

-- 
"Voodoo Programming:  Things programmers do that they know shouldn't work but
 they try anyway, and which sometimes actually work, such as recompiling
 everything."
	- Karl Lehenbauer
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/