Print this page
6198 Let's EOL cachefs
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/fs.d/autofs/automount.h
+++ new/usr/src/cmd/fs.d/autofs/automount.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 - * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
23 + * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 25
26 26 /*
27 27 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
28 28 * Use is subject to license terms.
29 29 */
30 30
31 31 #ifndef _AUTOMOUNT_H
32 32 #define _AUTOMOUNT_H
33 33
34 34 #include <fslib.h> /* needed for mntlist_t declaration */
35 35 #include <thread.h>
36 36 #include <sys/mntent.h> /* " " MNTTYPE_* declarations */
37 37 #include <synch.h> /* needed for mutex_t declaration */
38 38 #include <sys/types.h>
39 39 #include <rpc/rpc.h>
40 40 #include <sys/fs/autofs.h>
41 41 #include <netinet/in.h> /* needed for sockaddr_in declaration */
42 42 #include <door.h>
43 43
44 44 #ifdef MALLOC_DEBUG
45 45 #include <debug_alloc.h>
46 46 #endif
47 47
48 48 #ifdef __cplusplus
49 49 extern "C" {
50 50 #endif
51 51
52 52 #ifndef _REENTRANT
53 53 #define fork1 vfork
54 54 #define rpc_control(a, b) 1
55 55 #endif
56 56
57 57 #define DOMOUNT_USER 1
58 58 #define DOMOUNT_KERNEL 2
59 59
60 60 /*
61 61 * Solaris autofs configuration file location
62 62 */
63 63 #define AUTOFSADMIN "/etc/default/autofs"
64 64
65 65 #define MXHOSTNAMELEN 64
66 66 #define MAXNETNAMELEN 255
67 67 #define MAXFILENAMELEN 255
68 68 #define LINESZ 4096
69 69 #define MAXADDRLEN 128 /* max autofs address length */
70 70 #define MAXOPTSLEN 1024
71 71
72 72 #define AUTOFS_MOUNT_TIMEOUT 600 /* default min time mount will */
73 73 /* remain mounted (in seconds) */
74 74 #define AUTOFS_RPC_TIMEOUT 60 /* secs autofs will wait for */
75 75 /* automountd's reply before */
76 76 /* retransmitting */
77 77 /* stack ops */
78 78 #define ERASE 0
79 79 #define PUSH 1
80 80 #define POP 2
81 81 #define INIT 3
82 82 #define STACKSIZ 30
83 83
84 84 #define DIST_SELF 1
85 85 #define DIST_MYSUB 2
86 86 #define DIST_MYNET 3
87 87 #define DIST_OTHER 4
88 88
89 89 #define MAXIFS 32
90 90
91 91 /*
92 92 * Retry operation related definitions.
93 93 */
94 94 #define RET_OK 0
95 95 #define RET_RETRY 32
96 96 #define RET_ERR 33
97 97 #define INITDELAY 5
98 98 #define DELAY_BACKOFF 2
99 99 #define MAXDELAY 120
100 100 #define ARGV_MAX 16
101 101 #define VFS_PATH "/usr/lib/fs"
102 102 #define DELAY(delay) { \
103 103 (void) sleep(delay); \
104 104 delay *= DELAY_BACKOFF; \
105 105 if (delay > MAXDELAY) \
106 106 delay = MAXDELAY; \
107 107 }
108 108
109 109 struct mapline {
110 110 char linebuf[LINESZ];
111 111 char lineqbuf[LINESZ];
112 112 };
113 113
114 114 /*
115 115 * Structure describing a host/filesystem/dir tuple in a NIS map entry
116 116 */
117 117 struct mapfs {
118 118 struct mapfs *mfs_next; /* next in entry */
119 119 int mfs_ignore; /* ignore this entry */
120 120 char *mfs_host; /* host name */
121 121 char *mfs_dir; /* dir to mount */
122 122 int mfs_penalty; /* mount penalty for this host */
123 123 int mfs_distance; /* distance hint */
124 124 struct nfs_args *mfs_args; /* nfs_args */
125 125 struct netconfig *mfs_nconf;
126 126 rpcvers_t mfs_version; /* NFS version */
127 127
128 128 #define MFS_ALLOC_DIR 0x1 /* mfs_dir now points to different */
129 129 /* buffer */
130 130
131 131 #define MFS_URL 0x2 /* is NFS url listed in this tuple. */
132 132 #define MFS_FH_VIA_WEBNFS 0x4 /* got file handle during ping phase */
↓ open down ↓ |
99 lines elided |
↑ open up ↑ |
133 133
134 134 uint_t mfs_flags;
135 135 uint_t mfs_port; /* port# in NFS url */
136 136 };
137 137
138 138 /*
139 139 * NIS entry - lookup of name in DIR gets us this
140 140 */
141 141 struct mapent {
142 142 char *map_fstype; /* file system type e.g. "nfs" */
143 - char *map_mounter; /* base fs e.g. "cachefs" */
143 + char *map_mounter; /* base fs */
144 144 char *map_root; /* path to mount root */
145 145 char *map_mntpnt; /* path from mount root */
146 146 char *map_mntopts; /* mount options */
147 147 char *map_fsw; /* mount fs information */
148 148 char *map_fswq; /* quoted mountfs information */
149 149 int map_mntlevel; /* mapentry hierarchy level */
150 150 bool_t map_modified; /* flags modified mapentries */
151 151 bool_t map_faked; /* flags faked mapentries */
152 152 int map_err; /* flags any bad entries in the map */
153 153 struct mapfs *map_fs; /* list of replicas for nfs */
154 154 struct mapent *map_next;
155 155 };
156 156
157 157
158 158 /*
159 159 * Descriptor for each directory served by the automounter
160 160 */
161 161 struct autodir {
162 162 char *dir_name; /* mount point */
163 163 char *dir_map; /* name of map for dir */
164 164 char *dir_opts; /* default mount options */
165 165 int dir_direct; /* direct mountpoint ? */
166 166 int dir_remount; /* a remount */
167 167 struct autodir *dir_next; /* next entry */
168 168 struct autodir *dir_prev; /* prev entry */
169 169 };
170 170
171 171 /*
172 172 * This structure is used to build an array of
173 173 * hostnames with associated penalties to be
174 174 * passed to the nfs_cast procedure
175 175 */
176 176 struct host_names {
177 177 char *host;
178 178 int penalty;
179 179 };
180 180
181 181 /*
182 182 * structure used to build list of contents for a map on
183 183 * a readdir request
184 184 */
185 185 struct dir_entry {
186 186 char *name; /* name of entry */
187 187 ino_t nodeid;
188 188 off_t offset;
189 189 struct dir_entry *next;
190 190 struct dir_entry *left; /* left element in binary tree */
191 191 struct dir_entry *right; /* right element in binary tree */
192 192 };
193 193
194 194 /*
195 195 * offset index table
196 196 */
197 197 struct off_tbl {
198 198 off_t offset;
199 199 struct dir_entry *first;
200 200 struct off_tbl *next;
201 201 };
202 202
203 203 #ifndef NO_RDDIR_CACHE
204 204 /*
205 205 * directory cache for 'map'
206 206 */
207 207 struct autofs_rddir_cache {
208 208 char *map;
209 209 struct off_tbl *offtp;
210 210 ulong_t bucket_size;
211 211 time_t ttl;
212 212 struct dir_entry *entp;
213 213 mutex_t lock; /* protects 'in_use' field */
214 214 int in_use; /* # threads referencing it */
215 215 rwlock_t rwlock; /* protects 'full' and 'next' */
216 216 int full; /* full == 1 when cache full */
217 217 struct autofs_rddir_cache *next;
218 218 };
219 219
220 220 #define RDDIR_CACHE_TIME 300 /* in seconds */
221 221
222 222 #endif /* NO_RDDIR_CACHE */
223 223
224 224 /*
225 225 * structure used to maintain address list for localhost
226 226 */
227 227
228 228 struct myaddrs {
229 229 struct sockaddr_in sin;
230 230 struct myaddrs *myaddrs_next;
231 231 };
232 232
233 233 /*
234 234 * structure used to pass commands to the door servers
235 235 */
236 236
237 237 typedef struct command {
238 238 char file[MAXPATHLEN];
239 239 char argv[ARGV_MAX][MAXOPTSLEN];
240 240 char key[MAXOPTSLEN];
241 241 int console;
242 242 } command_t;
243 243
244 244 /*
245 245 * globally visible door_server file descriptor
246 246 */
247 247 int did_exec_map;
248 248 int did_fork_exec;
249 249
250 250 extern time_t timenow; /* set at start of processing of each RPC call */
251 251 extern char self[];
252 252 extern int verbose;
253 253 extern int trace;
254 254 extern int automountd_nobrowse;
255 255 extern struct autodir *dir_head;
256 256 extern struct autodir *dir_tail;
257 257 extern struct mntlist *current_mounts;
258 258 struct mounta; /* defined in sys/vfs.h */
259 259 extern struct myaddrs *myaddrs_head;
260 260
261 261 extern rwlock_t cache_lock;
262 262 extern rwlock_t portmap_cache_lock;
263 263 extern rwlock_t autofs_rddir_cache_lock;
264 264
265 265 extern mutex_t cleanup_lock;
266 266 extern cond_t cleanup_start_cv;
267 267 extern cond_t cleanup_done_cv;
268 268
269 269 /*
270 270 * mnttab handling routines
271 271 */
272 272 extern void free_mapent(struct mapent *);
273 273 extern struct mntlist *getmntlist(void);
274 274 extern dev_t get_devid(struct extmnttab *);
275 275
276 276 /*
277 277 * utilities
278 278 */
279 279 extern struct mapent *parse_entry(char *, char *, char *, struct mapline *,
280 280 char *, uint_t, bool_t);
281 281 extern int macro_expand(char *, char *, char *, int);
282 282 extern void unquote(char *, char *);
283 283 extern void unbracket(char **);
284 284 extern void trim(char *);
285 285 extern char *get_line(FILE *, char *, char *, int);
286 286 extern int getword(char *, char *, char **, char **, char, int);
287 287 extern int get_retry(char *);
288 288 extern int str_opt(struct mnttab *, char *, char **);
289 289 extern void put_automountd_env(void);
290 290 extern void dirinit(char *, char *, char *, int, char **, char ***);
291 291 extern void pr_msg(const char *, ...);
292 292 extern void trace_prt(int, char *, ...);
293 293 extern void free_autofs_args(autofs_args *);
294 294 extern void free_nfs_args(struct nfs_args *);
295 295 extern void free_mounta(struct mounta *);
296 296
297 297 extern int nopt(struct mnttab *, char *, int *);
298 298 extern int set_versrange(rpcvers_t, rpcvers_t *, rpcvers_t *);
299 299 extern enum clnt_stat pingnfs(char *, int, rpcvers_t *, rpcvers_t,
300 300 ushort_t, bool_t, char *, char *);
301 301
302 302 extern void *autofs_get_buffer(size_t);
303 303 extern int self_check(char *);
304 304 extern int do_mount1(char *, char *, char *, char *, char *, uint_t, uid_t,
305 305 action_list **, int);
306 306 extern int do_lookup1(char *, char *, char *, char *, char *, uint_t, uid_t,
307 307 autofs_action_t *, struct linka *);
308 308 extern int do_unmount1(umntrequest *);
309 309 extern int do_readdir(autofs_rddirargs *, autofs_rddirres *);
310 310 extern int nfsunmount(struct mnttab *);
311 311 extern int loopbackmount(char *, char *, char *, int);
312 312 extern int mount_nfs(struct mapent *, char *, char *, int, uid_t,
313 313 action_list **);
314 314 extern int mount_autofs(struct mapent *, char *, action_list *,
315 315 char *rootp, char *subdir, char *key);
316 316 extern int mount_generic(char *, char *, char *, char *, int);
317 317 extern enum clnt_stat nfs_cast(struct mapfs *, struct mapfs **, int);
318 318
319 319 extern bool_t hasrestrictopt(char *);
320 320
321 321 #ifndef NO_RDDIR_CACHE
322 322 /*
323 323 * readdir handling routines
324 324 */
325 325 extern char *auto_rddir_malloc(unsigned);
326 326 extern char *auto_rddir_strdup(const char *);
327 327 extern struct dir_entry *btree_lookup(struct dir_entry *, char *);
328 328 extern void btree_enter(struct dir_entry **, struct dir_entry *);
329 329 extern int add_dir_entry(char *, struct dir_entry **, struct dir_entry **);
330 330 extern void cache_cleanup(void);
331 331 extern int autofs_rddir_cache_lookup(char *, struct autofs_rddir_cache **);
332 332 extern struct dir_entry *rddir_entry_lookup(char *, struct dir_entry *);
333 333 #endif /* NO_RDDIR_CACHE */
334 334
335 335 /*
336 336 * generic interface to specific name service functions
337 337 */
338 338 extern void ns_setup(char **, char ***);
339 339 extern int getmapent(char *, char *, struct mapline *, char **, char ***,
340 340 bool_t *, bool_t);
341 341 extern int getmapkeys(char *, struct dir_entry **, int *, int *, char **,
342 342 char ***, uid_t);
343 343 extern int loadmaster_map(char *, char *, char **, char ***);
344 344 extern int loaddirect_map(char *, char *, char *, char **, char ***);
345 345
346 346 /*
347 347 * these name service specific functions should not be
348 348 * accessed directly, use the generic functions.
349 349 */
350 350 extern void init_files(char **, char ***);
351 351 extern int getmapent_files(char *, char *, struct mapline *, char **, char ***,
352 352 bool_t *, bool_t);
353 353 extern int loadmaster_files(char *, char *, char **, char ***);
354 354 extern int loaddirect_files(char *, char *, char *, char **, char ***);
355 355 extern int getmapkeys_files(char *, struct dir_entry **, int *, int *,
356 356 char **, char ***);
357 357 extern int stack_op(int, char *, char **, char ***);
358 358
359 359 extern void init_nis(char **, char ***);
360 360 extern int getmapent_nis(char *, char *, struct mapline *, char **, char ***,
361 361 bool_t *, bool_t);
362 362 extern int loadmaster_nis(char *, char *, char **, char ***);
363 363 extern int loaddirect_nis(char *, char *, char *, char **, char ***);
364 364 extern int getmapkeys_nis(char *, struct dir_entry **, int *, int *,
365 365 char **, char ***);
366 366
367 367 extern void init_ldap(char **, char ***);
368 368 extern int getmapent_ldap(char *, char *, struct mapline *, char **, char ***,
369 369 bool_t *, bool_t);
370 370 extern int loadmaster_ldap(char *, char *, char **, char ***);
371 371 extern int loaddirect_ldap(char *, char *, char *, char **, char ***);
372 372 extern int getmapkeys_ldap(char *, struct dir_entry **, int *, int *,
373 373 char **, char ***);
374 374
375 375
376 376 /*
377 377 * end of name service specific functions
378 378 */
379 379
380 380 /*
381 381 * not defined in any header file
382 382 */
383 383 extern int __clnt_bindresvport(CLIENT *);
384 384 extern int getnetmaskbynet(const struct in_addr, struct in_addr *);
385 385
386 386 /*
387 387 * Hidden rpc functions
388 388 */
389 389 extern int __nis_reset_state();
390 390 extern int __rpc_negotiate_uid(int);
391 391
392 392 /*
393 393 * door_server functions to handle fork activity within the automounter
394 394 */
395 395 void automountd_do_fork_exec(void *, char *, size_t, door_desc_t *, uint_t);
396 396 void automountd_do_exec_map(void *, char *, size_t, door_desc_t *, uint_t);
397 397
398 398 #ifdef __cplusplus
399 399 }
400 400 #endif
401 401
402 402 #endif /* _AUTOMOUNT_H */
↓ open down ↓ |
249 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX