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/id_space.h> 20 #include <sys/types.h> 21 #include <sys/vfs.h> 22 #include <sys/vnode.h> 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 typedef id_t fsh_handle_t; 29 typedef id_t fsh_callback_handle_t; 30 31 struct fsh_int; 32 typedef struct fsh_int fsh_int_t; 33 34 typedef struct fsh { 35 void *arg; 36 37 /* vnode */ 38 int (*read)(fsh_int_t *, void *, vnode_t *, uio_t *, int, cred_t *, 39 caller_context_t *); 40 int (*write)(fsh_int_t *, void *, vnode_t *, uio_t *, int, cred_t *, 41 caller_context_t *); 42 43 /* vfs */ 44 int (*mount)(fsh_int_t *, void *, vfs_t *, vnode_t *, struct mounta *, 45 cred_t *); 46 int (*unmount)(fsh_int_t *, void *, vfs_t *, int, cred_t *); 47 } fsh_t; 48 49 typedef struct fsh_callback { 50 void *fshc_arg; 51 void (*fshc_free)(vfs_t *, void *); 52 void (*fshc_mount)(vfs_t *, void *); 53 } fsh_callback_t; 54 55 /* API */ 56 extern fsh_handle_t fsh_hook_install(vfs_t *, fsh_t *); 57 extern int fsh_hook_remove(fsh_handle_t); 58 59 extern fsh_callback_handle_t fsh_callback_install(fsh_callback_t *); 60 extern int fsh_callback_remove(fsh_callback_handle_t); 61 62 extern void fsh_fs_enable(vfs_t *); 63 extern void fsh_fs_disable(vfs_t *); 64 65 /* fsh control passing */ 66 extern int fsh_next_read(fsh_int_t *, vnode_t *, uio_t *, int, cred_t *, 67 caller_context_t *); 68 extern int fsh_next_write(fsh_int_t *, vnode_t *, uio_t *, int, cred_t *, 69 caller_context_t *); 70 71 extern int fsh_next_mount(fsh_int_t *, vfs_t *, vnode_t *, struct mounta *uap, 72 cred_t *); 73 extern int fsh_next_unmount(fsh_int_t *, vfs_t *, int, cred_t *); 74 75 #ifdef __cplusplus 76 } 77 #endif 78 79 #endif /* _FSH_H */