static void update_cluster_info(struct join_message *msg, struct sd_node *joined, struct sd_node *nodes, size_t nr_nodes) { eprintf("status = %d, epoch = %d, %x, %d\n", msg->cluster_status, msg->epoch, msg->result, sys->join_finished); if (sys_stat_join_failed()) return; if (!sys->join_finished) finish_join(msg, joined, nodes, nr_nodes); sys->nodes[sys->nr_nodes++] = *joined; qsort(sys->nodes, sys->nr_nodes, sizeof(*sys->nodes), node_cmp); if (msg->cluster_status == SD_STATUS_OK || msg->cluster_status == SD_STATUS_HALT) { if (msg->inc_epoch) { sys->epoch++; update_epoch_log(sys->epoch); update_epoch_store(sys->epoch); } /* Fresh node */ if (!sys_stat_ok() && !sys_stat_halt()) { set_cluster_copies(sys->nr_copies); set_cluster_flags(sys->flags); set_cluster_ctime(msg->ctime); } } update_vnode_info(); sys_stat_set(msg->cluster_status); print_node_list(sys->nodes, sys->nr_nodes); }
struct dr_node * get_node_by_name(const char *drc_name, uint32_t node_type) { struct dr_node *node, *all_nodes; struct dr_node *prev_node = NULL; int child_found = 0; all_nodes = get_dlpar_nodes(node_type); if (all_nodes == NULL) { say(ERROR, "There are no DR capable slots on this system\n"); return NULL; } print_node_list(all_nodes); for (node = all_nodes; node; node = node->next) { struct dr_node *child; uint32_t drc_index; if (strcmp(node->drc_name, drc_name) == 0) break; /* See if the drc index was specified */ drc_index = strtoul(drc_name, NULL, 0); if (node->drc_index == drc_index) continue; for (child = node->children; child; child = child->next) { if (strcmp(drc_name, child->drc_name) == 0) child_found = 1; if (child->drc_index == drc_index) child_found = 1; } if (child_found) break; prev_node = node; } if (node) { if (prev_node) prev_node->next = node->next; else /* First in list */ all_nodes = all_nodes->next; node->next = NULL; } free_node(all_nodes); return node; }
int main(int argc, char *argv[]) { int number_of_nodes = 0; if (2 > argc) { printf("Error in main: missing grade file argument \n"); exit(1); } init(); number_of_nodes = read_rocketfuel_file(argv[1]); color_topology(MAX_LEVELS); map_nodes_to_ross(); print_node_list(); return (1); }
void print_node(ndr_node_t *np) { char *nm; if (!np) { (void) printf("<null>"); return; } switch (np->label) { case ALIGN_KW: nm = "align"; break; case STRUCT_KW: nm = "struct"; break; case UNION_KW: nm = "union"; break; case TYPEDEF_KW: nm = "typedef"; break; case INTERFACE_KW: nm = "interface"; break; case IN_KW: nm = "in"; break; case OUT_KW: nm = "out"; break; case SIZE_IS_KW: nm = "size_is"; break; case LENGTH_IS_KW: nm = "length_is"; break; case STRING_KW: nm = "string"; break; case TRANSMIT_AS_KW: nm = "transmit_as"; break; case OPERATION_KW: nm = "operation"; break; case UUID_KW: nm = "uuid"; break; case _NO_REORDER_KW: nm = "_no_reorder"; break; case EXTERN_KW: nm = "extern"; break; case ARG_IS_KW: nm = "arg_is"; break; case CASE_KW: nm = "case"; break; case DEFAULT_KW: nm = "default"; break; case BASIC_TYPE: nm = "<btype>"; break; case TYPENAME: nm = "<tname>"; break; case IDENTIFIER: nm = "<ident>"; break; case INTEGER: nm = "<intg>"; break; case STRING: nm = "<string>"; break; case STAR: nm = "<*>"; break; case LB: nm = "<[>"; break; case LP: nm = "<(>"; break; case L_MEMBER: nm = "<member>"; break; default: (void) printf("<<lab=%d>>", np->label); return; } switch (np->label) { case STRUCT_KW: case UNION_KW: case TYPEDEF_KW: (void) printf("\n"); if (np->n_c_advice) { print_advice_list(np->n_c_advice); (void) printf("\n"); } (void) printf("%s ", nm); print_node(np->n_c_typename); (void) printf(" {\n"); print_node_list(np->n_c_members); (void) printf("};\n"); break; case IN_KW: case OUT_KW: case STRING_KW: case DEFAULT_KW: case _NO_REORDER_KW: case EXTERN_KW: (void) printf("%s", nm); break; case ALIGN_KW: /* * Don't output anything for default alignment. */ if ((np->n_a_arg == NULL) || (np->n_a_arg->n_int == 0)) break; (void) printf("%s(", nm); print_node(np->n_a_arg); (void) printf(")"); break; case SIZE_IS_KW: case LENGTH_IS_KW: (void) printf("%s(", nm); print_field_attr(np); (void) printf(")"); break; case INTERFACE_KW: case TRANSMIT_AS_KW: case ARG_IS_KW: case CASE_KW: case OPERATION_KW: case UUID_KW: (void) printf("%s(", nm); print_node(np->n_a_arg); (void) printf(")"); break; case BASIC_TYPE: case TYPENAME: case IDENTIFIER: (void) printf("%s", np->n_sym->name); break; case INTEGER: (void) printf("%ld", np->n_int); break; case STRING: (void) printf("\"%s\"", np->n_str); break; case STAR: (void) printf("*"); print_node(np->n_d_descend); break; case LB: print_node(np->n_d_descend); (void) printf("["); if (np->n_d_dim) print_node(np->n_d_dim); (void) printf("]"); break; case LP: (void) printf("("); print_node(np->n_d_descend); (void) printf(")"); break; case L_MEMBER: if (np->n_m_advice) { (void) printf(" "); print_advice_list(np->n_m_advice); (void) printf("\n"); } (void) printf("\t"); print_declaration(np); (void) printf(";\n"); break; default: return; } }
void tdata_dump(void) { print_node_list(construct_list); }
/** * lsslot_chrp_port * @brief Print LHEA ports based on command line options * * @param opts * @returns 0 on success, !0 otherwise */ int lsslot_chrp_port(struct cmd_opts *opts) { struct dr_node *all_nodes; /* Pointer to list of all node info */ struct dr_node *node; /* Used to traverse list of node info */ struct dr_node *child; /* Used to traverse list of children */ char fmt[128]; struct print_node *p; char *sheading = "LHEA port name"; /* Used in printing headers */ char *dheading = "Description"; /* Used in printing headers */ int rc = 0; /* Set initial column sizes */ max_sname = MAX(max_sname, strlen(sheading)); max_desc = MAX(max_desc, strlen(dheading)); all_nodes = get_dlpar_nodes(HEA_NODES); /* If nothing returned, then no hot plug node */ if (all_nodes == NULL) { say(ERROR, "There are no LHEA ports on this system.\n"); return 1; } print_node_list(all_nodes); /* Otherwise, run through the node list looking for the nodes * we want to print */ for (node = all_nodes; node; node = node->next) { if (node->skip) continue; for (child = node->children; child; child = child->next) { if (child->skip) continue; /* If there is a search parameter, add matching ports. * If there is no search, add all the ports. */ if (opts->s_name != NULL) { if (cmp_drcname(child->drc_name, opts->s_name)) insert_print_node(child); } else insert_print_node(child); } } if (print_list == NULL) { /* If nothing to print, display message based on if * user specified a slot or a device name. */ if (opts->s_name != NULL) { say(ERROR, "The specified port was not found.\n"); rc = 1; } goto lsslot_port_exit; } /* This creates a format string so that port name and description * prints out in the required field width. When the -F flag is * specified, the format string contains the delimiting character * which the user specified at the command line. */ if (opts->delim != NULL) sprintf(fmt, "%s%s%s\n", "%s", opts->delim, "%s"); else { sprintf(fmt, "%%-%ds%%-%ds\n", max_sname + 2, max_desc + 2); /* Print out the header. */ printf(fmt, sheading, dheading); } /* Now run through the list of ports we actually want to print */ for (p = print_list; p != NULL; p = p->next) { printf(fmt, p->node->drc_name, p->desc); } lsslot_port_exit: free_print_list(); free_node(all_nodes); return rc; }
/** * lsslot_chrp_pci * @brief main entry point for lsslot command * * @param opts * @returns 0 on success, !0 otherwise */ int lsslot_chrp_pci(struct cmd_opts *opts) { struct dr_node *all_nodes; /* Pointer to list of all node info */ struct dr_node *node; /* Used to traverse list of node info */ char fmt[128]; struct print_node *p; char *sheading = "# Slot"; /* Used in printing headers */ char *dheading = "Description"; /* Used in printing headers */ char *lheading = "Device(s)"; /* Used in printing headers */ char *lname_header = "Linux Name"; int rc = 0; /* Set initial column sizes */ max_sname = MAX(max_sname, strlen(sheading)); max_desc = MAX(max_desc, strlen(dheading)); /* Get all of node(logical DR or PCI) node information */ if (opts->slot_type == PCI) all_nodes = get_hp_nodes(); else all_nodes = get_dlpar_nodes(PCI_NODES | VIO_NODES | HEA_NODES); /* If nothing returned, then no hot plug node */ if (all_nodes == NULL) { if (opts->slot_type == PCI) say(ERROR, "There are no PCI hot plug slots on " "this system.\n"); else say(ERROR, "There are no DR slots on this system.\n"); return 0; } print_node_list(all_nodes); /* Otherwise, run through the node list looking for the nodes * we want to print */ for (node = all_nodes; node; node = node->next) { if (! node->is_owned || node->skip) continue; if (opts->s_name != NULL) { if (cmp_drcname(node->drc_name, opts->s_name)) insert_print_node(node); } /* If aflag and slot is empty, then format the slot */ else if (opts->a_flag && (node->children == NULL)) insert_print_node(node); /* If oflag and slot occupied, then format the slot */ else if (opts->o_flag && (node->children != NULL)) insert_print_node(node); } if (print_list == NULL) { /* If nothing to print, display message based on if * user specified a slot or a device name. */ if (opts->s_name != NULL) { say(ERROR, "The specified PCI slot is either invalid\n" "or does not support hot plug operations.\n"); rc = 1; } goto lsslot_pci_exit; } /* This creates a format string so that slot name and description * prints out in the required field width. When the -F flag is * specified, the format string contains the delimiting character * which the user specified at the command line. */ if (opts->slot_type == SLOT) { if (opts->delim != NULL) sprintf(fmt, "%s%s%s%s%s%s", "%s", opts->delim, "%s", opts->delim, "%s", opts->delim); else { sprintf(fmt, "%%-%ds%%-%ds%%-%ds", max_sname + 2, max_desc + 2, LNAME_SIZE + 2); /* Print out the header. */ printf(fmt, sheading, dheading, lname_header); printf("%s\n", lheading); } } else { if (opts->delim != NULL) sprintf(fmt, "%s%s%s%s", "%s", opts->delim, "%s", opts->delim); else { sprintf(fmt, "%%-%ds%%-%ds", max_sname + 2, max_desc + 2); /* Print out the header. */ printf(fmt, sheading, dheading); printf("%s\n", lheading); } } /* Now run through the list of slots we actually want to print */ for (p = print_list; p != NULL; p = p->next) { if (! p->node->is_owned) { /* skip it, because the partition doesn't own it */ continue; } if (opts->slot_type == SLOT) print_drslot_line(p, fmt); else print_phpslot_line(p, fmt); } lsslot_pci_exit: free_print_list(); free_node(all_nodes); return rc; }