xref: /titanic_41/usr/src/uts/common/sys/ctfs_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	_SYS_CTFS_IMPL_H
277c478bd9Sstevel@tonic-gate #define	_SYS_CTFS_IMPL_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include <sys/contract.h>
327c478bd9Sstevel@tonic-gate #include <sys/gfs.h>
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
357c478bd9Sstevel@tonic-gate extern "C" {
367c478bd9Sstevel@tonic-gate #endif
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate /*
397c478bd9Sstevel@tonic-gate  * Inode numbers
407c478bd9Sstevel@tonic-gate  */
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  * Root inode:
447c478bd9Sstevel@tonic-gate  * ---------------------------------------------------
457c478bd9Sstevel@tonic-gate  * |                       0                         |
467c478bd9Sstevel@tonic-gate  * ---------------------------------------------------
477c478bd9Sstevel@tonic-gate  * 63						     0
487c478bd9Sstevel@tonic-gate  */
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate #define	CTFS_INO_ROOT 0
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * Contract-specific file:
547c478bd9Sstevel@tonic-gate  * ---------------------------------------------------
557c478bd9Sstevel@tonic-gate  * |1|    file (62:32)     |   contract id (31:0)    |
567c478bd9Sstevel@tonic-gate  * ---------------------------------------------------
577c478bd9Sstevel@tonic-gate  * 63						     0
587c478bd9Sstevel@tonic-gate  *	file = 0 : directory
597c478bd9Sstevel@tonic-gate  *	file = 1 : "all" directory symlink
607c478bd9Sstevel@tonic-gate  *	file > 1 : special files ("ctl", "status", etc.)
617c478bd9Sstevel@tonic-gate  */
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate #define	CTFS_INO_CT_SHIFT	32
647c478bd9Sstevel@tonic-gate #define	CTFS_INO_CT(ctid, file)	\
657c478bd9Sstevel@tonic-gate 	((1ULL << 63) | \
667c478bd9Sstevel@tonic-gate 	((unsigned long long)(file) << CTFS_INO_CT_SHIFT) | \
677c478bd9Sstevel@tonic-gate 	(ctid))
687c478bd9Sstevel@tonic-gate #define	CTFS_INO_CT_DIR(ctid)		CTFS_INO_CT((ctid), 0)
697c478bd9Sstevel@tonic-gate #define	CTFS_INO_CT_LINK(ctid)		CTFS_INO_CT((ctid), 1)
707c478bd9Sstevel@tonic-gate #define	CTFS_INO_CT_FILE(ctid, file)	CTFS_INO_CT((ctid), (file) + 2)
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate /*
737c478bd9Sstevel@tonic-gate  * Type-specific file:
747c478bd9Sstevel@tonic-gate  * ---------------------------------------------------
757c478bd9Sstevel@tonic-gate  * |          0         | type (31:16) | file (15:0) |
767c478bd9Sstevel@tonic-gate  * ---------------------------------------------------
777c478bd9Sstevel@tonic-gate  * 63						     0
787c478bd9Sstevel@tonic-gate  *	type = 0 : invalid
797c478bd9Sstevel@tonic-gate  *	type > 0 : contract type index + 1 ("all" is #types + 1)
807c478bd9Sstevel@tonic-gate  *	file = 0 : directory
817c478bd9Sstevel@tonic-gate  *	file > 0 : special files ("template", "latest", etc.)
827c478bd9Sstevel@tonic-gate  */
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate #define	CTFS_INO_TYPE_SHIFT	16
857c478bd9Sstevel@tonic-gate #define	CTFS_INO_TYPE(type, file)	\
867c478bd9Sstevel@tonic-gate 	(((type) + 1) << CTFS_INO_TYPE_SHIFT | (file))
877c478bd9Sstevel@tonic-gate #define	CTFS_INO_TYPE_DIR(type)		CTFS_INO_TYPE((type), 0)
887c478bd9Sstevel@tonic-gate #define	CTFS_INO_TYPE_FILE(type, file)	CTFS_INO_TYPE((type), (file) + 1)
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate /*
917c478bd9Sstevel@tonic-gate  * Other constants
927c478bd9Sstevel@tonic-gate  */
937c478bd9Sstevel@tonic-gate #define	CTFS_NAME_MAX		32
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate /*
967c478bd9Sstevel@tonic-gate  * Possible values for ctfs_endpt_flags, below.
977c478bd9Sstevel@tonic-gate  */
987c478bd9Sstevel@tonic-gate #define	CTFS_ENDPT_SETUP	0x1
997c478bd9Sstevel@tonic-gate #define	CTFS_ENDPT_NBLOCK	0x2
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate /*
1027c478bd9Sstevel@tonic-gate  * Common endpoint object.
1037c478bd9Sstevel@tonic-gate  */
1047c478bd9Sstevel@tonic-gate typedef struct ctfs_endpoint {
1057c478bd9Sstevel@tonic-gate 	kmutex_t	ctfs_endpt_lock;
1067c478bd9Sstevel@tonic-gate 	ct_listener_t	ctfs_endpt_listener;
1077c478bd9Sstevel@tonic-gate 	uint_t		ctfs_endpt_flags;
1087c478bd9Sstevel@tonic-gate } ctfs_endpoint_t;
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate /*
1117c478bd9Sstevel@tonic-gate  * root directory data
1127c478bd9Sstevel@tonic-gate  */
1137c478bd9Sstevel@tonic-gate typedef gfs_dir_t	ctfs_rootnode_t;
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate /*
1167c478bd9Sstevel@tonic-gate  * /all directory data
1177c478bd9Sstevel@tonic-gate  */
1187c478bd9Sstevel@tonic-gate typedef gfs_dir_t	ctfs_adirnode_t;
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate /*
1217c478bd9Sstevel@tonic-gate  * /all symlink data
1227c478bd9Sstevel@tonic-gate  */
1237c478bd9Sstevel@tonic-gate typedef struct ctfs_symnode {
1247c478bd9Sstevel@tonic-gate 	gfs_file_t	ctfs_sn_file;		/* gfs file */
1257c478bd9Sstevel@tonic-gate 	contract_t	*ctfs_sn_contract;	/* target contract */
1267c478bd9Sstevel@tonic-gate 	char		*ctfs_sn_string;	/* target path */
1277c478bd9Sstevel@tonic-gate 	size_t		ctfs_sn_size;		/* length of target path */
1287c478bd9Sstevel@tonic-gate } ctfs_symnode_t;
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate /*
1317c478bd9Sstevel@tonic-gate  * contract type directory data
1327c478bd9Sstevel@tonic-gate  */
1337c478bd9Sstevel@tonic-gate typedef	gfs_dir_t	ctfs_tdirnode_t;
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate /*
1367c478bd9Sstevel@tonic-gate  * contract directory data
1377c478bd9Sstevel@tonic-gate  */
1387c478bd9Sstevel@tonic-gate typedef struct ctfs_cdirnode {
1397c478bd9Sstevel@tonic-gate 	gfs_dir_t	ctfs_cn_dir;		/* directory contents */
1407c478bd9Sstevel@tonic-gate 	contract_t	*ctfs_cn_contract;	/* contract pointer */
1417c478bd9Sstevel@tonic-gate 	contract_vnode_t ctfs_cn_linkage;	/* contract vnode list node */
1427c478bd9Sstevel@tonic-gate } ctfs_cdirnode_t;
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate /*
1457c478bd9Sstevel@tonic-gate  * template file data
1467c478bd9Sstevel@tonic-gate  */
1477c478bd9Sstevel@tonic-gate typedef struct ctfs_tmplnode {
1487c478bd9Sstevel@tonic-gate 	gfs_file_t	ctfs_tmn_file;		/* gfs file */
1497c478bd9Sstevel@tonic-gate 	ct_template_t	*ctfs_tmn_tmpl;		/* template pointer */
1507c478bd9Sstevel@tonic-gate } ctfs_tmplnode_t;
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate /*
1537c478bd9Sstevel@tonic-gate  * ctl and status file data
1547c478bd9Sstevel@tonic-gate  */
1557c478bd9Sstevel@tonic-gate typedef struct ctfs_ctlnode {
1567c478bd9Sstevel@tonic-gate 	gfs_file_t	ctfs_ctl_file;		/* gfs file */
1577c478bd9Sstevel@tonic-gate 	contract_t	*ctfs_ctl_contract;	/* contract pointer */
1587c478bd9Sstevel@tonic-gate } ctfs_ctlnode_t;
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate /*
1617c478bd9Sstevel@tonic-gate  * latest file data
1627c478bd9Sstevel@tonic-gate  */
1637c478bd9Sstevel@tonic-gate typedef gfs_dir_t	ctfs_latenode_t;
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate /*
1667c478bd9Sstevel@tonic-gate  * events file data
1677c478bd9Sstevel@tonic-gate  */
1687c478bd9Sstevel@tonic-gate typedef struct ctfs_evnode {
1697c478bd9Sstevel@tonic-gate 	gfs_file_t	ctfs_ev_file;		/* gfs file */
1707c478bd9Sstevel@tonic-gate 	contract_t	*ctfs_ev_contract;	/* contract we're watching */
1717c478bd9Sstevel@tonic-gate 	ctfs_endpoint_t	ctfs_ev_listener;	/* common endpoint data */
1727c478bd9Sstevel@tonic-gate } ctfs_evnode_t;
1737c478bd9Sstevel@tonic-gate 
1747c478bd9Sstevel@tonic-gate /*
1757c478bd9Sstevel@tonic-gate  * bundle and pbundle file data
1767c478bd9Sstevel@tonic-gate  */
1777c478bd9Sstevel@tonic-gate typedef struct ctfs_bunode {
1787c478bd9Sstevel@tonic-gate 	gfs_file_t	ctfs_bu_file;		/* gfs file */
1797c478bd9Sstevel@tonic-gate 	ct_equeue_t	*ctfs_bu_queue;		/* queue we're watching */
1807c478bd9Sstevel@tonic-gate 	ctfs_endpoint_t	ctfs_bu_listener;	/* common endpoint data */
1817c478bd9Sstevel@tonic-gate } ctfs_bunode_t;
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate /*
1847c478bd9Sstevel@tonic-gate  * VFS data object
1857c478bd9Sstevel@tonic-gate  */
1867c478bd9Sstevel@tonic-gate typedef struct ctfs_vfs {
1877c478bd9Sstevel@tonic-gate 	vnode_t	*ctvfs_root;		/* root vnode pointer */
1887c478bd9Sstevel@tonic-gate } ctfs_vfs_t;
1897c478bd9Sstevel@tonic-gate 
1907c478bd9Sstevel@tonic-gate /*
1917c478bd9Sstevel@tonic-gate  * vnode creation routines
1927c478bd9Sstevel@tonic-gate  */
1937c478bd9Sstevel@tonic-gate extern vnode_t *ctfs_create_tdirnode(vnode_t *);
1947c478bd9Sstevel@tonic-gate extern vnode_t *ctfs_create_tmplnode(vnode_t *);
1957c478bd9Sstevel@tonic-gate extern vnode_t *ctfs_create_latenode(vnode_t *);
1967c478bd9Sstevel@tonic-gate extern vnode_t *ctfs_create_pbundle(vnode_t *);
1977c478bd9Sstevel@tonic-gate extern vnode_t *ctfs_create_bundle(vnode_t *);
1987c478bd9Sstevel@tonic-gate extern vnode_t *ctfs_create_ctlnode(vnode_t *);
1997c478bd9Sstevel@tonic-gate extern vnode_t *ctfs_create_statnode(vnode_t *);
2007c478bd9Sstevel@tonic-gate extern vnode_t *ctfs_create_evnode(vnode_t *);
2017c478bd9Sstevel@tonic-gate extern vnode_t *ctfs_create_adirnode(vnode_t *);
2027c478bd9Sstevel@tonic-gate extern vnode_t *ctfs_create_cdirnode(vnode_t *, contract_t *);
2037c478bd9Sstevel@tonic-gate extern vnode_t *ctfs_create_symnode(vnode_t *, contract_t *);
2047c478bd9Sstevel@tonic-gate 
2057c478bd9Sstevel@tonic-gate /*
2067c478bd9Sstevel@tonic-gate  * common ctfs routines
2077c478bd9Sstevel@tonic-gate  */
2087c478bd9Sstevel@tonic-gate extern void ctfs_common_getattr(vnode_t *, vattr_t *);
209*da6c28aaSamw extern int ctfs_close(vnode_t *, int, int, offset_t, cred_t *,
210*da6c28aaSamw 		caller_context_t *);
211*da6c28aaSamw extern int ctfs_access_dir(vnode_t *, int, int, cred_t *,
212*da6c28aaSamw 		caller_context_t *);
213*da6c28aaSamw extern int ctfs_access_readonly(vnode_t *, int, int, cred_t *,
214*da6c28aaSamw 		caller_context_t *);
215*da6c28aaSamw extern int ctfs_access_readwrite(vnode_t *, int, int, cred_t *,
216*da6c28aaSamw 		caller_context_t *);
217*da6c28aaSamw extern int ctfs_open(vnode_t **, int, cred_t *,
218*da6c28aaSamw 		caller_context_t *);
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate /*
2217c478bd9Sstevel@tonic-gate  * vnode ops vector templates
2227c478bd9Sstevel@tonic-gate  */
2237c478bd9Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_root;
2247c478bd9Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_adir;
2257c478bd9Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_sym;
2267c478bd9Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_tdir;
2277c478bd9Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_tmpl;
2287c478bd9Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_cdir;
2297c478bd9Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_ctl;
2307c478bd9Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_stat;
2317c478bd9Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_event;
2327c478bd9Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_bundle;
2337c478bd9Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_latest;
2347c478bd9Sstevel@tonic-gate 
2357c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2367c478bd9Sstevel@tonic-gate }
2377c478bd9Sstevel@tonic-gate #endif
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate #endif	/* _SYS_CTFS_IMPL_H */
240