![]() For example, this is the case for partition device files like /dev/sda1. Also not all devices have a device subfolder. ![]() Note that the existence of various directories in /sys may change depending on the kernel configuration. Eg: $ readlink /sys/block/sda/device/driver ![]() This works just as well: $ readlink /sys/dev/*/8\:0/device/driverīlock devices can also be accessed directly through their name via either /sys/block or /sys/class/block. If you are unsure if the device is a block or character device, in the shell you could simply replace this part with a *. This shows that the sd driver is used for the device. Eg, for my /dev/sda I can simply do: $ readlink /sys/dev/block/8\:0/device/driver If there is a driver available for the device, it can be found by reading the target of the driver link in this or the device sub-directory. Each device is then accessible by its major/minor number is this directory. The no-brainer here is that these are for block and character devices respectively. If you then look under /sys/dev, you will see there are two directories. Other devices may have a c for character device at the start. ![]() The b at the start of the listing also tells us that it is a block device. The 8, 0 tells us that major number is 8 and the minor is 0. To get this information from sysfs for a device file, first determine the major/minor number by looking at the output of ls -l, eg $ ls -l /dev/sdaīrw-rw- 1 root disk 8, 0 Apr 17 12:26 /dev/sda
0 Comments
Leave a Reply. |