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_SHARETAB_H 28*a237e38eSth199096 #define _SHAREFS_SHARETAB_H 29*a237e38eSth199096 30*a237e38eSth199096 #pragma ident "%Z%%M% %I% %E% SMI" 31*a237e38eSth199096 32*a237e38eSth199096 /* 33*a237e38eSth199096 * This header defines the glue to keeping a sharetab in memory. 34*a237e38eSth199096 * It is broken out from sharefs.h in the case that it will be 35*a237e38eSth199096 * reused in userland. 36*a237e38eSth199096 */ 37*a237e38eSth199096 38*a237e38eSth199096 /* 39*a237e38eSth199096 * Note: 40*a237e38eSth199096 * Must include share/share.h before this header. 41*a237e38eSth199096 */ 42*a237e38eSth199096 43*a237e38eSth199096 #ifdef __cplusplus 44*a237e38eSth199096 extern "C" { 45*a237e38eSth199096 #endif 46*a237e38eSth199096 47*a237e38eSth199096 typedef struct sh_list { /* cached share list */ 48*a237e38eSth199096 struct sh_list *shl_next; 49*a237e38eSth199096 share_t *shl_sh; 50*a237e38eSth199096 } sh_list_t; 51*a237e38eSth199096 52*a237e38eSth199096 typedef struct sharefs_hash_head { 53*a237e38eSth199096 share_t *ssh_sh; 54*a237e38eSth199096 uint_t ssh_count; 55*a237e38eSth199096 } sharefs_hash_head_t; 56*a237e38eSth199096 57*a237e38eSth199096 #define SHARETAB_HASHES 256 58*a237e38eSth199096 59*a237e38eSth199096 typedef struct sharetab { 60*a237e38eSth199096 sharefs_hash_head_t s_buckets[SHARETAB_HASHES]; 61*a237e38eSth199096 char *s_fstype; 62*a237e38eSth199096 struct sharetab *s_next; 63*a237e38eSth199096 uint_t s_count; 64*a237e38eSth199096 } sharetab_t; 65*a237e38eSth199096 66*a237e38eSth199096 #define MOD2(a, pow_of_2) (a) & ((pow_of_2) - 1) 67*a237e38eSth199096 68*a237e38eSth199096 /* 69*a237e38eSth199096 * Pearson's string hash 70*a237e38eSth199096 * 71*a237e38eSth199096 * See: Communications of the ACM, June 1990 Vol 33 pp 677-680 72*a237e38eSth199096 * http://www.acm.org/pubs/citations/journals/cacm/1990-33-6/p677-pearson 73*a237e38eSth199096 */ 74*a237e38eSth199096 #define SHARETAB_HASH_IT(hash, path) \ 75*a237e38eSth199096 { \ 76*a237e38eSth199096 uint_t key = 0x12345678; /* arbitrary value */ \ 77*a237e38eSth199096 int i, len; \ 78*a237e38eSth199096 \ 79*a237e38eSth199096 len = strlen((path)); \ 80*a237e38eSth199096 \ 81*a237e38eSth199096 (hash) = MOD2((key + len), SHARETAB_HASHES); \ 82*a237e38eSth199096 \ 83*a237e38eSth199096 for (i = 0; i < len; i++) { \ 84*a237e38eSth199096 (hash) = MOD2(((hash) + (path)[i]), SHARETAB_HASHES); \ 85*a237e38eSth199096 (hash) = pkp_tab[(hash)]; \ 86*a237e38eSth199096 } \ 87*a237e38eSth199096 } 88*a237e38eSth199096 89*a237e38eSth199096 #ifdef __cplusplus 90*a237e38eSth199096 } 91*a237e38eSth199096 #endif 92*a237e38eSth199096 93*a237e38eSth199096 #endif /* !_SHAREFS_SHARETAB_H */ 94