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 * ns_fnutils.h 23 * 24 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25 * Use is subject to license terms. 26 */ 27 28 #ifndef _NS_FNUTILS_H 29 #define _NS_FNUTILS_H 30 31 #include <rpc/rpc.h> 32 #include <xfn/xfn.h> 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 /* 39 * Enable compilation for either XFN1 (pre-2.6) or XFN2 environment. 40 */ 41 #ifdef XFN1ENV 42 #define XFN1(x) /* cstyle */, x 43 #define XFN2(x) 44 #define _fn_ctx_handle_from_initial_with_uid(uid, auth, status) \ 45 fn_ctx_handle_from_initial(status) 46 #else 47 #define XFN1(x) 48 #define XFN2(x) x, 49 #endif 50 51 /* 52 * FNS file system reference and address types. Each (char *) array is indexed 53 * using the corresponding enumeration. 54 */ 55 extern const char *reftypes[]; 56 57 typedef enum { 58 REF_FN_FS, 59 NUM_REFTYPES /* Not a ref type, but rather a count of them */ 60 } reftype_t; 61 62 extern const char *addrtypes[]; 63 64 typedef enum { 65 ADDR_MOUNT, 66 ADDR_HOST, 67 ADDR_USER, 68 NUM_ADDRTYPES /* Not an addr type, but rather a count of them */ 69 } addrtype_t; 70 71 72 /* 73 * Initialization for FNS. Return 0 on success. 74 */ 75 extern int 76 init_fn(void); 77 78 /* 79 * Allocate a new composite name. On error, log an error message and 80 * return NULL. 81 */ 82 extern FN_composite_name_t * 83 new_cname(const char *); 84 85 /* 86 * Return the type of a reference, or NUM_REFTYPES if the type is unknown. 87 */ 88 extern reftype_t 89 reftype(const FN_ref_t *); 90 91 /* 92 * Return the type of an address, or NUM_ADDRTYPES if the type is unknown. 93 */ 94 extern addrtype_t 95 addrtype(const FN_ref_addr_t *); 96 97 /* 98 * Determine whether two identifiers match. 99 */ 100 extern bool_t 101 ident_equal(const FN_identifier_t *, const FN_identifier_t *); 102 103 /* 104 * Determine whether an identifier and a string match. 105 */ 106 extern bool_t 107 ident_str_equal(const FN_identifier_t *, const char *); 108 109 /* 110 * Syslog an error message and status info (with detail level DETAIL) 111 * if "verbose" is set. 112 */ 113 #define DETAIL 0 114 extern void 115 logstat(const FN_status_t *, const char *msg1, const char *msg2); 116 117 /* 118 * Determine whether an error is potentially transient. 119 */ 120 extern bool_t 121 transient(const FN_status_t *); 122 123 /* 124 * Log a memory allocation failure if "verbose" is true. 125 */ 126 extern void 127 log_mem_failure(void); 128 129 extern FN_ctx_t * 130 _fn_ctx_handle_from_initial_with_uid(uid_t, unsigned int, FN_status_t *); 131 132 extern FN_string_t *empty_string; 133 extern FN_composite_name_t *empty_cname; 134 extern FN_composite_name_t *slash_cname; /* "/" */ 135 136 137 #ifdef __cplusplus 138 } 139 #endif 140 141 #endif /* _NS_FNUTILS_H */ 142