1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
|
.\" $NetBSD: MAKEDEV.8.template,v 1.21 2017/02/13 19:49:06 abhinav Exp $
.\"
.\" Copyright (c) 2001, 2003, 2007, 2008 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Thomas Klausner.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd @@@DATE@@@
.Dt MAKEDEV 8
.Os
.Sh NAME
.Nm MAKEDEV
.Nd create system and device special files
.Sh SYNOPSIS
.\" Please keep this in sync with MAKEDEV.local.8
.Nm
.Op Fl fMsu
.Op Fl m Ar mknod
.Op Fl p Ar pax
.Op Fl t Ar mtree
.Bro Ar special | device Brc Op Ar ...
.Sh DESCRIPTION
.Nm
is used to create system and device special files.
As arguments it takes the names of known devices, like
.Ar sd0 ,
or of special targets, like
.Pa all
or
.Pa std ,
which create a collection of device special files,
or
.Pa local ,
which invokes
.Xr MAKEDEV.local 8
with the
.Pa all
argument.
.Pp
The script is in
.Pa /dev/MAKEDEV .
Devices are created in the current working directory;
in normal use,
.Nm
should be invoked with
.Pa /dev
as the current working directory.
.Pp
Supported options are:
.Bl -tag -width XmXmknodXX
.It Fl f
Force permissions to be updated on existing devices.
This works only if
.Nm
invokes
.Xr mknod 8 ;
it is not compatible with the
.Fl p ,
.Fl s ,
or
.Fl t
options.
.It Fl M
Create a memory file system, union mounted over the current directory,
to contain the device special files.
The memory file system is created using
.Xr mount_tmpfs 8
or
.Xr mount_mfs 8 ,
in that order of preference.
.Pp
If the
.Fl M
flag is specified more than once, then
.Nm
assumes that it is being invoked from
.Xr init 8
to populate a memory file system for
.Pa /dev .
In this case,
.Nm
will also redirect its output to the system console.
.It Fl m Ar mknod
Force the use of
.Xr mknod 8 ,
and specify the name or path to the
.Xr mknod 8
program.
[Usually, $TOOL_MKNOD or mknod.]
.It Fl p Ar pax
Force the use of
.Xr pax 1 ,
and specify the name or path to the
.Xr pax 1
program.
[Usually, $TOOL_PAX or pax.]
.It Fl s
Generate an
.Xr mtree 8
specfile instead of creating devices.
.It Fl t Ar mtree
Force the use of
.Xr mtree 8 ,
and specify the name or path to the
.Xr mtree 8
program.
[Usually, $TOOL_MTREE or mtree.]
.It Fl u
Don't re-create devices that already exist.
.El
.Pp
.Nm
has several possible methods of creating device nodes:
.Bl -bullet
.It
By invoking the
.Xr mknod 8
command once for each device node.
This is the traditional method, but it is slow because each device node
is created using a new process.
.Pp
The
.Fl m
option forces
.Nm
to use the
.Xr mknod 8
method.
.It
By internally creating a specfile in a format usable by
.Xr mtree 8 ,
and providing the specfile on standard input to a
.Xr pax 1
or
.Xr mtree 8
command, invoked with options that request it to create the device nodes
as well as any necessary subdirectories.
This is much faster than creating device nodes with
.Xr mknod 8 ,
because it requires much fewer processes;
however, it's not compatible with the
.Fl f
option.
.Pp
The
.Fl p
or
.Fl t
options force
.Nm
to use the
.Xr pax 1
or
.Xr mtree 8
methods.
.It
If the
.Fl s
option is specified, then
.Nm
will not create device nodes at all, but will output
a specfile in a format usable by
.Xr mtree 8 .
.El
.Pp
The
.Fl m , Fl p , Fl s ,
and
.Fl t
flags are mutually exclusive.
If none of these flags is specified, then
.Nm
will use
.Xr mtree 8 ,
.Xr pax 1 ,
or
.Xr mknod 8 ,
in that order of preference, depending on which commands
appear to be available and usable.
In normal use, it's expected that
.Xr mtree 8
will be available, so it will be chosen.
If
.Nm
is invoked by
.Xr init 8 ,
it's expected that
.Xr mtree 8
will not be available, but
.Xr pax 1
may be available.
.Pp
The special targets supported on
.Nx
are:
.Pp
@@@SPECIAL@@@
.Pp
Please note that any hash marks
.Pq Dq #
in the following list of supported device targets must be replaced by
digits when calling
.Nm :
.Pp
@@@DEVICES@@@
.Sh ENVIRONMENT
The following environment variables affect the execution of
.Nm :
.Pp
.Bl -tag -width indent
.It Ev MAKEDEV_AS_LIBRARY
If this is set, then
.Nm
will define several shell functions and then return,
ignoring all its command line options and arguments.
This is used to enable
.Xr MAKEDEV.local 8
to use the shell functions defined in
.Nm .
.El
.Sh FILES
.Bl -tag -width "/dev/MAKEDEV.local" -compact
.It Pa /dev
special device files directory
.It Pa /dev/MAKEDEV
script described in this man page
.It Pa /dev/MAKEDEV.local
script for site-specific devices
.El
.Sh DIAGNOSTICS
If the script reports an error that is difficult to understand,
you can get more debugging output by using
.Dl Ic sh Fl x Ar MAKEDEV Ar argument .
.Sh SEE ALSO
.Xr config 1 ,
.Xr pax 1 ,
.Xr intro 4 ,
.Xr diskless 8 ,
.Xr init 8 ,
.Xr MAKEDEV.local 8 ,
.Xr mknod 8 ,
.Xr mount_mfs 8 ,
.Xr mount_tmpfs 8 ,
.Xr mtree 8
.Sh HISTORY
The
.Nm
command appeared in
.Bx 4.2 .
The
.Fl f ,
.Fl m ,
and
.Fl s
options were added in
.Nx 2.0 .
The
.Fl p ,
.Fl t ,
and
.Fl M
options were added in
.Nx 5.0 .
The ability to be used as a function library was added in
.Nx 5.0 .
.Sh BUGS
The
.Fl f
option is not compatible with the use of
.Xr mtree 8
or
.Xr pax 1 .
.Sh NOTES
Not all devices listed in this manpage are supported on all platforms.
.Pp
This man page is generated automatically from the same sources
as
.Pa /dev/MAKEDEV ,
in which the device files are not always sorted, which may result
in an unusual (non-alphabetical) order.
.Pp
In order to allow a diskless
.Nx
client to obtain its
.Pa /dev
directory from a file server running a foreign operating system,
one of the following techniques may be useful to populate
a directory of device nodes on the foreign server:
.Bl -bullet
.It
If the foreign server is sufficiently similar to
.Nx ,
run
.Nm
in an appropriate directory of the foreign server,
using the
.Fl m
flag to refer to a script that converts from command line
arguments that would be usable with the
.Nx
.Xr mknod 8
command to the equivalent commands for the foreign server.
.It
Run
.Nm
with the
.Fl s
flag to generate an
.Xr mtree 8
specification file; this can be done on any host with a
POSIX-compliant shell and a few widely-available utilities.
Use the
.Xr pax 1
command with the
.Fl w Fl M
flags to convert the
.Xr mtree 8
specification file into an archive
in a format that supports device nodes
(such as
.Ar ustar
format);
this can be done on a
.Nx
host, or can be done in a cross-build environment using
.Sy TOOLDIR Ns Pa /bin/nbpax .
Finally, use appropriate tools on the foreign server
to unpack the archive and create the device nodes.
.El
|