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