View | Details | Raw Unified | Return to bug 23509
Collapse All | Expand All

(-)dev_mkdb.8 (-6 / +11 lines)
Lines 42-58 Link Here
42
database
42
database
43
.Sh SYNOPSIS
43
.Sh SYNOPSIS
44
.Nm dev_mkdb
44
.Nm dev_mkdb
45
.Op Fl f Ar file
46
.Op Ar directory
45
.Sh DESCRIPTION
47
.Sh DESCRIPTION
46
The
48
The
47
.Nm
49
.Nm
48
command creates a
50
command creates a
49
.Xr db 3
51
.Xr db 3
50
hash access method database in
52
hash access method database in
51
.Pa /var/run/dev.db
53
.Pa file
54
.Pf ( Fa /var/run/dev.db
55
by default)
52
which contains the names of all of the character and block special
56
which contains the names of all of the character and block special
53
files in the
57
files in
54
.Pa /dev
58
.Pa directory
55
directory, using the file type and the 
59
.Pf ( Fa /dev
60
by default), using the file type and the
56
.Fa st_rdev
61
.Fa st_rdev
57
field as the key.
62
field as the key.
58
.Pp
63
.Pp
Lines 63-71 Link Here
63
.Sh FILES
68
.Sh FILES
64
.Bl -tag -width /var/run/dev.db -compact
69
.Bl -tag -width /var/run/dev.db -compact
65
.It Pa /dev
70
.It Pa /dev
66
Device directory.
71
Default device directory.
67
.It Pa /var/run/dev.db
72
.It Pa /var/run/dev.db
68
Database file.
73
Default database file.
69
.El
74
.El
70
.Sh SEE ALSO
75
.Sh SEE ALSO
71
.Xr ps 1 ,
76
.Xr ps 1 ,
(-)dev_mkdb.c (-8 / +22 lines)
Lines 76-87 Link Here
76
	} bkey;
76
	} bkey;
77
	DB *db;
77
	DB *db;
78
	DBT data, key;
78
	DBT data, key;
79
	int ch;
79
	int ch, ndbname = 0;
80
	u_char buf[MAXNAMLEN + 1];
80
	u_char buf[MAXNAMLEN + 1];
81
	char dbtmp[MAXPATHLEN + 1], dbname[MAXPATHLEN + 1];
81
	char dbtmp[MAXPATHLEN + 1], dbname[MAXPATHLEN + 1], *dirname;
82
82
83
	while ((ch = getopt(argc, argv, "")) != -1)
83
	while ((ch = getopt(argc, argv, "f:")) != -1)
84
		switch((char)ch) {
84
		switch((char)ch) {
85
		case 'f':
86
			strlcpy(dbname, optarg, sizeof(dbname));
87
			ndbname = 1;
88
			break;
85
		case '?':
89
		case '?':
86
		default:
90
		default:
87
			usage();
91
			usage();
Lines 89-104 Link Here
89
	argc -= optind;
93
	argc -= optind;
90
	argv += optind;
94
	argv += optind;
91
95
92
	if (argc > 0)
96
	if (argc > 1)
93
		usage();
97
		usage();
98
	else if (argc == 1)
99
		dirname = argv[0];
100
	else
101
		dirname = _PATH_DEV;
94
102
95
	if (chdir(_PATH_DEV))
103
	if (!ndbname)
96
		err(1, "%s", _PATH_DEV);
104
	{
105
		(void)snprintf(dbname, sizeof(dbtmp), "%sdev.db", _PATH_VARRUN);
106
		(void)snprintf(dbtmp, sizeof(dbtmp), "%sdev.tmp", _PATH_VARRUN);
107
	}
108
	else
109
		(void)snprintf(dbtmp, sizeof(dbtmp), "%s.tmp", dbname);
97
110
111
	if (chdir(dirname))
112
		err(1, "%s", dirname);
113
98
	dirp = opendir(".");
114
	dirp = opendir(".");
99
115
100
	(void)snprintf(dbtmp, sizeof(dbtmp), "%sdev.tmp", _PATH_VARRUN);
101
	(void)snprintf(dbname, sizeof(dbtmp), "%sdev.db", _PATH_VARRUN);
102
	db = dbopen(dbtmp, O_CREAT|O_EXLOCK|O_RDWR|O_TRUNC,
116
	db = dbopen(dbtmp, O_CREAT|O_EXLOCK|O_RDWR|O_TRUNC,
103
	    S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, DB_HASH, NULL);
117
	    S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, DB_HASH, NULL);
104
	if (db == NULL)
118
	if (db == NULL)

Return to bug 23509