Created
February 10, 2018 14:28
-
-
Save devlucas/de6df9e5e0f2d9262f63a96b0665ad42 to your computer and use it in GitHub Desktop.
Finds out which kernel driver is being used to serve a given device file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# call as: <script name> <device file path> | |
# example: driverfor /dev/input/mouse0 | |
lookup_driver_in_use_for_input_device() { | |
device_file="$(echo $1 | awk '{gsub("/dev/", "", $1); print $1}')" | |
module_file="$(realpath /sys/class/$device_file/device/device/driver/module)" | |
echo $module_file | awk '{gsub("/sys/module/", "", $1); print $1}' | |
} | |
result="$(lookup_driver_in_use_for_input_device $1)" | |
echo "$result" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment