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
1a1a84a324206b6b1f5f704ab166c4ebf78aed76Peter Dunlap * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * iSCSI session interfaces
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/scsi/adapters/iscsi_if.h> /* ioctl interfaces */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* protocol structs and defines */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic iscsi_targetparam_entry_t *iscsi_targetparam_create();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Initializes the target list structure. Called from iscsi_attach.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Frees target param list and destroys the list lock.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_targetparam_entry_t *curr_entry, *tmp_entry;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte kmem_free(curr_entry, sizeof (iscsi_targetparam_entry_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Creates a target param entry and adds it to the target param
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * entry list.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte target = kmem_alloc(sizeof (iscsi_targetparam_entry_t),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (void) strlcpy((char *)target->target_name, (char *)name,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* assign unique key for the target */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /* Add new target to the target list */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns a target param entry's oid given the target name. If the target
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * param entry cannot be found one is created and the new oid is returned.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte curr_entry = iscsi_targetparam_get_next_entry(NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if ((name_length == strlen((char *)curr_entry->target_name)) &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte curr_entry = iscsi_targetparam_get_next_entry(curr_entry);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns a target param entry's target name given its oid. If the oid cannot
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * be found, NULL is returned.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteuchar_t *iscsi_targetparam_get_name(uint32_t oid) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte curr_entry = iscsi_targetparam_get_next_entry(NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte curr_entry = iscsi_targetparam_get_next_entry(curr_entry);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Removes a target param entry from the target param entry list. The
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * oid is used to lookup the entry to be removed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte iscsi_targetparam_entry_t *prev_entry, *curr_entry;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte curr_entry = iscsi_targetparam_get_next_entry(NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte curr_entry = iscsi_targetparam_get_next_entry(curr_entry);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Returns the next element in the target param entry list. If
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * NULL is passed as the reference entry then the first item in
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * the list is returned. NULL will be returned when the last
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * element in the list is used as the reference entry.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteiscsi_targetparam_get_next_entry(iscsi_targetparam_entry_t *ref_entry) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Lock target param list.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte rw_enter(&(iscsi_targets.target_list_lock), type);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Unlock target param list.