fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
894ed91c969ef99fbc1891bf8de449cc1f11f518Milan Jurik * Copyright 2012 Milan Jurik. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This file's functions are responsible for all store and retrieve operations
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * against the STMF smf(5) database. The following shows the currently defined
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * schema for the STMF database:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description of property groups for service: svc:/system/stmf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Stability: Volatile
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 1. Property Group: host_groups
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Properties: group_name-<N> where <N> is an unsigned integer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type: ustring
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * contains: group name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * group_name-<N>-member_list where <N> is an unsigned
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * integer matching a group_name-<N> property.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type: ustring
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * contains: list of members
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Contains the host group names as well as the host group members
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for each host group.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 2. Property Group: target_groups
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Properties: group_name-<N> where <N> is an unsigned integer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type: ustring
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * contains: group name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * group_name-<N>-member_list where <N> is an unsigned
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * integer matching a group_name-<N> property.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type: ustring
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * contains: list of members
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Contains the target group names as well as the target group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * members for each target group.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 3. Property Group: lu-<GUID>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * where <GUID> is a 32 character hexadecimal string.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Properties: ve_cnt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type: count
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * contains: the number of current view entries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * view-entry-<N>-<GUID> where <N> is an unsigned integer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type: ustring
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * contains: nothing. Used as reference to the view
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * entry property group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Contains the references to each view entry. One lu-<GUID>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * property group will exist for each logical unit with 1 or more
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * view entries.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Potentially can hold any other data that can be managed on a per
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * logical unit basis.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 4. Property Group: view_entry-<N>-<GUID> (matches property in lu-<GUID>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * property group)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Properties: all_hosts
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type: boolean
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * contains: when true, the value of host_group is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * all_targets
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type: boolean
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * contains: when true, the value of target_group is
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * host_group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type: ustring
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * contains: host group for logical unit mapping and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * masking purposes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * target_group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type: ustring
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * contains: target group for logical unit mapping and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * masking purposes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type: opaque
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * contains: the 8-byte SCSI logical unit number for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * mapping and masking purposes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * One "view_entry-<N>-<GUID>" property group will exist for each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * view entry in the system. This property group name maps
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * directly to the "lu-<GUID>" property group with a matching
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 5. Property Group: provider_data_pg_<provider-name>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * where <provider-name> is the name of the provider
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * registered with stmf.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Properties: provider_data_prop-<N>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * where <N> is a sequential identifier for the data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type: opaque
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * contains: up to STMF_PROVIDER_DATA_PROP_SIZE bytes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of nvlist packed data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * provider_data_count
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type: count
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * contains: the number of provider data chunks
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * provider_data_type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * type: integer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * contains: STMF_PORT_PROVIDER_TYPE or
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_LU_PROVIDER_TYPE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Description:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Holds the nvlist packed provider data set via
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * stmfSetProviderData and retrieved via stmfGetProviderData. Data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * is stored in STMF_PROVIDER_DATA_PROP_SIZE chunks. On retrieve,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * these chunks are reassembled and unpacked.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iPsInit(scf_handle_t **, scf_service_t **);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iPsCreateDeleteGroup(char *, char *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iPsAddRemoveGroupMember(char *, char *, char *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iPsGetGroupList(char *, stmfGroupList **);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iPsGetGroupMemberList(char *, char *, stmfGroupProperties **);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iPsAddViewEntry(char *, char *, stmfViewEntry *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iPsAddRemoveLuViewEntry(char *, char *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iPsGetViewEntry(char *, stmfViewEntry *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iPsGetActualGroupName(char *, char *, char *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int iPsGetServiceVersion(uint64_t *, scf_handle_t *, scf_service_t *);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetostatic int iPsGetSetPersistType(uint8_t *, scf_handle_t *, scf_service_t *,
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapallistatic int iPsGetSetStmfProp(int, char *, int);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int viewEntryCompare(const void *, const void *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void sigHandler();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic pthread_mutex_t sigSetLock = PTHREAD_MUTEX_INITIALIZER;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Version info for the SMF schema
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Note: Do not change these property names and size values.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * They represent fields in the persistent config and once modified
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * will have a nasty side effect of invalidating the existing store.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * If you do need to change them, you'll need to use the versioning above
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * to retain backward compatiblity with the previous configuration schema.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/* BEGIN STORE PROPERTY DEFINITIONS */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Property Group Names and prefixes
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Property names and prefix for logical unit property group
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli/* Property names for stmf properties */
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli#define DEFAULT_LU_STATE "default_lu_state"
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli#define DEFAULT_TARGET_PORT_STATE "default_target_state"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Property names for view entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* Property group suffix for provider data */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define STMF_PROVIDER_DATA_PREFIX "provider_data_pg_"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define STMF_PROVIDER_DATA_PROP_PREFIX "provider_data_prop"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define STMF_PROVIDER_DATA_PROP_TYPE "provider_type"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define STMF_PROVIDER_DATA_PROP_SET_COUNT "provider_data_set_cnt"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define STMF_PROVIDER_DATA_PROP_COUNT "provider_data_cnt"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define STMF_SMF_READ_ATTR "solaris.smf.read.stmf"
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli#define STMF_PS_LU_ONLINE "default_lu_online"
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli#define STMF_PS_LU_OFFLINE "default_lu_offline"
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli#define STMF_PS_TARGET_PORT_ONLINE "default_target_online"
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli#define STMF_PS_TARGET_PORT_OFFLINE "default_target_offline"
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto/* END STORE PROPERTY DEFINITIONS */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* service name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* limits and flag values */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sigHandler
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Catch the signal and set the global signalsCaught to the signal received
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * signalsCaught will be used by releaseSignal to raise this signal when
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we're done processing our critical code.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iPsAddRemoveGroupMember
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add or remove a member for a given group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pgName - Property group name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupName - group name to which the member is added/removed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * memberName - member to be added/removed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * addRemoveFlag - ADD/REMOVE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiPsAddRemoveGroupMember(char *pgName, char *groupName, char *memberName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(pgName != NULL && groupName != NULL && memberName != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Init the service handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate scf resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((tran = scf_transaction_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((prop = scf_property_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((valueIter = scf_iter_create(handle)) == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "scf alloc resource failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the service property group handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Begin the transaction
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "start transaction for %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We're changing an existing property by adding a propval
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * There are no add semantics in libscf for a property value. We'll
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * need to read in the current properties and apply them all to the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set and then add the one we were asked to add or omit the one
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we were asked to remove.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_transaction_property_change(tran, entry, groupName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the property handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_pg_get_property(pg, groupName, prop) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Value lookup is used to lookup the existing values
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "scf value alloc for %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * valueIter is the iterator handle, create the resource
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_iter_property_values(valueIter, prop) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "iter values for %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate value resource pointers.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We need a value resource for each value as value pointers passed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to libscf cannot be destroyed until the commit or destroy on the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * transaction is done.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We're using GROUP_MEMBER_ALLOC initially. If it's not large
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * enough, we'll realloc on the fly
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte valueSet = (scf_value_t **)calloc(1, sizeof (*valueSet)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Iterate through the existing values
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (scf_iter_next_value(valueIter, valueLookup) == 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_value_get_ustring(valueLookup, buf, MAXNAMELEN) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Check for existing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we're adding, it's an error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we're removing, we skip it and simply not
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * add it to the set. Subtraction by omission.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create the value resource for this iteration
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "scf value alloc for %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the value
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_value_set_ustring(valueSet[i], buf) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "set value for %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now add the value
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_entry_add_value(entry, valueSet[i]) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "add value for %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * realloc if we've hit the previous alloc size
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set valueArraySize to final allocated length
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * so we can use it to destroy the resources correctly
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we're adding, we have one more step. Add the member to the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * propval list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now create the new entry
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "scf value alloc for %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the new member name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_value_set_ustring(valueSet[i], memberName) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "set value for %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add the new member
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_entry_add_value(entry, valueSet[i]) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "add value for %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Yes, we're finally done. We actually added or removed one entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * from the list.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((commitRet = scf_transaction_commit(tran)) != 1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction commit for %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free valueSet scf resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < valueArraySize; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now free the pointer array to the resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iPsAddRemoveLuViewEntry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Adds or removes a view entry name property for a given logical unit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * property group. There is one logical unit property group for every logical
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * unit that has one or more associated view entries.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * luPgName - Property group name of logical unit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * viewEntryPgName - Property group name of view entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * addRemoveFlag - ADD_VE/REMOVE_VE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiPsAddRemoveLuViewEntry(char *luPgName, char *viewEntryPgName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(luPgName != NULL || viewEntryPgName != NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(!(addRemoveFlag != ADD && addRemoveFlag != REMOVE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Init the service handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate scf resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((tran = scf_transaction_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((prop = scf_property_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "scf alloc resource failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the LU property group */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_service_get_pg(svc, luPgName, pg) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* if it doesn't exist, create it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* we need to create the VE_CNT property */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Begin the transaction
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "start transaction for %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create the STMF_VE_CNT property. This will keep the current
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * total view entries for this logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_transaction_property_new(tran, entry, STMF_VE_CNT,
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill "transaction property new %s/%s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The STMF_VE_CNT property already exists. Just update
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction property %s/%s change "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the STMF_VE_CNT property
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_pg_get_property(pg, STMF_VE_CNT, prop) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill luPgName, STMF_VE_CNT, scf_strerror(scf_error()));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the STMF_VE_CNT value
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s value failed - %s",
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill luPgName, STMF_VE_CNT, scf_strerror(scf_error()));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now get the actual value from the value handle
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get count value %s/%s failed - %s",
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill luPgName, STMF_VE_CNT, scf_strerror(scf_error()));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Reset the value resource as it is used below
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Check if this is the last one being removed */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Delete the pg and get out if this is the last
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * view entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the view entry count
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add the value to the transaction entry
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill luPgName, STMF_VE_CNT, scf_strerror(scf_error()));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create a transaction entry resource for the view entry name
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "scf transaction entry alloc %s/%s failed - %s",
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill luPgName, viewEntryPgName, scf_strerror(scf_error()));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If adding, create a property with the view entry name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_transaction_property_new(tran, entryVeName,
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill "transaction property new %s/%s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If removing, delete the existing property with the view
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * entry name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_transaction_property_delete(tran, entryVeName,
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill "transaction property delete %s/%s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Commit property transaction
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((commitRet = scf_transaction_commit(tran)) != 1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction commit for %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iPsAddViewEntry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add a view entry property group and optionally, a logical unit property
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * group if it does not exist.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * luName - ascii hexadecimal logical unit identifier
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * viewEntryName - name of view entry (VIEW_ENTRY_nn)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * viewEntry - pointer to stmfViewEntry structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiPsAddViewEntry(char *luPgName, char *viewEntryPgName, stmfViewEntry *viewEntry)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte scf_transaction_entry_t *entry[VIEW_ENTRY_STRUCT_CNT];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte assert(luPgName != NULL || viewEntryPgName != NULL ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Init the service handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate scf resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((tran = scf_transaction_create(handle)) == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "scf alloc resource failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allocate value and entry resources for scf
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < VIEW_ENTRY_STRUCT_CNT; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (((value[i] = scf_value_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((entry[i] = scf_entry_create(handle)) == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "scf alloc resource failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create the View Entry property group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_service_add_pg(svc, viewEntryPgName, SCF_GROUP_APPLICATION,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add the view entry as properties on the view entry group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Begin property update transaction
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "start transaction for add %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add allHosts property
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction property new %s/%s "
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill "failed - %s", viewEntryPgName, STMF_VE_ALLHOSTS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set the allHosts value */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add the allHosts value to the transaction
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_entry_add_value(entry[i], value[i]) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create hostGroup property
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction property new %s/%s "
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill "failed - %s", viewEntryPgName, STMF_VE_HOSTGROUP,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the value for hostGroup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_value_set_ustring(value[i], viewEntry->hostGroup) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add the hostGroup value to the transaction entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_entry_add_value(entry[i], value[i]) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create the allTargets property
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction property new %s/%s "
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill "failed - %s", viewEntryPgName, STMF_VE_ALLTARGETS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the allTargets value
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add the allTargets value to the transaction
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_entry_add_value(entry[i], value[i]) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create targetGroup property
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction property new %s/%s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the value for targetGroup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_value_set_ustring(value[i], viewEntry->targetGroup) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add targetGroup value to the transaction
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_entry_add_value(entry[i], value[i]) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create the luNbr property
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_transaction_property_new(tran, entry[i], STMF_VE_LUNBR,
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction property new %s/%s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the luNbr
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_value_set_opaque(value[i], (char *)viewEntry->luNbr,
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill viewEntryPgName, STMF_VE_LUNBR, scf_strerror(scf_error()));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add luNbr to the transaction entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_entry_add_value(entry[i], value[i]) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill viewEntryPgName, STMF_VE_LUNBR, scf_strerror(scf_error()));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now that we've successfully added the view entry,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * update the logical unit property group or create
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * it if it does not exist
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = iPsAddRemoveLuViewEntry(luPgName, viewEntryPgName, ADD);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we did not add the view entry name to the logical unit,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * make sure we do not commit the transaction
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Commit property transaction
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((commitRet = scf_transaction_commit(tran)) != 1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction commit for add %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we did not commit, try to remove the view entry name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * from the logical unit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If that fails, we're now inconsistent.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte backoutRet = iPsAddRemoveLuViewEntry(luPgName, viewEntryPgName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We are still in an error scenario even though the remove
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lu view entry succeeded.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* if there was an error, delete the created pg if one was created */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free value and entry scf resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (i > 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0; j < VIEW_ENTRY_STRUCT_CNT; j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psClearProviderData
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * providerName - name of provider data to clear
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortepsClearProviderData(char *providerName, int providerType)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (providerName == NULL || (providerType != STMF_LU_PROVIDER_TYPE &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate scf resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "scf alloc resource failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * create the property group name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * delete provider property group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iPsCreateDeleteGroup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Creates or deletes a group (target or host)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When creating a group, two properties are created. One to hold the group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * name and the other to hold the group members.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pgName - Property group name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupName - group name to create
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * addRemoveFlag - ADD_GROUP/REMOVE_GROUP
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiPsCreateDeleteGroup(char *pgRefName, char *groupName, int addRemoveFlag)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate scf resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((tran = scf_transaction_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((prop = scf_property_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((propIter = scf_iter_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "scf alloc resource failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the property group being modified
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_service_get_pg(svc, pgRefName, pg) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * propIter is the iterator handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_iter_pg_properties(propIter, pg) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "iter properties for %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Iterate through the group names.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we find it in the list, it's an error when addRemoveFlag == ADD.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (scf_iter_next_property(propIter, prop) == 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_property_get_name(prop, buf1, sizeof (buf1)) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get name from %s iter failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Skip over member list properties
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * buf1 contains the name for REMOVE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we're adding, we need to create a new property name for the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (groupIdx = 0; groupIdx < GROUP_MAX; groupIdx++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "buffer overflow on property name %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now create the new member list property for the new group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "buffer overflow on property name %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * buf1 now contains the name of the property if it was found in the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * list in the case of delete or the next available property name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in the case of create
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * buf2 now contains the member list property name
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "start transaction for %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create the property 'group name'
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is the container for the group name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_transaction_property_new(tran, entry1, buf1,
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction property new %s/%s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_value_set_ustring(value, groupName) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create the property 'group list'
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * This is the container for the group members
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_transaction_property_new(tran, entry2, buf2,
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction property new %s/%s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Delete the property 'group name'
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_transaction_property_delete(tran, entry1, buf1)
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill "transaction property delete %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Delete the property 'group list'
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_transaction_property_delete(tran, entry2, buf2)
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction property delete %s/%s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((commitRet = scf_transaction_commit(tran)) != 1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction commit for %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iPsGetGroupList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pgName - Property group name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupList - pointer to pointer to stmfGroupList structure. On success,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * contains the list of groups
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiPsGetGroupList(char *pgName, stmfGroupList **groupList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate scf resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((prop = scf_property_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((propIter = scf_iter_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "scf alloc resource failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * propIter is the iterator handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_iter_pg_properties(propIter, pg) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "iter properties for %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (scf_iter_next_property(propIter, prop) == 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_property_get_name(prop, buf, sizeof (buf)) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get name from %s iter failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Skip over member list properties
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * propIter is the iterator handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_iter_pg_properties(propIter, pg) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "iter properties for %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *groupList = (stmfGroupList *)calloc(1, sizeof (stmfGroupList) +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * In order to get a list of groups, simply get all of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * properties that are not member list properties, i.e. the group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * name properties.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * It's possible for this list to grow beyond what was originally
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * read so just ensure we're not writing beyond our allocated buffer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * by ensuring i < memberCnt
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((scf_iter_next_property(propIter, prop) == 1) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_property_get_name(prop, buf, sizeof (buf)) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get name from %s iter failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Skip over member list properties
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_value_get_ustring(value, buf, sizeof (buf)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(buf, (*groupList)->name[i++], strlen(buf));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iPsGetGroupMemberList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pgName - Property group name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupName - group name (host group or target group)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupMemberList - pointer to pointer to stmfGroupProperties structure. On
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * success, contains the list of group members
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiPsGetGroupMemberList(char *pgName, char *groupName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * init the service handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate scf resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((prop = scf_property_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((valueIter = scf_iter_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((valueLookup = scf_value_create(handle)) == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "scf alloc resource failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get the service property group handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the property handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * based on the target or host group name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_pg_get_property(pg, groupName, prop) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * valueIter is the iterator handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_iter_property_values(valueIter, prop) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (scf_iter_next_value(valueIter, valueLookup) == 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_value_get_ustring(valueLookup, buf, MAXNAMELEN) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * valueIter is the iterator handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_iter_property_values(valueIter, prop) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *groupMemberList = (stmfGroupProperties *)calloc(1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (stmfGroupProperties) + memberCnt * sizeof (stmfDevid));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((scf_iter_next_value(valueIter, valueLookup) == 1) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((len = scf_value_get_ustring(valueLookup, buf, MAXNAMELEN))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free resources
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = iPsGetSetPersistType(persistType, handle, svc, GET);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Free resources
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ret = iPsGetSetPersistType(&persistType, handle, svc, SET);
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Free resources
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szetoiPsGetSetPersistType(uint8_t *persistType, scf_handle_t *handle,
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto ((tran = scf_transaction_create(handle)) == NULL) ||
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* set to default */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * get stmf data property group
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (scf_service_get_pg(svc, STMF_DATA_GROUP, pg) == -1) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* find persistence property */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Get the persistence property
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (scf_pg_get_property(pg, STMF_PERSIST_TYPE, prop) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* no persist property found */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (ret == STMF_PS_ERROR_NOT_FOUND || getSet == SET) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * If we have no persistType property, go ahead
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * and create it with the user specified value or
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * the default value.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Begin the transaction
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "start transaction for %s failed - %s",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* is this a SET or GET w/error? */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * set the persist type
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (scf_value_set_astring(value, iPersistType) == -1) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * add the value to the transaction
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if ((commitRet = scf_transaction_commit(tran)) != 1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction commit for %s failed - %s",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* reset return value */
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto /* get the persist property */
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property value %s/%s failed - %s",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Get the value of the persist property
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (scf_value_get_astring(value, iPersistTypeGet, MAXNAMELEN)
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get string value %s/%s failed - %s",
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto if (strcmp(iPersistTypeGet, STMF_PS_PERSIST_NONE) == 0) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto } else if (strcmp(iPersistTypeGet, STMF_PS_PERSIST_SMF) == 0) {
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * Free resources.
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * handle and svc should not be free'd here. They're
8fe960854f0d52e2e8a80ba68e8621a5ac6a866dtim szeto * free'd elsewhere
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapallipsSetStmfProp(int propType, char *propVal)
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli return (iPsGetSetStmfProp(propType, propVal, SET));
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapallipsGetStmfProp(int propType, char *propVal)
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli return (iPsGetSetStmfProp(propType, propVal, GET));
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalliiPsGetSetStmfProp(int propType, char *propVal, int getSet)
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli scf_transaction_entry_t *entry = NULL;
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if (propVal == NULL || (getSet != GET && getSet != SET)) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli * Init the service handle
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli * Allocate scf resources
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if (((pg = scf_pg_create(handle)) == NULL) ||
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli ((prop = scf_property_create(handle)) == NULL) ||
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli ((entry = scf_entry_create(handle)) == NULL) ||
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli ((tran = scf_transaction_create(handle)) == NULL) ||
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli ((value = scf_value_create(handle)) == NULL)) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli syslog(LOG_ERR, "scf alloc resource failed - %s",
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli (void) strcpy(stmfPropGet, psStmfPropVal);
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli case STMF_DEFAULT_TARGET_PORT_STATE :
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli psStmfProp = DEFAULT_TARGET_PORT_STATE;
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli psStmfPropVal = STMF_PS_TARGET_PORT_ONLINE;
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli (void) strcpy(stmfPropGet, psStmfPropVal);
894ed91c969ef99fbc1891bf8de449cc1f11f518Milan Jurik "offline") == 0) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli case STMF_DEFAULT_TARGET_PORT_STATE :
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli psStmfProp = DEFAULT_TARGET_PORT_STATE;
894ed91c969ef99fbc1891bf8de449cc1f11f518Milan Jurik "offline") == 0) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli * get stmf data property group
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if (scf_service_get_pg(svc, STMF_DATA_GROUP, pg) == -1) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if (scf_error() == SCF_ERROR_NOT_FOUND) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli syslog(LOG_ERR, "get pg %s failed - %s",
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli STMF_DATA_GROUP, scf_strerror(scf_error()));
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli * get the stmf props property, if exists
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if (scf_pg_get_property(pg, psStmfProp, prop) == -1) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if (scf_error() == SCF_ERROR_NOT_FOUND) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli syslog(LOG_ERR, "start transaction for %s/%s "
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli "failed - %s", STMF_DATA_GROUP, psStmfProp,
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli /* if stmf prop is not found or while setting the prop */
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if (ret == STMF_PS_ERROR_NOT_FOUND || getSet == SET) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli * Begin the transaction
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if (scf_transaction_start(tran, pg) == -1) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli syslog(LOG_ERR, "start transaction for %s failed - %s",
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli STMF_DATA_GROUP, scf_strerror(scf_error()));
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if (scf_transaction_property_new(tran, entry,
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli psStmfProp, SCF_TYPE_ASTRING) == -1) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli syslog(LOG_ERR, "transaction property new "
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli "%s/%s failed - %s", STMF_DATA_GROUP,
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli psStmfProp, scf_strerror(scf_error()));
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if (scf_transaction_property_change(tran, entry,
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli psStmfProp, SCF_TYPE_ASTRING) == -1) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli "transaction property change "
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli "%s/%s failed - %s",
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli * set stmf prop value
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if (scf_value_set_astring(value, psStmfPropVal) == -1) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli syslog(LOG_ERR, "set value %s/%s failed - %s",
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli * add the value to the transaction
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if (scf_entry_add_value(entry, value) == -1) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli syslog(LOG_ERR, "add value %s/%s failed - %s",
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if ((commitRet = scf_transaction_commit(tran)) != 1) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli syslog(LOG_ERR, "transaction commit for %s"
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if (scf_property_get_value(prop, value) == -1) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli syslog(LOG_ERR, "get property value "
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli "%s/%s failed - %s",
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli /* get stmfProp */
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if (scf_value_get_astring(value, stmfPropGet, MAXNAMELEN)
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli syslog(LOG_ERR, "get string value %s/%s failed - %s",
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli if (strcmp(stmfPropGet, STMF_PS_LU_ONLINE) == 0) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli } else if (strcmp(stmfPropGet, STMF_PS_LU_OFFLINE) == 0) {
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli } else if (strcmp(stmfPropGet, STMF_PS_TARGET_PORT_ONLINE)
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli } else if (strcmp(stmfPropGet, STMF_PS_TARGET_PORT_OFFLINE)
4b31676f89e318c11400fc0c4defc802da29222fsrivijitha dugganapalli * Free resources.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Initialize scf stmf service access
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * handle - returned handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * service - returned service handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Both handle and service must be destroyed by the caller
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiPsInit(scf_handle_t **handle, scf_service_t **service)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*handle = scf_handle_create(SCF_VERSION)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((*service = scf_service_create(*handle)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "scf_service_create failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((scope = scf_scope_create(*handle)) == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_handle_get_scope(*handle, SCF_SCOPE_LOCAL, scope) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "scf_handle_get_scope failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_scope_get_service(scope, STMF_SERVICE, *service) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "scf_scope_get_service failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get and check the version number
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = iPsGetServiceVersion(&version, *handle, *service);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* we only need destroy the scope here */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * called by iPsInit only
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iPsGetServiceVersion
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiPsGetServiceVersion(uint64_t *version, scf_handle_t *handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((prop = scf_property_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((tran = scf_transaction_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "scf alloc resource failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get stmf data property group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_service_get_pg(svc, STMF_DATA_GROUP, pg) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* create the group */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * create the property group.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* reset return value */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* find version property */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the version property
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_pg_get_property(pg, STMF_VERSION_NAME, prop) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* no version property found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we have no version property, go ahead
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and create it. We're obviously making an assumption
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * here that someone did not delete the existing property
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and that this is the initial set and the initial call
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * to iPsInit.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If they did delete it, this will simply plant this
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * library's version on this service. That may or may not be
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * correct and we have no way of determining that.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Begin the transaction
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "start transaction for %s failed - %s",
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill "transaction property new %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * set the version number
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * add the value to the transaction
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((commitRet = scf_transaction_commit(tran)) != 1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction commit for %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* reset return value */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the version property */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_pg_get_property(pg, STMF_VERSION_NAME, prop) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the actual value of the view entry count property
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get count value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free resources.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * handle and svc should not be free'd here. They're
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * free'd elsewhere
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iPsGetActualGroupName
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pgName - Property group name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupName - requested group name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * actualName - actual group name to reference (len must be >= MAXNAMELEN)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiPsGetActualGroupName(char *pgName, char *groupName, char *actualName)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate scf resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((prop = scf_property_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((propIter = scf_iter_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "scf alloc resource failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get group list property group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * propIter is the iterator handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_iter_pg_properties(propIter, pg) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "iter properties for %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Iterate through group properties searching for the requested
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * group name. When we find it, we need to get the property name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * since it refers to the actual group name.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* initialize to not found */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (scf_iter_next_property(propIter, prop) == 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_property_get_name(prop, actualName, MAXNAMELEN) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get name from %s iter failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Skip over non-member list properties
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strstr(actualName, STMF_MEMBER_LIST_SUFFIX)) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_value_get_ustring(value, buf, sizeof (buf)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When we find a match, set success and break
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * if we didn't find it, ret is set to STMF_PS_ERROR_GROUP_NOT_FOUND
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psAddHostGroupMember
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add a host group member to a host group,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input: groupName - name of group to which the member is added
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * memberName - name of group member to add
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortepsAddHostGroupMember(char *groupName, char *memberName)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = iPsGetActualGroupName(STMF_HOST_GROUPS, groupName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (snprintf(groupPropListName, sizeof (groupPropListName),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s-%s", groupPropName, STMF_MEMBER_LIST_SUFFIX) >
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "buffer overflow on property name %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iPsAddRemoveGroupMember(STMF_HOST_GROUPS, groupPropListName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psAddTargetGroupMember
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add a target port group member to a target group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Input: groupName - name of group to which the member is added
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * memberName - name of group member to add. Must be nul terminated.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortepsAddTargetGroupMember(char *groupName, char *memberName)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = iPsGetActualGroupName(STMF_TARGET_GROUPS, groupName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (snprintf(groupPropListName, sizeof (groupPropListName),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s-%s", groupPropName, STMF_MEMBER_LIST_SUFFIX) >
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "buffer overflow on property name %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iPsAddRemoveGroupMember(STMF_TARGET_GROUPS, groupPropListName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psAddViewEntry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * luGuid - logical unit identifier
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * viewEntry - pointer to viewEntry allocated by the caller that contains
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the values to set for this view entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortepsAddViewEntry(stmfGuid *lu, stmfViewEntry *viewEntry)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char guidAsciiBuf[33]; /* size of ascii hex 16 byte guid with NULL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* grab the signal hold lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hold signals until we're done
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Convert to ASCII uppercase hexadecimal string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(guidAsciiBuf, sizeof (guidAsciiBuf),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lu->guid[0], lu->guid[1], lu->guid[2], lu->guid[3], lu->guid[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lu->guid[5], lu->guid[6], lu->guid[7], lu->guid[8], lu->guid[9],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lu->guid[10], lu->guid[11], lu->guid[12], lu->guid[13],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(scfLuPgName, sizeof (scfLuPgName), "%s-%s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(viewEntryPgName, sizeof (viewEntryPgName));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Format of view entry property group name:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * VE-<view_entry_name>-<lu_name>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(viewEntryPgName, sizeof (viewEntryPgName),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s-%d-%s", STMF_VE_PREFIX, viewEntry->veIndex, guidAsciiBuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = iPsAddViewEntry(scfLuPgName, viewEntryPgName, viewEntry);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Okay, we're done. Release the signals
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Don't set this as an STMF_PS_ERROR_*. We succeeded
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the requested operation. But we do need to log it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "Unable to release one or more signals - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* release the signal hold lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psCheckService
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Checks whether service exists
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psCreateHostGroup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupName - name of group to create
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iPsCreateDeleteGroup(STMF_HOST_GROUPS, groupName, ADD));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psCreateTargetGroup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupName - name of group to create
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iPsCreateDeleteGroup(STMF_TARGET_GROUPS, groupName, ADD));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psDeleteHostGroup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupName - name of group to delete
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iPsCreateDeleteGroup(STMF_HOST_GROUPS, groupName, REMOVE));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psDeleteTargetGroup
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupName - name of group to delete
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iPsCreateDeleteGroup(STMF_TARGET_GROUPS, groupName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psGetHostGroupList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupList - pointer to pointer to stmfGroupList. Contains the list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of host groups on successful return.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iPsGetGroupList(STMF_HOST_GROUPS, groupList));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psGetLogicalUnitList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0, j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate scf resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "scf alloc resource failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pgIter is the iterator handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "iter property groups failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_pg_get_name(pg, buf, sizeof (buf)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Only count LU property groups
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(buf, STMF_LU_PREFIX, strlen(STMF_LU_PREFIX)) == 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pgIter is the iterator handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "iter property groups failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *guidList = (stmfGuidList *)calloc(1, sizeof (stmfGuidList) +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * it's possible for entries to be added/removed while we're retrieving
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the property groups. Just make sure we don't write beyond our
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allocated buffer by checking to ensure i < guidCnt.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((scf_iter_next_pg(pgIter, pg) == 1) && (i < guidCnt)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_pg_get_name(pg, buf, sizeof (buf)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Only use LU property groups
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (strncmp(buf, STMF_LU_PREFIX, strlen(STMF_LU_PREFIX)) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &guid[0], &guid[1], &guid[2], &guid[3], &guid[4], &guid[5],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &guid[6], &guid[7], &guid[8], &guid[9], &guid[10],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &guid[11], &guid[12], &guid[13], &guid[14], &guid[15]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (j = 0; j < sizeof (stmfGuid); j++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(&outGuid, (*guidList)->guid[i++].guid, sizeof (stmfGuid));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psGetTargetGroupList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupList - pointer to pointer to stmfGroupList. Contains the list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * of target groups on successful return.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iPsGetGroupList(STMF_TARGET_GROUPS, groupList));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psGetHostGroupMemberList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupName - group name for which to retrieve a member list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupMemberList - pointer to pointer to stmfGroupProperties list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortepsGetHostGroupMemberList(char *groupName, stmfGroupProperties **groupMemberList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = iPsGetActualGroupName(STMF_HOST_GROUPS, groupName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (snprintf(groupPropListName, sizeof (groupPropListName),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s-%s", groupPropName, STMF_MEMBER_LIST_SUFFIX) >
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "buffer overflow on property name %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iPsGetGroupMemberList(STMF_HOST_GROUPS, groupPropListName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psGetTargetGroupMemberList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupName - group name for which to retrieve a member list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupMemberList - pointer to pointer to stmfGroupProperties list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = iPsGetActualGroupName(STMF_TARGET_GROUPS, groupName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (snprintf(groupPropListName, sizeof (groupPropListName),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s-%s", groupPropName, STMF_MEMBER_LIST_SUFFIX) >
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "buffer overflow on property name %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iPsGetGroupMemberList(STMF_TARGET_GROUPS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * qsort function
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * sort on veIndex
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte stmfViewEntry *v1 = (stmfViewEntry *)p1, *v2 = (stmfViewEntry *)p2;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (-1);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psGetViewEntryList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * luGuid - identifier of logical unit for which to retrieve a view entry list
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * viewEntryList - pointer to pointer to stmfViewEntryList. It will be allocated
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * on successful return.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortepsGetViewEntryList(stmfGuid *lu, stmfViewEntryList **viewEntryList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char guidAsciiBuf[33]; /* size of ascii hex 16 byte guid with NULL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate scf resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((prop = scf_property_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((propIter = scf_iter_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "scf alloc resource failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Convert to ASCII uppercase hexadecimal string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(guidAsciiBuf, sizeof (guidAsciiBuf),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lu->guid[0], lu->guid[1], lu->guid[2], lu->guid[3], lu->guid[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lu->guid[5], lu->guid[6], lu->guid[7], lu->guid[8], lu->guid[9],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lu->guid[10], lu->guid[11], lu->guid[12], lu->guid[13],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* form the LU property group name (LU-<guid>) */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(luPgName, sizeof (luPgName), "%s-%s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the property group associated with this LU */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_service_get_pg(svc, luPgName, pg) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get the view entry count property */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_pg_get_property(pg, STMF_VE_CNT, prop) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill luPgName, STMF_VE_CNT, scf_strerror(scf_error()));
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property value %s/%s failed - %s",
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill luPgName, STMF_VE_CNT, scf_strerror(scf_error()));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the actual value of the view entry count property
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get integer value %s/%s failed - %s",
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill luPgName, STMF_VE_CNT, scf_strerror(scf_error()));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * propIter is the iterator handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_iter_pg_properties(propIter, pg) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "iter properties for %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * alloc the list based on the view entry count
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (stmfViewEntryList) + veCnt * sizeof (stmfViewEntry));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iterate through the view entry properties to find the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * view entries
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while (scf_iter_next_property(propIter, prop) == 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* find match for view entry property */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We've exceeded our alloc limit
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * break with error
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &((*viewEntryList)->ve[i]))) != STMF_PS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set the list count */
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "scf iter %s properties failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We're sorting the final list here based on the veIndex
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If we don't, the caller is going to have to do it to reap
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * some intelligent output.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte qsort((void *)&((*viewEntryList)->ve[0]), (*viewEntryList)->cnt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iPsGetViewEntry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * viewEntryPgName - view entry property group name to retrieve
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * viewEntry - pointer to stmfViewEntry structure allocated by the caller
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteiPsGetViewEntry(char *viewEntryPgName, stmfViewEntry *viewEntry)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate scf resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((prop = scf_property_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "scf alloc resource failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * get the service property group view entry handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_service_get_pg(svc, viewEntryPgName, pg) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * format is: VE-<veIndex>-GUID
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Set the index */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte viewEntry->veIndex = atoi(strtok(++indexPtr, "-"));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get allHosts property */
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set allHosts */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_value_get_boolean(value, (uint8_t *)&scfBool) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get hostGroup property */
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set hostGroup */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(groupName, viewEntry->hostGroup, strlen(groupName));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get allTargets property */
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set allTargets */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_value_get_boolean(value, (uint8_t *)&scfBool) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get targetGroup property */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_pg_get_property(pg, STMF_VE_TARGETGROUP, prop) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set targetGroup */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bcopy(groupName, viewEntry->targetGroup, strlen(groupName));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* get luNbr property */
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set luNbr */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_value_get_opaque(value, (char *)viewEntry->luNbr,
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get opaque value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* set luNbrValid to true since we just got it */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psRemoveHostGroupMember
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Remove a host group member from a host group,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupName - name of group from which the member is removed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * memberName - name of group member to remove
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortepsRemoveHostGroupMember(char *groupName, char *memberName)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = iPsGetActualGroupName(STMF_HOST_GROUPS, groupName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (snprintf(groupPropListName, sizeof (groupPropListName),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s-%s", groupPropName, STMF_MEMBER_LIST_SUFFIX) >
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "buffer overflow on property name %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iPsAddRemoveGroupMember(STMF_HOST_GROUPS, groupPropListName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psRemoveTargetGroupMember
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Remove a target port group member from an target port group,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * groupName - name of group from which the member is removed
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * memberName - name of group member to remove
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortepsRemoveTargetGroupMember(char *groupName, char *memberName)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ret = iPsGetActualGroupName(STMF_TARGET_GROUPS, groupName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (snprintf(groupPropListName, sizeof (groupPropListName),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s-%s", groupPropName, STMF_MEMBER_LIST_SUFFIX) >
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "buffer overflow on property name %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (iPsAddRemoveGroupMember(STMF_TARGET_GROUPS, groupPropListName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psGetProviderData
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Retrieves an nvlist on a per provider basis
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * providerName - property group name to use
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * nvl - nvlist to retrieve
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortepsGetProviderData(char *providerName, nvlist_t **nvl, int providerType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char dataPropertyName[STMF_PROVIDER_DATA_PROP_NAME_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (providerName == NULL || (providerType != STMF_LU_PROVIDER_TYPE &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * create the property group name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate scf resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((prop = scf_property_create(handle)) == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "scf alloc resource failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Retrieve the existing property group.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the STMF_PROVIDER_DATA_PROP_COUNT property
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_pg_get_property(pg, STMF_PROVIDER_DATA_PROP_COUNT,
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the STMF_PROVIDER_DATA_PROP_COUNT value
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now get the actual value from the value handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_value_get_count(value, &blockCnt) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get integer value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Has the caller requested the token to be set? */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the STMF_PROVIDER_DATA_PROP_SET_COUNT property
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If it doesn't exist, we assume it to be zero.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_pg_get_property(pg, STMF_PROVIDER_DATA_PROP_SET_COUNT,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the STMF_PROVIDER_DATA_PROP_SET_COUNT value
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill "get property value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now get the actual value from the value handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and set the caller's token
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_value_get_count(value, setToken) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill "get integer value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < blockCnt; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte bzero(dataPropertyName, sizeof (dataPropertyName));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * create the name to use for the property
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(dataPropertyName, sizeof (dataPropertyName),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_pg_get_property(pg, dataPropertyName, prop) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the data block offset
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &nvlistEncoded[blockOffset], STMF_PROVIDER_DATA_PROP_SIZE);
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get opaque property value %s/%s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlist_unpack(nvlistEncoded, nvlistEncodedSize, nvl, 0) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psGetProviderDataList
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Retrieves the list of providers that currently store persistent data
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * providerList - pointer to a pointer to an stmfProviderList structure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * On success, this will contain the list of providers
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * currently storing persistent data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortepsGetProviderDataList(stmfProviderList **providerList)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i = 0, j;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate scf resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((prop = scf_property_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "scf alloc resource failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pgIter is the iterator handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "iter property groups failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_pg_get_name(pg, buf, sizeof (buf)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Only count LU property groups
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * pgIter is the iterator handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "iter property groups failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (stmfProviderList) + providerCnt * sizeof (stmfProvider));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * it's possible for entries to be added/removed while we're retrieving
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the property groups. Just make sure we don't write beyond our
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allocated buffer by checking to ensure i < providerCnt.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte while ((scf_iter_next_pg(pgIter, pg) == 1) && (i < providerCnt)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_pg_get_name(pg, buf, sizeof (buf)) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Only use provider data property groups
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the STMF_PROVIDER_DATA_PROP_TYPE property
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_pg_get_property(pg, STMF_PROVIDER_DATA_PROP_TYPE,
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the STMF_PROVIDER_DATA_PROP_TYPE value
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now get the actual value from the value handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_value_get_integer(value, &providerType) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get integer value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*providerList)->provider[i].providerType = providerType;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* determine offset for copy of provider name */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* copy provider name to caller's list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strncpy((*providerList)->provider[i].name, buf + j,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psSetProviderData
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Stores a packed nvlist on a per provider basis
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * providerName - property group name to use
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * nvl - nvlist to store
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * providerType - type of provider (logical unit or port)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortepsSetProviderData(char *providerName, nvlist_t *nvl, int providerType,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* represents arrays of entry and value pointers for scf */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * These declarations are for known entry and value set/get
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * operations
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char dataPropertyName[STMF_PROVIDER_DATA_PROP_NAME_SIZE];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i, j = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int addEntryAlloc = 0, deleteEntryAlloc = 0, addValueAlloc = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (providerName == NULL || (providerType != STMF_LU_PROVIDER_TYPE &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * create the property group name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Allocate scf resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((prop = scf_property_create(handle)) == NULL) ||
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ((tran = scf_transaction_create(handle)) == NULL)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "scf alloc resource failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the existing property group
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * create the property group.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Begin the transaction
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "start transaction for %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the STMF_PROVIDER_DATA_PROP_COUNT property
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_pg_get_property(pg, STMF_PROVIDER_DATA_PROP_COUNT,
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the STMF_PROVIDER_DATA_PROP_COUNT value
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_property_get_value(prop, value4) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now get the actual value from the value handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_value_get_count(value4, &oldBlockCnt) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get integer value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the STMF_PROVIDER_DATA_PROP_SET_COUNT property
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If it doesn't exist, we'll create it later after successfully
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * setting the data.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_pg_get_property(pg, STMF_PROVIDER_DATA_PROP_SET_COUNT,
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Get the STMF_PROVIDER_DATA_PROP_SET_COUNT value
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_property_get_value(prop, value5) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get property value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now get the actual value from the value handle
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_value_get_count(value5, &setCnt) == -1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "get integer value %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Compare the setCnt prop to the caller's.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * prepare the list for writing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlist_pack(nvl, &nvlistEncoded, &nvlistEncodedSize,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Determine how many chunks we need to write */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte blockCnt = nvlistEncodedSize/STMF_PROVIDER_DATA_PROP_SIZE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlistEncodedSize % STMF_PROVIDER_DATA_PROP_SIZE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* allocate entry and value resources for writing those chunks */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addEntry = (scf_transaction_entry_t **)calloc(1, sizeof (*addEntry)
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "addEntry alloc for %s failed", pgName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addValue = (scf_value_t **)calloc(1, sizeof (*addValue)
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "value alloc for %s failed", pgName);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * allocate entry delete resources for deleting anything existing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * that is more than the new block count. We could leave them around
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * without suffering any ill effects but it will be cleaner to look at
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in smf tools if they are deleted.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte deleteEntry = (scf_transaction_entry_t **)calloc(1,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (*deleteEntry) * (oldBlockCnt - blockCnt));
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "deleteEntry alloc for %s failed",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < blockCnt; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create the entry resource for the prop
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "scf value alloc for %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* bump alloc count for addEntry allocation */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * create the name to use for the property
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(dataPropertyName, sizeof (dataPropertyName),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create the new property
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_transaction_property_new(tran, addEntry[i],
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill "change %s/%s failed - %s",
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill "transaction property new %s/%s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create the value resource for the prop
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "scf value alloc for %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* bump alloc count for addValue allocation */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Set the data block offset and size
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Add the data block to the transaction entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_entry_add_value(addEntry[i], addValue[i]) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now we need to delete any chunks (properties) that are no longer
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * needed. Iterate through the rest of the chunks deleting each.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Create the entry resource for the prop
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "scf value alloc for %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * create the name to use for the property
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(dataPropertyName, sizeof (dataPropertyName),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Delete the existing property
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_transaction_property_delete(tran, deleteEntry[j++],
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "delete property %s/%s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Ensure the read_authorization property is set
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * for the group
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction property %s/%s new "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_value_set_astring(value1, STMF_SMF_READ_ATTR) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* create or change the count property */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STMF_PROVIDER_DATA_PROP_COUNT, SCF_TYPE_COUNT) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_transaction_property_change(tran, entry2,
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction property %s/%s new "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* create or change the set count property */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STMF_PROVIDER_DATA_PROP_SET_COUNT, SCF_TYPE_COUNT) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_transaction_property_change(tran, entry5,
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill "transaction property change %s/%s "
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction property new %s/%s "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* create or change the provider type property */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte STMF_PROVIDER_DATA_PROP_TYPE, SCF_TYPE_INTEGER) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_transaction_property_change(tran, entry3,
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill "transaction property change %s/%s "
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction property new %s/%s "
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill "failed - %s", pgName, STMF_PROVIDER_DATA_PROP_TYPE,
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "add value %s/%s failed - %s", pgName,
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill STMF_PROVIDER_DATA_PROP_TYPE, scf_strerror(scf_error()));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((commitRet = scf_transaction_commit(tran)) != 1) {
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "transaction commit for %s failed - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* pass the new token back to the caller if requested */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < addEntryAlloc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < addValueAlloc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < deleteEntryAlloc; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psGetViewEntry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Purpose: Get a single view entry based on the logical unit identifier and
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * view entry index
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * lu - logical unit identifier
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * viewEntryIndex - index of view entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * ve - caller allocated stmfViewEntry structure. On success, this will
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * contain the retrieved view entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortepsGetViewEntry(stmfGuid *lu, uint32_t viewEntryIndex, stmfViewEntry *ve)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char guidAsciiBuf[33]; /* size of ascii hex 16 byte guid with NULL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Convert to ASCII uppercase hexadecimal string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(guidAsciiBuf, sizeof (guidAsciiBuf),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lu->guid[0], lu->guid[1], lu->guid[2], lu->guid[3], lu->guid[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lu->guid[5], lu->guid[6], lu->guid[7], lu->guid[8], lu->guid[9],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lu->guid[10], lu->guid[11], lu->guid[12], lu->guid[13],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(luPgName, sizeof (luPgName), "%s-%s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Format of view entry property group name:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * VE-<view_entry_index>-<lu_name>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(viewEntryPgName, sizeof (viewEntryPgName),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s-%d-%s", STMF_VE_PREFIX, viewEntryIndex, guidAsciiBuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_service_get_pg(svc, viewEntryPgName, pg) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = iPsGetViewEntry(viewEntryPgName, ve)) != STMF_PS_SUCCESS) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * psRemoveViewEntry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Remove a view entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * luGuid - identifier of logical unit from which to remove view entry
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * viewEntryIndex - view entry name to remove
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_SUCCESS on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * STMF_PS_ERROR_* on failure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn FortepsRemoveViewEntry(stmfGuid *lu, uint32_t viewEntryIndex)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char guidAsciiBuf[33]; /* size of ascii hex 16 byte guid with NULL */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* grab the signal hold lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * hold signals until we're done
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Convert to ASCII uppercase hexadecimal string */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(guidAsciiBuf, sizeof (guidAsciiBuf),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lu->guid[0], lu->guid[1], lu->guid[2], lu->guid[3], lu->guid[4],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lu->guid[5], lu->guid[6], lu->guid[7], lu->guid[8], lu->guid[9],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lu->guid[10], lu->guid[11], lu->guid[12], lu->guid[13],
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(luPgName, sizeof (luPgName), "%s-%s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Format of view entry property group name:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * VE-<view_entry_index>-<lu_name>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) snprintf(viewEntryPgName, sizeof (viewEntryPgName),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "%s-%d-%s", STMF_VE_PREFIX, viewEntryIndex, guidAsciiBuf);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (scf_service_get_pg(svc, viewEntryPgName, pg) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * update the logical unit property group to remove
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the view entry and update the view entry count
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If it fails, we won't delete the property group so that
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we maintain consistency.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = iPsAddRemoveLuViewEntry(luPgName, viewEntryPgName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Delete the view entry. If this fails, we should try to add
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the logical unit view entry property group back otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we're inconsistent.
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "delete pg %s failed - %s", viewEntryPgName,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((ret = iPsAddRemoveLuViewEntry(luPgName, viewEntryPgName,
86b7dbefda771542da92c8e031c0153fd809ff01Peter Gill syslog(LOG_ERR, "add of view entry %s failed, possible"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Okay, we're done. Release the signals
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Don't set this as an STMF_PS_ERROR_*. We succeeded
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the requested operation. But we do need to log it.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte syslog(LOG_ERR, "Unable to release one or more signals - %s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Free resources
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* release the signal hold lock */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * holdSignal
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Hold SIGINT, SIGTERM, SIGQUIT until further notice.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Saves old signal mask on a per thread basis
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and saves action for the process.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Installs action for above signals.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * locks held: sigSetLock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Return existing signal mask for this thread
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pthread_sigmask(0, NULL, sigmaskRestore) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Have we set the actions for the signals we want to catch?
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sigaction(SIGQUIT, &act, ¤tActionQuit) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sigaction(SIGINT, &act, ¤tActionInt) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sigaction(SIGTERM, &act, ¤tActionTerm) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * We still need to change the mask for the current thread
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pthread_sigmask(SIG_SETMASK, &sigmask, NULL) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * releaseSignal
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Re-install the original signal mask and signal actions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Also, raise any signals that were caught during the hold period and clear
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the signal from the caught set (signalsCaught).
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * locks held: sigSetLock
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * 0 on success
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * non-zero otherwise
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sigaction(SIGQUIT, ¤tActionQuit, NULL) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sigaction(SIGINT, ¤tActionInt, NULL) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sigaction(SIGTERM, ¤tActionTerm, NULL) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Restore previous signal mask for this thread
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (pthread_sigmask(SIG_SETMASK, sigmaskRestore, NULL) != 0) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Now raise signals that were raised while we were held