fmtopo.c revision 0eb822a1c0c2bea495647510b75f77f0e57633eb
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <ctype.h>
#include <limits.h>
#include <strings.h>
#include <stdio.h>
#include <errno.h>
#define FMTOPO_EXIT_SUCCESS 0
#define FMTOPO_EXIT_ERROR 1
#define FMTOPO_EXIT_USAGE 2
#define STDERR "stderr"
#define DOTS "..."
#define ALL "all"
static const char *g_pname;
static const char *opt_R = "/";
static const char *opt_s = FM_FMRI_SCHEME_HC;
static int opt_e = 0;
static int opt_d = 0;
static int opt_V = 0;
static int opt_p = 0;
static int opt_x = 0;
static int
{
"Usage: %s [-edpvVx] [-Cdev] [-P properties] [-R root] "
"[-s scheme]\n", g_pname);
"\t-C dump core after completing execution\n"
"\t-d set debug mode for libtopo modules\n"
"\t-P display of FMRI with the specified properties\n"
"\t-p display of FMRI protocol properties\n"
"\t-R set root directory for libtopo plug-ins and other files\n"
"\t-s display topology for the specified FMRI scheme\n"
"\t-V set verbose mode\n"
"\t-x display a xml formatted topology\n");
return (FMTOPO_EXIT_USAGE);
}
static void
{
int err;
char *name;
return;
}
return;
}
if (opt_p) {
} else {
(void) printf("\tASRU: -\n");
}
} else {
(void) printf("\tFRU: -\n");
}
} else {
(void) printf("\tLabel: -\n");
}
}
}
static void
{
int i, err;
uint_t n;
return;
}
return;
}
buf[0] = '\0';
for (i = 0; i < n; i++) {
"name-instance for %s=%d\n", g_pname,
return;
}
errno = 0;
}
}
}
static void
{
int err;
return;
/* Print property name */
g_pname);
return;
} else {
}
return;
} else {
}
switch (type) {
default: tstr = "unknown type";
}
if (!skip)
/*
* Get property value
*/
g_pname);
return;
}
if (skip)
return;
switch (nvpair_type(pv_nvp)) {
case DATA_TYPE_INT32: {
break;
}
case DATA_TYPE_UINT32: {
break;
}
case DATA_TYPE_INT64: {
break;
}
case DATA_TYPE_UINT64: {
break;
}
case DATA_TYPE_STRING: {
char *val;
} else {
}
break;
}
case DATA_TYPE_NVLIST: {
char *fmri;
if (opt_V)
break;
}
} else {
}
break;
}
default:
break;
}
(void) printf("\n");
}
static void
{
char buf[30];
if (skip)
return;
printf(" group: %-30s version: %-3d stability: %s/%s\n",
} else {
printf(" group: %-30s version: %-3d stability: %s/%s\n",
}
}
static int
{
char buf[MAXNAMELEN];
char *np;
return (0);
return (0);
else
/*
* Eat up white space at beginning or end of the
* property group name
*/
begin++;
end--;
return (1);
count += 1;
return (1);
return (0);
}
}
return (1);
}
static void
{
continue;
/*
* Print property group name and stability levels
*/
} else if (strcmp(TOPO_PROP_GROUP_NSTAB,
nvpair_name(pg_nvp)) == 0 &&
} else if (strcmp(TOPO_PROP_GROUP_DSTAB,
nvpair_name(pg_nvp)) == 0 &&
} else if (strcmp(TOPO_PROP_GROUP_VERSION,
nvpair_name(pg_nvp)) == 0 &&
}
if (!pg_done) {
pg_done++;
} else {
continue;
}
/*
* Print property name-value pair
*/
}
}
pg_done = 0;
skip = 0;
}
}
/*ARGSUSED*/
static int
{
int err;
return (TOPO_WALK_NEXT);
}
"properties for %s=%d: %s\n", g_pname,
topo_strerror(err));
} else {
}
}
printf("\n");
return (TOPO_WALK_NEXT);
}
int
{
char *uuid;
int c, err = 0;
switch (c) {
case 'C':
break;
case 'd':
opt_d++;
break;
case 'e':
opt_e++;
break;
case 'P':
break;
case 'p':
opt_p++;
break;
case 'V':
opt_V++;
break;
case 'R':
break;
case 's':
break;
case 'x':
opt_x++;
break;
default:
}
}
return (FMTOPO_EXIT_USAGE);
}
}
return (FMTOPO_EXIT_ERROR);
}
if (opt_d)
return (FMTOPO_EXIT_ERROR);
} else if (err != 0) {
g_pname);
}
if (opt_x) {
err = 0;
"formatted topology:%s", g_pname,
topo_strerror(err));
}
== NULL) {
}
/*
* Print standard header
*/
if (!opt_e) {
char buf[32];
printf("TIME UUID\n");
(void) printf("\n");
}
g_pname);
return (FMTOPO_EXIT_ERROR);
}
return (FMTOPO_EXIT_SUCCESS);
}