From e0fd6dc05156f467bffc035be91ea56100b268fa Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Fri, 2 Sep 2016 16:40:24 -0700 Subject: [PATCH] Allow iser:// style URLs Let user specify iSER support by the protocol part of the URL. I.e. support both iser://127.0.0.1/iqn.ronnie.test/1 iscsi://127.0.0.1/iqn.ronnie.test/1?iser Signed-off-by: Ronnie Sahlberg --- README | 2 ++ lib/init.c | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README b/README index a1911d7..d940a73 100644 --- a/README +++ b/README @@ -34,6 +34,8 @@ iSCSI URL Format ================ iSCSI devices are specified by a URL format of the following form : iscsi://[[%]@][:]//[?[&]*] +or + iser://[[%]@][:]//[?[&]*] Arguments: Username and password for bidirectional CHAP authentication: diff --git a/lib/init.c b/lib/init.c index dfe3db0..9941ceb 100644 --- a/lib/init.c +++ b/lib/init.c @@ -520,7 +520,11 @@ iscsi_parse_url(struct iscsi_context *iscsi, const char *url, int full) int is_iser = 0; #endif - if (strncmp(url, "iscsi://", 8)) { + if (strncmp(url, "iscsi://", 8) +#ifdef HAVE_LINUX_ISER + && strncmp(url, "iser://", 7) +#endif + ) { if (full) { iscsi_set_error(iscsi, "Invalid URL %s\niSCSI URL must " "be of the form: %s", @@ -533,7 +537,15 @@ iscsi_parse_url(struct iscsi_context *iscsi, const char *url, int full) return NULL; } - strncpy(str,url + 8, MAX_STRING_SIZE); +#ifdef HAVE_LINUX_ISER + if (!strncmp(url, "iser://", 7)) { + is_iser = 1; + strncpy(str, url + 7, MAX_STRING_SIZE); + } +#endif + if (!strncmp(url, "iscsi://", 8)) { + strncpy(str, url + 8, MAX_STRING_SIZE); + } portal = str; user = getenv("LIBISCSI_CHAP_USERNAME");