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_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_fff "struct devfs_bitmap *bitmap"
63 .Fn devfs_clone_bitmap_chk "struct devfs_bitmap *bitmap" "int unit"
65 .Fn devfs_clone_bitmap_set "struct devfs_bitmap *bitmap" "int unit"
67 .Fn devfs_clone_bitmap_get "struct devfs_bitmap *bitmap" "int limit"
69 .Fn devfs_clone_bitmap_put "struct devfs_bitmap *bitmap" "int unit"
70 .Fn DEVFS_DECLARE_CLONE_BITMAP "name"
71 .Fn DEVFS_CLONE_BITMAP "name"
73 .Fn make_autoclone_dev
80 namespace, that (when opened) will invoke the clone handler specified by
84 is specified, the given
87 .Fn devfs_clone_bitmap_init .
89 The clone handler must be defined as follows:
91 d_clone_t mydev_clone;
94 mydev_clone(struct dev_clone_args *ap)
99 When called, the handler is passed a pointer to a populated
101 structure, which is defined as follows:
103 struct dev_clone_args {
104 struct dev_generic_args a_head;
108 struct ucred *a_cred;
116 of the accessed autoclone device.
120 are the registered clonable base name and its length, as specified to
121 .Fn make_autoclone_dev .
125 contain the mode and cred passed to the autoclone device's
128 The clone handler must set
132 returned by a call to
139 will ultimately fail with
144 .Pf non- Ns Dv NULL ,
145 it is automatically made visible and linked into
147 as if it was created with
151 should be used to destroy the cloned
153 once it is no longer required,
157 .Fn destroy_autoclone_dev
161 .Fn make_autoclone_dev
162 unregistering its clone handler and (if non-NULL) also uninitializes its
165 .Fn devfs_clone_bitmap_uninit .
167 .Fn devfs_clone_bitmap_init
168 initializes the given clone
170 so it is ready to use.
172 .Fn devfs_clone_bitmap_uninit
173 frees the memory associated with the specified clone
175 and leaves it unusable.
177 .Fn devfs_clone_bitmap_fff
178 returns the first unused unit in
180 To use this unit, it has to be acquired by a call to
181 .Fn devfs_clone_bitmap_set .
183 .Fn devfs_clone_bitmap_chk
186 is in use (set) and returns 1 if it is; otherwise 0 is returned.
188 .Fn devfs_clone_bitmap_set
193 as used, so further calls to
194 .Fn devfs_clone_bitmap_fff
196 .Fn devfs_clone_bitmap_get
198 If one intends to use a clone handler along with preallocated devices, it
199 is recommended to block the unit numbers of the preallocated devices by
201 .Fn devfs_clone_bitmap_set
204 .Fn devfs_clone_bitmap_put
209 as unused so further calls to
210 .Fn devfs_clone_bitmap_fff
212 .Fn devfs_clone_bitmap_get
213 can retrieve it again.
215 .Fn devfs_clone_bitmap_get
217 .Fn devfs_clone_bitmap_fff
219 .Fn devfs_clone_bitmap_set .
220 It will return the first unused unit number and also mark it as used.
223 .Fn DEVFS_DECLARE_CLONE_BITMAP
224 macro declares a clone bitmap with the specified
226 As long as the name specified is unique, this macro can be used to declare
230 .Fn DEVFS_CLONE_BITMAP
231 is a macro which expands the specified
233 to the full name of a clone bitmap.
234 It is used in conjunction with
235 .Fn DEVFS_DECLARE_CLONE_BITMAP ,
236 as it uses the same name.
240 clone facilities and the associated functions all appeared in