Fw: Basic question about IOCTL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




ccing list.

----- Forwarded Message ----
From: Manoj Awasthi <manoj_posh2k2@xxxxxxxxx>
To: Mayank Kaushik <mayank.utexas@xxxxxxxxx>
Sent: Friday, 8 February, 2008 3:02:29 PM
Subject: Re: Basic question about IOCTL

----- Original Message ----
From: Mayank Kaushik <mayank.utexas@xxxxxxxxx>
To: kernelnewbies@xxxxxxxxxxxx
Sent: Friday, 8 February, 2008 7:02:07 AM
Subject: Basic question about IOCTL

....
I am puzzled about what IOCTLs are and what they are used for. I could not understand much from the the man page for ioctl.
....

ioctls are a way of communication between user space and kernel space. From an article -

Even though ioctl is one of the system calls, its usefulness tempts me to talk about it separately. Sometimes referred to as Swiss army knife, ioctl stands for input/output control and is used to manipulate a character device via a file descriptor. ioctl is a catch-all function that takes a device, a request and a variable number of other parameters. The devices, requests and other parameters are then defined in header files.

Pros: Provides hardware level access to programmers.
Cons: device and requests are poorly documented and platform specific.


[source: http://www.nirendra.net/cms/communicate_kernel ]


Normally, you open a driver (using open system call), do some ioctl (i.e. call ioctl system call with some message which the driver can understand) which in effect does something in kernel and once you are done, you can close the driver (using close system call).


A description of what ioctls are used for (alongwith an example usage) would be very helpful.

e.g. suppose you have a driver installed which write protects a file. When the driver gets loaded, this file gets write protected. Now you want a command line interface, say a command which can remove this write protection. so in the implementation of this command, you open the driver and send it a ioctl message like _REM_WPROTECTION and close the driver. Handling of the message is inside your driver (that will do the needful).

Thanks in advance,
Mayank

Also read http://catb.org/~esr/faqs/smart-questions.html

thanks
-Manoj


Bring your gang together - do your thing. Start your group.



Get the freedom to save as many mails as you wish. Click here to know how.

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux