9075 Improve ZFS pool import/load process and corrupted pool recovery
[unleashed.git] / usr / src / uts / common / idmap / kidmap_priv.h
blob54170684defa6ec903fd177945824cda8305e788
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 * Windows to Solaris Identity Mapping kernel API
29 * This header file contains private definitions.
32 #ifndef _KIDMAP_PRIV_H
33 #define _KIDMAP_PRIV_H
35 #include <sys/avl.h>
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
41 typedef struct sid2pid {
42 avl_node_t avl_link;
43 struct sid2pid *flink;
44 struct sid2pid *blink;
45 const char *sid_prefix;
46 uint32_t rid;
47 uid_t uid;
48 time_t uid_ttl;
49 gid_t gid;
50 time_t gid_ttl;
51 int is_user;
52 } sid2pid_t;
55 typedef struct pid2sid {
56 avl_node_t avl_link;
57 struct pid2sid *flink;
58 struct pid2sid *blink;
59 const char *sid_prefix;
60 uint32_t rid;
61 uid_t pid;
62 time_t ttl;
63 } pid2sid_t;
67 typedef struct idmap_sid2pid_cache {
68 avl_tree_t tree;
69 kmutex_t mutex;
70 struct sid2pid head;
71 time_t purge_time;
72 int uid_num;
73 int gid_num;
74 int pid_num;
75 } idmap_sid2pid_cache_t;
78 typedef struct idmap_pid2sid_cache {
79 avl_tree_t tree;
80 kmutex_t mutex;
81 struct pid2sid head;
82 time_t purge_time;
83 } idmap_pid2sid_cache_t;
87 * There is a cache for every mapping request because a group SID
88 * on Windows can be set in a file owner field and versa-visa.
89 * To stop this causing problems on Solaris a SID can map to
90 * both a UID and a GID.
92 typedef struct idmap_cache {
93 idmap_sid2pid_cache_t sid2pid;
94 idmap_pid2sid_cache_t uid2sid;
95 idmap_pid2sid_cache_t gid2sid;
96 } idmap_cache_t;
99 void
100 kidmap_cache_create(idmap_cache_t *cache);
102 void
103 kidmap_cache_delete(idmap_cache_t *cache);
105 void
106 kidmap_cache_purge(idmap_cache_t *cache);
110 kidmap_cache_lookup_uidbysid(idmap_cache_t *cache, const char *sid_prefix,
111 uint32_t rid, uid_t *uid);
114 kidmap_cache_lookup_gidbysid(idmap_cache_t *cache, const char *sid_prefix,
115 uint32_t rid, gid_t *gid);
118 kidmap_cache_lookup_pidbysid(idmap_cache_t *cache, const char *sid_prefix,
119 uint32_t rid, uid_t *pid, int *is_user);
122 kidmap_cache_lookup_sidbyuid(idmap_cache_t *cache, const char **sid_prefix,
123 uint32_t *rid, uid_t uid);
126 kidmap_cache_lookup_sidbygid(idmap_cache_t *cache, const char **sid_prefix,
127 uint32_t *rid, gid_t gid);
130 void
131 kidmap_cache_add_sid2uid(idmap_cache_t *cache, const char *sid_prefix,
132 uint32_t rid, uid_t uid, int direction);
134 void
135 kidmap_cache_add_sid2gid(idmap_cache_t *cache, const char *sid_prefix,
136 uint32_t rid, gid_t gid, int direction);
138 void
139 kidmap_cache_add_sid2pid(idmap_cache_t *cache, const char *sid_prefix,
140 uint32_t rid, uid_t pid, int is_user, int direction);
141 void
142 kidmap_cache_get_data(idmap_cache_t *cache, size_t *uidbysid, size_t *gidbysid,
143 size_t *pidbysid, size_t *sidbyuid, size_t *sidbygid);
145 kidmap_start(void);
148 kidmap_stop(void);
150 void
151 kidmap_sid_prefix_store_init(void);
153 const char *
154 kidmap_find_sid_prefix(const char *sid_prefix);
156 #ifdef __cplusplus
158 #endif
160 #endif /* _KIDMAP_PRIV_H */