xref: /titanic_52/usr/src/uts/common/sys/objfs_impl.h (revision da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*da6c28aaSamw  * Common Development and Distribution License (the "License").
6*da6c28aaSamw  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*da6c28aaSamw  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_OBJFS_IMPL_H
277c478bd9Sstevel@tonic-gate #define	_OBJFS_IMPL_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
327c478bd9Sstevel@tonic-gate #include <sys/vfs.h>
337c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
347c478bd9Sstevel@tonic-gate #include <sys/gfs.h>
357c478bd9Sstevel@tonic-gate #include <sys/objfs.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
387c478bd9Sstevel@tonic-gate extern "C" {
397c478bd9Sstevel@tonic-gate #endif
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate /*
427c478bd9Sstevel@tonic-gate  * VFS data object
437c478bd9Sstevel@tonic-gate  */
447c478bd9Sstevel@tonic-gate typedef struct objfs_vfs {
457c478bd9Sstevel@tonic-gate 	vnode_t	*objfs_vfs_root;
467c478bd9Sstevel@tonic-gate } objfs_vfs_t;
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate /*
497c478bd9Sstevel@tonic-gate  * Common vop_ entry points
507c478bd9Sstevel@tonic-gate  */
51*da6c28aaSamw extern int objfs_dir_open(vnode_t **, int, cred_t *, caller_context_t *);
52*da6c28aaSamw extern int objfs_dir_access(vnode_t *, int, int, cred_t *,
53*da6c28aaSamw     caller_context_t *);
54*da6c28aaSamw extern int objfs_common_close(vnode_t *, int, int, offset_t, cred_t *,
55*da6c28aaSamw     caller_context_t *);
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /*
587c478bd9Sstevel@tonic-gate  * Common vop_ support functions
597c478bd9Sstevel@tonic-gate  */
607c478bd9Sstevel@tonic-gate extern int objfs_common_getattr(vnode_t *, vattr_t *);
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate /*
637c478bd9Sstevel@tonic-gate  * Miscellaneous support functions
647c478bd9Sstevel@tonic-gate  */
657c478bd9Sstevel@tonic-gate extern int objfs_nobjs(void);
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate #define	OBJFS_NAME_MAX	MAXNAMELEN
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate /*
707c478bd9Sstevel@tonic-gate  * The root vnode has an inode number of 0xffffffff.  All other vnodes have an
717c478bd9Sstevel@tonic-gate  * inode that is an OR of the module id with the type of vnode.
727c478bd9Sstevel@tonic-gate  *
737c478bd9Sstevel@tonic-gate  * ----------------------------------------
747c478bd9Sstevel@tonic-gate  * |     type         |      mod_id       |
757c478bd9Sstevel@tonic-gate  * ----------------------------------------
767c478bd9Sstevel@tonic-gate  * 63                 31                  0
777c478bd9Sstevel@tonic-gate  *
787c478bd9Sstevel@tonic-gate  * This way, module directories will have an inode value equal to their module
797c478bd9Sstevel@tonic-gate  * id.
807c478bd9Sstevel@tonic-gate  */
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate #define	OBJFS_INO(modid, type)	\
837c478bd9Sstevel@tonic-gate 	(((uint64_t)(type) << 32) | (modid))
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate /*
867c478bd9Sstevel@tonic-gate  * Root directory
877c478bd9Sstevel@tonic-gate  */
887c478bd9Sstevel@tonic-gate typedef gfs_dir_t	objfs_rootnode_t;
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate #define	OBJFS_INO_ROOT	0xffffffff
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate extern const fs_operation_def_t objfs_tops_root[];
937c478bd9Sstevel@tonic-gate extern vnodeops_t *objfs_ops_root;
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate extern vnode_t *objfs_create_root(vfs_t *);
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate /*
987c478bd9Sstevel@tonic-gate  * Object directory
997c478bd9Sstevel@tonic-gate  */
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate typedef struct objfs_odirnode {
1027c478bd9Sstevel@tonic-gate 	gfs_dir_t		objfs_odir_dir;		/* gfs dir */
1037c478bd9Sstevel@tonic-gate 	struct modctl		*objfs_odir_modctl;	/* modctl pointer */
1047c478bd9Sstevel@tonic-gate } objfs_odirnode_t;
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate #define	OBJFS_INO_ODIR(modid)	OBJFS_INO(modid, 0)
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate extern const fs_operation_def_t objfs_tops_odir[];
1097c478bd9Sstevel@tonic-gate extern vnodeops_t *objfs_ops_odir;
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate extern vnode_t *objfs_create_odirnode(vnode_t *, struct modctl *);
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate /*
1147c478bd9Sstevel@tonic-gate  * Data file
1157c478bd9Sstevel@tonic-gate  */
1167c478bd9Sstevel@tonic-gate typedef struct objfs_datanode {
1177c478bd9Sstevel@tonic-gate 	gfs_file_t		objfs_data_file;	/* gfs file */
1187c478bd9Sstevel@tonic-gate 	objfs_info_t		objfs_data_info;
1197c478bd9Sstevel@tonic-gate 	int			objfs_data_gencount;	/* gen when opened */
1207c478bd9Sstevel@tonic-gate } objfs_datanode_t;
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate #define	OBJFS_INO_DATA(modid)	OBJFS_INO(modid, 1)
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate extern const fs_operation_def_t objfs_tops_data[];
1257c478bd9Sstevel@tonic-gate extern vnodeops_t *objfs_ops_data;
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate extern void objfs_data_init(void);
1287c478bd9Sstevel@tonic-gate extern vnode_t *objfs_create_data(vnode_t *);
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1317c478bd9Sstevel@tonic-gate }
1327c478bd9Sstevel@tonic-gate #endif
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate #endif	/* _OBJFS_IMPL_H */
135