diff options
author | mav <mav@FreeBSD.org> | 2014-12-23 12:45:29 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2014-12-23 12:45:29 +0000 |
commit | 9cec8144119c5694ae6d69790232cbcb9ef1e0b5 (patch) | |
tree | 844896a084366968cdb5dd56a1fbb27bed906094 /usr.sbin/ctladm/ctladm.c | |
parent | be311950729ed36fd8722a9c139ac2270a780f1d (diff) | |
download | FreeBSD-src-9cec8144119c5694ae6d69790232cbcb9ef1e0b5.zip FreeBSD-src-9cec8144119c5694ae6d69790232cbcb9ef1e0b5.tar.gz |
MFC r275959: Report initiator id in portlist XML in more formalized way.
Diffstat (limited to 'usr.sbin/ctladm/ctladm.c')
-rw-r--r-- | usr.sbin/ctladm/ctladm.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/usr.sbin/ctladm/ctladm.c b/usr.sbin/ctladm/ctladm.c index 646cfbf..9f72c83 100644 --- a/usr.sbin/ctladm/ctladm.c +++ b/usr.sbin/ctladm/ctladm.c @@ -4117,6 +4117,7 @@ struct cctl_portlist_data { STAILQ_HEAD(,cctl_port) port_list; struct cctl_port *cur_port; int level; + uint64_t cur_id; struct sbuf *cur_sb[32]; }; @@ -4139,6 +4140,14 @@ cctl_start_pelement(void *user_data, const char *name, const char **attr) if (portlist->cur_sb[portlist->level] == NULL) err(1, "%s: Unable to allocate sbuf", __func__); + portlist->cur_id = 0; + for (i = 0; attr[i] != NULL; i += 2) { + if (strcmp(attr[i], "id") == 0) { + portlist->cur_id = strtoull(attr[i+1], NULL, 0); + break; + } + } + if (strcmp(name, "targ_port") == 0) { if (cur_port != NULL) errx(1, "%s: improper port element nesting", __func__); @@ -4153,16 +4162,8 @@ cctl_start_pelement(void *user_data, const char *name, const char **attr) STAILQ_INIT(&cur_port->init_list); STAILQ_INIT(&cur_port->attr_list); + cur_port->port_id = portlist->cur_id; STAILQ_INSERT_TAIL(&portlist->port_list, cur_port, links); - - for (i = 0; attr[i] != NULL; i += 2) { - if (strcmp(attr[i], "id") == 0) { - cur_port->port_id = strtoull(attr[i+1], NULL, 0); - } else { - errx(1, "%s: invalid LUN attribute %s = %s", - __func__, attr[i], attr[i+1]); - } - } } } @@ -4231,7 +4232,10 @@ cctl_end_pelement(void *user_data, const char *name) err(1, "%s: can't allocate %zd bytes for nv pair", __func__, sizeof(*nv)); - nv->name = strdup(name); + if (strcmp(name, "initiator") == 0) + asprintf(&nv->name, "%ju", portlist->cur_id); + else + nv->name = strdup(name); if (nv->name == NULL) err(1, "%s: can't allocated %zd bytes for string", __func__, strlen(name)); @@ -4372,7 +4376,8 @@ retry: if (port->target) printf(" Target: %s\n", port->target); STAILQ_FOREACH(nv, &port->init_list, links) { - printf(" Initiator: %s\n", nv->value); + printf(" Initiator %s: %s\n", + nv->name, nv->value); } } |