anaconda/anaconda-40.22.3.13/dracut/find-net-intfs-by-driver

24 lines
534 B
Text
Raw Normal View History

2024-11-14 21:39:56 -08:00
#!/bin/bash
#
# Find all devices which depend on input kernel driver.
#
# Author: Jiri Konecny
#
driver="$1"
# List all interfaces in system
for i in /sys/class/net/*/device/modalias; do
if [ -z "$i" ]; then
exit 0
fi
# Get kernel mods on which the interface is dependent
d=$(modprobe -R "$(cat "$i")")
# Test if this is the mod we are looking for. If so return name of the interface.
if [[ " $d " == *\ $driver\ * ]]; then
intf=${i%%/device/modalias}
echo "${intf##*/}"
fi
done