2 * Copyright (c) 2001 Dag-Erling Coïdan Smørgrav
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer
10 * in this position and unchanged.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef _PSEUDOFS_INTERNAL_H_INCLUDED
32 #define _PSEUDOFS_INTERNAL_H_INCLUDED
37 SYSCTL_DECL(_vfs_pfs);
43 struct pfs_node *pvd_pn;
45 struct vnode *pvd_vnode;
46 struct pfs_vdata*pvd_prev, *pvd_next;
53 void pfs_vncache_load (void);
54 void pfs_vncache_unload (void);
55 int pfs_vncache_alloc (struct mount *, struct vnode **,
56 struct pfs_node *, pid_t pid);
57 int pfs_vncache_free (struct vnode *);
62 void pfs_fileno_init (struct pfs_info *);
63 void pfs_fileno_uninit (struct pfs_info *);
64 void pfs_fileno_alloc (struct pfs_node *);
65 void pfs_fileno_free (struct pfs_node *);
73 #define PFS_TRACE(foo) \
76 printf("%s(): line %d: ", __func__, __LINE__); \
81 #define PFS_RETURN(err) \
84 printf("%s(): line %d: returning %d\n", \
85 __func__, __LINE__, err); \
90 #define PFS_TRACE(foo) \
91 do { /* nothing */ } while (0)
92 #define PFS_RETURN(err) \
97 * Inline helpers for locking
100 pfs_lock(struct pfs_node *pn)
103 mtx_lock(&pn->pn_mutex);
107 pfs_unlock(struct pfs_node *pn)
110 mtx_unlock(&pn->pn_mutex);
114 pfs_assert_owned(struct pfs_node *pn)
117 mtx_assert(&pn->pn_mutex, MA_OWNED);
121 pfs_assert_not_owned(struct pfs_node *pn)
124 mtx_assert(&pn->pn_mutex, MA_NOTOWNED);
128 pn_fill(PFS_FILL_ARGS)
131 PFS_TRACE(("%s", pn->pn_name));
132 KASSERT(pn->pn_fill != NULL, ("%s(): no callback", __func__));
134 PROC_LOCK_ASSERT(p, MA_NOTOWNED);
137 pfs_assert_not_owned(pn);
138 return ((pn->pn_fill)(PFS_FILL_ARGNAMES));
142 pn_attr(PFS_ATTR_ARGS)
145 PFS_TRACE(("%s", pn->pn_name));
146 KASSERT(pn->pn_attr != NULL, ("%s(): no callback", __func__));
148 PROC_LOCK_ASSERT(p, MA_OWNED);
149 pfs_assert_not_owned(pn);
150 return ((pn->pn_attr)(PFS_ATTR_ARGNAMES));
157 PFS_TRACE(("%s", pn->pn_name));
158 KASSERT(pn->pn_vis != NULL, ("%s(): no callback", __func__));
159 KASSERT(p != NULL, ("%s(): no process", __func__));
160 PROC_LOCK_ASSERT(p, MA_OWNED);
161 pfs_assert_not_owned(pn);
162 return ((pn->pn_vis)(PFS_VIS_ARGNAMES));
166 pn_ioctl(PFS_IOCTL_ARGS)
169 PFS_TRACE(("%s", pn->pn_name));
170 KASSERT(pn->pn_ioctl != NULL, ("%s(): no callback", __func__));
172 PROC_LOCK_ASSERT(p, MA_OWNED);
173 pfs_assert_not_owned(pn);
174 return ((pn->pn_ioctl)(PFS_IOCTL_ARGNAMES));
178 pn_getextattr(PFS_GETEXTATTR_ARGS)
181 PFS_TRACE(("%s", pn->pn_name));
182 KASSERT(pn->pn_getextattr != NULL, ("%s(): no callback", __func__));
184 PROC_LOCK_ASSERT(p, MA_OWNED);
185 pfs_assert_not_owned(pn);
186 return ((pn->pn_getextattr)(PFS_GETEXTATTR_ARGNAMES));
190 pn_close(PFS_CLOSE_ARGS)
193 PFS_TRACE(("%s", pn->pn_name));
194 KASSERT(pn->pn_close != NULL, ("%s(): no callback", __func__));
196 PROC_LOCK_ASSERT(p, MA_OWNED);
197 pfs_assert_not_owned(pn);
198 return ((pn->pn_close)(PFS_CLOSE_ARGNAMES));
202 pn_destroy(PFS_DESTROY_ARGS)
205 PFS_TRACE(("%s", pn->pn_name));
206 KASSERT(pn->pn_destroy != NULL, ("%s(): no callback", __func__));
207 pfs_assert_not_owned(pn);
208 return ((pn->pn_destroy)(PFS_DESTROY_ARGNAMES));