1*8329232eSGordon Ross /* 2*8329232eSGordon Ross * CDDL HEADER START 3*8329232eSGordon Ross * 4*8329232eSGordon Ross * The contents of this file are subject to the terms of the 5*8329232eSGordon Ross * Common Development and Distribution License (the "License"). 6*8329232eSGordon Ross * You may not use this file except in compliance with the License. 7*8329232eSGordon Ross * 8*8329232eSGordon Ross * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*8329232eSGordon Ross * or http://www.opensolaris.org/os/licensing. 10*8329232eSGordon Ross * See the License for the specific language governing permissions 11*8329232eSGordon Ross * and limitations under the License. 12*8329232eSGordon Ross * 13*8329232eSGordon Ross * When distributing Covered Code, include this CDDL HEADER in each 14*8329232eSGordon Ross * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*8329232eSGordon Ross * If applicable, add the following below this CDDL HEADER, with the 16*8329232eSGordon Ross * fields enclosed by brackets "[]" replaced with your own identifying 17*8329232eSGordon Ross * information: Portions Copyright [yyyy] [name of copyright owner] 18*8329232eSGordon Ross * 19*8329232eSGordon Ross * CDDL HEADER END 20*8329232eSGordon Ross */ 21*8329232eSGordon Ross /* 22*8329232eSGordon Ross * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23*8329232eSGordon Ross * Use is subject to license terms. 24*8329232eSGordon Ross * 25*8329232eSGordon Ross * Copyright 2017 Nexenta Systems, Inc. All rights reserved. 26*8329232eSGordon Ross */ 27*8329232eSGordon Ross 28*8329232eSGordon Ross #ifndef _SYS_VFS_OPREG_H 29*8329232eSGordon Ross #define _SYS_VFS_OPREG_H 30*8329232eSGordon Ross 31*8329232eSGordon Ross #include <sys/vfs.h> 32*8329232eSGordon Ross #include <sys/fem.h> 33*8329232eSGordon Ross 34*8329232eSGordon Ross #ifdef __cplusplus 35*8329232eSGordon Ross extern "C" { 36*8329232eSGordon Ross #endif 37*8329232eSGordon Ross 38*8329232eSGordon Ross #if defined(_KERNEL) || defined(_FAKE_KERNEL) 39*8329232eSGordon Ross 40*8329232eSGordon Ross /* 41*8329232eSGordon Ross * The following union allows us to use C99's "designated initializer" 42*8329232eSGordon Ross * feature so that we can have strong typechecking for the operations 43*8329232eSGordon Ross * used in the the fs_operation_def structures. 44*8329232eSGordon Ross */ 45*8329232eSGordon Ross 46*8329232eSGordon Ross typedef union fs_func { 47*8329232eSGordon Ross fs_generic_func_p fs_generic; /* Generic function signature */ 48*8329232eSGordon Ross int (*error)(); /* Signature of error function */ 49*8329232eSGordon Ross VFS_OPS; /* Signatures of all vfs operations (vfsops) */ 50*8329232eSGordon Ross VNODE_OPS; /* Signatures of all vnode operations (vops) */ 51*8329232eSGordon Ross FEM_OPS; /* Signatures of all FEM operations (femops) */ 52*8329232eSGordon Ross FSEM_OPS; /* Signatures of all FSEM ops (fsemops) */ 53*8329232eSGordon Ross } fs_func_p; 54*8329232eSGordon Ross 55*8329232eSGordon Ross /* 56*8329232eSGordon Ross * File systems use arrays of fs_operation_def structures to form 57*8329232eSGordon Ross * name/value pairs of operations. These arrays get passed to: 58*8329232eSGordon Ross * 59*8329232eSGordon Ross * - vn_make_ops() to create vnodeops 60*8329232eSGordon Ross * - vfs_makefsops()/vfs_setfsops() to create vfsops. 61*8329232eSGordon Ross */ 62*8329232eSGordon Ross typedef struct fs_operation_def { 63*8329232eSGordon Ross char *name; /* name of operation (NULL at end) */ 64*8329232eSGordon Ross fs_func_p func; /* function implementing operation */ 65*8329232eSGordon Ross } fs_operation_def_t; 66*8329232eSGordon Ross 67*8329232eSGordon Ross /* 68*8329232eSGordon Ross * The operation registration mechanism uses two master tables of operations: 69*8329232eSGordon Ross * one for vnode operations (vn_ops_table[]) and one for vfs operations 70*8329232eSGordon Ross * (vfs_ops_table[]). These tables are arrays of fs_operation_trans_def 71*8329232eSGordon Ross * structures. They contain all of the information necessary for the system 72*8329232eSGordon Ross * to populate an operations structure (e.g., vnodeops, vfsops). 73*8329232eSGordon Ross * 74*8329232eSGordon Ross * File systems call registration routines (vfs_setfsops(), vfs_makefsops(), 75*8329232eSGordon Ross * and vn_make_ops()) and pass in their operations specification tables 76*8329232eSGordon Ross * (arrays of fs_operation_def structures). These routines use the master 77*8329232eSGordon Ross * table(s) of operations to build a vnodeops or vfsops structure. 78*8329232eSGordon Ross */ 79*8329232eSGordon Ross typedef struct fs_operation_trans_def { 80*8329232eSGordon Ross char *name; /* name of operation (NULL at end) */ 81*8329232eSGordon Ross int offset; /* byte offset within ops vector */ 82*8329232eSGordon Ross fs_generic_func_p defaultFunc; /* default function */ 83*8329232eSGordon Ross fs_generic_func_p errorFunc; /* error function */ 84*8329232eSGordon Ross } fs_operation_trans_def_t; 85*8329232eSGordon Ross 86*8329232eSGordon Ross /* 87*8329232eSGordon Ross * Generic operations vector types (used for vfs/vnode ops registration). 88*8329232eSGordon Ross */ 89*8329232eSGordon Ross 90*8329232eSGordon Ross extern int fs_default(); /* "default" function placeholder */ 91*8329232eSGordon Ross extern int fs_error(); /* "error" function placeholder */ 92*8329232eSGordon Ross 93*8329232eSGordon Ross int fs_build_vector(void *vector, int *unused_ops, 94*8329232eSGordon Ross const fs_operation_trans_def_t *translation, 95*8329232eSGordon Ross const fs_operation_def_t *operations); 96*8329232eSGordon Ross 97*8329232eSGordon Ross /* 98*8329232eSGordon Ross * Public operations. 99*8329232eSGordon Ross */ 100*8329232eSGordon Ross 101*8329232eSGordon Ross int vn_make_ops(const char *, const struct fs_operation_def *, 102*8329232eSGordon Ross vnodeops_t **); 103*8329232eSGordon Ross void vn_freevnodeops(vnodeops_t *); 104*8329232eSGordon Ross 105*8329232eSGordon Ross int vfs_setfsops(int, const fs_operation_def_t *, vfsops_t **); 106*8329232eSGordon Ross int vfs_makefsops(const fs_operation_def_t *, vfsops_t **); 107*8329232eSGordon Ross void vfs_freevfsops(vfsops_t *); 108*8329232eSGordon Ross int vfs_freevfsops_by_type(int); 109*8329232eSGordon Ross 110*8329232eSGordon Ross #endif /* _KERNEL */ 111*8329232eSGordon Ross 112*8329232eSGordon Ross #ifdef __cplusplus 113*8329232eSGordon Ross } 114*8329232eSGordon Ross #endif 115*8329232eSGordon Ross 116*8329232eSGordon Ross #endif /* _SYS_VFS_OPREG_H */ 117