1
+ .\"
2
+ .\" SPDX-License-Identifier: BSD-2-Clause
3
+ .\"
1
4
.\" Copyright (c) 1999 Chris Costello
2
5
.\" All rights reserved.
3
6
.\"
22
25
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23
26
.\" SUCH DAMAGE.
24
27
.\"
25
- .Dd March 2, 2016
28
+ .Dd January 19, 2025
26
29
.Dt MAKE_DEV 9
27
30
.Os
28
31
.Sh NAME
38
41
.Nm destroy_dev_sched_cb ,
39
42
.Nm destroy_dev_drain ,
40
43
.Nm dev_depends
41
- .Nd manage
42
- .Vt cdev Ns 's
43
- and DEVFS registration for devices
44
+ .Nd create and destroy character devices including devfs registration
44
45
.Sh SYNOPSIS
45
46
.In sys/param.h
46
47
.In sys/conf.h
@@ -105,6 +106,7 @@ struct make_dev_args {
105
106
void *mda_si_drv2;
106
107
};
107
108
.Ed
109
+ .Pp
108
110
Before use and filling with the desired values, the structure must be
109
111
initialized by the
110
112
.Fn make_dev_args_init
@@ -166,10 +168,10 @@ member of the initialized
166
168
The
167
169
.Va args.mda_flags
168
170
argument alters the operation of
169
- .Fn make_dev_s.
171
+ .Fn make_dev_s .
170
172
The following values are currently accepted:
171
173
.Pp
172
- .Bl -tag -width " It Dv MAKEDEV_CHECKNAME" -compact -offset indent
174
+ .Bl -tag -width " MAKEDEV_CHECKNAME" -compact -offset indent
173
175
.It Dv MAKEDEV_REF
174
176
reference the created device
175
177
.It Dv MAKEDEV_NOWAIT
@@ -200,12 +202,13 @@ is specified.
200
202
.Pp
201
203
The
202
204
.Xr dev_clone 9
203
- event handler shall specify
205
+ event handler shall specify the
204
206
.Dv MAKEDEV_REF
205
- flag when creating a device in response to lookup, to avoid race where
206
- the device created is destroyed immediately after
207
- .Xr devfs_lookup 9
208
- drops his reference to cdev.
207
+ flag when creating a device in response to lookup, to avoid a race where
208
+ the created device is immediately destroyed after
209
+ .Fn devfs_lookup
210
+ drops its reference to
211
+ .Fa cdev .
209
212
.Pp
210
213
The
211
214
.Dv MAKEDEV_ETERNAL
@@ -226,13 +229,14 @@ and the device name is invalid or already exists.
226
229
.Pp
227
230
The
228
231
.Fn make_dev_p
229
- use of the form
232
+ use of the form:
230
233
.Bd -literal -offset indent
231
234
struct cdev *dev;
232
235
int res;
233
236
res = make_dev_p(flags, &dev, cdevsw, cred, uid, gid, perms, name);
234
237
.Ed
235
- is equivalent to the code
238
+ .Pp
239
+ is equivalent to the code:
236
240
.Bd -literal -offset indent
237
241
struct cdev *dev;
238
242
struct make_dev_args args;
@@ -241,7 +245,7 @@ int res;
241
245
make_dev_args_init(&args);
242
246
args.mda_flags = flags;
243
247
args.mda_devsw = cdevsw;
244
- args.mda_cred = cred;
248
+ args.mda_cr = cred;
245
249
args.mda_uid = uid;
246
250
args.mda_gid = gid;
247
251
args.mda_mode = perms;
@@ -250,10 +254,11 @@ res = make_dev_s(&args, &dev, name);
250
254
.Pp
251
255
Similarly, the
252
256
.Fn make_dev_credf
253
- function call is equivalent to
257
+ function call is equivalent to:
254
258
.Bd -literal -offset indent
255
- (void) make_dev_s(&args, &dev, name);
259
+ (void) make_dev_s(&args, &dev, name);
256
260
.Ed
261
+ .Pp
257
262
In other words,
258
263
.Fn make_dev_credf
259
264
does not allow the caller to obtain the return value, and in
@@ -263,14 +268,14 @@ options, the function asserts that the device creation succeeded.
263
268
.Pp
264
269
The
265
270
.Fn make_dev_cred
266
- function is equivalent to the call
271
+ function is equivalent to the call:
267
272
.Bd -literal -offset indent
268
273
make_dev_credf(0, cdevsw, unit, cr, uid, gid, perms, fmt, ...);
269
274
.Ed
270
275
.Pp
271
276
The
272
277
.Fn make_dev
273
- function call is the same as
278
+ function call is the same as:
274
279
.Bd -literal -offset indent
275
280
make_dev_credf(0, cdevsw, unit, NULL, uid, gid, perms, fmt, ...);
276
281
.Ed
@@ -377,7 +382,7 @@ is called, with argument
377
382
.Fa arg .
378
383
The
379
384
.Fn destroy_dev_sched
380
- function is the same as
385
+ function is the same as:
381
386
.Bd -literal -offset indent
382
387
destroy_dev_sched_cb(cdev, NULL, NULL);
383
388
.Ed
0 commit comments