]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - share/man/man9/devfs_set_cdevpriv.9
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / share / man / man9 / devfs_set_cdevpriv.9
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 September 8, 2008
28 .Dt DEVFS_CDEVPRIV 9
29 .Os
30 .Sh NAME
31 .Nm devfs_set_cdevpriv ,
32 .Nm devfs_get_cdevpriv ,
33 .Nm devfs_clear_cdevpriv
34 .Nd manage per-open filedescriptor data for devices
35 .Sh SYNOPSIS
36 .In sys/param.h
37 .In sys/conf.h
38 .Bd -literal
39 typedef void (*cdevpriv_dtr_t)(void *data);
40 .Ed
41 .Ft int
42 .Fn devfs_get_cdevpriv "void **datap"
43 .Ft int
44 .Fn devfs_set_cdevpriv "void *priv" "cdevpriv_dtr_t dtr"
45 .Ft void
46 .Fn devfs_clear_cdevpriv "void"
47 .Sh DESCRIPTION
48 The
49 .Fn devfs_xxx_cdevpriv
50 family of functions allows the
51 .Fa cdev
52 driver methods to associate some driver-specific data with each
53 user process
54 .Xr open 2
55 of the device special file.
56 Currently, functioning of these functions is restricted to the context
57 of the
58 .Fa cdevsw
59 switch method calls performed as
60 .Xr devfs 5
61 operations in response to system calls that use filedescriptors.
62 .Pp
63 The
64 .Fn devfs_set_cdevpriv
65 function associates a data pointed by
66 .Va priv
67 with current calling context (filedescriptor).
68 The data may be retrieved later, possibly from another call
69 performed on this filedescriptor, by the
70 .Fn devfs_get_cdevpriv
71 function.
72 The
73 .Fn devfs_clear_cdevpriv
74 disassociates previously attached data from context.
75 Immediately after
76 .Fn devfs_clear_cdevpriv
77 finished operating, the
78 .Va dtr
79 callback is called, with private data supplied
80 .Va data
81 argument.
82 .Pp
83 On the last filedescriptor close, system automatically arranges
84 .Fn devfs_clear_cdevpriv
85 call.
86 .Pp
87 If successful, the functions return 0.
88 .Pp
89 The function
90 .Fn devfs_set_cdevpriv
91 returns the following values on error:
92 .Bl -tag -width Er
93 .It Bq Er ENOENT
94 The current call is not associated with some filedescriptor.
95 .It Bq Er EBUSY
96 The private driver data is already associated with current
97 filedescriptor.
98 .El
99 .Pp
100 The function
101 .Fn devfs_get_cdevpriv
102 returns the following values on error:
103 .Bl -tag -width Er
104 .It Bq Er EBADF
105 The current call is not associated with some filedescriptor.
106 .It Bq Er ENOENT
107 The private driver data was not associated with current
108 filedescriptor, or
109 .Fn devfs_clear_cdevpriv
110 was called.
111 .El
112 .Sh SEE ALSO
113 .Xr open 2 ,
114 .Xr close 2 ,
115 .Xr devfs 5 ,
116 .Xr kern_openat 9
117 .Sh HISTORY
118 The
119 .Fn devfs_cdevpriv
120 family of functions first appeared in
121 .Fx 7.1 .