LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-03-2004, 03:34 AM   #1
appas
Member
 
Registered: Jul 2004
Posts: 72

Rep: Reputation: 15
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");
}
 
Old 08-03-2004, 11:48 AM   #2
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
1) you need to implement open() and close() in addition to ioctl()
2) you don't initialize the file ops structure like that, there is no guarantee to the order of fields in structure, it should be treated as opaque and u use tagged initialization:
Code:
struct file_operations xxx_fops = 
{  
  open: my_open,
  close: my_close...
and so on.
 
Old 08-04-2004, 04:09 AM   #3
appas
Member
 
Registered: Jul 2004
Posts: 72

Original Poster
Rep: Reputation: 15
Thank you, I got that working.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"Xlib: extension "XFree86-DRI" missing on display ":0.0"." zaps Linux - Games 9 05-14-2007 03:07 PM
"Inproper ioctl reading somedirs", dirs are readonly pingu Debian 5 05-17-2005 04:22 AM
"ioctl: Operation not permitted" (beep media playe) unholy Linux - Software 1 12-18-2004 06:14 PM
err on running "perl -MCPAN -e shell" wellblue88 Linux - Newbie 0 09-21-2004 01:43 PM
Err TV-Out: "no modes remaining for display device TV-0" alexaltair Linux - Hardware 0 08-01-2003 01:43 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration