* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
* %sccs.include.redist.c%
static char copyright
[] =
"@(#) Copyright (c) 1990, 1993\n\
The Regents of the University of California. All rights reserved.\n";
static char sccsid
[] = "@(#)kvm_mkdb.c 8.1 (Berkeley) %G%";
static void usage
__P((void));
char *p
, *nlistpath
, *nlistname
, dbtemp
[MAXPATHLEN
], dbname
[MAXPATHLEN
];
while ((ch
= getopt(argc
, argv
, "")) != EOF
)
/* If the existing db file matches the currently running kernel, exit */
#define basename(cp) ((p = rindex((cp), '/')) != NULL ? p + 1 : (cp))
nlistpath
= argc
> 0 ? argv
[0] : _PATH_UNIX
;
nlistname
= basename(nlistpath
);
(void)snprintf(dbtemp
, sizeof(dbtemp
), "%skvm_%s.tmp",
(void)snprintf(dbname
, sizeof(dbname
), "%skvm_%s.db",
db
= dbopen(dbtemp
, O_CREAT
| O_EXLOCK
| O_TRUNC
| O_RDWR
,
S_IRUSR
| S_IWUSR
| S_IRGRP
| S_IROTH
, DB_HASH
, NULL
);
create_knlist(nlistpath
, db
);
if (rename(dbtemp
, dbname
))
err(1, "rename %s to %s", dbtemp
, dbname
);
(void)fprintf(stderr
, "usage: kvm_mkdb [file]\n");