Skip to content

Commit

Permalink
lstopo/draw: display the osdev-type before their name
Browse files Browse the repository at this point in the history
So that "Block nvme0n1" and "Net enp0" is more clear than "nvme0n1" and "enp0".

The name may be hidden by disabling index displaying for osdevs
since names are usually "<type><number>".

Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed Mar 13, 2020
1 parent 2af29c0 commit 274acf4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions utils/lstopo/lstopo-draw.c
Expand Up @@ -720,10 +720,20 @@ lstopo_obj_snprintf(struct lstopo_output *loutput, char *text, size_t textlen, h
char totmemstr[64] = "";
int attrlen;

/* For OSDev, Misc and Group, name replaces type+index+attrs */
if (obj->name && (obj->type == HWLOC_OBJ_OS_DEVICE || obj->type == HWLOC_OBJ_MISC || obj->type == HWLOC_OBJ_GROUP)) {
/* For Misc and Group, name replaces type+index+attrs */
if (obj->name && (obj->type == HWLOC_OBJ_MISC || obj->type == HWLOC_OBJ_GROUP)) {
return snprintf(text, textlen, "%s", obj->name);
}
/* For OSDev, OSDev-type+name replaces type+index+attrs */
if (obj->type == HWLOC_OBJ_OS_DEVICE) {
/* consider the name as an index and remove it if LSTOPO_INDEX_TYPE_NONE */
if (index_type != LSTOPO_INDEX_TYPE_NONE) {
hwloc_obj_type_snprintf(typestr, sizeof(typestr), obj, 0);
return snprintf(text, textlen, "%s %s", typestr, obj->name);
} else {
return hwloc_obj_type_snprintf(text, textlen, obj, 0);
}
}

/* subtype replaces the basic type name */
if (obj->subtype) {
Expand Down

0 comments on commit 274acf4

Please sign in to comment.