Skip to content

Commit 274acf4

Browse files
committed
lstopo/draw: display the osdev-type before their name
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 <[email protected]>
1 parent 2af29c0 commit 274acf4

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

utils/lstopo/lstopo-draw.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,10 +720,20 @@ lstopo_obj_snprintf(struct lstopo_output *loutput, char *text, size_t textlen, h
720720
char totmemstr[64] = "";
721721
int attrlen;
722722

723-
/* For OSDev, Misc and Group, name replaces type+index+attrs */
724-
if (obj->name && (obj->type == HWLOC_OBJ_OS_DEVICE || obj->type == HWLOC_OBJ_MISC || obj->type == HWLOC_OBJ_GROUP)) {
723+
/* For Misc and Group, name replaces type+index+attrs */
724+
if (obj->name && (obj->type == HWLOC_OBJ_MISC || obj->type == HWLOC_OBJ_GROUP)) {
725725
return snprintf(text, textlen, "%s", obj->name);
726726
}
727+
/* For OSDev, OSDev-type+name replaces type+index+attrs */
728+
if (obj->type == HWLOC_OBJ_OS_DEVICE) {
729+
/* consider the name as an index and remove it if LSTOPO_INDEX_TYPE_NONE */
730+
if (index_type != LSTOPO_INDEX_TYPE_NONE) {
731+
hwloc_obj_type_snprintf(typestr, sizeof(typestr), obj, 0);
732+
return snprintf(text, textlen, "%s %s", typestr, obj->name);
733+
} else {
734+
return hwloc_obj_type_snprintf(text, textlen, obj, 0);
735+
}
736+
}
727737

728738
/* subtype replaces the basic type name */
729739
if (obj->subtype) {

0 commit comments

Comments
 (0)