diff options
author | kmohan <none@none> | 2005-12-15 10:33:57 -0800 |
---|---|---|
committer | kmohan <none@none> | 2005-12-15 10:33:57 -0800 |
commit | 35551380472894a564e057962b701af78f719377 (patch) | |
tree | 463a704dede02307f7d39e136c85927078fe3024 /usr/src/lib/libfru | |
parent | a5be7ebb94dde0271db3c498c22a4b6afdb72af3 (diff) | |
download | illumos-joyent-35551380472894a564e057962b701af78f719377.tar.gz |
6325788 Error processing FRU tree: IO error
Diffstat (limited to 'usr/src/lib/libfru')
-rw-r--r-- | usr/src/lib/libfru/include/libfru.h | 3 | ||||
-rw-r--r-- | usr/src/lib/libfru/libfru/libfru.cc | 193 | ||||
-rw-r--r-- | usr/src/lib/libfru/libfrupicl/frupicl.c | 86 | ||||
-rw-r--r-- | usr/src/lib/libfru/libfrupicltree/frupicltree.c | 88 |
4 files changed, 197 insertions, 173 deletions
diff --git a/usr/src/lib/libfru/include/libfru.h b/usr/src/lib/libfru/include/libfru.h index 2f281b2332..756e22dfbc 100644 --- a/usr/src/lib/libfru/include/libfru.h +++ b/usr/src/lib/libfru/include/libfru.h @@ -62,7 +62,8 @@ typedef enum FRU_SEGCORRUPT, FRU_DATACORRUPT, FRU_FAILURE, - FRU_WALK_TERMINATE + FRU_WALK_TERMINATE, + FRU_NORESPONSE } fru_errno_t; diff --git a/usr/src/lib/libfru/libfru/libfru.cc b/usr/src/lib/libfru/libfru/libfru.cc index 94bd09cc68..0abb0a94ff 100644 --- a/usr/src/lib/libfru/libfru/libfru.cc +++ b/usr/src/lib/libfru/libfru/libfru.cc @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -109,6 +109,13 @@ static void *ds_lib = NULL; static int ds_lib_ref_cnt = 0; static char *ds_lib_name = NULL; +#define FRU_NORESPONSE_RETRY 500 + +#define RETRY(expr) \ + { for (int loop = 0; loop < FRU_NORESPONSE_RETRY && \ + (expr) == FRU_NORESPONSE; loop++) ; \ + } + /* ========================================================================= */ static const char *fru_errmsg[] = { @@ -135,6 +142,7 @@ static const char *fru_errmsg[] = "Data Corrupt", "General LIBFRU FAILURE", "Walk terminated", + "FRU No response", "Unknown error" }; @@ -420,14 +428,17 @@ fru_close_data_source(void) int segment_is_encrypted(fru_nodehdl_t container, const char *seg_name) { - fru_errno_t tmp; + fru_errno_t err = FRU_SUCCESS; fru_segdef_t segdef; if (data_source == NULL) { return (0); } - if (data_source->get_seg_def(NODEHDL_TO_TREEHDL(container), - seg_name, &segdef) != FRU_SUCCESS) { + + RETRY(err = data_source->get_seg_def(NODEHDL_TO_TREEHDL(container), + seg_name, &segdef)) + + if (err != FRU_SUCCESS) { return (0); } @@ -445,8 +456,10 @@ get_seg_list_from_ds(fru_nodehdl_t node, fru_strlist_t *list) } /* get a list of all segments */ - if ((err = data_source->get_seg_list(NODEHDL_TO_TREEHDL(node), - &raw_list)) != FRU_SUCCESS) { + RETRY(err = data_source->get_seg_list(NODEHDL_TO_TREEHDL(node), + &raw_list)) + + if (err != FRU_SUCCESS) { return (err); } @@ -497,7 +510,7 @@ fru_get_root(fru_nodehdl_t *handle) return (FRU_FAILURE); } - err = data_source->get_root(&tr_root); + RETRY(err = data_source->get_root(&tr_root)) if (err == FRU_SUCCESS) { *handle = TREEHDL_TO_NODEHDL(tr_root); } @@ -511,16 +524,19 @@ fru_get_child(fru_nodehdl_t handle, fru_nodehdl_t *child) fru_errno_t err = FRU_SUCCESS; fru_treehdl_t tr_child; fru_node_t type; - if (data_source == NULL) { return (FRU_FAILURE); } - if ((err = data_source->get_child(NODEHDL_TO_TREEHDL(handle), - &tr_child)) != FRU_SUCCESS) { + + RETRY(err = data_source->get_child(NODEHDL_TO_TREEHDL(handle), + &tr_child)) + if (err != FRU_SUCCESS) { return (err); } - if ((err = data_source->get_node_type(tr_child, &type)) - != FRU_SUCCESS) { + + RETRY(err = data_source->get_node_type(tr_child, &type)) + + if (err != FRU_SUCCESS) { return (err); } if ((type == FRU_NODE_LOCATION) || @@ -535,12 +551,13 @@ fru_get_child(fru_nodehdl_t handle, fru_nodehdl_t *child) * valid */ do { - if ((err = data_source->get_peer(tr_child, - &tr_child)) != FRU_SUCCESS) { + RETRY(err = data_source->get_peer(tr_child, &tr_child)) + if (err != FRU_SUCCESS) { return (err); } - if ((err = data_source->get_node_type(tr_child, &type)) - != FRU_SUCCESS) { + + RETRY(err = data_source->get_node_type(tr_child, &type)) + if (err != FRU_SUCCESS) { return (err); } if ((type == FRU_NODE_LOCATION) || @@ -565,12 +582,14 @@ fru_get_peer(fru_nodehdl_t handle, fru_nodehdl_t *peer) } do { - if ((err = data_source->get_peer(tr_peer, &tr_peer)) - != FRU_SUCCESS) { + RETRY(err = data_source->get_peer(tr_peer, &tr_peer)) + + if (err != FRU_SUCCESS) { return (err); } - if ((err = data_source->get_node_type(tr_peer, &type)) - != FRU_SUCCESS) { + + RETRY(err = data_source->get_node_type(tr_peer, &type)) + if (err != FRU_SUCCESS) { return (err); } if ((type == FRU_NODE_LOCATION) || @@ -590,7 +609,9 @@ fru_get_parent(fru_nodehdl_t handle, fru_nodehdl_t *parent) if (data_source == NULL) { return (FRU_FAILURE); } - err = data_source->get_parent(NODEHDL_TO_TREEHDL(handle), &tr_parent); + + RETRY(err = data_source->get_parent(NODEHDL_TO_TREEHDL(handle), + &tr_parent)) if (err == FRU_SUCCESS) { *parent = TREEHDL_TO_NODEHDL(tr_parent); } @@ -602,11 +623,15 @@ fru_get_parent(fru_nodehdl_t handle, fru_nodehdl_t *parent) fru_errno_t fru_get_name_from_hdl(fru_nodehdl_t handle, char **name) { + fru_errno_t err = FRU_SUCCESS; + if (data_source == NULL) { return (FRU_FAILURE); } - return (data_source->get_name_from_hdl(NODEHDL_TO_TREEHDL(handle), - name)); + + RETRY(err = data_source->get_name_from_hdl(NODEHDL_TO_TREEHDL(handle), + name)) + return (err); } /* ========================================================================= */ @@ -717,12 +742,13 @@ fru_get_node_type(fru_nodehdl_t handle, fru_node_t *type) if (data_source == NULL) { return (FRU_FAILURE); } - if ((err = data_source->get_node_type(NODEHDL_TO_TREEHDL(handle), - &tmp)) != FRU_SUCCESS) { - return (err); + + RETRY(err = data_source->get_node_type(NODEHDL_TO_TREEHDL(handle), + &tmp)) + if (err == FRU_SUCCESS) { + *type = tmp; } - *type = tmp; - return (FRU_SUCCESS); + return (err); } /* ========================================================================= */ @@ -844,8 +870,9 @@ fru_create_segment(fru_nodehdl_t container, fru_segdef_t *def) /* get a list of all segments */ /* here we do not want to leave out the encrypted segments. */ - if ((err = data_source->get_seg_list(NODEHDL_TO_TREEHDL(container), - &seg_list)) != FRU_SUCCESS) { + RETRY(err = data_source->get_seg_list(NODEHDL_TO_TREEHDL(container), + &seg_list)) + if (err != FRU_SUCCESS) { CHK_UNLOCK_CONTAINER(container); return (err); } @@ -860,7 +887,8 @@ fru_create_segment(fru_nodehdl_t container, fru_segdef_t *def) } fru_destroy_strlist(&seg_list); - err = data_source->add_seg(NODEHDL_TO_TREEHDL(container), def); + RETRY(err = data_source->add_seg(NODEHDL_TO_TREEHDL(container), def)) + CHK_UNLOCK_CONTAINER(container); return (err); } @@ -892,8 +920,9 @@ fru_remove_segment(fru_nodehdl_t container, const char *seg_name) (fru_encryption_supported() == FRU_NOTSUP)) { err = FRU_INVALSEG; } else { - err = data_source->delete_seg(NODEHDL_TO_TREEHDL(container), - seg_name); + RETRY(err = + data_source->delete_seg(NODEHDL_TO_TREEHDL(container), + seg_name)) } CHK_UNLOCK_CONTAINER(container); @@ -925,8 +954,11 @@ fru_get_segment_def(fru_nodehdl_t container, const char *seg_name, // NOTE: not passing "definition" to this function such that I may // check for encryption before allowing the user to get the data. fru_segdef_t segdef; - if ((err = data_source->get_seg_def(NODEHDL_TO_TREEHDL(container), - seg_name, &segdef)) != FRU_SUCCESS) { + + RETRY(err = data_source->get_seg_def(NODEHDL_TO_TREEHDL(container), + seg_name, &segdef)) + + if (err != FRU_SUCCESS) { CHK_UNLOCK_CONTAINER(container); return (err); } @@ -982,9 +1014,9 @@ fru_list_elems_in(fru_nodehdl_t container, const char *seg_name, return (FRU_INVALSEG); } - if ((err = data_source->get_tag_list(NODEHDL_TO_TREEHDL(container), - seg_name, &tags, &num_tags)) - != FRU_SUCCESS) { + RETRY(err = data_source->get_tag_list(NODEHDL_TO_TREEHDL(container), + seg_name, &tags, &num_tags)) + if (err != FRU_SUCCESS) { CHK_UNLOCK_CONTAINER(container); return (err); } @@ -1052,10 +1084,9 @@ fru_for_each_segment(fru_nodehdl_t container, if (lock_container(READ_LOCK, container) != FRU_SUCCESS) { return (FRU_FAILURE); } - - status = data_source->for_each_segment(NODEHDL_TO_TREEHDL(container), - function, args); - + RETRY(status = + data_source->for_each_segment(NODEHDL_TO_TREEHDL(container), + function, args)) CHK_UNLOCK_CONTAINER(container); return (status); } @@ -1071,9 +1102,13 @@ fru_for_each_segment(fru_nodehdl_t container, fru_errno_t fru_get_segment_name(fru_seghdl_t segment, char **name) { + fru_errno_t err = FRU_SUCCESS; + assert(data_source != NULL); - return (data_source->get_segment_name(NODEHDL_TO_TREEHDL(segment), - name)); + + RETRY(err = data_source->get_segment_name(NODEHDL_TO_TREEHDL(segment), + name)) + return (err); } /* ========================================================================= */ @@ -1090,9 +1125,13 @@ fru_for_each_packet(fru_seghdl_t segment, size_t length, void *args), void *args) { + fru_errno_t err = FRU_SUCCESS; + assert(data_source != NULL); - return (data_source->for_each_packet(NODEHDL_TO_TREEHDL(segment), - function, args)); + + RETRY(err = data_source->for_each_packet(NODEHDL_TO_TREEHDL(segment), + function, args)) + return (err); } @@ -1391,9 +1430,9 @@ static fru_errno_t get_payload(fru_nodehdl_t container, if (data_source == NULL) { return (FRU_FAILURE); } - if ((err = data_source->get_tag_list(NODEHDL_TO_TREEHDL(container), - seg_name, &tags, &num_tags)) - != FRU_SUCCESS) { + RETRY(err = data_source->get_tag_list(NODEHDL_TO_TREEHDL(container), + seg_name, &tags, &num_tags)) + if (err != FRU_SUCCESS) { return (err); } @@ -1416,10 +1455,10 @@ static fru_errno_t get_payload(fru_nodehdl_t container, free(tags); return (err); } - - err = data_source->get_tag_data(NODEHDL_TO_TREEHDL(container), - seg_name, tagToRead, unknown_inst, - payload, payloadLen); + RETRY(err = + data_source->get_tag_data(NODEHDL_TO_TREEHDL(container), + seg_name, tagToRead, unknown_inst, payload, + payloadLen)) free(tags); return (err); } @@ -1472,20 +1511,15 @@ static fru_errno_t get_payload(fru_nodehdl_t container, // if we get here this means the instance number within the payload. *instLeft = instance; - - if ((err = data_source->get_tag_data(NODEHDL_TO_TREEHDL(container), - seg_name, (*correct)->getTag(), - (*tagInstance), - payload, payloadLen)) - != FRU_SUCCESS) { - free(tags); + RETRY(err = data_source->get_tag_data(NODEHDL_TO_TREEHDL(container), + seg_name, (*correct)->getTag(), (*tagInstance), payload, + payloadLen)) + free(tags); + if (err != FRU_SUCCESS) { delete *ancestors; // linked list delete *pathDef; - return (err); } - - free(tags); - return (FRU_SUCCESS); + return (err); } /* ========================================================================= */ @@ -1735,11 +1769,9 @@ fru_update_field(fru_nodehdl_t container, } } - err = data_source->set_tag_data(NODEHDL_TO_TREEHDL(container), - seg_name, - correctAnt->getTag(), tagInstance, - payload, payloadLen); - + RETRY(err = data_source->set_tag_data(NODEHDL_TO_TREEHDL(container), + seg_name, correctAnt->getTag(), + tagInstance, payload, payloadLen)) CHK_UNLOCK_CONTAINER(container); delete ancestors; // linked list. free(payload); @@ -1914,11 +1946,9 @@ fru_add_element(fru_nodehdl_t container, return (err); } } - - err = data_source->add_tag_to_seg(NODEHDL_TO_TREEHDL(container), - seg_name, tag, - data, def->payloadLen); - + + RETRY(err = data_source->add_tag_to_seg(NODEHDL_TO_TREEHDL(container), + seg_name, tag, data, def->payloadLen)) CHK_UNLOCK_CONTAINER(container); delete[] data; return (err); @@ -1964,10 +1994,11 @@ fru_delete_element(fru_nodehdl_t container, fru_tag_t *tags = NULL; int num_tags = 0; - if ((err = data_source->get_tag_list( - NODEHDL_TO_TREEHDL(container), - seg_name, &tags, &num_tags)) - != FRU_SUCCESS) { + RETRY(err = + data_source->get_tag_list(NODEHDL_TO_TREEHDL(container), + seg_name, &tags, &num_tags)) + + if (err != FRU_SUCCESS) { CHK_UNLOCK_CONTAINER(container); return (err); } @@ -1991,9 +2022,9 @@ fru_delete_element(fru_nodehdl_t container, } mk_tag(def->tagType, def->tagDense, def->payloadLen, &tag); } - - err = data_source->delete_tag(NODEHDL_TO_TREEHDL(container), seg_name, - tag, instance); + + RETRY(err = data_source->delete_tag(NODEHDL_TO_TREEHDL(container), + seg_name, tag, instance)) CHK_UNLOCK_CONTAINER(container); return (err); } diff --git a/usr/src/lib/libfru/libfrupicl/frupicl.c b/usr/src/lib/libfru/libfrupicl/frupicl.c index 1814a35eb0..9d1263d358 100644 --- a/usr/src/lib/libfru/libfrupicl/frupicl.c +++ b/usr/src/lib/libfru/libfrupicl/frupicl.c @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 2000-2002 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -65,6 +65,12 @@ map_plugin_err(int picl_err) return (FRU_DUPSEG); case PICL_NOSPACE: return (FRU_NOSPACE); + case PICL_NORESPONSE: + return (FRU_NORESPONSE); + case PICL_PROPNOTFOUND: + return (FRU_NODENOTFOUND); + case PICL_ENDOFLIST: + return (FRU_DATANOTFOUND); } return (FRU_IOERROR); } @@ -134,7 +140,7 @@ fpt_get_name_from_hdl(fru_treehdl_t node, char **name) /* get the name */ if ((picl_err = get_strprop_by_name(handle, PICL_PROP_NAME, &tmp_name)) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } /* get the label, if any */ @@ -142,7 +148,7 @@ fpt_get_name_from_hdl(fru_treehdl_t node, char **name) &label)) != PICL_SUCCESS) { if (picl_err != PICL_PROPNOTFOUND) { free(tmp_name); - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } /* else PICL_PROPNOTFOUND is OK because not all nodes */ /* will have a label. */ @@ -226,7 +232,7 @@ fpt_get_root(fru_treehdl_t *node) if ((picl_err = picl_get_propval_by_name(picl_node, PICL_PROP_CHILD, (void *)&picl_node, sizeof (picl_node))) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } while (cmp_node_name(picl_node, PICL_NODE_FRUTREE) @@ -237,7 +243,7 @@ fpt_get_root(fru_treehdl_t *node) sizeof (picl_node))) == PICL_PROPNOTFOUND) { return (FRU_NODENOTFOUND); } else if (picl_err != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } } @@ -257,10 +263,7 @@ fpt_get_peer(fru_treehdl_t sibling, fru_treehdl_t *peer) rc = picl_get_propval_by_name(handle, PICL_PROP_PEER, (void *)&picl_peer, sizeof (picl_peer)); if (rc != PICL_SUCCESS) { - if (rc == PICL_PROPNOTFOUND) - return (FRU_NODENOTFOUND); - else - return (FRU_IOERROR); + return (map_plugin_err(rc)); } *peer = PICLHDL_TO_TREEHDL(picl_peer); @@ -275,10 +278,7 @@ fpt_get_child(fru_treehdl_t handle, fru_treehdl_t *child) int rc = picl_get_propval_by_name(TREEHDL_TO_PICLHDL(handle), PICL_PROP_CHILD, (void *)&p_child, sizeof (p_child)); if (rc != PICL_SUCCESS) { - if (rc == PICL_PROPNOTFOUND) - return (FRU_NODENOTFOUND); - else - return (FRU_IOERROR); + return (map_plugin_err(rc)); } *child = PICLHDL_TO_TREEHDL(p_child); @@ -300,10 +300,7 @@ fpt_get_parent(fru_treehdl_t handle, fru_treehdl_t *parent) rc = picl_get_propval_by_name(TREEHDL_TO_PICLHDL(handle), PICL_PROP_PARENT, (void *)&p_parent, sizeof (p_parent)); if (rc != PICL_SUCCESS) { - if (rc == PICL_PROPNOTFOUND) - return (FRU_NODENOTFOUND); - else - return (FRU_IOERROR); + return (map_plugin_err(rc)); } *parent = PICLHDL_TO_TREEHDL(p_parent); @@ -314,12 +311,13 @@ fpt_get_parent(fru_treehdl_t handle, fru_treehdl_t *parent) static fru_errno_t fpt_get_node_type(fru_treehdl_t node, fru_node_t *type) { + int rc = PICL_SUCCESS; char picl_class[PICL_PROPNAMELEN_MAX]; picl_nodehdl_t handle = TREEHDL_TO_PICLHDL(node); - if (picl_get_propval_by_name(handle, PICL_PROP_CLASSNAME, - picl_class, sizeof (picl_class)) != PICL_SUCCESS) { - return (FRU_IOERROR); + if ((rc = picl_get_propval_by_name(handle, PICL_PROP_CLASSNAME, + picl_class, sizeof (picl_class))) != PICL_SUCCESS) { + return (map_plugin_err(rc)); } if (strcmp(picl_class, PICL_CLASS_LOCATION) == 0) { @@ -449,11 +447,12 @@ get_segment_node(picl_nodehdl_t handle, const char *segment, return (FRU_SEGCORRUPT); } /* get the HW protections of this section. */ - if (picl_get_propval_by_name(sect_node, + if ((rc = picl_get_propval_by_name(sect_node, PICL_PROP_PROTECTED, (void *)&protection, - sizeof (protection)) != PICL_SUCCESS) { - return (FRU_IOERROR); + sizeof (protection))) + != PICL_SUCCESS) { + return (map_plugin_err(rc)); } hw_desc->all_bits = 0; hw_desc->field.read_only = protection; @@ -467,7 +466,7 @@ get_segment_node(picl_nodehdl_t handle, const char *segment, /* Peer property not found is ok */ if (rc != PICL_PROPNOTFOUND) { - return (FRU_IOERROR); + return (map_plugin_err(rc)); } err = find_next_section(sect_node, §_node); @@ -534,7 +533,7 @@ add_segs_for_section(picl_nodehdl_t section, fru_strlist_t *list) /* Peer property not found is ok */ if (rc != PICL_PROPNOTFOUND) { - return (FRU_IOERROR); + return (map_plugin_err(rc)); } } @@ -598,19 +597,19 @@ fpt_get_seg_def(fru_treehdl_t handle, const char *seg_name, fru_segdef_t *def) if ((picl_err = picl_get_propval_by_name(seg_node, PICL_PROP_DESCRIPTOR, &desc, sizeof (desc))) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } if ((picl_err = picl_get_propval_by_name(seg_node, PICL_PROP_LENGTH, &size, sizeof (size))) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } if ((picl_err = picl_get_propval_by_name(seg_node, PICL_PROP_OFFSET, &address, sizeof (address))) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } def->version = LIBFRU_VERSION; @@ -698,11 +697,11 @@ fpt_add_tag_to_seg(fru_treehdl_t handle, const char *seg_name, if ((picl_err = picl_get_prop_by_name(segHdl, PICL_PROP_ADD_PACKET, &add_prop)) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } if ((picl_err = picl_get_propinfo(add_prop, &add_prop_info)) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } buf_size = add_prop_info.size; @@ -750,7 +749,7 @@ fpt_get_tag_list(fru_treehdl_t handle, const char *seg_name, PICL_PROP_NUM_TAGS, (void *)&total_tags, sizeof (total_tags))) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } if (total_tags == 0) { @@ -769,7 +768,7 @@ fpt_get_tag_list(fru_treehdl_t handle, const char *seg_name, PICL_PROP_PACKET_TABLE, &tagTable, sizeof (tagTable))) != PICL_SUCCESS) { free(rc_tags); - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } picl_err = picl_get_next_by_col(tagTable, &tagTable); while (picl_err == PICL_SUCCESS) { @@ -783,7 +782,7 @@ fpt_get_tag_list(fru_treehdl_t handle, const char *seg_name, (void *)&(rc_tags[rc_num++]), sizeof (fru_tag_t))) != PICL_SUCCESS) { free(rc_tags); - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } /* get the next tag */ picl_err = picl_get_next_by_col(tagTable, &tagTable); @@ -794,7 +793,7 @@ fpt_get_tag_list(fru_treehdl_t handle, const char *seg_name, *number = rc_num; return (FRU_SUCCESS); } - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } /* ========================================================================= */ @@ -826,7 +825,7 @@ get_tag_handle(picl_nodehdl_t handle, const char *segment, if ((picl_err = picl_get_propval_by_name(tmp_seg, PICL_PROP_PACKET_TABLE, &tagTable, sizeof (tagTable))) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } picl_err = picl_get_next_by_col(tagTable, &tagTable); @@ -834,7 +833,7 @@ get_tag_handle(picl_nodehdl_t handle, const char *segment, (picl_err == PICL_SUCCESS)) { if ((picl_err = picl_get_propval(tagTable, (void *)&foundTag, sizeof (foundTag))) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } if ((tags_equal(tag, foundTag) == 1) && (instance-- == 0)) { *segHdl = tmp_seg; @@ -844,10 +843,7 @@ get_tag_handle(picl_nodehdl_t handle, const char *segment, picl_err = picl_get_next_by_col(tagTable, &tagTable); } - if (picl_err == PICL_ENDOFLIST) - return (FRU_DATANOTFOUND); - - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } /* ========================================================================= */ @@ -871,7 +867,7 @@ fpt_get_tag_data(fru_treehdl_t handle, const char *seg_name, if ((picl_err = picl_get_next_by_row(tagHdl, &tagHdl)) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } buf_len = get_payload_length(&tag); @@ -910,7 +906,7 @@ fpt_set_tag_data(fru_treehdl_t handle, const char *seg_name, if ((picl_err = picl_get_next_by_row(tagHdl, &tagHdl)) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } if ((picl_err = picl_set_propval(tagHdl, data, data_len)) @@ -1031,10 +1027,10 @@ fpt_get_segment_name(fru_treeseghdl_t segment, char **name) picl_propinfo_t propinfo; - if (picl_get_propinfo_by_name(TREESEGHDL_TO_PICLHDL(segment), - PICL_PROP_NAME, &propinfo, &proph) + if ((status = picl_get_propinfo_by_name(TREESEGHDL_TO_PICLHDL(segment), + PICL_PROP_NAME, &propinfo, &proph)) != PICL_SUCCESS) - return (FRU_IOERROR); + return (map_plugin_err(status)); if (propinfo.size == 0) return (FRU_INVALDATASIZE); diff --git a/usr/src/lib/libfru/libfrupicltree/frupicltree.c b/usr/src/lib/libfru/libfrupicltree/frupicltree.c index 2a21e4b8a4..4e9f781fbd 100644 --- a/usr/src/lib/libfru/libfrupicltree/frupicltree.c +++ b/usr/src/lib/libfru/libfrupicltree/frupicltree.c @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 2000-2002 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -69,6 +69,12 @@ map_plugin_err(int picl_err) return (FRU_DUPSEG); case PICL_NOSPACE: return (FRU_NOSPACE); + case PICL_NORESPONSE: + return (FRU_NORESPONSE); + case PICL_PROPNOTFOUND: + return (FRU_NODENOTFOUND); + case PICL_ENDOFLIST: + return (FRU_DATANOTFOUND); } return (FRU_IOERROR); } @@ -146,7 +152,7 @@ fpt_get_name_from_hdl(fru_treehdl_t node, char **name) /* get the name */ if ((picl_err = get_strprop_by_name(handle, PICL_PROP_NAME, &tmp_name)) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } /* get the label, if any */ @@ -154,7 +160,7 @@ fpt_get_name_from_hdl(fru_treehdl_t node, char **name) &label)) != PICL_SUCCESS) { if (picl_err != PICL_PROPNOTFOUND) { free(tmp_name); - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } /* else PICL_PROPNOTFOUND is OK because not all nodes */ /* will have a label. */ @@ -237,7 +243,7 @@ fpt_get_root(fru_treehdl_t *node) if ((picl_err = ptree_get_propval_by_name(picl_node, PICL_PROP_CHILD, (void *)&picl_node, sizeof (picl_node))) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } while (cmp_node_name(picl_node, PICL_NODE_FRUTREE) @@ -248,7 +254,7 @@ fpt_get_root(fru_treehdl_t *node) sizeof (picl_node))) == PICL_PROPNOTFOUND) { return (FRU_NODENOTFOUND); } else if (picl_err != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } } @@ -268,10 +274,7 @@ fpt_get_peer(fru_treehdl_t sibling, fru_treehdl_t *peer) rc = ptree_get_propval_by_name(handle, PICL_PROP_PEER, (void *)&picl_peer, sizeof (picl_peer)); if (rc != PICL_SUCCESS) { - if (rc == PICL_PROPNOTFOUND) - return (FRU_NODENOTFOUND); - else - return (FRU_IOERROR); + return (map_plugin_err(rc)); } *peer = PICLHDL_TO_TREEHDL(picl_peer); @@ -286,10 +289,7 @@ fpt_get_child(fru_treehdl_t handle, fru_treehdl_t *child) int rc = ptree_get_propval_by_name(TREEHDL_TO_PICLHDL(handle), PICL_PROP_CHILD, (void *)&p_child, sizeof (p_child)); if (rc != PICL_SUCCESS) { - if (rc == PICL_PROPNOTFOUND) - return (FRU_NODENOTFOUND); - else - return (FRU_IOERROR); + return (map_plugin_err(rc)); } *child = PICLHDL_TO_TREEHDL(p_child); @@ -311,10 +311,7 @@ fpt_get_parent(fru_treehdl_t handle, fru_treehdl_t *parent) rc = ptree_get_propval_by_name(TREEHDL_TO_PICLHDL(handle), PICL_PROP_PARENT, (void *)&p_parent, sizeof (p_parent)); if (rc != PICL_SUCCESS) { - if (rc == PICL_PROPNOTFOUND) - return (FRU_NODENOTFOUND); - else - return (FRU_IOERROR); + return (map_plugin_err(rc)); } *parent = PICLHDL_TO_TREEHDL(p_parent); @@ -325,12 +322,13 @@ fpt_get_parent(fru_treehdl_t handle, fru_treehdl_t *parent) static fru_errno_t fpt_get_node_type(fru_treehdl_t node, fru_node_t *type) { + int rc = PICL_SUCCESS; char picl_class[PICL_PROPNAMELEN_MAX]; picl_nodehdl_t handle = TREEHDL_TO_PICLHDL(node); - if (ptree_get_propval_by_name(handle, PICL_PROP_CLASSNAME, - picl_class, sizeof (picl_class)) != PICL_SUCCESS) { - return (FRU_IOERROR); + if ((rc = ptree_get_propval_by_name(handle, PICL_PROP_CLASSNAME, + picl_class, sizeof (picl_class))) != PICL_SUCCESS) { + return (map_plugin_err(rc)); } if (strcmp(picl_class, PICL_CLASS_LOCATION) == 0) { @@ -460,11 +458,12 @@ get_segment_node(picl_nodehdl_t handle, const char *segment, return (FRU_SEGCORRUPT); } /* get the HW protections of this section. */ - if (ptree_get_propval_by_name(sect_node, + if ((rc = ptree_get_propval_by_name(sect_node, PICL_PROP_PROTECTED, (void *)&protection, - sizeof (protection)) != PICL_SUCCESS) { - return (FRU_IOERROR); + sizeof (protection))) + != PICL_SUCCESS) { + return (map_plugin_err(rc)); } hw_desc->all_bits = 0; hw_desc->field.read_only = protection; @@ -478,7 +477,7 @@ get_segment_node(picl_nodehdl_t handle, const char *segment, /* Peer property not found is ok */ if (rc != PICL_PROPNOTFOUND) { - return (FRU_IOERROR); + return (map_plugin_err(rc)); } err = find_next_section(sect_node, §_node); @@ -545,7 +544,7 @@ add_segs_for_section(picl_nodehdl_t section, fru_strlist_t *list) /* Peer property not found is ok */ if (rc != PICL_PROPNOTFOUND) { - return (FRU_IOERROR); + return (map_plugin_err(rc)); } } @@ -609,19 +608,19 @@ fpt_get_seg_def(fru_treehdl_t handle, const char *seg_name, fru_segdef_t *def) if ((picl_err = ptree_get_propval_by_name(seg_node, PICL_PROP_DESCRIPTOR, &desc, sizeof (desc))) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } if ((picl_err = ptree_get_propval_by_name(seg_node, PICL_PROP_LENGTH, &size, sizeof (size))) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } if ((picl_err = ptree_get_propval_by_name(seg_node, PICL_PROP_OFFSET, &address, sizeof (address))) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } def->version = LIBFRU_VERSION; @@ -709,12 +708,12 @@ fpt_add_tag_to_seg(fru_treehdl_t handle, const char *seg_name, if ((picl_err = ptree_get_prop_by_name(segHdl, PICL_PROP_ADD_PACKET, &add_prop)) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } if ((picl_err = ptree_get_propinfo(add_prop, &add_prop_info)) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } buf_size = add_prop_info.piclinfo.size; @@ -762,7 +761,7 @@ fpt_get_tag_list(fru_treehdl_t handle, const char *seg_name, PICL_PROP_NUM_TAGS, (void *)&total_tags, sizeof (total_tags))) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } if (total_tags == 0) { @@ -781,7 +780,7 @@ fpt_get_tag_list(fru_treehdl_t handle, const char *seg_name, PICL_PROP_PACKET_TABLE, &tagTable, sizeof (tagTable))) != PICL_SUCCESS) { free(rc_tags); - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } picl_err = ptree_get_next_by_col(tagTable, &tagTable); while (picl_err == PICL_SUCCESS) { @@ -795,7 +794,7 @@ fpt_get_tag_list(fru_treehdl_t handle, const char *seg_name, (void *)&(rc_tags[rc_num++]), sizeof (fru_tag_t))) != PICL_SUCCESS) { free(rc_tags); - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } /* get the next tag */ picl_err = ptree_get_next_by_col(tagTable, &tagTable); @@ -806,7 +805,7 @@ fpt_get_tag_list(fru_treehdl_t handle, const char *seg_name, *number = rc_num; return (FRU_SUCCESS); } - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } /* ========================================================================= */ @@ -838,7 +837,7 @@ get_tag_handle(picl_nodehdl_t handle, const char *segment, if ((picl_err = ptree_get_propval_by_name(tmp_seg, PICL_PROP_PACKET_TABLE, &tagTable, sizeof (tagTable))) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } picl_err = ptree_get_next_by_col(tagTable, &tagTable); @@ -846,7 +845,7 @@ get_tag_handle(picl_nodehdl_t handle, const char *segment, (picl_err == PICL_SUCCESS)) { if ((picl_err = ptree_get_propval(tagTable, (void *)&foundTag, sizeof (foundTag))) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } if ((tags_equal(tag, foundTag) == 1) && (instance-- == 0)) { *segHdl = tmp_seg; @@ -856,10 +855,7 @@ get_tag_handle(picl_nodehdl_t handle, const char *segment, picl_err = ptree_get_next_by_col(tagTable, &tagTable); } - if (picl_err == PICL_ENDOFLIST) - return (FRU_DATANOTFOUND); - - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } /* ========================================================================= */ @@ -883,7 +879,7 @@ fpt_get_tag_data(fru_treehdl_t handle, const char *seg_name, if ((picl_err = ptree_get_next_by_row(tagHdl, &tagHdl)) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } buf_len = get_payload_length(&tag); @@ -922,7 +918,7 @@ fpt_set_tag_data(fru_treehdl_t handle, const char *seg_name, if ((picl_err = ptree_get_next_by_row(tagHdl, &tagHdl)) != PICL_SUCCESS) { - return (FRU_IOERROR); + return (map_plugin_err(picl_err)); } if ((picl_err = ptree_update_propval(tagHdl, data, data_len)) @@ -1043,13 +1039,13 @@ fpt_get_segment_name(fru_treeseghdl_t segment, char **name) ptree_propinfo_t propinfo; - if (ptree_get_prop_by_name(TREESEGHDL_TO_PICLHDL(segment), - PICL_PROP_NAME, &proph) + if ((status = ptree_get_prop_by_name(TREESEGHDL_TO_PICLHDL(segment), + PICL_PROP_NAME, &proph)) != PICL_SUCCESS) - return (FRU_IOERROR); + return (map_plugin_err(status)); if (ptree_get_propinfo(proph, &propinfo) != PICL_SUCCESS) - return (FRU_IOERROR); + return (map_plugin_err(status)); if (propinfo.piclinfo.size == 0) return (FRU_INVALDATASIZE); |