Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/intrctl intrctl(8): pretty printing intrctl list.
details: https://anonhg.NetBSD.org/src/rev/5bbe241e733b
branches: trunk
changeset: 346787:5bbe241e733b
user: knakahara <knakahara%NetBSD.org@localhost>
date: Wed Aug 03 08:34:21 2016 +0000
description:
intrctl(8): pretty printing intrctl list.
e.g.
========== before ==========
interrupt id CPU#00 CPU#01 device name(s)
irq 9 0* 0 pq3pcie1
irq 10 0* 0 pq3pcie0
irq 12 30* 0 usb1
irq 13 79* 0 etsec1-tx
irq 14 268* 0 etsec1-rx
irq 15 0* 0 etsec3-tx
irq 16 0* 0 etsec3-rx
irq 17 0* 0 etsec3-err
irq 18 0* 0 etsec1-err
irq 26 1030* 0 duart
irq 27 0* 0 i2c
irq 56 680437* 0 esdhc
msigroup 0 0* 0 msi 0-31
========== before ==========
========== after ==========
interrupt id CPU0 CPU1 device name(s)
irq 9 0* 0 pq3pcie1
irq 10 0* 0 pq3pcie0
irq 12 30* 0 usb1
irq 13 79* 0 etsec1-tx
irq 14 310* 0 etsec1-rx
irq 15 0* 0 etsec3-tx
irq 16 0* 0 etsec3-rx
irq 17 0* 0 etsec3-err
irq 18 0* 0 etsec1-err
irq 26 1629* 0 duart
irq 27 0* 0 i2c
irq 56 730617* 0 esdhc
msigroup 0 0 18* msi 0-31
========== after ==========
This patch is implemented by nonaka@n.o. Thanks.
diffstat:
usr.sbin/intrctl/intrctl.c | 29 ++++++++++++++++++++---------
1 files changed, 20 insertions(+), 9 deletions(-)
diffs (66 lines):
diff -r 646f3be4ecd0 -r 5bbe241e733b usr.sbin/intrctl/intrctl.c
--- a/usr.sbin/intrctl/intrctl.c Wed Aug 03 08:28:09 2016 +0000
+++ b/usr.sbin/intrctl/intrctl.c Wed Aug 03 08:34:21 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: intrctl.c,v 1.1 2015/08/17 06:42:46 knakahara Exp $ */
+/* $NetBSD: intrctl.c,v 1.2 2016/08/03 08:34:21 knakahara Exp $ */
/*
* Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: intrctl.c,v 1.1 2015/08/17 06:42:46 knakahara Exp $");
+__RCSID("$NetBSD: intrctl.c,v 1.2 2016/08/03 08:34:21 knakahara Exp $");
#include <sys/param.h>
#include <sys/sysctl.h>
@@ -115,29 +115,40 @@
struct intrio_list_line *illine;
int i, ncpus;
void *handle;
+ size_t intridlen;
handle = intrctl_io_alloc(intrctl_io_alloc_retry_count);
if (handle == NULL)
err(EXIT_FAILURE, "intrctl_io_alloc");
- /* header */
+ /* calc columns */
ncpus = intrctl_io_ncpus(handle);
- printf("interrupt id\t");
+ intridlen = strlen("interrupt id");
+ illine = intrctl_io_firstline(handle);
+ for (; illine != NULL; illine = intrctl_io_nextline(handle, illine)) {
+ size_t len = strlen(illine->ill_intrid);
+ if (intridlen < len)
+ intridlen = len;
+ }
+
+ /* header */
+ printf("%-*s", (int)intridlen, "interrupt id");
for (i = 0; i < ncpus; i++) {
- printf(" CPU#%02u\t", i);
+ char buf[64];
+ snprintf(buf, sizeof(buf), "CPU%u", i);
+ printf(" %20s ", buf);
}
- printf("device name(s)\n");
+ printf(" device name(s)\n");
/* body */
illine = intrctl_io_firstline(handle);
for (; illine != NULL; illine = intrctl_io_nextline(handle, illine)) {
- printf("%s\t", illine->ill_intrid);
+ printf("%-*s ", (int)intridlen, illine->ill_intrid);
for (i = 0; i < ncpus; i++) {
struct intrio_list_line_cpu *illc = &illine->ill_cpu[i];
- printf("%8" PRIu64 "%c\t", illc->illc_count,
+ printf("%20" PRIu64 "%c ", illc->illc_count,
illc->illc_assigned ? '*' : ' ');
}
-
printf("%s\n", illine->ill_xname);
}
Home |
Main Index |
Thread Index |
Old Index