xref: /freebsd/share/man/man9/dev_clone.9 (revision 911f0260390e18cf85f3dbf2c719b593efdc1e3c)
1.\" Copyright (c) 2008 Konstantin Belousov
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd January 3, 2009
28.Dt DEV_CLONE 9
29.Os
30.Sh NAME
31.Nm dev_clone ,
32.Nm drain_dev_clone_events
33.Nd eventhandler for name-based device cloning in devfs
34.Sh SYNOPSIS
35.In sys/param.h
36.In sys/conf.h
37.Ft void
38.Fn clone_handler "void *arg" "struct ucred *cr" "char *name" "int namelen" "struct cdev **dev"
39.Bd -literal
40EVENTHANDLER_REGISTER(dev_clone, clone_handler, arg, priority);
41.Ed
42.Ft void
43.Fn drain_dev_clone_events
44.Sh DESCRIPTION
45A device driver may register a listener that will be notified each time
46a name lookup on the
47.Xr devfs 5
48mount point fails to find the vnode.
49A listener shall be registered for the
50.Va dev_clone
51event.
52When called, it is supplied with the first argument
53.Va arg
54that was specified at handler registration time,
55appropriate credentials
56.Va cr ,
57and a name
58.Va name
59of length
60.Va namelen
61that we look for.
62If the handler decides that the name is appropriate and wants to create the device
63that will be associated with the name, it should return it to devfs
64in the
65.Va dev
66argument.
67.Pp
68The
69.Fn drain_dev_clone_events
70function is a barrier.
71It is guaranteed that all calls to eventhandlers for
72.Nm dev_clone
73that were started before
74.Fn drain_dev_clone_events
75call, are finished before it returns control.
76.Sh SEE ALSO
77.Xr devfs 5 ,
78.Xr namei 9
79