summaryrefslogtreecommitdiffstats
path: root/usr.sbin/dev_mkdb
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-09-17 06:26:06 +0000
committercharnier <charnier@FreeBSD.org>1997-09-17 06:26:06 +0000
commit9b3a5c04f489ab22fa4a1913c89cf18546171f3b (patch)
tree4afe077078791b54aa22acfc20897c9cd4bba699 /usr.sbin/dev_mkdb
parent34a6b27326dc91b02abd2d076f78ebe1517503ae (diff)
downloadFreeBSD-src-9b3a5c04f489ab22fa4a1913c89cf18546171f3b.zip
FreeBSD-src-9b3a5c04f489ab22fa4a1913c89cf18546171f3b.tar.gz
Use err(3) instead of local redefinition.
Diffstat (limited to 'usr.sbin/dev_mkdb')
-rw-r--r--usr.sbin/dev_mkdb/dev_mkdb.88
-rw-r--r--usr.sbin/dev_mkdb/dev_mkdb.c66
2 files changed, 23 insertions, 51 deletions
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 <sys/param.h>
#include <sys/stat.h>
-#include <fcntl.h>
-#undef DIRBLKSIZ
+#include <db.h>
#include <dirent.h>
-#include <nlist.h>
+#include <err.h>
+#include <fcntl.h>
#include <kvm.h>
-#include <db.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdio.h>
+#include <nlist.h>
#include <paths.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
-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 <stdarg.h>
-#else
-#include <varargs.h>
-#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 */
-}
OpenPOWER on IntegriCloud