Re: ioctl()

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

 



On Sat, 3 Jan 2009, Rohit Sharma wrote:

> ioctls are also known as generic system calls. Its a simple switch
> case implementation inside a device.
> you send command and argument through ioctls as parameters.
> Its a way you use to interact with the device itself.
>
> for using it just open the device and use its fd to invoke ioctls.
>
> for eg.
>
> fd = open("/dev/mydev", O_RDONLY);
>
> ioctl(fd, cmd, argument);
>
>
> its internal representation is something like:
>
> ioctl( struct file *, struct inode*, unsigned int cmd, unsigned long arg)
> {
>     switch(cmd) {
>                          case 1:  .......
>                          case 2:  .........
>      }
> }
>
> for more details refer Beginning Linux Programming.
> I hope that helps.

  the last i heard, while ioctl's aren't going away any time soon,
they're deprecated in favour of ... uh, files under /sys?  am i
remembering that correctly?  in short, if you're already working with
an ioctl-based code base, keep doing that.  but if you have the
opportunity to design some kernel code from scratch, use the sysfs.

  or am i way off base here?

rday
--

========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry:
    Have classroom, will lecture.

http://crashcourse.ca                          Waterloo, Ontario, CANADA
========================================================================

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[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