xref: /onnv-gate/usr/src/lib/udapl/libdat/common/udat.c (revision 8580:85b678a652f5)
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*8580SBill.Taylor@Sun.COM  * Common Development and Distribution License (the "License").
6*8580SBill.Taylor@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  * Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate /*
26*8580SBill.Taylor@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
270Sstevel@tonic-gate  * Use is subject to license terms.
280Sstevel@tonic-gate  */
290Sstevel@tonic-gate 
300Sstevel@tonic-gate 
310Sstevel@tonic-gate /*
320Sstevel@tonic-gate  *
330Sstevel@tonic-gate  * MODULE: udat.c
340Sstevel@tonic-gate  *
350Sstevel@tonic-gate  * PURPOSE: DAT Provider and Consumer registry functions.
360Sstevel@tonic-gate  *
370Sstevel@tonic-gate  * $Id: udat.c,v 1.13 2003/08/20 14:28:40 hobie16 Exp $
380Sstevel@tonic-gate  */
390Sstevel@tonic-gate 
400Sstevel@tonic-gate #include <dat/udat.h>
410Sstevel@tonic-gate #include <dat/dat_registry.h> /* Provider API function prototypes */
420Sstevel@tonic-gate 
430Sstevel@tonic-gate #include "dat_dr.h"
440Sstevel@tonic-gate #include "dat_init.h"
450Sstevel@tonic-gate #include "dat_osd.h"
460Sstevel@tonic-gate #ifndef	DAT_NO_STATIC_REGISTRY
470Sstevel@tonic-gate #include "dat_sr.h"
480Sstevel@tonic-gate #endif
490Sstevel@tonic-gate 
500Sstevel@tonic-gate 
510Sstevel@tonic-gate #define	UDAT_IS_BAD_POINTER(p) (NULL == (p))
520Sstevel@tonic-gate 
530Sstevel@tonic-gate /*
540Sstevel@tonic-gate  *
550Sstevel@tonic-gate  * Internal Function Declarations
560Sstevel@tonic-gate  *
570Sstevel@tonic-gate  */
580Sstevel@tonic-gate 
590Sstevel@tonic-gate DAT_BOOLEAN
600Sstevel@tonic-gate udat_check_state(void);
610Sstevel@tonic-gate 
620Sstevel@tonic-gate 
630Sstevel@tonic-gate /*
640Sstevel@tonic-gate  *
650Sstevel@tonic-gate  * External Function Definitions
660Sstevel@tonic-gate  *
670Sstevel@tonic-gate  */
680Sstevel@tonic-gate 
690Sstevel@tonic-gate 
700Sstevel@tonic-gate /*
710Sstevel@tonic-gate  *
720Sstevel@tonic-gate  * Provider API
730Sstevel@tonic-gate  *
740Sstevel@tonic-gate  */
750Sstevel@tonic-gate 
760Sstevel@tonic-gate 
770Sstevel@tonic-gate /*
780Sstevel@tonic-gate  * Function: dat_registry_add_provider
790Sstevel@tonic-gate  */
800Sstevel@tonic-gate 
810Sstevel@tonic-gate DAT_RETURN
dat_registry_add_provider(IN DAT_PROVIDER * provider,IN const DAT_PROVIDER_INFO * provider_info)820Sstevel@tonic-gate dat_registry_add_provider(
830Sstevel@tonic-gate 	IN DAT_PROVIDER			*provider,
840Sstevel@tonic-gate 	IN const DAT_PROVIDER_INFO	*provider_info)
850Sstevel@tonic-gate {
860Sstevel@tonic-gate 	DAT_DR_ENTRY 		entry;
870Sstevel@tonic-gate 
880Sstevel@tonic-gate 	dat_os_dbg_print(DAT_OS_DBG_TYPE_PROVIDER_API,
890Sstevel@tonic-gate 	    "DAT Registry: dat_registry_add_provider() called\n");
900Sstevel@tonic-gate 
910Sstevel@tonic-gate 	if (UDAT_IS_BAD_POINTER(provider)) {
920Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1));
930Sstevel@tonic-gate 	}
940Sstevel@tonic-gate 
950Sstevel@tonic-gate 	if (UDAT_IS_BAD_POINTER(provider_info)) {
960Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2));
970Sstevel@tonic-gate 	}
980Sstevel@tonic-gate 
990Sstevel@tonic-gate 	if (DAT_FALSE == udat_check_state()) {
1000Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_STATE, 0));
1010Sstevel@tonic-gate 	}
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate 	entry.ref_count = 0;
1040Sstevel@tonic-gate 	entry.ia_open_func = provider->ia_open_func;
1050Sstevel@tonic-gate 	entry.info = *provider_info;
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate 	return (dat_dr_insert(provider_info, &entry));
1080Sstevel@tonic-gate }
1090Sstevel@tonic-gate 
1100Sstevel@tonic-gate 
1110Sstevel@tonic-gate /*
1120Sstevel@tonic-gate  * Function: dat_registry_remove_provider
1130Sstevel@tonic-gate  */
1140Sstevel@tonic-gate 
1150Sstevel@tonic-gate DAT_RETURN
dat_registry_remove_provider(IN DAT_PROVIDER * provider,IN const DAT_PROVIDER_INFO * provider_info)1160Sstevel@tonic-gate dat_registry_remove_provider(
1170Sstevel@tonic-gate 	IN DAT_PROVIDER 		*provider,
1180Sstevel@tonic-gate 	IN  const DAT_PROVIDER_INFO	*provider_info)
1190Sstevel@tonic-gate {
1200Sstevel@tonic-gate 	dat_os_dbg_print(DAT_OS_DBG_TYPE_PROVIDER_API,
1210Sstevel@tonic-gate 	    "DAT Registry: dat_registry_remove_provider() called\n");
1220Sstevel@tonic-gate 
1230Sstevel@tonic-gate 	if (UDAT_IS_BAD_POINTER(provider)) {
1240Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1));
1250Sstevel@tonic-gate 	}
1260Sstevel@tonic-gate 
1270Sstevel@tonic-gate 	if (DAT_FALSE == udat_check_state()) {
1280Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_STATE, 0));
1290Sstevel@tonic-gate 	}
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate 	return (dat_dr_remove(provider_info));
1320Sstevel@tonic-gate }
1330Sstevel@tonic-gate 
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate /*
1360Sstevel@tonic-gate  *
1370Sstevel@tonic-gate  * Consumer API
1380Sstevel@tonic-gate  *
1390Sstevel@tonic-gate  */
1400Sstevel@tonic-gate 
1410Sstevel@tonic-gate /*
1420Sstevel@tonic-gate  * Function: dat_ia_open
1430Sstevel@tonic-gate  */
1440Sstevel@tonic-gate 
1450Sstevel@tonic-gate DAT_RETURN
dat_ia_openv(IN const DAT_NAME_PTR name,IN DAT_COUNT async_event_qlen,INOUT DAT_EVD_HANDLE * async_event_handle,OUT DAT_IA_HANDLE * ia_handle,IN DAT_UINT32 dapl_major,IN DAT_UINT32 dapl_minor,IN DAT_BOOLEAN thread_safety)1460Sstevel@tonic-gate dat_ia_openv(
1470Sstevel@tonic-gate 	IN	const DAT_NAME_PTR	name,
1480Sstevel@tonic-gate 	IN	DAT_COUNT		async_event_qlen,
1490Sstevel@tonic-gate 	INOUT	DAT_EVD_HANDLE		*async_event_handle,
1500Sstevel@tonic-gate 	OUT	DAT_IA_HANDLE		*ia_handle,
1510Sstevel@tonic-gate 	IN	DAT_UINT32		dapl_major,
1520Sstevel@tonic-gate 	IN	DAT_UINT32		dapl_minor,
1530Sstevel@tonic-gate 	IN	DAT_BOOLEAN		thread_safety)
1540Sstevel@tonic-gate {
1550Sstevel@tonic-gate 	DAT_IA_OPEN_FUNC		ia_open_func;
1560Sstevel@tonic-gate 	DAT_PROVIDER_INFO 		info;
1570Sstevel@tonic-gate 	DAT_RETURN 			status;
158*8580SBill.Taylor@Sun.COM 	DAT_OS_SIZE 			len;
159*8580SBill.Taylor@Sun.COM #define	RO_AWARE_PREFIX	"RO_AWARE_"
160*8580SBill.Taylor@Sun.COM 	boolean_t			ro_aware_client;
161*8580SBill.Taylor@Sun.COM 	const char			*_name = name;
1620Sstevel@tonic-gate 
1630Sstevel@tonic-gate 	dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
1640Sstevel@tonic-gate 	    "DAT Registry: dat_ia_open() called\n");
1650Sstevel@tonic-gate 
166*8580SBill.Taylor@Sun.COM 	if (UDAT_IS_BAD_POINTER(_name)) {
1670Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1));
1680Sstevel@tonic-gate 	}
1690Sstevel@tonic-gate 
170*8580SBill.Taylor@Sun.COM 	len = dat_os_strlen(_name);
1710Sstevel@tonic-gate 
172*8580SBill.Taylor@Sun.COM 	if (DAT_NAME_MAX_LENGTH <= len) {
1730Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1));
1740Sstevel@tonic-gate 	}
1750Sstevel@tonic-gate 
1760Sstevel@tonic-gate 	if (UDAT_IS_BAD_POINTER(ia_handle)) {
1770Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA));
1780Sstevel@tonic-gate 	}
1790Sstevel@tonic-gate 
1800Sstevel@tonic-gate 	if (DAT_FALSE == udat_check_state()) {
1810Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_STATE, 0));
1820Sstevel@tonic-gate 	}
1830Sstevel@tonic-gate 
184*8580SBill.Taylor@Sun.COM 	/* Find out if this is an RO aware client and if so, strip the prefix */
185*8580SBill.Taylor@Sun.COM 	ro_aware_client =
186*8580SBill.Taylor@Sun.COM 	    (strncmp(RO_AWARE_PREFIX, _name, sizeof (RO_AWARE_PREFIX) - 1) ==
187*8580SBill.Taylor@Sun.COM 	    0);
188*8580SBill.Taylor@Sun.COM 
189*8580SBill.Taylor@Sun.COM 	/* strip off the prefix from the provider's name if present */
190*8580SBill.Taylor@Sun.COM 	if (ro_aware_client) {
191*8580SBill.Taylor@Sun.COM 		_name = _name + sizeof (RO_AWARE_PREFIX) - 1;
192*8580SBill.Taylor@Sun.COM 		len -= sizeof (RO_AWARE_PREFIX) - 1;
193*8580SBill.Taylor@Sun.COM 	}
194*8580SBill.Taylor@Sun.COM 
195*8580SBill.Taylor@Sun.COM 	(void) dat_os_strncpy(info.ia_name, _name, len);
1960Sstevel@tonic-gate 	info.ia_name[len] = '\0';
1970Sstevel@tonic-gate 
1980Sstevel@tonic-gate 	info.dapl_version_major = dapl_major;
1990Sstevel@tonic-gate 	info.dapl_version_minor = dapl_minor;
2000Sstevel@tonic-gate 	info.is_thread_safe = thread_safety;
2010Sstevel@tonic-gate 
2020Sstevel@tonic-gate 	/*
2030Sstevel@tonic-gate 	 * Since DAT allows providers to be loaded by either the static
2040Sstevel@tonic-gate 	 * registry or explicitly through OS dependent methods, do not
2050Sstevel@tonic-gate 	 * return an error if no providers are loaded via the static registry.
2060Sstevel@tonic-gate 	 * Don't even bother calling the static registry if DAT is compiled
2070Sstevel@tonic-gate 	 * with no static registry support.
2080Sstevel@tonic-gate 	 */
2090Sstevel@tonic-gate 
2100Sstevel@tonic-gate #ifndef DAT_NO_STATIC_REGISTRY
2110Sstevel@tonic-gate 	(void) dat_sr_provider_open(&info);
2120Sstevel@tonic-gate #endif
2130Sstevel@tonic-gate 
2140Sstevel@tonic-gate 	status = dat_dr_provider_open(&info, &ia_open_func);
2150Sstevel@tonic-gate 	if (status != DAT_SUCCESS) {
2160Sstevel@tonic-gate 		dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
2170Sstevel@tonic-gate 		    "DAT Registry: dat_ia_open() provider information "
2180Sstevel@tonic-gate 		    "for IA name %s not found in dynamic registry\n",
219*8580SBill.Taylor@Sun.COM 		    _name);
2200Sstevel@tonic-gate 		return (status);
2210Sstevel@tonic-gate 	}
2220Sstevel@tonic-gate 
223*8580SBill.Taylor@Sun.COM 	return (*ia_open_func)((const DAT_NAME_PTR) _name,
2240Sstevel@tonic-gate 	    async_event_qlen,
2250Sstevel@tonic-gate 	    async_event_handle,
226*8580SBill.Taylor@Sun.COM 	    ia_handle,
227*8580SBill.Taylor@Sun.COM 	    ro_aware_client);
2280Sstevel@tonic-gate }
2290Sstevel@tonic-gate 
2300Sstevel@tonic-gate 
2310Sstevel@tonic-gate /*
2320Sstevel@tonic-gate  * Function: dat_ia_close
2330Sstevel@tonic-gate  */
2340Sstevel@tonic-gate 
2350Sstevel@tonic-gate DAT_RETURN
dat_ia_close(IN DAT_IA_HANDLE ia_handle,IN DAT_CLOSE_FLAGS ia_flags)2360Sstevel@tonic-gate dat_ia_close(
2370Sstevel@tonic-gate 	IN DAT_IA_HANDLE	ia_handle,
2380Sstevel@tonic-gate 	IN DAT_CLOSE_FLAGS	ia_flags)
2390Sstevel@tonic-gate {
2400Sstevel@tonic-gate 	DAT_PROVIDER	*provider;
2410Sstevel@tonic-gate 	DAT_PROVIDER_ATTR   provider_attr = {0};
2420Sstevel@tonic-gate 	DAT_RETURN 		status;
2430Sstevel@tonic-gate 	const char 		*ia_name;
2440Sstevel@tonic-gate 
2450Sstevel@tonic-gate 	dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
2460Sstevel@tonic-gate 	    "DAT Registry: dat_ia_close() called\n");
2470Sstevel@tonic-gate 
2480Sstevel@tonic-gate 	if (UDAT_IS_BAD_POINTER(ia_handle)) {
2490Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_HANDLE, DAT_INVALID_HANDLE_IA));
2500Sstevel@tonic-gate 	}
2510Sstevel@tonic-gate 
2520Sstevel@tonic-gate 	if (DAT_FALSE == udat_check_state()) {
2530Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_STATE, 0));
2540Sstevel@tonic-gate 	}
2550Sstevel@tonic-gate 
2560Sstevel@tonic-gate 	provider = DAT_HANDLE_TO_PROVIDER(ia_handle);
2570Sstevel@tonic-gate 	ia_name = provider->device_name;
2580Sstevel@tonic-gate 
2590Sstevel@tonic-gate 	if (DAT_SUCCESS != (status = dat_ia_query(ia_handle,
2600Sstevel@tonic-gate 	    NULL,
2610Sstevel@tonic-gate 	    0,
2620Sstevel@tonic-gate 	    NULL,
2630Sstevel@tonic-gate 	    DAT_PROVIDER_FIELD_ALL,
2640Sstevel@tonic-gate 	    &provider_attr))) {
2650Sstevel@tonic-gate 		dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
2660Sstevel@tonic-gate 		    "DAT Registry: query function for %s provider failed\n",
2670Sstevel@tonic-gate 		    ia_name);
2680Sstevel@tonic-gate 	} else if (DAT_SUCCESS != (status =
2690Sstevel@tonic-gate 	    (*provider->ia_close_func)(ia_handle, ia_flags))) {
2700Sstevel@tonic-gate 		dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
2710Sstevel@tonic-gate 		    "DAT Registry: close function for %s provider failed\n",
2720Sstevel@tonic-gate 		    ia_name);
2730Sstevel@tonic-gate 	} else {
2740Sstevel@tonic-gate 		DAT_PROVIDER_INFO info;
2750Sstevel@tonic-gate 		DAT_OS_SIZE len;
2760Sstevel@tonic-gate 
2770Sstevel@tonic-gate 		len = dat_os_strlen(ia_name);
2780Sstevel@tonic-gate 
2790Sstevel@tonic-gate 		dat_os_assert(len <= DAT_NAME_MAX_LENGTH);
2800Sstevel@tonic-gate 
2810Sstevel@tonic-gate 		(void) dat_os_strncpy(info.ia_name, ia_name, len);
2820Sstevel@tonic-gate 		info.ia_name[len] = '\0';
2830Sstevel@tonic-gate 
2840Sstevel@tonic-gate 		info.dapl_version_major = provider_attr.dapl_version_major;
2850Sstevel@tonic-gate 		info.dapl_version_minor = provider_attr.dapl_version_minor;
2860Sstevel@tonic-gate 		info.is_thread_safe = provider_attr.is_thread_safe;
2870Sstevel@tonic-gate 
2880Sstevel@tonic-gate 		status = dat_dr_provider_close(&info);
2890Sstevel@tonic-gate 		if (DAT_SUCCESS != status) {
2900Sstevel@tonic-gate 			dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
2910Sstevel@tonic-gate 			    "DAT Registry: dynamic registry unable to close "
2920Sstevel@tonic-gate 			    "provider for IA name %s\n",
2930Sstevel@tonic-gate 			    ia_name);
2940Sstevel@tonic-gate 		}
2950Sstevel@tonic-gate 
2960Sstevel@tonic-gate #ifndef DAT_NO_STATIC_REGISTRY
2970Sstevel@tonic-gate 		status = dat_sr_provider_close(&info);
2980Sstevel@tonic-gate 		if (DAT_SUCCESS != status) {
2990Sstevel@tonic-gate 			dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
3000Sstevel@tonic-gate 			    "DAT Registry: static registry unable to close "
3010Sstevel@tonic-gate 			    "provider for IA name %s\n",
3020Sstevel@tonic-gate 			    ia_name);
3030Sstevel@tonic-gate 		}
3040Sstevel@tonic-gate #endif
3050Sstevel@tonic-gate 	}
3060Sstevel@tonic-gate 
3070Sstevel@tonic-gate 	return (status);
3080Sstevel@tonic-gate }
3090Sstevel@tonic-gate 
3100Sstevel@tonic-gate 
3110Sstevel@tonic-gate /*
3120Sstevel@tonic-gate  * Function: dat_registry_list_providers
3130Sstevel@tonic-gate  */
3140Sstevel@tonic-gate 
3150Sstevel@tonic-gate DAT_RETURN
dat_registry_list_providers(IN DAT_COUNT max_to_return,OUT DAT_COUNT * entries_returned,OUT DAT_PROVIDER_INFO * (dat_provider_list[]))3160Sstevel@tonic-gate dat_registry_list_providers(
3170Sstevel@tonic-gate 	IN  DAT_COUNT   		max_to_return,
3180Sstevel@tonic-gate 	    OUT DAT_COUNT   		*entries_returned,
3190Sstevel@tonic-gate 	    OUT	DAT_PROVIDER_INFO 	*(dat_provider_list[]))
3200Sstevel@tonic-gate {
3210Sstevel@tonic-gate 	DAT_RETURN	dat_status;
3220Sstevel@tonic-gate 
3230Sstevel@tonic-gate 	dat_status = DAT_SUCCESS;
3240Sstevel@tonic-gate 	dat_os_dbg_print(DAT_OS_DBG_TYPE_CONSUMER_API,
3250Sstevel@tonic-gate 	    "DAT Registry: dat_registry_list_providers() called\n");
3260Sstevel@tonic-gate 
3270Sstevel@tonic-gate 	if (DAT_FALSE == udat_check_state()) {
3280Sstevel@tonic-gate 			return (DAT_ERROR(DAT_INVALID_STATE, 0));
3290Sstevel@tonic-gate 	}
3300Sstevel@tonic-gate 
3310Sstevel@tonic-gate 	if ((UDAT_IS_BAD_POINTER(entries_returned))) {
3320Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG2));
3330Sstevel@tonic-gate 	}
3340Sstevel@tonic-gate 
3350Sstevel@tonic-gate 	if (0 != max_to_return && (UDAT_IS_BAD_POINTER(dat_provider_list))) {
3360Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG3));
3370Sstevel@tonic-gate 	}
3380Sstevel@tonic-gate 
3390Sstevel@tonic-gate 	if (0 == max_to_return) {
3400Sstevel@tonic-gate 		/*
3410Sstevel@tonic-gate 		 * the user is allowed to call with max_to_return set to zero.
3420Sstevel@tonic-gate 		 * in which case we simply return (in *entries_returned) the
3430Sstevel@tonic-gate 		 * number of providers currently installed.  We must also
3440Sstevel@tonic-gate 		 * (per spec) return an error
3450Sstevel@tonic-gate 		 */
3460Sstevel@tonic-gate #ifndef DAT_NO_STATIC_REGISTRY
3470Sstevel@tonic-gate 		(void) dat_sr_size(entries_returned);
3480Sstevel@tonic-gate #else
3490Sstevel@tonic-gate 		(void) dat_dr_size(entries_returned);
3500Sstevel@tonic-gate #endif
3510Sstevel@tonic-gate 		return (DAT_ERROR(DAT_INVALID_PARAMETER, DAT_INVALID_ARG1));
3520Sstevel@tonic-gate 	} else {
3530Sstevel@tonic-gate #ifndef DAT_NO_STATIC_REGISTRY
3540Sstevel@tonic-gate 		dat_status = dat_sr_list(max_to_return,
3550Sstevel@tonic-gate 		    entries_returned,
3560Sstevel@tonic-gate 		    dat_provider_list);
3570Sstevel@tonic-gate #else
3580Sstevel@tonic-gate 		dat_status = dat_dr_list(max_to_return,
3590Sstevel@tonic-gate 		    entries_returned,
3600Sstevel@tonic-gate 		    dat_provider_list);
3610Sstevel@tonic-gate #endif
3620Sstevel@tonic-gate 	}
3630Sstevel@tonic-gate 	return (dat_status);
3640Sstevel@tonic-gate }
3650Sstevel@tonic-gate 
3660Sstevel@tonic-gate 
3670Sstevel@tonic-gate /*
3680Sstevel@tonic-gate  *
3690Sstevel@tonic-gate  * Internal Function Definitions
3700Sstevel@tonic-gate  *
3710Sstevel@tonic-gate  */
3720Sstevel@tonic-gate 
3730Sstevel@tonic-gate 
3740Sstevel@tonic-gate /*
3750Sstevel@tonic-gate  * Function: udat_check_state
3760Sstevel@tonic-gate  */
3770Sstevel@tonic-gate 
3780Sstevel@tonic-gate /*
3790Sstevel@tonic-gate  * This function returns TRUE if the DAT registry is in a state capable
3800Sstevel@tonic-gate  * of handling DAT API calls and false otherwise.
3810Sstevel@tonic-gate  */
3820Sstevel@tonic-gate 
3830Sstevel@tonic-gate DAT_BOOLEAN
udat_check_state(void)3840Sstevel@tonic-gate udat_check_state(void)
3850Sstevel@tonic-gate {
3860Sstevel@tonic-gate 	DAT_MODULE_STATE 		state;
3870Sstevel@tonic-gate 	DAT_BOOLEAN 		status;
3880Sstevel@tonic-gate 
3890Sstevel@tonic-gate 	state = dat_module_get_state();
3900Sstevel@tonic-gate 
3910Sstevel@tonic-gate 	if (DAT_MODULE_STATE_UNINITIALIZED == state) {
3920Sstevel@tonic-gate 		dat_init();
3930Sstevel@tonic-gate 		status = DAT_TRUE;
3940Sstevel@tonic-gate 	} else if (DAT_MODULE_STATE_DEINITIALIZED == state) {
3950Sstevel@tonic-gate 		status = DAT_FALSE;
3960Sstevel@tonic-gate 	} else {
3970Sstevel@tonic-gate 		status = DAT_TRUE;
3980Sstevel@tonic-gate 	}
3990Sstevel@tonic-gate 
4000Sstevel@tonic-gate 	return (status);
4010Sstevel@tonic-gate }
4020Sstevel@tonic-gate 
4030Sstevel@tonic-gate 
4040Sstevel@tonic-gate /*
4050Sstevel@tonic-gate  * Local variables:
4060Sstevel@tonic-gate  *  c-indent-level: 4
4070Sstevel@tonic-gate  *  c-basic-offset: 4
4080Sstevel@tonic-gate  *  tab-width: 8
4090Sstevel@tonic-gate  * End:
4100Sstevel@tonic-gate  */
411