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