3

I have two questions:

(A) I am trying to identify the various options available for a Linux device driver to exchange data with userspace.

A common approach I am aware of is copy_from_user() and copy_to_user(). From the question on SO, some other options include netlink, ioctl, sysfs, procfs, configfs. I want to ask if anyone is aware of any resource where a complete list of options is described along with when it is appropriate to use these options.

(B) I also have the question of whether the type of driver in Linux has anything to do with options allowed to exchange data with user space.

Based on searching online, I can identify the drivers types as Character, Block, PCI, USB, Network, TTY (not sure if this list is complete). I want to ask whether there is any relation between type of driver and way to exchange data with user space OR are they independent ?

Jake
  • 1,353
  • Define "the type of driver in Linux" – 炸鱼薯条德里克 Aug 10 '19 at 23:21
  • When I check online the category of driver I find are Character, Block, PCI, USB, Network – Jake Aug 11 '19 at 00:10
  • 1
    Think. Are these categories sounds orthogonal? Can't a network card Driver be usb? Since obviously you can buy a USB NIC or PCIe NIC. A driver is mostly a kernel module, as code running in kernel mode, it can do anything to exchange data with userspace code. If a path doesn't exist, then it can create it. Unlike userspace code is restricted by the kernel, kernel mode code, (running in Ring0, if x86) is only limited by CPU. – 炸鱼薯条德里克 Aug 11 '19 at 04:27

1 Answers1

0

Actually copy_from_user() and copy_to_user() - we can find these APIs in character driver. We can use sysfs attributes to share the data kernel to user space.

Greenonline
  • 1,851
  • 7
  • 17
  • 23