mediatek: filogic: avoid sub-shell invovation in netdev rename loop
authorDaniel Golle <daniel@makrotopia.org>
Thu, 30 May 2024 13:38:56 +0000 (14:38 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Fri, 31 May 2024 12:26:54 +0000 (13:26 +0100)
Rename network devices to their label set in DT without invocation of
a sub-shell.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
target/linux/mediatek/filogic/base-files/lib/preinit/04_set_netdev_label

index f8b6f155deb64c21feb4ba21fa75bc89b4348977..110e023b962d3dfb86883d7bd840458ecece67ce 100644 (file)
@@ -5,8 +5,8 @@ set_netdev_labels() {
 
        for dir in /sys/class/net/*; do
                [ -r "$dir/of_node/label" ] || continue
-               label="$(cat "$dir/of_node/label")"
-               netdev="$(basename $dir)"
+               read -r label < "$dir/of_node/label"
+               netdev="${dir##*/}"
                [ "$netdev" = "$label" ] && continue
                ip link set "$netdev" name "$label"
        done