xref: /freebsd/share/man/man9/make_dev.9 (revision e3718e310c4a8b7f563514b9cf9ab6e3b015dc5a)
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.\"
27f14b89faSDima Dorfman.Dd May 27, 2001
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 ,
34f14b89faSDima Dorfman.Nm depends_dev
35e3718e31SRuslan Ermilov.Nd manage
36e3718e31SRuslan Ermilov.Vt dev_t Ns 's
37e3718e31SRuslan Ermilovand DEVFS registration for devices
3894b1839dSChris Costello.Sh SYNOPSIS
3994b1839dSChris Costello.Fd #include <sys/types.h>
4094b1839dSChris Costello.Fd #include <sys/conf.h>
4194b1839dSChris Costello.Ft dev_t
42bd00dbfaSBruce Evans.Fn make_dev "struct cdevsw *cdevsw" "int minor" "uid_t uid" "gid_t gid" "int perms" "char *fmt" ...
43792b2369SMatt Jacob.Ft dev_t
44792b2369SMatt Jacob.Fn make_dev_alias "dev_t pdev" "char *fmt" ...
4594b1839dSChris Costello.Ft void
46bd00dbfaSBruce Evans.Fn destroy_dev "dev_t dev"
47f14b89faSDima Dorfman.Ft void
48f14b89faSDima Dorfman.Fn dev_depends "dev_t pdev" "dev_t cdev"
4994b1839dSChris Costello.Sh DESCRIPTION
5094b1839dSChris CostelloThe
5194b1839dSChris Costello.Fn make_dev
5294b1839dSChris Costellofunction creates a
5394b1839dSChris Costello.Fa dev_t
5494b1839dSChris Costellostructure for a new device.  If DEVFS is available, it is also notified of
5594b1839dSChris Costellothe presence of the new device.  The device will be owned by
5694b1839dSChris Costello.Va uid ,
5794b1839dSChris Costellowith the group ownership as
5894b1839dSChris Costello.Va gid ,
5994b1839dSChris Costelloand with the name as specified in
6094b1839dSChris Costello.Va name .
6194b1839dSChris CostelloThe permissions of the file specified in
6294b1839dSChris Costello.Va perms
6394b1839dSChris Costelloare defined in
6494b1839dSChris Costello.Aq Pa sys/stat.h :
6594b1839dSChris Costello.Pp
6694b1839dSChris Costello.Bd -literal -offset indent -compact
6794b1839dSChris Costello#define S_IRWXU 0000700    /* RWX mask for owner */
6894b1839dSChris Costello#define S_IRUSR 0000400    /* R for owner */
6994b1839dSChris Costello#define S_IWUSR 0000200    /* W for owner */
7094b1839dSChris Costello#define S_IXUSR 0000100    /* X for owner */
7194b1839dSChris Costello
7294b1839dSChris Costello#define S_IRWXG 0000070    /* RWX mask for group */
7394b1839dSChris Costello#define S_IRGRP 0000040    /* R for group */
7494b1839dSChris Costello#define S_IWGRP 0000020    /* W for group */
7594b1839dSChris Costello#define S_IXGRP 0000010    /* X for group */
7694b1839dSChris Costello
7794b1839dSChris Costello#define S_IRWXO 0000007    /* RWX mask for other */
7894b1839dSChris Costello#define S_IROTH 0000004    /* R for other */
7994b1839dSChris Costello#define S_IWOTH 0000002    /* W for other */
8094b1839dSChris Costello#define S_IXOTH 0000001    /* X for other */
8194b1839dSChris Costello
8294b1839dSChris Costello#define S_ISUID 0004000    /* set user id on execution */
8394b1839dSChris Costello#define S_ISGID 0002000    /* set group id on execution */
8494b1839dSChris Costello#define S_ISVTX 0001000    /* sticky bit */
8594b1839dSChris Costello#ifndef _POSIX_SOURCE
8694b1839dSChris Costello#define S_ISTXT 0001000
8794b1839dSChris Costello#endif
8894b1839dSChris Costello.Ed
8994b1839dSChris Costello.Pp
9094b1839dSChris CostelloThe
91792b2369SMatt Jacob.Fn make_dev_alias
92792b2369SMatt Jacobfunction takes the returned
93edf0984dSRuslan Ermilov.Ft dev_t
94792b2369SMatt Jacobfrom
95792b2369SMatt Jacob.Fn make_dev
96edf0984dSRuslan Ermilovand makes another (aliased) name for this device.
97edf0984dSRuslan ErmilovIt is an error to call
98792b2369SMatt Jacob.Fn make_dev_alias
99792b2369SMatt Jacobprior to calling
100792b2369SMatt Jacob.Fn make_dev .
101792b2369SMatt Jacob.Pp
102792b2369SMatt JacobThe
103bd00dbfaSBruce Evans.Fn destroy_dev
10494b1839dSChris Costellofunction takes the returned
10594b1839dSChris Costello.Fa dev_t
10694b1839dSChris Costellofrom
10794b1839dSChris Costello.Fn make_dev
108edf0984dSRuslan Ermilovand destroys the registration for that device.
109edf0984dSRuslan ErmilovDo not call
110792b2369SMatt Jacob.Fn destroy_dev
111792b2369SMatt Jacobon devices that were created with
112792b2369SMatt Jacob.Fn make_dev_alias .
113f14b89faSDima Dorfman.Pp
114f14b89faSDima DorfmanThe
115f14b89faSDima Dorfman.Fn depends_dev
116f14b89faSDima Dorfmanfunction establishes a parent-child relationship between two devices.
117f14b89faSDima DorfmanThe net effect is that a
118f14b89faSDima Dorfman.Fn destroy_dev
119f14b89faSDima Dorfmanof the parent device will also result in the destruction of the
120f14b89faSDima Dorfmanchild device(s),
121f14b89faSDima Dorfmanif any exist.
122f14b89faSDima DorfmanA device may simultaneously be a parent and a child,
123f14b89faSDima Dorfmanso it is possible to build a complete hierachy.
12494b1839dSChris Costello.Sh HISTORY
12594b1839dSChris CostelloThe
12694b1839dSChris Costello.Fn make_dev
12794b1839dSChris Costelloand
128bd00dbfaSBruce Evans.Fn destroy_dev
12994b1839dSChris Costellofunctions first appeared in
13094b1839dSChris Costello.Fx 4.0 .
131792b2369SMatt JacobThe function
132792b2369SMatt Jacob.Fn make_dev_alias
133792b2369SMatt Jacobfirst appeared in
134792b2369SMatt Jacob.Fx 4.1 .
135f14b89faSDima DorfmanThe function
136f14b89faSDima Dorfman.Fn depends_dev
137f14b89faSDima Dorfmanfirst appeared in
138f14b89faSDima Dorfman.Fx 5.0 .
139