10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*5331Samw * Common Development and Distribution License (the "License"). 6*5331Samw * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*5331Samw * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _SYS_CTFS_IMPL_H 270Sstevel@tonic-gate #define _SYS_CTFS_IMPL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include <sys/contract.h> 320Sstevel@tonic-gate #include <sys/gfs.h> 330Sstevel@tonic-gate 340Sstevel@tonic-gate #ifdef __cplusplus 350Sstevel@tonic-gate extern "C" { 360Sstevel@tonic-gate #endif 370Sstevel@tonic-gate 380Sstevel@tonic-gate /* 390Sstevel@tonic-gate * Inode numbers 400Sstevel@tonic-gate */ 410Sstevel@tonic-gate 420Sstevel@tonic-gate /* 430Sstevel@tonic-gate * Root inode: 440Sstevel@tonic-gate * --------------------------------------------------- 450Sstevel@tonic-gate * | 0 | 460Sstevel@tonic-gate * --------------------------------------------------- 470Sstevel@tonic-gate * 63 0 480Sstevel@tonic-gate */ 490Sstevel@tonic-gate 500Sstevel@tonic-gate #define CTFS_INO_ROOT 0 510Sstevel@tonic-gate 520Sstevel@tonic-gate /* 530Sstevel@tonic-gate * Contract-specific file: 540Sstevel@tonic-gate * --------------------------------------------------- 550Sstevel@tonic-gate * |1| file (62:32) | contract id (31:0) | 560Sstevel@tonic-gate * --------------------------------------------------- 570Sstevel@tonic-gate * 63 0 580Sstevel@tonic-gate * file = 0 : directory 590Sstevel@tonic-gate * file = 1 : "all" directory symlink 600Sstevel@tonic-gate * file > 1 : special files ("ctl", "status", etc.) 610Sstevel@tonic-gate */ 620Sstevel@tonic-gate 630Sstevel@tonic-gate #define CTFS_INO_CT_SHIFT 32 640Sstevel@tonic-gate #define CTFS_INO_CT(ctid, file) \ 650Sstevel@tonic-gate ((1ULL << 63) | \ 660Sstevel@tonic-gate ((unsigned long long)(file) << CTFS_INO_CT_SHIFT) | \ 670Sstevel@tonic-gate (ctid)) 680Sstevel@tonic-gate #define CTFS_INO_CT_DIR(ctid) CTFS_INO_CT((ctid), 0) 690Sstevel@tonic-gate #define CTFS_INO_CT_LINK(ctid) CTFS_INO_CT((ctid), 1) 700Sstevel@tonic-gate #define CTFS_INO_CT_FILE(ctid, file) CTFS_INO_CT((ctid), (file) + 2) 710Sstevel@tonic-gate 720Sstevel@tonic-gate /* 730Sstevel@tonic-gate * Type-specific file: 740Sstevel@tonic-gate * --------------------------------------------------- 750Sstevel@tonic-gate * | 0 | type (31:16) | file (15:0) | 760Sstevel@tonic-gate * --------------------------------------------------- 770Sstevel@tonic-gate * 63 0 780Sstevel@tonic-gate * type = 0 : invalid 790Sstevel@tonic-gate * type > 0 : contract type index + 1 ("all" is #types + 1) 800Sstevel@tonic-gate * file = 0 : directory 810Sstevel@tonic-gate * file > 0 : special files ("template", "latest", etc.) 820Sstevel@tonic-gate */ 830Sstevel@tonic-gate 840Sstevel@tonic-gate #define CTFS_INO_TYPE_SHIFT 16 850Sstevel@tonic-gate #define CTFS_INO_TYPE(type, file) \ 860Sstevel@tonic-gate (((type) + 1) << CTFS_INO_TYPE_SHIFT | (file)) 870Sstevel@tonic-gate #define CTFS_INO_TYPE_DIR(type) CTFS_INO_TYPE((type), 0) 880Sstevel@tonic-gate #define CTFS_INO_TYPE_FILE(type, file) CTFS_INO_TYPE((type), (file) + 1) 890Sstevel@tonic-gate 900Sstevel@tonic-gate /* 910Sstevel@tonic-gate * Other constants 920Sstevel@tonic-gate */ 930Sstevel@tonic-gate #define CTFS_NAME_MAX 32 940Sstevel@tonic-gate 950Sstevel@tonic-gate /* 960Sstevel@tonic-gate * Possible values for ctfs_endpt_flags, below. 970Sstevel@tonic-gate */ 980Sstevel@tonic-gate #define CTFS_ENDPT_SETUP 0x1 990Sstevel@tonic-gate #define CTFS_ENDPT_NBLOCK 0x2 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate /* 1020Sstevel@tonic-gate * Common endpoint object. 1030Sstevel@tonic-gate */ 1040Sstevel@tonic-gate typedef struct ctfs_endpoint { 1050Sstevel@tonic-gate kmutex_t ctfs_endpt_lock; 1060Sstevel@tonic-gate ct_listener_t ctfs_endpt_listener; 1070Sstevel@tonic-gate uint_t ctfs_endpt_flags; 1080Sstevel@tonic-gate } ctfs_endpoint_t; 1090Sstevel@tonic-gate 1100Sstevel@tonic-gate /* 1110Sstevel@tonic-gate * root directory data 1120Sstevel@tonic-gate */ 1130Sstevel@tonic-gate typedef gfs_dir_t ctfs_rootnode_t; 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate /* 1160Sstevel@tonic-gate * /all directory data 1170Sstevel@tonic-gate */ 1180Sstevel@tonic-gate typedef gfs_dir_t ctfs_adirnode_t; 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate /* 1210Sstevel@tonic-gate * /all symlink data 1220Sstevel@tonic-gate */ 1230Sstevel@tonic-gate typedef struct ctfs_symnode { 1240Sstevel@tonic-gate gfs_file_t ctfs_sn_file; /* gfs file */ 1250Sstevel@tonic-gate contract_t *ctfs_sn_contract; /* target contract */ 1260Sstevel@tonic-gate char *ctfs_sn_string; /* target path */ 1270Sstevel@tonic-gate size_t ctfs_sn_size; /* length of target path */ 1280Sstevel@tonic-gate } ctfs_symnode_t; 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate /* 1310Sstevel@tonic-gate * contract type directory data 1320Sstevel@tonic-gate */ 1330Sstevel@tonic-gate typedef gfs_dir_t ctfs_tdirnode_t; 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate /* 1360Sstevel@tonic-gate * contract directory data 1370Sstevel@tonic-gate */ 1380Sstevel@tonic-gate typedef struct ctfs_cdirnode { 1390Sstevel@tonic-gate gfs_dir_t ctfs_cn_dir; /* directory contents */ 1400Sstevel@tonic-gate contract_t *ctfs_cn_contract; /* contract pointer */ 1410Sstevel@tonic-gate contract_vnode_t ctfs_cn_linkage; /* contract vnode list node */ 1420Sstevel@tonic-gate } ctfs_cdirnode_t; 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate /* 1450Sstevel@tonic-gate * template file data 1460Sstevel@tonic-gate */ 1470Sstevel@tonic-gate typedef struct ctfs_tmplnode { 1480Sstevel@tonic-gate gfs_file_t ctfs_tmn_file; /* gfs file */ 1490Sstevel@tonic-gate ct_template_t *ctfs_tmn_tmpl; /* template pointer */ 1500Sstevel@tonic-gate } ctfs_tmplnode_t; 1510Sstevel@tonic-gate 1520Sstevel@tonic-gate /* 1530Sstevel@tonic-gate * ctl and status file data 1540Sstevel@tonic-gate */ 1550Sstevel@tonic-gate typedef struct ctfs_ctlnode { 1560Sstevel@tonic-gate gfs_file_t ctfs_ctl_file; /* gfs file */ 1570Sstevel@tonic-gate contract_t *ctfs_ctl_contract; /* contract pointer */ 1580Sstevel@tonic-gate } ctfs_ctlnode_t; 1590Sstevel@tonic-gate 1600Sstevel@tonic-gate /* 1610Sstevel@tonic-gate * latest file data 1620Sstevel@tonic-gate */ 1630Sstevel@tonic-gate typedef gfs_dir_t ctfs_latenode_t; 1640Sstevel@tonic-gate 1650Sstevel@tonic-gate /* 1660Sstevel@tonic-gate * events file data 1670Sstevel@tonic-gate */ 1680Sstevel@tonic-gate typedef struct ctfs_evnode { 1690Sstevel@tonic-gate gfs_file_t ctfs_ev_file; /* gfs file */ 1700Sstevel@tonic-gate contract_t *ctfs_ev_contract; /* contract we're watching */ 1710Sstevel@tonic-gate ctfs_endpoint_t ctfs_ev_listener; /* common endpoint data */ 1720Sstevel@tonic-gate } ctfs_evnode_t; 1730Sstevel@tonic-gate 1740Sstevel@tonic-gate /* 1750Sstevel@tonic-gate * bundle and pbundle file data 1760Sstevel@tonic-gate */ 1770Sstevel@tonic-gate typedef struct ctfs_bunode { 1780Sstevel@tonic-gate gfs_file_t ctfs_bu_file; /* gfs file */ 1790Sstevel@tonic-gate ct_equeue_t *ctfs_bu_queue; /* queue we're watching */ 1800Sstevel@tonic-gate ctfs_endpoint_t ctfs_bu_listener; /* common endpoint data */ 1810Sstevel@tonic-gate } ctfs_bunode_t; 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate /* 1840Sstevel@tonic-gate * VFS data object 1850Sstevel@tonic-gate */ 1860Sstevel@tonic-gate typedef struct ctfs_vfs { 1870Sstevel@tonic-gate vnode_t *ctvfs_root; /* root vnode pointer */ 1880Sstevel@tonic-gate } ctfs_vfs_t; 1890Sstevel@tonic-gate 1900Sstevel@tonic-gate /* 1910Sstevel@tonic-gate * vnode creation routines 1920Sstevel@tonic-gate */ 1930Sstevel@tonic-gate extern vnode_t *ctfs_create_tdirnode(vnode_t *); 1940Sstevel@tonic-gate extern vnode_t *ctfs_create_tmplnode(vnode_t *); 1950Sstevel@tonic-gate extern vnode_t *ctfs_create_latenode(vnode_t *); 1960Sstevel@tonic-gate extern vnode_t *ctfs_create_pbundle(vnode_t *); 1970Sstevel@tonic-gate extern vnode_t *ctfs_create_bundle(vnode_t *); 1980Sstevel@tonic-gate extern vnode_t *ctfs_create_ctlnode(vnode_t *); 1990Sstevel@tonic-gate extern vnode_t *ctfs_create_statnode(vnode_t *); 2000Sstevel@tonic-gate extern vnode_t *ctfs_create_evnode(vnode_t *); 2010Sstevel@tonic-gate extern vnode_t *ctfs_create_adirnode(vnode_t *); 2020Sstevel@tonic-gate extern vnode_t *ctfs_create_cdirnode(vnode_t *, contract_t *); 2030Sstevel@tonic-gate extern vnode_t *ctfs_create_symnode(vnode_t *, contract_t *); 2040Sstevel@tonic-gate 2050Sstevel@tonic-gate /* 2060Sstevel@tonic-gate * common ctfs routines 2070Sstevel@tonic-gate */ 2080Sstevel@tonic-gate extern void ctfs_common_getattr(vnode_t *, vattr_t *); 209*5331Samw extern int ctfs_close(vnode_t *, int, int, offset_t, cred_t *, 210*5331Samw caller_context_t *); 211*5331Samw extern int ctfs_access_dir(vnode_t *, int, int, cred_t *, 212*5331Samw caller_context_t *); 213*5331Samw extern int ctfs_access_readonly(vnode_t *, int, int, cred_t *, 214*5331Samw caller_context_t *); 215*5331Samw extern int ctfs_access_readwrite(vnode_t *, int, int, cred_t *, 216*5331Samw caller_context_t *); 217*5331Samw extern int ctfs_open(vnode_t **, int, cred_t *, 218*5331Samw caller_context_t *); 2190Sstevel@tonic-gate 2200Sstevel@tonic-gate /* 2210Sstevel@tonic-gate * vnode ops vector templates 2220Sstevel@tonic-gate */ 2230Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_root; 2240Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_adir; 2250Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_sym; 2260Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_tdir; 2270Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_tmpl; 2280Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_cdir; 2290Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_ctl; 2300Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_stat; 2310Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_event; 2320Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_bundle; 2330Sstevel@tonic-gate extern vnodeops_t *ctfs_ops_latest; 2340Sstevel@tonic-gate 2350Sstevel@tonic-gate #ifdef __cplusplus 2360Sstevel@tonic-gate } 2370Sstevel@tonic-gate #endif 2380Sstevel@tonic-gate 2390Sstevel@tonic-gate #endif /* _SYS_CTFS_IMPL_H */ 240