17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*36e852a1SRaja Andra * Common Development and Distribution License (the "License"). 6*36e852a1SRaja Andra * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 227c478bd9Sstevel@tonic-gate * ns_fnutils.h 237c478bd9Sstevel@tonic-gate * 24*36e852a1SRaja Andra * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25*36e852a1SRaja Andra * Use is subject to license terms. 267c478bd9Sstevel@tonic-gate */ 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #ifndef _NS_FNUTILS_H 297c478bd9Sstevel@tonic-gate #define _NS_FNUTILS_H 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #include <rpc/rpc.h> 327c478bd9Sstevel@tonic-gate #include <xfn/xfn.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate /* 397c478bd9Sstevel@tonic-gate * Enable compilation for either XFN1 (pre-2.6) or XFN2 environment. 407c478bd9Sstevel@tonic-gate */ 417c478bd9Sstevel@tonic-gate #ifdef XFN1ENV 427c478bd9Sstevel@tonic-gate #define XFN1(x) /* cstyle */, x 437c478bd9Sstevel@tonic-gate #define XFN2(x) 447c478bd9Sstevel@tonic-gate #define _fn_ctx_handle_from_initial_with_uid(uid, auth, status) \ 457c478bd9Sstevel@tonic-gate fn_ctx_handle_from_initial(status) 467c478bd9Sstevel@tonic-gate #else 477c478bd9Sstevel@tonic-gate #define XFN1(x) 487c478bd9Sstevel@tonic-gate #define XFN2(x) x, 497c478bd9Sstevel@tonic-gate #endif 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate /* 527c478bd9Sstevel@tonic-gate * FNS file system reference and address types. Each (char *) array is indexed 537c478bd9Sstevel@tonic-gate * using the corresponding enumeration. 547c478bd9Sstevel@tonic-gate */ 557c478bd9Sstevel@tonic-gate extern const char *reftypes[]; 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate typedef enum { 587c478bd9Sstevel@tonic-gate REF_FN_FS, 597c478bd9Sstevel@tonic-gate NUM_REFTYPES /* Not a ref type, but rather a count of them */ 607c478bd9Sstevel@tonic-gate } reftype_t; 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate extern const char *addrtypes[]; 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate typedef enum { 657c478bd9Sstevel@tonic-gate ADDR_MOUNT, 667c478bd9Sstevel@tonic-gate ADDR_HOST, 677c478bd9Sstevel@tonic-gate ADDR_USER, 687c478bd9Sstevel@tonic-gate NUM_ADDRTYPES /* Not an addr type, but rather a count of them */ 697c478bd9Sstevel@tonic-gate } addrtype_t; 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate /* 737c478bd9Sstevel@tonic-gate * Initialization for FNS. Return 0 on success. 747c478bd9Sstevel@tonic-gate */ 757c478bd9Sstevel@tonic-gate extern int 767c478bd9Sstevel@tonic-gate init_fn(void); 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate /* 797c478bd9Sstevel@tonic-gate * Allocate a new composite name. On error, log an error message and 807c478bd9Sstevel@tonic-gate * return NULL. 817c478bd9Sstevel@tonic-gate */ 827c478bd9Sstevel@tonic-gate extern FN_composite_name_t * 837c478bd9Sstevel@tonic-gate new_cname(const char *); 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate /* 867c478bd9Sstevel@tonic-gate * Return the type of a reference, or NUM_REFTYPES if the type is unknown. 877c478bd9Sstevel@tonic-gate */ 887c478bd9Sstevel@tonic-gate extern reftype_t 897c478bd9Sstevel@tonic-gate reftype(const FN_ref_t *); 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* 927c478bd9Sstevel@tonic-gate * Return the type of an address, or NUM_ADDRTYPES if the type is unknown. 937c478bd9Sstevel@tonic-gate */ 947c478bd9Sstevel@tonic-gate extern addrtype_t 957c478bd9Sstevel@tonic-gate addrtype(const FN_ref_addr_t *); 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* 987c478bd9Sstevel@tonic-gate * Determine whether two identifiers match. 997c478bd9Sstevel@tonic-gate */ 1007c478bd9Sstevel@tonic-gate extern bool_t 1017c478bd9Sstevel@tonic-gate ident_equal(const FN_identifier_t *, const FN_identifier_t *); 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate /* 1047c478bd9Sstevel@tonic-gate * Determine whether an identifier and a string match. 1057c478bd9Sstevel@tonic-gate */ 1067c478bd9Sstevel@tonic-gate extern bool_t 1077c478bd9Sstevel@tonic-gate ident_str_equal(const FN_identifier_t *, const char *); 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate /* 1107c478bd9Sstevel@tonic-gate * Syslog an error message and status info (with detail level DETAIL) 1117c478bd9Sstevel@tonic-gate * if "verbose" is set. 1127c478bd9Sstevel@tonic-gate */ 1137c478bd9Sstevel@tonic-gate #define DETAIL 0 1147c478bd9Sstevel@tonic-gate extern void 1157c478bd9Sstevel@tonic-gate logstat(const FN_status_t *, const char *msg1, const char *msg2); 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate /* 1187c478bd9Sstevel@tonic-gate * Determine whether an error is potentially transient. 1197c478bd9Sstevel@tonic-gate */ 1207c478bd9Sstevel@tonic-gate extern bool_t 1217c478bd9Sstevel@tonic-gate transient(const FN_status_t *); 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate /* 1247c478bd9Sstevel@tonic-gate * Log a memory allocation failure if "verbose" is true. 1257c478bd9Sstevel@tonic-gate */ 1267c478bd9Sstevel@tonic-gate extern void 1277c478bd9Sstevel@tonic-gate log_mem_failure(void); 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate extern FN_ctx_t * 1307c478bd9Sstevel@tonic-gate _fn_ctx_handle_from_initial_with_uid(uid_t, unsigned int, FN_status_t *); 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate extern FN_string_t *empty_string; 1337c478bd9Sstevel@tonic-gate extern FN_composite_name_t *empty_cname; 1347c478bd9Sstevel@tonic-gate extern FN_composite_name_t *slash_cname; /* "/" */ 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1387c478bd9Sstevel@tonic-gate } 1397c478bd9Sstevel@tonic-gate #endif 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate #endif /* _NS_FNUTILS_H */ 142