1+ .\"
2+ .\" SPDX-License-Identifier: BSD-2-Clause
3+ .\"
14.\" Copyright (c) 1999 Chris Costello
25.\" All rights reserved.
36.\"
2225.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2326.\" SUCH DAMAGE.
2427.\"
25- .Dd March 2, 2016
28+ .Dd January 19, 2025
2629.Dt MAKE_DEV 9
2730.Os
2831.Sh NAME
3841.Nm destroy_dev_sched_cb ,
3942.Nm destroy_dev_drain ,
4043.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
4445.Sh SYNOPSIS
4546.In sys/param.h
4647.In sys/conf.h
@@ -105,6 +106,7 @@ struct make_dev_args {
105106 void *mda_si_drv2;
106107};
107108.Ed
109+ .Pp
108110Before use and filling with the desired values, the structure must be
109111initialized by the
110112.Fn make_dev_args_init
@@ -166,10 +168,10 @@ member of the initialized
166168The
167169.Va args.mda_flags
168170argument alters the operation of
169- .Fn make_dev_s.
171+ .Fn make_dev_s .
170172The following values are currently accepted:
171173.Pp
172- .Bl -tag -width " It Dv MAKEDEV_CHECKNAME" -compact -offset indent
174+ .Bl -tag -width " MAKEDEV_CHECKNAME" -compact -offset indent
173175.It Dv MAKEDEV_REF
174176reference the created device
175177.It Dv MAKEDEV_NOWAIT
@@ -200,12 +202,13 @@ is specified.
200202.Pp
201203The
202204.Xr dev_clone 9
203- event handler shall specify
205+ event handler shall specify the
204206.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 .
209212.Pp
210213The
211214.Dv MAKEDEV_ETERNAL
@@ -226,13 +229,14 @@ and the device name is invalid or already exists.
226229.Pp
227230The
228231.Fn make_dev_p
229- use of the form
232+ use of the form:
230233.Bd -literal -offset indent
231234struct cdev *dev;
232235int res;
233236res = make_dev_p(flags, &dev, cdevsw, cred, uid, gid, perms, name);
234237.Ed
235- is equivalent to the code
238+ .Pp
239+ is equivalent to the code:
236240.Bd -literal -offset indent
237241struct cdev *dev;
238242struct make_dev_args args;
@@ -241,7 +245,7 @@ int res;
241245make_dev_args_init(&args);
242246args.mda_flags = flags;
243247args.mda_devsw = cdevsw;
244- args.mda_cred = cred;
248+ args.mda_cr = cred;
245249args.mda_uid = uid;
246250args.mda_gid = gid;
247251args.mda_mode = perms;
@@ -250,10 +254,11 @@ res = make_dev_s(&args, &dev, name);
250254.Pp
251255Similarly, the
252256.Fn make_dev_credf
253- function call is equivalent to
257+ function call is equivalent to:
254258.Bd -literal -offset indent
255- (void) make_dev_s(&args, &dev, name);
259+ (void) make_dev_s(&args, &dev, name);
256260.Ed
261+ .Pp
257262In other words,
258263.Fn make_dev_credf
259264does not allow the caller to obtain the return value, and in
@@ -263,14 +268,14 @@ options, the function asserts that the device creation succeeded.
263268.Pp
264269The
265270.Fn make_dev_cred
266- function is equivalent to the call
271+ function is equivalent to the call:
267272.Bd -literal -offset indent
268273make_dev_credf(0, cdevsw, unit, cr, uid, gid, perms, fmt, ...);
269274.Ed
270275.Pp
271276The
272277.Fn make_dev
273- function call is the same as
278+ function call is the same as:
274279.Bd -literal -offset indent
275280make_dev_credf(0, cdevsw, unit, NULL, uid, gid, perms, fmt, ...);
276281.Ed
@@ -377,7 +382,7 @@ is called, with argument
377382.Fa arg .
378383The
379384.Fn destroy_dev_sched
380- function is the same as
385+ function is the same as:
381386.Bd -literal -offset indent
382387destroy_dev_sched_cb(cdev, NULL, NULL);
383388.Ed
0 commit comments