xref: /titanic_44/usr/src/uts/common/sys/objfs_impl.h (revision ee5416c9d7e449233197d5d20bc6b81e4ff091b2)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_OBJFS_IMPL_H
28 #define	_OBJFS_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/modctl.h>
33 #include <sys/vfs.h>
34 #include <sys/vnode.h>
35 #include <sys/gfs.h>
36 #include <sys/objfs.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * VFS data object
44  */
45 typedef struct objfs_vfs {
46 	vnode_t	*objfs_vfs_root;
47 } objfs_vfs_t;
48 
49 /*
50  * Common vop_ entry points
51  */
52 extern int objfs_dir_open(vnode_t **, int, cred_t *);
53 extern int objfs_dir_access(vnode_t *, int, int, cred_t *);
54 extern int objfs_common_close(vnode_t *, int, int, offset_t, cred_t *);
55 
56 /*
57  * Common vop_ support functions
58  */
59 extern int objfs_common_getattr(vnode_t *, vattr_t *);
60 
61 /*
62  * Miscellaneous support functions
63  */
64 extern int objfs_nobjs(void);
65 
66 #define	OBJFS_NAME_MAX	MAXNAMELEN
67 
68 /*
69  * The root vnode has an inode number of 0xffffffff.  All other vnodes have an
70  * inode that is an OR of the module id with the type of vnode.
71  *
72  * ----------------------------------------
73  * |     type         |      mod_id       |
74  * ----------------------------------------
75  * 63                 31                  0
76  *
77  * This way, module directories will have an inode value equal to their module
78  * id.
79  */
80 
81 #define	OBJFS_INO(modid, type)	\
82 	(((uint64_t)(type) << 32) | (modid))
83 
84 /*
85  * Root directory
86  */
87 typedef gfs_dir_t	objfs_rootnode_t;
88 
89 #define	OBJFS_INO_ROOT	0xffffffff
90 
91 extern const fs_operation_def_t objfs_tops_root[];
92 extern vnodeops_t *objfs_ops_root;
93 
94 extern vnode_t *objfs_create_root(vfs_t *);
95 
96 /*
97  * Object directory
98  */
99 
100 typedef struct objfs_odirnode {
101 	gfs_dir_t		objfs_odir_dir;		/* gfs dir */
102 	struct modctl		*objfs_odir_modctl;	/* modctl pointer */
103 } objfs_odirnode_t;
104 
105 #define	OBJFS_INO_ODIR(modid)	OBJFS_INO(modid, 0)
106 
107 extern const fs_operation_def_t objfs_tops_odir[];
108 extern vnodeops_t *objfs_ops_odir;
109 
110 extern vnode_t *objfs_create_odirnode(vnode_t *, struct modctl *);
111 
112 /*
113  * Data file
114  */
115 typedef struct objfs_datanode {
116 	gfs_file_t		objfs_data_file;	/* gfs file */
117 	objfs_info_t		objfs_data_info;
118 	int			objfs_data_gencount;	/* gen when opened */
119 } objfs_datanode_t;
120 
121 #define	OBJFS_INO_DATA(modid)	OBJFS_INO(modid, 1)
122 
123 extern const fs_operation_def_t objfs_tops_data[];
124 extern vnodeops_t *objfs_ops_data;
125 
126 extern void objfs_data_init(void);
127 extern vnode_t *objfs_create_data(vnode_t *);
128 
129 #ifdef	__cplusplus
130 }
131 #endif
132 
133 #endif	/* _OBJFS_IMPL_H */
134