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_node; 28 typedef struct fsh_node fsh_node_t; 29 30 #define FSH_OPS \ 31 int (*hook_open)(const fsh_node_t *fsh_node, void *arg, vnode_t **vpp, \ 32 int mode, cred_t *cr, caller_context_t *ct); \ 33 int (*hook_close)(const fsh_node_t *fsh_node, void *arg, vnode_t *vp, \ 34 int flag, int count, offset_t offset, cred_t *cr, \ 35 caller_context_t *ct); \ 36 int (*hook_read)(const fsh_node_t *fsh_node, void *arg, vnode_t *vp, \ 37 uio_t *uiop, int ioflag, cred_t *cr, caller_context_t *ct); \ 38 int (*hook_write)(const fsh_node_t *fsh_node, void *arg, vnode_t *vp, \ 39 uio_t *uiop, int ioflag, cred_t *cr, caller_context_t *ct); \ 40 /* vfs */ \ 41 int (*hook_mount)(const fsh_node_t *fsh_node, void *arg, vfs_t *vfsp, \ 42 vnode_t *mvp, struct mounta *uap, cred_t *cr); \ 43 int (*hook_unmount)(const fsh_node_t *fsh_node, void *arg, vfs_t *vfsp, \ 44 int flag, cred_t *cr); \ 45 int (*hook_root)(const fsh_node_t *fsh_node, void *arg, vfs_t *vfsp, \ 46 vnode_t **vpp); \ 47 int (*hook_statfs)(const fsh_node_t *fsh_node, void *arg, vfs_t *vfsp, \ 48 statvfs64_t *sp); \ 49 int (*hook_vget)(const fsh_node_t *fsh_node, void *arg, vfs_t *vfsp, \ 50 vnode_t **vpp, fid_t *fidp) /* NO ';' HERE */ 51 52 /* API */ 53 typedef struct fsh { 54 void *arg; 55 FSH_OPS; 56 } fsh_t; 57 58 extern int fsh_hook_install(vfs_t *vfsp, fsh_t *hooks); 59 extern int fsh_hook_remove(vfs_t *vfsp, fsh_t *hooks); 60 61 typedef struct fsh_callback { 62 void *fshc_arg; 63 void (*fshc_create)(vfs_t *vfsp, void *arg); 64 void (*fshc_destroy)(vfs_t *vfsp, void *arg); 65 } fsh_callback_t; 66 67 extern int fsh_callback_install(fsh_callback_t *fsh_callback); 68 extern int fsh_callback_remove(fsh_callback_t *fsh_callback); 69 70 extern int fsh_fs_enable(vfs_t *vfsp); 71 extern int fsh_fs_disable(vfs_t *vfsp); 72 73 74 /* fsh control passing */ 75 extern int fsh_next_open(fsh_node_t *fsh_node, vnode_t **vpp, 76 int mode, cred_t *cr, caller_context_t *ct); 77 extern int fsh_next_close(fsh_node_t *fsh_node, vnode_t *vp, 78 int flag, int count, offset_t offset, cred_t *cr, 79 caller_context_t *ct); 80 extern int fsh_next_read(fsh_node_t *fsh_node, vnode_t *vp, 81 uio_t *uiop, int ioflag, cred_t *cr, caller_context_t *ct); 82 extern int fsh_next_write(fsh_node_t *fsh_node, vnode_t *vp, 83 uio_t *uiop, int ioflag, cred_t *cr, caller_context_t *ct); 84 85 extern int fsh_next_mount(fsh_node_t *fsh_node, vfs_t *vfsp, 86 vnode_t *mvp, struct mounta *uap, cred_t *cr); 87 extern int fsh_next_unmount(fsh_node_t *fsh_node, vfs_t *vfsp, 88 int flag, cred_t *cr); 89 extern int fsh_next_root(fsh_node_t *fsh_node, vfs_t *vfsp, 90 vnode_t **vpp); 91 extern int fsh_next_statfs(fsh_node_t *fsh_node, vfs_t *vfsp, statvfs64_t *sp); 92 extern int fsh_next_vget(fsh_node_t *fsh_node, vfs_t *vfsp, 93 vnode_t **vpp, fid_t *fidp); 94 95 #ifdef __cplusplus 96 } 97 #endif 98 99 #endif /* _FSH_H */