Re: [PATCH] fix host number sysfs parsing

2008-05-05 Thread Mike Christie

Pete Wyckoff wrote:
> I need this on top of git head to be able to get status
> from iscsi using 2.6.25-rc1.  You'll probably want
> to go looking for host in both sysfs paths, to handle
> old and new kernels.  Here's an example of how it works
> in a recent one.
> 
> Others testing recent kernels may want to hack this
> in temporarily.
> 
> Here are the error message from old iscsi utils,
> iscsi-initiator-utils-6.2.0.868-0.3.fc9.x86_64.
> 
> aib01# iscsiadm -m session
> iscsiadm: Could not get host for sid 1.
> iscsiadm: could not get host_no for session 6.
> iscsiadm: could not find session info for session1
> iscsiadm: Can not get list of active sessions (6)
> 
> aib01# iscsiadm -m node -p 10.100.2.32,3260 -T aib02 -u
> iscsiadm: Could not get host for sid 1.
> iscsiadm: could not get host_no for session 6.
> iscsiadm: could not find session info for session1
> 
>   -- Pete
> 
> 
> Sysfs layout changed yet again.  Accommodate new kernels (2.6.25-rc1
> at least), but probably break the parsing on older ones.
> 

Damn you sysfs! :) I am in the middle of trying to use udev's sysfs code 
instead of our crap. I will send out a test patch later this week.

Thanks for the patch and the bug report.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to open-iscsi@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/open-iscsi
-~--~~~~--~~--~--~---



[PATCH] fix host number sysfs parsing

2008-05-04 Thread Pete Wyckoff

I need this on top of git head to be able to get status
from iscsi using 2.6.25-rc1.  You'll probably want
to go looking for host in both sysfs paths, to handle
old and new kernels.  Here's an example of how it works
in a recent one.

Others testing recent kernels may want to hack this
in temporarily.

Here are the error message from old iscsi utils,
iscsi-initiator-utils-6.2.0.868-0.3.fc9.x86_64.

aib01# iscsiadm -m session
iscsiadm: Could not get host for sid 1.
iscsiadm: could not get host_no for session 6.
iscsiadm: could not find session info for session1
iscsiadm: Can not get list of active sessions (6)

aib01# iscsiadm -m node -p 10.100.2.32,3260 -T aib02 -u
iscsiadm: Could not get host for sid 1.
iscsiadm: could not get host_no for session 6.
iscsiadm: could not find session info for session1

-- Pete


Sysfs layout changed yet again.  Accommodate new kernels (2.6.25-rc1
at least), but probably break the parsing on older ones.

Signed-off-by: Pete Wyckoff <[EMAIL PROTECTED]>
---
 usr/iscsi_sysfs.c |   19 +++
 1 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c
index 7b65d6d..361eff0 100644
--- a/usr/iscsi_sysfs.c
+++ b/usr/iscsi_sysfs.c
@@ -279,7 +279,7 @@ void get_negotiated_session_conf(int sid,
 uint32_t get_host_no_from_sid(uint32_t sid, int *err)
 {
char *buf, *path, *tmp;
-   uint32_t host_no;
+   uint32_t host_no = 0;
 
*err = 0;
 
@@ -290,28 +290,23 @@ uint32_t get_host_no_from_sid(uint32_t sid, int *err)
}
path = buf + PATH_MAX;
 
-   sprintf(path, ISCSI_SESSION_DIR"/session%d/device", sid);
+   sprintf(path, ISCSI_SESSION_DIR"/session%d", sid);
if (readlink(path, buf, PATH_MAX) < 0) {
log_error("Could not get link for %s.", path);
*err = errno;
goto free_buf;
}
 
-   /* buf will be .bus_info/hostX/sessionY */
+   /* buf will be 
../../devices/platform/hostX/sessionY/iscsi_session/sessionY */
 
/* find hostX */
-   tmp = strrchr(buf, '/');
-   *tmp = '\0';
-
-   /* find bus and increment past it */
-   tmp = strrchr(buf, '/');
-   tmp++;
-
-   if (sscanf(tmp, "host%u", &host_no) != 1) {
-   log_error("Could not get host for sid %u.", sid);
+   tmp = strstr(buf, "host");
+   if (tmp == NULL) {
+   log_error("could not find host in session link %s", buf);
*err = ENXIO;
goto free_buf;
}
+   host_no = atoi(tmp + 4);
 
 free_buf:
free(buf);
-- 
1.5.4.1


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to open-iscsi@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/open-iscsi
-~--~~~~--~~--~--~---