2043c5
diff -up open-iscsi-2.0-870.1/utils/fwparam_ibft/fwparam_ibft_sysfs.c~ open-iscsi-2.0-870.1/utils/fwparam_ibft/fwparam_ibft_sysfs.c
2043c5
--- open-iscsi-2.0-870.1/utils/fwparam_ibft/fwparam_ibft_sysfs.c~	2009-01-28 22:09:21.000000000 +0100
2043c5
+++ open-iscsi-2.0-870.1/utils/fwparam_ibft/fwparam_ibft_sysfs.c	2009-01-28 22:10:29.000000000 +0100
2043c5
@@ -186,6 +186,40 @@ static int get_iface_from_device(const c
2043c5
 		break;
2043c5
 	}
2043c5
 
2043c5
+	closedir(dirfd);
2043c5
+
2043c5
+	if (rc != ENODEV)
2043c5
+		return rc;
2043c5
+
2043c5
+	/* If not found try again with newer kernel networkdev sysfs layout */
2043c5
+	strncat(dev_dir, "/net", FILENAMESZ);
2043c5
+
2043c5
+	if (!file_exist(dev_dir))
2043c5
+		return rc;
2043c5
+
2043c5
+	dirfd = opendir(dev_dir);
2043c5
+	if (!dirfd)
2043c5
+		return errno;
2043c5
+
2043c5
+	while ((dent = readdir(dirfd))) {
2043c5
+		if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, ".."))
2043c5
+			continue;
2043c5
+
2043c5
+		/* Take the first "regular" directory entry */
2043c5
+		if (strlen(dent->d_name) > (sizeof(context->iface) - 1)) {
2043c5
+			rc = EINVAL;
2043c5
+			printf("Net device %s too bug for iface buffer.\n",
2043c5
+			       dent->d_name);
2043c5
+			break;
2043c5
+		}
2043c5
+
2043c5
+		strcpy(context->iface, dent->d_name);
2043c5
+		rc = 0;
2043c5
+		break;
2043c5
+	}
2043c5
+
2043c5
+	closedir(dirfd);
2043c5
+
2043c5
 	return rc;
2043c5
 }
2043c5