From 3b6f768ed2bd827b24eba463b3afe7802d24befb Mon Sep 17 00:00:00 2001 From: cgd Date: Sat, 12 Oct 1996 00:51:44 +0000 Subject: [PATCH] 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. --- usr.sbin/kvm_mkdb/kvm_mkdb.8 | 17 +++++++++-------- usr.sbin/kvm_mkdb/kvm_mkdb.c | 10 ++++------ usr.sbin/kvm_mkdb/testdb.c | 13 ++++--------- 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/usr.sbin/kvm_mkdb/kvm_mkdb.8 b/usr.sbin/kvm_mkdb/kvm_mkdb.8 index c23f0b6c5caa..4a1fa74fc76a 100644 --- a/usr.sbin/kvm_mkdb/kvm_mkdb.8 +++ b/usr.sbin/kvm_mkdb/kvm_mkdb.8 @@ -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 diff --git a/usr.sbin/kvm_mkdb/kvm_mkdb.c b/usr.sbin/kvm_mkdb/kvm_mkdb.c index 1421c5125e7f..bb40dfe98716 100644 --- a/usr.sbin/kvm_mkdb/kvm_mkdb.c +++ b/usr.sbin/kvm_mkdb/kvm_mkdb.c @@ -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); diff --git a/usr.sbin/kvm_mkdb/testdb.c b/usr.sbin/kvm_mkdb/testdb.c index 2de613d1889a..f65f15f7f17a 100644 --- a/usr.sbin/kvm_mkdb/testdb.c +++ b/usr.sbin/kvm_mkdb/testdb.c @@ -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 */