4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_CTFS_IMPL_H
27 #define _SYS_CTFS_IMPL_H
29 #pragma ident "%Z%%M% %I% %E% SMI"
31 #include <sys/contract.h>
44 * ---------------------------------------------------
46 * ---------------------------------------------------
50 #define CTFS_INO_ROOT 0
53 * Contract-specific file:
54 * ---------------------------------------------------
55 * |1| file (62:32) | contract id (31:0) |
56 * ---------------------------------------------------
58 * file = 0 : directory
59 * file = 1 : "all" directory symlink
60 * file > 1 : special files ("ctl", "status", etc.)
63 #define CTFS_INO_CT_SHIFT 32
64 #define CTFS_INO_CT(ctid, file) \
66 ((unsigned long long)(file) << CTFS_INO_CT_SHIFT) | \
68 #define CTFS_INO_CT_DIR(ctid) CTFS_INO_CT((ctid), 0)
69 #define CTFS_INO_CT_LINK(ctid) CTFS_INO_CT((ctid), 1)
70 #define CTFS_INO_CT_FILE(ctid, file) CTFS_INO_CT((ctid), (file) + 2)
74 * ---------------------------------------------------
75 * | 0 | type (31:16) | file (15:0) |
76 * ---------------------------------------------------
79 * type > 0 : contract type index + 1 ("all" is #types + 1)
80 * file = 0 : directory
81 * file > 0 : special files ("template", "latest", etc.)
84 #define CTFS_INO_TYPE_SHIFT 16
85 #define CTFS_INO_TYPE(type, file) \
86 (((type) + 1) << CTFS_INO_TYPE_SHIFT | (file))
87 #define CTFS_INO_TYPE_DIR(type) CTFS_INO_TYPE((type), 0)
88 #define CTFS_INO_TYPE_FILE(type, file) CTFS_INO_TYPE((type), (file) + 1)
93 #define CTFS_NAME_MAX 32
96 * Possible values for ctfs_endpt_flags, below.
98 #define CTFS_ENDPT_SETUP 0x1
99 #define CTFS_ENDPT_NBLOCK 0x2
102 * Common endpoint object.
104 typedef struct ctfs_endpoint
{
105 kmutex_t ctfs_endpt_lock
;
106 ct_listener_t ctfs_endpt_listener
;
107 uint_t ctfs_endpt_flags
;
111 * root directory data
113 typedef gfs_dir_t ctfs_rootnode_t
;
116 * /all directory data
118 typedef gfs_dir_t ctfs_adirnode_t
;
123 typedef struct ctfs_symnode
{
124 gfs_file_t ctfs_sn_file
; /* gfs file */
125 contract_t
*ctfs_sn_contract
; /* target contract */
126 char *ctfs_sn_string
; /* target path */
127 size_t ctfs_sn_size
; /* length of target path */
131 * contract type directory data
133 typedef gfs_dir_t ctfs_tdirnode_t
;
136 * contract directory data
138 typedef struct ctfs_cdirnode
{
139 gfs_dir_t ctfs_cn_dir
; /* directory contents */
140 contract_t
*ctfs_cn_contract
; /* contract pointer */
141 contract_vnode_t ctfs_cn_linkage
; /* contract vnode list node */
147 typedef struct ctfs_tmplnode
{
148 gfs_file_t ctfs_tmn_file
; /* gfs file */
149 ct_template_t
*ctfs_tmn_tmpl
; /* template pointer */
153 * ctl and status file data
155 typedef struct ctfs_ctlnode
{
156 gfs_file_t ctfs_ctl_file
; /* gfs file */
157 contract_t
*ctfs_ctl_contract
; /* contract pointer */
163 typedef gfs_dir_t ctfs_latenode_t
;
168 typedef struct ctfs_evnode
{
169 gfs_file_t ctfs_ev_file
; /* gfs file */
170 contract_t
*ctfs_ev_contract
; /* contract we're watching */
171 ctfs_endpoint_t ctfs_ev_listener
; /* common endpoint data */
175 * bundle and pbundle file data
177 typedef struct ctfs_bunode
{
178 gfs_file_t ctfs_bu_file
; /* gfs file */
179 ct_equeue_t
*ctfs_bu_queue
; /* queue we're watching */
180 ctfs_endpoint_t ctfs_bu_listener
; /* common endpoint data */
186 typedef struct ctfs_vfs
{
187 vnode_t
*ctvfs_root
; /* root vnode pointer */
191 * vnode creation routines
193 extern vnode_t
*ctfs_create_tdirnode(vnode_t
*);
194 extern vnode_t
*ctfs_create_tmplnode(vnode_t
*);
195 extern vnode_t
*ctfs_create_latenode(vnode_t
*);
196 extern vnode_t
*ctfs_create_pbundle(vnode_t
*);
197 extern vnode_t
*ctfs_create_bundle(vnode_t
*);
198 extern vnode_t
*ctfs_create_ctlnode(vnode_t
*);
199 extern vnode_t
*ctfs_create_statnode(vnode_t
*);
200 extern vnode_t
*ctfs_create_evnode(vnode_t
*);
201 extern vnode_t
*ctfs_create_adirnode(vnode_t
*);
202 extern vnode_t
*ctfs_create_cdirnode(vnode_t
*, contract_t
*);
203 extern vnode_t
*ctfs_create_symnode(vnode_t
*, contract_t
*);
206 * common ctfs routines
208 extern void ctfs_common_getattr(vnode_t
*, vattr_t
*);
209 extern int ctfs_close(vnode_t
*, int, int, offset_t
, cred_t
*,
211 extern int ctfs_access_dir(vnode_t
*, int, int, cred_t
*,
213 extern int ctfs_access_readonly(vnode_t
*, int, int, cred_t
*,
215 extern int ctfs_access_readwrite(vnode_t
*, int, int, cred_t
*,
217 extern int ctfs_open(vnode_t
**, int, cred_t
*,
221 * vnode ops vector templates
223 extern const struct vnodeops ctfs_ops_root
;
224 extern const struct vnodeops ctfs_ops_adir
;
225 extern const struct vnodeops ctfs_ops_sym
;
226 extern const struct vnodeops ctfs_ops_tdir
;
227 extern const struct vnodeops ctfs_ops_tmpl
;
228 extern const struct vnodeops ctfs_ops_cdir
;
229 extern const struct vnodeops ctfs_ops_ctl
;
230 extern const struct vnodeops ctfs_ops_stat
;
231 extern const struct vnodeops ctfs_ops_event
;
232 extern const struct vnodeops ctfs_ops_bundle
;
233 extern const struct vnodeops ctfs_ops_latest
;
239 #endif /* _SYS_CTFS_IMPL_H */