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