xref: /titanic_41/usr/src/lib/udapl/libdat/common/dat_dr.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright (c) 2002-2003, Network Appliance, Inc. All rights reserved.
24*7c478bd9Sstevel@tonic-gate  */
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate /*
27*7c478bd9Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
28*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
29*7c478bd9Sstevel@tonic-gate  */
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
32*7c478bd9Sstevel@tonic-gate 
33*7c478bd9Sstevel@tonic-gate /*
34*7c478bd9Sstevel@tonic-gate  *
35*7c478bd9Sstevel@tonic-gate  * MODULE: dat_dr.c
36*7c478bd9Sstevel@tonic-gate  *
37*7c478bd9Sstevel@tonic-gate  * PURPOSE: dynamic registry implementation
38*7c478bd9Sstevel@tonic-gate  *
39*7c478bd9Sstevel@tonic-gate  * $Id: dat_dr.c,v 1.12 2003/08/20 14:28:40 hobie16 Exp $
40*7c478bd9Sstevel@tonic-gate  */
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate #include "dat_dr.h"
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate #include "dat_dictionary.h"
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate /*
49*7c478bd9Sstevel@tonic-gate  *
50*7c478bd9Sstevel@tonic-gate  * Global Variables
51*7c478bd9Sstevel@tonic-gate  *
52*7c478bd9Sstevel@tonic-gate  */
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate static DAT_OS_LOCK 		g_dr_lock;
55*7c478bd9Sstevel@tonic-gate static DAT_DICTIONARY 		*g_dr_dictionary = NULL;
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate /*
59*7c478bd9Sstevel@tonic-gate  *
60*7c478bd9Sstevel@tonic-gate  * External Functions
61*7c478bd9Sstevel@tonic-gate  *
62*7c478bd9Sstevel@tonic-gate  */
63*7c478bd9Sstevel@tonic-gate 
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate /*
66*7c478bd9Sstevel@tonic-gate  * Function: dat_dr_init
67*7c478bd9Sstevel@tonic-gate  */
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate DAT_RETURN
dat_dr_init(void)70*7c478bd9Sstevel@tonic-gate dat_dr_init(void)
71*7c478bd9Sstevel@tonic-gate {
72*7c478bd9Sstevel@tonic-gate 	DAT_RETURN 	status;
73*7c478bd9Sstevel@tonic-gate 
74*7c478bd9Sstevel@tonic-gate 	status = dat_os_lock_init(&g_dr_lock);
75*7c478bd9Sstevel@tonic-gate 	if (DAT_SUCCESS != status) {
76*7c478bd9Sstevel@tonic-gate 		return (status);
77*7c478bd9Sstevel@tonic-gate 	}
78*7c478bd9Sstevel@tonic-gate 
79*7c478bd9Sstevel@tonic-gate 	status = dat_dictionary_create(&g_dr_dictionary);
80*7c478bd9Sstevel@tonic-gate 	if (DAT_SUCCESS != status) {
81*7c478bd9Sstevel@tonic-gate 		return (status);
82*7c478bd9Sstevel@tonic-gate 	}
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate 	return (DAT_SUCCESS);
85*7c478bd9Sstevel@tonic-gate }
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate /*
89*7c478bd9Sstevel@tonic-gate  * Function: dat_dr_fini
90*7c478bd9Sstevel@tonic-gate  */
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate DAT_RETURN
dat_dr_fini(void)93*7c478bd9Sstevel@tonic-gate dat_dr_fini(void)
94*7c478bd9Sstevel@tonic-gate {
95*7c478bd9Sstevel@tonic-gate 	DAT_RETURN 			status;
96*7c478bd9Sstevel@tonic-gate 
97*7c478bd9Sstevel@tonic-gate 	status = dat_os_lock_destroy(&g_dr_lock);
98*7c478bd9Sstevel@tonic-gate 	if (DAT_SUCCESS != status) {
99*7c478bd9Sstevel@tonic-gate 		return (status);
100*7c478bd9Sstevel@tonic-gate 	}
101*7c478bd9Sstevel@tonic-gate 
102*7c478bd9Sstevel@tonic-gate 	status = dat_dictionary_destroy(g_dr_dictionary);
103*7c478bd9Sstevel@tonic-gate 	if (DAT_SUCCESS != status) {
104*7c478bd9Sstevel@tonic-gate 		return (status);
105*7c478bd9Sstevel@tonic-gate 	}
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate 	return (DAT_SUCCESS);
108*7c478bd9Sstevel@tonic-gate }
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate /*
112*7c478bd9Sstevel@tonic-gate  * Function: dat_dr_insert
113*7c478bd9Sstevel@tonic-gate  */
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate extern DAT_RETURN
dat_dr_insert(IN const DAT_PROVIDER_INFO * info,IN DAT_DR_ENTRY * entry)116*7c478bd9Sstevel@tonic-gate dat_dr_insert(
117*7c478bd9Sstevel@tonic-gate     IN  const DAT_PROVIDER_INFO *info,
118*7c478bd9Sstevel@tonic-gate     IN  DAT_DR_ENTRY 		*entry)
119*7c478bd9Sstevel@tonic-gate {
120*7c478bd9Sstevel@tonic-gate 	DAT_RETURN 		status;
121*7c478bd9Sstevel@tonic-gate 	DAT_DICTIONARY_ENTRY 	dict_entry;
122*7c478bd9Sstevel@tonic-gate 	DAT_DR_ENTRY		*data;
123*7c478bd9Sstevel@tonic-gate 
124*7c478bd9Sstevel@tonic-gate 	data = dat_os_alloc(sizeof (DAT_DR_ENTRY));
125*7c478bd9Sstevel@tonic-gate 	if (NULL == data) {
126*7c478bd9Sstevel@tonic-gate 		status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
127*7c478bd9Sstevel@tonic-gate 		    DAT_RESOURCE_MEMORY);
128*7c478bd9Sstevel@tonic-gate 		goto bail;
129*7c478bd9Sstevel@tonic-gate 	}
130*7c478bd9Sstevel@tonic-gate 
131*7c478bd9Sstevel@tonic-gate 	*data = *entry;
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate 	dict_entry = NULL;
134*7c478bd9Sstevel@tonic-gate 	status = dat_dictionary_entry_create(&dict_entry);
135*7c478bd9Sstevel@tonic-gate 	if (DAT_SUCCESS != status) {
136*7c478bd9Sstevel@tonic-gate 		goto bail;
137*7c478bd9Sstevel@tonic-gate 	}
138*7c478bd9Sstevel@tonic-gate 
139*7c478bd9Sstevel@tonic-gate 	dat_os_lock(&g_dr_lock);
140*7c478bd9Sstevel@tonic-gate 
141*7c478bd9Sstevel@tonic-gate 	status = dat_dictionary_insert(g_dr_dictionary,
142*7c478bd9Sstevel@tonic-gate 		dict_entry,
143*7c478bd9Sstevel@tonic-gate 		info,
144*7c478bd9Sstevel@tonic-gate 		(DAT_DICTIONARY_DATA *) data);
145*7c478bd9Sstevel@tonic-gate 
146*7c478bd9Sstevel@tonic-gate 	dat_os_unlock(&g_dr_lock);
147*7c478bd9Sstevel@tonic-gate 
148*7c478bd9Sstevel@tonic-gate bail:
149*7c478bd9Sstevel@tonic-gate 	if (DAT_SUCCESS != status) {
150*7c478bd9Sstevel@tonic-gate 		if (NULL != data) {
151*7c478bd9Sstevel@tonic-gate 			dat_os_free(data, sizeof (DAT_DR_ENTRY));
152*7c478bd9Sstevel@tonic-gate 		}
153*7c478bd9Sstevel@tonic-gate 
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate 		if (NULL != dict_entry) {
156*7c478bd9Sstevel@tonic-gate 			(void) dat_dictionary_entry_destroy(dict_entry);
157*7c478bd9Sstevel@tonic-gate 		}
158*7c478bd9Sstevel@tonic-gate 	}
159*7c478bd9Sstevel@tonic-gate 
160*7c478bd9Sstevel@tonic-gate 	return (status);
161*7c478bd9Sstevel@tonic-gate }
162*7c478bd9Sstevel@tonic-gate 
163*7c478bd9Sstevel@tonic-gate 
164*7c478bd9Sstevel@tonic-gate /*
165*7c478bd9Sstevel@tonic-gate  * Function: dat_dr_remove
166*7c478bd9Sstevel@tonic-gate  */
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate extern DAT_RETURN
dat_dr_remove(IN const DAT_PROVIDER_INFO * info)169*7c478bd9Sstevel@tonic-gate dat_dr_remove(
170*7c478bd9Sstevel@tonic-gate     IN  const DAT_PROVIDER_INFO *info)
171*7c478bd9Sstevel@tonic-gate {
172*7c478bd9Sstevel@tonic-gate 	DAT_DR_ENTRY 		*data;
173*7c478bd9Sstevel@tonic-gate 	DAT_DICTIONARY_ENTRY 	dict_entry;
174*7c478bd9Sstevel@tonic-gate 	DAT_RETURN 		status;
175*7c478bd9Sstevel@tonic-gate 
176*7c478bd9Sstevel@tonic-gate 	dat_os_lock(&g_dr_lock);
177*7c478bd9Sstevel@tonic-gate 
178*7c478bd9Sstevel@tonic-gate 	status = dat_dictionary_search(g_dr_dictionary,
179*7c478bd9Sstevel@tonic-gate 	    info,
180*7c478bd9Sstevel@tonic-gate 	    (DAT_DICTIONARY_DATA *) &data);
181*7c478bd9Sstevel@tonic-gate 
182*7c478bd9Sstevel@tonic-gate 	if (DAT_SUCCESS != status) {
183*7c478bd9Sstevel@tonic-gate 		/* return status from dat_dictionary_search() */
184*7c478bd9Sstevel@tonic-gate 		goto bail;
185*7c478bd9Sstevel@tonic-gate 	}
186*7c478bd9Sstevel@tonic-gate 
187*7c478bd9Sstevel@tonic-gate 	if (0 != data->ref_count) {
188*7c478bd9Sstevel@tonic-gate 		status = DAT_ERROR(DAT_PROVIDER_IN_USE, 0);
189*7c478bd9Sstevel@tonic-gate 		goto bail;
190*7c478bd9Sstevel@tonic-gate 	}
191*7c478bd9Sstevel@tonic-gate 
192*7c478bd9Sstevel@tonic-gate 	dict_entry = NULL;
193*7c478bd9Sstevel@tonic-gate 	status = dat_dictionary_remove(g_dr_dictionary,
194*7c478bd9Sstevel@tonic-gate 	    &dict_entry,
195*7c478bd9Sstevel@tonic-gate 	    info,
196*7c478bd9Sstevel@tonic-gate 	    (DAT_DICTIONARY_DATA *) &data);
197*7c478bd9Sstevel@tonic-gate 
198*7c478bd9Sstevel@tonic-gate 	if (DAT_SUCCESS != status) {
199*7c478bd9Sstevel@tonic-gate 		/* return status from dat_dictionary_remove() */
200*7c478bd9Sstevel@tonic-gate 		goto bail;
201*7c478bd9Sstevel@tonic-gate 	}
202*7c478bd9Sstevel@tonic-gate 
203*7c478bd9Sstevel@tonic-gate 	dat_os_free(data, sizeof (DAT_DR_ENTRY));
204*7c478bd9Sstevel@tonic-gate 
205*7c478bd9Sstevel@tonic-gate bail:
206*7c478bd9Sstevel@tonic-gate 	dat_os_unlock(&g_dr_lock);
207*7c478bd9Sstevel@tonic-gate 
208*7c478bd9Sstevel@tonic-gate 	if (NULL != dict_entry) {
209*7c478bd9Sstevel@tonic-gate 		(void) dat_dictionary_entry_destroy(dict_entry);
210*7c478bd9Sstevel@tonic-gate 	}
211*7c478bd9Sstevel@tonic-gate 
212*7c478bd9Sstevel@tonic-gate 	return (status);
213*7c478bd9Sstevel@tonic-gate }
214*7c478bd9Sstevel@tonic-gate 
215*7c478bd9Sstevel@tonic-gate 
216*7c478bd9Sstevel@tonic-gate /*
217*7c478bd9Sstevel@tonic-gate  * Function: dat_dr_provider_open
218*7c478bd9Sstevel@tonic-gate  */
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate extern DAT_RETURN
dat_dr_provider_open(IN const DAT_PROVIDER_INFO * info,OUT DAT_IA_OPEN_FUNC * p_ia_open_func)221*7c478bd9Sstevel@tonic-gate dat_dr_provider_open(
222*7c478bd9Sstevel@tonic-gate     IN  const DAT_PROVIDER_INFO *info,
223*7c478bd9Sstevel@tonic-gate     OUT DAT_IA_OPEN_FUNC	*p_ia_open_func)
224*7c478bd9Sstevel@tonic-gate {
225*7c478bd9Sstevel@tonic-gate 	DAT_RETURN 		status;
226*7c478bd9Sstevel@tonic-gate 	DAT_DR_ENTRY 		*data;
227*7c478bd9Sstevel@tonic-gate 
228*7c478bd9Sstevel@tonic-gate 	dat_os_lock(&g_dr_lock);
229*7c478bd9Sstevel@tonic-gate 
230*7c478bd9Sstevel@tonic-gate 	status = dat_dictionary_search(g_dr_dictionary,
231*7c478bd9Sstevel@tonic-gate 				info,
232*7c478bd9Sstevel@tonic-gate 				(DAT_DICTIONARY_DATA *) &data);
233*7c478bd9Sstevel@tonic-gate 
234*7c478bd9Sstevel@tonic-gate 	dat_os_unlock(&g_dr_lock);
235*7c478bd9Sstevel@tonic-gate 
236*7c478bd9Sstevel@tonic-gate 	if (DAT_SUCCESS == status) {
237*7c478bd9Sstevel@tonic-gate 		data->ref_count++;
238*7c478bd9Sstevel@tonic-gate 		*p_ia_open_func = data->ia_open_func;
239*7c478bd9Sstevel@tonic-gate 	}
240*7c478bd9Sstevel@tonic-gate 
241*7c478bd9Sstevel@tonic-gate 	return (status);
242*7c478bd9Sstevel@tonic-gate }
243*7c478bd9Sstevel@tonic-gate 
244*7c478bd9Sstevel@tonic-gate 
245*7c478bd9Sstevel@tonic-gate /*
246*7c478bd9Sstevel@tonic-gate  * Function: dat_dr_provider_close
247*7c478bd9Sstevel@tonic-gate  */
248*7c478bd9Sstevel@tonic-gate 
249*7c478bd9Sstevel@tonic-gate extern DAT_RETURN
dat_dr_provider_close(IN const DAT_PROVIDER_INFO * info)250*7c478bd9Sstevel@tonic-gate dat_dr_provider_close(
251*7c478bd9Sstevel@tonic-gate     IN  const DAT_PROVIDER_INFO *info)
252*7c478bd9Sstevel@tonic-gate {
253*7c478bd9Sstevel@tonic-gate 	DAT_RETURN 		status;
254*7c478bd9Sstevel@tonic-gate 	DAT_DR_ENTRY 		*data;
255*7c478bd9Sstevel@tonic-gate 
256*7c478bd9Sstevel@tonic-gate 	dat_os_lock(&g_dr_lock);
257*7c478bd9Sstevel@tonic-gate 
258*7c478bd9Sstevel@tonic-gate 	status = dat_dictionary_search(g_dr_dictionary,
259*7c478bd9Sstevel@tonic-gate 	    info,
260*7c478bd9Sstevel@tonic-gate 	    (DAT_DICTIONARY_DATA *) &data);
261*7c478bd9Sstevel@tonic-gate 
262*7c478bd9Sstevel@tonic-gate 	dat_os_unlock(&g_dr_lock);
263*7c478bd9Sstevel@tonic-gate 
264*7c478bd9Sstevel@tonic-gate 	if (DAT_SUCCESS == status) {
265*7c478bd9Sstevel@tonic-gate 		data->ref_count--;
266*7c478bd9Sstevel@tonic-gate 	}
267*7c478bd9Sstevel@tonic-gate 
268*7c478bd9Sstevel@tonic-gate 	return (status);
269*7c478bd9Sstevel@tonic-gate }
270*7c478bd9Sstevel@tonic-gate 
271*7c478bd9Sstevel@tonic-gate 
272*7c478bd9Sstevel@tonic-gate /*
273*7c478bd9Sstevel@tonic-gate  * Function: dat_dr_size
274*7c478bd9Sstevel@tonic-gate  */
275*7c478bd9Sstevel@tonic-gate 
276*7c478bd9Sstevel@tonic-gate DAT_RETURN
dat_dr_size(OUT DAT_COUNT * size)277*7c478bd9Sstevel@tonic-gate dat_dr_size(
278*7c478bd9Sstevel@tonic-gate     OUT	DAT_COUNT		*size)
279*7c478bd9Sstevel@tonic-gate {
280*7c478bd9Sstevel@tonic-gate 	return (dat_dictionary_size(g_dr_dictionary, size));
281*7c478bd9Sstevel@tonic-gate }
282*7c478bd9Sstevel@tonic-gate 
283*7c478bd9Sstevel@tonic-gate 
284*7c478bd9Sstevel@tonic-gate /*
285*7c478bd9Sstevel@tonic-gate  * Function: dat_dr_list
286*7c478bd9Sstevel@tonic-gate  */
287*7c478bd9Sstevel@tonic-gate 
288*7c478bd9Sstevel@tonic-gate DAT_RETURN
dat_dr_list(IN DAT_COUNT max_to_return,OUT DAT_COUNT * entries_returned,OUT DAT_PROVIDER_INFO * (dat_provider_list[]))289*7c478bd9Sstevel@tonic-gate dat_dr_list(
290*7c478bd9Sstevel@tonic-gate     IN  DAT_COUNT		max_to_return,
291*7c478bd9Sstevel@tonic-gate     OUT DAT_COUNT		*entries_returned,
292*7c478bd9Sstevel@tonic-gate     OUT DAT_PROVIDER_INFO	* (dat_provider_list[]))
293*7c478bd9Sstevel@tonic-gate {
294*7c478bd9Sstevel@tonic-gate 	DAT_DR_ENTRY		**array;
295*7c478bd9Sstevel@tonic-gate 	DAT_COUNT 		array_size;
296*7c478bd9Sstevel@tonic-gate 	DAT_COUNT 		i;
297*7c478bd9Sstevel@tonic-gate 	DAT_RETURN 		status;
298*7c478bd9Sstevel@tonic-gate 
299*7c478bd9Sstevel@tonic-gate 	array = NULL;
300*7c478bd9Sstevel@tonic-gate 	status = DAT_SUCCESS;
301*7c478bd9Sstevel@tonic-gate 
302*7c478bd9Sstevel@tonic-gate 	/*
303*7c478bd9Sstevel@tonic-gate 	 * The dictionary size may increase between the call to
304*7c478bd9Sstevel@tonic-gate 	 * dat_dictionary_size() and dat_dictionary_enumerate().
305*7c478bd9Sstevel@tonic-gate 	 * Therefore we loop until a successful enumeration is made.
306*7c478bd9Sstevel@tonic-gate 	 */
307*7c478bd9Sstevel@tonic-gate 	*entries_returned = 0;
308*7c478bd9Sstevel@tonic-gate 	for (;;) {
309*7c478bd9Sstevel@tonic-gate 		status = dat_dictionary_size(g_dr_dictionary, &array_size);
310*7c478bd9Sstevel@tonic-gate 		if (status != DAT_SUCCESS) {
311*7c478bd9Sstevel@tonic-gate 			goto bail;
312*7c478bd9Sstevel@tonic-gate 		}
313*7c478bd9Sstevel@tonic-gate 
314*7c478bd9Sstevel@tonic-gate 		if (array_size == 0) {
315*7c478bd9Sstevel@tonic-gate 			status = DAT_SUCCESS;
316*7c478bd9Sstevel@tonic-gate 			goto bail;
317*7c478bd9Sstevel@tonic-gate 		}
318*7c478bd9Sstevel@tonic-gate 
319*7c478bd9Sstevel@tonic-gate 		array = dat_os_alloc(array_size * sizeof (DAT_DR_ENTRY *));
320*7c478bd9Sstevel@tonic-gate 		if (array == NULL) {
321*7c478bd9Sstevel@tonic-gate 			status = DAT_ERROR(DAT_INSUFFICIENT_RESOURCES,
322*7c478bd9Sstevel@tonic-gate 			    DAT_RESOURCE_MEMORY);
323*7c478bd9Sstevel@tonic-gate 			goto bail;
324*7c478bd9Sstevel@tonic-gate 		}
325*7c478bd9Sstevel@tonic-gate 
326*7c478bd9Sstevel@tonic-gate 		dat_os_lock(&g_dr_lock);
327*7c478bd9Sstevel@tonic-gate 
328*7c478bd9Sstevel@tonic-gate 		status = dat_dictionary_enumerate(g_dr_dictionary,
329*7c478bd9Sstevel@tonic-gate 		    (DAT_DICTIONARY_DATA *) array,
330*7c478bd9Sstevel@tonic-gate 		    array_size);
331*7c478bd9Sstevel@tonic-gate 
332*7c478bd9Sstevel@tonic-gate 		dat_os_unlock(&g_dr_lock);
333*7c478bd9Sstevel@tonic-gate 
334*7c478bd9Sstevel@tonic-gate 		if (DAT_SUCCESS == status) {
335*7c478bd9Sstevel@tonic-gate 			break;
336*7c478bd9Sstevel@tonic-gate 		} else {
337*7c478bd9Sstevel@tonic-gate 			dat_os_free(array,
338*7c478bd9Sstevel@tonic-gate 			    array_size * sizeof (DAT_DR_ENTRY *));
339*7c478bd9Sstevel@tonic-gate 			array = NULL;
340*7c478bd9Sstevel@tonic-gate 			continue;
341*7c478bd9Sstevel@tonic-gate 		}
342*7c478bd9Sstevel@tonic-gate 	}
343*7c478bd9Sstevel@tonic-gate 
344*7c478bd9Sstevel@tonic-gate 	for (i = 0; (i < max_to_return) && (i < array_size); i++) {
345*7c478bd9Sstevel@tonic-gate 		if (NULL == dat_provider_list[i]) {
346*7c478bd9Sstevel@tonic-gate 			status = DAT_ERROR(DAT_INVALID_PARAMETER,
347*7c478bd9Sstevel@tonic-gate 			    DAT_INVALID_ARG3);
348*7c478bd9Sstevel@tonic-gate 			goto bail;
349*7c478bd9Sstevel@tonic-gate 		}
350*7c478bd9Sstevel@tonic-gate 
351*7c478bd9Sstevel@tonic-gate 		*dat_provider_list[i] = array[i]->info;
352*7c478bd9Sstevel@tonic-gate 	}
353*7c478bd9Sstevel@tonic-gate 
354*7c478bd9Sstevel@tonic-gate 	*entries_returned = i;
355*7c478bd9Sstevel@tonic-gate 
356*7c478bd9Sstevel@tonic-gate bail:
357*7c478bd9Sstevel@tonic-gate 	if (NULL != array) {
358*7c478bd9Sstevel@tonic-gate 		dat_os_free(array, array_size * sizeof (DAT_DR_ENTRY *));
359*7c478bd9Sstevel@tonic-gate 	}
360*7c478bd9Sstevel@tonic-gate 
361*7c478bd9Sstevel@tonic-gate 	return (status);
362*7c478bd9Sstevel@tonic-gate }
363*7c478bd9Sstevel@tonic-gate 
364*7c478bd9Sstevel@tonic-gate /*
365*7c478bd9Sstevel@tonic-gate  * Local variables:
366*7c478bd9Sstevel@tonic-gate  *  c-indent-level: 4
367*7c478bd9Sstevel@tonic-gate  *  c-basic-offset: 4
368*7c478bd9Sstevel@tonic-gate  *  tab-width: 8
369*7c478bd9Sstevel@tonic-gate  * End:
370*7c478bd9Sstevel@tonic-gate  */
371