From owner-svn-src-stable-10@FreeBSD.ORG Tue Dec 23 12:45:31 2014 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 203D29BF; Tue, 23 Dec 2014 12:45:31 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 013D56459C; Tue, 23 Dec 2014 12:45:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBNCjUB5008867; Tue, 23 Dec 2014 12:45:30 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBNCjUEc008864; Tue, 23 Dec 2014 12:45:30 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201412231245.sBNCjUEc008864@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 23 Dec 2014 12:45:30 +0000 (UTC) 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 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Dec 2014 12:45:31 -0000 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%u %s\n", + "\t%s\n", j, port->wwpn_iid[j].name); else retval = sbuf_printf(sb, - "\t%u naa.%08jx\n", + "\tnaa.%08jx\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); } }