Solaris_HostedShare.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "Solaris_HostedShare.h"
#include "nfs_keys.h"
#include "nfs_providers_msgstrings.h"
#include "messageStrings.h"
#include "nfs_provider_names.h"
#include "util.h"
#include "libfsmgt.h"
#include "common_functions.h"
#include "createprop_methods.h"
/*
* Private method declarations
*/
static CCIMObjectPath* get_Antecedent();
/*
* Public methods
*/
/*
* Instance provider methods
*/
/*
* Method: cp_createInstance_Solaris_HostedShare
*
* Description: This method is not supported. It is not supported because in
* order for a Solaris_HostedShare association to exist a corresponding
* Solaris_NFSShare and Solaris_ComputerSystem must exist.
*
* Parameters:
* - CCIMObjectPath *hostedShareOP - An object path containing the name of
* the class of which to create an instance of.
* - CCIMInstance *hostedShareInst - Not used.
*
* Returns:
* - Always returns NULL because the method is not supported.
*/
/* ARGSUSED */
int err = 0;
util_handleError("SOLARIS_HOSTEDSHARE::CREATE_INSTANCE",
return ((CCIMObjectPath *)NULL);
} /* cp_createInstance_Solaris_HostedShare */
/*
* Method: cp_deleteInstance_Solaris_HostedShare
*
* Description: This method is not supported. It is not supported because in
* order for it to be actually deleted the corresponding Solaris_NFSShare would
* need to be deleted. That action is not appropriate for this provider.
*
* Parameters:
* - CCIMObjectPath *hostedShareOP - An object path containing the
* information about the class of which to delete the instance of.
*
* Returns:
* - Always returns cim_false because the method is not supported.
*/
/* ARGSUSED */
int err = 0;
util_handleError("SOLARIS_HOSTEDSHARE::DELETE_INSTANCE",
return (cim_false);
} /* cp_deleteInstance_Solaris_HostedShare */
/*
* Method: cp_enumInstances_Solaris_HostedShare
*
* Description: Enumerates the instances of Solaris_HostedShare on a host.
* An instance of Solaris_HostedShare is an association that links a share to
* the hosting machine.
*
* Parameters:
* - CCIMObjectPath *hostedShareOP - An object path containing the name of
* the class of which to enumerate the instances of.
*
* Returns:
* - A pointer to a list of Solaris_HostedShare instances.
* - NULL if an error occurred or if there are no instances of
* Solaris_HostedShare on the host. In the case of an error, the error
* will be logged.
*/
int err = 0;
/*
* The Antecedent property is a Solaris_ComputerSystem reference.
* The Dependent property is a Solaris_NFSShare reference.
*/
if (hostedShareOP == NULL) {
util_handleError("SOLARIS_HOSTEDSHARE::ENUM_INSTANCES",
return ((CCIMInstanceList *)NULL);
}
if (nfsShareOP == NULL) {
ex = cim_getLastError();
util_handleError("SOLARIS_HOSTEDSHARE::ENUM_INSTANCES",
return ((CCIMInstanceList *)NULL);
}
/*
* Enumerate all of the Solaris_NFSShare object paths on the system.
*/
/*
* A NULL return value indicates an error, an empty list does not.
*/
if (nfsShareOPList == NULL) {
cim_logDebug("cp_enumInstances_Solaris_HostedShare",
"nfsShareOPList = NULL");
ex = cim_getLastError();
util_handleError("SOLARIS_HOSTEDSHARE::ENUM_INSTANCES",
return ((CCIMInstanceList *)NULL);
}
return ((CCIMInstanceList *)NULL);
}
antOP = get_Antecedent();
/*
* The error was logged in get_Antecedent.
*/
return ((CCIMInstanceList *)NULL);
}
if (hostedShareInstList == NULL) {
ex = cim_getLastError();
util_handleError("SOLARIS_HOSTEDSHARE::ENUM_INSTANCES",
return ((CCIMInstanceList *)NULL);
}
/*
* Each share on the system will be associated with the same
* Solaris_ComputerSystem object path.
*/
if (hostedShareInst == NULL) {
ex = cim_getLastError();
util_handleError("SOLARIS_HOSTEDSHARE::ENUM_INSTANCES",
&err);
return ((CCIMInstanceList *)NULL);
}
hostedShareInst) == cim_false) {
return ((CCIMInstanceList *)NULL);
}
== cim_false) {
return ((CCIMInstanceList *)NULL);
}
if (hostedShareInstList == NULL) {
ex = cim_getLastError();
util_handleError("SOLARIS_HOSTEDSHARE::ENUM_INSTANCES",
return ((CCIMInstanceList *)NULL);
}
}
return (hostedShareInstList);
} /* cp_enumInstances_Solaris_HostedShare */
/*
* Method: cp_enumInstanceNames_Solaris_HostedShare
*
* Description: Enumerates the instances of Solaris_HostedShare on the host.
*
* Parameters:
* - CCIMObjectPath *hostedShareOP - An object path containing the name of
* the class of which to enumerate the instance names of.
*
* Returns:
* - A list of object paths corresponding to the instances of
* Solaris_HostedShare on the host.
* - NULL if an error occurred or if there are no instances of
* Solaris_HostedShare on the host. In the case of an error, the error
* will be logged.
*/
int err = 0;
if (hostedShareOP == NULL) {
util_handleError("SOLARIS_HOSTEDSHARE::ENUM_INSTANCENAMES",
return ((CCIMObjectPathList *)NULL);
}
if (hostedShareInstList == NULL) {
/*
* An error occurred in enumInstances or there are simply
* no Solaris_HostedShare instances to enumerate. In the case,
* of an error, the error would have been handled in the
* cp_enumInstances_Solaris_HostedShare function.
*/
return ((CCIMObjectPathList *)NULL);
}
/*
* If an error occurred it will be handled in cim_createObjectPathList.
*/
return (hostedShareOPList);
} /* cp_enumInstanceNames_Solaris_HostedShare */
/*
* Method: cp_execQuery_Solaris_HostedShare
*
* Description: Queries the host to find those Solaris_HostedShare instances
* that meet the search criteria.
*
* Parameters:
* - CCIMObjectPath *hostedShareOP - An object path containing the name of
* the class of which to query.
* - char *selectClause - Not used.
* - char *nonJoinExp - Not used.
* - char *queryExp - Not used.
* - char *queryLang - Not used.
*
* Returns:
* - A pointer to a list of Solaris_HostedShare instances that match the
* criteria.
* - NULL if an error occurred or if there are no Solaris_HostedShare
* instances that match the criteria. In the case of an error, the error
* will be logged.
*
* NOTE: Currently, there is no WQL parser for the C providers. As a result,
* what is returned to the CIMOM is a list of instances with
* a NULL value at the beginning of the list. This NULL value indicates
* to the CIMOM that it must do the filtering for the client.
*/
/* ARGSUSED */
int err = 0;
if (hostedShareOP == NULL) {
util_handleError("SOLARIS_HOSTEDSHARE::EXEC_QUERY",
return ((CCIMInstanceList *)NULL);
}
if (hostedShareInstList == NULL) {
return ((CCIMInstanceList *)NULL);
}
ex = cim_getLastError();
util_handleError("SOLARIS_HOSTEDSHARE::EXEC_QUERY",
return ((CCIMInstanceList *)NULL);
}
if (hostedShareInstList == NULL) {
ex = cim_getLastError();
util_handleError("SOLARIS_HOSTEDSHARE::EXEC_QUERY",
return ((CCIMInstanceList *)NULL);
}
return (hostedShareInstList);
} /* cp_execQuery_Solaris_HostedShare */
/*
* Method: cp_getInstance_Solaris_HostedShare
*
* Description: Gets the instance corresponding to the passed in object path.
*
* Parameters:
* - CCIMObjectPath *hostedShareOP - The object path containing all the
* keys of the instance that is supposed to be returned.
*
* Returns:
* - A pointer to the instance of Solaris_HostedShare corresponding to
* hostedShareOP.
* - NULL if an error occurred or if the instance doesn't exist on the
* host. In the case of an error, the error will be logged.
*/
int err = 0;
util_handleError("SOLARIS_HOSTEDSHARE::GET_INSTANCE",
return ((CCIMInstance *)NULL);
}
/*
* Get the Dependent and Antecedent properties.
*/
/*
* Check if we have the Antecedent and Dependent properties.
*/
util_handleError("SOLARIS_HOSTEDSHARE::GET_INSTANCE",
return ((CCIMInstance *)NULL);
}
return ((CCIMInstance *)NULL);
}
return (inst);
} /* cp_getInstance_Solaris_HostedShare */
/*
* Method: cp_setInstance_Solaris_HostedShare
*
* Description: This method is not supported. It is not supported because in
* order to change a Solaris_HostedShare instance the underlying share and
* computer system must be modified. Those actions must be done on the
* appropriate share and computer system objects, not here.
*
* Parameters:
* - CCIMObjectPath *pOP - An object path containing the name of the class
* of which to set the instance.
* - CCIMInstance *pInst - Not used.
*
* Returns:
* - Always returns cim_false, because the method is not supported.
*/
/* ARGSUSED */
int err = 0;
util_handleError("SOLARIS_HOSTEDSHARE::SET_INSTANCE",
return (cim_false);
} /* cp_setInstance_Solaris_HostedShare */
/*
* Method: cp_setInstanceWithList_Solaris_HostedShare
*
* Description: This method is not supported. It is not supported because in
* order to change a Solaris_HostedShare instance the underlying share and
* computer system must be modified. Those actions must be done on the
* appropriate share and computer system objects, not here.
*
* Parameters:
* - CCIMObjectPath *hostedShareOP - The object path containing the name
* of the class of which to set the instance.
* - CCIMInstance *hostedShareInst - Not used.
* - char **props - Not used.
* - int num_props - Not used.
*
* Returns:
* - Always returns cim_false, because the method is not supported.
*/
/* ARGSUSED */
int err = 0;
util_handleError("SOLARIS_HOSTEDSHARE::SET_INSTANCE",
return (cim_false);
} /* cp_setInstanceWithList_Solaris_HostedShare */
/*
* Association provider methods
*/
/*
* Method: cp_associators_Solaris_HostedShare
*
* Description: Returns the instances associated, via the Solaris_HostedShare
* association, to the pObjectName parameter.
*
* Parameters:
* - CCIMObjectPath *pAssocName - An object path containing the name of
* the association that the caller is trying to reach.
* - CCIMObjectPath *pObjectName - The object path containing information
* (Class Name, Key Properties) about the object whose associated objects
* are to be returned.
* - char *pResultClass - If specified, only return instances that are of
* this class type.
* - char *pRole - If specified, this is the role of the pObjectName
* object path passed in. If this is not valid, NULL is returned.
* - char *pResultRole - If specified, only return instances that are
* playing this role in the association.
*
* Returns:
* - A list of Solaris_NFSShare (if pRole == Antecedent && pObjectName is
* a Solaris_ComputerSystem object path) or Solaris_ComputerSystem (if
* pRole == Dependent && pObjectName is a Solaris_NFSShare object path)
* instances which are associated to the pObjectName parameter.
* - NULL if an error occurred or if there are no instances associated to
* the pObjectName passed in. In the case of an error, the error will be
* logged.
*/
/* ARGSUSED */
char *pResultRole) {
char *name;
char **pPropertyList;
unsigned int pNumProps;
int err = 0;
/*
* Check if the needed parameters are NULL.
*/
util_handleError("SOLARIS_HOSTEDSHARE::ASSOCIATORS",
return ((CCIMInstanceList *)NULL);
}
/*
* The Name key property is the defining property for each the
* Antecedent (Solaris_ComputerSystem) and the Dependent
* (Solaris_NFSShare) so retrieve that property.
*/
/*
* We don't have the appropriate information.
*/
util_handleError("SOLARIS_HOSTEDSHARE::ASSOCIATORS",
return ((CCIMInstanceList *)NULL);
}
/*
* Determine whether the pObjectName is the Antecedent or the Dependent
* of the association. Antecedent == Solaris_ComputerSystem,
* Dependent == Solaris_NFSShare
*/
char *hostname;
/*
* If a value was passed in with pRole and it does not match
* the role that pObjectName actually is then log an invalid
* param error.
*/
util_handleError("SOLARIS_NFSMOUNT::ASSOCIATORS",
return ((CCIMInstanceList *)NULL);
}
/*
* Get the current host name and compare it to the name
* property of the passed in pObjectName.
*/
util_handleError("SOLARIS_HOSTEDSHARE::ASSOCIATORS",
&err);
return ((CCIMInstanceList *)NULL);
}
/*
* We can only determine shares on the current host.
* The providers are not distributed.
*/
util_handleError("SOLARIS_HOSTEDSHARE::ASSOCIATORS",
return ((CCIMInstanceList *)NULL);
}
/*
* pObjectName is the Dependent (Solaris_NFSShare) so determine
* if the share actually exists by comparing the Name property
* of pObjectName, which is populated with the shared directory,
* to existing nfs shares on the system.
*/
if (shareExists == cim_false) {
return ((CCIMInstanceList *)NULL);
}
} else {
util_handleError("SOLARIS_HOSTEDSHARE::ASSOCIATORS",
return ((CCIMInstanceList *)NULL);
}
ex = cim_getLastError();
util_handleError("SOLARIS_HOSTEDSHARE::ASSOCIATORS",
return ((CCIMInstanceList *)NULL);
}
pNumProps = 0;
/*
* A NULL return value indicates an error, an empty list
* doesn't.
*/
if (returnInstList == NULL) {
ex = cim_getLastError();
util_handleError("SOLARIS_HOSTEDSHARE::ASSOCIATORS",
&err);
return ((CCIMInstanceList *)NULL);
}
return ((CCIMInstanceList *)NULL);
}
return (returnInstList);
} /* cp_associators_Solaris_HostedShare */
/*
* Method: cp_associatorNames_Solaris_HostedShare
*
* Description: Returns the object paths of the instances on the other side of
* the association which are associated via the Solaris_HostedShare association
* and having the passed in parameter, pObjectName, as the opposite key.
*
* Parameters:
* - CCIMObjectPath *pAssocName - An object path containing information
* about the association that the caller is trying to reach.
* - CCIMObjectPath *pObjectName - The object path which contains the
* information on whose associated objects are to be returned.
* - char *pResultClass - If specified, only return instances that are of
* this class type.
* - char *pRole - If specified, this is the role of the pObjectName
* object path passed in. If this is not valid, NULL is returned.
* - char *pResultRole - If specified, only return instances that are
* playing this role in the association.
*
* Returns:
* - A list of Solaris_NFSShare (if pRole == Antecedent && pObjectName is
* a Solaris_ComputerSystem object path) or Solaris_ComputerSystem (if
* pRole == Dependent && pObjectName is a Solaris_NFSShare object path)
* object paths which are associated to the pObjectName parameter.
* - NULL if an error occurred or if there are no instances associated to
* the pObjectName passed in. In the case of an error, the error will be
* logged.
*/
char *pResultRole) {
int err = 0;
util_handleError("SOLARIS_HOSTEDSHARE::ASSOCIATOR_NAMES",
return ((CCIMObjectPathList *)NULL);
}
return ((CCIMObjectPathList *)NULL);
}
return (objPathList);
} /* cp_associatorNames_Solaris_HostedShare */
/*
* Method: cp_references_Solaris_HostedShare
*
* Description: Returns the Solaris_HostedShare instances that have the passed
* in parameter, pObjectName, as one of it's keys.
*
* Parameters:
* - CCIMObjectPath *pAssocName - An object path containing information
* about the association that the caller is trying to reach.
* - CCIMObjectPath *pObjectName - The object path which contains the
* information on whose associated objects are to be returned.
* - char *pRole - If specified, this is the role of the pObjectName
* object path passed in. If this is not valid, NULL is returned.
*
* Returns:
* - A pointer to a list of Solaris_HostedShare instances.
* - NULL if an error occurred or if there are no Solaris_HostedShare
* instances having pObjectName as one of it's keys.
*/
char *pObjectNameRole;
char *objPathListRole;
int err = 0;
util_handleError("SOLARIS_HOSTEDSHARE::REFERENCES",
return ((CCIMInstanceList *)NULL);
}
/*
* Get everything that is related to the pObjectName passed in.
*/
if (objPathList == NULL) {
return ((CCIMInstanceList *)NULL);
}
/*
* Now use the object paths in the object path list and the pObjectName
* variable to create the association instances.
*/
/*
* pObjectName is the Dependent.
*/
objPathListRole, &err);
} else {
/*
* pObjectName is the Antecedent.
*/
objPathListRole, &err);
}
return (instList);
} /* cp_references_Solaris_HostedShare */
/*
* Method: cp_referenceNames_Solaris_HostedShare
*
* Description: Returns the Solaris_HostedShare object paths of the instances
* that have the passed in parameter, pObjectName, as one of it's keys.
*
* Parameters:
* - CCIMObjectPath *pAssocName - An object path containing information
* about the association that the caller is trying to reach.
* - CCIMObjectPath *pObjectName - The object path which contains the
* information on whose associated objects are to be returned.
* - char *pRole - If specified, this is the role of the pObjectName
* object path passed in. If this is not valid, NULL is returned.
*
* Returns:
* - A pointer to a list of Solaris_HostedShare object paths.
* - NULL if an error occurred or if there are no Solaris_HostedShare
* instances having pObjectName as one of it's keys.
*/
int err = 0;
util_handleError("SOLARIS_HOSTEDSHARE::REFERENCE_NAMES",
return ((CCIMObjectPathList *)NULL);
}
pObjectName, pRole);
if (hostedShareInstList == NULL) {
return ((CCIMObjectPathList *)NULL);
}
/*
* If an error occurred it will be handled in cim_createObjectPathList.
*/
return (hostedShareOPList);
} /* cp_referenceNames_Solaris_HostedShare */
/*
* Property provider methods
*/
/*
* Method: cp_getProperty_Solaris_HostedShare
*
* Description: Retrieves a certain property from the instance of
* Solaris_HostedShare on the host that is described by the parameter
* hostedShareOP.
*
* Parameters:
* - CCIMObjectPath *hostedShareOP - The object path containing all the
* information needed to find the instance in which the property is to
* be returned.
* - cimchar *pPropName - The name of the property to be found.
*
* Returns:
* - A pointer to the property corresponding to the name passed in with
* pPropName.
* - NULL if an error occurred or if the property doesn't exist. In the
* case of an error, the error will be logged.
*/
int err = 0;
if (hostedShareOP == NULL) {
util_handleError("SOLARIS_HOSTEDSHARE::GET_PROPERTY",
return ((CCIMProperty *)NULL);
}
if (hostedShareInst == NULL) {
return ((CCIMProperty *)NULL);
}
return (hostedShareProp);
} /* cp_getProperty_Solaris_HostedShare */
/*
* Method: cp_setProperty_Solaris_HostedShare
*
* Description: This method is not supported. It is not supported because in
* order to change the properties of a Solaris_HostedShare instance, the
* underlying classes being associated must be changed. This provider isn't
* the appropriate place to be changing other things on the host.
*
* Parameters:
* - CCIMObjectPath *hostedShareOP - Not used.
* - CCIMProperty *pProp - Not used.
*
* Returns:
* - Always returns cim_false because the method is not supported.
*/
/* ARGSUSED */
CCIMProperty *pProp) {
int err = 0;
util_handleError("SOLARIS_HOSTEDSHARE::SET_PROPERTY",
return (cim_false);
} /* cp_setProperty_Solaris_HostedShare */
/*
* Method provider methods
*/
/*
* Method: cp_invokeMethod_Solaris_HostedShare
*
* Description: This method is not supported because the provider doesn't have
* any methods.
*
* Parameters:
* - CCIMObjectPath* op - Not used.
* - cimchar* methodName - Not used.
* - CCIMPropertyList* inParams - Not used.
* - CCIMPropertyList* outParams - Not used.
*
* Returns:
* - Always returns null because the method is not supported.
*/
/* ARGSUSED */
return ((CCIMProperty *)NULL);
} /* cp_invokeMethod_Solaris_HostedShare */
/*
* Private methods
*/
/*
* Method: does_share_exist
*
* Description: Determines if a given share exists on the host.
*
* Parameters:
* - char *dir - The name of the directory to see if it is shared.
*
* Returns:
* - An integer corresponding to the existence of the share on the system.
* 1 is returned if the share exists, 0 is returned if the share does not
* exist.
*/
static CIMBool
does_share_exist(char *dir) {
int err = 0;
if (share_list == NULL) {
/*
* Either there was an error or there are no shares on the
* system. If there was an error err should be a non-zero
* value.
*/
if (err != 0) {
util_handleError("SOLARIS_HOSTEDSHARE::SHARE_EXISTS",
&err);
}
return (return_val);
}
}
}
return (return_val);
} /* does_share_exist */
/*
* Method: get_Antecedent
*
* Description: Retrieves a reference property of the host's
* Solaris_ComputerSystem class.
*
* Parameters:
* - NONE
* Returns:
* - A pointer to a property which is a reference property of the host's
* Solaris_ComputerSystem instance.
* - Upon error, NULL is returned and the error is logged.
*/
static CCIMObjectPath *
get_Antecedent() {
char *hostname;
int err = 0;
if (compSysInst == NULL) {
ex = cim_getLastError();
util_handleError("SOLARIS_HOSTEDSHARE::GET_ANT",
return ((CCIMObjectPath *)NULL);
}
/*
* Create the key properties on the Solaris_ComputerSystem instance.
*
* The Solaris_ComputerSystem keys are as follows:
* CreationClassName = "Solaris_ComputerSystem"
* Name = < host name >
*/
return ((CCIMObjectPath *)NULL);
}
util_handleError("SOLARIS_HOSTEDSHARE::GET_ANT",
return ((CCIMObjectPath *)NULL);
}
return ((CCIMObjectPath *)NULL);
}
ex = cim_getLastError();
util_handleError("SOLARIS_HOSTEDSHARE::GET_ANT",
return ((CCIMObjectPath *)NULL);
}
return (compSysOP);
} /* get_Antecedent */