receiveing err "ENOTTY" in using ioctl .
I am receiving errno 25 in the below code.
Summary of what i have done:
1. Created a module TestCharDriver implementing ioctl. . installed the driver using "insmod"
2. created device node xxx using mknod.
3. created a c program ( below code) .
int main() {
fd = open("/dev/xxx", O_RDWR);
// Not sure about what to be passed as second argument
int returnVal = ioctl(fd,I_FIND,"TestCharDriver");
printf("IOCTL returns %d ERRNO %d\n", returnVal, errno);
close(fd);
return 0;
}
Can anyone explain where i went wrong.
/*********** Below is the code for created module. **************/
struct file_operations xxx_fops =
{
NULL, /* lseek() */
NULL,//xxx_read, /* read() */
NULL, //"xxx_write", /* write() */
NULL, /* readdir() */
NULL, /* select() */
"xxx_ioctl", /* ioctl() */
NULL, /* mmap() */
NULL, //xxx_open, /* open() */
NULL //xxx_close /* close() */
};
int init_module()
{
int returnValue ;
returnValue = register_chrdev(22, "xxx", &xxx_fops) ;
printk(" RETRUN VALUE OF REGISTER %d \n",returnValue);
return 0;
}
int cleanup_module()
{
unregister_chrdev(22,"xxx");
printk("CLEANING MODULES \n");
}
int xxx_ioctl(struct inode * inodearg, struct file * filearg, unsigned int value, unsigned long arg)
{
printk(" IOCTL CALLED FROM USERPROGRAM\n");
}
|