implementing ioctl's for device drivers

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

Reply to
sapna
Loading thread data ...

[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
Klein-Winternheim / Germany       http://www.sysgo.com
Reply to
Robert Kaiser

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

greetings

Reply to
M.Kmann

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.