xref: /illumos-gate/usr/src/uts/common/sys/objfs_impl.h (revision 2d6eb4a5)
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 #include <sys/modctl.h>
307c478bd9Sstevel@tonic-gate #include <sys/vfs.h>
317c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
327c478bd9Sstevel@tonic-gate #include <sys/gfs.h>
337c478bd9Sstevel@tonic-gate #include <sys/objfs.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
367c478bd9Sstevel@tonic-gate extern "C" {
377c478bd9Sstevel@tonic-gate #endif
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /*
407c478bd9Sstevel@tonic-gate  * VFS data object
417c478bd9Sstevel@tonic-gate  */
427c478bd9Sstevel@tonic-gate typedef struct objfs_vfs {
437c478bd9Sstevel@tonic-gate 	vnode_t	*objfs_vfs_root;
447c478bd9Sstevel@tonic-gate } objfs_vfs_t;
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate /*
477c478bd9Sstevel@tonic-gate  * Common vop_ entry points
487c478bd9Sstevel@tonic-gate  */
49*da6c28aaSamw extern int objfs_dir_open(vnode_t **, int, cred_t *, caller_context_t *);
50*da6c28aaSamw extern int objfs_dir_access(vnode_t *, int, int, cred_t *,
51*da6c28aaSamw     caller_context_t *);
52*da6c28aaSamw extern int objfs_common_close(vnode_t *, int, int, offset_t, cred_t *,
53*da6c28aaSamw     caller_context_t *);
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate /*
567c478bd9Sstevel@tonic-gate  * Common vop_ support functions
577c478bd9Sstevel@tonic-gate  */
587c478bd9Sstevel@tonic-gate extern int objfs_common_getattr(vnode_t *, vattr_t *);
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate /*
617c478bd9Sstevel@tonic-gate  * Miscellaneous support functions
627c478bd9Sstevel@tonic-gate  */
637c478bd9Sstevel@tonic-gate extern int objfs_nobjs(void);
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate #define	OBJFS_NAME_MAX	MAXNAMELEN
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate /*
687c478bd9Sstevel@tonic-gate  * The root vnode has an inode number of 0xffffffff.  All other vnodes have an
697c478bd9Sstevel@tonic-gate  * inode that is an OR of the module id with the type of vnode.
707c478bd9Sstevel@tonic-gate  *
717c478bd9Sstevel@tonic-gate  * ----------------------------------------
727c478bd9Sstevel@tonic-gate  * |     type         |      mod_id       |
737c478bd9Sstevel@tonic-gate  * ----------------------------------------
747c478bd9Sstevel@tonic-gate  * 63                 31                  0
757c478bd9Sstevel@tonic-gate  *
767c478bd9Sstevel@tonic-gate  * This way, module directories will have an inode value equal to their module
777c478bd9Sstevel@tonic-gate  * id.
787c478bd9Sstevel@tonic-gate  */
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate #define	OBJFS_INO(modid, type)	\
817c478bd9Sstevel@tonic-gate 	(((uint64_t)(type) << 32) | (modid))
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate /*
847c478bd9Sstevel@tonic-gate  * Root directory
857c478bd9Sstevel@tonic-gate  */
867c478bd9Sstevel@tonic-gate typedef gfs_dir_t	objfs_rootnode_t;
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate #define	OBJFS_INO_ROOT	0xffffffff
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate extern const fs_operation_def_t objfs_tops_root[];
917c478bd9Sstevel@tonic-gate extern vnodeops_t *objfs_ops_root;
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate extern vnode_t *objfs_create_root(vfs_t *);
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate /*
967c478bd9Sstevel@tonic-gate  * Object directory
977c478bd9Sstevel@tonic-gate  */
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate typedef struct objfs_odirnode {
1007c478bd9Sstevel@tonic-gate 	gfs_dir_t		objfs_odir_dir;		/* gfs dir */
1017c478bd9Sstevel@tonic-gate 	struct modctl		*objfs_odir_modctl;	/* modctl pointer */
1027c478bd9Sstevel@tonic-gate } objfs_odirnode_t;
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate #define	OBJFS_INO_ODIR(modid)	OBJFS_INO(modid, 0)
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate extern const fs_operation_def_t objfs_tops_odir[];
1077c478bd9Sstevel@tonic-gate extern vnodeops_t *objfs_ops_odir;
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate extern vnode_t *objfs_create_odirnode(vnode_t *, struct modctl *);
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate /*
1127c478bd9Sstevel@tonic-gate  * Data file
1137c478bd9Sstevel@tonic-gate  */
1147c478bd9Sstevel@tonic-gate typedef struct objfs_datanode {
1157c478bd9Sstevel@tonic-gate 	gfs_file_t		objfs_data_file;	/* gfs file */
1167c478bd9Sstevel@tonic-gate 	objfs_info_t		objfs_data_info;
1177c478bd9Sstevel@tonic-gate 	int			objfs_data_gencount;	/* gen when opened */
1187c478bd9Sstevel@tonic-gate } objfs_datanode_t;
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate #define	OBJFS_INO_DATA(modid)	OBJFS_INO(modid, 1)
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate extern const fs_operation_def_t objfs_tops_data[];
1237c478bd9Sstevel@tonic-gate extern vnodeops_t *objfs_ops_data;
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate extern void objfs_data_init(void);
1267c478bd9Sstevel@tonic-gate extern vnode_t *objfs_create_data(vnode_t *);
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1297c478bd9Sstevel@tonic-gate }
1307c478bd9Sstevel@tonic-gate #endif
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate #endif	/* _OBJFS_IMPL_H */
133