Tools support for the posted interface breaking flashnode sysfs changes.

Still falls back to the bus path, maintaining compatibility.
---
 usr/iscsi_sysfs.c | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c
index 0cc55b97bde9..5d176db8dba7 100644
--- a/usr/iscsi_sysfs.c
+++ b/usr/iscsi_sysfs.c
@@ -48,7 +48,9 @@
 #define ISCSI_TRANSPORT_DIR    "/sys/class/iscsi_transport"
 #define ISCSI_SESSION_DIR      "/sys/class/iscsi_session"
 #define ISCSI_HOST_DIR         "/sys/class/iscsi_host"
-#define ISCSI_FLASHNODE_DIR    "/sys/bus/iscsi_flashnode/devices"
+#define ISCSI_FLASHNODE_DIR    "/sys/class/iscsi_flashnode"
+/* old location, flashnode was previously a bus instead of a class */
+#define ISCSI_FLASHNODE_BUS_DIR        "/sys/bus/iscsi_flashnode/devices"
 
 #define ISCSI_SESSION_SUBSYS           "iscsi_session"
 #define ISCSI_CONN_SUBSYS              "iscsi_connection"
@@ -470,18 +472,21 @@ int iscsi_sysfs_get_flashnode_info(struct flashnode_rec 
*fnode,
        snprintf(sess_id, sizeof(sess_id), ISCSI_FLASHNODE_SESS, host_no,
                 flashnode_idx);
 
-       snprintf(fnode_path, sizeof(fnode_path), ISCSI_FLASHNODE_DIR"/%s",
-                sess_id);
-       if (access(fnode_path, F_OK) != 0)
-               return errno;
+       snprintf(fnode_path, sizeof(fnode_path), ISCSI_FLASHNODE_DIR"/%s", 
sess_id);
+       if (access(fnode_path, F_OK) != 0) {
+               snprintf(fnode_path, sizeof(fnode_path), 
ISCSI_FLASHNODE_BUS_DIR"/%s", sess_id);
+               if (access(fnode_path, F_OK) != 0)
+                       return errno;
+       }
 
-       snprintf(conn_id, sizeof(conn_id), ISCSI_FLASHNODE_CONN, host_no,
-                flashnode_idx);
+       snprintf(conn_id, sizeof(conn_id), ISCSI_FLASHNODE_CONN, host_no, 
flashnode_idx);
 
-       snprintf(fnode_path, sizeof(fnode_path), ISCSI_FLASHNODE_DIR"/%s",
-                conn_id);
-       if (access(fnode_path, F_OK) != 0)
-               return errno;
+       snprintf(fnode_path, sizeof(fnode_path), ISCSI_FLASHNODE_DIR"/%s", 
conn_id);
+       if (access(fnode_path, F_OK) != 0) {
+               snprintf(fnode_path, sizeof(fnode_path), 
ISCSI_FLASHNODE_BUS_DIR"/%s", conn_id);
+               if (access(fnode_path, F_OK) != 0)
+                       return errno;
+       }
 
 
        sysfs_get_uint8(conn_id, ISCSI_FLASHNODE_SUBSYS, "is_fw_assigned_ipv6",
@@ -634,6 +639,10 @@ int iscsi_sysfs_for_each_flashnode(void *data, uint32_t 
host_no, int *nr_found,
                return ISCSI_ERR_NOMEM;
 
        n = scandir(ISCSI_FLASHNODE_DIR, &namelist, trans_filter, alphasort);
+       if (n == -1) {
+               /* fall back to old sysfs bus location */
+               n = scandir(ISCSI_FLASHNODE_BUS_DIR, &namelist, trans_filter, 
alphasort);
+       }
        if (n <= 0)
                goto free_fnode;
 
-- 
2.9.4

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to