From 9b3a5c04f489ab22fa4a1913c89cf18546171f3b Mon Sep 17 00:00:00 2001 From: charnier Date: Wed, 17 Sep 1997 06:26:06 +0000 Subject: Use err(3) instead of local redefinition. --- usr.sbin/dev_mkdb/dev_mkdb.8 | 8 +++--- usr.sbin/dev_mkdb/dev_mkdb.c | 66 +++++++++++++------------------------------- 2 files changed, 23 insertions(+), 51 deletions(-) (limited to 'usr.sbin/dev_mkdb') diff --git a/usr.sbin/dev_mkdb/dev_mkdb.8 b/usr.sbin/dev_mkdb/dev_mkdb.8 index 9369b2b..5488a93 100644 --- a/usr.sbin/dev_mkdb/dev_mkdb.8 +++ b/usr.sbin/dev_mkdb/dev_mkdb.8 @@ -43,14 +43,14 @@ database .Nm dev_mkdb .Sh DESCRIPTION The -.Nm dev_mkdb +.Nm command creates a .Xr db 3 hash access method database in -.Dq Pa /var/run/dev.db +.Pa /var/run/dev.db which contains the names of all of the character and block special files in the -.Dq Pa /dev +.Pa /dev directory, using the file type and the .Fa st_rdev field as the key. @@ -76,6 +76,6 @@ Database file. .Xr kvm_mkdb 8 .Sh HISTORY The -.Nm dev_mkdb +.Nm command appeared in .Bx 4.4 . diff --git a/usr.sbin/dev_mkdb/dev_mkdb.c b/usr.sbin/dev_mkdb/dev_mkdb.c index 276db7e..ef113d1 100644 --- a/usr.sbin/dev_mkdb/dev_mkdb.c +++ b/usr.sbin/dev_mkdb/dev_mkdb.c @@ -32,33 +32,35 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1990, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint +#if 0 static char sccsid[] = "@(#)dev_mkdb.c 8.1 (Berkeley) 6/6/93"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ #include #include -#include -#undef DIRBLKSIZ +#include #include -#include +#include +#include #include -#include -#include -#include -#include +#include #include +#include #include #include +#include -void err __P((const char *, ...)); -void usage __P((void)); +static void usage __P((void)); int main(argc, argv) @@ -91,7 +93,7 @@ main(argc, argv) usage(); if (chdir(_PATH_DEV)) - err("%s: %s", _PATH_DEV, strerror(errno)); + err(1, "%s", _PATH_DEV); dirp = opendir("."); @@ -100,7 +102,7 @@ main(argc, argv) db = dbopen(dbtmp, O_CREAT|O_EXLOCK|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, DB_HASH, NULL); if (db == NULL) - err("%s: %s", dbtmp, strerror(errno)); + err(1, "%s", dbtmp); /* * Keys are a mode_t followed by a dev_t. The former is the type of @@ -112,10 +114,9 @@ main(argc, argv) key.data = &bkey; key.size = sizeof(bkey); data.data = buf; - while (dp = readdir(dirp)) { + while ((dp = readdir(dirp))) { if (lstat(dp->d_name, &sb)) { - (void)fprintf(stderr, - "dev_mkdb: %s: %s\n", dp->d_name, strerror(errno)); + warn("%s", dp->d_name); continue; } @@ -136,46 +137,17 @@ main(argc, argv) buf[dp->d_namlen] = '\0'; data.size = dp->d_namlen + 1; if ((db->put)(db, &key, &data, 0)) - err("dbput %s: %s\n", dbtmp, strerror(errno)); + err(1, "dbput %s", dbtmp); } (void)(db->close)(db); if (rename(dbtmp, dbname)) - err("rename %s to %s: %s", dbtmp, dbname, strerror(errno)); + err(1, "rename %s to %s", dbtmp, dbname); exit(0); } -void +static void usage() { (void)fprintf(stderr, "usage: dev_mkdb\n"); exit(1); } - -#if __STDC__ -#include -#else -#include -#endif - -void -#if __STDC__ -err(const char *fmt, ...) -#else -err(fmt, va_alist) - char *fmt; - va_dcl -#endif -{ - va_list ap; -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - (void)fprintf(stderr, "dev_mkdb: "); - (void)vfprintf(stderr, fmt, ap); - va_end(ap); - (void)fprintf(stderr, "\n"); - exit(1); - /* NOTREACHED */ -} -- cgit v1.1