On Thu, 7 Feb 2008, Brandon Philips wrote: > On 19:32 Thu 07 Feb 2008, Mayank Kaushik wrote: > > 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. > > I was very puzzled about ioctls when I first started using Unix too. :) > > In any case, an ioctl is short for "I/O Control" and is used to perform > functions on device entries (/dev/video0 for example). > > > A description of what ioctls are used for (alongwith an example usage) would > > be very helpful. > > An example from the video4linux subsystem would be this call to turn off > a video stream: > > enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; > ret = ioctl(fd, VIDIOC_STREAMOFF, &type) > > Where fd is an open /dev/video* entry. just to expand on the above, an ioctl() call allows you to pass arbitrary integer values to a kernel routine, where you can interpret those values (and optional arguments) any way you want. so you could decide that the values passed to a kernel routine might mean: 1: open device door 2: close device door 3: make coffee 4: burst into flame see? total freedom in terms of how you interpret the values, which is why ioctl() calls are actually deprecated these days -- they're just too unstructured, and are being phased out in terms of /proc or sysfs entries. but there's obviously a lot of them still in the kernel. rday -- ======================================================================== Robert P. J. Day Linux Consulting, Training and Annoying Kernel Pedantry Waterloo, Ontario, CANADA Home page: http://crashcourse.ca Fedora Cookbook: http://crashcourse.ca/wiki/index.php/Fedora_Cookbook ======================================================================== -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ