diff options
author | wollman <wollman@FreeBSD.org> | 1995-05-12 19:10:56 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 1995-05-12 19:10:56 +0000 |
commit | e7f4268dca67a63ab550ce0bc79e14eee95a7ff4 (patch) | |
tree | 7f4f1e7869f0ef6a717e8eed49251c2a0ca9d014 | |
parent | 56ee935a6308c4852acc11d2cad634c47d8dcdae (diff) | |
download | FreeBSD-src-e7f4268dca67a63ab550ce0bc79e14eee95a7ff4.zip FreeBSD-src-e7f4268dca67a63ab550ce0bc79e14eee95a7ff4.tar.gz |
Learn how to print out kern.dumpdev as a name.
-rw-r--r-- | sbin/sysctl/sysctl.c | 15 | ||||
-rw-r--r-- | 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 1d163e1..1ce0453 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 <sys/param.h> @@ -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 1d163e1..1ce0453 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 <sys/param.h> @@ -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; |