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_NFSShareEntry.h" 30#include "nfs_keys.h" 31#include "nfs_providers_msgstrings.h" 32#include "nfs_provider_names.h" 33#include "messageStrings.h" 34#include "util.h" 35#include "common_functions.h" 36#include "createprop_methods.h" 37#include "libfsmgt.h" 38 39#define COMMAND "Command" 40/* 41 * Private method declarations 42 */ 43static CCIMInstanceList* create_shareEntry_inst_and_update_list( 44 CCIMObjectPath *nfsShare, CCIMInstanceList *shareEntInstList); 45static CCIMInstanceList* get_associated_nfsShare_instList( 46 CCIMObjectPath *sharePersistOP); 47static CCIMInstanceList* get_associated_sharePersist_instList( 48 CCIMObjectPath *nfsShareOP); 49static CCIMObjectPathList* get_associated_sharePersist_OPList( 50 CCIMObjectPath *nfsShareOP, int *errp); 51static CCIMObjectPath* get_Solaris_NFSShare_OP(char *nameKey); 52static CCIMInstance* get_Solaris_PersistentShare_Inst(char *path, 53 char *command); 54 55/* 56 * Public methods 57 */ 58 59/* 60 * Instance provider methods 61 */ 62 63/* 64 * Method: cp_createInstance_Solaris_NFSShareEntry 65 * 66 * Description: This method is not supported. It is not supported because in 67 * order for a Solaris_NFSShareEntry association to exist a corresponding 68 * Solaris_NFSShare and Solaris_PersistentShare must exist. 69 * 70 * Parameters: 71 * - CCIMObjectPath *hostedShareOP - An object path containing the name of 72 * the class of which to create an instance of. 73 * - CCIMInstance *pInst - Not used. 74 * 75 * Return Value: 76 * - Always returns NULL because the method is not supported. 77 */ 78/* ARGSUSED */ 79CCIMObjectPath * 80cp_createInstance_Solaris_NFSShareEntry(CCIMObjectPath *pOP, 81 CCIMInstance *pInst) { 82 83 int err = 0; 84 85 util_handleError("SOLARIS_NFSSHAREENT::CREATE_INSTANCE", 86 CIM_ERR_NOT_SUPPORTED, NULL, NULL, &err); 87 88 return ((CCIMObjectPath *)NULL); 89} /* cp_createInstance_Solaris_NFSShareEntry */ 90 91/* 92 * Method: cp_deleteInstance_Solaris_NFSShareEntry 93 * 94 * Description: This method is not supported. It is not supported because in 95 * order for it to be actually deleted the corresponding Solaris_NFSShare or 96 * Solaris_PersistentShare would need to be deleted. That action is not 97 * for this provider. 98 * 99 * Parameters: 100 * - CCIMObjectPath *pOP - An object path containing the 101 * information about the class of which to delete the instance of. 102 * 103 * Return Value: 104 * - Always returns cim_false because the method is not supported. 105 */ 106/* ARGSUSED */ 107CIMBool 108cp_deleteInstance_Solaris_NFSShareEntry(CCIMObjectPath *pOP) { 109 int err = 0; 110 111 util_handleError("SOLARIS_NFSSHAREENT::DELETE_INSTANCE", 112 CIM_ERR_NOT_SUPPORTED, NULL, NULL, &err); 113 114 return (cim_false); 115} /* cp_deleteInstance_Solaris_NFSShareEntry */ 116 117/* 118 * Method: cp_enumInstances_Solaris_NFSShareEntry 119 * 120 * Description: Enumerates the instances of Solaris_NFSShareEntry on a host. 121 * An instance of Solaris_NFSShareEntry is an association that links a share to 122 * it's persistent share entry. 123 * 124 * Parameters: 125 * - CCIMObjectPath *pOP - An object path containing the name of 126 * the class of which to enumerate the instances of. 127 * 128 * Return Value: 129 * - A pointer to a list of Solaris_NFSShareEntry instances. 130 * - NULL if an error occurred or if there are no instances of 131 * Solaris_NFSShareEntry on the host. In the case of an error, the error 132 * will be logged. 133 */ 134 135CCIMInstanceList * 136cp_enumInstances_Solaris_NFSShareEntry(CCIMObjectPath *pOP) { 137 CCIMInstanceList *shareEntryInstList; 138 CCIMObjectPathList *nfsShareOPList; 139 CCIMObjectPathList *currentShareOP; 140 CCIMObjectPath *nfsShareOP; 141 CCIMException *ex; 142 int err = 0; 143 144 if (pOP == NULL) { 145 util_handleError("SOLARIS_NFSSHAREENT::ENUM_INSTANCES", 146 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err); 147 return ((CCIMInstanceList *)NULL); 148 } 149 150 nfsShareOP = cim_createEmptyObjectPath(SOLARIS_NFSSHARE); 151 if (nfsShareOP == NULL) { 152 ex = cim_getLastError(); 153 util_handleError("SOLARIS_NFSSHAREENT::ENUM_INSTANCES", 154 CIM_ERR_FAILED, CREATE_EMPTY_OBJPATH_FAILURE, ex, 155 &err); 156 return ((CCIMInstanceList *)NULL); 157 } 158 159 nfsShareOPList = cimom_enumerateInstanceNames(nfsShareOP, cim_false); 160 161 /* 162 * A NULL return value means error, an empty list does not. 163 */ 164 if (nfsShareOPList == NULL) { 165 ex = cim_getLastError(); 166 util_handleError("SOLARIS_NFSSHAREENT::ENUM_INSTANCES", 167 CIM_ERR_FAILED, CIMOM_ENUM_INSTNAMES_FAILURE, ex, &err); 168 cim_freeObjectPath(nfsShareOP); 169 return ((CCIMInstanceList *)NULL); 170 } 171 172 cim_freeObjectPath(nfsShareOP); 173 174 if (nfsShareOPList->mDataObject == NULL) { 175 cim_freeObjectPathList(nfsShareOPList); 176 return ((CCIMInstanceList *)NULL); 177 } 178 179 shareEntryInstList = cim_createInstanceList(); 180 if (shareEntryInstList == NULL) { 181 ex = cim_getLastError(); 182 util_handleError("SOLARIS_NFSSHAREENT::ENUM_INSTANCES", 183 CIM_ERR_FAILED, CREATE_INSTANCE_LIST_FAILURE, ex, &err); 184 cim_freeObjectPathList(nfsShareOPList); 185 return ((CCIMInstanceList *)NULL); 186 } 187 188 for (currentShareOP = nfsShareOPList; currentShareOP != NULL; 189 currentShareOP = currentShareOP->mNext) { 190 191 shareEntryInstList = create_shareEntry_inst_and_update_list( 192 currentShareOP->mDataObject, shareEntryInstList); 193 if (shareEntryInstList == NULL) { 194 cim_freeObjectPathList(nfsShareOPList); 195 return ((CCIMInstanceList *)NULL); 196 } 197 } 198 199 cim_freeObjectPathList(nfsShareOPList); 200 return (shareEntryInstList); 201} /* cp_enumInstances_Solaris_NFSShareEntry */ 202 203/* 204 * Method: cp_enumInstanceNames_Solaris_NFSShareEntry 205 * 206 * Description: Enumerates all of the instances of Solaris_NFSShareEntry on the 207 * host. 208 * 209 * Parameters: 210 * - CCIMObjectPath* pOP - An object path containing the name of the 211 * class of which to enumerate instances of. 212 * 213 * Returns: 214 * - A pointer to a list of Solaris_NFSShareEntry object paths. 215 * - NULL if an error occurred or if there are no NFS mounts on the host. 216 * In the case of an error, the error will be logged. 217 */ 218CCIMObjectPathList * 219cp_enumInstanceNames_Solaris_NFSShareEntry(CCIMObjectPath *pOP) { 220 CCIMInstanceList *instList; 221 CCIMObjectPathList *OPList; 222 int err = 0; 223 224 if (pOP == NULL) { 225 util_handleError("SOLARIS_NFSSHAREENT::ENUM_INSTANCENAMES", 226 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err); 227 return ((CCIMObjectPathList *)NULL); 228 } 229 230 instList = cp_enumInstances_Solaris_NFSShareEntry(pOP); 231 if (instList == NULL) { 232 /* 233 * Either an error occurred or we don't have any 234 * Solaris_NFSShareEntry instances on the host. 235 */ 236 return ((CCIMObjectPathList *)NULL); 237 } 238 239 OPList = cim_createObjectPathList(instList); 240 241 cim_freeInstanceList(instList); 242 return (OPList); 243} /* cp_enumInstanceNames_Solaris_NFSShareEntry */ 244 245/* 246 * Method: cp_execQuery_Solaris_NFSShareEntry 247 * 248 * Description: Queries the Solaris_NFSShareEntry instances on the host to find 249 * those that meet the search criteria. 250 * 251 * Parameters: 252 * - CCIMObjectPath *pOP - An object path containing the name of 253 * the class of which to query. 254 * - char *selectClause - Not used. 255 * - char *nonJoinExp - Not used. 256 * - char *queryExp - Not used. 257 * - char *queryLang - Not used. 258 * 259 * Returns: 260 * - A pointer to a list of Solaris_NFSShareEntry instances that match the 261 * criteria. 262 * - NULL if an error occurred or if there are no Solaris_NFSShareEntry 263 * instances that match the criteria. In the case of an error, the error 264 * will be logged. 265 * 266 * NOTE: Currently, there is no WQL parser for the C providers. As a result, 267 * what is returned to the CIMOM is a list of instances with 268 * a NULL value at the beginning of the list. This NULL value indicates 269 * to the CIMOM that it must do the filtering for the client. 270 */ 271/* ARGSUSED */ 272CCIMInstanceList * 273cp_execQuery_Solaris_NFSShareEntry(CCIMObjectPath *pOP, char *selectClause, 274 char *nonJoinExp, char *queryExp, char *queryLang) { 275 276 CCIMInstance *emptyInst; 277 CCIMInstanceList *shareEntryInstList; 278 CCIMException *ex; 279 int err = 0; 280 281 if (pOP == NULL) { 282 util_handleError("SOLARIS_NFSSHAREENT::EXEC_QUERY", 283 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err); 284 return ((CCIMInstanceList *)NULL); 285 } 286 287 shareEntryInstList = cp_enumInstances_Solaris_NFSShareEntry(pOP); 288 if (shareEntryInstList == NULL) { 289 return ((CCIMInstanceList *)NULL); 290 } 291 292 emptyInst = cim_createInstance(""); 293 if (emptyInst == NULL) { 294 ex = cim_getLastError(); 295 util_handleError("SOLARIS_NFSSHAREENT::EXEC_QUERY", 296 CIM_ERR_FAILED, CREATE_INSTANCE_FAILURE, ex, &err); 297 cim_freeInstanceList(shareEntryInstList); 298 return ((CCIMInstanceList *)NULL); 299 } 300 301 shareEntryInstList = cim_prependInstance(shareEntryInstList, 302 emptyInst); 303 if (shareEntryInstList == NULL) { 304 ex = cim_getLastError(); 305 util_handleError("SOLARIS_NFSSHAREENT::EXEC_QUERY", 306 CIM_ERR_FAILED, PREPEND_INSTANCE_FAILURE, ex, &err); 307 cim_freeInstance(emptyInst); 308 return ((CCIMInstanceList *)NULL); 309 } 310 311 return (shareEntryInstList); 312} /* cp_execQuery_Solaris_NFSShareEntry */ 313 314/* 315 * Method: cp_getInstance_Solaris_NFSShareEntry 316 * 317 * Description: Gets the instance corresponding to the Solaris_NFSShareEntry 318 * object path passed in. 319 * 320 * Parameters: 321 * - CCIMObjectPath* pOP - An object path containing all the keys of 322 * the instance that is supposed to be returned. 323 * 324 * Returns: 325 * - A pointer to the Solaris_NFSShareEntry instance corresponding to the 326 * object path parameter. 327 * - NULL if an error occurred or if the instance doesn't exist. In the 328 * case of an error, the error will be logged. 329 */ 330CCIMInstance * 331cp_getInstance_Solaris_NFSShareEntry(CCIMObjectPath *pOP) { 332 CCIMInstanceList *instList; 333 CCIMInstance *inst; 334 CCIMObjectPath *setOP; 335 CCIMObjectPath *elemOP; 336 CCIMPropertyList *shareEntPropList; 337 int err = 0; 338 339 if (pOP == NULL || pOP->mKeyProperties == NULL) { 340 util_handleError("SOLARIS_NFSSHAREENT::GET_INSTANCE", 341 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err); 342 return ((CCIMInstance *)NULL); 343 } 344 345 /* 346 * Determine if the key values are populated. 347 */ 348 shareEntPropList = pOP->mKeyProperties; 349 setOP = util_getKeyValue(shareEntPropList, shareEntProps[SETTING].type, 350 shareEntProps[SETTING].name, &err); 351 elemOP = util_getKeyValue(shareEntPropList, shareEntProps[ELEMENT].type, 352 shareEntProps[ELEMENT].name, &err); 353 354 if (setOP == NULL || elemOP == NULL || 355 setOP->mKeyProperties == NULL || 356 elemOP->mKeyProperties == NULL) { 357 358 util_handleError("SOLARIS_NFSSHAREENT::GET_INSTANCE", 359 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err); 360 return ((CCIMInstance *)NULL); 361 } 362 363 instList = cp_enumInstances_Solaris_NFSShareEntry(pOP); 364 if (instList == NULL) { 365 /* 366 * Either an error occurred or we simply don't have any 367 * instances of Solaris_NFSShareEntry on the system. In the 368 * case that an error occurred, it will be handled in 369 * cp_enumInstances_Solaris_NFSShareEntry. 370 */ 371 return ((CCIMInstance *)NULL); 372 } 373 374 inst = cim_getInstance(instList, pOP); 375 376 cim_freeInstanceList(instList); 377 return (inst); 378} /* cp_getInstance_Solaris_NFSShareEntry */ 379 380/* 381 * Method: cp_setInstance_Solaris_NFSShareEntry 382 * 383 * Description: This method is not supported. This is not allowed because in 384 * order to change the properties a Solaris_NFSShareEntry on the host, the 385 * Solaris_NFSShare and Solaris_PersistentShare must most likely be changed. 386 * In order to change the associated objects, they need to be changed in those 387 * providers and not this one. 388 * 389 * Parameters: 390 * - CCIMObjectPath *pOP - An object path containing the name of the class 391 * of which to set the instance. 392 * - CCIMInstance *pInst - Not used. 393 * 394 * Returns: 395 * - cim_false is returned every time since the method is not supported. 396 */ 397/* ARGSUSED */ 398CIMBool 399cp_setInstance_Solaris_NFSShareEntry(CCIMObjectPath *pOP, CCIMInstance *pInst) { 400 int err = 0; 401 402 util_handleError("SOLARIS_NFSSHAREENT::SET_INSTANCE", 403 CIM_ERR_NOT_SUPPORTED, NULL, NULL, &err); 404 405 return (cim_false); 406} /* cp_setInstance_Solaris_NFSShareEntry */ 407 408/* 409 * Method: cp_setInstanceWithList_Solaris_NFSShareEntry 410 * 411 * Description: This method is not supported. This is not allowed because in 412 * order to change the properties a Solaris_NFSShareEntry on the host, the 413 * Solaris_NFSShare and Solaris_PersistentShare must most likely be changed. 414 * In order to change the associated objects, they need to be changed in those 415 * providers and not this one. 416 * 417 * Parameters: 418 * - CCIMObjectPath *pOP - An object path containing the name of the class 419 * of which to set the instance. 420 * - CCIMInstance *pInst - Not used. 421 * 422 * Returns: 423 * - cim_false is returned every time since the method is not supported. 424 */ 425/* ARGSUSED */ 426CIMBool 427cp_setInstanceWithList_Solaris_NFSShareEntry(CCIMObjectPath *pOP, 428 CCIMInstance *pInst, char **props, int num_props) { 429 430 int err = 0; 431 432 util_handleError("SOLARIS_NFSSHAREENT::SET_INSTANCE", 433 CIM_ERR_NOT_SUPPORTED, NULL, NULL, &err); 434 435 return (cim_false); 436} /* cp_setInstanceWithList_Solaris_NFSShareEntry */ 437 438/* 439 * Association provider methods 440 */ 441 442/* 443 * Method: cp_associators_Solaris_NFSShareEntry 444 * 445 * Description: Returns the instances associated, via the Solaris_NFSShareEntry 446 * association, to the pObjectName parameter. 447 * 448 * Parameters: 449 * - CCIMObjectPath *pAssocName - An object path containing the name of 450 * the association that the caller is trying to reach. 451 * - CCIMObjectPath *pObjectName - The object path containing information 452 * (Class Name, Key Properties) about the object whose associated objects 453 * are to be returned. 454 * - char *pResultClass - If specified, only return instances that are of 455 * this class type. 456 * - char *pRole - If specified, this is the role of the pObjectName 457 * object path passed in. If this is not valid, NULL is returned. 458 * - char *pResultRole - If specified, only return instances that are 459 * playing this role in the association. 460 * 461 * Returns: 462 * - A pointer to a list of Solaris_PersistentShare (if pRole == 463 * Element && pObjectName is a Solaris_NFSShare object path) or 464 * Solaris_NFSShare (if pRole == Setting && pObjectName is a 465 * Solaris_PersistentShare object path) instances which are associated to 466 * the pObjectName parameter. 467 * - NULL if an error occurred or if there are no instances associated to 468 * the pObjectName passed in. In the case of an error, the error will be 469 * logged. 470 */ 471/* ARGSUSED */ 472CCIMInstanceList * 473cp_associators_Solaris_NFSShareEntry(CCIMObjectPath *pAssocName, 474 CCIMObjectPath *pObjectName, char *pResultClass, char *pRole, 475 char *pResultRole) { 476 477 CCIMInstanceList *returnInstList; 478 int err = 0; 479 480 if (pObjectName == NULL || pObjectName->mKeyProperties == NULL) { 481 util_handleError("SOLARIS_NFSSHAREENT::ASSOCIATORS", 482 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err); 483 return ((CCIMInstanceList *)NULL); 484 } 485 486 /* 487 * Determine whether pObjectname is the Element or the Setting of the 488 * association. Element = Solaris_NFSShare, 489 * Setting = Solaris_PersistentShare. 490 */ 491 if (strcasecmp(pObjectName->mName, SOLARIS_NFSSHARE) == 0) { 492 if (pRole != NULL && (strcasecmp(pRole, 493 shareEntProps[ELEMENT].name) != 0)) { 494 495 util_handleError("SOLARIS_NFSSHAREENT::ASSOCIATORS", 496 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err); 497 return ((CCIMInstanceList *)NULL); 498 } 499 500 returnInstList = get_associated_sharePersist_instList( 501 pObjectName); 502 } else if (strcasecmp(pObjectName->mName, SOLARIS_PERSISTSHARE) == 0) { 503 if (pRole != NULL && (strcasecmp(pRole, 504 shareEntProps[SETTING].name) != 0)) { 505 506 util_handleError("SOLARIS_NFSSHAREENT::ASSOCIATORS", 507 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err); 508 return ((CCIMInstanceList *)NULL); 509 } 510 511 returnInstList = get_associated_nfsShare_instList(pObjectName); 512 } else { 513 util_handleError("SOLARIS_NFSSHAREENT::ASSOCIATORS", 514 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err); 515 return ((CCIMInstanceList *)NULL); 516 } 517 518 return (returnInstList); 519} /* cp_associators_Solaris_NFSShareEntry */ 520 521/* 522 * Method: cp_associatorNames_Solaris_NFSShareEntry 523 * 524 * Description: Returns the object paths of the instances on the other side of 525 * the association which are associated via the Solaris_NFSShareEntry 526 * association and having the passed in parameter, pObjectName, as the 527 * opposite key. 528 * 529 * Parameters: 530 * - CCIMObjectPath *pAssocName - An object path containing information 531 * about the association that the caller is trying to reach. 532 * - CCIMObjectPath *pObjectName - The object path which contains the 533 * information on whose associated objects are to be returned. 534 * - char *pResultClass - If specified, only return instances that are of 535 * this class type. 536 * - char *pRole - If specified, this is the role of the pObjectName 537 * object path passed in. If this is not valid, NULL is returned. 538 * - char *pResultRole - If specified, only return instances that are 539 * playing this role in the association. 540 * 541 * Returns: 542 * - A pointer to a list of Solaris_PersistentShare (if pRole == 543 * Element && pObjectName is a Solaris_NFSShare object path) or 544 * Solaris_NFSShare (if pRole == Setting && pObjectName is a 545 * Solaris_PersistentShare object path) object paths which are associated 546 * to the pObjectName parameter. 547 * - NULL if an error occurred or if there are no instances associated to 548 * the pObjectName passed in. In the case of an error, the error will be 549 * logged. 550 */ 551CCIMObjectPathList * 552cp_associatorNames_Solaris_NFSShareEntry(CCIMObjectPath *pAssocName, 553 CCIMObjectPath *pObjectName, char *pResultClass, char *pRole, 554 char *pResultRole) { 555 556 CCIMInstanceList *instList; 557 CCIMObjectPathList *objPathList; 558 int err = 0; 559 560 if (pObjectName == NULL || pObjectName->mKeyProperties == NULL) { 561 util_handleError("SOLARIS_NFSSHAREENT::ASSOCIATOR_NAMES", 562 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err); 563 return ((CCIMObjectPathList *)NULL); 564 } 565 566 instList = cp_associators_Solaris_NFSShareEntry(pAssocName, pObjectName, 567 pResultClass, pRole, pResultRole); 568 if (instList == NULL) { 569 return ((CCIMObjectPathList *)NULL); 570 } 571 572 objPathList = cim_createObjectPathList(instList); 573 574 cim_freeInstanceList(instList); 575 576 return (objPathList); 577} /* cp_associatorNames_Solaris_NFSShareEntry */ 578 579/* 580 * Method: cp_references_Solaris_NFSShareEntry 581 * 582 * Description: Returns the Solaris_NFSShareEntry instances that have the 583 * passed in parameter, pObjectName, as one of it's keys. 584 * 585 * Parameters: 586 * - CCIMObjectPath *pAssocName - An object path containing information 587 * about the association that the caller is trying to reach. 588 * - CCIMObjectPath *pObjectName - The object path which contains the 589 * information on whose associated objects are to be returned. 590 * - char *pRole - If specified, this is the role of the pObjectName 591 * object path passed in. If this is not valid, NULL is returned. 592 * 593 * Returns: 594 * - A pointer to a list of Solaris_NFSShareEntry instances. 595 * - NULL if an error occurred or if there are no Solaris_NFSShareEntry 596 * instances having pObjectName as one of it's keys. 597 */ 598CCIMInstanceList * 599cp_references_Solaris_NFSShareEntry(CCIMObjectPath *pAssocName, 600 CCIMObjectPath *pObjectName, char *pRole) { 601 602 CCIMInstanceList *instList; 603 CCIMObjectPathList *objPathList; 604 int err = 0; 605 606 if (pObjectName == NULL || pObjectName->mKeyProperties == NULL) { 607 util_handleError("SOLARIS_NFSSHAREENT::REFERENCES", 608 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err); 609 return ((CCIMInstanceList *)NULL); 610 } 611 612 /* 613 * Get everything that is related to the pObjectName passed in. 614 */ 615 objPathList = cp_associatorNames_Solaris_NFSShareEntry( 616 pAssocName, pObjectName, NULL, pRole, NULL); 617 if (objPathList == NULL) { 618 return ((CCIMInstanceList *)NULL); 619 } 620 621 /* 622 * Determine whether pObjectname is the Element or the Setting of the 623 * association. Element = Solaris_NFSShare, 624 * Setting = Solaris_PersistentShare. 625 */ 626 627 if (strcasecmp(pObjectName->mName, SOLARIS_NFSSHARE) == 0) { 628 instList = create_association_instList(SOLARIS_NFSSHAREENT, 629 pObjectName, shareEntProps[ELEMENT].name, objPathList, 630 shareEntProps[SETTING].name, &err); 631 } else { 632 instList = create_association_instList(SOLARIS_NFSSHAREENT, 633 pObjectName, shareEntProps[SETTING].name, objPathList, 634 shareEntProps[ELEMENT].name, &err); 635 } 636 cim_freeObjectPathList(objPathList); 637 638 return (instList); 639} /* cp_references_Solaris_NFSShareEntry */ 640 641/* 642 * Method: cp_referenceNames_Solaris_NFSShareEntry 643 * 644 * Description: Returns the Solaris_NFSShareEntry object paths of the instances 645 * that have the passed in parameter, pObjectName, as one of it's keys. 646 * 647 * Parameters: 648 * - CCIMObjectPath *pAssocName - An object path containing information 649 * about the association that the caller is trying to reach. 650 * - CCIMObjectPath *pObjectName - The object path which contains the 651 * information on whose associated objects are to be returned. 652 * - char *pRole - If specified, this is the role of the pObjectName 653 * object path passed in. If this is not valid, NULL is returned. 654 * 655 * Returns: 656 * - A pointer to a list of Solaris_NFSShareEntry object paths. 657 * - NULL if an error occurred or if there are no Solaris_NFSShareEntry 658 * instances having pObjectName as one of it's keys. 659 */ 660CCIMObjectPathList * 661cp_referenceNames_Solaris_NFSShareEntry(CCIMObjectPath *pAssocName, 662 CCIMObjectPath *pObjectName, char *pRole) { 663 664 CCIMInstanceList *shareEntryInstList; 665 CCIMObjectPathList *shareEntryOPList; 666 int err = 0; 667 668 if (pObjectName == NULL || pObjectName->mKeyProperties == NULL) { 669 util_handleError("SOLARIS_NFSSHAREENT::REFERENCE_NAMES", 670 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err); 671 return ((CCIMInstanceList *)NULL); 672 } 673 674 shareEntryInstList = cp_references_Solaris_NFSShareEntry(pAssocName, 675 pObjectName, pRole); 676 677 if (shareEntryInstList == NULL) { 678 return ((CCIMObjectPathList *)NULL); 679 } 680 681 shareEntryOPList = cim_createObjectPathList(shareEntryInstList); 682 683 cim_freeInstanceList(shareEntryInstList); 684 685 return (shareEntryOPList); 686} /* cp_referenceNames_Solaris_NFSShareEntry */ 687 688/* 689 * Property provider methods 690 */ 691 692/* 693 * Method: cp_getProperty_Solaris_NFSShareEntry 694 * 695 * Description: Retrieves a certain property from the instance of 696 * Solaris_NFSShareEntry on the host that is described by the parameter pOP. 697 * 698 * Parameters: 699 * - CCIMObjectPath *pOP - The object path containing all the 700 * information needed to find the instance in which the property is to 701 * be returned. 702 * - cimchar *pPropName - The name of the property to be found. 703 * 704 * Returns: 705 * - A pointer to the property corresponding to the name passed in with 706 * pPropName. 707 * - NULL if an error occurred or if the property doesn't exist. In the 708 * case of an error, the error will be logged. 709 */ 710CCIMProperty * 711cp_getProperty_Solaris_NFSShareEntry(CCIMObjectPath *pOP, cimchar *pPropName) { 712 CCIMInstance *shareEntryInst; 713 CCIMProperty *shareEntryProp; 714 int err = 0; 715 716 if (pOP == NULL) { 717 util_handleError("SOLARIS_NFSSHAREENT::GET_PROPERTY", 718 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err); 719 return ((CCIMProperty *)NULL); 720 } 721 722 shareEntryInst = cp_getInstance_Solaris_NFSShareEntry(pOP); 723 if (shareEntryInst == NULL) { 724 return ((CCIMProperty *)NULL); 725 } 726 727 shareEntryProp = cim_getProperty(shareEntryInst, pPropName); 728 cim_freeInstance(shareEntryInst); 729 730 return (shareEntryProp); 731} /* cp_getProperty_Solaris_NFSShareEntry */ 732 733/* 734 * Method: cp_setProperty_Solaris_NFSShareEntry 735 * 736 * Description: This method is not supported. This is not allowed because in 737 * order to change the properties a Solaris_NFSShareEntry on the host, the 738 * Solaris_NFSShare and Solaris_PersistentShare must most likely be changed. 739 * In order to change the associated objects, they need to be changed in those 740 * providers and not this one. 741 * 742 * Parameters: 743 * - CCIMObjectPath *pOP - Not used. 744 * - CCIMProperty *pProp - Not used. 745 * 746 * Returns: 747 * - cim_false is returned every time since the method is not supported. 748 */ 749/* ARGSUSED */ 750CIMBool 751cp_setProperty_Solaris_NFSShareEntry(CCIMObjectPath *pOP, CCIMProperty *pProp) { 752 int err = 0; 753 754 util_handleError("SOLARIS_NFSSHAREENT::SET_PROPERTY", 755 CIM_ERR_NOT_SUPPORTED, NULL, NULL, &err); 756 757 return (cim_false); 758} /* cp_setProperty_Solaris_NFSShareEntry */ 759 760/* 761 * Method provider methods 762 */ 763 764/* 765 * Method: cp_invokeMethod_Solaris_NFSShareEntry 766 * 767 * Description: This method is not supported because the provider doesn't have 768 * any methods. 769 * 770 * Parameters: 771 * - CCIMObjectPath* op - Not used. 772 * - cimchar* methodName - Not used. 773 * - CCIMPropertyList* inParams - Not used. 774 * - CCIMPropertyList* outParams - Not used. 775 * 776 * Return Value: 777 * - Always returns null because the method is not supported. 778 */ 779/* ARGSUSED */ 780CCIMProperty * 781cp_invokeMethod_Solaris_NFSShareEntry(CCIMObjectPath* op, cimchar* methodName, 782 CCIMPropertyList* inParams, CCIMPropertyList* outParams) { 783 784 return ((CCIMProperty *)NULL); 785} /* cp_invokeMethod_Solaris_NFSShareEntry */ 786 787/* 788 * Private methods 789 */ 790 791/* 792 * Method: create_shareEntry_inst_and_update_list 793 * 794 */ 795static CCIMInstanceList * 796create_shareEntry_inst_and_update_list(CCIMObjectPath *nfsShareOP, 797 CCIMInstanceList *shareEntInstList) { 798 799 CCIMObjectPathList *sharePersistOPList; 800 CCIMObjectPathList *currentPersistShareOP; 801 CCIMInstance *shareEntryInst; 802 CCIMException *ex; 803 int err = 0; 804 805 shareEntryInst = cim_createInstance(SOLARIS_NFSSHAREENT); 806 if (shareEntryInst == NULL) { 807 ex = cim_getLastError(); 808 util_handleError("SOLARIS_NFSSHAREENT::ENUM_INSTANCES", 809 CIM_ERR_FAILED, CREATE_INSTANCE_FAILURE, ex, 810 &err); 811 return ((CCIMInstanceList *)NULL); 812 } 813 814 /* 815 * Retrieve all of the Solaris_PersistentShare object paths 816 * associated with the current Solaris_NFSShare object path. 817 * 818 * NOTE: Although it is wrong, and we can't control it since 819 * /etc/dfs/dfstab is a editable file, there may be multiple 820 * dfstab entries for one nfs share. 821 */ 822 sharePersistOPList = get_associated_sharePersist_OPList(nfsShareOP, 823 &err); 824 if (sharePersistOPList == NULL) { 825 if (err != 0) { 826 cim_freeInstance(shareEntryInst); 827 return ((CCIMInstanceList *)NULL); 828 } 829 cim_freeInstance(shareEntryInst); 830 return (shareEntInstList); 831 } 832 833 for (currentPersistShareOP = sharePersistOPList; 834 currentPersistShareOP != NULL; 835 currentPersistShareOP = currentPersistShareOP->mNext) { 836 /* 837 * Add the properties to the Solaris_NFSShareEntry 838 * instance. 839 */ 840 if (add_property_to_instance(shareEntProps[SETTING].name, 841 shareEntProps[SETTING].type, NULL, 842 currentPersistShareOP->mDataObject, 843 shareEntProps[SETTING].isKey, shareEntryInst) 844 == cim_false) { 845 846 cim_freeObjectPathList(sharePersistOPList); 847 return ((CCIMInstanceList *)NULL); 848 } 849 850 if (add_property_to_instance(shareEntProps[ELEMENT].name, 851 shareEntProps[ELEMENT].type, NULL, nfsShareOP, 852 shareEntProps[ELEMENT].isKey, shareEntryInst) 853 == cim_false) { 854 855 cim_freeObjectPathList(sharePersistOPList); 856 return ((CCIMInstanceList *)NULL); 857 } 858 859 shareEntInstList = cim_addInstance(shareEntInstList, 860 shareEntryInst); 861 if (shareEntInstList == NULL) { 862 ex = cim_getLastError(); 863 util_handleError("SOLARIS_NFSSHAREENT::ENUM_INSTANCES", 864 CIM_ERR_FAILED, ADD_INSTANCE_FAILURE, 865 ex, &err); 866 cim_freeInstance(shareEntryInst); 867 return ((CCIMInstanceList *)NULL); 868 } 869 } 870 871 return (shareEntInstList); 872} /* create_shareEntry_inst_and_update_list */ 873 874/* 875 * Method: get_associated_nfsShare_instList 876 * 877 * Description: Finds the Solaris_NFSShare instances that are associated to 878 * the passed in Solaris_PersistentShare object path. 879 * 880 * Parameters: 881 * - CCIMObjectPath *sharePersistOP - The Solaris_PersistentShare object 882 * path that is to be used to find the associated Solaris_NFSShare 883 * instances. 884 * 885 * Returns: 886 * - A pointer to a list of Solaris_NFSShare instances that are associated 887 * to the Solaris_PersistentShare object path, sharePersistOP, passed in. 888 * - NULL if an error occurred or if there are no Solaris_NFSShare 889 * instances associated to the Solaris_PersistentShare object path. In 890 * the case of an error, the error will be logged. 891 */ 892static CCIMInstanceList * 893get_associated_nfsShare_instList(CCIMObjectPath *sharePersistOP) { 894 CCIMInstanceList *nfsShareInstList; 895 CCIMInstance *nfsShareInst; 896 CCIMObjectPath *nfsShareOP; 897 CCIMException *ex; 898 char *settingId; 899 int err = 0; 900 901 settingId = util_getKeyValue(sharePersistOP->mKeyProperties, string, 902 SETTING_ID, &err); 903 if (settingId == NULL || err != 0) { 904 util_handleError( 905 "SOLARIS_NFSSHAREENT::GET_ASSOC_SHARE_INSTLIST", 906 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err); 907 return ((CCIMInstanceList *)NULL); 908 } 909 910 nfsShareInstList = cim_createInstanceList(); 911 if (nfsShareInstList == NULL) { 912 ex = cim_getLastError(); 913 util_handleError( 914 "SOLARIS_NFSSHAREENT::GET_ASSOC_SHARE_INSTLIST", 915 CIM_ERR_FAILED, CREATE_INSTANCE_LIST_FAILURE, ex, &err); 916 return ((CCIMInstanceList *)NULL); 917 } 918 919 nfsShareOP = get_Solaris_NFSShare_OP(settingId); 920 if (nfsShareOP == NULL) { 921 /* 922 * An error occurred in get_Solaris_NFSShare_OP and was 923 * handled there. 924 */ 925 cim_freeInstanceList(nfsShareInstList); 926 return ((CCIMInstanceList *)NULL); 927 } 928 929 nfsShareInst = cimom_getInstance(nfsShareOP, cim_false, cim_false, 930 cim_false, cim_false, NULL, 0); 931 932 cim_freeObjectPath(nfsShareOP); 933 /* 934 * A NULL return value indicates an error, an empty instance does not. 935 */ 936 if (nfsShareInst == NULL) { 937 ex = cim_getLastError(); 938 util_handleError( 939 "SOLARIS_NFSSHAREENT::GET_ASSOC_SHARE_INSTLIST", 940 CIM_ERR_FAILED, CIMOM_GET_INST_FAILURE, ex, &err); 941 cim_freeInstanceList(nfsShareInstList); 942 return ((CCIMInstanceList *)NULL); 943 } 944 945 if (nfsShareInst->mProperties == NULL) { 946 cim_freeInstanceList(nfsShareInstList); 947 cim_freeInstance(nfsShareInst); 948 return ((CCIMInstanceList *)NULL); 949 } 950 951 /* 952 * Work around for cimom bug 4649100. 953 */ 954 if (!set_share_keyProperties_to_true(nfsShareInst)) { 955 /* 956 * Key values not found 957 */ 958 cim_logDebug( 959 "get_associated_nfsShareSec_instList", 960 "No keyProprties found, should return error here"); 961 cim_freeInstance(nfsShareInst); 962 cim_freeInstanceList(nfsShareInstList); 963 return ((CCIMInstanceList *)NULL); 964 } 965 966 nfsShareInstList = cim_addInstance(nfsShareInstList, nfsShareInst); 967 if (nfsShareInstList == NULL) { 968 ex = cim_getLastError(); 969 util_handleError( 970 "SOLARIS_NFSSHAREENT::GET_ASSOC_SHARE_INSTLIST", 971 CIM_ERR_FAILED, ADD_INSTANCE_FAILURE, ex, &err); 972 cim_freeInstance(nfsShareInst); 973 return ((CCIMInstanceList *)NULL); 974 } 975 976 return (nfsShareInstList); 977} /* get_associated_nfsShare_instList */ 978 979/* 980 * Method: get_associated_sharePersist_instList 981 * 982 * Description: Finds the Solaris_PersistentShare instances that are 983 * associated to the passed in Solaris_NFSShare object path. 984 * 985 * Parameters: 986 * - CCIMObjectPath *nfsShareOP - The Solaris_NFSShare object path that is 987 * to be used to find the associated Solaris_PersistentShare instances. 988 * 989 * Returns: 990 * - A pointer to a list of Solaris_PersistentShare instances that are 991 * associated to the Solaris_NFSShare object path, nfsShareOP, passed in. 992 * NOTE: An instance list is returned rather than a single instance 993 * because it is possible (although unlikely) to have multiple 994 * /etc/dfs/dfstab entries per share. 995 * - NULL if an error occurred or if there are no Solaris_PersistentShare 996 * instances associated to the Solaris_NFSShare object path. 997 */ 998static CCIMInstanceList * 999get_associated_sharePersist_instList(CCIMObjectPath *nfsShareOP) { 1000 CCIMInstanceList *sharePersistInstList = NULL; 1001 CCIMException *ex; 1002 fs_dfstab_entry_t dfstabEnt; 1003 fs_dfstab_entry_t tmpDfstabEnt; 1004 char *name; 1005 int err = 0; 1006 1007 name = util_getKeyValue(nfsShareOP->mKeyProperties, string, NAME, &err); 1008 if (name == NULL || err != 0) { 1009 util_handleError("SOLARIS_NFSSHAREENT::GET_ASSOC_SP_INSTLIST", 1010 CIM_ERR_INVALID_PARAMETER, NULL, NULL, &err); 1011 return ((CCIMInstanceList *)NULL); 1012 } 1013 1014 sharePersistInstList = cim_createInstanceList(); 1015 if (sharePersistInstList == NULL) { 1016 ex = cim_getLastError(); 1017 util_handleError("SOLARIS_NFSSHAREENT::GET_ASSOC_SP_INSTLIST", 1018 CIM_ERR_FAILED, CREATE_INSTANCE_LIST_FAILURE, ex, &err); 1019 return ((CCIMInstanceList *)NULL); 1020 } 1021 1022 dfstabEnt = fs_get_DFStab_ents(&err); 1023 if (dfstabEnt == NULL) { 1024 /* 1025 * Check if an error occurred or if there just weren't any 1026 * /etc/dfs/dfstab entries. 1027 */ 1028 if (err != 0) { 1029 util_handleError( 1030 "SOLARIS_NFSSHAREENT::GET_ASSOC_SP_INSTLIST", 1031 CIM_ERR_FAILED, FS_GET_DFSTAB_ENT_FAILURE, 1032 NULL, &err); 1033 cim_freeInstanceList(sharePersistInstList); 1034 return ((CCIMInstanceList *)NULL); 1035 } 1036 1037 return ((CCIMInstanceList *)NULL); 1038 } 1039 1040 for (tmpDfstabEnt = dfstabEnt; tmpDfstabEnt != NULL; 1041 tmpDfstabEnt = fs_get_DFStab_ent_Next(tmpDfstabEnt)) { 1042 char *path; 1043 char *fstype; 1044 char *command; 1045 1046 err = 0; 1047 path = fs_get_DFStab_ent_Path(tmpDfstabEnt); 1048 fstype = fs_get_DFStab_ent_Fstype(tmpDfstabEnt); 1049 command = fs_get_Dfstab_share_cmd(tmpDfstabEnt, &err); 1050 1051 /* 1052 * Compare the dfstab entry to the nfs share. Do this by first 1053 * checking if the fstype is "nfs" and second by checking 1054 * if the path is the same. 1055 */ 1056 if ((strcasecmp(fstype, NFS) == 0) && 1057 (strcmp(path, name) == 0)) { 1058 1059 CCIMInstance *sharePersistInst; 1060 1061 /* 1062 * We can't just call Solaris_PersistentShare's 1063 * cp_getInstance method because there is a chance that 1064 * multiple dfstab entries having the same path. If 1065 * this is the case, that method will return null and 1066 * some sort of "key not unique" error. 1067 */ 1068 sharePersistInst = get_Solaris_PersistentShare_Inst( 1069 path, command); 1070 if (sharePersistInst == NULL) { 1071 /* 1072 * An error occurred and it was handled in 1073 * get_sharePersist_Inst. 1074 */ 1075 fs_free_DFStab_ents(dfstabEnt); 1076 return ((CCIMInstanceList *)NULL); 1077 } 1078 1079 sharePersistInstList = cim_addInstance( 1080 sharePersistInstList, sharePersistInst); 1081 if (sharePersistInstList == NULL) { 1082 ex = cim_getLastError(); 1083 util_handleError( 1084 "SOLARIS_NFSSHAREENT::GET_ASSOC_SP_INSTLIST", 1085 CIM_ERR_FAILED, ADD_INSTANCE_FAILURE, ex, &err); 1086 cim_freeInstance(sharePersistInst); 1087 fs_free_DFStab_ents(dfstabEnt); 1088 return ((CCIMInstanceList *)NULL); 1089 } 1090 } 1091 } 1092 1093 fs_free_DFStab_ents(dfstabEnt); 1094 return (sharePersistInstList); 1095} /* get_associated_sharePersist_instList */ 1096 1097/* 1098 * Method: get_associated_sharePersist_OPList 1099 * 1100 * Description: Finds the Solaris_PersistentShare object paths that are 1101 * associated to the passed in Solaris_NFSShare object path. 1102 * 1103 * Parameters: 1104 * - CCIMObjectPath *nfsShareOP - The Solaris_NFSShare object path of 1105 * of which to retrieve the associated Solaris_PersistentShare object 1106 * paths. 1107 * 1108 * Returns: 1109 * - A pointer to a list of Solaris_PersistentShare object paths that are 1110 * associated to the passed in Solaris_NFSShare object path. 1111 * - Upon error, NULL is returned and the error is logged. 1112 * 1113 * Returns: 1114 */ 1115static CCIMObjectPathList * 1116get_associated_sharePersist_OPList(CCIMObjectPath *nfsShareOP, int *errp) { 1117 CCIMInstanceList *sharePersistInstList; 1118 CCIMObjectPathList *sharePersistOPList; 1119 CCIMException *ex; 1120 int err = 0; 1121 1122 sharePersistInstList = get_associated_sharePersist_instList(nfsShareOP); 1123 if (sharePersistInstList == NULL) { 1124 /* 1125 * An error occurred in get_associated_sharePersist_InstList 1126 * and was handled in that function. 1127 */ 1128 *errp = -1; 1129 return ((CCIMObjectPathList *)NULL); 1130 } 1131 1132 sharePersistOPList = cim_createObjectPathList(sharePersistInstList); 1133 if (sharePersistOPList == NULL) { 1134 ex = cim_getLastError(); 1135 util_handleError("SOLARIS_NFSSHAREENT::GET_ASSOC_SP_OPLIST", 1136 CIM_ERR_FAILED, CREATE_OBJECT_LIST_FAILURE, ex, &err); 1137 cim_freeInstanceList(sharePersistInstList); 1138 *errp = -1; 1139 return ((CCIMObjectPathList *)NULL); 1140 } 1141 1142 cim_freeInstanceList(sharePersistInstList); 1143 return (sharePersistOPList); 1144} /* get_associated_sharePersist_OPList */ 1145 1146/* 1147 * Method: get_Solaris_NFSShare_OP 1148 * 1149 * Description: 1150 * 1151 * Parameters: 1152 * 1153 * Returns: 1154 */ 1155static CCIMObjectPath * 1156get_Solaris_NFSShare_OP(char *nameKey) { 1157 CCIMObjectPath *nfsShareOP; 1158 CCIMPropertyList *nfsShareKeyPropList; 1159 CCIMException *ex; 1160 char *sysName; 1161 int err = 0; 1162 1163 nfsShareOP = cim_createEmptyObjectPath(SOLARIS_NFSSHARE); 1164 if (nfsShareOP == NULL) { 1165 ex = cim_getLastError(); 1166 util_handleError("SOLARIS_NFSSHAREENT::GET_NFSSHARE_OP", 1167 CIM_ERR_FAILED, CREATE_EMPTY_OBJPATH_FAILURE, ex, 1168 &err); 1169 return ((CCIMObjectPath *)NULL); 1170 } 1171 1172 sysName = (cimchar *)sys_get_hostname(&err); 1173 if (sysName == NULL) { 1174 util_handleError("SOLARIS_NFSSHAREENT::GET_NFSSHARE_OP", 1175 CIM_ERR_FAILED, GET_HOSTNAME_FAILURE, NULL, &err); 1176 cim_freeObjectPath(nfsShareOP); 1177 return ((CCIMObjectPath *)NULL); 1178 } 1179 1180 /* 1181 * Create the property list which to add all the key properties to and 1182 * which will be added to the object path. 1183 */ 1184 nfsShareKeyPropList = cim_createPropertyList(); 1185 if (nfsShareKeyPropList == NULL) { 1186 ex = cim_getLastError(); 1187 util_handleError("SOLARIS_NFSSHAREENT::GET_NFSSHARE_OP", 1188 CIM_ERR_FAILED, CREATE_PROPLIST_FAILURE, ex, &err); 1189 cim_freeObjectPath(nfsShareOP); 1190 return ((CCIMObjectPath *)NULL); 1191 } 1192 1193 /* 1194 * add_property_to_list parameters are as follows: 1195 * 1.) property name (cimchar *), 1196 * 2.) property type (CIMType), 1197 * 3.) property value (cimchar *), 1198 * 4.) property object path for reference properties (CCIMObjectPath *), 1199 * 5.) is property a key? (CIMBool), 1200 * 6.) property list to add the property to (CCIMPropertyList *). 1201 */ 1202 nfsShareKeyPropList = add_property_to_list(NAME, string, nameKey, 1203 NULL, cim_true, nfsShareKeyPropList); 1204 if (nfsShareKeyPropList == NULL) { 1205 cim_freeObjectPath(nfsShareOP); 1206 return ((CCIMObjectPath *)NULL); 1207 } 1208 1209 nfsShareKeyPropList = add_property_to_list(CREATION_CLASS, string, 1210 SOLARIS_NFSSHARE, NULL, cim_true, nfsShareKeyPropList); 1211 if (nfsShareKeyPropList == NULL) { 1212 cim_freeObjectPath(nfsShareOP); 1213 return ((CCIMObjectPath *)NULL); 1214 } 1215 1216 nfsShareKeyPropList = add_property_to_list(SYS_CREATION_CLASS, string, 1217 COMPUTER_SYSTEM, NULL, cim_true, nfsShareKeyPropList); 1218 if (nfsShareKeyPropList == NULL) { 1219 cim_freeObjectPath(nfsShareOP); 1220 return ((CCIMObjectPath *)NULL); 1221 } 1222 1223 nfsShareKeyPropList = add_property_to_list(SYSTEM, string, sysName, 1224 NULL, cim_true, nfsShareKeyPropList); 1225 if (nfsShareKeyPropList == NULL) { 1226 free(sysName); 1227 cim_freeObjectPath(nfsShareOP); 1228 return ((CCIMObjectPath *)NULL); 1229 } 1230 free(sysName); 1231 1232 nfsShareOP = cim_addPropertyListToObjectPath(nfsShareOP, 1233 nfsShareKeyPropList); 1234 if (nfsShareOP == NULL) { 1235 ex = cim_getLastError(); 1236 util_handleError("SOLARIS_NFSSHAREENT::GET_NFSSHARE_OP", 1237 CIM_ERR_FAILED, ADD_PROP_TO_OBJPATH_FAILURE, ex, &err); 1238 cim_freePropertyList(nfsShareKeyPropList); 1239 return ((CCIMObjectPath *)NULL); 1240 } 1241 1242 return (nfsShareOP); 1243} /* get_Solaris_NFSShare_OP */ 1244 1245/* 1246 * Method: get_Solaris_PersistentShare_Inst 1247 * 1248 * Description: Creates an instance of the Solaris_PersistentShare class. 1249 * 1250 * Parameters: 1251 * - char *path - The value to be used for the SettingID property. 1252 * - char *command - The value to be used for the Command property. 1253 * 1254 * Returns: 1255 * - A pointer to a Solaris_PersistentShare instance. 1256 * - Upon error, NULL is returned and the error is logged. 1257 */ 1258static CCIMInstance * 1259get_Solaris_PersistentShare_Inst(char *path, char *command) { 1260 CCIMInstance *sharePersistInst; 1261 CCIMException *ex; 1262 cimchar *sysName; 1263 int err = 0; 1264 1265 sysName = (cimchar *)sys_get_hostname(&err); 1266 if (sysName == NULL) { 1267 util_handleError("SOLARIS_NFSSHAREENT::GET_SHAREPERSIST_INST", 1268 CIM_ERR_FAILED, GET_HOSTNAME_FAILURE, NULL, &err); 1269 return ((CCIMInstance *)NULL); 1270 } 1271 1272 sharePersistInst = cim_createInstance(SOLARIS_PERSISTSHARE); 1273 if (sharePersistInst == NULL) { 1274 ex = cim_getLastError(); 1275 util_handleError("SOLARIS_NFSSHAREENT::GET_SHAREPERSIST_INST", 1276 CIM_ERR_FAILED, CREATE_INSTANCE_FAILURE, ex, &err); 1277 return ((CCIMInstance *)NULL); 1278 } 1279 1280 /* 1281 * add_property_to_instance parameters are as follows: 1282 * 1.) property name (cimchar *), 1283 * 2.) property type (CIMType), 1284 * 3.) property value (cimchar *), 1285 * 4.) property object path for reference properties (CCIMObjectPath *), 1286 * 5.) is property a key? (CIMBool), 1287 * 6.) instance to add the property to (CCIMInstance *). 1288 */ 1289 if (add_property_to_instance(CREATION_CLASS, string, 1290 SOLARIS_PERSISTSHARE, NULL, cim_true, sharePersistInst) 1291 == cim_false) { 1292 1293 cim_freeInstance(sharePersistInst); 1294 return ((CCIMInstance *)NULL); 1295 } 1296 1297 if (add_property_to_instance(SYS_CREATION_CLASS, string, 1298 COMPUTER_SYSTEM, NULL, cim_true, sharePersistInst) 1299 == cim_false) { 1300 1301 cim_freeInstance(sharePersistInst); 1302 return ((CCIMInstance *)NULL); 1303 } 1304 1305 if (add_property_to_instance(SETTING_ID, string, path, 1306 NULL, cim_true, sharePersistInst) == cim_false) { 1307 1308 cim_freeInstance(sharePersistInst); 1309 return ((CCIMInstance *)NULL); 1310 } 1311 1312 if (add_property_to_instance(SYSTEM, string, sysName, 1313 NULL, cim_true, sharePersistInst) == cim_false) { 1314 1315 free(sysName); 1316 cim_freeInstance(sharePersistInst); 1317 return ((CCIMInstance *)NULL); 1318 } 1319 free(sysName); 1320 1321 if (add_property_to_instance(COMMAND, string, command, 1322 NULL, cim_false, sharePersistInst) == cim_false) { 1323 1324 cim_freeInstance(sharePersistInst); 1325 return ((CCIMInstance *)NULL); 1326 } 1327 1328 return (sharePersistInst); 1329} /* get_Solaris_PersistentShare_Inst */ 1330