The fdrop() procedure no longer needs a thread argument, remove it.
[dragonfly.git] / sys / sys / file2.h
1 /*
2  * Copyright (c) 1982, 1986, 1989, 1993
3  *      The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *      This product includes software developed by the University of
16  *      California, Berkeley and its contributors.
17  * 4. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  *      @(#)file.h      8.3 (Berkeley) 1/9/95
34  * $FreeBSD: src/sys/sys/file.h,v 1.22.2.7 2002/11/21 23:39:24 sam Exp $
35  * $DragonFly: src/sys/sys/file2.h,v 1.5 2006/05/06 06:38:39 dillon Exp $
36  */
37
38 #ifndef _SYS_FILE2_H_
39 #define _SYS_FILE2_H_
40
41 #ifdef _KERNEL
42
43 static __inline void
44 fhold(struct file *fp)
45 {
46         fp->f_count++;
47 }
48
49 static __inline int
50 fo_read(
51         struct file *fp,
52         struct uio *uio,
53         struct ucred *cred,
54         int flags
55 ) {
56         int error;
57
58         fhold(fp);
59         error = (*fp->f_ops->fold_read)(fp, uio, cred, flags);
60         fdrop(fp);
61         return (error);
62 }
63
64 static __inline int
65 fo_write(
66         struct file *fp,
67         struct uio *uio,
68         struct ucred *cred,
69         int flags
70 ) {
71         int error;
72
73         fhold(fp);
74         error = (*fp->f_ops->fold_write)(fp, uio, cred, flags);
75         fdrop(fp);
76         return (error);
77 }
78
79 static __inline int
80 fo_ioctl(
81         struct file *fp,
82         u_long com,
83         caddr_t data,
84         struct ucred *cred
85 ) {
86         int error;
87
88         fhold(fp);
89         error = (*fp->f_ops->fold_ioctl)(fp, com, data, cred);
90         fdrop(fp);
91         return (error);
92 }
93
94 static __inline int
95 fo_poll(
96         struct file *fp,
97         int events,
98         struct ucred *cred
99 ) {
100         int error;
101
102         fhold(fp);
103         error = (*fp->f_ops->fold_poll)(fp, events, cred);
104         fdrop(fp);
105         return (error);
106 }
107
108 static __inline int
109 fo_stat(struct file *fp, struct stat *sb, struct ucred *cred)
110 {
111         int error;
112
113         fhold(fp);
114         error = (*fp->f_ops->fold_stat)(fp, sb, cred);
115         fdrop(fp);
116         return (error);
117 }
118
119 static __inline int
120 fo_close(struct file *fp)
121 {
122         return ((*fp->f_ops->fold_close)(fp));
123 }
124
125 static __inline int
126 fo_shutdown(struct file *fp, int how)
127 {
128         return ((*fp->f_ops->fold_shutdown)(fp, how));
129 }
130
131 static __inline int
132 fo_kqfilter(struct file *fp, struct knote *kn)
133 {
134         return ((*fp->f_ops->fold_kqfilter)(fp, kn));
135 }
136
137 #endif /* _KERNEL */
138
139 #endif /* !SYS_FILE2_H */
140