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