File 0002-hcnmgr-Wait-for-sysfs-device-ready-when-looking-up-d.patch of Package powerpc-utils.20109

From d9bcb21179ccfea122f326aca4690afe0f7de0c6 Mon Sep 17 00:00:00 2001
From: Mingming Cao <mmc@linux.vnet.ibm.com>
Date: Mon, 1 Mar 2021 21:34:34 -0800
Subject: [PATCH 2/4] hcnmgr: Wait for sysfs device ready when looking up
 device name

References: bsc#1181956 ltc#190722
Upstream: accpeted, expected v1.3.9
Git-commit: d9bcb21179ccfea122f326aca4690afe0f7de0c6

At the time of calling ofpathname to look up for devicename, wait
for sysfs device ready. Otherwise, the OS may be in the middle of device
renaming.

Signed-off-by: Mingming Cao <mmc@linux.vnet.ibm.com>
[tyreld: fixed up commit log]
Signed-off-by: Tyrel Datwyler <tyreld@linux.ibm.com>
---
 scripts/hcnmgr | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/hcnmgr b/scripts/hcnmgr
index c95edba1216c..0d20e7dab4b6 100644
--- a/scripts/hcnmgr
+++ b/scripts/hcnmgr
@@ -241,7 +241,10 @@ get_dev_hcn() {
 	# Let's retry a few times.
 	while [ $wait != 0 ]; do
 		if DEVNAME=$(ofpathname -l "$(echo "$1" | sed -e "s/\/proc\/device-tree//")" 2>/dev/null); then
-			break
+			if [ -e /sys/class/net/"$DEVNAME" ]; then
+				hcnlog DEBUG "ofpathname waiting for /sys/class/net device $DEVNAME ready"
+				break
+			fi
 		fi
 
 		hcnlog DEBUG "ofpathname return $?, devname is $DEVNAME rety counter $wait"
-- 
2.26.2

openSUSE Build Service is sponsored by