make_dev.9 (7505ef3a411ed3f714d5c6bf3228f0d7cd83d97f) | make_dev.9 (580a458787646012ff4fb480c5c7278896de5491) |
---|---|
1.\" Copyright (c) 1999 Chris Costello 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. --- 10 unchanged lines hidden (view full) --- 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.\" $FreeBSD$ 26.\" | 1.\" Copyright (c) 1999 Chris Costello 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. --- 10 unchanged lines hidden (view full) --- 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.\" $FreeBSD$ 26.\" |
27.Dd May 03, 2011 | 27.Dd May 3, 2011 |
28.Dt MAKE_DEV 9 29.Os 30.Sh NAME 31.Nm make_dev , 32.Nm make_dev_cred , 33.Nm make_dev_credf , 34.Nm make_dev_p , 35.Nm make_dev_alias , --- 43 unchanged lines hidden (view full) --- 79to be created. 80Besides this, a 81.Xr devctl 4 82notification is sent. 83The device will be owned by 84.Va uid , 85with the group ownership as 86.Va gid . | 28.Dt MAKE_DEV 9 29.Os 30.Sh NAME 31.Nm make_dev , 32.Nm make_dev_cred , 33.Nm make_dev_credf , 34.Nm make_dev_p , 35.Nm make_dev_alias , --- 43 unchanged lines hidden (view full) --- 79to be created. 80Besides this, a 81.Xr devctl 4 82notification is sent. 83The device will be owned by 84.Va uid , 85with the group ownership as 86.Va gid . |
87The name is the expansion of 88.Va fmt | 87The name is the expansion of 88.Va fmt |
89and following arguments as 90.Xr printf 9 91would print it. 92The name determines its path under 93.Pa /dev | 89and following arguments as 90.Xr printf 9 91would print it. 92The name determines its path under 93.Pa /dev |
94or other 95.Xr devfs 5 | 94or other 95.Xr devfs 5 |
96mount point and may contain slash 97.Ql / 98characters to denote subdirectories. 99The permissions of the file specified in 100.Va perms 101are defined in 102.In sys/stat.h : 103.Pp --- 43 unchanged lines hidden (view full) --- 147.It MAKEDEV_WAITOK 148allow the function to sleep to satisfy malloc 149.It MAKEDEV_ETERNAL 150created device will be never destroyed 151.It MAKEDEV_CHECKNAME 152return an error if the device name is invalid or already exists 153.El 154.Pp | 96mount point and may contain slash 97.Ql / 98characters to denote subdirectories. 99The permissions of the file specified in 100.Va perms 101are defined in 102.In sys/stat.h : 103.Pp --- 43 unchanged lines hidden (view full) --- 147.It MAKEDEV_WAITOK 148allow the function to sleep to satisfy malloc 149.It MAKEDEV_ETERNAL 150created device will be never destroyed 151.It MAKEDEV_CHECKNAME 152return an error if the device name is invalid or already exists 153.El 154.Pp |
155Only | 155Only |
156.Dv MAKEDEV_NOWAIT , | 156.Dv MAKEDEV_NOWAIT , |
157.Dv MAKEDEV_WAITOK | 157.Dv MAKEDEV_WAITOK |
158and 159.Dv MAKEDEV_CHECKNAME 160values are accepted for the 161.Fn make_dev_alias_p 162function. 163.Pp 164The 165.Dv MAKEDEV_WAITOK --- 136 unchanged lines hidden (view full) --- 302.Bd -literal -offset indent 303destroy_dev_sched_cb(cdev, NULL, NULL); 304.Ed 305.Pp 306The 307.Fn d_close 308driver method cannot call 309.Fn destroy_dev | 158and 159.Dv MAKEDEV_CHECKNAME 160values are accepted for the 161.Fn make_dev_alias_p 162function. 163.Pp 164The 165.Dv MAKEDEV_WAITOK --- 136 unchanged lines hidden (view full) --- 302.Bd -literal -offset indent 303destroy_dev_sched_cb(cdev, NULL, NULL); 304.Ed 305.Pp 306The 307.Fn d_close 308driver method cannot call 309.Fn destroy_dev |
310directly. Doing so causes deadlock when | 310directly. 311Doing so causes deadlock when |
311.Fn destroy_dev 312waits for all threads to leave the driver methods. 313Also, because 314.Fn destroy_dev 315sleeps, no non-sleepable locks may be held over the call. 316The 317.Fn destroy_dev_sched 318family of functions overcome these issues. 319.Pp 320The device driver may call the 321.Fn destroy_dev_drain 322function to wait until all devices that have supplied 323.Fa csw | 312.Fn destroy_dev 313waits for all threads to leave the driver methods. 314Also, because 315.Fn destroy_dev 316sleeps, no non-sleepable locks may be held over the call. 317The 318.Fn destroy_dev_sched 319family of functions overcome these issues. 320.Pp 321The device driver may call the 322.Fn destroy_dev_drain 323function to wait until all devices that have supplied 324.Fa csw |
324as cdevsw, are destroyed. This is useful when driver knows that | 325as cdevsw, are destroyed. 326This is useful when driver knows that |
325.Fn destroy_dev_sched 326is called for all instantiated devices, but need to postpone module 327unload until 328.Fn destroy_dev 329is actually finished for all of them. 330.Sh RETURN VALUES 331If successful, 332.Fn make_dev_p --- 32 unchanged lines hidden (view full) --- 365.It Bq Er EEXIST 366The 367.Dv MAKEDEV_CHECKNAME 368flag was specified and the provided device name already exists. 369.El 370.Pp 371.Sh SEE ALSO 372.Xr devctl 4 , | 327.Fn destroy_dev_sched 328is called for all instantiated devices, but need to postpone module 329unload until 330.Fn destroy_dev 331is actually finished for all of them. 332.Sh RETURN VALUES 333If successful, 334.Fn make_dev_p --- 32 unchanged lines hidden (view full) --- 367.It Bq Er EEXIST 368The 369.Dv MAKEDEV_CHECKNAME 370flag was specified and the provided device name already exists. 371.El 372.Pp 373.Sh SEE ALSO 374.Xr devctl 4 , |
375.Xr devfs 5 , |
|
373.Xr destroy_dev_drain 9 , | 376.Xr destroy_dev_drain 9 , |
374.Xr dev_clone 9 , 375.Xr devfs 5 | 377.Xr dev_clone 9 |
376.Sh HISTORY 377The 378.Fn make_dev 379and 380.Fn destroy_dev 381functions first appeared in 382.Fx 4.0 . 383The function --- 17 unchanged lines hidden --- | 378.Sh HISTORY 379The 380.Fn make_dev 381and 382.Fn destroy_dev 383functions first appeared in 384.Fx 4.0 . 385The function --- 17 unchanged lines hidden --- |