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