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