luci-base: resolve symlinks for PCI hardware
authorPaul Donald <redacted>
Mon, 16 Mar 2026 14:54:07 +0000 (15:54 +0100)
committerPaul Donald <redacted>
Mon, 16 Mar 2026 14:54:07 +0000 (15:54 +0100)
commitab72c4457a18334a99a175da6eb6a1a53c63af7e
tree4defa541d9501c3a85508a18daf662c4440231dd
parentb015dfa745bdcff139b2b51d233b53b43ef6943f
luci-base: resolve symlinks for PCI hardware

getBuiltinEthernetPorts crashed with "Unknown error"
on hardware where NICs have PCI subsystem symlinks at
different sysfs depths (e.g. onboard NIC vs PCIe card NIC).

The getBuiltinEthernetPorts x86_64 workaround block
needs realpath() to resolve PCI subsystem symlinks.

readlink() returns different strings ("../../../bus/pci" vs
"../../../../bus/pci") even though both resolve to /sys/bus/pci,
causing eth1 and eth2 to be incorrectly excluded from the result.

E.g.:

  eth0: /sys/class/net/eth0/device/subsystem -> ../../../bus/pci
  eth1: /sys/class/net/eth1/device/subsystem -> ../../../../bus/pci
  eth2: /sys/class/net/eth2/device/subsystem -> ../../../../bus/pci

1. Add realpath to the 'fs' module import statement
2. Use realpath() to normalize paths

Closes #8425
Reported-by: @MI2-2
Signed-off-by: Paul Donald <redacted>
modules/luci-base/root/usr/share/rpcd/ucode/luci
git clone https://git.99rst.org/PROJECT