IOCTL Linux device driver -


can explain me,

  1. what ioctl?
  2. what used for?
  3. how can use it?
  4. why can't define new function same work ioctl?

an ioctl, means "input-output control" kind of device-specific system call. there few system calls in linux (300-400), not enough express unique functions devices may have. driver can define ioctl allows userspace application send orders. however, ioctls not flexible , tend bit cluttered (dozens of "magic numbers" work... or not), , can insecure, pass buffer kernel - bad handling can break things easily.

an alternative sysfs interface, set file under /sys/ , read/write information , driver. example of how set up:

static ssize_t mydrvr_version_show(struct device *dev,         struct device_attribute *attr, char *buf) {     return sprintf(buf, "%s\n", driver_release); }  static device_attr(version, s_irugo, mydrvr_version_show, null); 

and during driver setup:

device_create_file(dev, &dev_attr_version); 

you have file device in /sys/, example, /sys/block/myblk/version block driver.

another method heavier use netlink, ipc (inter-process communication) method talk driver on bsd socket interface. used, example, wifi drivers. communicate userspace using libnl or libnl3 libraries.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -