* Copyright (c) 1990 The Regents of the University of California.
* %sccs.include.redist.c%
"@(#) Copyright (c) 1990 The Regents of the University of California.\n\
static char sccsid
[] = "@(#)kvm_mkdb.c 5.12 (Berkeley) %G%";
#define basename(cp) ((tmp=rindex((cp), '/')) ? tmp+1 : (cp))
char *nlistpath
, *nlistname
, dbtemp
[MAXPATHLEN
], dbname
[MAXPATHLEN
];
while ((ch
= getopt(argc
, argv
, "")) != EOF
)
nlistpath
= argc
> 1 ? argv
[0] : _PATH_UNIX
;
nlistname
= basename(nlistpath
);
(void)sprintf(dbtemp
, "%s/kvm_%s.tmp", _PATH_VARRUN
, nlistname
);
(void)sprintf(dbname
, "%s/kvm_%s.db", _PATH_VARRUN
, nlistname
);
db
= dbopen(dbtemp
, O_CREAT
|O_WRONLY
|O_EXCL
,
S_IRUSR
|S_IWUSR
|S_IRGRP
|S_IROTH
, DB_HASH
, NULL
);
"kvm_mkdb: %s: %s\n", dbtemp
, strerror(errno
));
create_knlist(nlistpath
, db
);
if (rename(dbtemp
, dbname
)) {
(void)fprintf(stderr
, "kvm_mkdb: %s to %s: %s.\n",
dbtemp
, dbname
, strerror(errno
));
(void)fprintf(stderr
, "kvm_mkdb: ");
(void)fprintf(stderr
, "%s: ", n
);
(void)fprintf(stderr
, "%s\n", strerror(sverr
));
(void)fprintf(stderr
, "usage: kvm_mkdb [file]\n");