[Open-FCoE] [RFC PATCH] libhbalinux: Fix the junk characters in adapter name

Steve Ma steve.ma at intel.com
Wed Apr 15 19:45:59 UTC 2009


When the adapter name (ap->ad_name) is created in sysfs_scan
routine, the name contains junk characters instead the ethernet
interface name (ethx). This patch is to have correct interface
name in ap->ad_name.
---

 lport.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lport.c b/lport.c
index 7b1b18a..4e2ad48 100644
--- a/lport.c
+++ b/lport.c
@@ -168,6 +168,10 @@ sysfs_scan(struct dirent *dp, void *arg)
 	if (!cp)
 		goto skip;
 
+	/* Save the ifname */
+	cp += 6;
+	sa_strncpy_safe(ifname, sizeof(ifname), cp, strlen(cp));
+
 	/*
 	 * See if host_dir is a PCI device directory
 	 * If not, try it as a net device.
@@ -181,8 +185,6 @@ sysfs_scan(struct dirent *dp, void *arg)
 		snprintf(hba_dir, sizeof(hba_dir), "%s/device/..", host_dir);
 	} else {
 		/* assume a net device */
-		cp += 6;
-		sa_strncpy_safe(ifname, sizeof(ifname), cp, strlen(cp));
 		snprintf(hba_dir, sizeof(hba_dir), SYSFS_HBA_DIR "/%s/device",
 			ifname);
 		i = readlink(hba_dir, buf, sizeof(buf) - 1);




More information about the devel mailing list