diff options
| author | cth <none@none> | 2008-08-01 15:17:57 -0700 |
|---|---|---|
| committer | cth <none@none> | 2008-08-01 15:17:57 -0700 |
| commit | fa08425907599c31bdd9b57b218364c818c1e1f3 (patch) | |
| tree | 16ac4a81247bc6b9a4999adb209843763d80e074 | |
| parent | c64d15a587b6038b85a928885fc997da7315fbfe (diff) | |
| download | illumos-joyent-fa08425907599c31bdd9b57b218364c818c1e1f3.tar.gz | |
6502202 prtconf should display 'compatible'
| -rw-r--r-- | usr/src/cmd/prtconf/pdevinfo.c | 84 |
1 files changed, 74 insertions, 10 deletions
diff --git a/usr/src/cmd/prtconf/pdevinfo.c b/usr/src/cmd/prtconf/pdevinfo.c index 8fb6d537cb..154020664a 100644 --- a/usr/src/cmd/prtconf/pdevinfo.c +++ b/usr/src/cmd/prtconf/pdevinfo.c @@ -131,7 +131,7 @@ static int prop_type_guess(const dumpops_t *, void *, void **, int *); static void walk_driver(di_node_t, di_devlink_handle_t); static int dump_devs(di_node_t, void *); static int dump_prop_list(const dumpops_t *, const char *, - int, void *, dev_t); + int, void *, dev_t, int *); static int _error(const char *, ...); static int is_openprom(); static void walk(uchar_t *, uint_t, int); @@ -141,6 +141,7 @@ static void dump_prodinfo(di_prom_handle_t, di_node_t, const char **, static di_node_t find_node_by_name(di_prom_handle_t, di_node_t, char *); static int get_propval_by_name(di_prom_handle_t, di_node_t, const char *, uchar_t **); +static int dump_compatible(char *, int, di_node_t); static void dump_pathing_data(int, di_node_t); static void dump_minor_data(int, di_node_t, di_devlink_handle_t); static void dump_link_data(int, di_node_t, di_devlink_handle_t); @@ -506,7 +507,7 @@ prop_type_guess(const dumpops_t *propops, void *prop, void **prop_data, */ static int dump_prop_list(const dumpops_t *dumpops, const char *name, int ilev, - void *node, dev_t dev) + void *node, dev_t dev, int *compat_printed) { void *prop = DI_PROP_NIL, *prop_data; di_minor_t minor; @@ -515,6 +516,9 @@ dump_prop_list(const dumpops_t *dumpops, const char *name, int ilev, dev_t pdev; int nprop = 0; + if (compat_printed) + *compat_printed = 0; + while ((prop = NEXTPROP(dumpops)(node, prop)) != DI_PROP_NIL) { /* Skip properties a dev_t oriented caller is not requesting */ @@ -578,6 +582,11 @@ print: nitems = prop_type_guess(dumpops, prop, &prop_data, &prop_type); indent_to_level(ilev); (void) printf("name='%s' type=", PROPNAME(dumpops)(prop)); + /* report 'compatible' as processed */ + if (compat_printed && + (strcmp(PROPNAME(dumpops)(prop), "compatible") == 0)) + *compat_printed = 1; + switch (prop_type) { case DI_PROP_TYPE_UNDEF_IT: (void) printf("undef"); @@ -688,6 +697,8 @@ dump_devs(di_node_t node, void *arg) int ilev = 0; /* indentation level */ char *driver_name; di_node_t root_node, tmp; + int compat_printed; + int printed; if (dbg.d_debug) { char *path = di_devfs_path(node); @@ -743,17 +754,25 @@ dump_devs(di_node_t node, void *arg) if (opts.o_verbose) { if (dump_prop_list(&sysprop_dumpops, "System", ilev + 1, - node, DDI_DEV_T_ANY)) { + node, DDI_DEV_T_ANY, NULL)) { (void) dump_prop_list(&globprop_dumpops, NULL, ilev + 1, - node, DDI_DEV_T_ANY); + node, DDI_DEV_T_ANY, NULL); } else { (void) dump_prop_list(&globprop_dumpops, - "System software", ilev + 1, node, DDI_DEV_T_ANY); + "System software", ilev + 1, + node, DDI_DEV_T_ANY, NULL); } (void) dump_prop_list(&drvprop_dumpops, "Driver", ilev + 1, - node, DDI_DEV_T_NONE); - (void) dump_prop_list(&hwprop_dumpops, "Hardware", ilev + 1, - node, DDI_DEV_T_ANY); + node, DDI_DEV_T_NONE, NULL); + + printed = dump_prop_list(&hwprop_dumpops, "Hardware", + ilev + 1, node, DDI_DEV_T_ANY, &compat_printed); + + /* Ensure that 'compatible' is printed under Hardware header */ + if (!compat_printed) + (void) dump_compatible(printed ? NULL : "Hardware", + ilev + 1, node); + dump_priv_data(ilev + 1, node); dump_pathing_data(ilev + 1, node); dump_link_data(ilev + 1, node, devlink_hdl); @@ -1021,7 +1040,7 @@ dump_pathing_data(int ilev, di_node_t node) (void) printf("%s#%d (%s)\n", di_driver_name(phci_node), di_instance(phci_node), path_state_name(di_path_state(pi))); (void) dump_prop_list(&pathprop_dumpops, NULL, ilev + 1, - pi, DDI_DEV_T_ANY); + pi, DDI_DEV_T_ANY, NULL); } } @@ -1369,7 +1388,7 @@ dump_minor_data(int ilev, di_node_t node, di_devlink_handle_t devlink_hdl) /* display properties associated with this devt */ (void) dump_prop_list(&drvprop_dumpops, "Minor", - ilev + 1, node, devt); + ilev + 1, node, devt, NULL); } /* @@ -1833,3 +1852,48 @@ dump_prodinfo(di_prom_handle_t promh, di_node_t node, const char **propstr, } } } + +static int +dump_compatible(char *name, int ilev, di_node_t node) +{ + int ncompat; + char *compat_array; + char *p, *q; + int i; + + if (node == DI_PATH_NIL) + return (0); + + ncompat = di_compatible_names(node, &compat_array); + if (ncompat <= 0) + return (0); /* no 'compatible' available */ + + /* verify integrety of compat_array */ + for (i = 0, p = compat_array; i < ncompat; i++, p += strlen(p) + 1) { + if (strlen(p) == 0) + return (0); /* NULL string */ + for (q = p; *q; q++) { + if (!(isascii(*q) && (isprint(*q) || isspace(*q)))) + return (0); /* Not printable or space */ + } + } + + /* If name is non-NULL, produce header */ + if (name) { + indent_to_level(ilev); + (void) printf("%s properties:\n", name); + } + ilev++; + + /* process like a string array property */ + indent_to_level(ilev); + (void) printf("name='compatible' type=string items=%d\n", ncompat); + indent_to_level(ilev); + (void) printf(" value="); + for (i = 0, p = compat_array; i < (ncompat - 1); + i++, p += strlen(p) + 1) + (void) printf("'%s' + ", p); + (void) printf("'%s'", p); + (void) putchar('\n'); + return (1); +} |
