09-15-2008
6,
0
Join Date: Sep 2008
Last Activity: 7 May 2013, 6:30 PM EDT
Posts: 6
Thanks Given: 0
Thanked 0 Times in 0 Posts
ioctl() system call on Linux-i386
Greetings,
Please help me with the following :
Where can I find what means exactly and how to use each of the second
argument of the ioctl() system call in Linux/386 : FIOxxx (file IOCTL
requests), SIOxxx (socket IOCTL requests), TCxxx TIOxxx (terminal
IOCTL requests) ?
I did not find yet anything useful on Internet about this topic.
Maybe a Linux [kernel] developer could help me.
Trying to understand which are the ioctl() requests (the second argument to the system call ioctl() ) in Linux and what does each request, I looked in the kernel sources directory, /usr/src/linux, where I found that ioctl() it is coded in a hexadecimal number of 8 hexadecimal figures : bits 31-30 mean fi the call is of type _IO, _IOW, _IOR, _IOWR, bits 29-16 mean the size of the structure gived as the argument, bits 15-8 mean an ASCII character, supposed unique to each driver, and bits 7-0 mean the number of the ioctl() function in that driver.
I set out to study which are the ioctl() requests for files, (those with type FIOxxx) : FIOCLEX, FIONCLEX, FIOASYNC, FIONBIO, FIONREAD, FIOQSIZE.
Writing a short program, I found out that in hexadecimal, for a Linux-i386 machine, they have the following values : 0x5451, 0x5450, 0x5452, 0x5421, 0x541b, 0x5460.
What I do not understand, in first instance, and here I hope you to help me, is why the bits 29-16, of these hexadecimal numbers above, are set to 0 and why bits 31-30 are also 0, so we have _IO commands, and NOT _IOR or _IOW, as would normal be.
If I could understand these, I could go further, to the second step : looking to the Linux kernel sources and to exactly see what does every ioctl() request (what does every ioctl() function) and to enlighten myself, without the need of more documentation.
Thanks,
Alexandru Goia.