Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
+device_get_driver() {
+ local device="${1}"
+ assert isset device
+
+ get_driver_from_path "${SYS_CLASS_NET}/${device}/device/driver/module"
+}
+
# Check if the device is a bonding device
device_is_bonding() {
[ -d "/sys/class/net/${1}/bonding" ]
# Check if the device is a bonding device
device_is_bonding() {
[ -d "/sys/class/net/${1}/bonding" ]
+phy_get_driver() {
+ local phy="${1}"
+ assert isset phy
+
+ get_driver_from_path "$(phy_dir "${phy}")/device/driver/module"
+}
+
phy_get_devices() {
local phy="${1}"
assert isset phy
phy_get_devices() {
local phy="${1}"
assert isset phy
tr -sc [:alnum:] "-" < <(printf "%s" "${string,,}")
}
tr -sc [:alnum:] "-" < <(printf "%s" "${string,,}")
}
+
+get_driver_from_path() {
+ local path="${1}"
+
+ if file_exists "${path}"; then
+ # Resolve symlink
+ local driver="$(readlink "${path}")"
+
+ # Print module name
+ basename "${driver}"
+ return ${EXIT_OK}
+ fi
+
+ return ${EXIT_ERROR}
+}
cli_print_fmt1 1 "Status" "${status}"
cli_print_fmt1 1 "Type" "${type}"
cli_print_fmt1 1 "Status" "${status}"
cli_print_fmt1 1 "Type" "${type}"
+ # Print the driver name
+ local driver="$(device_get_driver "${device}")"
+ if isset driver; then
+ cli_print_fmt1 1 "Driver" "${driver}"
+ fi
+
# Ethernet-compatible?
device_is_ethernet_compatible "${device}" &>/dev/null
cli_print_fmt1 1 "Ethernet-compatible" "$(cli_print_bool $?)"
# Ethernet-compatible?
device_is_ethernet_compatible "${device}" &>/dev/null
cli_print_fmt1 1 "Ethernet-compatible" "$(cli_print_bool $?)"
local address="$(phy_get_address "${phy}")"
cli_print_fmt1 1 "Address" "${address}"
local address="$(phy_get_address "${phy}")"
cli_print_fmt1 1 "Address" "${address}"
+
+ # Show kernel module
+ local driver="$(phy_get_driver "${phy}")"
+ if isset driver; then
+ cli_print_fmt1 1 "Driver" "${driver}"
+ fi
+
cli_space
local devices="$(phy_get_devices "${phy}")"
cli_space
local devices="$(phy_get_devices "${phy}")"