From 55678a2eb9735980578f16b19f23a8a374bab208 Mon Sep 17 00:00:00 2001 From: Garrett Wollman Date: Fri, 12 May 1995 19:10:56 +0000 Subject: [PATCH] Learn how to print out kern.dumpdev as a name. --- sbin/sysctl/sysctl.c | 15 ++++++++++++--- usr.sbin/sysctl/sysctl.c | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c index 1d163e1579b4..1ce0453db2f7 100644 --- a/sbin/sysctl/sysctl.c +++ b/sbin/sysctl/sysctl.c @@ -40,7 +40,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "From: @(#)sysctl.c 8.1 (Berkeley) 6/6/93"; */ static const char rcsid[] = - "$Id: sysctl.c,v 1.3 1995/02/09 23:16:17 wollman Exp $"; + "$Id: sysctl.c,v 1.4 1995/02/16 00:28:42 wollman Exp $"; #endif /* not lint */ #include @@ -111,6 +111,7 @@ int Aflag, aflag, nflag, wflag; #define CLOCK 0x00000001 #define BOOTTIME 0x00000002 #define CONSDEV 0x00000004 +#define DUMPDEV 0x00000008 int main(argc, argv) @@ -274,6 +275,9 @@ parse(string, flags) case KERN_BOOTTIME: special |= BOOTTIME; break; + case KERN_DUMPDEV: + special |= DUMPDEV; + break; } break; @@ -391,12 +395,17 @@ parse(string, flags) fprintf(stdout, "%d\n", btp->tv_sec); return; } - if (special & CONSDEV) { + if (special & (CONSDEV | DUMPDEV)) { dev_t dev = *(dev_t *)buf; + if ((special & DUMPDEV) && dev == NODEV && !nflag) { + printf("%s = disabled\n", string); + return; + } if (!nflag) fprintf(stdout, "%s = %s\n", string, - devname(dev, S_IFCHR)); + devname(dev, + (special & CONSDEV) ? S_IFCHR : S_IFBLK)); else fprintf(stdout, "0x%x\n", dev); return; diff --git a/usr.sbin/sysctl/sysctl.c b/usr.sbin/sysctl/sysctl.c index 1d163e1579b4..1ce0453db2f7 100644 --- a/usr.sbin/sysctl/sysctl.c +++ b/usr.sbin/sysctl/sysctl.c @@ -40,7 +40,7 @@ static char copyright[] = #ifndef lint /*static char sccsid[] = "From: @(#)sysctl.c 8.1 (Berkeley) 6/6/93"; */ static const char rcsid[] = - "$Id: sysctl.c,v 1.3 1995/02/09 23:16:17 wollman Exp $"; + "$Id: sysctl.c,v 1.4 1995/02/16 00:28:42 wollman Exp $"; #endif /* not lint */ #include @@ -111,6 +111,7 @@ int Aflag, aflag, nflag, wflag; #define CLOCK 0x00000001 #define BOOTTIME 0x00000002 #define CONSDEV 0x00000004 +#define DUMPDEV 0x00000008 int main(argc, argv) @@ -274,6 +275,9 @@ parse(string, flags) case KERN_BOOTTIME: special |= BOOTTIME; break; + case KERN_DUMPDEV: + special |= DUMPDEV; + break; } break; @@ -391,12 +395,17 @@ parse(string, flags) fprintf(stdout, "%d\n", btp->tv_sec); return; } - if (special & CONSDEV) { + if (special & (CONSDEV | DUMPDEV)) { dev_t dev = *(dev_t *)buf; + if ((special & DUMPDEV) && dev == NODEV && !nflag) { + printf("%s = disabled\n", string); + return; + } if (!nflag) fprintf(stdout, "%s = %s\n", string, - devname(dev, S_IFCHR)); + devname(dev, + (special & CONSDEV) ? S_IFCHR : S_IFBLK)); else fprintf(stdout, "0x%x\n", dev); return;