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