xref: /illumos-gate/usr/src/cmd/fs.d/autofs/ns_fnutils.h (revision 88f8b78a88cbdc6d8c1af5c3e54bc49d25095c98)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * ns_fnutils.h
24  *
25  * Copyright (c) 1995 - 1996, by Sun Microsystems, Inc.
26  * All rights reserved.
27  */
28 
29 #ifndef _NS_FNUTILS_H
30 #define	_NS_FNUTILS_H
31 
32 #pragma ident	"%Z%%M%	%I%	%E% SMI"
33 
34 #include <rpc/rpc.h>
35 #include <xfn/xfn.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 /*
42  * Enable compilation for either XFN1 (pre-2.6) or XFN2 environment.
43  */
44 #ifdef	XFN1ENV
45 #define	XFN1(x) /* cstyle */, x
46 #define	XFN2(x)
47 #define	_fn_ctx_handle_from_initial_with_uid(uid, auth, status) \
48 	    fn_ctx_handle_from_initial(status)
49 #else
50 #define	XFN1(x)
51 #define	XFN2(x) x,
52 #endif
53 
54 /*
55  * FNS file system reference and address types.  Each (char *) array is indexed
56  * using the corresponding enumeration.
57  */
58 extern const char *reftypes[];
59 
60 typedef enum {
61 	REF_FN_FS,
62 	NUM_REFTYPES	/* Not a ref type, but rather a count of them */
63 } reftype_t;
64 
65 extern const char *addrtypes[];
66 
67 typedef enum {
68 	ADDR_MOUNT,
69 	ADDR_HOST,
70 	ADDR_USER,
71 	ADDR_USER_NISPLUS,
72 	NUM_ADDRTYPES	/* Not an addr type, but rather a count of them */
73 } addrtype_t;
74 
75 
76 /*
77  * Initialization for FNS.  Return 0 on success.
78  */
79 extern int
80 init_fn(void);
81 
82 /*
83  * Allocate a new composite name.  On error, log an error message and
84  * return NULL.
85  */
86 extern FN_composite_name_t *
87 new_cname(const char *);
88 
89 /*
90  * Return the type of a reference, or NUM_REFTYPES if the type is unknown.
91  */
92 extern reftype_t
93 reftype(const FN_ref_t *);
94 
95 /*
96  * Return the type of an address, or NUM_ADDRTYPES if the type is unknown.
97  */
98 extern addrtype_t
99 addrtype(const FN_ref_addr_t *);
100 
101 /*
102  * Determine whether two identifiers match.
103  */
104 extern bool_t
105 ident_equal(const FN_identifier_t *, const FN_identifier_t *);
106 
107 /*
108  * Determine whether an identifier and a string match.
109  */
110 extern bool_t
111 ident_str_equal(const FN_identifier_t *, const char *);
112 
113 /*
114  * Syslog an error message and status info (with detail level DETAIL)
115  * if "verbose" is set.
116  */
117 #define	DETAIL	0
118 extern void
119 logstat(const FN_status_t *, const char *msg1, const char *msg2);
120 
121 /*
122  * Determine whether an error is potentially transient.
123  */
124 extern bool_t
125 transient(const FN_status_t *);
126 
127 /*
128  * Log a memory allocation failure if "verbose" is true.
129  */
130 extern void
131 log_mem_failure(void);
132 
133 extern FN_ctx_t *
134 _fn_ctx_handle_from_initial_with_uid(uid_t, unsigned int, FN_status_t *);
135 
136 extern FN_string_t		*empty_string;
137 extern FN_composite_name_t	*empty_cname;
138 extern FN_composite_name_t	*slash_cname;	/* "/" */
139 
140 
141 #ifdef	__cplusplus
142 }
143 #endif
144 
145 #endif	/* _NS_FNUTILS_H */
146