Click here to Skip to main content
15,908,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

Thank you for help.

I try to build a device driver and have build it Successfully.

When I call the ioctl system call, it prompts "Killed".

Then I run with strace command, it say "ioctl(3, 0x22 <unfinished ...=""> +++ killed by SIGKILL +++ Killed".

The related driver code is:
C++
#define TEST_IOC_MAGIC 0x00
//Documentation/ioctl-number.txt say 0x00~0x1F are been used.
#define TEST_IOCRESET _IO(TEST_IOC_MAGIC, 0x22)
....
static const struct file_operations globalfifo_fops =
{
       .unlocked_ioctl = globalfifo_ioctl,

};
...
static int globalfifo_ioctl(struct inode *inode,struct file *filp,unsigned int cmd,unsigned long arg)
{
      ...
      case TEST_IOCRESET:
      ....
}

The related program code is:
C++
int main()
{
      //  /dev/globalfifopoll is the device file.
      fd = open("/dev/globalfifopoll", O_CREAT|O_RDWR|O_NONBLOCK);
      ioctl(fd, TEST_IOCRESET, 0);
}

The device driver and the program are both build Successfully. Meanwhile, the device driver can work well when you write buffer data to it or read buffer data from it.

I don't know where is wrong. In the program, the function open() return value 3 to fd. But when run the code ioctl(), it says "ioctl(3, 0x22 <unfinished ...=""> ".

If I delete the code ioctl(fd, TEST_IOCRESET, 0), the program can run well.

Thank you for your help.
Posted
Updated 25-Dec-11 20:33pm
v2

Sorry, the wrong result say ioctl(3, 0x22 (unfinished ....).

I write the log in the function of globalfifo_ioctl(), but the log is not print( use the command dmesg to see). I'm sure this device driver can work well, because I can print other log in other interfaces of the driver.
 
Share this answer
 
Oh, I resolve it. Thank you for your notice.

The reason is that:

Before the linux version 2.6.32, the ioctl driver method is :
static int (*ioctl)(struct inode *inode,struct file *filp,unsigned int cmd,unsigned long arg);
My linux version is 2.6.38, the ioctl driver method is :
static long (*ioctl)(struct file *filp, unsigned int cmd, unsigned long arg)

In my device driver, I use the first ioctl driver method, that is abandon. When I use the second ioctl driver method, everything is OK.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900