Module Name: src Committed By: christos Date: Thu Aug 30 12:31:26 UTC 2012
Modified Files: src/usr.bin/config: config.1 main.c Log Message: make config -x look at the booted kernel first. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/usr.bin/config/config.1 cvs rdiff -u -r1.47 -r1.48 src/usr.bin/config/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/config/config.1 diff -u src/usr.bin/config/config.1:1.10 src/usr.bin/config/config.1:1.11 --- src/usr.bin/config/config.1:1.10 Mon Aug 31 03:45:24 2009 +++ src/usr.bin/config/config.1 Thu Aug 30 08:31:25 2012 @@ -1,4 +1,4 @@ -.\" $NetBSD: config.1,v 1.10 2009/08/31 07:45:24 wiz Exp $ +.\" $NetBSD: config.1,v 1.11 2012/08/30 12:31:25 christos Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -71,9 +71,17 @@ flag), then extracts the embedded config writes it to standard output. If .Ar kernel-file -is not given, -.Pa /netbsd -is used. +is not given, and the system is not running +.Nx +an error is printed. +On systems running +.Nx +the booted kernel is looked up using the +.Xr sysctl 3 +.Dv machdep.booted_kernel +variable and if that's not found, +.Dv _PATH_UNIX +(/netbsd) is used. Configuration data will be available if the given kernel was compiled with either .Va INCLUDE_CONFIG_FILE Index: src/usr.bin/config/main.c diff -u src/usr.bin/config/main.c:1.47 src/usr.bin/config/main.c:1.48 --- src/usr.bin/config/main.c:1.47 Sun Mar 11 22:58:55 2012 +++ src/usr.bin/config/main.c Thu Aug 30 08:31:25 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.47 2012/03/12 02:58:55 dholland Exp $ */ +/* $NetBSD: main.c,v 1.48 2012/08/30 12:31:25 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -60,6 +60,9 @@ COPYRIGHT("@(#) Copyright (c) 1992, 1993 #include <sys/stat.h> #include <sys/param.h> #include <sys/mman.h> +#ifdef __NetBSD__ +#include <sys/sysctl.h> +#endif #include <paths.h> #include <ctype.h> #include <err.h> @@ -230,12 +233,20 @@ main(int argc, char **argv) errx(EXIT_FAILURE, "-L can only be used with -s and -v"); if (xflag) { + if (argc == 0) { #ifdef __NetBSD__ - conffile = (argc == 1) ? argv[0] : _PATH_UNIX; + char path_unix[MAXPATHLEN]; + size_t len = sizeof(path_unix) - 1; + path_unix[0] = '/'; + + conffile = sysctlbyname("machdep.booted_kernel", + &path_unix[1], &len, NULL, 0) == -1 ? _PATH_UNIX : + path_unix; #else - if (argc == 0) errx(EXIT_FAILURE, "no kernel supplied"); #endif + } else + conffile = argv[0]; if (!is_elf(conffile)) errx(EXIT_FAILURE, "%s: not a binary kernel", conffile);