Date: Tue, 23 Dec 2014 12:45:30 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r276139 - in stable/10: sys/cam/ctl usr.sbin/ctladm Message-ID: <201412231245.sBNCjUEc008864@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Tue Dec 23 12:45:29 2014 New Revision: 276139 URL: https://svnweb.freebsd.org/changeset/base/276139 Log: MFC r275959: Report initiator id in portlist XML in more formalized way. Modified: stable/10/sys/cam/ctl/ctl.c stable/10/usr.sbin/ctladm/ctladm.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/ctl.c ============================================================================== --- stable/10/sys/cam/ctl/ctl.c Tue Dec 23 12:44:16 2014 (r276138) +++ stable/10/sys/cam/ctl/ctl.c Tue Dec 23 12:45:29 2014 (r276139) @@ -3500,11 +3500,11 @@ ctl_ioctl(struct cdev *dev, u_long cmd, if (port->wwpn_iid[j].name != NULL) retval = sbuf_printf(sb, - "\t<initiator>%u %s</initiator>\n", + "\t<initiator id=\"%u\">%s</initiator>\n", j, port->wwpn_iid[j].name); else retval = sbuf_printf(sb, - "\t<initiator>%u naa.%08jx</initiator>\n", + "\t<initiator id=\"%u\">naa.%08jx</initiator>\n", j, port->wwpn_iid[j].wwpn); if (retval != 0) break; Modified: stable/10/usr.sbin/ctladm/ctladm.c ============================================================================== --- stable/10/usr.sbin/ctladm/ctladm.c Tue Dec 23 12:44:16 2014 (r276138) +++ stable/10/usr.sbin/ctladm/ctladm.c Tue Dec 23 12:45:29 2014 (r276139) @@ -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, con 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, con 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 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); } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412231245.sBNCjUEc008864>