Raunaq Kochar Raunaq Kochar - 10 months ago 65
Linux Question

Working of ioctl(2)

Please explain to me the working of the

system call.

The manual page and wikipedia are neither very informative nor detailed.

What should the file descriptor that is passed as the first argument of
be pointing to?

Answer Source

You have to open the device you want to manipulate before calling ioctl. Then you pass the file descriptor for the device you want to manipulate as the first parameter. You would only call ioctl when there's some particular device that has some particular manipulation that you want to perform on it.