3 .\" The DragonFly Project. All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in
13 .\" the documentation and/or other materials provided with the
15 .\" 3. Neither the name of The DragonFly Project nor the names of its
16 .\" contributors may be used to endorse or promote products derived
17 .\" from this software without specific, prior written permission.
19 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 .\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23 .\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 .\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 .Dt MAKE_AUTOCLONE_DEV 9
36 .Nm make_autoclone_dev ,
37 .Nm destroy_autoclone_dev ,
38 .Nm devfs_clone_bitmap_init ,
39 .Nm devfs_clone_bitmap_uninit ,
40 .Nm devfs_clone_bitmap_chk ,
41 .Nm devfs_clone_bitmap_set ,
42 .Nm devfs_clone_bitmap_get ,
43 .Nm devfs_clone_bitmap_put ,
44 .Nm DEVFS_DECLARE_CLONE_BITMAP ,
45 .Nm DEVFS_DEFINE_CLONE_BITMAP ,
46 .Nm DEVFS_CLONE_BITMAP
47 .Nd device clone functions
53 .Fn make_autoclone_dev "struct dev_ops *ops" "struct devfs_bitmap *bitmap" "d_clone_t *nhandler" "uid_t uid" "gid_t gid" "int perms" "const char *fmt" "..."
55 .Fn destroy_autoclone_dev "cdev_t dev" "struct devfs_bitmap *bitmap"
57 .Fn devfs_clone_bitmap_init "struct devfs_bitmap *bitmap"
59 .Fn devfs_clone_bitmap_uninit "struct devfs_bitmap *bitmap"
61 .Fn devfs_clone_bitmap_chk "struct devfs_bitmap *bitmap" "int unit"
63 .Fn devfs_clone_bitmap_set "struct devfs_bitmap *bitmap" "int unit"
65 .Fn devfs_clone_bitmap_get "struct devfs_bitmap *bitmap" "int limit"
67 .Fn devfs_clone_bitmap_put "struct devfs_bitmap *bitmap" "int unit"
68 .Fn DEVFS_DECLARE_CLONE_BITMAP "name"
69 .Fn DEVFS_DEFINE_CLONE_BITMAP "name"
70 .Fn DEVFS_CLONE_BITMAP "name"
72 .Fn make_autoclone_dev
79 namespace, that (when opened) will invoke the clone handler specified by
83 is specified, the given
86 .Fn devfs_clone_bitmap_init .
88 The clone handler must be defined as follows:
90 d_clone_t mydev_clone;
93 mydev_clone(struct dev_clone_args *ap)
98 When called, the handler is passed a pointer to a populated
100 structure, which is defined as follows:
102 struct dev_clone_args {
103 struct dev_generic_args a_head;
107 struct ucred *a_cred;
115 of the accessed autoclone device.
119 are the registered clonable base name and its length, as specified to
120 .Fn make_autoclone_dev .
124 contain the mode and cred passed to the autoclone device's
127 The clone handler must set
131 returned by a call to
138 will ultimately fail with
143 .Pf non- Ns Dv NULL ,
144 it is automatically made visible and linked into
146 as if it was created with
150 should be used to destroy the cloned
152 once it is no longer required,
156 .Fn destroy_autoclone_dev
160 .Fn make_autoclone_dev
161 unregistering its clone handler and (if non-NULL) also uninitializes its
164 .Fn devfs_clone_bitmap_uninit .
166 .Fn devfs_clone_bitmap_init
167 initializes the given clone
169 so it is ready to use.
171 .Fn devfs_clone_bitmap_uninit
172 frees the memory associated with the specified clone
174 and leaves it unusable.
176 .Fn devfs_clone_bitmap_chk
179 is in use (set) and returns 1 if it is; otherwise 0 is returned.
181 .Fn devfs_clone_bitmap_set
186 as used, so further calls to
187 .Fn devfs_clone_bitmap_get
189 If one intends to use a clone handler along with preallocated devices, it
190 is recommended to block the unit numbers of the preallocated devices by
192 .Fn devfs_clone_bitmap_set
195 .Fn devfs_clone_bitmap_put
200 as unused so further calls to
201 .Fn devfs_clone_bitmap_fff
203 .Fn devfs_clone_bitmap_get
204 can retrieve it again.
205 It is recommended that the associated device be destroyed prior to
208 available in the bitmap again, to avoid racing against a new clone.
210 .Fn devfs_clone_bitmap_get
211 will return the first unused unit number and also mark it as used
216 .Fn DEVFS_DEFINE_CLONE_BITMAP
217 macro defines a clone bitmap with the specified
219 As long as the name specified is unique, this macro can be used to define
222 .Fn DEVFS_DECLARE_CLONE_BITMAP
223 declares a clone bitmap.
226 .Fn DEVFS_CLONE_BITMAP
227 is a macro which expands the specified
229 to the full name of a clone bitmap.
230 It is used in conjunction with
231 .Fn DEVFS_DEFINE_CLONE_BITMAP
233 .Fn DEVFS_DECLARE_CLONE_BITMAP ,
234 as it uses the same name.
238 clone facilities and the associated functions all appeared in