make config -x look at the booted kernel first.
This commit is contained in:
parent
8588929dc5
commit
8aaed51273
|
@ -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
|
.\" Copyright (c) 1980, 1991, 1993
|
||||||
.\" The Regents of the University of California. All rights reserved.
|
.\" The Regents of the University of California. All rights reserved.
|
||||||
|
@ -71,9 +71,17 @@ flag), then extracts the embedded configuration file (if any) and
|
||||||
writes it to standard output.
|
writes it to standard output.
|
||||||
If
|
If
|
||||||
.Ar kernel-file
|
.Ar kernel-file
|
||||||
is not given,
|
is not given, and the system is not running
|
||||||
.Pa /netbsd
|
.Nx
|
||||||
is used.
|
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
|
Configuration data will be available if the given kernel was compiled
|
||||||
with either
|
with either
|
||||||
.Va INCLUDE_CONFIG_FILE
|
.Va INCLUDE_CONFIG_FILE
|
||||||
|
|
|
@ -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
|
* Copyright (c) 1992, 1993
|
||||||
|
@ -60,6 +60,9 @@ COPYRIGHT("@(#) Copyright (c) 1992, 1993\
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#ifdef __NetBSD__
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#endif
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <err.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");
|
errx(EXIT_FAILURE, "-L can only be used with -s and -v");
|
||||||
|
|
||||||
if (xflag) {
|
if (xflag) {
|
||||||
|
if (argc == 0) {
|
||||||
#ifdef __NetBSD__
|
#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
|
#else
|
||||||
if (argc == 0)
|
|
||||||
errx(EXIT_FAILURE, "no kernel supplied");
|
errx(EXIT_FAILURE, "no kernel supplied");
|
||||||
#endif
|
#endif
|
||||||
|
} else
|
||||||
|
conffile = argv[0];
|
||||||
if (!is_elf(conffile))
|
if (!is_elf(conffile))
|
||||||
errx(EXIT_FAILURE, "%s: not a binary kernel",
|
errx(EXIT_FAILURE, "%s: not a binary kernel",
|
||||||
conffile);
|
conffile);
|
||||||
|
|
Loading…
Reference in New Issue