1 .\" Copyright (c) 2008 Konstantin Belousov
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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.
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
25 .\" $FreeBSD: head/share/man/man9/devfs_set_cdevpriv.9 291653 2015-12-02 18:27:30Z jhb $
28 .Dt DEVFS_SET_CDEVPRIV 9
31 .Nm devfs_set_cdevpriv ,
32 .Nm devfs_get_cdevpriv ,
33 .Nm devfs_clear_cdevpriv
34 .Nd manage per-open filedescriptor data for devices
38 typedef void d_priv_dtor_t(void *data);
41 .Fn devfs_set_cdevpriv "struct file *fp" "void *priv" "d_priv_dtor_t *dtr"
43 .Fn devfs_get_cdevpriv "struct file *fp" "void **datap"
45 .Fn devfs_clear_cdevpriv "struct file *fp"
48 .Fn devfs_xxx_cdevpriv
49 family of functions allows the device driver methods to associate some
50 driver-specific data with each user process
52 of the device special file.
53 Currently, functioning of these functions is restricted to the context
56 switch method calls performed as
58 operations in response to system calls that use file descriptors.
61 .Fn devfs_set_cdevpriv
62 function associates a data pointed by
64 with the calling context (file descriptor) specified by
66 The data may be retrieved later by
67 .Fn devfs_get_cdevpriv ,
68 possibly from another call
69 performed on this file descriptor.
72 .Fn devfs_clear_cdevpriv
73 function disassociates the previously attached data from the
77 .Fn devfs_clear_cdevpriv
78 operation, the previously associated
80 callback is called, with private data supplied its
84 .Fn devfs_clear_cdevpriv
85 function will be automatically called upon the
87 of the file descriptor.
89 If successful, the functions return 0.
92 .Fn devfs_set_cdevpriv
93 returns the following values on error:
101 The private driver data is already associated with the given
106 .Fn devfs_get_cdevpriv
107 returns the following values on error:
115 The private driver data was not associated with the given
118 .Fn devfs_clear_cdevpriv
127 .Fn devfs_xxx_cdevpriv
128 family of functions first appeared in
130 and was implemented in