xref: /onnv-gate/usr/src/cmd/fs.d/autofs/ns_fnutils.h (revision 11262:b7ebfbf2359e)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*11262SRajagopal.Andra@Sun.COM  * Common Development and Distribution License (the "License").
6*11262SRajagopal.Andra@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
220Sstevel@tonic-gate  * ns_fnutils.h
230Sstevel@tonic-gate  *
24*11262SRajagopal.Andra@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25*11262SRajagopal.Andra@Sun.COM  * Use is subject to license terms.
260Sstevel@tonic-gate  */
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #ifndef _NS_FNUTILS_H
290Sstevel@tonic-gate #define	_NS_FNUTILS_H
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #include <rpc/rpc.h>
320Sstevel@tonic-gate #include <xfn/xfn.h>
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #ifdef	__cplusplus
350Sstevel@tonic-gate extern "C" {
360Sstevel@tonic-gate #endif
370Sstevel@tonic-gate 
380Sstevel@tonic-gate /*
390Sstevel@tonic-gate  * Enable compilation for either XFN1 (pre-2.6) or XFN2 environment.
400Sstevel@tonic-gate  */
410Sstevel@tonic-gate #ifdef	XFN1ENV
420Sstevel@tonic-gate #define	XFN1(x) /* cstyle */, x
430Sstevel@tonic-gate #define	XFN2(x)
440Sstevel@tonic-gate #define	_fn_ctx_handle_from_initial_with_uid(uid, auth, status) \
450Sstevel@tonic-gate 	    fn_ctx_handle_from_initial(status)
460Sstevel@tonic-gate #else
470Sstevel@tonic-gate #define	XFN1(x)
480Sstevel@tonic-gate #define	XFN2(x) x,
490Sstevel@tonic-gate #endif
500Sstevel@tonic-gate 
510Sstevel@tonic-gate /*
520Sstevel@tonic-gate  * FNS file system reference and address types.  Each (char *) array is indexed
530Sstevel@tonic-gate  * using the corresponding enumeration.
540Sstevel@tonic-gate  */
550Sstevel@tonic-gate extern const char *reftypes[];
560Sstevel@tonic-gate 
570Sstevel@tonic-gate typedef enum {
580Sstevel@tonic-gate 	REF_FN_FS,
590Sstevel@tonic-gate 	NUM_REFTYPES	/* Not a ref type, but rather a count of them */
600Sstevel@tonic-gate } reftype_t;
610Sstevel@tonic-gate 
620Sstevel@tonic-gate extern const char *addrtypes[];
630Sstevel@tonic-gate 
640Sstevel@tonic-gate typedef enum {
650Sstevel@tonic-gate 	ADDR_MOUNT,
660Sstevel@tonic-gate 	ADDR_HOST,
670Sstevel@tonic-gate 	ADDR_USER,
680Sstevel@tonic-gate 	NUM_ADDRTYPES	/* Not an addr type, but rather a count of them */
690Sstevel@tonic-gate } addrtype_t;
700Sstevel@tonic-gate 
710Sstevel@tonic-gate 
720Sstevel@tonic-gate /*
730Sstevel@tonic-gate  * Initialization for FNS.  Return 0 on success.
740Sstevel@tonic-gate  */
750Sstevel@tonic-gate extern int
760Sstevel@tonic-gate init_fn(void);
770Sstevel@tonic-gate 
780Sstevel@tonic-gate /*
790Sstevel@tonic-gate  * Allocate a new composite name.  On error, log an error message and
800Sstevel@tonic-gate  * return NULL.
810Sstevel@tonic-gate  */
820Sstevel@tonic-gate extern FN_composite_name_t *
830Sstevel@tonic-gate new_cname(const char *);
840Sstevel@tonic-gate 
850Sstevel@tonic-gate /*
860Sstevel@tonic-gate  * Return the type of a reference, or NUM_REFTYPES if the type is unknown.
870Sstevel@tonic-gate  */
880Sstevel@tonic-gate extern reftype_t
890Sstevel@tonic-gate reftype(const FN_ref_t *);
900Sstevel@tonic-gate 
910Sstevel@tonic-gate /*
920Sstevel@tonic-gate  * Return the type of an address, or NUM_ADDRTYPES if the type is unknown.
930Sstevel@tonic-gate  */
940Sstevel@tonic-gate extern addrtype_t
950Sstevel@tonic-gate addrtype(const FN_ref_addr_t *);
960Sstevel@tonic-gate 
970Sstevel@tonic-gate /*
980Sstevel@tonic-gate  * Determine whether two identifiers match.
990Sstevel@tonic-gate  */
1000Sstevel@tonic-gate extern bool_t
1010Sstevel@tonic-gate ident_equal(const FN_identifier_t *, const FN_identifier_t *);
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate /*
1040Sstevel@tonic-gate  * Determine whether an identifier and a string match.
1050Sstevel@tonic-gate  */
1060Sstevel@tonic-gate extern bool_t
1070Sstevel@tonic-gate ident_str_equal(const FN_identifier_t *, const char *);
1080Sstevel@tonic-gate 
1090Sstevel@tonic-gate /*
1100Sstevel@tonic-gate  * Syslog an error message and status info (with detail level DETAIL)
1110Sstevel@tonic-gate  * if "verbose" is set.
1120Sstevel@tonic-gate  */
1130Sstevel@tonic-gate #define	DETAIL	0
1140Sstevel@tonic-gate extern void
1150Sstevel@tonic-gate logstat(const FN_status_t *, const char *msg1, const char *msg2);
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate /*
1180Sstevel@tonic-gate  * Determine whether an error is potentially transient.
1190Sstevel@tonic-gate  */
1200Sstevel@tonic-gate extern bool_t
1210Sstevel@tonic-gate transient(const FN_status_t *);
1220Sstevel@tonic-gate 
1230Sstevel@tonic-gate /*
1240Sstevel@tonic-gate  * Log a memory allocation failure if "verbose" is true.
1250Sstevel@tonic-gate  */
1260Sstevel@tonic-gate extern void
1270Sstevel@tonic-gate log_mem_failure(void);
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate extern FN_ctx_t *
1300Sstevel@tonic-gate _fn_ctx_handle_from_initial_with_uid(uid_t, unsigned int, FN_status_t *);
1310Sstevel@tonic-gate 
1320Sstevel@tonic-gate extern FN_string_t		*empty_string;
1330Sstevel@tonic-gate extern FN_composite_name_t	*empty_cname;
1340Sstevel@tonic-gate extern FN_composite_name_t	*slash_cname;	/* "/" */
1350Sstevel@tonic-gate 
1360Sstevel@tonic-gate 
1370Sstevel@tonic-gate #ifdef	__cplusplus
1380Sstevel@tonic-gate }
1390Sstevel@tonic-gate #endif
1400Sstevel@tonic-gate 
1410Sstevel@tonic-gate #endif	/* _NS_FNUTILS_H */
142