Finding a char device in /sys using a Bash script?
I have one of and I am trying to write a Bash script for finding the device path in /sys
.
My approach goes something like this:
- start in
/sys/modules/usbled
since this is the name of the kernel module loaded when the device is plugged in cd
todrivers/usb:usbled
, which appears to be the bus and name of the driver for the device (according to )- ???
I get stuck on the last step since the directory contains:
$ ls
1-1.2:1.0 bind module new_id remove_id uevent unbind
Now, I happen to know in this case that the 1-1.2:1.0
directory contains the char devices necessary to control the LEDs. However, how does my script know this? Is there any particular naming convention behind the directory? What if there are multiple devices of the same type plugged in?
3
Nathan Osman 2022-07-25 20:42:57
Source
Share
Answers: 0
Related questions