pkg: ship usr/lib/security/amd64/*.so links
[unleashed.git] / include / sys / vfs_dispatch.h
blob08c2db681a7e6b53f2ec167ae70ec512c9bb0a5a
1 /*
2 * Copyright 2017 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #ifndef _SYS_VFS_DISPATCH_H
18 #define _SYS_VFS_DISPATCH_H
20 #include <sys/vfs.h>
21 #include <sys/stdbool.h>
22 #include <sys/fem.h>
25 * Ideally these static inlines could be just inline statements in the
26 * corresponding fsop_*() functions. Unfortunately, fem gets in the way and
27 * we have to make these to centralize the damage.
29 * See comment in sys/vnode_dispatch.h for more details and an example.
32 #define VFS_DISPATCH(fname, opname, vheadname, args, callargs) \
33 static inline int fname args \
34 { \
35 if (check_fem && vfs->vfs_femhead != NULL) \
36 return vheadname callargs; \
37 if (vfs->vfs_op->opname == NULL) \
38 return ENOSYS; \
39 return vfs->vfs_op->opname callargs; \
42 VFS_DISPATCH(fsop_mount_dispatch, vfs_mount, fshead_mount,
43 (struct vfs *vfs, struct vnode *mvnode, struct mounta *uap, cred_t *cr,
44 bool check_fem),
45 (vfs, mvnode, uap, cr))
46 VFS_DISPATCH(fsop_unmount_dispatch, vfs_unmount, fshead_unmount,
47 (struct vfs *vfs, int flag, cred_t *cr, bool check_fem),
48 (vfs, flag, cr))
49 VFS_DISPATCH(fsop_root_dispatch, vfs_root, fshead_root,
50 (struct vfs *vfs, struct vnode **vnode, bool check_fem),
51 (vfs, vnode))
52 VFS_DISPATCH(fsop_statfs_dispatch, vfs_statvfs, fshead_statvfs,
53 (struct vfs *vfs, statvfs64_t *sp, bool check_fem),
54 (vfs, sp))
56 /* no-op by default, so it is hand-coded */
57 static inline int fsop_sync_dispatch(struct vfs *vfs, short flag, cred_t *cr,
58 bool check_fem)
60 if (check_fem && vfs->vfs_femhead != NULL)
61 return fshead_sync(vfs, flag, cr);
63 if (vfs->vfs_op->vfs_sync == NULL)
64 return 0;
66 return vfs->vfs_op->vfs_sync(vfs, flag, cr);
69 VFS_DISPATCH(fsop_vget_dispatch, vfs_vget, fshead_vget,
70 (struct vfs *vfs, struct vnode **vnode, fid_t *fid, bool check_fem),
71 (vfs, vnode, fid))
72 VFS_DISPATCH(fsop_mountroot_dispatch, vfs_mountroot, fshead_mountroot,
73 (struct vfs *vfs, enum whymountroot reason, bool check_fem),
74 (vfs, reason))
76 /* returns void, so it is hand-coded */
77 static inline void fsop_freefs_dispatch(struct vfs *vfs, bool check_fem)
79 if (check_fem && vfs->vfs_femhead != NULL)
80 fshead_freevfs(vfs);
81 else if (vfs->vfs_op->vfs_freevfs != NULL)
82 vfs->vfs_op->vfs_freevfs(vfs);
85 VFS_DISPATCH(fsop_vnstate_dispatch, vfs_vnstate, fshead_vnstate,
86 (struct vfs *vfs, struct vnode *vnode, vntrans_t nstate, bool check_fem),
87 (vfs, vnode, nstate))
89 #undef VFS_DISPATCH
91 #endif