summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/paths.h9
-rw-r--r--lib/libkvm/kvm.c2
-rw-r--r--lib/libkvm/kvm_open.35
-rw-r--r--sbin/savecore/savecore.815
-rw-r--r--sbin/savecore/savecore.c25
-rw-r--r--usr.bin/systat/disks.c2
-rw-r--r--usr.bin/systat/mbufs.c2
-rw-r--r--usr.sbin/kgmon/kgmon.c2
-rw-r--r--usr.sbin/kvm_mkdb/kvm_mkdb.c2
-rw-r--r--usr.sbin/kvm_mkdb/testdb.c2
-rw-r--r--usr.sbin/trpt/trpt.c2
-rw-r--r--usr.sbin/trsp/trsp.c2
-rw-r--r--usr.sbin/xntpd/util/tickadj.c6
13 files changed, 40 insertions, 36 deletions
diff --git a/include/paths.h b/include/paths.h
index ecba76c..ffeab09 100644
--- a/include/paths.h
+++ b/include/paths.h
@@ -36,6 +36,8 @@
#ifndef _PATHS_H_
#define _PATHS_H_
+#include <sys/cdefs.h>
+
/* Default search path. */
#define _PATH_DEFPATH "/usr/bin:/bin"
/* All standard utilities path. */
@@ -56,7 +58,7 @@
#define _PATH_SENDMAIL "/usr/sbin/sendmail"
#define _PATH_SHELLS "/etc/shells"
#define _PATH_TTY "/dev/tty"
-#define _PATH_UNIX "/kernel"
+#define _PATH_UNIX "don't use _PATH_UNIX"
#define _PATH_VI "/usr/bin/vi"
/* Provide trailing slash, since mostly used for building pathnames. */
@@ -66,4 +68,9 @@
#define _PATH_VARRUN "/var/run/"
#define _PATH_VARTMP "/var/tmp/"
+/* How to get the correct name of the kernel. */
+__BEGIN_DECLS
+const char *getbootfile __P((void));
+__END_DECLS
+
#endif /* !_PATHS_H_ */
diff --git a/lib/libkvm/kvm.c b/lib/libkvm/kvm.c
index 56ab485..b8d342b 100644
--- a/lib/libkvm/kvm.c
+++ b/lib/libkvm/kvm.c
@@ -182,7 +182,7 @@ _kvm_open(kd, uf, mf, sf, flag, errout)
kd->argv = 0;
if (uf == 0)
- uf = _PATH_UNIX;
+ uf = getbootfile();
else if (strlen(uf) >= MAXPATHLEN) {
_kvm_err(kd, kd->program, "exec file name too long");
goto failed;
diff --git a/lib/libkvm/kvm_open.3 b/lib/libkvm/kvm_open.3
index dd6895b..7e604a1 100644
--- a/lib/libkvm/kvm_open.3
+++ b/lib/libkvm/kvm_open.3
@@ -70,9 +70,8 @@ This file must contain a symbol table.
If this argument is
.Dv NULL ,
the currently running system is assumed,
-which is indicated by
-.Dv _PATH_UNIX
-in <paths.h>.
+as determined from
+.Xr getbootfile 3 .
.Pp
.Fa corefile
is the kernel memory device file. It can be either /dev/mem
diff --git a/sbin/savecore/savecore.8 b/sbin/savecore/savecore.8
index 3fca145..47e0a34 100644
--- a/sbin/savecore/savecore.8
+++ b/sbin/savecore/savecore.8
@@ -29,9 +29,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)savecore.8 8.1 (Berkeley) 6/5/93
+.\" From: @(#)savecore.8 8.1 (Berkeley) 6/5/93
+.\" $Id$
.\"
-.Dd June 5, 1993
+.Dd September 23, 1994
.Dt SAVECORE 8
.Os BSD 4
.Sh NAME
@@ -63,7 +64,8 @@ is insufficient disk space.
.It Fl N
Use
.Ar system
-as the kernel instead of the default ``/kernel''.
+as the kernel instead of the running kernel (as determined from
+.Xr getbootfile 3 )
.It Fl v
Prints out some additional debugging information.
.It Fl z
@@ -106,16 +108,11 @@ is meant to be called near the end of the initialization file
.Pa /etc/rc
(see
.Xr rc 8 ) .
-.Sh FILES
-.Bl -tag -width /kernelxx -compact
-.It Pa /kernel
-current
-.Tn UNIX
-.El
.Sh BUGS
The minfree code does not consider the effect of compression.
.Sh SEE ALSO
.Xr compress 1 ,
+.Xr getbootfile 3 ,
.Xr syslogd 8
.Sh HISTORY
The
diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c
index 59e0ff5..2c69001 100644
--- a/sbin/savecore/savecore.c
+++ b/sbin/savecore/savecore.c
@@ -121,7 +121,7 @@ int get_crashtime __P((void));
void kmem_setup __P((void));
void log __P((int, char *, ...));
void Lseek __P((int, off_t, int));
-int Open __P((char *, int rw));
+int Open __P((const char *, int rw));
int Read __P((int, void *, int));
char *rawname __P((char *s));
void save_core __P((void));
@@ -202,7 +202,7 @@ kmem_setup()
{
FILE *fp;
int kmem, i;
- char *dump_sys;
+ const char *dump_sys;
/*
* Some names we need for the currently running system, others for
@@ -212,16 +212,17 @@ kmem_setup()
* presumed to be the same (since the disk partitions are probably
* the same!)
*/
- if ((nlist(_PATH_UNIX, current_nl)) == -1)
- syslog(LOG_ERR, "%s: nlist: %s", _PATH_UNIX, strerror(errno));
+ if ((nlist(getbootfile(), current_nl)) == -1)
+ syslog(LOG_ERR, "%s: nlist: %s", getbootfile(),
+ strerror(errno));
for (i = 0; cursyms[i] != -1; i++)
if (current_nl[cursyms[i]].n_value == 0) {
syslog(LOG_ERR, "%s: %s not in namelist",
- _PATH_UNIX, current_nl[cursyms[i]].n_name);
+ getbootfile(), current_nl[cursyms[i]].n_name);
exit(1);
}
- dump_sys = kernel ? kernel : _PATH_UNIX;
+ dump_sys = kernel ? kernel : getbootfile();
if ((nlist(dump_sys, dump_nl)) == -1)
syslog(LOG_ERR, "%s: nlist: %s", dump_sys, strerror(errno));
for (i = 0; dumpsyms[i] != -1; i++)
@@ -278,7 +279,7 @@ check_kmem()
if (strcmp(vers, core_vers) && kernel == 0)
syslog(LOG_WARNING,
"warning: %s version mismatch:\n\t%s\nand\t%s\n",
- _PATH_UNIX, vers, core_vers);
+ getbootfile(), vers, core_vers);
(void)fseek(fp,
(off_t)(dumplo + ok(dump_nl[X_PANICSTR].n_value)), L_SET);
(void)fread(&panicstr, sizeof(panicstr), 1, fp);
@@ -413,7 +414,7 @@ err2: syslog(LOG_WARNING,
(void)close(ofd);
/* Copy the kernel. */
- ifd = Open(kernel ? kernel : _PATH_UNIX, O_RDONLY);
+ ifd = Open(kernel ? kernel : getbootfile(), O_RDONLY);
(void)snprintf(path, sizeof(path), "%s/kernel.%d%s",
dirname, bounds, compress ? ".Z" : "");
if (compress) {
@@ -440,7 +441,7 @@ err2: syslog(LOG_WARNING,
}
if (nr < 0) {
syslog(LOG_ERR, "%s: %s",
- kernel ? kernel : _PATH_UNIX, strerror(errno));
+ kernel ? kernel : getbootfile(), strerror(errno));
syslog(LOG_WARNING,
"WARNING: kernel may be incomplete");
exit(1);
@@ -532,13 +533,13 @@ int
check_space()
{
register FILE *fp;
- char *tkernel;
+ const char *tkernel;
off_t minfree, spacefree, kernelsize, needed;
struct stat st;
struct statfs fsbuf;
char buf[100], path[MAXPATHLEN];
- tkernel = kernel ? kernel : _PATH_UNIX;
+ tkernel = kernel ? kernel : getbootfile();
if (stat(tkernel, &st) < 0) {
syslog(LOG_ERR, "%s: %m", tkernel);
exit(1);
@@ -575,7 +576,7 @@ check_space()
int
Open(name, rw)
- char *name;
+ const char *name;
int rw;
{
int fd;
diff --git a/usr.bin/systat/disks.c b/usr.bin/systat/disks.c
index 24606a3..5cb5c4d 100644
--- a/usr.bin/systat/disks.c
+++ b/usr.bin/systat/disks.c
@@ -110,7 +110,7 @@ dkinit()
}
NREAD(X_DK_NDRIVE, &dk_ndrive, LONG);
if (dk_ndrive <= 0) {
- error("dk_ndrive=%d according to %s", dk_ndrive, _PATH_UNIX);
+ error("dk_ndrive=%d according to %s", dk_ndrive, getbootfile());
return(0);
}
dk_mspw = (float *)calloc(dk_ndrive, sizeof (float));
diff --git a/usr.bin/systat/mbufs.c b/usr.bin/systat/mbufs.c
index 4b5ca66..8056f45 100644
--- a/usr.bin/systat/mbufs.c
+++ b/usr.bin/systat/mbufs.c
@@ -145,7 +145,7 @@ initmbufs()
return(0);
}
if (namelist[X_MBSTAT].n_type == 0) {
- error("namelist on %s failed", _PATH_UNIX);
+ error("namelist on %s failed", getbootfile());
return(0);
}
}
diff --git a/usr.sbin/kgmon/kgmon.c b/usr.sbin/kgmon/kgmon.c
index 1265ce2..cf75723 100644
--- a/usr.sbin/kgmon/kgmon.c
+++ b/usr.sbin/kgmon/kgmon.c
@@ -134,7 +134,7 @@ main(int argc, char **argv)
}
#endif
if (system == NULL)
- system = _PATH_UNIX;
+ system = (char *)getbootfile();
accessmode = openfiles(system, kmemf, &kvmvars);
mode = getprof(&kvmvars);
if (hflag)
diff --git a/usr.sbin/kvm_mkdb/kvm_mkdb.c b/usr.sbin/kvm_mkdb/kvm_mkdb.c
index f80b109..2315352 100644
--- a/usr.sbin/kvm_mkdb/kvm_mkdb.c
+++ b/usr.sbin/kvm_mkdb/kvm_mkdb.c
@@ -83,7 +83,7 @@ main(argc, argv)
exit(0);
#define basename(cp) ((p = rindex((cp), '/')) != NULL ? p + 1 : (cp))
- nlistpath = argc > 0 ? argv[0] : _PATH_UNIX;
+ nlistpath = argc > 0 ? argv[0] : (char *)getbootfile();
nlistname = basename(nlistpath);
(void)snprintf(dbtemp, sizeof(dbtemp), "%skvm_%s.tmp",
diff --git a/usr.sbin/kvm_mkdb/testdb.c b/usr.sbin/kvm_mkdb/testdb.c
index f4f3bf0..fe4581e 100644
--- a/usr.sbin/kvm_mkdb/testdb.c
+++ b/usr.sbin/kvm_mkdb/testdb.c
@@ -66,7 +66,7 @@ testdb()
if ((kd = open(_PATH_KMEM, O_RDONLY, 0)) < 0)
goto close;
- uf = _PATH_UNIX;
+ uf = (char *)getbootfile();
if ((cp = rindex(uf, '/')) != 0)
uf = cp + 1;
(void) snprintf(dbname, sizeof(dbname), "%skvm_%s.db", _PATH_VARDB, uf);
diff --git a/usr.sbin/trpt/trpt.c b/usr.sbin/trpt/trpt.c
index 7452cdd..ef18570 100644
--- a/usr.sbin/trpt/trpt.c
+++ b/usr.sbin/trpt/trpt.c
@@ -164,7 +164,7 @@ main(argc, argv)
setgid(getgid());
}
else
- system = _PATH_UNIX;
+ system = (char *)getbootfile();
if (nlist(system, nl) < 0 || !nl[0].n_value) {
fprintf(stderr, "trpt: %s: no namelist\n", system);
diff --git a/usr.sbin/trsp/trsp.c b/usr.sbin/trsp/trsp.c
index c2c0267..7548c58 100644
--- a/usr.sbin/trsp/trsp.c
+++ b/usr.sbin/trsp/trsp.c
@@ -95,7 +95,7 @@ main(argc, argv)
int i, mask = 0, npcbs = 0;
char *system, *core;
- system = _PATH_UNIX;
+ system = (char *)getbootfile();
core = _PATH_KMEM;
argc--, argv++;
diff --git a/usr.sbin/xntpd/util/tickadj.c b/usr.sbin/xntpd/util/tickadj.c
index 1d7ba66..9bc8f35 100644
--- a/usr.sbin/xntpd/util/tickadj.c
+++ b/usr.sbin/xntpd/util/tickadj.c
@@ -420,9 +420,9 @@ getoffsets(filex, tick_off, tickadj_off, dosync_off, noprintf_off)
{""},
};
#endif
- static char *kernels[] = {
-#ifdef _PATH_UNIX
- _PATH_UNIX,
+ char *kernels[] = {
+#if __FreeBSD__ > 2
+ (char *)getbootfile(),
#endif
"/vmunix",
"/unix",
OpenPOWER on IntegriCloud