1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2013 Damian Bogel. All rights reserved.
14 */
15
16 #ifndef _FSH_H
17 #define _FSH_H
18
19 #include <sys/types.h>
20 #include <sys/vfs.h>
21 #include <sys/vnode.h>
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 struct fsh_int;
28 typedef struct fsh_int fsh_int_t;
29
30 #define FSH_OPS \
31 /* vnode */ \
32 int (*hook_read)(fsh_int_t *fsh_int, void *arg, vnode_t *vp, \
33 uio_t *uiop, int ioflag, cred_t *cr, caller_context_t *ct); \
34 int (*hook_write)(fsh_int_t *fsh_int, void *arg, vnode_t *vp, \
35 uio_t *uiop, int ioflag, cred_t *cr, caller_context_t *ct); \
36 /* vfs */ \
37 int (*hook_mount)(fsh_int_t *fsh_int, void *arg, vfs_t *vfsp, \
38 vnode_t *mvp, struct mounta *uap, cred_t *cr); \
39 int (*hook_unmount)(fsh_int_t *fsh_int, void *arg, vfs_t *vfsp, \
40 int flag, cred_t *cr) \
41
42 /* API */
43 typedef struct fsh {
44 void *arg;
45 FSH_OPS;
46 } fsh_t;
47
48 extern void fsh_hook_install(vfs_t *vfsp, fsh_t *hooks);
49 extern void fsh_hook_remove(vfs_t *vfsp, fsh_t *hooks);
50
51 typedef struct fsh_callback {
52 void *fshc_arg;
53 void (*fshc_free)(vfs_t *vfsp, void *arg);
54 void (*fshc_mount)(vfs_t *vfsp, void *arg);
55 } fsh_callback_t;
56
57 extern void fsh_callback_install(fsh_callback_t *fsh_callback);
58 extern void fsh_callback_remove(fsh_callback_t *fsh_callback);
59
60 extern void fsh_fs_enable(vfs_t *vfsp);
61 extern void fsh_fs_disable(vfs_t *vfsp);
62
63 /* FSH control passing */
64 extern int fsh_next_read(fsh_int_t *fsh_int, vnode_t *vp,
65 uio_t *uiop, int ioflag, cred_t *cr, caller_context_t *ct);
66 extern int fsh_next_write(fsh_int_t *fsh_int, vnode_t *vp,
67 uio_t *uiop, int ioflag, cred_t *cr, caller_context_t *ct);
68
69 extern int fsh_next_mount(fsh_int_t *fsh_int, vfs_t *vfsp,
70 vnode_t *mvp, struct mounta *uap, cred_t *cr);
71 extern int fsh_next_unmount(fsh_int_t *fsh_int, vfs_t *vfsp,
72 int flag, cred_t *cr);
73
74 #ifdef __cplusplus
75 }
76 #endif
77
78 #endif /* _FSH_H */