Create only /var/db/kvm.db, and only create it if it doesn't

already match the running kernel.  Fixes an inconsistency
where /var/db/kvm_filename.db would be created, but only
if /var/db/kvm_netbsd.db didn't match the running kernel.
This commit is contained in:
cgd 1996-10-12 00:51:44 +00:00
parent e79d25e2e9
commit 3b6f768ed2
3 changed files with 17 additions and 23 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: kvm_mkdb.8,v 1.7 1996/09/30 18:27:00 thorpej Exp $
.\" $NetBSD: kvm_mkdb.8,v 1.8 1996/10/12 00:51:44 cgd Exp $
.\"
.\" Copyright (c) 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -44,24 +44,25 @@
.Op file
.Sh DESCRIPTION
.Nm Kvm_mkdb
creates a database in
.Pa /var/db
creates a database,
.Pa /var/db/kvm.db ,
containing information about the specified file.
If no file is specified,
.Pa /netbsd
is used by default.
The file is named ``kvm_filename.db'', where ``filename'' is the
name of the file read.
The database will only be recreated if its contents
do not already describe the running kernel.
.Pp
Various library routines consult this database.
The only information currently stored is the kernel namelist, which is
used by the
.Xr kvm_nlist 3
function, however, in the future the database may contain other static
function. In the future, the database may contain other static
information about the current system.
.Sh FILES
.Bl -tag -width /var/db/kvm_netbsd.db -compact
.Bl -tag -width /var/db/kvm.db -compact
.It Pa /netbsd
.It Pa /var/db/kvm_netbsd.db
.It Pa /var/db/kvm.db
.El
.Sh SEE ALSO
.Xr kvm_nlist 3

View File

@ -1,4 +1,4 @@
/* $NetBSD: kvm_mkdb.c,v 1.11 1996/09/30 19:48:44 cgd Exp $ */
/* $NetBSD: kvm_mkdb.c,v 1.12 1996/10/12 00:51:45 cgd Exp $ */
/*-
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "from: @(#)kvm_mkdb.c 8.3 (Berkeley) 5/4/95";
#else
static char *rcsid = "$NetBSD: kvm_mkdb.c,v 1.11 1996/09/30 19:48:44 cgd Exp $";
static char *rcsid = "$NetBSD: kvm_mkdb.c,v 1.12 1996/10/12 00:51:45 cgd Exp $";
#endif
#endif /* not lint */
@ -105,10 +105,8 @@ main(argc, argv)
nlistpath = argc > 0 ? argv[0] : _PATH_UNIX;
nlistname = basename(nlistpath);
(void)snprintf(dbtemp, sizeof(dbtemp), "%skvm_%s.tmp",
_PATH_VARDB, nlistname);
(void)snprintf(dbname, sizeof(dbname), "%skvm_%s.db",
_PATH_VARDB, nlistname);
(void)snprintf(dbname, sizeof(dbname), "%s", _PATH_KVMDB);
(void)snprintf(dbtemp, sizeof(dbtemp), "%s.tmp", _PATH_KVMDB);
(void)umask(0);
db = dbopen(dbtemp, O_CREAT | O_EXLOCK | O_TRUNC | O_RDWR,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, DB_HASH, &openinfo);

View File

@ -1,4 +1,4 @@
/* $NetBSD: testdb.c,v 1.3 1996/09/30 18:27:04 thorpej Exp $ */
/* $NetBSD: testdb.c,v 1.4 1996/10/12 00:51:46 cgd Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "from: @(#)testdb.c 8.1 (Berkeley) 6/6/93";
#else
static char *rcsid = "$NetBSD: testdb.c,v 1.3 1996/09/30 18:27:04 thorpej Exp $";
static char *rcsid = "$NetBSD: testdb.c,v 1.4 1996/10/12 00:51:46 cgd Exp $";
#endif
#endif /* not lint */
@ -60,10 +60,9 @@ testdb()
{
register DB *db;
register int cc, kd, ret, dbversionlen;
register char *cp, *uf;
DBT rec;
struct nlist nitem;
char dbname[MAXPATHLEN], dbversion[_POSIX2_LINE_MAX];
char dbversion[_POSIX2_LINE_MAX];
char kversion[_POSIX2_LINE_MAX];
ret = 0;
@ -72,11 +71,7 @@ testdb()
if ((kd = open(_PATH_KMEM, O_RDONLY, 0)) < 0)
goto close;
uf = _PATH_UNIX;
if ((cp = rindex(uf, '/')) != 0)
uf = cp + 1;
(void) snprintf(dbname, sizeof(dbname), "%skvm_%s.db", _PATH_VARDB, uf);
if ((db = dbopen(dbname, O_RDONLY, 0, DB_HASH, NULL)) == NULL)
if ((db = dbopen(_PATH_KVMDB, O_RDONLY, 0, DB_HASH, NULL)) == NULL)
goto close;
/* Read the version out of the database */