From 3f6e8e32daac5914a6ddc07ba09be8a7985cc29a Mon Sep 17 00:00:00 2001 From: Josef 'Jeff' Sipek Date: Mon, 26 Nov 2018 16:11:20 -0500 Subject: [PATCH] cmd: remove sparc-only fruadm & prtfru --- share/man/man7d/bscv.7d | 2 +- share/man/man8/Makefile | 2 - share/man/man8/fruadm.8 | 214 ---- share/man/man8/prtfru.8 | 109 -- usr/src/cmd/Makefile | 8 +- usr/src/cmd/fruadm/Makefile | 52 - usr/src/cmd/fruadm/fruadm.c | 967 ---------------- usr/src/cmd/prtfru/Makefile | 65 -- usr/src/cmd/prtfru/main.c | 124 -- usr/src/cmd/prtfru/prtfru.c | 1382 ----------------------- usr/src/cmd/prtfru/prtfru.h | 45 - usr/src/pkg/manifests/system-fru-id-platform.mf | 2 - usr/src/pkg/manifests/system-fru-id.mf | 4 +- 13 files changed, 3 insertions(+), 2973 deletions(-) delete mode 100644 share/man/man8/fruadm.8 delete mode 100644 share/man/man8/prtfru.8 delete mode 100644 usr/src/cmd/fruadm/Makefile delete mode 100644 usr/src/cmd/fruadm/fruadm.c delete mode 100644 usr/src/cmd/prtfru/Makefile delete mode 100644 usr/src/cmd/prtfru/main.c delete mode 100644 usr/src/cmd/prtfru/prtfru.c delete mode 100644 usr/src/cmd/prtfru/prtfru.h diff --git a/share/man/man7d/bscv.7d b/share/man/man7d/bscv.7d index 607907b37f..5d56207d66 100644 --- a/share/man/man7d/bscv.7d +++ b/share/man/man7d/bscv.7d @@ -16,7 +16,7 @@ information between Solaris and the Blade support chip. .sp .LP These drivers do not export public interfaces. Instead they make information -available via picl, prtdiag, prtfru and related tools. In addition, these +available via picl, prtdiag, and related tools. In addition, these drivers log Blade support chip environmental event information into system logs. .SH FILES diff --git a/share/man/man8/Makefile b/share/man/man8/Makefile index 1f7047d710..30eca91ae9 100644 --- a/share/man/man8/Makefile +++ b/share/man/man8/Makefile @@ -95,7 +95,6 @@ MAN = 6to4relay.8 \ fmstat.8 \ fmthard.8 \ format.8 \ - fruadm.8 \ fsck.8 \ fsck_pcfs.8 \ fsck_udfs.8 \ @@ -293,7 +292,6 @@ MAN = 6to4relay.8 \ prstat.8 \ prtconf.8 \ prtdiag.8 \ - prtfru.8 \ prtpicl.8 \ prtvtoc.8 \ psradm.8 \ diff --git a/share/man/man8/fruadm.8 b/share/man/man8/fruadm.8 deleted file mode 100644 index ad87b2364e..0000000000 --- a/share/man/man8/fruadm.8 +++ /dev/null @@ -1,214 +0,0 @@ -'\" te -.\" Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved. -.\" 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 or http://www.opensolaris.org/os/licensing. 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] -.TH FRUADM 8 "Feb 22, 2002" -.SH NAME -fruadm \- prints and updates customer data associated with FRUs -.SH SYNOPSIS -.LP -.nf -\fB/usr/platform/sun4u/sbin/fruadm\fR -.fi - -.LP -.nf -\fB/usr/platform/sun4u/sbin/fruadm\fR \fB-l\fR -.fi - -.LP -.nf -\fB/usr/platform/sun4u/sbin/fruadm\fR [\fB-r\fR] \fIpath\fR [\fItext\fR] -.fi - -.SH DESCRIPTION -.sp -.LP -\fBfruadm\fR prints or sets the customer data for Field-Replaceable Units -(\fBFRU\fRs). -.sp -.LP -Without arguments, \fBfruadm\fR prints the paths of all \fBFRU ID\fR-capable -\fBFRU\fRs (containers) in the system, along with the contents of the customer -data record, if present, for each such \fBFRU\fR; for \fBFRU\fRs without -customer data, \fBfruadm\fR prints only the container's path. -.sp -.LP - Only a privileged user can create or update data in containers. The privileges -required to perform these write operations are hardware dependent. Typically, a -default system configuration restricts write operations to the superuser or to -the platform-administrator user. -.SH OPTIONS -.sp -.LP -The following options are supported: -.sp -.ne 2 -.na -\fB\fB-l\fR\fR -.ad -.RS 6n -List the system's frutree paths. -.RE - -.sp -.ne 2 -.na -\fB\fB-r\fR\fR -.ad -.RS 6n -Recursively display or update the data for all containers rooted at the -argument \fIpath\fR. -.RE - -.SH OPERANDS -.sp -.LP -The following operands are supported: -.sp -.ne 2 -.na -\fB\fIpath\fR\fR -.ad -.RS 8n -A full or partial system frutree path for or under which to print or set the -customer data. The first field of each line of output of \fBfruadm \fR\fB-l\fR -gives the valid full \fBfrutree\fR paths for the system. -.sp -Paths can include shell meta-characters; such paths should be quoted -appropriately for the user's shell. For partial paths, the first matching full -path is selected for display or update. Without the \fB-r\fR option, the path -must be that of a container; with the \fB-r\fR option, all containers (if any) -under \fIpath\fR will be selected. -.RE - -.sp -.ne 2 -.na -\fB\fItext\fR\fR -.ad -.RS 8n -Up to 80 characters of text set as the customer data. If the text contains -white space or shell metacharacters, it should be quoted appropriately for the -user's shell. -.RE - -.SH EXAMPLES -.LP -\fBExample 1 \fRDisplaying All Customer Data -.sp -.LP -The following example prints all customer data available from \fBFRU\fRs on the -system. For containers with no customer data, only the containers' paths will -be listed. - -.sp -.in +2 -.nf -example% fruadm -.fi -.in -2 -.sp - -.LP -\fBExample 2 \fRDisplaying Customer Data For a Single FRU -.sp -.LP -The following command prints the customer data, if present, for the specified -\fBFRU\fR: - -.sp -.in +2 -.nf -example% fruadm /frutree/chassis/system-board -.fi -.in -2 -.sp - -.LP -\fBExample 3 \fRDisplaying Customer Data For a Single FRU -.sp -.LP -The following command prints the customer data, if present, for the first -\fBmem-module\fR found: - -.sp -.in +2 -.nf -example% fruadm mem-module -.fi -.in -2 -.sp - -.LP -\fBExample 4 \fR Setting Customer Data -.sp -.LP -The following example sets the customer data for a \fBFRU\fR: - -.sp -.in +2 -.nf -example# fruadm system-board 'Asset Tag 123456' -.fi -.in -2 -.sp - -.LP -\fBExample 5 \fRSetting Customer Data -.sp -.LP -The following command sets the customer data for all \fBFRU\fRs under -\fBchassis\fR: - -.sp -.in +2 -.nf -example# fruadm -r /frutree/chassis "Property of XYZ, Inc." -.fi -.in -2 -.sp - -.SH EXIT STATUS -.sp -.LP -The following exit values are returned: -.sp -.ne 2 -.na -\fB\fB0\fR \fR -.ad -.RS 6n -Successful completion. -.RE - -.sp -.ne 2 -.na -\fB>\fB0\fR\fR -.ad -.RS 6n -An error occurred. -.RE - -.SH ATTRIBUTES -.sp -.LP -See \fBattributes\fR(5) for descriptions of the following attributes: -.sp - -.sp -.TS -box; -c | c -l | l . -ATTRIBUTE TYPE ATTRIBUTE VALUE -_ -Interface Stability Unstable -.TE - -.SH SEE ALSO -.sp -.LP -\fBprtfru\fR(8), \fBattributes\fR(5) diff --git a/share/man/man8/prtfru.8 b/share/man/man8/prtfru.8 deleted file mode 100644 index e769839a6b..0000000000 --- a/share/man/man8/prtfru.8 +++ /dev/null @@ -1,109 +0,0 @@ -'\" te -.\" Copyright (c) 2002, Sun Microsystems, Inc. All Rights Reserved -.\" 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 or http://www.opensolaris.org/os/licensing. 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] -.TH PRTFRU 8 "April 9, 2016" -.SH NAME -prtfru \- print FRUID-specific information about the FRUs on a system or domain -.SH SYNOPSIS -.LP -.nf -\fB/usr/sbin/prtfru\fR [\fB-d\fR] | [\fB-clx\fR] [\fIcontainer\fR] -.fi - -.SH DESCRIPTION -.LP -The \fBprtfru\fR utility is used to obtain \fBFRUID\fR data from the system or -domain. Its output is that of a tree structure echoing the path in the -\fBFRU\fR (Field-Replaceable Unit) tree to each container. When a container is -found, the data from that container is printed in a tree-like structure as -well. -.sp -.LP -\fBprtfru\fR without any arguments will print the \fBFRU\fR hierarchy and all -of the \fBFRUID\fR container data. \fBprtfru\fR prints to stdout which may be -redirected to a file. -.SH OPTIONS -.LP -The following options are supported: -.sp -.ne 2 -.na -\fB\fB-c\fR \fR -.ad -.RS 7n -Prints \fIonly\fR the containers and their data. This option does not print the -\fBFRU\fR tree hierarchy. -.RE - -.sp -.ne 2 -.na -\fB\fB-d\fR \fR -.ad -.RS 7n -Prints a \fBDTD\fR for the current registry to stdout. -.RE - -.sp -.ne 2 -.na -\fB\fB-l\fR \fR -.ad -.RS 7n -Prints \fIonly\fR the \fBFRU\fR tree hierarchy. This option does not print the -container data. -.RE - -.sp -.ne 2 -.na -\fB\fB-x\fR \fR -.ad -.RS 7n -Prints in \fBXML\fR format with a system identifier (SYSTEM) of -\fBprtfrureg.dtd\fR. -.RE - -.sp -.LP -Options \fB-c\fR and \fB-l\fR can be used together to obtain a list of the -containers. -.SH OPERANDS -.LP -The following operand is supported: -.sp -.ne 2 -.na -\fB\fIcontainer\fR\fR -.ad -.RS 13n -The name of a particular container in the \fBFRU\fR hierarchy, that is, either -the name or path/name of a container as displayed in the \fB-l\fR option. -.RE - -.SH EXIT STATUS -.LP -The following exit values are returned: -.sp -.ne 2 -.na -\fB\fB0\fR\fR -.ad -.RS 6n -All information was found and printed successfully. -.RE - -.sp -.ne 2 -.na -\fB\fB>0\fR\fR -.ad -.RS 6n -An error has occurred. -.RE - -.SH SEE ALSO -.LP -\fBfruadm\fR(8), \fBattributes\fR(5) diff --git a/usr/src/cmd/Makefile b/usr/src/cmd/Makefile index 1d22cc0f3a..c47d2fc95b 100644 --- a/usr/src/cmd/Makefile +++ b/usr/src/cmd/Makefile @@ -416,9 +416,7 @@ i386_SUBDIRS= \ sparc_SUBDIRS= \ device_remap \ - drd \ - fruadm \ - prtfru + drd # # Commands that are messaged. @@ -614,10 +612,6 @@ MSGSUBDIRS= \ zpool \ zonestat -sparc_MSGSUBDIRS= \ - fruadm \ - prtfru - i386_MSGSUBDIRS= \ ucodeadm diff --git a/usr/src/cmd/fruadm/Makefile b/usr/src/cmd/fruadm/Makefile deleted file mode 100644 index fca8df0b40..0000000000 --- a/usr/src/cmd/fruadm/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -PROG = fruadm -PLATFORM = sun4u -CLASS = 32 # so ParallelMake isn't confused by empty rules - -include $(SRC)/cmd/Makefile.cmd -include $(SRC)/Makefile.psm - -FRULIBS = -L$(SRC)/lib/libfru/$(MACH) -lfru - -CERRWARN += -Wno-switch -CPPFLAGS += -I$(SRC)/lib/libfru/include -LDLIBS += $(FRULIBS) -lm - - -FILEMODE = 755 - -.KEEP_STATE: - -all: $(PROG) - -install: all $(USR_PSM_SBIN_DIR) $(USR_PSM_SBIN_PROG) - -clean: - - -include $(SRC)/cmd/Makefile.targ -include $(SRC)/Makefile.psm.targ diff --git a/usr/src/cmd/fruadm/fruadm.c b/usr/src/cmd/fruadm/fruadm.c deleted file mode 100644 index 0efb6c5539..0000000000 --- a/usr/src/cmd/fruadm/fruadm.c +++ /dev/null @@ -1,967 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 (c) 2014 Gary Mills - * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define NUM_OF_SEGMENT 1 -#define SEGMENT_NAME_SIZE 2 - -#define FD_SEGMENT_SIZE 2949 - -static char *command, *customer_data = NULL, *frupath = NULL, **svcargv; - -/* DataElement supported in the customer operation */ -static char *cust_data_list[] = {"Customer_DataR"}; - -/* DataElement supported in the service operation */ -static char *serv_data_list[] = {"InstallationR", "ECO_CurrentR"}; - -/* currently supported segment name */ -static char *segment_name[] = {"FD"}; - -static int found_frupath = 0, list_only = 0, recursive = 0, - service_mode = 0, svcargc, update = 0; - - -static void -usage(void) -{ - (void) fprintf(stderr, - gettext("Usage: %s [ -l ] | [ [ -r ] frupath [ text ] ]\n"), - command); -} - -static int -validate_fieldnames(int argc, char *argv[]) -{ - static int num = sizeof (serv_data_list)/sizeof (*serv_data_list); - - char *fieldname; - - int i, j, match, status; - - fru_elemdef_t definition; - - - for (i = 0; i < argc; i += 2) { - if (argv[i][0] == '/') { - fieldname = &argv[i][1]; - } else { - fieldname = &argv[i][0]; - } - - match = 0; - for (j = 0; j < num; j++) { - if (strncmp(fieldname, serv_data_list[j], - strlen(serv_data_list[j])) == 0) { - match = 1; - } - } - if (!match) { - (void) fprintf(stderr, - gettext("\"%s\" is not a supported field\n"), - argv[i]); - return (1); - } - - if ((status = fru_get_definition(argv[i], &definition)) - != FRU_SUCCESS) { - (void) fprintf(stderr, gettext("\"%s\": %s\n"), - argv[i], - fru_strerror(status)); - return (1); - } else if ((definition.data_type == FDTYPE_Record) || - (definition.data_type == FDTYPE_UNDEFINED)) { - (void) fprintf(stderr, - gettext("\"%s\" is not a field\n"), argv[i]); - return (1); - } - } - - return (0); -} - -static int -pathmatch(const char *path) -{ - char *match; - - if ((frupath != NULL) && - ((match = strstr(path, frupath)) != NULL) && - ((match + strlen(frupath)) == (path + strlen(path))) && - ((match == path) || (*(match - 1) == '/'))) { - found_frupath = 1; - return (1); - } - return (0); -} - -static void -displayBinary(unsigned char *data, size_t length, fru_elemdef_t *def) -{ - int i = 0; - uint64_t lldata; - uint64_t mask; - - if (def->disp_type == FDISP_Hex) { - for (i = 0; i < length; i++) { - (void) printf("%02X", data[i]); - } - return; - } - - (void) memcpy(&lldata, data, sizeof (lldata)); - switch (def->disp_type) { - case FDISP_Binary: - { - mask = 0x8000000000000000ULL; - for (i = 0; i < (sizeof (uint64_t) *8); i++) { - if (lldata & (mask >> i)) { - (void) printf("1"); - } else { - (void) printf("0"); - } - } - return; - } - case FDISP_Octal: - { - (void) printf("%llo", lldata); - return; - } - case FDISP_Decimal: - { - (void) printf("%lld", lldata); - return; - } - case FDISP_Time: - { - char buffer[PATH_MAX]; - time_t time; - time = (time_t)lldata; - (void) strftime(buffer, PATH_MAX, "%+", - localtime(&time)); - (void) printf("%s", buffer); - return; - } - } -} - -static void -displayBAasBinary(unsigned char *data, size_t length) -{ - int i; - unsigned char mask; - - for (i = 0; i < length; i++) { - /* - * make a mask for the high order bit and adjust down through - * all the bits. - */ - for (mask = 0x80; mask > 0; mask /= 2) { - if ((data[i] & mask) != 0) /* bit must be on */ - (void) printf("1"); - else /* bit is off... */ - (void) printf("0"); - } - } - (void) printf("\n"); -} - -static void -display_data(unsigned char *data, size_t length, fru_elemdef_t *def) -{ - int i = 0; - uint64_t lldata; - - if (data == 0x00) { - (void) printf("\n"); - return; - } - - switch (def->data_type) { - case FDTYPE_Binary: - { - displayBinary(data, length, def); - return; - } - - case FDTYPE_ByteArray: - { - switch (def->disp_type) { - case FDISP_Binary: - displayBAasBinary(data, length); - return; - case FDISP_Hex: - for (i = 0; i < length; i++) { - (void) printf("%02X", data[i]); - } - return; - } - return; - } - case FDTYPE_Unicode: - assert(gettext("Unicode not yet supported") == 0); - break; - case FDTYPE_ASCII: - { - char *disp_str = (char *)alloca(length+1); - for (i = 0; i < length; i++) - disp_str[i] = data[i]; - disp_str[i] = '\0'; - (void) printf("%s", disp_str); - return; - } - - case FDTYPE_Enumeration: - { - lldata = strtoull((const char *)data, NULL, 0); - for (i = 0; i < def->enum_count; i++) { - if (def->enum_table[i].value == lldata) { - /* strdup such that map_... can realloc if necessary. */ - char *tmp = strdup(def->enum_table[i].text); - (void) printf("%s", tmp); - free(tmp); - return; - } - } - (void) printf(gettext("Unrecognized Value: 0x")); - for (i = 0; i < sizeof (uint64_t); i++) - (void) printf("%02X", data[i]); - break; - } - default: - break; - } -} - -static void -print_node_data(fru_nodehdl_t cont_hdl) -{ - int iter_cnt = 0; - int iter; - int numseg; - int list_cnt; - unsigned char *data; - size_t dataLen; - int total_cnt; - char *found_path = NULL; - fru_elemdef_t def, def1; - int instance = 0; - char **ptr; - char **tmp_ptr; - int count = 0; - char elem_name[PATH_MAX]; - - if (service_mode) { - total_cnt = sizeof (serv_data_list)/sizeof (*serv_data_list); - ptr = serv_data_list; - } else { - total_cnt = sizeof (cust_data_list)/sizeof (*cust_data_list); - ptr = cust_data_list; - } - tmp_ptr = ptr; - - for (numseg = 0; numseg < NUM_OF_SEGMENT; numseg++) { - ptr = tmp_ptr; - for (list_cnt = 0; list_cnt < total_cnt; list_cnt++) { - if ((fru_get_definition(*ptr, &def)) != FRU_SUCCESS) { - continue; - } - if ((fru_get_num_iterations(cont_hdl, - &segment_name[numseg], 0, *ptr, - &iter_cnt, NULL)) != FRU_SUCCESS) { - iter_cnt = 0; - } - iter = 0; - do { - for (count = 0; count < def.enum_count; - count++) { - if (def.iteration_type != - FRU_NOT_ITERATED) { - (void) snprintf(elem_name, - sizeof (elem_name), - "/%s[%d]/%s", *ptr, iter, def.enum_table[count].text); - } else { - (void) snprintf(elem_name, - sizeof (elem_name), - "/%s/%s", *ptr, def.enum_table[count].text); - } - - if ((fru_read_field(cont_hdl, - &segment_name[numseg], instance, - elem_name, (void**)&data, &dataLen, - &found_path)) != FRU_SUCCESS) { - break; - } - - if ((fru_get_definition( - def.enum_table[count].text, &def1)) != FRU_SUCCESS) { - break; - } - (void) printf(" %s: ",\ - elem_name); - display_data(data, dataLen, &def1); - (void) printf("\n"); - } - iter ++; - } while (iter < iter_cnt); - ptr++; - } - } -} - -static char * -convertBinaryToDecimal(char *ptr) -{ - int cnt = 0; - char *data; - int str_len; - char *ret = NULL; - uint64_t result = 0; - - str_len = strlen(ptr); - data = ptr; - - while (str_len >= 1) { - str_len -= 1; - if (data[str_len] == '0') { - result += (0 * pow(2, cnt)); - } - if (data[str_len] == '1') { - result += (1 * pow(2, cnt)); - } - cnt++; - } - ret = (char *)lltostr(result, "\n"); - return (ret); -} - -/* - * called update_field() to update the field with specific field value. - * nodehdl represents the fru, segment represents the segment name in the fru. - * field_name represents the field to be updated with the value field_value. - */ - -static int -convert_update(fru_nodehdl_t nodehdl, char *segment, char *field_name, - char *field_value) -{ - uint64_t num = 0; - fru_elemdef_t def; - fru_errno_t err; - void *data = NULL; - size_t dataLen = 0; - int i; - - if ((err = fru_get_definition(field_name, &def)) != FRU_SUCCESS) { - (void) fprintf(stderr, - gettext("Failed to get definition %s: %s\n"), - field_name, fru_strerror(err)); - return (1); - } - - if (field_value == NULL) { - return (1); - } - - switch (def.data_type) { - case FDTYPE_Binary: - if (def.disp_type != FDISP_Time) { - if (field_value[0] == 'b') { - field_value = - convertBinaryToDecimal((field_value - +1)); - } - num = strtoll(field_value, (char **)NULL, 0); - if ((num == 0) && (errno == 0)) { - return (1); - } - data = (void*)# - dataLen = sizeof (uint64_t); - } - break; - case FDTYPE_ByteArray: - return (1); - case FDTYPE_Unicode: - return (1); - case FDTYPE_ASCII: - data = (void *) field_value; - dataLen = strlen(field_value); - if (dataLen < def.data_length) { - dataLen++; - } - break; - case FDTYPE_Enumeration: - for (i = 0; i < def.enum_count; i++) { - if (strcmp(def.enum_table[i].text, - field_value) == 0) { - data = (void *)(uintptr_t) - def.enum_table[i].value; - dataLen = sizeof (uint64_t); - break; - } - } - return (1); - case FDTYPE_Record: - if (def.iteration_count == 0) { - return (1); - } - data = NULL; - dataLen = 0; - break; - case FDTYPE_UNDEFINED: - return (1); - } - - if ((err = fru_update_field(nodehdl, segment, 0, field_name, data, - dataLen)) != FRU_SUCCESS) { - (void) fprintf(stderr, gettext("fru_update_field(): %s\n"), - fru_strerror(err)); - return (1); - } - return (0); -} -/* - * called by update_field() when a new data element is created. - * it updates the UNIX_Timestamp32 field with the current system time. - */ - -static int -update_unixtimestamp(fru_nodehdl_t nodehdl, char *segment, char **ptr) -{ - char *field_name; - time_t clock; - struct tm *sp_tm; - fru_errno_t err = FRU_SUCCESS; - uint64_t time_data; - size_t len; - - len = strlen(*ptr) + strlen("UNIX_Timestamp32") + 3; - field_name = alloca(len); - - (void) snprintf(field_name, len, "/%s/UNIX_Timestamp32", *ptr); - - clock = time(NULL); - sp_tm = localtime(&clock); - time_data = (uint64_t)mktime(sp_tm); - - if ((err = fru_update_field(nodehdl, segment, 0, field_name, - (void *)&time_data, sizeof (time_data))) != FRU_SUCCESS) { - (void) fprintf(stderr, gettext("fru_update_field(): %s\n"), - fru_strerror(err)); - return (1); - } - return (0); -} - -/* - * create segment on the specified fru represented by nodehdl. - */ - -static int -create_segment(fru_nodehdl_t nodehdl) -{ - fru_segdesc_t seg_desc; - fru_segdef_t def; - int cnt; - int status; - - (void) memset(&seg_desc, 0, sizeof (seg_desc)); - seg_desc.field.field_perm = 0x6; - seg_desc.field.operations_perm = 0x6; - seg_desc.field.engineering_perm = 0x6; - seg_desc.field.repair_perm = 0x6; - - (void) memset(&def, 0, sizeof (def)); - def.address = 0; - def.desc.raw_data = seg_desc.raw_data; - def.hw_desc.all_bits = 0; - - for (cnt = 0; cnt < NUM_OF_SEGMENT; cnt++) { - (void) strncpy(def.name, segment_name[cnt], SEGMENT_NAME_SIZE); - if (cnt == 0) { - def.size = FD_SEGMENT_SIZE; - } - if ((status = fru_create_segment(nodehdl, &def)) - != FRU_SUCCESS) { - continue; - } - return (cnt); - } - if (status != FRU_SUCCESS) - (void) fprintf(stderr, gettext("fru_create_segment(): %s\n"), - fru_strerror(status)); - return (1); -} - -/* - * called from update_field() when service flag is ON. currently - * supported iterated record is InstallationR and fields supported for - * update are Geo_North, Geo_East, Geo_Alt, Geo_Location. - */ - -static int -updateiter_record(fru_nodehdl_t nodehdl, int cnt, char **ptr, - char *field_name, char *field_value) -{ - int iter_cnt = 0; - char rec_name[512]; - void *data = NULL; - char *tmpptr = NULL; - size_t dataLen = 0; - char **elem_ptr; - int found = 0; - int index; - int total_cnt; - fru_errno_t err; - - static char *elem_list[] = {"/Geo_North", "/Geo_East",\ - "/Geo_Alt", "/Geo_Location"}; - - elem_ptr = elem_list; - total_cnt = sizeof (elem_list)/sizeof (*elem_list); - - for (index = 0; index < total_cnt; index++) { - tmpptr = strrchr(field_name, '/'); - if (tmpptr == NULL) { - (void) fprintf(stderr, - gettext("Error: Data Element not known\n")); - return (1); - } - if ((strncmp(*elem_ptr, tmpptr, strlen(*elem_ptr)) != 0)) { - elem_ptr++; - continue; - } - found = 1; - break; - } - - if (found == 0) { - (void) fprintf(stderr, - gettext("Error: Update not allowed for field: %s\n"), - field_name); - return (1); - } - - if ((fru_get_num_iterations(nodehdl, &segment_name[cnt], 0, - *ptr, &iter_cnt, NULL)) != FRU_SUCCESS) { - return (1); - } - - /* add a new Iterated Record if complete path is not given */ - if (iter_cnt == 0) { - (void) snprintf(rec_name, sizeof (rec_name), "/%s[+]", *ptr); - if ((err = fru_update_field(nodehdl, segment_name[cnt], 0, - rec_name, data, dataLen)) != FRU_SUCCESS) { - (void) fprintf(stderr, - gettext("fru_update_field(): %s\n"), - fru_strerror(err)); - return (1); - } - - iter_cnt = 1; - } - - (void) snprintf(rec_name, sizeof (rec_name), "/%s[%d]%s", - *ptr, iter_cnt-1, strrchr(field_name, '/')); - - if ((convert_update(nodehdl, segment_name[cnt], rec_name, - field_value)) != 0) { - return (1); - } - - /* update success now update the unix timestamp */ - - (void) snprintf(rec_name, sizeof (rec_name), "/%s[%d]", - *ptr, iter_cnt-1); - tmpptr = rec_name; - - /* update UNIX_Timestamp32 with creation time */ - if ((update_unixtimestamp(nodehdl, segment_name[cnt], - &tmpptr)) != 0) { - return (1); - } - - return (0); -} - -static int -update_field(fru_nodehdl_t nodehdl, char *field_name, char *field_value) -{ - fru_elemdef_t def; - unsigned char *data; - size_t dataLen; - char *found_path = NULL; - int cnt; - char **ptr; - fru_strlist_t elem; - int elem_cnt; - int add_flag = 1; - int total_cnt; - int status; - - if (service_mode) { - ptr = serv_data_list; - total_cnt = sizeof (serv_data_list)/sizeof (*serv_data_list); - - for (cnt = 0; cnt < total_cnt; cnt++) { - if ((strncmp(*ptr, &field_name[1], strlen(*ptr)) \ - != 0) && (strncmp(*ptr, &field_name[0], - strlen(*ptr)) != 0)) { - ptr++; - add_flag = 0; - continue; - } - add_flag = 1; - break; - } - } else { - ptr = cust_data_list; - } - - /* look for the field in either of the segment if found update it */ - for (cnt = 0; cnt < NUM_OF_SEGMENT; cnt++) { - if ((fru_read_field(nodehdl, &segment_name[cnt], 0, field_name, - (void **) &data, &dataLen, &found_path)) != FRU_SUCCESS) { - continue; - } - if ((fru_get_definition(*ptr, &def)) == FRU_SUCCESS) { - if (def.iteration_count != 0) { - if ((updateiter_record(nodehdl, cnt, ptr, - field_name, field_value)) != 0) { - return (1); - } - return (0); - } - } - - if ((convert_update(nodehdl, segment_name[cnt], - field_name, field_value)) != 0) { - return (1); - } - - /* update UNIX_Timestamp32 with update time */ - if ((update_unixtimestamp(nodehdl, segment_name[cnt], - ptr)) != 0) { - return (1); - } - return (0); - } - - elem.num = 0; - - /* field not found add the the record in one of the segment */ - for (cnt = 0; cnt < NUM_OF_SEGMENT; cnt++) { - (void) fru_list_elems_in(nodehdl, segment_name[cnt], &elem); - for (elem_cnt = 0; elem_cnt < elem.num; elem_cnt++) { - if ((strcmp(*ptr, elem.strs[elem_cnt])) == 0) { - add_flag = 0; - } - } - - if (add_flag) { - if ((fru_add_element(nodehdl, segment_name[cnt], - *ptr)) != FRU_SUCCESS) { - continue; - } - } - - if ((fru_get_definition(*ptr, &def)) == FRU_SUCCESS) { - if (def.iteration_count != 0) { - if ((updateiter_record(nodehdl, cnt, ptr, - field_name, field_value)) != 0) { - return (1); - } - return (0); - } - } - - /* update UNIX_Timestamp32 with creation time */ - if ((update_unixtimestamp(nodehdl, segment_name[cnt], - ptr)) != 0) { - return (1); - } - - /* record added update the field with the value */ - if ((convert_update(nodehdl, segment_name[cnt], field_name, - field_value)) != 0) { - return (1); - } - return (0); - } - - /* segment not present, create one and add the record */ - cnt = create_segment(nodehdl); - if (cnt == 1) { - return (1); - } - - if ((status = fru_add_element(nodehdl, segment_name[cnt], *ptr)) - != FRU_SUCCESS) { - (void) fprintf(stderr, gettext("fru_add_element(): %s\n"), - fru_strerror(status)); - return (1); - } - - if ((fru_get_definition(*ptr, &def)) == FRU_SUCCESS) { - if (def.iteration_count != 0) { - if ((updateiter_record(nodehdl, cnt, ptr, - field_name, field_value)) != 0) { - return (1); - } - return (0); - } - } - - /* update UNIX_Timestamp32 with creation time */ - if ((update_unixtimestamp(nodehdl, segment_name[cnt], - ptr)) != 0) { - return (1); - } - - if ((convert_update(nodehdl, segment_name[cnt], field_name, - field_value)) != 0) { - return (1); - } - return (0); -} - -static int -update_node_data(fru_nodehdl_t node) -{ - int i; - int status = 0; - - if (service_mode) { - for (i = 0; i < svcargc; i += 2) - if (update_field(node, svcargv[i], svcargv[i + 1])) { - status = 1; - } - } else { - status = update_field(node, "/Customer_DataR/Cust_Data", - customer_data); - } - return (status); -} - -static void -walk_tree(fru_nodehdl_t node, const char *prior_path, int process_tree) -{ - char *name, path[PATH_MAX]; - int process_self = process_tree, status, update_status = 0; - fru_nodehdl_t next_node; - fru_node_t type; - - if ((status = fru_get_node_type(node, &type)) != FRU_SUCCESS) { - (void) fprintf(stderr, - gettext("Error getting FRU tree node type: %s\n"), - fru_strerror(status)); - exit(1); - } - - if ((status = fru_get_name_from_hdl(node, &name)) != FRU_SUCCESS) { - (void) fprintf(stderr, - gettext("Error getting name of FRU tree node: %s\n"), - fru_strerror(status)); - exit(1); - } - - - /* - * Build the current path - */ - if (snprintf(path, sizeof (path), "%s/%s", prior_path, name) - >= sizeof (path)) { - (void) fprintf(stderr, - gettext("FRU tree path would overflow buffer\n")); - exit(1); - } - - free(name); - - /* - * Process the node - */ - if (list_only) { - (void) printf("%s%s\n", path, ((type == FRU_NODE_FRU) ? - " (fru)" : ((type == FRU_NODE_CONTAINER) ? - " (container)" : ""))); - } else if ((process_tree || (process_self = pathmatch(path))) && - (type == FRU_NODE_CONTAINER)) { - (void) printf("%s\n", path); - if (update) { - status = update_node_data(node); - update_status = status; - } - print_node_data(node); - if (!recursive) { - exit(status); - } - } else if (process_self && !recursive) { - (void) fprintf(stderr, - gettext("\"%s\" is not a container\n"), path); - exit(1); - } - - - /* - * Recurse - */ - if (fru_get_child(node, &next_node) == FRU_SUCCESS) - walk_tree(next_node, path, process_self); - - if (fru_get_peer(node, &next_node) == FRU_SUCCESS) - walk_tree(next_node, prior_path, process_tree); - - /* - * when update_node_data failed, need to exit with return value 1 - */ - if (update_status) - exit(1); -} - -int -main(int argc, char *argv[]) -{ - int process_tree = 0, option, status; - - fru_nodehdl_t root; - - - command = argv[0]; - - opterr = 0; /* "getopt" should not print to "stderr" */ - while ((option = getopt(argc, argv, "lrs")) != EOF) { - switch (option) { - case 'l': - list_only = 1; - break; - case 'r': - recursive = 1; - break; - case 's': - service_mode = 1; - break; - default: - usage(); - return (1); - } - } - - argc -= optind; - argv += optind; - - if (argc == 0) { - process_tree = 1; - recursive = 1; - } else { - if (list_only) { - usage(); - return (1); - } - - frupath = argv[0]; - if (*frupath == 0) { - usage(); - (void) fprintf(stderr, - gettext("\"frupath\" should not be empty\n")); - return (1); - } - - argc--; - argv++; - - if (argc > 0) { - update = 1; - if (service_mode) { - if ((argc % 2) != 0) { - (void) fprintf(stderr, - gettext("Must specify " - "field-value pairs " - "for update\n")); - return (1); - } - - if (validate_fieldnames(argc, argv) != 0) { - return (1); - } - - svcargc = argc; - svcargv = argv; - } else if (argc == 1) - customer_data = argv[0]; - else { - usage(); - return (1); - } - } - } - - if ((status = fru_open_data_source("picl", NULL)) != FRU_SUCCESS) { - (void) fprintf(stderr, - gettext("Unable to access FRU data source: %s\n"), - fru_strerror(status)); - return (1); - } - - if ((status = fru_get_root(&root)) == FRU_NODENOTFOUND) { - (void) fprintf(stderr, - gettext("This system does not support PICL " - "infrastructure to provide FRUID data\n" - "Please use the platform SP to access the FRUID " - "information\n")); - return (1); - } else if (status != FRU_SUCCESS) { - (void) fprintf(stderr, - gettext("Unable to access FRU ID data " - "due to data source error\n")); - return (1); - } - - walk_tree(root, "", process_tree); - - if ((frupath != NULL) && (!found_frupath)) { - (void) fprintf(stderr, - gettext("\"%s\" not found\n"), - frupath); - return (1); - } - - return (0); -} diff --git a/usr/src/cmd/prtfru/Makefile b/usr/src/cmd/prtfru/Makefile deleted file mode 100644 index 072227e799..0000000000 --- a/usr/src/cmd/prtfru/Makefile +++ /dev/null @@ -1,65 +0,0 @@ -# -# 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 -# or http://www.opensolaris.org/os/licensing. -# 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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# cmd/prtfru/Makefile -# - -PROG = prtfru -OBJS = $(PROG).o main.o -SRCS = $(OBJS:%.o=%.c) - -include $(SRC)/cmd/Makefile.cmd - -CERRWARN += -Wno-switch -CERRWARN += -Wno-parentheses -CPPFLAGS += -I$(SRC)/lib/libfru/include \ - -I$(SRC)/lib/libfruutils -EXTRA_LDLIBS = -lfru -lfrureg -lfruutils - -FILEMODE = 755 - -.KEEP_STATE: - -all: $(PROG) - -$(PROG): $(OBJS) - $(LINK.c) -o $@ $(OBJS) $(LDLIBS) $(EXTRA_LDLIBS) - $(POST_PROCESS) - -install: all $(ROOTUSRSBIN) $(ROOTUSRSBINPROG) - -$(ROOTUSRSBIN): - $(INS.dir) - - -POFILE = $(PROG)_msg.po -POFILES = $(OBJS:%.o=%.po) - -$(POFILE): $(POFILES) - $(RM) $@; cat $(POFILES) > $@ - -clean: - $(RM) $(OBJS) - -include $(SRC)/cmd/Makefile.targ diff --git a/usr/src/cmd/prtfru/main.c b/usr/src/cmd/prtfru/main.c deleted file mode 100644 index 511d16966d..0000000000 --- a/usr/src/cmd/prtfru/main.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include -#include -#include - -#include "libfru.h" -#include "prtfru.h" - - -static void -usage(const char *command) -{ - (void) fprintf(stderr, - gettext("Usage: %s [ -d ] | [ -clx ] [ container ]\n"), - command); -} - -int -main(int argc, char *argv[]) -{ - char *command = argv[0], *searchpath = NULL; - - int containers_only = 0, dtd = 0, list_only = 0, nodtd = 0, option, - status, xml = 0; - - - (void) setlocale(LC_ALL, ""); - (void) textdomain(TEXT_DOMAIN); - - opterr = 0; /* "getopt" should not print to "stderr" */ - while ((option = getopt(argc, argv, "cdlx")) != EOF) { - switch (option) { - case 'c': - containers_only = 1; - nodtd = 1; - break; - case 'd': - dtd = 1; - break; - case 'l': - list_only = 1; - nodtd = 1; - break; - case 'x': - xml = 1; - nodtd = 1; - break; - default: - usage(command); - return (1); - } - } - - argc -= optind; - argv += optind; - - if (dtd) { - if (nodtd || (argc > 0)) { - usage(command); - (void) fprintf(stderr, - gettext("Specify \"-d\" alone\n")); - return (1); - } - - return (output_dtd()); - } - - switch (argc) { - case 0: - break; - case 1: - searchpath = argv[0]; - if (!searchpath[0]) { - usage(command); - (void) fprintf(stderr, - gettext("\"container\" should not be empty\n")); - return (1); - } - break; - default: - usage(command); - return (1); - } - - - /* - * Select the data source and print all the data - */ - if ((status = fru_open_data_source("picl")) != FRU_SUCCESS) { - (void) fprintf(stderr, - gettext("Error opening FRU ID data source: %s\n"), - fru_strerror(status)); - return (1); - } - - return (prtfru(searchpath, containers_only, list_only, xml)); -} diff --git a/usr/src/cmd/prtfru/prtfru.c b/usr/src/cmd/prtfru/prtfru.c deleted file mode 100644 index 71708e7453..0000000000 --- a/usr/src/cmd/prtfru/prtfru.c +++ /dev/null @@ -1,1382 +0,0 @@ -/* - * 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 - * or http://www.opensolaris.org/os/licensing. - * 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 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "fru_tag.h" -#include "libfrup.h" -#include "libfrureg.h" - - -#define NUM_ITER_BYTES 4 - -#define HEAD_ITER 0 -#define TAIL_ITER 1 /* not used */ -#define NUM_ITER 2 -#define MAX_ITER 3 - -#define INDENT 3 -#define TIMESTRINGLEN 128 -#define TEMPERATURE_OFFSET 73 -#define MIN_VERSION 17 -#define GMT "%a, %b %d %Y %H:%M:%S GMT" - -typedef struct -{ - uint8_t value; - char *data; -} Status_CurrentR; - -Status_CurrentR Status_CurrentR_status[] = { - { 0x00, "OK"}, - { 0x04, "DEEMED FAULTY"}, - { 0x08, "FRU DETECTED"}, - { 0x0c, "FRU DETECTED, DEEMED FAULTY"}, - { 0x10, "PROXIED FAULT"}, - { 0x14, "DEEMED FAULTY. Also PROXIED FAULT"}, - { 0x18, "FRU DETECTED. Also PROXIED FAULT"}, - { 0x1c, "FRU DETECTED, DEEMED FAULTY. Also PROXIED FAULT"}, - { 0x20, "SUSPECT"}, - { 0x24, "SUSPECT, DEEMED FAULTY"}, - { 0x28, "SUSPECT, FRU DETECTED"}, - { 0x2c, "SUSPECT, FRU DETECTED, DEEMED FAULTY"}, - { 0x30, "SUSPECT. Also PROXIED FAULT"}, - { 0x34, "SUSPECT, DEEMED FAULTY. Also PROXIED FAULT"}, - { 0x38, "SUSPECT, FRU DETECTED. Also PROXIED FAULT"}, - { 0x3c, "SUSPECT, FRU DETECTED, DEEMED FAULTY. Also PROXIED FAULT"}, - { 0x40, "MAINTENANCE REQUIRED"}, - { 0x44, "MAINTENANCE REQUIRED, DEEMED FAULTY"}, - { 0x48, "MAINTENANCE REQUIRED, FRU DETECTED"}, - { 0x4c, "MAINTENANCE REQUIRED, FRU DETECTED, DEEMED FAULTY"}, - { 0x50, "MAINTENANCE REQUIRED. Also PROXIED FAULT"}, - { 0x54, "MAINTENANCE REQUIRED, DEEMED FAULTY. Also PROXIED FAULT"}, - { 0x58, "MAINTENANCE REQUIRED, FRU DETECTED. Also PROXIED FAULT"}, - { 0x5c, "MAINTENANCE REQUIRED, FRU DETECTED, DEEMED FAULTY. \ - Also PROXIED FAULT"}, - { 0x60, "MAINTENANCE REQUIRED, SUSPECT"}, - { 0x64, "MAINTENANCE REQUIRED, SUSPECT, DEEMED FAULTY"}, - { 0x68, "MAINTENANCE REQUIRED, SUSPECT, FRU DETECTED"}, - { 0x6c, "MAINTENANCE REQUIRED, SUSPECT, FRU DETECTED, DEEMED FAULTY"}, - { 0x70, "MAINTENANCE REQUIRED, SUSPECT. Also PROXIED FAULT"}, - { 0x74, "MAINTENANCE REQUIRED, SUSPECT, DEEMED FAULTY.\ - Also PROXIED FAULT"}, - { 0x78, "MAINTENANCE REQUIRED, SUSPECT, FRU DETECTED. \ - Also PROXIED FAULT"}, - { 0x7c, "MAINTENANCE REQUIRED, SUSPECT, FRU DETECTED, \ - DEEMED FAULTY. Also PROXIED FAULT"}, - { 0x80, "DISABLED"}, - { 0x84, "DISABLED, DEEMED FAULTY"}, - { 0x88, "DISABLED, FRU DETECTED"}, - { 0x8c, "DISABLED, FRU DETECTED, DEEMED FAULTY"}, - { 0x90, "DISABLED. Also PROXIED FAULT"}, - { 0x94, "DISABLED, DEEMED FAULTY. Also PROXIED FAULT"}, - { 0x98, "DISABLED, FRU DETECTED. Also PROXIED FAULT"}, - { 0x9c, "DISABLED, FRU DETECTED, DEEMED FAULTY. Also PROXIED FAULT"}, - { 0xa0, "DISABLED, SUSPECT"}, - { 0xa4, "DISABLED, SUSPECT, DEEMED FAULTY"}, - { 0xa8, "DISABLED, SUSPECT, FRU DETECTED"}, - { 0xac, "DISABLED, SUSPECT, FRU DETECTED, DEEMED FAULTY"}, - { 0xb0, "DISABLED, SUSPECT. Also PROXIED FAULT"}, - { 0xb4, "DISABLED, SUSPECT, DEEMED FAULTY. Also PROXIED FAULT"}, - { 0xb8, "DISABLED, SUSPECT, FRU DETECTED. Also PROXIED FAULT"}, - { 0xbc, "DISABLED, SUSPECT, FRU DETECTED, \ - DEEMED FAULTY. Also PROXIED FAULT"}, - { 0xc0, "DISABLED, MAINTENANCE REQUIRED"}, - { 0xc4, "DISABLED, MAINTENANCE REQUIRED, DEEMED FAULTY"}, - { 0xc8, "DISABLED, MAINTENANCE REQUIRED, FRU DETECTED"}, - { 0xcc, "DISABLED, MAINTENANCE REQUIRED, FRU DETECTED, DEEMED FAULTY"}, - { 0xd0, "DISABLED, MAINTENANCE REQUIRED. Also PROXIED FAULT"}, - { 0xd4, "DISABLED, MAINTENANCE REQUIRED, \ - DEEMED FAULTY. Also PROXIED FAULT"}, - { 0xd8, "DISABLED, MAINTENANCE REQUIRED, \ - FRU DETECTED. Also PROXIED FAULT"}, - { 0xdc, "DISABLED, MAINTENANCE REQUIRED, FRU DETECTED, \ - DEEMED FAULTY. Also PROXIED FAULT"}, - { 0xe0, "DISABLED, MAINTENANCE REQUIRED, SUSPECT"}, - { 0xe4, "DISABLED, MAINTENANCE REQUIRED, SUSPECT, DEEMED FAULTY"}, - { 0xe8, "DISABLED, MAINTENANCE REQUIRED, SUSPECT, FRU DETECTED"}, - { 0xec, "DISABLED, MAINTENANCE REQUIRED, SUSPECT, \ - FRU DETECTED, DEEMED FAULTY"}, - { 0xf0, "DISABLED, MAINTENANCE REQUIRED, SUSPECT. Also PROXIED FAULT"}, - { 0xf4, "DISABLED, MAINTENANCE REQUIRED, SUSPECT, \ - DEEMED FAULTY. Also PROXIED FAULT"}, - { 0xf8, "DISABLED, MAINTENANCE REQUIRED, SUSPECT, \ - FRU DETECTED. Also PROXIED FAULT"}, - { 0xfc, "DISABLED, MAINTENANCE REQUIRED, SUSPECT, \ - FRU DETECTED, DEEMED FAULTY. Also PROXIED FAULT"}, - { 0xff, "RETIRED"} -}; - -static void (*print_node)(fru_node_t fru_type, const char *path, - const char *name, end_node_fp_t *end_node, - void **end_args); - -static void print_element(const uint8_t *data, const fru_regdef_t *def, -const char *parent_path, int indent); - -static char tagname[sizeof ("?_0123456789_0123456789_0123456789")]; - -static int containers_only = 0, list_only = 0, saved_status = 0, xml = 0; - -static FILE *errlog; - -int iterglobal = 0; -int FMAmessageR = -1; -int Fault_Install_DataR_flag = 0; -int Power_On_DataR_flag = 0; -int spd_memtype = 0; -int spd_revision = 0; -/* - * Definition for data elements found in devices but not found in - * the system's version of libfrureg - */ -static fru_regdef_t unknown = { - REGDEF_VERSION, - tagname, - -1, - -1, - -1, - -1, - FDTYPE_ByteArray, - FDISP_Hex, - FRU_WHICH_UNDEFINED, - FRU_WHICH_UNDEFINED, - 0, - NULL, - 0, - FRU_NOT_ITERATED, - NULL -}; - - -/* - * Write message to standard error and possibly the error log buffer - */ -static void -error(const char *format, ...) -{ - va_list args; - - - /* make relevant output appear before error message */ - if (fflush(stdout) == EOF) { - (void) fprintf(stderr, "Error flushing output: %s\n", - strerror(errno)); - exit(1); - } - - va_start(args, format); - if (vfprintf(stderr, format, args) < 0) exit(1); - if (errlog && (vfprintf(errlog, format, args) < 0)) exit(1); -} - -/* - * Write message to standard output - */ -static void -output(const char *format, ...) -{ - va_list args; - - - va_start(args, format); - if (vfprintf(stdout, format, args) < 0) { - error(gettext("Error writing output: %s\n"), - strerror(errno)); - exit(1); - } -} - -/* - * Safe wrapper for putchar() - */ -static void -voidputchar(int c) -{ - if (putchar(c) == EOF) { - error(gettext("Error writing output: %s\n"), - strerror(errno)); - exit(1); - } -} - -static void (*safeputchar)(int c) = voidputchar; - -/* - * Safe wrapper for puts() - */ -static void -voidputs(const char *s) -{ - if (fputs(s, stdout) == EOF) { - error(gettext("Error writing output: %s\n"), - strerror(errno)); - exit(1); - } -} - -static void (*safeputs)(const char *s) = voidputs; - -/* - * XML-safe wrapper for putchar(): quotes XML-special characters - */ -static void -xputchar(int c) -{ - switch (c) { - case '<': - c = fputs("<", stdout); - break; - case '>': - c = fputs(">", stdout); - break; - case '&': - c = fputs("&", stdout); - break; - case '"': - c = fputs(""", stdout); - break; - default: - c = putchar(c); - break; - } - - if (c == EOF) { - error(gettext("Error writing output: %s\n"), - strerror(errno)); - exit(1); - } -} - -/* - * XML-safe analog of puts(): quotes XML-special characters - */ -static void -xputs(const char *s) -{ - char c; - - for (/* */; ((c = *s) != 0); s++) - xputchar(c); -} - -/* - * Output the XML DTD derived from the registry provided by libfrureg - */ -int -output_dtd(void) -{ - char **element; - - unsigned int i, j, num_elements = 0; - - uint8_t *tagged; - - const fru_regdef_t *def; - - - if (((element = fru_reg_list_entries(&num_elements)) == NULL) || - (num_elements == 0)) { - error(gettext("No FRU ID Registry elements")); - return (1); - } - - if ((tagged = calloc(num_elements, sizeof (*tagged))) == NULL) { - error(gettext("Unable to get memory for tagged element list"), - strerror(errno)); - return (1); - } - - /* - * Output the DTD preamble - */ - output("\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n"); - - /* - * Output the definition for each element - */ - for (i = 0; i < num_elements; i++) { - assert(element[i] != NULL); - /* Prevent incompatible duplicate defn. from FRUID Registry. */ - if ((strcmp("Location", element[i])) == 0) continue; - if ((def = fru_reg_lookup_def_by_name(element[i])) == NULL) { - error(gettext("Error looking up registry " - "definition for \"%s\"\n"), - element[i]); - return (1); - } - - if (def->tagType != FRU_X) tagged[i] = 1; - - if (def->dataType == FDTYPE_Record) { - if (def->iterationType == FRU_NOT_ITERATED) - output("enumTable[0].text); - else - output("\n" - "\n" - "enumTable[0].text); - - for (j = 1; j < def->enumCount; j++) - output(",\n\t%s", def->enumTable[j].text); - - output(")>\n"); - } else if (def->iterationType == FRU_NOT_ITERATED) { - output("\n" - "\n", - element[i], element[i]); - - if (def->dataType == FDTYPE_Enumeration) { - output("\n"); - } - } - else - output("\n", element[i]); - - output("\n"); - } - - /* Provide for returning the tag for an "unknown" element */ - output("\n\n"); - - - /* - * List all data elements as possible members of "Segment" - */ - output("\n"); - free(element); - free(tagged); - - return (0); -} -/* - * Function to convert bcd to binary to correct the SPD_Manufacturer_Week - * - */ -static void convertbcdtobinary(int *val) -{ - unsigned int newval = (unsigned int)*val, tmpval = 0; - while (newval > 0) { - tmpval = (tmpval << 4) | (newval & 0xF); - newval >>= 4; - } - while (tmpval > 0) { - newval = (newval * 10) + (tmpval & 0xF); - tmpval >>= 4; - } - *val = newval; -} - -/* - * Checking UTF-8 printable charecter - */ -static int check_utf_char(const uint8_t *field, int len) -{ - int i, status = 0; - char tmp[128], tmp1[128], tmp2[128]; - (void) sprintf(tmp, " (Invalid Data"); - (void) sprintf(tmp2, "0x"); - for (i = 0; i < len && field[i]; i++) { - (void) sprintf(tmp1, "%2.2X", field[i]); - (void) strcat(tmp2, tmp1); - if (iswprint(field[i]) == 0) { - status = 1; - (void) sprintf(tmp1, " : 0x%2.2X", field[i]); - (void) strcat(tmp, tmp1); - } - } - if (status) { - (void) sprintf(tmp1, ")"); - (void) strcat(tmp, tmp1); - (void) strcat(tmp2, tmp); - output("%s", tmp2); - } - return (status); -} - -/* - * Safely pretty-print the value of a field - */ -static void -print_field(const uint8_t *field, const fru_regdef_t *def) -{ - char *errmsg = NULL, timestring[TIMESTRINGLEN], path[16384]; - - int i, valueint; - - uint64_t value; - - time_t timefield; - - struct tm *tm; - - uchar_t first_byte, data[128]; - - const fru_regdef_t *new_def; - - const char *elem_name = NULL; - const char *parent_path; - switch (def->dataType) { - case FDTYPE_Binary: - assert(def->payloadLen <= sizeof (value)); - switch (def->dispType) { - case FDISP_Binary: - for (i = 0; i < def->payloadLen; i++) - output("%c%c%c%c%c%c%c%c", - ((field[i] & 0x80) ? '1' : '0'), - ((field[i] & 0x40) ? '1' : '0'), - ((field[i] & 0x20) ? '1' : '0'), - ((field[i] & 0x10) ? '1' : '0'), - ((field[i] & 0x08) ? '1' : '0'), - ((field[i] & 0x04) ? '1' : '0'), - ((field[i] & 0x02) ? '1' : '0'), - ((field[i] & 0x01) ? '1' : '0')); - return; - case FDISP_Octal: - case FDISP_Decimal: - value = 0; - valueint = 0; - (void) memcpy((((uint8_t *)&value) + - sizeof (value) - def->payloadLen), - field, def->payloadLen); - if ((value != 0) && - (strcmp(def->name, "SPD_Manufacture_Week") == 0)) { - valueint = (int)value; - if (spd_memtype && spd_revision) { - convertbcdtobinary(&valueint); - spd_memtype = 0; - spd_revision = 0; - } - output("%d", valueint); - return; - } - if ((value != 0) && - ((strcmp(def->name, "Lowest") == 0) || - (strcmp(def->name, "Highest") == 0) || - (strcmp(def->name, "Latest") == 0))) - output((def->dispType == FDISP_Octal) ? - "%llo" : "%lld (%lld degrees C)", - value, (value - TEMPERATURE_OFFSET)); - else - output((def->dispType == FDISP_Octal) ? - "%llo" : "%lld", value); - return; - case FDISP_Time: - if (def->payloadLen > sizeof (timefield)) { - errmsg = "time value too large for formatting"; - break; - } - timefield = 0; - (void) memcpy((((uint8_t *)&timefield) + - sizeof (timefield) - def->payloadLen), - field, def->payloadLen); - if (timefield == 0) { - errmsg = "No Value Recorded"; - break; - } - if ((tm = gmtime(&timefield)) == NULL) { - errmsg = "cannot convert time value"; - break; - } - if (strftime(timestring, sizeof (timestring), GMT, tm) - == 0) { - errmsg = "formatted time would overflow buffer"; - break; - } - safeputs(timestring); - return; - } - break; - case FDTYPE_ASCII: - if (!xml) { - if (strcmp(def->name, "Message") == 0) { - if (FMAmessageR == 0) - elem_name = "FMA_Event_DataR"; - else if (FMAmessageR == 1) - elem_name = "FMA_MessageR"; - if (elem_name != NULL) { - (void) memcpy(data, field, - def->payloadLen); - new_def = - fru_reg_lookup_def_by_name - (elem_name); - (void) snprintf(path, sizeof (path), - "/Status_EventsR[%d]/Message(FMA)", - iterglobal); - parent_path = path; - output("\n"); - print_element(data, new_def, - parent_path, 2*INDENT); - return; - } - } - } - if (strcmp(def->name, "Fru_Path") == 0) { - if (check_utf_char(field, def->payloadLen) == 1) - return; - } - for (i = 0; i < def->payloadLen && field[i]; i++) - safeputchar(field[i]); - return; - case FDTYPE_Enumeration: - value = 0; - (void) memcpy((((uint8_t *)&value) + sizeof (value) - - def->payloadLen), - field, def->payloadLen); - for (i = 0; i < def->enumCount; i++) - if (def->enumTable[i].value == value) { - if (strcmp(def->name, "Event_Code") == 0) { - if (strcmp(def->enumTable[i].text, -"FMA Message R") == 0) - FMAmessageR = 1; - else - if (strcmp(def->enumTable[i].text, -"FMA Event Data R") == 0) - FMAmessageR = 0; - } - if (strcmp(def->name, -"SPD_Fundamental_Memory_Type") == 0) { - if (strcmp(def->enumTable[i].text, -"DDR II SDRAM") == 0) - spd_memtype = 1; - } - safeputs(def->enumTable[i].text); - return; - } - - errmsg = "unrecognized value"; - break; - } - - /* If nothing matched above, print the field in hex */ - switch (def->dispType) { - case FDISP_MSGID: - (void) memcpy((uchar_t *)&first_byte, field, 1); - if (isprint(first_byte)) { - for (i = 0; i < def->payloadLen && field[i]; - i++) - safeputchar(field[i]); - } - break; - case FDISP_UUID: - for (i = 0; i < def->payloadLen; i++) { - if ((i == 4) || (i == 6) || - (i == 8) || (i == 10)) - output("-"); - output("%2.2x", field[i]); - } - break; - default: - if ((strcmp(def->name, "Status") == 0) || - (strcmp(def->name, "Old_Status") == 0) || - (strcmp(def->name, "New_Status") == 0)) { - int status_length = \ - sizeof (Status_CurrentR_status) / \ - sizeof (*(Status_CurrentR_status)); - i = 0; - do { - if (Status_CurrentR_status[i].value == \ - *(field)) - break; - i++; - } while (i < status_length); - if (i < status_length) - output("0x%2.2X (%s)", *(field), - Status_CurrentR_status[i].data); - else - output("0x%2.2X (UNKNOWN)", *(field)); - break; - } - if (strcmp(def->name, - "SPD_Data_Revision_Code") == 0) { - value = 0; - valueint = 0; - (void) memcpy((((uint8_t *)&value) - + sizeof (value) - def->payloadLen), - field, def->payloadLen); - valueint = (int)value; - if ((valueint >= MIN_VERSION) && (spd_memtype)) - spd_revision = 1; - } - for (i = 0; i < def->payloadLen; i++) - output("%2.2X", field[i]); - break; - } - - /* Safely print any error message associated with the field */ - if (errmsg) { - if (strcmp(def->name, "Fault_Diag_Secs") != 0) { - output(" ("); - safeputs(errmsg); - output(")"); - } - } -} - -/* - * Recursively print the contents of a data element - */ -static void -print_element(const uint8_t *data, const fru_regdef_t *def, - const char *parent_path, int indent) -{ - char *path; - size_t len; - - int bytes = 0, i; - - - indent = (xml) ? (indent + INDENT) : (2*INDENT); - if (strcmp(def->name, "Sun_SPD_DataR") == 0) { - Fault_Install_DataR_flag = indent; - Power_On_DataR_flag = indent; - } - /* - * Construct the path, or, for XML, the name, for the current - * data element - */ - if ((def->iterationCount == 0) && - (def->iterationType != FRU_NOT_ITERATED)) { - if (xml) { - if (def->dataType == FDTYPE_Record) { - len = strlen("Index_") + strlen(def->name) + 1; - path = alloca(len); - (void) snprintf(path, len, - "Index_%s", def->name); - } - else - path = "Index"; - } - else - path = (char *)parent_path; - } else { - if (xml) - path = (char *)def->name; - else { - len = strlen(parent_path) + sizeof ("/") + - strlen(def->name) + - (def->iterationCount ? sizeof ("[255]") : 0); - path = alloca(len); - bytes = snprintf(path, len, - "%s/%s", parent_path, def->name); - } - } - - if ((Fault_Install_DataR_flag) && - (strcmp(path, "E_1_46") == 0) || (strcmp(path, "/E_1_46") == 0)) { - int cnt; - char timestring[128]; - time_t timefield = 0; - struct tm *tm; - indent = Fault_Install_DataR_flag; - (void) memcpy((uint8_t *)&timefield, data, 4); - if (timefield == 0) { - (void) sprintf(timestring, - "00000000 (No Value Recorded)\""); - } else { - if ((tm = gmtime(&timefield)) == NULL) - (void) sprintf(timestring, - "cannot convert time value"); - if (strftime(timestring, - sizeof (timestring), GMT, tm) == 0) - (void) sprintf(timestring, - "formatted time would overflow buffer"); - } - if (xml) { - (void) sprintf(path, "Fault_Install_DataR"); - output("%*s<%s>\n", indent, "", path); - indent = Fault_Install_DataR_flag + INDENT; - (void) sprintf(path, "UNIX_Timestamp32"); - output("%*s<%s value=\"", indent, "", path); - /*CSTYLED*/ - output("%s\"/>\n", timestring); - (void) sprintf(path, "MACADDR"); - output("%*s<%s value=\"", indent, "", path); - for (cnt = 4; cnt < 4 + 6; cnt++) { - output("%2.2x", data[cnt]); - if (cnt < 4 + 6 - 1) - output(":"); - } - /*CSTYLED*/ - output("\"/>\n"); - (void) sprintf(path, "Status"); - output("%*s<%s value=\"", indent, "", path); - /*CSTYLED*/ - output("%2.2x\"/>\n", data[10]); - (void) sprintf(path, "Initiator"); - output("%*s<%s value=\"", indent, "", path); - /*CSTYLED*/ - output("%2.2x\"/>\n", data[11]); - (void) sprintf(path, "Message_Type"); - output("%*s<%s value=\"", indent, "", path); - /*CSTYLED*/ - output("%2.2x\"/>\n", data[12]); - (void) sprintf(path, "Message_32"); - output("%*s<%s value=\"", indent, "", path); - for (cnt = 13; cnt < 13 + 32; cnt++) - output("%2.2x", data[cnt]); - /*CSTYLED*/ - output("\"/>\n"); - indent = Fault_Install_DataR_flag; - (void) sprintf(path, "Fault_Install_DataR"); - output("%*s\n", indent, "", path); - } else { - (void) sprintf(path, "/Fault_Install_DataR"); - output("%*s%s\n", indent, "", path); - (void) sprintf(path, - "/Fault_Install_DataR/UNIX_Timestamp32"); - output("%*s%s: ", indent, "", path); - output("%s\n", timestring); - (void) sprintf(path, "/Fault_Install_DataR/MACADDR"); - output("%*s%s: ", indent, "", path); - for (cnt = 4; cnt < 4 + 6; cnt++) { - output("%2.2x", data[cnt]); - if (cnt < 4 + 6 - 1) - output(":"); - } - output("\n"); - (void) sprintf(path, "/Fault_Install_DataR/Status"); - output("%*s%s: ", indent, "", path); - output("%2.2x\n", data[10]); - (void) sprintf(path, "/Fault_Install_DataR/Initiator"); - output("%*s%s: ", indent, "", path); - output("%2.2x\n", data[11]); - (void) sprintf(path, - "/Fault_Install_DataR/Message_Type"); - output("%*s%s: ", indent, "", path); - output("%2.2x\n", data[12]); - (void) sprintf(path, "/Fault_Install_DataR/Message_32"); - output("%*s%s: ", indent, "", path); - for (cnt = 13; cnt < 13 + 32; cnt++) - output("%2.2x", data[cnt]); - output("\n"); - } - Fault_Install_DataR_flag = 0; - return; - } else if ((Power_On_DataR_flag) && ( - strcmp(path, "C_10_8") == 0 || - (strcmp(path, "/C_10_8") == 0))) { - int cnt; - char timestring[128]; - time_t timefield = 0; - struct tm *tm; - indent = Power_On_DataR_flag; - (void) memcpy((uint8_t *)&timefield, data, 4); - if (timefield == 0) { - (void) sprintf(timestring, - "00000000 (No Value Recorded)"); - } else { - if ((tm = gmtime(&timefield)) == NULL) - (void) sprintf(timestring, - "cannot convert time value"); - if (strftime(timestring, - sizeof (timestring), GMT, tm) == 0) - (void) sprintf(timestring, - "formatted time would overflow buffer"); - } - if (xml) { - (void) sprintf(path, "Power_On_DataR"); - output("%*s<%s>\n", indent, "", path); - indent = Power_On_DataR_flag + INDENT; - (void) sprintf(path, "UNIX_Timestamp32"); - output("%*s<%s value=\"", indent, "", path); - /*CSTYLED*/ - output("%s\"/>\n", timestring); - (void) sprintf(path, "Power_On_Minutes"); - output("%*s<%s value=\"", indent, "", path); - for (cnt = 4; cnt < 4 + 4; cnt++) - output("%2.2x", data[cnt]); - /*CSTYLED*/ - output("\"/>\n"); - indent = Power_On_DataR_flag; - (void) sprintf(path, "Power_On_DataR"); - output("%*s\n", indent, "", path); - } else { - (void) sprintf(path, "/Power_On_DataR"); - output("%*s%s\n", indent, "", path); - (void) sprintf(path, - "/Power_On_DataR/UNIX_Timestamp32"); - output("%*s%s: ", indent, "", path); - output("%s\n", timestring); - (void) sprintf(path, - "/Power_On_DataR/Power_On_Minutes"); - output("%*s%s: ", indent, "", path); - for (cnt = 4; cnt < 4 + 4; cnt++) - output("%2.2x", data[cnt]); - output("\n"); - } - Power_On_DataR_flag = 0; - return; - } - /* - * Handle the various categories of data elements: iteration, - * record, and field - */ - if (def->iterationCount) { - int iterlen = (def->payloadLen - NUM_ITER_BYTES)/ - def->iterationCount, - n, valid = 1; - - uint8_t head, num; - - fru_regdef_t newdef; - - - /* - * Make a new element definition to describe the components - * of the iteration - */ - (void) memcpy(&newdef, def, sizeof (newdef)); - newdef.iterationCount = 0; - newdef.payloadLen = iterlen; - - /* - * Validate the contents of the iteration control bytes - */ - if (data[HEAD_ITER] >= def->iterationCount) { - valid = 0; - error(gettext("%s: Invalid iteration head: %d " - "(should be less than %d)\n"), - path, data[HEAD_ITER], def->iterationCount); - } - - if (data[NUM_ITER] > def->iterationCount) { - valid = 0; - error(gettext("%s: Invalid iteration count: %d " - "(should not be greater than %d)\n"), - path, data[NUM_ITER], def->iterationCount); - } - - if (data[MAX_ITER] != def->iterationCount) { - valid = 0; - error(gettext("%s: Invalid iteration maximum: %d " - "(should equal %d)\n"), - path, data[MAX_ITER], def->iterationCount); - } - - if (valid) { - head = data[HEAD_ITER]; - num = data[NUM_ITER]; - } else { - head = 0; - num = def->iterationCount; - error(gettext("%s: Showing all iterations\n"), path); - } - - if (xml) - output("%*s<%s>\n", indent, "", path); - else - output("%*s%s (%d iterations)\n", indent, "", path, - num); - - /* - * Print each component of the iteration - */ - for (i = head, n = 0, data += 4; - n < num; - i = ((i + 1) % def->iterationCount), n++) { - if (!xml) (void) sprintf((path + bytes), "[%d]", n); - iterglobal = n; - print_element((data + i*iterlen), &newdef, path, - indent); - } - - if (xml) output("%*s\n", indent, "", path); - - } else if (def->dataType == FDTYPE_Record) { - const fru_regdef_t *component; - - if (xml) - output("%*s<%s>\n", indent, "", path); - else - output("%*s%s\n", indent, "", path); - - /* - * Print each component of the record - */ - for (i = 0; i < def->enumCount; - i++, data += component->payloadLen) { - component = fru_reg_lookup_def_by_name( - def->enumTable[i].text); - assert(component != NULL); - print_element(data, component, path, indent); - } - - if (xml) output("%*s\n", indent, "", path); - } else if (xml) { - /* - * Base case: print the field formatted for XML - */ - char *format = ((def == &unknown) - ? "%*s\n"); /* \" confuses cstyle */ - - if ((strcmp(def->name, "Message") == 0) && - ((FMAmessageR == 0) || (FMAmessageR == 1))) { - const char *elem_name = NULL; - const char *parent_path; - uchar_t tmpdata[128]; - char path[16384]; - const fru_regdef_t *new_def; - - if (FMAmessageR == 0) - elem_name = "FMA_Event_DataR"; - else if (FMAmessageR == 1) - elem_name = "FMA_MessageR"; - if (elem_name != NULL) { - (void) memcpy(tmpdata, data, def->payloadLen); - new_def = fru_reg_lookup_def_by_name(elem_name); - (void) snprintf(path, sizeof (path), - "/Status_EventsR[%d]/Message(FMA)", iterglobal); - parent_path = path; - print_element(tmpdata, new_def, - parent_path, 2*INDENT); - FMAmessageR = -1; - } - } - - } else { - /* - * Base case: print the field - */ - output("%*s%s: ", indent, "", path); - print_field(data, def); - output("\n"); - } -} - -/* - * Print the contents of a packet (i.e., a tagged data element) - */ -/* ARGSUSED */ -static int -print_packet(fru_tag_t *tag, uint8_t *payload, size_t length, void *args) -{ - int tag_type = get_tag_type(tag); - - size_t payload_length = 0; - - const fru_regdef_t *def; - - /* - * Build a definition for unrecognized tags (e.g., not in libfrureg) - */ - if ((tag_type == -1) || - ((payload_length = get_payload_length(tag)) != length)) { - def = &unknown; - - unknown.tagType = -1; - unknown.tagDense = -1; - unknown.payloadLen = length; - unknown.dataLength = unknown.payloadLen; - - if (tag_type == -1) - (void) snprintf(tagname, sizeof (tagname), "INVALID"); - else - (void) snprintf(tagname, sizeof (tagname), - "%s_%u_%u_%u", get_tagtype_str(tag_type), - get_tag_dense(tag), payload_length, length); - } else if ((def = fru_reg_lookup_def_by_tag(*tag)) == NULL) { - def = &unknown; - - unknown.tagType = tag_type; - unknown.tagDense = get_tag_dense(tag); - unknown.payloadLen = payload_length; - unknown.dataLength = unknown.payloadLen; - - (void) snprintf(tagname, sizeof (tagname), "%s_%u_%u", - get_tagtype_str(unknown.tagType), - unknown.tagDense, payload_length); - } - - - /* - * Print the defined element - */ - print_element(payload, def, "", INDENT); - - return (FRU_SUCCESS); -} - -/* - * Print a segment's name and the contents of each data element in the segment - */ -static int -print_packets_in_segment(fru_seghdl_t segment, void *args) -{ - char *name; - - int status; - - - if ((status = fru_get_segment_name(segment, &name)) != FRU_SUCCESS) { - saved_status = status; - name = ""; - error(gettext("Error getting segment name: %s\n"), - fru_strerror(status)); - } - - - if (xml) - output("%*s\n", INDENT, "", name); - else - output("%*sSEGMENT: %s\n", INDENT, "", name); - - if (strcmp(name, "ED") == 0) { - if (xml) output("%*s\n", INDENT, ""); - free(name); - return (FRU_SUCCESS); - } - /* Iterate over the packets in the segment, printing the contents */ - if ((status = fru_for_each_packet(segment, print_packet, args)) - != FRU_SUCCESS) { - saved_status = status; - error(gettext("Error processing data in segment \"%s\": %s\n"), - name, fru_strerror(status)); - } - - if (xml) output("%*s\n", INDENT, ""); - - free(name); - - return (FRU_SUCCESS); -} - -/* ARGSUSED */ -static void -print_node_path(fru_node_t fru_type, const char *path, const char *name, - end_node_fp_t *end_node, void **end_args) -{ - output("%s%s\n", path, - ((fru_type == FRU_NODE_CONTAINER) ? " (container)" - : ((fru_type == FRU_NODE_FRU) ? " (fru)" : ""))); -} - -/* - * Close the XML element for a "location" node - */ -/* ARGSUSED */ -static void -end_location_xml(fru_nodehdl_t node, const char *path, const char *name, - void *args) -{ - assert(args != NULL); - output(" \n", args); -} - -/* - * Close the XML element for a "fru" node - */ -/* ARGSUSED */ -static void -end_fru_xml(fru_nodehdl_t node, const char *path, const char *name, void *args) -{ - assert(args != NULL); - output(" \n", args); -} - -/* - * Close the XML element for a "container" node - */ -/* ARGSUSED */ -static void -end_container_xml(fru_nodehdl_t node, const char *path, const char *name, - void *args) -{ - assert(args != NULL); - output(" \n", args); -} - -/* - * Introduce a node in XML and set the appropriate node-closing function - */ -/* ARGSUSED */ -static void -print_node_xml(fru_node_t fru_type, const char *path, const char *name, - end_node_fp_t *end_node, void **end_args) -{ - switch (fru_type) { - case FRU_NODE_FRU: - output("\n", name); - *end_node = end_fru_xml; - break; - case FRU_NODE_CONTAINER: - output("\n", name); - *end_node = end_container_xml; - break; - default: - output("\n", name); - *end_node = end_location_xml; - break; - } - - *end_args = (void *) name; -} - -/* - * Print node info and, where appropriate, node contents - */ -/* ARGSUSED */ -static fru_errno_t -process_node(fru_nodehdl_t node, const char *path, const char *name, - void *args, end_node_fp_t *end_node, void **end_args) -{ - int status; - - fru_node_t fru_type = FRU_NODE_UNKNOWN; - - - if ((status = fru_get_node_type(node, &fru_type)) != FRU_SUCCESS) { - saved_status = status; - error(gettext("Error getting node type: %s\n"), - fru_strerror(status)); - } - - if (containers_only) { - if (fru_type != FRU_NODE_CONTAINER) - return (FRU_SUCCESS); - name = path; - } - - /* Introduce the node */ - assert(print_node != NULL); - print_node(fru_type, path, name, end_node, end_args); - - if (list_only) - return (FRU_SUCCESS); - - /* Print the contents of each packet in each segment of a container */ - if (fru_type == FRU_NODE_CONTAINER) { - if (xml) output("\n"); - if ((status = - fru_for_each_segment(node, print_packets_in_segment, - NULL)) - != FRU_SUCCESS) { - saved_status = status; - error(gettext("Error processing node \"%s\": %s\n"), - name, fru_strerror(status)); - } - if (xml) output("\n"); - } - - return (FRU_SUCCESS); -} - -/* - * Process the node if its path matches the search path in "args" - */ -/* ARGSUSED */ -static fru_errno_t -process_matching_node(fru_nodehdl_t node, const char *path, const char *name, - void *args, end_node_fp_t *end_node, void **end_args) - { - int status; - - - if (!fru_pathmatch(path, args)) - return (FRU_SUCCESS); - - status = process_node(node, path, path, args, end_node, end_args); - - return ((status == FRU_SUCCESS) ? FRU_WALK_TERMINATE : status); -} - -/* - * Write the trailer required for well-formed DTD-compliant XML - */ -static void -terminate_xml() -{ - errno = 0; - if (ftell(errlog) > 0) { - char c; - - output("\n"); - rewind(errlog); - if (!errno) - while ((c = getc(errlog)) != EOF) - xputchar(c); - output("\n"); - } - - if (errno) { - /*NOTREACHED*/ - errlog = NULL; - error(gettext("Error copying error messages to \"ErrorLog\""), - strerror(errno)); - } - - output("\n"); -} - -/* - * Print available FRU ID information - */ -int -prtfru(const char *searchpath, int containers_only_flag, int list_only_flag, - int xml_flag) -{ - fru_errno_t status; - - fru_nodehdl_t frutree = 0; - - - /* Copy parameter flags to global flags */ - containers_only = containers_only_flag; - list_only = list_only_flag; - xml = xml_flag; - - - /* Help arrange for correct, efficient interleaving of output */ - (void) setvbuf(stderr, NULL, _IOLBF, 0); - - - /* Initialize for XML--or not */ - if (xml) { - safeputchar = xputchar; - safeputs = xputs; - - print_node = print_node_xml; - - if ((errlog = tmpfile()) == NULL) { - (void) fprintf(stderr, - "Error creating error log file: %s\n", - strerror(errno)); - return (1); - } - - /* Output the XML preamble */ - output("\n" - "\n\n" - "\n\n" - "\n"); - - /* Arrange to always properly terminate XML */ - if (atexit(terminate_xml)) - error(gettext("Warning: XML will not be terminated: " - "%s\n"), strerror(errno)); - } else - print_node = print_node_path; - - - /* Get the root node */ - if ((status = fru_get_root(&frutree)) == FRU_NODENOTFOUND) { - error(gettext("This system does not support PICL " - "infrastructure to provide FRUID data\n" - "Please use the platform SP to access the FRUID " - "information\n")); - return (1); - } else if (status != FRU_SUCCESS) { - error(gettext("Unable to access FRU ID data: %s\n"), - fru_strerror(status)); - return (1); - } - - /* Process the tree */ - if (searchpath == NULL) { - status = fru_walk_tree(frutree, "", process_node, NULL); - } else { - status = fru_walk_tree(frutree, "", process_matching_node, - (void *)searchpath); - if (status == FRU_WALK_TERMINATE) { - status = FRU_SUCCESS; - } else if (status == FRU_SUCCESS) { - error(gettext("\"%s\" not found\n"), searchpath); - return (1); - } - } - - if (status != FRU_SUCCESS) - error(gettext("Error processing FRU tree: %s\n"), - fru_strerror(status)); - - return (((status == FRU_SUCCESS) && (saved_status == 0)) ? 0 : 1); -} diff --git a/usr/src/cmd/prtfru/prtfru.h b/usr/src/cmd/prtfru/prtfru.h deleted file mode 100644 index ec44a79ed9..0000000000 --- a/usr/src/cmd/prtfru/prtfru.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (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 - * or http://www.opensolaris.org/os/licensing. - * 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 2002 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _PRTFRU_H -#define _PRTFRU_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -int output_dtd(void); - -int prtfru(const char *searchpath, int containers_only, int list_only, - int xml); - -#ifdef __cplusplus -} -#endif - -#endif /* _PRTFRU_H */ diff --git a/usr/src/pkg/manifests/system-fru-id-platform.mf b/usr/src/pkg/manifests/system-fru-id-platform.mf index c755cdc138..1827f1a1d8 100644 --- a/usr/src/pkg/manifests/system-fru-id-platform.mf +++ b/usr/src/pkg/manifests/system-fru-id-platform.mf @@ -34,8 +34,6 @@ dir path=usr group=sys dir path=usr/lib dir path=usr/lib/picl group=sys dir path=usr/lib/picl/plugins group=sys -dir path=usr/share/man/man8 file path=usr/lib/picl/plugins/fru_container.conf group=sys -file path=usr/share/man/man8/fruadm.8 license cr_Sun license=cr_Sun license lic_CDDL license=lic_CDDL diff --git a/usr/src/pkg/manifests/system-fru-id.mf b/usr/src/pkg/manifests/system-fru-id.mf index 1a9d7c30cc..be28f2246f 100644 --- a/usr/src/pkg/manifests/system-fru-id.mf +++ b/usr/src/pkg/manifests/system-fru-id.mf @@ -24,7 +24,7 @@ # set name=pkg.fmri value=pkg:/system/fru-id@$(PKGVERS) -set name=pkg.description value="FRU ID prtfru command and libfru library" +set name=pkg.description value="FRU ID libfru library" set name=pkg.summary value="FRU ID Utility and Library" set name=info.classification \ value="org.opensolaris.category.2008:System/Administration and Configuration" @@ -32,7 +32,6 @@ set name=variant.arch value=$(ARCH) dir path=usr group=sys dir path=usr/lib dir path=usr/lib/$(ARCH64) -dir path=usr/share/man/man8 file path=usr/lib/$(ARCH64)/libfru.so.1 file path=usr/lib/$(ARCH64)/libfruraw.so.1 file path=usr/lib/$(ARCH64)/libfrureg.so.1 @@ -43,7 +42,6 @@ file path=usr/lib/libfruraw.so.1 file path=usr/lib/libfrureg.so.1 file path=usr/lib/libfruutils.so.1 file path=usr/lib/libnvfru.so.1 -file path=usr/share/man/man8/prtfru.8 license cr_Sun license=cr_Sun license lic_CDDL license=lic_CDDL link path=usr/lib/$(ARCH64)/libfru.so target=./libfru.so.1 -- 2.11.4.GIT