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_fff ,
41 .Nm devfs_clone_bitmap_chk ,
42 .Nm devfs_clone_bitmap_set ,
43 .Nm devfs_clone_bitmap_get ,
44 .Nm devfs_clone_bitmap_put ,
45 .Nm DEVFS_DECLARE_CLONE_BITMAP ,
46 .Nm DEVFS_DEFINE_CLONE_BITMAP ,
47 .Nm DEVFS_CLONE_BITMAP
48 .Nd device clone functions
54 .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" "..."
56 .Fn destroy_autoclone_dev "cdev_t dev" "struct devfs_bitmap *bitmap"
58 .Fn devfs_clone_bitmap_init "struct devfs_bitmap *bitmap"
60 .Fn devfs_clone_bitmap_uninit "struct devfs_bitmap *bitmap"
62 .Fn devfs_clone_bitmap_fff "struct devfs_bitmap *bitmap"
64 .Fn devfs_clone_bitmap_chk "struct devfs_bitmap *bitmap" "int unit"
66 .Fn devfs_clone_bitmap_set "struct devfs_bitmap *bitmap" "int unit"
68 .Fn devfs_clone_bitmap_get "struct devfs_bitmap *bitmap" "int limit"
70 .Fn devfs_clone_bitmap_put "struct devfs_bitmap *bitmap" "int unit"
71 .Fn DEVFS_DECLARE_CLONE_BITMAP "name"
72 .Fn DEVFS_DEFINE_CLONE_BITMAP "name"
73 .Fn DEVFS_CLONE_BITMAP "name"
75 .Fn make_autoclone_dev
82 namespace, that (when opened) will invoke the clone handler specified by
86 is specified, the given
89 .Fn devfs_clone_bitmap_init .
91 The clone handler must be defined as follows:
93 d_clone_t mydev_clone;
96 mydev_clone(struct dev_clone_args *ap)
101 When called, the handler is passed a pointer to a populated
103 structure, which is defined as follows:
105 struct dev_clone_args {
106 struct dev_generic_args a_head;
110 struct ucred *a_cred;
118 of the accessed autoclone device.
122 are the registered clonable base name and its length, as specified to
123 .Fn make_autoclone_dev .
127 contain the mode and cred passed to the autoclone device's
130 The clone handler must set
134 returned by a call to
141 will ultimately fail with
146 .Pf non- Ns Dv NULL ,
147 it is automatically made visible and linked into
149 as if it was created with
153 should be used to destroy the cloned
155 once it is no longer required,
159 .Fn destroy_autoclone_dev
163 .Fn make_autoclone_dev
164 unregistering its clone handler and (if non-NULL) also uninitializes its
167 .Fn devfs_clone_bitmap_uninit .
169 .Fn devfs_clone_bitmap_init
170 initializes the given clone
172 so it is ready to use.
174 .Fn devfs_clone_bitmap_uninit
175 frees the memory associated with the specified clone
177 and leaves it unusable.
179 .Fn devfs_clone_bitmap_fff
180 returns the first unused unit in
182 To use this unit, it has to be acquired by a call to
183 .Fn devfs_clone_bitmap_set .
185 .Fn devfs_clone_bitmap_chk
188 is in use (set) and returns 1 if it is; otherwise 0 is returned.
190 .Fn devfs_clone_bitmap_set
195 as used, so further calls to
196 .Fn devfs_clone_bitmap_fff
198 .Fn devfs_clone_bitmap_get
200 If one intends to use a clone handler along with preallocated devices, it
201 is recommended to block the unit numbers of the preallocated devices by
203 .Fn devfs_clone_bitmap_set
206 .Fn devfs_clone_bitmap_put
211 as unused so further calls to
212 .Fn devfs_clone_bitmap_fff
214 .Fn devfs_clone_bitmap_get
215 can retrieve it again.
217 .Fn devfs_clone_bitmap_get
219 .Fn devfs_clone_bitmap_fff
221 .Fn devfs_clone_bitmap_set .
222 It will return the first unused unit number and also mark it as used.
225 .Fn DEVFS_DEFINE_CLONE_BITMAP
226 macro defines a clone bitmap with the specified
228 As long as the name specified is unique, this macro can be used to define
231 .Fn DEVFS_DECLARE_CLONE_BITMAP
232 declares a clone bitmap.
235 .Fn DEVFS_CLONE_BITMAP
236 is a macro which expands the specified
238 to the full name of a clone bitmap.
239 It is used in conjunction with
240 .Fn DEVFS_DEFINE_CLONE_BITMAP
242 .Fn DEVFS_DECLARE_CLONE_BITMAP ,
243 as it uses the same name.
247 clone facilities and the associated functions all appeared in