Re: Issue with ioctl commands - Linux version 2.6.35.7+
On 12/27/11, Alexandru Juncu <alex.juncu@rosedu.org> wrote:
On Tue, Dec 27, 2011 at 1:57 PM, Chetan Nanda <chetannanda@gmail.com> wrote:
On Tue, Dec 27, 2011 at 5:23 PM, Alexandru Juncu <alex.juncu@rosedu.org> wrote:
On Tue, Dec 27, 2011 at 1:39 PM, Chetan Nanda <chetannanda@gmail.com> wrote:
Hi All,
I am facing a strange issue with the ioctl commands, and not able to find what wrong I am doing. I am trying with a dummy kernel driver and implemented ioctl command as follow:
in my_ioctl.h #define READHWREG_MAGIC_NUMBER 0x15 #define READHWREG_CAM_READPE _IOR(READHWREG_MAGIC_NUMBER, 1, int*)
But the value of 'READHWREG_CAM_READPE' is comes out to be different in userspace (in the application) and kernel space (in the driver).
In userspace I used ioctl as ... printf("\ncommand %x \n",READHWREG_CAM_READPE); <-- command 80041501 error = ioctl(g_DevFileId, READHWREG_CAM_READPE); ..
In kernel space
int readHwReg_ioctl(struct inode *node, struct file *filp, unsigned int cmd, unsigned long arg) { ... printk("\n%d %s cmd = %x\n",__LINE__,__FUNCTION__,cmd); <--- cmd = bee6a9d4 ... }
I am not able to figure out the root cause, Please help to check...
I think that the command is actually sent via the arg parameter, which is an address (it's a pointer to the value your are sending to kernel space).
Yes, even I observe this now. But how this can happen. 'command' is the second argument for ioctl call.
As far as I remember, you can send an integer through the cmd, but other things (like structures or buffers) through their address (and copy_from_user-ed). But, maybe, on new implementations (or on some architectures) everything is send via address.
What I have observed, third argument of the ioctl system call is reaching the driver as a command. ioctl(g_DevFileId, READHWREG_CAM_READPE, xx); In driver: int readHwReg_ioctl(struct inode *node, struct file *filp, unsigned int cmd, unsigned long arg) cmd is equal to xx Am I missing something in the driver/application. Thanks, Chetan Nanda
participants (1)
-
Chetan Nanda