xref: /titanic_51/usr/src/uts/common/sys/objfs_impl.h (revision 5a7763bf3e9db4cfe6cb523b096cb74af71e3793)
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	_OBJFS_IMPL_H
27 #define	_OBJFS_IMPL_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/modctl.h>
32 #include <sys/vfs.h>
33 #include <sys/vnode.h>
34 #include <sys/gfs.h>
35 #include <sys/objfs.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 /*
42  * VFS data object
43  */
44 typedef struct objfs_vfs {
45 	vnode_t	*objfs_vfs_root;
46 } objfs_vfs_t;
47 
48 /*
49  * Common vop_ entry points
50  */
51 extern int objfs_dir_open(vnode_t **, int, cred_t *, caller_context_t *);
52 extern int objfs_dir_access(vnode_t *, int, int, cred_t *,
53     caller_context_t *);
54 extern int objfs_common_close(vnode_t *, int, int, offset_t, cred_t *,
55     caller_context_t *);
56 
57 /*
58  * Common vop_ support functions
59  */
60 extern int objfs_common_getattr(vnode_t *, vattr_t *);
61 
62 /*
63  * Miscellaneous support functions
64  */
65 extern int objfs_nobjs(void);
66 
67 #define	OBJFS_NAME_MAX	MAXNAMELEN
68 
69 /*
70  * The root vnode has an inode number of 0xffffffff.  All other vnodes have an
71  * inode that is an OR of the module id with the type of vnode.
72  *
73  * ----------------------------------------
74  * |     type         |      mod_id       |
75  * ----------------------------------------
76  * 63                 31                  0
77  *
78  * This way, module directories will have an inode value equal to their module
79  * id.
80  */
81 
82 #define	OBJFS_INO(modid, type)	\
83 	(((uint64_t)(type) << 32) | (modid))
84 
85 /*
86  * Root directory
87  */
88 typedef gfs_dir_t	objfs_rootnode_t;
89 
90 #define	OBJFS_INO_ROOT	0xffffffff
91 
92 extern const fs_operation_def_t objfs_tops_root[];
93 extern vnodeops_t *objfs_ops_root;
94 
95 extern vnode_t *objfs_create_root(vfs_t *);
96 
97 /*
98  * Object directory
99  */
100 
101 typedef struct objfs_odirnode {
102 	gfs_dir_t		objfs_odir_dir;		/* gfs dir */
103 	struct modctl		*objfs_odir_modctl;	/* modctl pointer */
104 } objfs_odirnode_t;
105 
106 #define	OBJFS_INO_ODIR(modid)	OBJFS_INO(modid, 0)
107 
108 extern const fs_operation_def_t objfs_tops_odir[];
109 extern vnodeops_t *objfs_ops_odir;
110 
111 extern vnode_t *objfs_create_odirnode(vnode_t *, struct modctl *);
112 
113 /*
114  * Data file
115  */
116 typedef struct objfs_datanode {
117 	gfs_file_t		objfs_data_file;	/* gfs file */
118 	objfs_info_t		objfs_data_info;
119 	int			objfs_data_gencount;	/* gen when opened */
120 } objfs_datanode_t;
121 
122 #define	OBJFS_INO_DATA(modid)	OBJFS_INO(modid, 1)
123 
124 extern const fs_operation_def_t objfs_tops_data[];
125 extern vnodeops_t *objfs_ops_data;
126 
127 extern void objfs_data_init(void);
128 extern vnode_t *objfs_create_data(vnode_t *);
129 
130 #ifdef	__cplusplus
131 }
132 #endif
133 
134 #endif	/* _OBJFS_IMPL_H */
135