Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/config make config -x look at the booted kernel first.
details: https://anonhg.NetBSD.org/src/rev/83a9ca068e9b
branches: trunk
changeset: 781283:83a9ca068e9b
user: christos <christos%NetBSD.org@localhost>
date: Thu Aug 30 12:31:25 2012 +0000
description:
make config -x look at the booted kernel first.
diffstat:
usr.bin/config/config.1 | 16 ++++++++++++----
usr.bin/config/main.c | 17 ++++++++++++++---
2 files changed, 26 insertions(+), 7 deletions(-)
diffs (72 lines):
diff -r 92aca9d3bc91 -r 83a9ca068e9b usr.bin/config/config.1
--- a/usr.bin/config/config.1 Thu Aug 30 12:16:48 2012 +0000
+++ b/usr.bin/config/config.1 Thu Aug 30 12:31:25 2012 +0000
@@ -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 @@
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
diff -r 92aca9d3bc91 -r 83a9ca068e9b usr.bin/config/main.c
--- a/usr.bin/config/main.c Thu Aug 30 12:16:48 2012 +0000
+++ b/usr.bin/config/main.c Thu Aug 30 12:31:25 2012 +0000
@@ -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 @@
#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 @@
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);
Home |
Main Index |
Thread Index |
Old Index