implementing ioctl's for device drivers

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
hi all,

we are beginners in kernel programming. we are writing a device
driver. we tried a very simple ioctl to pass an integer pointer from
user to kernel space.
the problem is that the ioctl_param argument which is supposed to hold
the address of the memory in user space(from wer data is to be copied
to kernel space,i.e driver)is not getting passed correctly.

wen we print the address in user space & wen we print the address
getting passed to kernel space they r different. the correct user
space location is not getting accessed at all.

we have used the get_user to transfer the required data into kernel
space.

we followed the linux kernel modular programming guide written by
peter salzman.

anybody with any clue y our ioctl is not working please help us as
soon as possible.

thanking you,
sapna

Re: implementing ioctl's for device drivers
    sapna snipped-for-privacy@yahoo.co.in (sapna) writes:
Quoted text here. Click to load it


[Maybe you should post some well-chosen (!) code excerpts so we don't
have to guess ....]

My guess is that you use get_user on the address of the pointer that
you pass with the ioctl(). Note that only your user space
program and your driver are aware that the parameter you are passing
is an address. To the layers in between (i.e. Linux), it is just
another odd number. Therefore, the address value should indeed be
the same when printed out in user space as well as in the driver.

However, when your driver code *dereferences* that pointer (i.e.
accesses the integer value the pointer points at), that's where
you need to use get_user.


Rob

--
Robert Kaiser                     email: rkaiser AT sysgo DOT com
SYSGO AG                          http://www.elinos.com
We've slightly trimmed the long signature. Click to see the full one.
Re: implementing ioctl's for device drivers
hy,

Quoted text here. Click to load it

use copy_to_user and copy_from_user for data transfer, it is more
straightforward.

greetings

Site Timeline