1*a237e38eSth199096 /* 2*a237e38eSth199096 * CDDL HEADER START 3*a237e38eSth199096 * 4*a237e38eSth199096 * The contents of this file are subject to the terms of the 5*a237e38eSth199096 * Common Development and Distribution License (the "License"). 6*a237e38eSth199096 * You may not use this file except in compliance with the License. 7*a237e38eSth199096 * 8*a237e38eSth199096 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*a237e38eSth199096 * or http://www.opensolaris.org/os/licensing. 10*a237e38eSth199096 * See the License for the specific language governing permissions 11*a237e38eSth199096 * and limitations under the License. 12*a237e38eSth199096 * 13*a237e38eSth199096 * When distributing Covered Code, include this CDDL HEADER in each 14*a237e38eSth199096 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*a237e38eSth199096 * If applicable, add the following below this CDDL HEADER, with the 16*a237e38eSth199096 * fields enclosed by brackets "[]" replaced with your own identifying 17*a237e38eSth199096 * information: Portions Copyright [yyyy] [name of copyright owner] 18*a237e38eSth199096 * 19*a237e38eSth199096 * CDDL HEADER END 20*a237e38eSth199096 */ 21*a237e38eSth199096 22*a237e38eSth199096 /* 23*a237e38eSth199096 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24*a237e38eSth199096 * Use is subject to license terms. 25*a237e38eSth199096 */ 26*a237e38eSth199096 27*a237e38eSth199096 #ifndef _SHAREFS_SHAREFS_H 28*a237e38eSth199096 #define _SHAREFS_SHAREFS_H 29*a237e38eSth199096 30*a237e38eSth199096 #pragma ident "%Z%%M% %I% %E% SMI" 31*a237e38eSth199096 32*a237e38eSth199096 /* 33*a237e38eSth199096 * This header provides service for the sharefs module. 34*a237e38eSth199096 */ 35*a237e38eSth199096 36*a237e38eSth199096 #include <sys/modctl.h> 37*a237e38eSth199096 #include <sys/vfs.h> 38*a237e38eSth199096 #include <sys/vnode.h> 39*a237e38eSth199096 #include <sys/gfs.h> 40*a237e38eSth199096 #include <sharefs/share.h> 41*a237e38eSth199096 #include <sharefs/sharetab.h> 42*a237e38eSth199096 43*a237e38eSth199096 #ifdef __cplusplus 44*a237e38eSth199096 extern "C" { 45*a237e38eSth199096 #endif 46*a237e38eSth199096 47*a237e38eSth199096 #define SHAREFS_ROOT "/etc/dfs" 48*a237e38eSth199096 #define SHAREFS_BASE "sharetab" 49*a237e38eSth199096 50*a237e38eSth199096 /* 51*a237e38eSth199096 * Lengths of strings. 52*a237e38eSth199096 */ 53*a237e38eSth199096 typedef struct sharefs_lens { 54*a237e38eSth199096 int shl_path; 55*a237e38eSth199096 int shl_res; 56*a237e38eSth199096 int shl_fstype; 57*a237e38eSth199096 int shl_opts; 58*a237e38eSth199096 int shl_descr; 59*a237e38eSth199096 } sharefs_lens_t; 60*a237e38eSth199096 61*a237e38eSth199096 /* 62*a237e38eSth199096 * VFS data object 63*a237e38eSth199096 */ 64*a237e38eSth199096 typedef struct sharefs_vfs { 65*a237e38eSth199096 vnode_t *sharefs_vfs_root; 66*a237e38eSth199096 } sharefs_vfs_t; 67*a237e38eSth199096 68*a237e38eSth199096 #define SHAREFS_NAME_MAX MAXNAMELEN 69*a237e38eSth199096 70*a237e38eSth199096 /* 71*a237e38eSth199096 * The lock ordering whenever sharefs_lock and sharetab_lock both 72*a237e38eSth199096 * need to be held is: sharefs_lock and then sharetab_lock. 73*a237e38eSth199096 */ 74*a237e38eSth199096 extern krwlock_t sharefs_lock; /* lock for the vnode ops */ 75*a237e38eSth199096 extern sharetab_t *sharefs_sharetab; /* The sharetab. */ 76*a237e38eSth199096 77*a237e38eSth199096 extern uint_t sharetab_count; /* How many shares? */ 78*a237e38eSth199096 extern krwlock_t sharetab_lock; /* lock for the cached sharetab */ 79*a237e38eSth199096 extern size_t sharetab_size; /* How big is the sharetab file? */ 80*a237e38eSth199096 81*a237e38eSth199096 extern timestruc_t sharetab_mtime; /* Last mod to sharetab */ 82*a237e38eSth199096 extern timestruc_t sharetab_snap_time; /* Last snap */ 83*a237e38eSth199096 extern uint_t sharetab_generation; /* Which copy is it? */ 84*a237e38eSth199096 85*a237e38eSth199096 #define SHAREFS_INO_FILE 0x80 86*a237e38eSth199096 87*a237e38eSth199096 extern vnode_t *sharefs_create_root_file(vfs_t *); 88*a237e38eSth199096 89*a237e38eSth199096 /* 90*a237e38eSth199096 * Sharetab file 91*a237e38eSth199096 * 92*a237e38eSth199096 * Note that even though the sharetab code does not explictly 93*a237e38eSth199096 * use 'sharefs_file', it is required by GFS that the first 94*a237e38eSth199096 * field of the private data be a gfs_file_t. 95*a237e38eSth199096 */ 96*a237e38eSth199096 typedef struct shnode_t { 97*a237e38eSth199096 gfs_file_t sharefs_file; /* gfs file */ 98*a237e38eSth199096 char *sharefs_snap; /* snapshot of the share */ 99*a237e38eSth199096 size_t sharefs_size; /* size of the snapshot */ 100*a237e38eSth199096 uint_t sharefs_count; /* number of shares */ 101*a237e38eSth199096 uint_t sharefs_refs; /* reference count */ 102*a237e38eSth199096 uint_t sharefs_real_vp; /* Are we a real or snap */ 103*a237e38eSth199096 uint_t sharefs_generation; /* Which copy are we? */ 104*a237e38eSth199096 timestruc_t sharefs_snap_time; /* When were we modded? */ 105*a237e38eSth199096 } shnode_t; 106*a237e38eSth199096 107*a237e38eSth199096 /* 108*a237e38eSth199096 * Some conversion macros: 109*a237e38eSth199096 */ 110*a237e38eSth199096 #define VTOSH(vp) ((shnode_t *)((vp)->v_data)) 111*a237e38eSth199096 112*a237e38eSth199096 extern const fs_operation_def_t sharefs_tops_data[]; 113*a237e38eSth199096 extern vnodeops_t *sharefs_ops_data; 114*a237e38eSth199096 115*a237e38eSth199096 extern void sharefs_data_init(void); 116*a237e38eSth199096 117*a237e38eSth199096 extern void sharefs_sharetab_init(void); 118*a237e38eSth199096 119*a237e38eSth199096 #ifdef __cplusplus 120*a237e38eSth199096 } 121*a237e38eSth199096 #endif 122*a237e38eSth199096 123*a237e38eSth199096 #endif /* !_SHAREFS_SHAREFS_H */ 124