xref: /freebsd/share/man/man9/make_dev.9 (revision 77213b87eb43ce140e104a136c21fd62970da28b)
194b1839dSChris Costello.\" Copyright (c) 1999 Chris Costello
294b1839dSChris Costello.\" All rights reserved.
394b1839dSChris Costello.\"
494b1839dSChris Costello.\" Redistribution and use in source and binary forms, with or without
594b1839dSChris Costello.\" modification, are permitted provided that the following conditions
694b1839dSChris Costello.\" are met:
794b1839dSChris Costello.\" 1. Redistributions of source code must retain the above copyright
894b1839dSChris Costello.\"    notice, this list of conditions and the following disclaimer.
994b1839dSChris Costello.\" 2. Redistributions in binary form must reproduce the above copyright
1094b1839dSChris Costello.\"    notice, this list of conditions and the following disclaimer in the
1194b1839dSChris Costello.\"    documentation and/or other materials provided with the distribution.
1294b1839dSChris Costello.\"
1394b1839dSChris Costello.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1494b1839dSChris Costello.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1594b1839dSChris Costello.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1694b1839dSChris Costello.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1794b1839dSChris Costello.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1894b1839dSChris Costello.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1994b1839dSChris Costello.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2094b1839dSChris Costello.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2194b1839dSChris Costello.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2294b1839dSChris Costello.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2394b1839dSChris Costello.\" SUCH DAMAGE.
2494b1839dSChris Costello.\"
2594b1839dSChris Costello.\" $FreeBSD$
2694b1839dSChris Costello.\"
2777213b87SChristian Brueffer.Dd May 6, 2007
2894b1839dSChris Costello.Os
2994b1839dSChris Costello.Dt MAKE_DEV 9
3094b1839dSChris Costello.Sh NAME
3194b1839dSChris Costello.Nm make_dev ,
32f14b89faSDima Dorfman.Nm make_dev_alias ,
33f14b89faSDima Dorfman.Nm destroy_dev ,
3444c63b64SDima Dorfman.Nm dev_depends
35e3718e31SRuslan Ermilov.Nd manage
36c97dc39fSChristian Brueffer.Vt cdev Ns 's
37e3718e31SRuslan Ermilovand DEVFS registration for devices
3894b1839dSChris Costello.Sh SYNOPSIS
39212c98aaSBruce Evans.In sys/param.h
4032eef9aeSRuslan Ermilov.In sys/conf.h
41097fcfebSWarner Losh.Ft struct cdev *
42212c98aaSBruce Evans.Fn make_dev "struct cdevsw *cdevsw" "int minor" "uid_t uid" "gid_t gid" "int perms" "const char *fmt" ...
43097fcfebSWarner Losh.Ft struct cdev *
4474c9ea0cSJohn-Mark Gurney.Fn make_dev_alias "struct cdev *pdev" "const char *fmt" ...
4594b1839dSChris Costello.Ft void
46097fcfebSWarner Losh.Fn destroy_dev "struct cdev *dev"
47f14b89faSDima Dorfman.Ft void
48097fcfebSWarner Losh.Fn dev_depends "struct cdev *pdev" "struct cdev *cdev"
4994b1839dSChris Costello.Sh DESCRIPTION
5094b1839dSChris CostelloThe
5194b1839dSChris Costello.Fn make_dev
5294b1839dSChris Costellofunction creates a
53c97dc39fSChristian Brueffer.Fa cdev
54a0942a60SHiten Pandyastructure for a new device.
55a0942a60SHiten PandyaIf DEVFS is available, it is also notified of
56a0942a60SHiten Pandyathe presence of the new device.
57a0942a60SHiten PandyaThe device will be owned by
5894b1839dSChris Costello.Va uid ,
5994b1839dSChris Costellowith the group ownership as
601dfbd9c2SWarner Losh.Va gid .
611dfbd9c2SWarner LoshThe name is the expansion of
621dfbd9c2SWarner Losh.Va fmt
631dfbd9c2SWarner Loshand following arguments as
641dfbd9c2SWarner Losh.Xr printf 9
651dfbd9c2SWarner Loshwould print it.
661dfbd9c2SWarner LoshThe name determines its path under
671dfbd9c2SWarner Losh.Pa /dev
681dfbd9c2SWarner Loshor other
691dfbd9c2SWarner Losh.Xr devfs 5
701dfbd9c2SWarner Loshmount point and may contain slash
711dfbd9c2SWarner Losh.Ql /
721dfbd9c2SWarner Loshcharacters to denote subdirectories.
7394b1839dSChris CostelloThe permissions of the file specified in
7494b1839dSChris Costello.Va perms
7594b1839dSChris Costelloare defined in
76fe08efe6SRuslan Ermilov.In sys/stat.h :
7794b1839dSChris Costello.Pp
7894b1839dSChris Costello.Bd -literal -offset indent -compact
7994b1839dSChris Costello#define S_IRWXU 0000700    /* RWX mask for owner */
8094b1839dSChris Costello#define S_IRUSR 0000400    /* R for owner */
8194b1839dSChris Costello#define S_IWUSR 0000200    /* W for owner */
8294b1839dSChris Costello#define S_IXUSR 0000100    /* X for owner */
8394b1839dSChris Costello
8494b1839dSChris Costello#define S_IRWXG 0000070    /* RWX mask for group */
8594b1839dSChris Costello#define S_IRGRP 0000040    /* R for group */
8694b1839dSChris Costello#define S_IWGRP 0000020    /* W for group */
8794b1839dSChris Costello#define S_IXGRP 0000010    /* X for group */
8894b1839dSChris Costello
8994b1839dSChris Costello#define S_IRWXO 0000007    /* RWX mask for other */
9094b1839dSChris Costello#define S_IROTH 0000004    /* R for other */
9194b1839dSChris Costello#define S_IWOTH 0000002    /* W for other */
9294b1839dSChris Costello#define S_IXOTH 0000001    /* X for other */
9394b1839dSChris Costello
9494b1839dSChris Costello#define S_ISUID 0004000    /* set user id on execution */
9594b1839dSChris Costello#define S_ISGID 0002000    /* set group id on execution */
9694b1839dSChris Costello#define S_ISVTX 0001000    /* sticky bit */
9794b1839dSChris Costello#ifndef _POSIX_SOURCE
9894b1839dSChris Costello#define S_ISTXT 0001000
9994b1839dSChris Costello#endif
10094b1839dSChris Costello.Ed
10194b1839dSChris Costello.Pp
10294b1839dSChris CostelloThe
103792b2369SMatt Jacob.Fn make_dev_alias
104792b2369SMatt Jacobfunction takes the returned
105c97dc39fSChristian Brueffer.Ft cdev
106792b2369SMatt Jacobfrom
107792b2369SMatt Jacob.Fn make_dev
108edf0984dSRuslan Ermilovand makes another (aliased) name for this device.
109edf0984dSRuslan ErmilovIt is an error to call
110792b2369SMatt Jacob.Fn make_dev_alias
111792b2369SMatt Jacobprior to calling
112792b2369SMatt Jacob.Fn make_dev .
113792b2369SMatt Jacob.Pp
114792b2369SMatt JacobThe
1152557913dSJohn-Mark Gurney.Fa cdev
1162557913dSJohn-Mark Gurneyreturned by
1172557913dSJohn-Mark Gurney.Fn make_dev
1182557913dSJohn-Mark Gurneyand
1192557913dSJohn-Mark Gurney.Fn make_dev_alias
1202557913dSJohn-Mark Gurneyhas two fields,
1212557913dSJohn-Mark Gurney.Fa si_drv1
1222557913dSJohn-Mark Gurneyand
1232557913dSJohn-Mark Gurney.Fa si_drv2 ,
12477213b87SChristian Bruefferthat are available to store state.
12577213b87SChristian BruefferBoth fields are of type
1262557913dSJohn-Mark Gurney.Ft void * .
1272557913dSJohn-Mark GurneyThese are designed to replace the
1282557913dSJohn-Mark Gurney.Fa minor
1292557913dSJohn-Mark Gurneyargument to
1302557913dSJohn-Mark Gurney.Fn make_dev .
1312557913dSJohn-Mark Gurney.Pp
1322557913dSJohn-Mark GurneyThe
133bd00dbfaSBruce Evans.Fn destroy_dev
13494b1839dSChris Costellofunction takes the returned
135c97dc39fSChristian Brueffer.Fa cdev
13694b1839dSChris Costellofrom
13794b1839dSChris Costello.Fn make_dev
138edf0984dSRuslan Ermilovand destroys the registration for that device.
139edf0984dSRuslan ErmilovDo not call
140792b2369SMatt Jacob.Fn destroy_dev
141792b2369SMatt Jacobon devices that were created with
142792b2369SMatt Jacob.Fn make_dev_alias .
143f14b89faSDima Dorfman.Pp
144f14b89faSDima DorfmanThe
14544c63b64SDima Dorfman.Fn dev_depends
146f14b89faSDima Dorfmanfunction establishes a parent-child relationship between two devices.
147f14b89faSDima DorfmanThe net effect is that a
148f14b89faSDima Dorfman.Fn destroy_dev
149f14b89faSDima Dorfmanof the parent device will also result in the destruction of the
150f14b89faSDima Dorfmanchild device(s),
151f14b89faSDima Dorfmanif any exist.
152f14b89faSDima DorfmanA device may simultaneously be a parent and a child,
153b82af3f5SMike Pritchardso it is possible to build a complete hierarchy.
154e07f1d5fSHiten Pandya.Sh SEE ALSO
155e07f1d5fSHiten Pandya.Xr devfs 5
15694b1839dSChris Costello.Sh HISTORY
15794b1839dSChris CostelloThe
15894b1839dSChris Costello.Fn make_dev
15994b1839dSChris Costelloand
160bd00dbfaSBruce Evans.Fn destroy_dev
16194b1839dSChris Costellofunctions first appeared in
16294b1839dSChris Costello.Fx 4.0 .
163792b2369SMatt JacobThe function
164792b2369SMatt Jacob.Fn make_dev_alias
165792b2369SMatt Jacobfirst appeared in
166792b2369SMatt Jacob.Fx 4.1 .
167f14b89faSDima DorfmanThe function
16844c63b64SDima Dorfman.Fn dev_depends
169f14b89faSDima Dorfmanfirst appeared in
170f14b89faSDima Dorfman.Fx 5.0 .
171