Print this page
Updated wording
5032 share_nfs(1m): Documentation for "noaclfab" is needed
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/nfs/export.h
+++ new/usr/src/uts/common/nfs/export.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 *
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.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
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 23 * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
24 24 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
25 + * Copyright 2016 Jason King.
25 26 */
26 27
27 28 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 29 /* All Rights Reserved */
29 30
30 31 #ifndef _NFS_EXPORT_H
31 32 #define _NFS_EXPORT_H
32 33
33 34 #include <nfs/nfs_sec.h>
34 35 #include <nfs/auth.h>
35 36 #include <sys/vnode.h>
36 37 #include <nfs/nfs4.h>
37 38 #include <sys/kiconv.h>
38 39 #include <sys/avl.h>
39 40
40 41 #ifdef __cplusplus
41 42 extern "C" {
42 43 #endif
43 44
44 45 /*
45 46 * nfs pseudo flavor number is owned by IANA. Need to make sure the
46 47 * Solaris specific NFS_FLAVOR_NOMAP number will not overlap with any
47 48 * new IANA defined pseudo flavor numbers. The chance for the overlap
48 49 * is very small since the growth of new flavor numbers is expected
49 50 * to be limited.
50 51 */
51 52 #define NFS_FLAVOR_NOMAP 999999 /* no nfs flavor mapping */
52 53
53 54 /*
54 55 * As duplicate flavors can be passed into exportfs in the arguments, we
55 56 * allocate a cleaned up array with non duplicate flavors on the stack.
56 57 * So we need to know how much to allocate.
57 58 */
58 59 #define MAX_FLAVORS 6 /* none, sys, dh, krb5, krb5i krb5p */
59 60
60 61 /*
61 62 * Note: exported_lock is currently used to ensure the integrity of
62 63 * the secinfo fields.
63 64 */
64 65 struct secinfo {
65 66 seconfig_t s_secinfo; /* /etc/nfssec.conf entry */
66 67 unsigned int s_flags; /* flags (see below) */
67 68 int32_t s_refcnt; /* reference count for tracking */
68 69 /* how many children (self included) */
69 70 /* use this flavor. */
70 71 int s_window; /* window */
71 72 uint_t s_rootid; /* UID to use for authorized roots */
72 73 int s_rootcnt; /* count of root names */
73 74 caddr_t *s_rootnames; /* array of root names */
74 75 /* they are strings for AUTH_DES and */
75 76 /* rpc_gss_principal_t for RPCSEC_GSS */
76 77 };
77 78
78 79 #ifdef _SYSCALL32
79 80 struct secinfo32 {
80 81 seconfig32_t s_secinfo; /* /etc/nfssec.conf entry */
81 82 uint32_t s_flags; /* flags (see below) */
82 83 int32_t s_refcnt; /* reference count for tracking */
83 84 /* how many children (self included) */
84 85 /* use this flavor. */
85 86 int32_t s_window; /* window */
86 87 uint32_t s_rootid; /* UID to use for authorized roots */
87 88 int32_t s_rootcnt; /* count of root names */
88 89 caddr32_t s_rootnames; /* array of root names */
89 90 /* they are strings for AUTH_DES and */
90 91 /* rpc_gss_principal_t for RPCSEC_GSS */
91 92 };
92 93 #endif /* _SYSCALL32 */
93 94
94 95 /*
95 96 * security negotiation related
96 97 */
97 98
98 99 #define SEC_QUERY 0x01 /* query sec modes */
99 100
100 101 struct sec_ol {
101 102 int sec_flags; /* security nego flags */
102 103 uint_t sec_index; /* index into sec flavor array */
103 104 };
104 105
105 106 /*
106 107 * Per-mode flags (secinfo.s_flags)
107 108 */
108 109 #define M_RO 0x01 /* exported ro to all */
109 110 #define M_ROL 0x02 /* exported ro to all listed */
110 111 #define M_RW 0x04 /* exported rw to all */
111 112 #define M_RWL 0x08 /* exported ro to all listed */
112 113 #define M_ROOT 0x10 /* root list is defined */
113 114 #define M_4SEC_EXPORTED 0x20 /* this is an explicitly shared flavor */
114 115 #define M_NONE 0x40 /* none list is defined */
115 116 #define M_MAP 0x80 /* uidmap and/or gidmap is defined */
116 117
117 118 /* invalid secinfo reference count */
118 119 #define SEC_REF_INVALID(p) ((p)->s_refcnt < 1)
119 120
120 121 /* last secinfo reference */
121 122 #define SEC_REF_LAST(p) ((p)->s_refcnt == 1)
122 123
123 124 /* sec flavor explicitly shared for the exported node */
124 125 #define SEC_REF_EXPORTED(p) ((p)->s_flags & M_4SEC_EXPORTED)
125 126
126 127 /* the only reference count left is for referring itself */
127 128 #define SEC_REF_SELF(p) (SEC_REF_LAST(p) && SEC_REF_EXPORTED(p))
128 129
129 130 /*
130 131 * The export information passed to exportfs() (Version 2)
131 132 */
132 133 #define EX_CURRENT_VERSION 2 /* current version of exportdata struct */
133 134
134 135 struct exportdata {
135 136 int ex_version; /* structure version */
136 137 char *ex_path; /* exported path */
137 138 size_t ex_pathlen; /* path length */
138 139 int ex_flags; /* flags */
139 140 unsigned int ex_anon; /* uid for unauthenticated requests */
140 141 int ex_seccnt; /* count of security modes */
141 142 struct secinfo *ex_secinfo; /* security mode info */
142 143 char *ex_index; /* index file for public filesystem */
143 144 char *ex_log_buffer; /* path to logging buffer file */
144 145 size_t ex_log_bufferlen; /* buffer file path len */
145 146 char *ex_tag; /* tag used to identify log config */
146 147 size_t ex_taglen; /* tag length */
147 148 };
148 149
149 150 #ifdef _SYSCALL32
150 151 struct exportdata32 {
151 152 int32_t ex_version; /* structure version */
152 153 caddr32_t ex_path; /* exported path */
153 154 int32_t ex_pathlen; /* path length */
154 155 int32_t ex_flags; /* flags */
155 156 uint32_t ex_anon; /* uid for unauthenticated requests */
156 157 int32_t ex_seccnt; /* count of security modes */
157 158 caddr32_t ex_secinfo; /* security mode info */
158 159 caddr32_t ex_index; /* index file for public filesystem */
159 160 caddr32_t ex_log_buffer; /* path to logging buffer file */
160 161 int32_t ex_log_bufferlen; /* buffer file path len */
161 162 caddr32_t ex_tag; /* tag used to identify log config */
162 163 int32_t ex_taglen; /* tag length */
163 164 };
164 165 #endif /* _SYSCALL32 */
165 166
166 167 /*
167 168 * exported vfs flags.
168 169 */
169 170
170 171 #define EX_NOSUID 0x01 /* exported with unsetable set[ug]ids */
171 172 #define EX_ACLOK 0x02 /* exported with maximal access if acl exists */
172 173 #define EX_PUBLIC 0x04 /* exported with public filehandle */
173 174 #define EX_NOSUB 0x08 /* no nfs_getfh or MCL below export point */
174 175 #define EX_INDEX 0x10 /* exported with index file specified */
175 176 #define EX_LOG 0x20 /* logging enabled */
176 177 #define EX_LOG_ALLOPS 0x40 /* logging of all RPC operations enabled */
177 178 /* by default only operations which affect */
↓ open down ↓ |
143 lines elided |
↑ open up ↑ |
178 179 /* transaction logging are enabled */
179 180 #define EX_PSEUDO 0x80 /* pseudo filesystem export */
180 181 #ifdef VOLATILE_FH_TEST
181 182 #define EX_VOLFH 0x100 /* XXX nfsv4 fh may expire anytime */
182 183 #define EX_VOLRNM 0x200 /* XXX nfsv4 fh expire at rename */
183 184 #define EX_VOLMIG 0x400 /* XXX nfsv4 fh expire at migration */
184 185 #define EX_NOEXPOPEN 0x800 /* XXX nfsv4 fh no expire with open */
185 186 #endif /* VOLATILE_FH_TEST */
186 187
187 188 #define EX_CHARMAP 0x1000 /* NFS may need a character set conversion */
188 -#define EX_NOACLFAB 0x2000 /* If set, NFSv2 and v3 servers doesn't */
189 - /* fabricate ACL for VOP_GETSECATTR OTW call */
189 +#define EX_NOACLFAB 0x2000 /* If set, NFSv2 and v3 servers won't */
190 + /* fabricate an aclent_t ACL on file systems */
191 + /* that don't support aclent_t ACLs */
190 192
191 193 #ifdef _KERNEL
192 194
193 195 #define RPC_IDEMPOTENT 0x1 /* idempotent or not */
194 196 /*
195 197 * Be very careful about which NFS procedures get the RPC_ALLOWANON bit.
196 198 * Right now, if this bit is on, we ignore the results of per NFS request
197 199 * access control.
198 200 */
199 201 #define RPC_ALLOWANON 0x2 /* allow anonymous access */
200 202 #define RPC_MAPRESP 0x4 /* use mapped response buffer */
201 203 #define RPC_AVOIDWORK 0x8 /* do work avoidance for dups */
202 204 #define RPC_PUBLICFH_OK 0x10 /* allow use of public filehandle */
203 205
204 206 /*
205 207 * RPC_ALL is an or of all above bits to be used with "don't care"
206 208 * nfsv4 ops. The flags of an nfsv4 request is the bit-AND of the
207 209 * per-op flags.
208 210 */
209 211 #define RPC_ALL (RPC_IDEMPOTENT|RPC_ALLOWANON|RPC_AVOIDWORK|RPC_PUBLICFH_OK)
210 212
211 213
212 214 #ifdef VOLATILE_FH_TEST
213 215 struct ex_vol_rename {
214 216 nfs_fh4_fmt_t vrn_fh_fmt;
215 217 struct ex_vol_rename *vrn_next;
216 218 };
217 219 #endif /* VOLATILE_FH_TEST */
218 220
219 221 /*
220 222 * An auth cache client entry. This is the umbrella structure and contains all
221 223 * related auth_cache entries in the authc_tree AVL tree.
222 224 */
223 225 struct auth_cache_clnt {
224 226 avl_node_t authc_link;
225 227 struct netbuf authc_addr; /* address of the client */
226 228 krwlock_t authc_lock; /* protects authc_tree */
227 229 avl_tree_t authc_tree; /* auth_cache entries */
228 230 };
229 231
230 232 /*
231 233 * An auth cache entry can exist in 6 states.
232 234 *
233 235 * A NEW entry was recently allocated and added to the cache. It does not
234 236 * contain the valid auth state yet.
235 237 *
236 238 * A WAITING entry is one which is actively engaging the user land mountd code
237 239 * to authenticate or re-authenticate it. The auth state might not be valid
238 240 * yet. The other threads should wait on auth_cv until the retrieving thread
239 241 * finishes the retrieval and changes the auth cache entry to FRESH, or NEW (in
240 242 * a case this entry had no valid auth state yet).
241 243 *
242 244 * A REFRESHING entry is one which is actively engaging the user land mountd
243 245 * code to re-authenticate the cache entry. There is currently no other thread
244 246 * waiting for the results of the refresh.
245 247 *
246 248 * A FRESH entry is one which is valid (it is either newly retrieved or has
247 249 * been refreshed at least once).
248 250 *
249 251 * A STALE entry is one which has been detected to be too old. The transition
250 252 * from FRESH to STALE prevents multiple threads from submitting refresh
251 253 * requests.
252 254 *
253 255 * An INVALID entry is one which was either STALE or REFRESHING and was deleted
254 256 * out of the encapsulating exi. Since we can't delete it yet, we mark it as
255 257 * INVALID, which lets the refresh thread know not to work on it and free it
256 258 * instead.
257 259 *
258 260 * Note that the auth state of the entry is valid, even if the entry is STALE.
259 261 * Just as you can eat stale bread, you can consume a stale cache entry. The
260 262 * only time the contents change could be during the transition from REFRESHING
261 263 * or WAITING to FRESH.
262 264 *
263 265 * Valid state transitions:
264 266 *
265 267 * alloc
266 268 * |
267 269 * v
268 270 * +-----+
269 271 * +--->| NEW |------>free
270 272 * | +-----+
271 273 * | |
272 274 * | v
273 275 * | +---------+
274 276 * +<-| WAITING |
275 277 * ^ +---------+
276 278 * | |
277 279 * | v
278 280 * | +<--------------------------+<---------------+
279 281 * | | ^ |
280 282 * | v | |
281 283 * | +-------+ +-------+ +------------+ +---------+
282 284 * +---| FRESH |--->| STALE |--->| REFRESHING |--->| WAITING |
283 285 * +-------+ +-------+ +------------+ +---------+
284 286 * | | |
285 287 * | v |
286 288 * v +---------+ |
287 289 * free<-----| INVALID |<--------+
288 290 * +---------+
289 291 */
290 292 typedef enum auth_state {
291 293 NFS_AUTH_FRESH,
292 294 NFS_AUTH_STALE,
293 295 NFS_AUTH_REFRESHING,
294 296 NFS_AUTH_INVALID,
295 297 NFS_AUTH_NEW,
296 298 NFS_AUTH_WAITING
297 299 } auth_state_t;
298 300
299 301 /*
300 302 * An authorization cache entry
301 303 *
302 304 * Either the state in auth_state will protect the
303 305 * contents or auth_lock must be held.
304 306 */
305 307 struct auth_cache {
306 308 avl_node_t auth_link;
307 309 struct auth_cache_clnt *auth_clnt;
308 310 int auth_flavor;
309 311 cred_t *auth_clnt_cred;
310 312 uid_t auth_srv_uid;
311 313 gid_t auth_srv_gid;
312 314 uint_t auth_srv_ngids;
313 315 gid_t *auth_srv_gids;
314 316 int auth_access;
315 317 time_t auth_time;
316 318 time_t auth_freshness;
317 319 auth_state_t auth_state;
318 320 kmutex_t auth_lock;
319 321 kcondvar_t auth_cv;
320 322 };
321 323
322 324 #define AUTH_TABLESIZE 32
323 325
324 326 /*
325 327 * Structure containing log file meta-data.
326 328 */
327 329 struct log_file {
328 330 unsigned int lf_flags; /* flags (see below) */
329 331 int lf_writers; /* outstanding writers */
330 332 int lf_refcnt; /* references to this struct */
331 333 caddr_t lf_path; /* buffer file location */
332 334 vnode_t *lf_vp; /* vnode for the buffer file */
333 335 kmutex_t lf_lock;
334 336 kcondvar_t lf_cv_waiters;
335 337 };
336 338
337 339 /*
338 340 * log_file and log_buffer flags.
339 341 */
340 342 #define L_WAITING 0x01 /* flush of in-core data to stable */
341 343 /* storage in progress */
342 344 #define L_PRINTED 0x02 /* error message printed to console */
343 345 #define L_ERROR 0x04 /* error condition detected */
344 346
345 347 /*
346 348 * The logging buffer information.
347 349 * This structure may be shared by multiple exportinfo structures,
348 350 * if they share the same buffer file.
349 351 * This structure contains the basic information about the buffer, such
350 352 * as it's location in the filesystem.
351 353 *
352 354 * 'lb_lock' protects all the fields in this structure except for 'lb_path',
353 355 * and 'lb_next'.
354 356 * 'lb_path' is a write-once/read-many field which needs no locking, it is
355 357 * set before the structure is linked to any exportinfo structure.
356 358 * 'lb_next' is protected by the log_buffer_list_lock.
357 359 */
358 360 struct log_buffer {
359 361 unsigned int lb_flags; /* L_ONLIST set? */
360 362 int lb_refcnt; /* references to this struct */
361 363 unsigned int lb_rec_id; /* used to generate unique id */
362 364 caddr_t lb_path; /* buffer file pathname */
363 365 struct log_file *lb_logfile; /* points to log_file structure */
364 366 kmutex_t lb_lock;
365 367 struct log_buffer *lb_next;
366 368 kcondvar_t lb_cv_waiters;
367 369 caddr_t lb_records; /* linked list of records to write */
368 370 int lb_num_recs; /* # of records to write */
369 371 ssize_t lb_size_queued; /* number of bytes queued for write */
370 372 };
371 373
372 374 #define LOG_BUFFER_HOLD(lbp) { \
373 375 mutex_enter(&(lbp)->lb_lock); \
374 376 (lbp)->lb_refcnt++; \
375 377 mutex_exit(&(lbp)->lb_lock); \
376 378 }
377 379
378 380 #define LOG_BUFFER_RELE(lbp) { \
379 381 log_buffer_rele(lbp); \
380 382 }
381 383
382 384 /*
383 385 * Structure for character set conversion mapping based on client address.
384 386 */
385 387 struct charset_cache {
386 388 struct charset_cache *next;
387 389 kiconv_t inbound;
388 390 kiconv_t outbound;
389 391 struct sockaddr client_addr;
390 392 };
391 393
392 394 /* Forward declarations */
393 395 struct exportinfo;
394 396 struct exp_visible;
395 397 struct svc_req;
396 398
397 399 /*
398 400 * Treenodes are used to build tree representing every node which is part
399 401 * of nfs server pseudo namespace. They are connected with both exportinfo
400 402 * and exp_visible struct. They were introduced to avoid lookup of ".."
401 403 * in the underlying file system during unshare, which was failing if the
402 404 * file system was forcibly unmounted or if the directory was removed.
403 405 * One exp_visible_t can be shared via several treenode_t, i.e.
404 406 * different tree_vis can point to the same exp_visible_t.
405 407 * This will happen if some directory is on two different shared paths:
406 408 * E.g. after share /tmp/a/b1 and share /tmp/a/b2 there will be two treenodes
407 409 * corresponding to /tmp/a and both will have same value in tree_vis.
408 410 *
409 411 *
410 412 *
411 413 * NEW DATA STRUCT ORIGINAL DATA STRUCT
412 414 *
413 415 * ns_root +---+ +----------+
414 416 * | / | |PSEUDO EXP|-->+---+ +---+ +---+
415 417 * +---+--------- ----+----------+ | a |-->| k |-->| b |
416 418 * /\ +---+ +---+ +---+
417 419 * / \ . . .
418 420 * +---+...\......... ..................... . .
419 421 * *| a | \ +----------+ . .
420 422 * +---+-----\------- ----|REAL EXP a| . .
421 423 * / \ +----------+ . .
422 424 * / +===+... ............................. .
423 425 * / *| k | +----------+ .
424 426 * / +===+--- ----|REAL EXP k| .
425 427 * / +----------+ .
426 428 * +===+................ .....................................
427 429 * *| b | +----------+
428 430 * +===+---------------- ----|REAL EXP b|-->+---+
429 431 * \ +----------+ | d |
430 432 * +===+............. ...................+---+
431 433 * | d | +----------+
432 434 * +===+------------- ----|PSEUDO EXP|-->+---+ +---+
433 435 * / +----------+ | e |-->| g |
434 436 * +---+................. ...................+---+ +---+
435 437 * | e | .
436 438 * +---+ .
437 439 * \ .
438 440 * +---+.............. ............................
439 441 * *| g | +----------+
440 442 * +---+-------------- ----|REAL EXP g|
441 443 * +----------+
442 444 *
443 445 *
444 446 *
445 447 * +===+ +---+ +---+
446 448 * | b |..mountpoint | e |..directory/file *| a |..node is shared
447 449 * +===+ (VROOT) +---+ +---+
448 450 *
449 451 *
450 452 * Bi-directional interconnect:
451 453 * treenode_t::tree_exi --------- exportinfo_t::exi_tree
452 454 * One-way direction connection:
453 455 * treenode_t::tree_vis .........> exp_visible_t
454 456 */
455 457 /* Access to treenode_t is under protection of exported_lock RW_LOCK */
456 458 typedef struct treenode {
457 459 /* support for generic n-ary trees */
458 460 struct treenode *tree_parent;
459 461 struct treenode *tree_child_first;
460 462 struct treenode *tree_sibling; /* next sibling */
461 463 /* private, nfs specific part */
462 464 struct exportinfo *tree_exi;
463 465 struct exp_visible *tree_vis;
464 466 } treenode_t;
465 467
466 468 /*
467 469 * TREE_ROOT checks if the node corresponds to a filesystem root
468 470 * TREE_EXPORTED checks if the node is explicitly shared
469 471 */
470 472
471 473 #define TREE_ROOT(t) \
472 474 ((t)->tree_exi && (t)->tree_exi->exi_vp->v_flag & VROOT)
473 475
474 476 #define TREE_EXPORTED(t) \
475 477 ((t)->tree_exi && !PSEUDO((t)->tree_exi))
476 478
477 479 /* Root of nfs pseudo namespace */
478 480 extern treenode_t *ns_root;
479 481
480 482 #define EXPTABLESIZE 256
481 483
482 484 struct exp_hash {
483 485 struct exportinfo *prev; /* ptr to the previous exportinfo */
484 486 struct exportinfo *next; /* ptr to the next exportinfo */
485 487 struct exportinfo **bckt; /* backpointer to the hash bucket */
486 488 };
487 489
488 490 /*
489 491 * A node associated with an export entry on the
490 492 * list of exported filesystems.
491 493 *
492 494 * exi_count+exi_lock protects an individual exportinfo from being freed
493 495 * when in use.
494 496 *
495 497 * You must have the writer lock on exported_lock to add/delete an exportinfo
496 498 * structure to/from the list.
497 499 *
498 500 * exi_volatile_dev maps to VSW_VOLATILEDEV. It means that the
499 501 * underlying fs devno can change on each mount. When set, the server
500 502 * should not use va_fsid for a GETATTR(FATTR4_FSID) reply. It must
501 503 * use exi_fsid because it is guaranteed to be persistent. This isn't
502 504 * in any way related to NFS4 volatile filehandles.
503 505 *
504 506 * The exi_cache_lock protects the exi_cache AVL trees.
505 507 */
506 508 struct exportinfo {
507 509 struct exportdata exi_export;
508 510 fsid_t exi_fsid;
509 511 struct fid exi_fid;
510 512 struct exp_hash fid_hash;
511 513 struct exp_hash path_hash;
512 514 struct treenode *exi_tree;
513 515 fhandle_t exi_fh;
514 516 krwlock_t exi_cache_lock;
515 517 kmutex_t exi_lock;
516 518 uint_t exi_count;
517 519 vnode_t *exi_vp;
518 520 vnode_t *exi_dvp;
519 521 avl_tree_t *exi_cache[AUTH_TABLESIZE];
520 522 struct log_buffer *exi_logbuffer;
521 523 struct exp_visible *exi_visible;
522 524 struct charset_cache *exi_charset;
523 525 unsigned exi_volatile_dev:1;
524 526 unsigned exi_moved:1;
525 527 #ifdef VOLATILE_FH_TEST
526 528 uint32_t exi_volatile_id;
527 529 struct ex_vol_rename *exi_vol_rename;
528 530 kmutex_t exi_vol_rename_lock;
529 531 #endif /* VOLATILE_FH_TEST */
530 532 };
531 533
532 534 typedef struct exportinfo exportinfo_t;
533 535 typedef struct exportdata exportdata_t;
534 536 typedef struct secinfo secinfo_t;
535 537
536 538 /*
537 539 * exp_visible is a visible list per filesystem. It is for filesystems
538 540 * that may need a limited view of its contents. A pseudo export and
539 541 * a real export at the mount point (VROOT) which has a subtree shared
540 542 * has a visible list.
541 543 *
542 544 * The exi_visible field is NULL for normal, non-pseudo filesystems
543 545 * which do not have any subtree exported. If the field is non-null,
544 546 * it points to a list of visible entries, identified by vis_fid and/or
545 547 * vis_ino. The presence of a "visible" list means that if this export
546 548 * can only have a limited view, it can only view the entries in the
547 549 * exp_visible list. The directories in the fid list comprise paths that
548 550 * lead to exported directories.
549 551 *
550 552 * The vis_count field records the number of paths in this filesystem
551 553 * that use this directory. The vis_exported field is non-zero if the
552 554 * entry is an exported directory (leaf node).
553 555 *
554 556 * exp_visible itself is not reference counted. Each exp_visible is
555 557 * referenced twice:
556 558 * 1) from treenode::tree_vis
557 559 * 2) linked from exportinfo::exi_visible
558 560 * The 'owner' of exp_visible is the exportinfo structure. exp_visible should
559 561 * be always freed only from exportinfo_t, never from treenode::tree_vis.
560 562 */
561 563
562 564 struct exp_visible {
563 565 vnode_t *vis_vp;
564 566 fid_t vis_fid;
565 567 u_longlong_t vis_ino;
566 568 int vis_count;
567 569 int vis_exported;
568 570 struct exp_visible *vis_next;
569 571 struct secinfo *vis_secinfo;
570 572 int vis_seccnt;
571 573 timespec_t vis_change;
572 574 };
573 575 typedef struct exp_visible exp_visible_t;
574 576
575 577 #define PSEUDO(exi) ((exi)->exi_export.ex_flags & EX_PSEUDO)
576 578 #define EXP_LINKED(exi) ((exi)->fid_hash.bckt != NULL)
577 579
578 580 #define EQFSID(fsidp1, fsidp2) \
579 581 (((fsidp1)->val[0] == (fsidp2)->val[0]) && \
580 582 ((fsidp1)->val[1] == (fsidp2)->val[1]))
581 583
582 584 #define EQFID(fidp1, fidp2) \
583 585 ((fidp1)->fid_len == (fidp2)->fid_len && \
584 586 bcmp((char *)(fidp1)->fid_data, (char *)(fidp2)->fid_data, \
585 587 (uint_t)(fidp1)->fid_len) == 0)
586 588
587 589 #define exportmatch(exi, fsid, fid) \
588 590 (EQFSID(&(exi)->exi_fsid, (fsid)) && EQFID(&(exi)->exi_fid, (fid)))
589 591
590 592 /*
591 593 * Returns true iff exported filesystem is read-only to the given host.
592 594 *
593 595 * Note: this macro should be as fast as possible since it's called
594 596 * on each NFS modification request.
595 597 */
596 598 #define rdonly(ro, vp) ((ro) || vn_is_readonly(vp))
597 599 #define rdonly4(req, cs) \
598 600 (vn_is_readonly((cs)->vp) || \
599 601 (nfsauth4_access((cs)->exi, (cs)->vp, (req), (cs)->basecr, NULL, \
600 602 NULL, NULL, NULL) & (NFSAUTH_RO | NFSAUTH_LIMITED)))
601 603
602 604 extern int nfsauth4_access(struct exportinfo *, vnode_t *,
603 605 struct svc_req *, cred_t *, uid_t *, gid_t *, uint_t *, gid_t **);
604 606 extern int nfsauth4_secinfo_access(struct exportinfo *,
605 607 struct svc_req *, int, int, cred_t *);
606 608 extern int nfsauth_cache_clnt_compar(const void *, const void *);
607 609 extern int nfs_fhbcmp(char *, char *, int);
608 610 extern int nfs_exportinit(void);
609 611 extern void nfs_exportfini(void);
610 612 extern int chk_clnt_sec(struct exportinfo *, struct svc_req *);
611 613 extern int makefh(fhandle_t *, struct vnode *, struct exportinfo *);
612 614 extern int makefh_ol(fhandle_t *, struct exportinfo *, uint_t);
613 615 extern int makefh3(nfs_fh3 *, struct vnode *, struct exportinfo *);
614 616 extern int makefh3_ol(nfs_fh3 *, struct exportinfo *, uint_t);
615 617 extern vnode_t *nfs_fhtovp(fhandle_t *, struct exportinfo *);
616 618 extern vnode_t *nfs3_fhtovp(nfs_fh3 *, struct exportinfo *);
617 619 extern struct exportinfo *checkexport(fsid_t *, struct fid *);
618 620 extern struct exportinfo *checkexport4(fsid_t *, struct fid *, vnode_t *);
619 621 extern void exi_hold(struct exportinfo *);
620 622 extern void exi_rele(struct exportinfo *);
621 623 extern struct exportinfo *nfs_vptoexi(vnode_t *, vnode_t *, cred_t *, int *,
622 624 int *, bool_t);
623 625 extern int nfs_check_vpexi(vnode_t *, vnode_t *, cred_t *,
624 626 struct exportinfo **);
625 627 extern void export_link(struct exportinfo *);
626 628 extern void export_unlink(struct exportinfo *);
627 629 extern vnode_t *untraverse(vnode_t *);
628 630 extern int vn_is_nfs_reparse(vnode_t *, cred_t *);
629 631 extern int client_is_downrev(struct svc_req *);
630 632 extern char *build_symlink(vnode_t *, cred_t *, size_t *);
631 633
632 634 /*
633 635 * Functions that handle the NFSv4 server namespace
634 636 */
635 637 extern exportinfo_t *vis2exi(treenode_t *);
636 638 extern int treeclimb_export(struct exportinfo *);
637 639 extern void treeclimb_unexport(struct exportinfo *);
638 640 extern int nfs_visible(struct exportinfo *, vnode_t *, int *);
639 641 extern int nfs_visible_inode(struct exportinfo *, ino64_t,
640 642 struct exp_visible **);
641 643 extern int has_visible(struct exportinfo *, vnode_t *);
642 644 extern void free_visible(struct exp_visible *);
643 645 extern int nfs_exported(struct exportinfo *, vnode_t *);
644 646 extern struct exportinfo *pseudo_exportfs(vnode_t *, fid_t *,
645 647 struct exp_visible *, struct exportdata *);
646 648 extern int vop_fid_pseudo(vnode_t *, fid_t *);
647 649 extern int nfs4_vget_pseudo(struct exportinfo *, vnode_t **, fid_t *);
648 650 extern bool_t nfs_visible_change(struct exportinfo *, vnode_t *,
649 651 timespec_t *);
650 652 extern void tree_update_change(treenode_t *, timespec_t *);
651 653 /*
652 654 * Functions that handle the NFSv4 server namespace security flavors
653 655 * information.
654 656 */
655 657 extern void srv_secinfo_exp2pseu(struct exportdata *, struct exportdata *);
656 658 extern void srv_secinfo_list_free(struct secinfo *, int);
657 659
658 660 /*
659 661 * "public" and default (root) location for public filehandle
660 662 */
661 663 extern struct exportinfo *exi_public, *exi_root;
662 664 extern fhandle_t nullfh2; /* for comparing V2 filehandles */
663 665 extern krwlock_t exported_lock;
664 666 extern struct exportinfo *exptable[];
665 667
666 668 /*
667 669 * Two macros for identifying public filehandles.
668 670 * A v2 public filehandle is 32 zero bytes.
669 671 * A v3 public filehandle is zero length.
670 672 */
671 673 #define PUBLIC_FH2(fh) \
672 674 ((fh)->fh_fsid.val[1] == 0 && \
673 675 bcmp((fh), &nullfh2, sizeof (fhandle_t)) == 0)
674 676
675 677 #define PUBLIC_FH3(fh) \
676 678 ((fh)->fh3_length == 0)
677 679
678 680 extern int makefh4(nfs_fh4 *, struct vnode *, struct exportinfo *);
679 681 extern vnode_t *nfs4_fhtovp(nfs_fh4 *, struct exportinfo *, nfsstat4 *);
680 682
681 683 #endif /* _KERNEL */
682 684
683 685 #ifdef __cplusplus
684 686 }
685 687 #endif
686 688
687 689 #endif /* _NFS_EXPORT_H */
↓ open down ↓ |
488 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX