1 /* 2 * CDDL HEADER START 3 * 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. 7 * 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. 12 * 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] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 23 */ 24 25 #ifndef _NFS4_IDMAP_IMPL_H 26 #define _NFS4_IDMAP_IMPL_H 27 28 #include <sys/list.h> 29 #include <sys/door.h> 30 #include <sys/pkp_hash.h> 31 32 /* 33 * This is a private header file. Applications should not directly include 34 * this file. 35 */ 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 /* 42 * Cache Entry Definitions 43 */ 44 #define NFSID_CACHE_ANCHORS PKP_HASH_SIZE 45 46 typedef struct nfsidmap { 47 struct nfsidmap *id_chain[2]; /* must be first */ 48 time_t id_time; /* time stamp */ 49 uid_t id_no; /* uid/gid */ 50 utf8string id_str; /* user@domain string */ 51 } nfsidmap_t; 52 53 #define id_forw id_chain[0] 54 #define id_back id_chain[1] 55 #define id_len id_str.utf8string_len 56 #define id_val id_str.utf8string_val 57 58 typedef struct nfsidhq { 59 union { 60 struct nfsidhq *hq_head[2]; /* for empty queue */ 61 struct nfsidmap *hq_chain[2]; /* for LRU list */ 62 } hq_link; 63 kmutex_t hq_lock; /* protects hash queue */ 64 } nfsidhq_t; 65 66 #define hq_que_forw hq_link.hq_head[0] 67 #define hq_que_back hq_link.hq_head[1] 68 #define hq_lru_forw hq_link.hq_chain[0] 69 #define hq_lru_back hq_link.hq_chain[1] 70 71 typedef struct { 72 const char *name; /* cache name */ 73 nfsidhq_t *table; /* hash table */ 74 /* 75 * Since we need to know the status of nfsmapid from random functions 76 * that deal with idmap caches, we keep a pointer to the relevant fields 77 * in the zone's globals so we don't have to keep passing them around. 78 */ 79 door_handle_t *nfsidmap_daemon_dh; 80 } idmap_cache_info_t; 81 82 typedef enum hash_stat { HQ_HASH_HINT, HQ_HASH_FIND } hash_stat; 83 84 /* 85 * Per-zone modular globals 86 */ 87 struct nfsidmap_globals { 88 list_node_t nig_link; /* linkage into global list */ 89 enum clnt_stat nig_last_stat; /* status of last RPC call */ 90 int nig_msg_done; /* have we printed a message? */ 91 idmap_cache_info_t u2s_ci; /* table mapping uid-to-string */ 92 idmap_cache_info_t s2u_ci; /* table mapping string-to-uid */ 93 idmap_cache_info_t g2s_ci; /* table mapping groupid-to-string */ 94 idmap_cache_info_t s2g_ci; /* table mapping string-to-groupid */ 95 pid_t nfsidmap_pid; 96 kmutex_t nfsidmap_daemon_lock; 97 /* 98 * nfsidmap_daemon_lock protects the following: 99 * nfsidmap_daemon_dh 100 */ 101 door_handle_t nfsidmap_daemon_dh; 102 }; 103 104 #ifdef __cplusplus 105 } 106 #endif 107 108 #endif /* _NFS4_IDMAP_IMPL_H */ 109