Date: Sat, 20 Dec 2014 16:39:57 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r275959 - in head: sys/cam/ctl usr.sbin/ctladm Message-ID: <201412201639.sBKGdvvQ007559@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Sat Dec 20 16:39:56 2014 New Revision: 275959 URL: https://svnweb.freebsd.org/changeset/base/275959 Log: Report initiator id in portlist XML in more formalized way. MFC after: 3 days Modified: head/sys/cam/ctl/ctl.c head/usr.sbin/ctladm/ctladm.c Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Sat Dec 20 16:13:31 2014 (r275958) +++ head/sys/cam/ctl/ctl.c Sat Dec 20 16:39:56 2014 (r275959) @@ -3497,11 +3497,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: head/usr.sbin/ctladm/ctladm.c ============================================================================== --- head/usr.sbin/ctladm/ctladm.c Sat Dec 20 16:13:31 2014 (r275958) +++ head/usr.sbin/ctladm/ctladm.c Sat Dec 20 16:39:56 2014 (r275959) @@ -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?201412201639.sBKGdvvQ007559>