xref: /titanic_41/usr/src/uts/common/sys/vfs_opreg.h (revision 9e39c5ba00a55fa05777cc94b148296af305e135)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_VFS_OPREG_H
27 #define	_SYS_VFS_OPREG_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/vfs.h>
32 #include <sys/fem.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 #ifdef _KERNEL
39 
40 /*
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.
44  */
45 
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) */
53 } fs_func_p;
54 
55 /*
56  * File systems use arrays of fs_operation_def structures to form
57  * name/value pairs of operations.  These arrays get passed to:
58  *
59  * 	- vn_make_ops() to create vnodeops
60  * 	- vfs_makefsops()/vfs_setfsops() to create vfsops.
61  */
62 typedef struct fs_operation_def {
63 	char *name;			/* name of operation (NULL at end) */
64 	fs_func_p func;			/* function implementing operation */
65 } fs_operation_def_t;
66 
67 /*
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).
73  *
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.
78  */
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;
85 
86 /*
87  * Generic operations vector types (used for vfs/vnode ops registration).
88  */
89 
90 extern int fs_default();		/* "default" function placeholder */
91 extern int fs_error();			/* "error" function placeholder */
92 
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);
96 
97 /*
98  * Public operations.
99  */
100 
101 int	vn_make_ops(const char *, const struct fs_operation_def *,
102 		vnodeops_t **);
103 void	vn_freevnodeops(vnodeops_t *);
104 
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);
109 
110 #endif /* _KERNEL */
111 
112 #ifdef	__cplusplus
113 }
114 #endif
115 
116 #endif	/* _SYS_VFS_OPREG_H */
117