On Tue, 2005-12-20 at 14:02 +0200, John Que wrote: [...] > I had written a very simple ioctl() method in a module; > this ioctl calls copy_to_user(); > > I am getting EFAULT when trying to call this ioctl from > use space. > > Any idea what can be the reason ? Yes. > Here is the code: > > static unsigned long my_ioctl(struct inode* inode, > struct file* file, > unsigned int cmd, > unsigned long data) > > { > ... > ... > case MY_IOCTL: > { > unsigned int result = 99; > > if (copy_to_user((unsigned int *)data, > &result, > sizeof(unsigned int))) > { > printk("copy_to_user failed\n"); > return -EFAULT; > } > > } What value is returned by copy_to_user()? Bernd -- Firmix Software GmbH http://www.firmix.at/ mobil: +43 664 4416156 fax: +43 1 7890849-55 Embedded Linux Development and Services -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/