ANSI clenaups
SCCS-vsn: usr.sbin/dev_mkdb/dev_mkdb.c 5.8
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)dev_mkdb.c 5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)dev_mkdb.c 5.8 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
#include <fcntl.h>
#undef DIRBLKSIZ
#include <dirent.h>
#include <fcntl.h>
#undef DIRBLKSIZ
#include <dirent.h>
-struct nlist; /* XXX bletch */
#include <kvm.h>
#include <db.h>
#include <errno.h>
#include <kvm.h>
#include <db.h>
#include <errno.h>
#include <stdio.h>
#include <paths.h>
#include <stdio.h>
#include <paths.h>
+static void error(), usage();
+
main(argc, argv)
int argc;
char **argv;
main(argc, argv)
int argc;
char **argv;
register DIR *dirp;
register struct dirent *dp;
struct stat sb;
register DIR *dirp;
register struct dirent *dp;
struct stat sb;
- char bkeybuf[sizeof(sb.st_rdev) + 1];
+ struct {
+ mode_t type;
+ dev_t dev;
+ } bkey;
DB *db;
DBT data, key;
int ch;
DB *db;
DBT data, key;
int ch;
- * Character devices are stored using st_rdev as the key.
- * Block devices are stores using st_rdev followed by exactly
- * one NULL byte as the key.
+ * Keys are a mode_t followed by a dev_t. The former is the type of
+ * the file (mode & S_IFMT), the latter is the st_rdev field.
- key.data = bkeybuf;
- bkeybuf[sizeof(sb.st_rdev)] = NULL;
+ key.data = &bkey;
+ key.size = sizeof(bkey);
data.data = buf;
while (dp = readdir(dirp)) {
if (stat(dp->d_name, &sb)) {
data.data = buf;
while (dp = readdir(dirp)) {
if (stat(dp->d_name, &sb)) {
+
+ /* Create the key. */
- key.size = sizeof(sb.st_rdev);
else if (S_ISBLK(sb.st_mode))
else if (S_ISBLK(sb.st_mode))
- key.size = sizeof(sb.st_rdev) + 1;
- bcopy(&sb.st_rdev, bkeybuf, sizeof(sb.st_rdev));
- /*
- * Nul terminate the name so caller doesn't have to.
+ bkey.dev = sb.st_rdev;
+
+ /*
+ * Create the data; nul terminate the name so caller doesn't
+ * have to.
*/
bcopy(dp->d_name, buf, dp->d_namlen);
buf[dp->d_namlen] = '\0';
*/
bcopy(dp->d_name, buf, dp->d_namlen);
buf[dp->d_namlen] = '\0';
usage()
{
(void)fprintf(stderr, "usage: dev_mkdb\n");
usage()
{
(void)fprintf(stderr, "usage: dev_mkdb\n");