summaryrefslogtreecommitdiffstats
path: root/usr.sbin/lsdev
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>1994-10-24 22:21:51 +0000
committerwollman <wollman@FreeBSD.org>1994-10-24 22:21:51 +0000
commita20115b9164905f860ae24fc17796186f5aa8b9f (patch)
treee22cb847d883666f00bcf3f80808a9152a1982c7 /usr.sbin/lsdev
parent61b5dc899b13a0e56a7e638c0f63058a0c76831f (diff)
downloadFreeBSD-src-a20115b9164905f860ae24fc17796186f5aa8b9f.zip
FreeBSD-src-a20115b9164905f860ae24fc17796186f5aa8b9f.tar.gz
When -v not given, display longer `state' and no `parent'.
Diffstat (limited to 'usr.sbin/lsdev')
-rw-r--r--usr.sbin/lsdev/lsdev.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/usr.sbin/lsdev/lsdev.c b/usr.sbin/lsdev/lsdev.c
index a1b3b49..0e337d7 100644
--- a/usr.sbin/lsdev/lsdev.c
+++ b/usr.sbin/lsdev/lsdev.c
@@ -168,14 +168,29 @@ badname(const char *name)
static void
hprint_pretty(void)
{
- printf("%-10.10s %-2.2s %-10.10s %s\n",
- "Device", "St", "Parent", "Description");
- printf("%-10.10s %-2.2s %-10.10s %s\n",
- "----------", "--", "----------",
- "--------------------------------------------------");
+ printf("%-10.10s ", "Device");
+ if(vflag) {
+ printf("%-2.2s %-10.10s ", "St", "Parent");
+ } else {
+ printf("%-15.15s ", "State");
+ }
+
+ printf("%s\n", "Description");
+
+ printf("%-10.10s ", "----------");
+ if(vflag) {
+ printf("%-2.2s %-10.10s ", "--", "----------");
+ } else {
+ printf("%-15.15s ", "---------------");
+ }
+
+ printf("%s\n", "--------------------------------------------------");
}
static const char *const states[] = { "??", "NC", "I", "B" };
+static const char *const longstates[] = {
+ "Unknown", "Unconfigured", "Idle", "Busy"
+};
static void
print_pretty(struct devconf *dc)
@@ -184,15 +199,21 @@ print_pretty(struct devconf *dc)
snprintf(buf, sizeof buf, "%s%d", dc->dc_name, dc->dc_unit);
- printf("%-10.10s %2.2s ", buf, states[dc->dc_state]);
+ if(vflag) {
+ printf("%-10.10s %2.2s ", buf, states[dc->dc_state]);
- if(dc->dc_punit >= 0) {
- snprintf(buf, sizeof buf, "%s%d", dc->dc_pname, dc->dc_punit);
+ if(dc->dc_punit >= 0) {
+ snprintf(buf, sizeof buf, "%s%d", dc->dc_pname,
+ dc->dc_punit);
+ } else {
+ buf[0] = '-';
+ buf[1] = '\0';
+ }
+ printf("%-10.10s ", buf);
} else {
- buf[0] = '-';
- buf[1] = '\0';
+ printf("%-10.10s %-15.15s ", buf, longstates[dc->dc_state]);
}
- printf("%-10.10s %s\n", buf, dc->dc_descr);
+ printf("%s\n", dc->dc_descr);
}
OpenPOWER on IntegriCloud