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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include "Solaris_SharedFileSystem.h"
30 #include "nfs_keys.h"
31 #include "nfs_providers_msgstrings.h"
32 #include "messageStrings.h"
33 #include "nfs_provider_names.h"
34 #include "util.h"
35 #include "common_functions.h"
36 #include "createprop_methods.h"
37 #include <sys/types.h>
38 
39 typedef void* inst_or_objPath;
40 
41 /*
42  * Private method declaration
43  */
44 static inst_or_objPath	get_associated_directory(CCIMObjectPath *nfsShareOP,
45 				boolean_t returnInst);
46 static CCIMInstanceList* get_associated_instances(CCIMObjectPath *pOP,
47 				boolean_t isSystemElement);
48 static CCIMInstance*	get_associated_share(CCIMObjectPath *dirOP);
49 
50 /*
51  * Public methods
52  */
53 
54 /*
55  * Instance provider methods
56  */
57 
58 /*
59  * Method: cp_createInstance_Solaris_SharedFileSystem
60  *
61  * Description: This method is not supported.  It is not supported because in
62  * order for a Solaris_SharedFileSystem association to exist a corresponding
63  * Solaris_NFSShare and Solaris_Directory must exist.
64  *
65  * Parameters:
66  *	- CCIMObjectPath *pOP - An object path containing the name of
67  *	the class of which to create an instance of.
68  *	- CCIMInstance *pInst - Not used.
69  *
70  * Returns:
71  *	- Always returns NULL because the method is not supported.
72  */
73 /* ARGSUSED */
74 CCIMObjectPath *
cp_createInstance_Solaris_SharedFileSystem(CCIMObjectPath * pOP,CCIMInstance * pInst)75 cp_createInstance_Solaris_SharedFileSystem(CCIMObjectPath *pOP,
76 	CCIMInstance *pInst) {
77 
78 	int	err = 0;
79 
80 	util_handleError("SOLARIS_SHAREDFS::CREATE_INSTANCE",
81 		CIM_ERR_NOT_SUPPORTED, NULL, NULL, &err);
82 
83 	return ((CCIMObjectPath *)NULL);
84 } /* cp_createInstance_Solaris_SharedFileSystem */
85 
86 /*
87  * Method: cp_deleteInstance_Solaris_SharedFileSystem
88  *
89  * Description: This method is not supported.  It is not supported because in
90  * order for it to be actually deleted the corresponding Solaris_NFSShare or
91  * Solaris_Directory would need to be deleted.  That action is not appropriate
92  * for this provider.
93  *
94  * Parameters:
95  *	- CCIMObjectPath *pOP - An object path containing the
96  *	information about the class of which to delete the instance of.
97  *
98  * Returns:
99  *	- Always returns cim_false because the method is not supported.
100  */
101 /* ARGSUSED */
102 CIMBool
cp_deleteInstance_Solaris_SharedFileSystem(CCIMObjectPath pOP)103 cp_deleteInstance_Solaris_SharedFileSystem(CCIMObjectPath pOP) {
104 	int	err = 0;
105 
106 	util_handleError("SOLARIS_SHAREDFS::DELETE_INSTANCE",
107 		CIM_ERR_NOT_SUPPORTED, NULL, NULL, &err);
108 
109 	return (cim_false);
110 } /* cp_deleteInstance_Solaris_SharedFileSystem */
111 
112 /*
113  * Method: cp_enumInstances_Solaris_SharedFileSystem
114  *
115  * Description: Enumerates the instances of Solaris_SharedFileSystem on a host.
116  * An instance of Solaris_SharedFileSystem is an association that links a share
117  * object to the directory that is shared.
118  *
119  * Parameters:
120  *	- CCIMObjectPath *pOP - An object path containing the name of
121  *	the class of which to enumerate the instances of.
122  *
123  * Returns:
124  *	- A pointer to a list of Solaris_SharedFileSystem instances.
125  *	- NULL if an error occurred or if there are no instances of
126  *	Solaris_SharedFileSystem on the host.  In the case of an error, the
127  *	error will be logged.
128  */
129 CCIMInstanceList *
cp_enumInstances_Solaris_SharedFileSystem(CCIMObjectPath * pOP)130 cp_enumInstances_Solaris_SharedFileSystem(CCIMObjectPath *pOP) {
131 	CCIMObjectPathList	*nfsShareOPList;
132 	CCIMObjectPathList	*currentShareOP;
133 	CCIMInstanceList	*sharedFSInstList;
134 	CCIMObjectPath		*nfsShareOP;
135 	CCIMException		*ex;
136 	cimchar			*pValue;
137 	int			err = 0;
138 
139 	if (pOP == NULL) {
140 		util_handleError("SOLARIS_SHAREDFS::ENUM_INSTANCES",
141 			CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err);
142 		return ((CCIMInstanceList *)NULL);
143 	}
144 
145 	nfsShareOP = cim_createEmptyObjectPath(SOLARIS_NFSSHARE);
146 	if (nfsShareOP == NULL) {
147 		ex = cim_getLastError();
148 		util_handleError("SOLARIS_SHAREDFS::ENUM_INSTANCES",
149 			CIM_ERR_FAILED, CREATE_EMPTY_OBJPATH_FAILURE, ex, &err);
150 		return ((CCIMInstanceList *)NULL);
151 	}
152 
153 	nfsShareOPList = cimom_enumerateInstanceNames(nfsShareOP, cim_false);
154 	/*
155 	 * A NULL return value means error, an empty list does not.
156 	 */
157 	if (nfsShareOPList == NULL) {
158 		ex = cim_getLastError();
159 		util_handleError("SOLARIS_SHAREDFS::ENUM_INSTANCES",
160 			CIM_ERR_FAILED, CIMOM_ENUM_INSTNAMES_FAILURE, ex, &err);
161 		cim_freeObjectPath(nfsShareOP);
162 		return ((CCIMInstanceList *)NULL);
163 	}
164 
165 	cim_freeObjectPath(nfsShareOP);
166 
167 	if (nfsShareOPList->mDataObject == NULL) {
168 		return ((CCIMInstanceList *)NULL);
169 	}
170 
171 	sharedFSInstList = cim_createInstanceList();
172 	if (sharedFSInstList == NULL) {
173 		ex = cim_getLastError();
174 		util_handleError("SOLARIS_SHAREDFS::ENUM_INSTANCES",
175 			CIM_ERR_FAILED, CREATE_INSTANCE_LIST_FAILURE, ex, &err);
176 		cim_freeObjectPathList(nfsShareOPList);
177 		return ((CCIMInstanceList *)NULL);
178 	}
179 
180 	for (currentShareOP = nfsShareOPList; currentShareOP != NULL;
181 		currentShareOP = currentShareOP->mNext) {
182 
183 		CCIMObjectPath	*sysElementOP;
184 		CCIMInstance	*sharedFSInst;
185 
186 		sharedFSInst = cim_createInstance(SOLARIS_SHAREDFS);
187 		if (sharedFSInst == NULL) {
188 			ex = cim_getLastError();
189 			util_handleError("SOLARIS_SHAREDFS::ENUM_INSTANCES",
190 				CIM_ERR_FAILED, CREATE_INSTANCE_FAILURE, ex,
191 				&err);
192 			cim_freeObjectPathList(nfsShareOPList);
193 			cim_freeInstanceList(sharedFSInstList);
194 			return ((CCIMInstanceList *) NULL);
195 		}
196 
197 		/*
198 		 * Retrieve the Solaris_Directory instance associated with
199 		 * the current Solaris_NFSShare object path.
200 		 */
201 		sysElementOP = get_associated_directory(
202 			currentShareOP->mDataObject, B_FALSE);
203 		if (sysElementOP == NULL) {
204 			cim_freeObjectPathList(nfsShareOPList);
205 			cim_freeInstanceList(sharedFSInstList);
206 			cim_freeInstance(sharedFSInst);
207 			return ((CCIMInstanceList *)NULL);
208 		}
209 
210 		pValue = NULL;
211 		if (add_property_to_instance(sharedFSProps[SYS].name,
212 			sharedFSProps[SYS].type, pValue, sysElementOP,
213 			sharedFSProps[SYS].isKey, sharedFSInst) == cim_false) {
214 
215 			cim_freeObjectPathList(nfsShareOPList);
216 			cim_freeObjectPath(sysElementOP);
217 			cim_freeInstanceList(sharedFSInstList);
218 			cim_freeInstance(sharedFSInst);
219 			return ((CCIMInstanceList *)NULL);
220 		}
221 
222 		cim_freeObjectPath(sysElementOP);
223 
224 		pValue = NULL;
225 		if (add_property_to_instance(sharedFSProps[SAME].name,
226 			sharedFSProps[SAME].type, pValue,
227 			currentShareOP->mDataObject, sharedFSProps[SAME].isKey,
228 			sharedFSInst) == cim_false) {
229 
230 			cim_freeObjectPathList(nfsShareOPList);
231 			cim_freeInstanceList(sharedFSInstList);
232 			cim_freeInstance(sharedFSInst);
233 			return ((CCIMInstanceList *)NULL);
234 		}
235 
236 		/*
237 		 * Add the instance to the instance list.
238 		 */
239 		sharedFSInstList = cim_addInstance(sharedFSInstList,
240 			sharedFSInst);
241 		if (sharedFSInstList == NULL) {
242 			ex = cim_getLastError();
243 			util_handleError("SOLARIS_SHAREDFS::ENUM_INSTANCES",
244 				CIM_ERR_FAILED, ADD_INSTANCE_FAILURE, ex, &err);
245 			cim_freeObjectPathList(nfsShareOPList);
246 			cim_freeInstance(sharedFSInst);
247 			return ((CCIMInstanceList *)NULL);
248 		}
249 
250 	} /* end for */
251 
252 	cim_freeObjectPathList(nfsShareOPList);
253 	return (sharedFSInstList);
254 } /* cp_enumInstances_Solaris_SharedFileSystem */
255 
256 /*
257  * Method: cp_enumInstanceNames_Solaris_SharedFileSystem
258  *
259  * Description: Enumerates the instances of Solaris_SharedFileSystem on a host.
260  * An instance of Solaris_SharedFileSystem is an association that links a share
261  * object to the directory that is shared.
262  *
263  * Parameters:
264  *	- CCIMObjectPath *pOP - An object path containing the name of
265  *	the class of which to enumerate the instances of.
266  *
267  * Returns:
268  *	- A pointer to a list of object paths corresponding to the
269  *	Solaris_SharedFileSystem instances on the host.
270  *	- NULL if an error occurred or if there are no instances of
271  *	Solaris_SharedFileSystem on the host.  In the case of an error, the
272  *	error will be logged.
273  */
274 CCIMObjectPathList *
cp_enumInstanceNames_Solaris_SharedFileSystem(CCIMObjectPath * pOP)275 cp_enumInstanceNames_Solaris_SharedFileSystem(CCIMObjectPath *pOP) {
276 	CCIMInstanceList	*sharedFSInstList;
277 	CCIMObjectPathList	*sharedFSOPList;
278 	int			err = 0;
279 
280 	if (pOP == NULL) {
281 		util_handleError("SOLARIS_SHAREDFS::ENUM_INSTANCENAMES",
282 			CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err);
283 		return ((CCIMObjectPathList *)NULL);
284 	}
285 
286 	sharedFSInstList = cp_enumInstances_Solaris_SharedFileSystem(pOP);
287 	if (sharedFSInstList == NULL) {
288 		/*
289 		 * Either an error occurred or there are no instances of
290 		 * Solaris_SharedFileSystem on the system.  In the case of an
291 		 * error, the error would have been handled in
292 		 * cp_enumInstances_Solaris_SharedFileSystem.
293 		 */
294 		return ((CCIMObjectPathList *)NULL);
295 	}
296 
297 	sharedFSOPList = cim_createObjectPathList(sharedFSInstList);
298 
299 	cim_freeInstanceList(sharedFSInstList);
300 	return (sharedFSOPList);
301 } /* cp_enumInstanceNames_Solaris_SharedFileSystem */
302 
303 /*
304  * Method: cp_execQuery_Solaris_SharedFileSystem
305  *
306  * Description: Queries the host to find those Solaris_SharedFileSystem
307  * instances that meet the search criteria.
308  *
309  * Parameters:
310  *	- CCIMObjectPath *pOP - An object path containing the name of
311  *	the class of which to query.
312  *	- char *selectClause - Not used.
313  *	- char *nonJoinExp - Not used.
314  *	- char *queryExp - Not used.
315  *	- char *queryLang - Not used.
316  *
317  * Returns:
318  *	- A pointer to a list of Solaris_SharedFileSystem instances that match
319  *	the criteria.
320  *	- NULL if an error occurred or if there are no Solaris_SharedFileSystem
321  *	instances that match the criteria.  In the case of an error, the error
322  *	will be logged.
323  *
324  * NOTE: Currently, there is no WQL parser for the C providers. As a result,
325  * what is returned to the CIMOM is a list of instances with
326  * a NULL value at the beginning of the list. This NULL value indicates
327  * to the CIMOM that it must do the filtering for the client.
328  */
329 /* ARGSUSED */
330 CCIMInstanceList *
cp_execQuery_Solaris_SharedFileSystem(CCIMObjectPath * pOP,char * selectClause,char * nonJoinExp,char * queryExp,char * queryLang)331 cp_execQuery_Solaris_SharedFileSystem(CCIMObjectPath *pOP,
332 	char *selectClause, char *nonJoinExp, char *queryExp, char *queryLang) {
333 
334 	CCIMInstance		*emptyInst;
335 	CCIMInstanceList	*sharedElemInstList;
336 	CCIMException		*ex;
337 	int			err = 0;
338 
339 	if (pOP == NULL) {
340 		util_handleError("SOLARIS_SHAREDFS::EXEC_QUERY",
341 			CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err);
342 		return ((CCIMInstanceList *)NULL);
343 	}
344 
345 	sharedElemInstList = cp_enumInstances_Solaris_SharedFileSystem(pOP);
346 	if (sharedElemInstList == NULL) {
347 		return ((CCIMInstanceList *)NULL);
348 	}
349 
350 	emptyInst = cim_createInstance("");
351 	if (emptyInst == NULL) {
352 		ex = cim_getLastError();
353 		util_handleError("SOLARIS_SHAREDFS::EXEC_QUERY",
354 			CIM_ERR_FAILED, CREATE_INSTANCE_FAILURE, ex, &err);
355 		cim_freeInstanceList(sharedElemInstList);
356 		return ((CCIMInstanceList *)NULL);
357 	}
358 
359 	sharedElemInstList = cim_prependInstance(sharedElemInstList, emptyInst);
360 	if (sharedElemInstList == NULL) {
361 		ex = cim_getLastError();
362 		util_handleError("SOLARIS_SHAREDFS::EXEC_QUERY",
363 			CIM_ERR_FAILED, PREPEND_INSTANCE_FAILURE, ex, &err);
364 		cim_freeInstance(emptyInst);
365 		return ((CCIMInstanceList *)NULL);
366 	}
367 
368 	return (sharedElemInstList);
369 } /* cp_execQuery_Solaris_SharedFileSystem */
370 
371 /*
372  * Method: cp_getInstance_Solaris_SharedFileSystem
373  *
374  * Description: Gets the instance corresponding to the passed in object path.
375  *
376  * Parameters:
377  *	- CCIMObjectPath *pOP - The object path containing all the
378  *	keys of the instance that is supposed to be returned.
379  *
380  * Returns:
381  *	- A pointer to the instance of Solaris_SharedFileSystem corresponding
382  *	to pOP.
383  *	- NULL if an error occurred or if the instance doesn't exist on the
384  *	host.  In the case of an error, the error will be logged.
385  */
386 CCIMInstance *
cp_getInstance_Solaris_SharedFileSystem(CCIMObjectPath * pOP)387 cp_getInstance_Solaris_SharedFileSystem(CCIMObjectPath *pOP) {
388 	CCIMInstanceList	*instList;
389 	CCIMInstance		*inst;
390 	CCIMObjectPath		*sameOP;
391 	CCIMObjectPath		*sysOP;
392 	CCIMPropertyList	*sharedFSPropList;
393 	int			err = 0;
394 
395 	if (pOP == NULL || pOP->mKeyProperties == NULL) {
396 		util_handleError("SOLARIS_SHAREDFS::GET_INSTANCE",
397 			CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err);
398 		return ((CCIMInstance *)NULL);
399 	}
400 
401 	/*
402 	 * Check if we have the SameElement and SystemElement properties.
403 	 */
404 	sharedFSPropList = pOP->mKeyProperties;
405 	sameOP = util_getKeyValue(sharedFSPropList, sharedFSProps[SAME].type,
406 		sharedFSProps[SAME].name, &err);
407 	sysOP = util_getKeyValue(sharedFSPropList, sharedFSProps[SYS].type,
408 		sharedFSProps[SYS].name, &err);
409 
410 	if (sameOP == NULL || sysOP == NULL) {
411 		util_handleError("SOLARIS_SHAREDFS::GET_INSTANCE",
412 			CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err);
413 		return ((CCIMInstance *)NULL);
414 	}
415 
416 	if (sameOP->mKeyProperties == NULL || sysOP->mKeyProperties == NULL) {
417 		util_handleError("SOLARIS_SHAREDFS::GET_INSTANCE",
418 			CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err);
419 		return ((CCIMInstance *)NULL);
420 	}
421 
422 	instList = cp_enumInstances_Solaris_SharedFileSystem(pOP);
423 	if (instList == NULL) {
424 		return ((CCIMInstance *)NULL);
425 	}
426 
427 	inst = cim_getInstance(instList, pOP);
428 
429 	cim_freeInstanceList(instList);
430 	return (inst);
431 } /* cp_getInstances_Solaris_SharedFileSystem */
432 
433 /*
434  * Method: cp_setInstance_Solaris_SharedFileSystem
435  *
436  * Description: This method is not supported.  It is not supported because in
437  * order to change a Solaris_SharedFileSystem instance the underlying share and
438  * directory must be modified.  Those actions must be done on the appropriate
439  * share and directory objects, not here.
440  *
441  * Parameters:
442  *	- CCIMObjectPath *pOP - An object path containing the name of the class
443  *	of which to set the instance.
444  *	- CCIMInstance *pInst - Not used.
445  *
446  * Returns:
447  *	- Always returns cim_false, because the method is not supported.
448  */
449 /* ARGSUSED */
450 CIMBool
cp_setInstance_Solaris_SharedFileSystem(CCIMObjectPath * pOP,CCIMInstance * pInst)451 cp_setInstance_Solaris_SharedFileSystem(CCIMObjectPath *pOP,
452 	CCIMInstance *pInst) {
453 
454 	int	err = 0;
455 
456 	util_handleError("SOLARIS_SHAREDFS::SET_INSTANCE",
457 		CIM_ERR_NOT_SUPPORTED, NULL, NULL, &err);
458 
459 	return (cim_false);
460 } /* cp_setInstance_Solaris_SharedFileSystem */
461 
462 /*
463  * Method: cp_setInstanceWithList_Solaris_SharedFileSystem
464  *
465  * Description: This method is not supported.  It is not supported because in
466  * order to change a Solaris_SharedFileSystem instance the underlying share and
467  * directory must be modified.  Those actions must be done on the appropriate
468  * share and directory objects, not here.
469  *
470  * Parameters:
471  *	- CCIMObjectPath *pOP - An object path containing the name of the class
472  *	of which to set the instance.
473  *	- CCIMInstance *pInst - Not used.
474  *
475  * Returns:
476  *	- Always returns cim_false, because the method is not supported.
477  */
478 /* ARGSUSED */
479 CIMBool
cp_setInstanceWithList_Solaris_SharedFileSystem(CCIMObjectPath * pOP,CCIMInstance * pInst,char ** props,int num_props)480 cp_setInstanceWithList_Solaris_SharedFileSystem(CCIMObjectPath *pOP,
481 	CCIMInstance *pInst, char **props, int num_props) {
482 
483 	int	err = 0;
484 
485 	util_handleError("SOLARIS_SHAREDFS::SET_INSTANCE",
486 		CIM_ERR_NOT_SUPPORTED, NULL, NULL, &err);
487 
488 	return (cim_false);
489 } /* cp_setInstanceWithList_Solaris_SharedFileSystem */
490 
491 /*
492  * Association provider methods
493  */
494 
495 /*
496  * Method: cp_associators_Solaris_SharedFileSystem
497  *
498  * Description: Returns the instances associated, via the
499  * Solaris_SharedFileSystem association, to the pObjectName parameter.
500  *
501  * Parameters:
502  *	- CCIMObjectPath *pAssocName - An object path containing the name of
503  *	the association that the caller is trying to reach.
504  *	- CCIMObjectPath *pObjectName - The object path containing information
505  *	(Class Name, Key Properties) about the object whose associated objects
506  *	are to be returned.
507  *	- char *pResultClass - If specified, only return instances that are of
508  *	this class type.
509  *	- char *pRole - If specified, this is the role of the pObjectName
510  *	object path passed in.  If this is not valid, NULL is returned.
511  *	- char *pResultRole - If specified, only return instances that are
512  *	playing this role in the association.
513  *
514  * Returns:
515  *	- A list of Solaris_NFSShare (if pRole == SystemElement && pObjectName
516  *	is a Solaris_Directory object path) or Solaris_Directory (if
517  *	pRole == SameElement && pObjectName is a Solaris_NFSShare object path)
518  *	instances which are associated to the pObjectName parameter.
519  *	- NULL if an error occurred or if there are no instances associated to
520  *	the pObjectName passed in.  In the case of an error, the error will be
521  *	logged.
522  */
523 /* ARGSUSED */
524 CCIMInstanceList *
cp_associators_Solaris_SharedFileSystem(CCIMObjectPath * pAssocName,CCIMObjectPath * pObjectName,char * pResultClass,char * pRole,char * pResultRole)525 cp_associators_Solaris_SharedFileSystem(CCIMObjectPath *pAssocName,
526 	CCIMObjectPath *pObjectName, char *pResultClass, char *pRole,
527 	char *pResultRole) {
528 
529 	CCIMInstanceList	*returnInstList = NULL;
530 	boolean_t		isSystemElement = B_FALSE;
531 	int			err = 0;
532 
533 	/*
534 	 * Check if the needed parameters are null.
535 	 */
536 	if (pObjectName == NULL || pObjectName->mKeyProperties == NULL) {
537 		util_handleError("SOLARIS_SHAREDFS::ASSOCIATORS",
538 			CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err);
539 		return ((CCIMInstanceList *)NULL);
540 	}
541 
542 	if ((strcasecmp(pObjectName->mName, SOLARIS_DIR) == 0)) {
543 		isSystemElement = B_TRUE;
544 		/*
545 		 * If a value was passed in with pRole and it does not match
546 		 * the role that pObjectName actually is then log an invalid
547 		 * param error.
548 		 */
549 		if (pRole != NULL && (strcasecmp(pRole, SYSTEM_ELEMENT) != 0)) {
550 			util_handleError("SOLARIS_SHAREDFS::ASSOCIATORS",
551 				CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err);
552 			return ((CCIMInstanceList *)NULL);
553 		}
554 	} else if ((strcasecmp(pObjectName->mName, SOLARIS_NFSSHARE) == 0)) {
555 		isSystemElement = B_FALSE;
556 		if (pRole != NULL && (strcasecmp(pRole, SAME_ELEMENT) != 0)) {
557 			util_handleError("SOLARIS_SHAREDFS::ASSOCIATORS",
558 				CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err);
559 			return ((CCIMInstanceList *)NULL);
560 		}
561 	} else {
562 		util_handleError("SOLARIS_SHAREDFS::ASSOCIATORS",
563 			CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err);
564 		return ((CCIMInstanceList *)NULL);
565 	}
566 
567 	returnInstList = get_associated_instances(pObjectName, isSystemElement);
568 
569 	return (returnInstList);
570 } /* cp_associators_Solaris_SharedFileSystem */
571 
572 /*
573  * Method: cp_associatorNames_Solaris_SharedFileSystem
574  *
575  * Description: Returns the object paths of the instances on the other side of
576  * the association which are associated via the Solaris_SharedFileSystem
577  * association and having the passed in parameter, pObjectName, as the opposite
578  * key.
579  *
580  * Parameters:
581  *	- CCIMObjectPath *pAssocName - An object path containing information
582  *	about the association that the caller is trying to reach.
583  *	- CCIMObjectPath *pObjectName - The object path which contains the
584  *	information on whose associated objects are to be returned.
585  *	- char *pResultClass - If specified, only return instances that are of
586  *	this class type.
587  *	- char *pRole - If specified, this is the role of the pObjectName
588  *	object path passed in.  If this is not valid, NULL is returned.
589  *	- char *pResultRole - If specified, only return instances that are
590  *	playing this role in the association.
591  *
592  * Returns:
593  *	- A list of Solaris_NFSShare (if pRole == SystemElement && pObjectName
594  *	is a Solaris_Directory object path) or Solaris_Directory (if
595  *	pRole == SameElement && pObjectName is a Solaris_NFSShare object path)
596  *	object paths which are associated to the pObjectName parameter.
597  *	- NULL if an error occurred or if there are no instances associated to
598  *	the pObjectName passed in.  In the case of an error, the error will be
599  *	logged.
600  */
601 CCIMObjectPathList *
cp_associatorNames_Solaris_SharedFileSystem(CCIMObjectPath * pAssocName,CCIMObjectPath * pObjectName,char * pResultClass,char * pRole,char * pResultRole)602 cp_associatorNames_Solaris_SharedFileSystem(CCIMObjectPath *pAssocName,
603 	CCIMObjectPath *pObjectName, char *pResultClass, char *pRole,
604 	char *pResultRole) {
605 
606 	CCIMInstanceList	*instList;
607 	CCIMObjectPathList	*objPathList;
608 	CCIMException		*ex;
609 	int			err = 0;
610 
611 	if (pObjectName == NULL || pObjectName->mKeyProperties == NULL) {
612 		util_handleError("SOLARIS_SHAREDFS::ASSOCIATOR_NAMES",
613 			CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err);
614 		return ((CCIMObjectPathList *)NULL);
615 	}
616 
617 	instList = cp_associators_Solaris_SharedFileSystem(pAssocName,
618 		pObjectName, pResultClass, pRole, pResultRole);
619 	if (instList == NULL) {
620 		return ((CCIMObjectPathList *)NULL);
621 	}
622 
623 	objPathList = cim_createObjectPathList(instList);
624 	if (objPathList == NULL) {
625 		ex = cim_getLastError();
626 		util_handleError("SOLARIS_SHAREDFS::ASSOCIATOR_NAMES",
627 			CIM_ERR_FAILED, CREATE_OBJECT_LIST_FAILURE, ex, &err);
628 		cim_freeInstanceList(instList);
629 		return ((CCIMObjectPathList *)NULL);
630 	}
631 
632 	cim_freeInstanceList(instList);
633 	return (objPathList);
634 } /* cp_associatorNames_Solaris_SharedFileSystem */
635 
636 /*
637  * Method: cp_references_Solaris_SharedFileSystem
638  *
639  * Description: Returns the Solaris_ShareSharedFileSystem instances that have
640  * the passed in parameter, pObjectName, as one of it's keys.
641  *
642  * Parameters:
643  *	- CCIMObjectPath *pAssocName - An object path containing information
644  *	about the association that the caller is trying to reach.
645  *	- CCIMObjectPath *pObjectName - The object path which contains the
646  *	information on whose associated objects are to be returned.
647  *	- char *pRole - If specified, this is the role of the pObjectName
648  *	object path passed in.  If this is not valid, NULL is returned.
649  *
650  * Returns:
651  *	- A pointer to a list of Solaris_SharedFileSystem instances.
652  *	- NULL if an error occurred or if there are no Solaris_SharedFileSystem
653  *	instances having pObjectName as one of it's keys.
654  */
655 CCIMInstanceList *
cp_references_Solaris_SharedFileSystem(CCIMObjectPath * pAssocName,CCIMObjectPath * pObjectName,char * pRole)656 cp_references_Solaris_SharedFileSystem(CCIMObjectPath *pAssocName,
657 	CCIMObjectPath *pObjectName, char *pRole) {
658 
659 	CCIMInstanceList	*instList;
660 	CCIMObjectPathList	*objPathList;
661 	int			err = 0;
662 
663 	if (pObjectName == NULL || pObjectName->mKeyProperties == NULL) {
664 		util_handleError("SOLARIS_SHAREDFS::REFERENCES",
665 			CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err);
666 		return ((CCIMObjectPathList *)NULL);
667 	}
668 
669 	/*
670 	 * Get everything that is related to the pObjectName passed in.
671 	 */
672 	objPathList = cp_associatorNames_Solaris_SharedFileSystem(pAssocName,
673 		pObjectName, NULL, pRole, NULL);
674 	if (objPathList == NULL) {
675 		return ((CCIMObjectPathList *)NULL);
676 	}
677 
678 	/*
679 	 * Now use the object paths in the object path list and the pObjectName
680 	 * variable to create the association instances.
681 	 */
682 	if ((strcasecmp(pObjectName->mName, SOLARIS_DIR) == 0)) {
683 		/*
684 		 * pObjectName is the SystemElement
685 		 */
686 		instList = create_association_instList(SOLARIS_SHAREDFS,
687 			pObjectName,  SYS_ELEMENT, objPathList, SAME_ELEMENT,
688 			&err);
689 	} else {
690 		/*
691 		 * pObjectName is the SameElement
692 		 */
693 		instList = create_association_instList(SOLARIS_SHAREDFS,
694 			pObjectName, SAME_ELEMENT, objPathList, SYS_ELEMENT,
695 			&err);
696 	}
697 
698 	cim_freeObjectPathList(objPathList);
699 
700 	return (instList);
701 } /* cp_references_Solaris_SharedFileSystem */
702 
703 /*
704  * Method: cp_referenceNames_Solaris_SharedFileSystem
705  *
706  * Description: Returns the object paths of the Solaris_ShareSharedFileSystem
707  * instances that have the passed in parameter, pObjectName, as one of it's
708  * keys.
709  *
710  * Parameters:
711  *	- CCIMObjectPath *pAssocName - An object path containing information
712  *	about the association that the caller is trying to reach.
713  *	- CCIMObjectPath *pObjectName - The object path which contains the
714  *	information on whose associated objects are to be returned.
715  *	- char *pRole - If specified, this is the role of the pObjectName
716  *	object path passed in.  If this is not valid, NULL is returned.
717  *
718  * Returns:
719  *	- A pointer to a list of Solaris_SharedFileSystem object paths.
720  *	- NULL if an error occurred or if there are no Solaris_SharedFileSystem
721  *	instances having pObjectName as one of it's keys.
722  */
723 CCIMObjectPathList *
cp_referenceNames_Solaris_SharedFileSystem(CCIMObjectPath * pAssocName,CCIMObjectPath * pObjectName,char * pRole)724 cp_referenceNames_Solaris_SharedFileSystem(CCIMObjectPath *pAssocName,
725 	CCIMObjectPath *pObjectName, char *pRole) {
726 
727 	CCIMInstanceList	*sharedElemInstList;
728 	CCIMObjectPathList	*sharedElemOPList;
729 	int			err = 0;
730 
731 	if (pObjectName == NULL || pObjectName->mKeyProperties == NULL) {
732 		util_handleError("SOLARIS_SHAREDFS::REFERENCE_NAMES",
733 			CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err);
734 		return ((CCIMObjectPathList *)NULL);
735 	}
736 
737 	sharedElemInstList = cp_references_Solaris_SharedFileSystem(pAssocName,
738 		pObjectName, pRole);
739 	if (sharedElemInstList == NULL) {
740 		return ((CCIMObjectPathList *)NULL);
741 	}
742 
743 	sharedElemOPList = cim_createObjectPathList(sharedElemInstList);
744 
745 	cim_freeInstanceList(sharedElemInstList);
746 
747 	return (sharedElemOPList);
748 } /* cp_referenceNames_Solaris_SharedFileSystem */
749 
750 /*
751  * Property provider methods
752  */
753 
754 /*
755  * Method: cp_getProperty_Solaris_SharedFileSystem
756  *
757  * Description: Retrieves a certain property from the instance of
758  * Solaris_SharedFileSystem on the host that is described by the parameter
759  * pOP.
760  *
761  * Parameters:
762  *	- CCIMObjectPath *pOP - The object path containing all the
763  *	information needed to find the instance in which the property is to
764  *	be returned.
765  *	- cimchar *pPropName - The name of the property to be found.
766  *
767  * Returns:
768  *	- A pointer to the property corresponding to the name passed in with
769  *	pPropName.
770  *	- NULL if an error occurred or if the property doesn't exist.  In the
771  *	case of an error, the error will be logged.
772  */
773 CCIMProperty *
cp_getProperty_Solaris_SharedFileSystem(CCIMObjectPath * pOP,cimchar * pPropName)774 cp_getProperty_Solaris_SharedFileSystem(CCIMObjectPath *pOP, cimchar *pPropName)
775 {
776 	CCIMInstance	*sharedElemInst;
777 	CCIMProperty	*sharedElemProp;
778 	int		err = 0;
779 
780 	if (pOP == NULL) {
781 		util_handleError("SOLARIS_SHAREDFS::GET_PROPERTY",
782 			CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err);
783 		return ((CCIMProperty *)NULL);
784 	}
785 
786 	sharedElemInst = cp_getInstance_Solaris_SharedFileSystem(pOP);
787 	if (sharedElemInst == NULL) {
788 		return ((CCIMProperty *)NULL);
789 	}
790 
791 	sharedElemProp = cim_getProperty(sharedElemInst, pPropName);
792 	cim_freeInstance(sharedElemInst);
793 
794 	return (sharedElemProp);
795 } /* cp_getProperty_Solaris_SharedFileSystem */
796 
797 /*
798  * Method: cp_setProperty_Solaris_SharedFileSystem
799  *
800  * Description: This method is not supported.  It is not supported because in
801  * order to change a Solaris_SharedFileSystem instance the underlying share and
802  * directory must be modified.  Those actions must be done on the appropriate
803  * share and directory objects, not here.
804  *
805  * Parameters:
806  *      - CCIMObjectPath *pOP - Not used.
807  *      - CCIMProperty *pProp - Not used.
808  *
809  * Returns:
810  *      - Always returns cim_false because the method is not supported.
811  */
812 /* ARGSUSED */
813 CIMBool
cp_setProperty_Solaris_SharedFileSystem(CCIMObjectPath * pOP,CCIMProperty * pProp)814 cp_setProperty_Solaris_SharedFileSystem(CCIMObjectPath *pOP,
815 	CCIMProperty *pProp) {
816 
817 	int	err = 0;
818 
819 	util_handleError("SOLARIS_SHAREDFS::SET_PROPERTY",
820 		CIM_ERR_NOT_SUPPORTED, NULL, NULL, &err);
821 
822 	return (cim_false);
823 } /* cp_setProperty_Solaris_SharedFileSystem */
824 
825 /*
826  * Method provider methods
827  */
828 
829 /*
830  * Method: cp_invokeMethod_Solaris_SharedFileSystem
831  *
832  * Description: This method is not supported because the provider doesn't have
833  * any methods.
834  *
835  * Parameters:
836  *      - CCIMObjectPath* op - Not used.
837  *      - cimchar* methodName - Not used.
838  *      - CCIMPropertyList* inParams - Not used.
839  *      - CCIMPropertyList* outParams - Not used.
840  *
841  * Returns:
842  *      - Always returns null because the method is not supported.
843  */
844 /* ARGSUSED */
845 CCIMProperty *
cp_invokeMethod_Solaris_SharedFileSystem(CCIMObjectPath * op,cimchar * methodName,CCIMPropertyList * inParams,CCIMPropertyList * outParams)846 cp_invokeMethod_Solaris_SharedFileSystem(CCIMObjectPath* op,
847 	cimchar* methodName, CCIMPropertyList* inParams,
848 	CCIMPropertyList* outParams) {
849 
850 	return ((CCIMProperty *)NULL);
851 } /* cp_invokeMethod_Solaris_SharedFileSystem */
852 
853 /*
854  * Private methods
855  */
856 
857 /*
858  * Method: get_associated_directory
859  *
860  * Description:
861  * This method will return the Solaris_Directory instance or object path
862  * associated with the Solaris_NFSShare object path passed in.  The returnInst
863  * parameter determines whether an CCIMInstance* or a CCIMObjectPath* is
864  * returned.
865  *
866  * Parameters:
867  *	- CCIMObjectPath *nfsShareOP - Solaris_NFSShare object path which to
868  *	find the associated Solaris_Directory instance.
869  *	- boolean_t returnInst - The value which determines whether to return
870  *	a Solaris_Directory instance or an object path.
871  *
872  * Returns:
873  *	- If returnInst == B_TRUE, a pointer to a Solaris_Directory instance.
874  *	If returnInst == B_FALSE, a pointer to a Solaris_Directory object path.
875  *	- NULL is returned if an error occurred or if there are no
876  *	Solaris_Directory instances associated to the Solaris_NFSShare object
877  *	path passed in.
878  */
879 static inst_or_objPath
get_associated_directory(CCIMObjectPath * nfsShareOP,boolean_t returnInst)880 get_associated_directory(CCIMObjectPath *nfsShareOP, boolean_t returnInst) {
881 	CCIMObjectPath	*dirOP;
882 	CCIMInstance	*dirInst;
883 	CCIMException	*ex;
884 	CCIMObjectPath	*propOP;
885 	CIMType		propType;
886 	CIMBool		propIsKey;
887 	cimchar		*propName;
888 	cimchar		*propValue;
889 	char		*name;
890 	int		err = 0;
891 
892 	/*
893 	 * Retrieve the Name key property value from the Solaris_NFSShare
894 	 * object path passed in with nfsShareOP.
895 	 */
896 	name = util_getKeyValue(nfsShareOP->mKeyProperties, string, NAME, &err);
897 	if (name == NULL || err != 0) {
898 		util_handleError("SOLARIS_SHAREDFS::GET_ASSOC_DIR",
899 			CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err);
900 		return (NULL);
901 	}
902 
903 	dirInst = cim_createInstance(SOLARIS_DIR);
904 	if (dirInst == NULL) {
905 		ex = cim_getLastError();
906 		util_handleError("SOLARIS_SHAREDFS::GET_ASSOC_DIR",
907 			CIM_ERR_FAILED, CREATE_INSTANCE_FAILURE, ex, &err);
908 		return (NULL);
909 	}
910 
911 	/*
912 	 * Create Name property and add it to the Solaris_Directory instance
913 	 */
914 	propName = NAME;
915 	propType = string;
916 	propValue = name;
917 	propOP = NULL;
918 	propIsKey = cim_true;
919 	if (add_property_to_instance(propName, propType, propValue,
920 		propOP, propIsKey, dirInst) == cim_false) {
921 
922 		cim_freeInstance(dirInst);
923 		return (NULL);
924 	}
925 
926 	/*
927 	 * Create the Solaris_Directory object path.
928 	 */
929 	dirOP = cim_createObjectPath(dirInst);
930 	cim_freeInstance(dirInst);
931 	if (dirOP == NULL) {
932 		ex = cim_getLastError();
933 		util_handleError("SOLARIS_SHAREDFS::GET_ASSOC_DIR",
934 			CIM_ERR_FAILED, CREATE_OBJECT_PATH_FAILURE, ex, &err);
935 		return (NULL);
936 	}
937 
938 	/*
939 	 * Must use cimom_getInstance to determine if the directory exists.
940 	 */
941 	dirInst = cimom_getInstance(dirOP, cim_false, cim_false, cim_false,
942 		cim_false, NULL, 0);
943 	cim_freeObjectPath(dirOP);
944 	/*
945 	 * A NULL return value means error, an empty list does not.
946 	 */
947 	if (dirInst == NULL) {
948 		ex = cim_getLastError();
949 		util_handleError("SOLARIS_SHAREDFS::GET_ASSOC_DIR",
950 			CIM_ERR_FAILED, CIMOM_GET_INST_FAILURE, ex, &err);
951 		return (NULL);
952 	}
953 
954 	if (dirInst->mProperties == NULL) {
955 		cim_freeInstance(dirInst);
956 		return (NULL);
957 	}
958 
959 	/*
960 	 * Work around for cimom bug 4649100.
961 	 */
962 	if (!set_dir_keyProperties_to_true(dirInst)) {
963 		cim_freeInstance(dirInst);
964 		return (NULL);
965 	}
966 
967 	if (returnInst == B_TRUE)
968 		return (dirInst);
969 
970 	/*
971 	 * Create the correct Solaris_Directory object path.
972 	 */
973 	dirOP = cim_createObjectPath(dirInst);
974 	if (dirOP == NULL) {
975 		ex = cim_getLastError();
976 		util_handleError("SOLARIS_SHAREDFS::GET_ASSOC_DIR",
977 			CIM_ERR_FAILED, CREATE_OBJECT_PATH_FAILURE, ex, &err);
978 		cim_freeInstance(dirInst);
979 		return (NULL);
980 	}
981 
982 	cim_freeInstance(dirInst);
983 	return (dirOP);
984 } /* get_associated_directory */
985 
986 /*
987  * Method: get_associated_instances
988  *
989  * Description:
990  * This method will get the instances associated to the object passed in.
991  * The result role is the role the Instances to be returned in the instance
992  * list are to play regarding the Solaris_SharedFileSystem association.
993  *
994  * Parameters:
995  *	- CCIMObjectPath *pOP - The object path of which to get the associated
996  *	instances.
997  *	- boolean_t isSystemElement - Whether or not the pObjectName is the
998  *	SystemElement.  If isSystemElement == B_FALSE, pObjectName is the
999  *	SameElement.
1000  * Returns:
1001  *	- A pointer to a list of Solaris_NFSShare or Solaris_Directory
1002  *	instances depending on the parameters passed in.
1003  *	- NULL if an error occurred or if there are no instances associated
1004  *	with the object path passed in.
1005  */
1006 
1007 static CCIMInstanceList *
get_associated_instances(CCIMObjectPath * pOP,boolean_t isSystemElement)1008 get_associated_instances(CCIMObjectPath *pOP, boolean_t isSystemElement) {
1009 	CCIMInstanceList	*returnInstList;
1010 	CCIMInstance		*assocInst;
1011 	CCIMException		*ex;
1012 	int			err = 0;
1013 
1014 	returnInstList = cim_createInstanceList();
1015 	if (returnInstList == NULL) {
1016 		ex = cim_getLastError();
1017 		util_handleError("SOLARIS_SHAREDFS::GET_ASSOC_INST",
1018 			CIM_ERR_FAILED, CREATE_INSTANCE_LIST_FAILURE, ex, &err);
1019 		return ((CCIMInstanceList *)NULL);
1020 	}
1021 
1022 	/*
1023 	 * Determine if we are supposed to return the SameElement or
1024 	 * SystemElement instances by checking isSystemElement.
1025 	 */
1026 	if (isSystemElement == B_TRUE) {
1027 		/*
1028 		 * pOP is a Solaris_Directory object path so find the associated
1029 		 * Solaris_NFSShare instances.  There should only be one.
1030 		 */
1031 		assocInst = get_associated_share(pOP);
1032 	} else {
1033 		/*
1034 		 * pOP is a Solaris_NFSShare object path so find the associated
1035 		 * Solaris_Directory instances.  There should only be one.
1036 		 */
1037 		assocInst = get_associated_directory(pOP, B_TRUE);
1038 	}
1039 
1040 	if (assocInst == NULL) {
1041 		cim_freeInstanceList(returnInstList);
1042 		return ((CCIMInstanceList *)NULL);
1043 	}
1044 	/*
1045 	 * Add the instance to the instance list.
1046 	 */
1047 	returnInstList = cim_addInstance(returnInstList, assocInst);
1048 	if (returnInstList == NULL) {
1049 		ex = cim_getLastError();
1050 		util_handleError("SOLARIS_SHAREDFS::GET_ASSOC_INST",
1051 			CIM_ERR_FAILED, ADD_INSTANCE_FAILURE, ex, &err);
1052 		cim_freeInstance(assocInst);
1053 		return ((CCIMInstanceList *)NULL);
1054 	}
1055 
1056 	return (returnInstList);
1057 } /* get_associated_instances */
1058 
1059 /*
1060  * Method: get_associated_share
1061  *
1062  * Description:
1063  * This method will return the Solaris_NFSShare instance or reference property
1064  * associated with the Solaris_Directory object path passed in.  The returnInst
1065  * parameter determines whether an CCIMInstance or a CCIMProperty is returned.
1066  *
1067  * Parameters:
1068  *      - CCIMObjectPath *nfsShareOP - Solaris_Directory object path which to
1069  *      find the associated Solaris_NFSShare instance.
1070  *      - boolean_t returnInst - The value which determines whether to return
1071  *      a Solaris_NFSShare instance or a reference property.
1072  *
1073  * Returns:
1074  *      - If returnInst == B_TRUE, a pointer to a Solaris_NFSShare instance.
1075  *      If returnInst == B_FALSE, a pointer to a Solaris_NFSShare reference
1076  *      property.
1077  *      - NULL is returned if an error occurred or if there are no
1078  *      Solaris_NFSShare instances associated to the Solaris_Directory object
1079  *      path passed in.
1080  */
1081 static CCIMInstance *
get_associated_share(CCIMObjectPath * dirOP)1082 get_associated_share(CCIMObjectPath *dirOP) {
1083 	CCIMObjectPath	*nfsShareOP;
1084 	CCIMInstance	*nfsShareInst;
1085 	CCIMException	*ex;
1086 	CCIMObjectPath	*propOP;
1087 	CIMType		propType;
1088 	CIMBool		propIsKey;
1089 	cimchar		*propName;
1090 	cimchar		*propValue;
1091 	char		*name;
1092 	int		err = 0;
1093 
1094 	/*
1095 	 * Retrieve the Name key property value from the Solaris_Directory
1096 	 * object path passed in with dirOP.
1097 	 */
1098 	name = util_getKeyValue(dirOP->mKeyProperties, string, NAME, &err);
1099 	if (name == NULL || err != 0) {
1100 		util_handleError("SOLARIS_SHAREDFS::GET_ASSOC_SHARE",
1101 			CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err);
1102 		return ((CCIMInstance *)NULL);
1103 	}
1104 
1105 	nfsShareInst = cim_createInstance(SOLARIS_NFSSHARE);
1106 	if (nfsShareInst == NULL) {
1107 		ex = cim_getLastError();
1108 		util_handleError("SOLARIS_SHAREDFS::GET_ASSOC_SHARE",
1109 			CIM_ERR_FAILED, CREATE_INSTANCE_FAILURE, ex, &err);
1110 		return ((CCIMInstance *)NULL);
1111 	}
1112 
1113 	propName = NAME;
1114 	propType = string;
1115 	propValue = name;
1116 	propOP = NULL;
1117 	propIsKey = cim_true;
1118 	if (add_property_to_instance(propName, propType, propValue,
1119 		propOP, propIsKey, nfsShareInst) == cim_false) {
1120 
1121 		cim_freeInstance(nfsShareInst);
1122 		return ((CCIMInstance *)NULL);
1123 	}
1124 
1125 	nfsShareOP = cim_createObjectPath(nfsShareInst);
1126 	if (nfsShareOP == NULL) {
1127 		ex = cim_getLastError();
1128 		util_handleError("SOLARIS_SHAREDFS::GET_ASSOC_SHARE",
1129 			CIM_ERR_FAILED, CREATE_OBJECT_PATH_FAILURE, ex, &err);
1130 		cim_freeInstance(nfsShareInst);
1131 		return ((CCIMInstance *)NULL);
1132 	}
1133 
1134 	cim_freeInstance(nfsShareInst);
1135 
1136 	/*
1137 	 * Use cimom_getInstance to determine if the share exists.
1138 	 */
1139 	nfsShareInst = cimom_getInstance(nfsShareOP, cim_false, cim_false,
1140 		cim_false, cim_false, NULL, 0);
1141 
1142 	/*
1143 	 * A NULL return value indicates an error, an empty list does not.
1144 	 */
1145 	if (nfsShareInst == NULL) {
1146 		ex = cim_getLastError();
1147 		util_handleError("SOLARIS_SHAREDFS::GET_ASSOC_SHARE",
1148 			CIM_ERR_FAILED, CIMOM_GET_INST_FAILURE, ex, &err);
1149 		cim_freeObjectPath(nfsShareOP);
1150 		return ((CCIMInstance *)NULL);
1151 	}
1152 
1153 	cim_freeObjectPath(nfsShareOP);
1154 
1155 	if (nfsShareInst->mProperties == NULL) {
1156 		return ((CCIMInstance *)NULL);
1157 	}
1158 
1159 	return (nfsShareInst);
1160 
1161 } /* get_associated_share */
1162