summaryrefslogtreecommitdiff
path: root/usr/src/lib/libiscsitgt
diff options
context:
space:
mode:
authorJim Dunham <James.Dunham@Sun.COM>2010-03-09 15:50:06 -0500
committerJim Dunham <James.Dunham@Sun.COM>2010-03-09 15:50:06 -0500
commitab003da878e3fe36b164e1856f9e15a78384c9eb (patch)
treec12489dfbd3d4d3d0a38b6d9996651cea7ec998d /usr/src/lib/libiscsitgt
parent1d5a4f25f16de80ff14501395a3d2646696a928b (diff)
downloadillumos-joyent-ab003da878e3fe36b164e1856f9e15a78384c9eb.tar.gz
PSARC/2010/006 EOF of iSCSI Target Daemon
6914623 Remove iSCSI Target Daemon from ON Consolidation
Diffstat (limited to 'usr/src/lib/libiscsitgt')
-rw-r--r--usr/src/lib/libiscsitgt/Makefile56
-rw-r--r--usr/src/lib/libiscsitgt/Makefile.com54
-rw-r--r--usr/src/lib/libiscsitgt/amd64/Makefile31
-rw-r--r--usr/src/lib/libiscsitgt/common/gen.c266
-rw-r--r--usr/src/lib/libiscsitgt/common/if_gen.c48
-rw-r--r--usr/src/lib/libiscsitgt/common/if_zfs.c155
-rw-r--r--usr/src/lib/libiscsitgt/common/iscsitgt_impl.h211
-rw-r--r--usr/src/lib/libiscsitgt/common/libiscsitgt.h578
-rw-r--r--usr/src/lib/libiscsitgt/common/llib-liscsitgt30
-rw-r--r--usr/src/lib/libiscsitgt/common/mapfile-vers72
-rw-r--r--usr/src/lib/libiscsitgt/common/xml.c914
-rw-r--r--usr/src/lib/libiscsitgt/i386/Makefile30
-rw-r--r--usr/src/lib/libiscsitgt/sparc/Makefile30
-rw-r--r--usr/src/lib/libiscsitgt/sparcv9/Makefile31
14 files changed, 0 insertions, 2506 deletions
diff --git a/usr/src/lib/libiscsitgt/Makefile b/usr/src/lib/libiscsitgt/Makefile
deleted file mode 100644
index 58d09d3c9b..0000000000
--- a/usr/src/lib/libiscsitgt/Makefile
+++ /dev/null
@@ -1,56 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../Makefile.lib
-
-SUBDIRS = $(MACH)
-$(BUILD64)SUBDIRS += $(MACH64)
-
-all := TARGET= all
-clean := TARGET= clean
-clobber := TARGET= clobber
-install := TARGET= install
-lint := TARGET= lint
-test := TARGET= test
-
-HDRS= libiscsitgt.h iscsitgt_impl.h
-HDRDIR= common
-
-.KEEP_STATE:
-
-all clean clobber install lint: $(SUBDIRS)
-
-install_h: $(ROOTHDRS)
-
-check: $(CHECKHDRS)
-
-$(SUBDIRS): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
-
-include ../Makefile.targ
diff --git a/usr/src/lib/libiscsitgt/Makefile.com b/usr/src/lib/libiscsitgt/Makefile.com
deleted file mode 100644
index 3d4559c7fd..0000000000
--- a/usr/src/lib/libiscsitgt/Makefile.com
+++ /dev/null
@@ -1,54 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-LIBRARY= libiscsitgt.a
-VERS= .1
-OBJECTS= if_zfs.o if_gen.o xml.o gen.o
-
-include ../../Makefile.lib
-include ../../Makefile.rootfs
-
-SRCDIR = ../common
-
-LIBS = $(DYNLIB) $(LINTLIB)
-LDLIBS += -lscf -lc
-$(DYNLIB) := LDLIBS += -lxml2
-SRCS = $(OBJECTS:%.o=$(SRCDIR)/%.c)
-
-$(LINTLIB) := SRCS = $(SRCDIR)/$(LINTSRC)
-
-CFLAGS += $(CCVERBOSE)
-CPPFLAGS += -I/usr/include/libxml2 -I$(SRCDIR) \
- -I../../../cmd/iscsi/iscsitgtd
-
-.KEEP_STATE:
-
-all: $(LIBS)
-
-lint: lintcheck
-
-include ../../Makefile.targ
diff --git a/usr/src/lib/libiscsitgt/amd64/Makefile b/usr/src/lib/libiscsitgt/amd64/Makefile
deleted file mode 100644
index 2e8cdecf75..0000000000
--- a/usr/src/lib/libiscsitgt/amd64/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../Makefile.com
-include ../../Makefile.lib.64
-
-install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/libiscsitgt/common/gen.c b/usr/src/lib/libiscsitgt/common/gen.c
deleted file mode 100644
index 12bc7bad64..0000000000
--- a/usr/src/lib/libiscsitgt/common/gen.c
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Support routines for library
- */
-#include <errno.h>
-#include <strings.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <libscf.h>
-#include <door.h>
-#include <libxml/xmlreader.h>
-#include <sys/mman.h>
-
-#include "iscsitgt_impl.h"
-
-#define WAIT_FOR_SERVICE 15
-#define WAIT_FOR_DOOR 15
-static char *service = "system/iscsitgt:default";
-
-static Boolean_t check_and_online(int);
-
-tgt_node_t *
-tgt_door_call(char *str, int smf_flags)
-{
- tgt_node_t *n = NULL;
- door_arg_t d;
- int s;
- int allocated;
- xmlTextReaderPtr r;
- char *door_buf = NULL;
-
- /*
- * Setup the door pointers for the initial try.
- */
- allocated = MAX(DOOR_MIN_SPACE, strlen(str) + 1);
- if ((door_buf = malloc(allocated)) == NULL)
- return (NULL);
- (void) strncpy(door_buf, str, allocated);
- bzero(&d, sizeof (d));
- d.data_ptr = door_buf;
- d.data_size = allocated;
- d.rbuf = door_buf;
- d.rsize = allocated;
-
- /*
- * It's entirely possible that we'll be sending this request more
- * than once. In the case of a list operation it's unknown how much
- * data will be required, so the request will be sent and the daemon
- * will return information on how large of a buffer is needed.
- * It possible that the second request, with a larger buffer, also
- * fails with not enough space since between the first and second
- * calls a third party could have created another target increasing
- * the space required. This is not an error, just need to handle it.
- */
- do {
- /*
- * Open the door and if that doesn't work or the first door call
- * fails, try to bring the service online. Then repeat one
- * more time. If the second attempt at the door_call fails
- * then bail out.
- */
- if (((s = open(ISCSI_TARGET_MGMT_DOOR, 0)) == -1) ||
- (door_call(s, &d) == -1)) {
- if (s != -1) {
- (void) close(s);
- s = -1;
- }
- if (check_and_online(smf_flags) == False) {
- goto error;
- } else if ((s = open(ISCSI_TARGET_MGMT_DOOR, 0)) ==
- -1) {
- goto error;
- } else if (door_call(s, &d) == -1) {
- goto error;
- }
- }
-
- if (d.rbuf == NULL)
- goto error;
-
- if ((r = (xmlTextReaderPtr)xmlReaderForMemory(d.rbuf,
- strlen(d.rbuf), NULL, NULL, 0)) == NULL)
- goto error;
-
- while (xmlTextReaderRead(r) == 1)
- if (tgt_node_process(r, &n) == False)
- break;
- xmlFreeTextReader(r);
-
- /*
- * Check to see if our request failed to provide enough
- * buffer room. This can occur if:
- * (1) The request caused an error and the message
- * is larger than the request.
- * (2) We're requesting a configuration list which is
- * fairly large and need to reissue the request with
- * a larger buffer, which the daemon is kind enough
- * to tell us the size needed.
- */
- if (tgt_find_value_int(n, XML_ELEMENT_MORESPACE,
- &allocated) == True) {
-
- tgt_node_free(n);
- n = NULL;
-
- /*
- * It's possible that we've already done a request
- * with a larger buffer, but before we could reissue
- * the request the results got bigger. Targets being
- * added to the configuration would be the common
- * cause of this condition.
- */
- if (door_buf != NULL)
- free(door_buf);
-
- if ((door_buf = malloc(allocated)) == NULL)
- goto error;
-
- (void) strncpy(door_buf, str, allocated);
- d.data_ptr = door_buf;
- d.data_size = allocated;
- d.rbuf = door_buf;
- d.rsize = allocated;
- }
-
- (void) close(s);
- s = -1;
- } while (n == NULL);
-
-error:
- if (door_buf)
- free(door_buf);
- (void) close(s);
- return (n);
-}
-
-static Boolean_t
-is_online(void)
-{
- char *s;
- Boolean_t rval = False;
-
- if (getenv("iscsitgt_no_daemon") != NULL) {
- rval = True;
- } else {
- if ((s = smf_get_state(service)) != NULL) {
- if (strcmp(s, SCF_STATE_STRING_ONLINE) == 0)
- rval = True;
- free(s);
- }
- }
-
- return (rval);
-}
-
-static Boolean_t
-is_auto_enabled(void)
-{
- scf_simple_prop_t *prop;
- uint8_t *ret;
- Boolean_t rval = True;
-
- if ((prop = scf_simple_prop_get(NULL, service, "application",
- "auto_enable")) == NULL)
- return (True);
-
- if ((ret = scf_simple_prop_next_boolean(prop)) != NULL)
- rval = (*ret != 0);
-
- scf_simple_prop_free(prop);
-
- return (rval);
-}
-
-static Boolean_t
-check_and_online(int smf_flags)
-{
- int i;
- int fd;
- door_arg_t d;
-
- if (!is_online()) {
- if (!is_auto_enabled())
- return (False);
-
- if (smf_enable_instance(service, smf_flags) != 0)
- return (False);
-
- for (i = 0; i < WAIT_FOR_SERVICE; i++) {
- if (is_online() == True)
- break;
- (void) sleep(1);
- }
-
- if (i == WAIT_FOR_SERVICE)
- return (False);
- }
-
- for (i = 0; i < WAIT_FOR_DOOR; i++) {
- if ((fd = open(ISCSI_TARGET_MGMT_DOOR, 0)) >= 0) {
- /*
- * There's at least a file with the same name as our
- * door. Let's see if someone is currently answering
- * by sending an empty XML request.
- */
- d.data_ptr = "<config></config>";
- d.data_size = strlen(d.data_ptr) + 1;
- d.desc_ptr = NULL;
- d.desc_num = 0;
- d.rbuf = NULL;
- d.rsize = 0;
-
- if (door_call(fd, &d) == 0) {
- /*
- * The daemon is now ready to handle requests.
- */
- (void) close(fd);
- return (True);
- } else
- (void) close(fd);
-
- }
- if (!is_online())
- break;
- (void) sleep(1);
- }
- return (False);
-}
-
-/*
- * Not using Boolean_t here, since that is a
- * private type to the library
- */
-int
-iscsitgt_svc_online()
-{
- return ((is_online() == True) ? 0 : 1);
-}
diff --git a/usr/src/lib/libiscsitgt/common/if_gen.c b/usr/src/lib/libiscsitgt/common/if_gen.c
deleted file mode 100644
index 1ab74664fe..0000000000
--- a/usr/src/lib/libiscsitgt/common/if_gen.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <libiscsitgt.h>
-
-/*
- * iscsitgt_init -- Create a handle for each daemon
- */
-/*ARGSUSED*/
-iscsit_handle_t
-iscsitgt_init(char *host)
-{
- return (NULL);
-}
-
-/*
- * iscsitgt_fini -- free resources allocated by iscsitgt_init()
- */
-/*ARGSUSED*/
-void
-iscsitgt_fini(iscsit_handle_t h)
-{
-}
diff --git a/usr/src/lib/libiscsitgt/common/if_zfs.c b/usr/src/lib/libiscsitgt/common/if_zfs.c
deleted file mode 100644
index 3528872286..0000000000
--- a/usr/src/lib/libiscsitgt/common/if_zfs.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Methods for ZFS to notify the iSCSI Target about which ZVOLs
- * need to be made available.
- */
-
-#include <libiscsitgt.h>
-#include <strings.h>
-#include <errno.h>
-#include <libscf.h>
-#include <errcode.h>
-
-#include "iscsitgt_impl.h"
-
-/*
- * iscsitgt_zfs_share -- share a ZFS volume as an iSCSI target
- */
-int
-iscsitgt_zfs_share(const char *dataset)
-{
- char *str = NULL;
- tgt_node_t *n;
- int code;
-
- tgt_buf_add_tag(&str, "create", Tag_Start);
- tgt_buf_add_tag(&str, "zfs", Tag_Start);
- tgt_buf_add(&str, "name", dataset);
- tgt_buf_add_tag(&str, "zfs", Tag_End);
- tgt_buf_add_tag(&str, "create", Tag_End);
-
- if ((n = tgt_door_call(str, SMF_TEMPORARY)) == NULL) {
- if (iscsitgt_svc_online() != 0) {
- errno = EPERM;
- } else {
- errno = EINVAL;
- }
- free(str);
- return (-1);
- }
-
- if (strcmp(n->x_name, XML_ELEMENT_ERROR) == 0 &&
- tgt_find_value_int(n, XML_ELEMENT_CODE, &code) == True) {
- if (code == 1000) {
- free(str);
- tgt_node_free(n);
- return (0);
- } else {
- errno = (code == ERR_NO_PERMISSION) ? EPERM : EINVAL;
- }
- } else {
- errno = EINVAL;
- }
- free(str);
- tgt_node_free(n);
- return (-1);
-}
-
-/*
- * iscsitgt_zfs_unshare -- unshare a ZFS volume
- */
-int
-iscsitgt_zfs_unshare(const char *dataset)
-{
- char *str = NULL;
- tgt_node_t *n;
- int code;
-
- tgt_buf_add_tag(&str, "delete", Tag_Start);
- tgt_buf_add_tag(&str, "zfs", Tag_Start);
- tgt_buf_add(&str, "name", dataset);
- tgt_buf_add_tag(&str, "zfs", Tag_End);
- tgt_buf_add_tag(&str, "delete", Tag_End);
-
- if ((n = tgt_door_call(str, SMF_TEMPORARY)) == NULL) {
- errno = EINVAL;
- free(str);
- return (-1);
- }
-
- if (strcmp(n->x_name, XML_ELEMENT_ERROR) == 0 &&
- tgt_find_value_int(n, XML_ELEMENT_CODE, &code) == True) {
- if (code == 1000) {
- free(str);
- tgt_node_free(n);
- return (0);
- } else {
- errno = (code == ERR_NO_PERMISSION) ? EPERM : EINVAL;
- }
- } else {
- errno = EINVAL;
- }
-
- free(str);
- tgt_node_free(n);
- return (-1);
-}
-
-int
-iscsitgt_zfs_is_shared(const char *dataset)
-{
- char *str = NULL;
- tgt_node_t *n;
- int code;
-
- tgt_buf_add_tag(&str, "modify", Tag_Start);
- tgt_buf_add_tag(&str, "zfs", Tag_Start);
- tgt_buf_add(&str, "name", dataset);
- tgt_buf_add(&str, XML_ELEMENT_VALIDATE, XML_VALUE_TRUE);
- tgt_buf_add_tag(&str, "zfs", Tag_End);
- tgt_buf_add_tag(&str, "modify", Tag_End);
-
- if ((n = tgt_door_call(str, SMF_TEMPORARY)) == NULL) {
- errno = EINVAL;
- free(str);
- return (-1);
- }
- if (strcmp(n->x_name, XML_ELEMENT_ERROR) == 0 &&
- tgt_find_value_int(n, XML_ELEMENT_CODE, &code) == True &&
- code == 1000) {
- free(str);
- tgt_node_free(n);
- return (1);
- }
-
- free(str);
- tgt_node_free(n);
- return (0);
-}
diff --git a/usr/src/lib/libiscsitgt/common/iscsitgt_impl.h b/usr/src/lib/libiscsitgt/common/iscsitgt_impl.h
deleted file mode 100644
index 415273871f..0000000000
--- a/usr/src/lib/libiscsitgt/common/iscsitgt_impl.h
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _ISCSITGT_IMPL_H
-#define _ISCSITGT_IMPL_H
-
-/*
- * Block comment which describes the contents of this file.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <libxml/xmlreader.h>
-
-#ifndef MIN
-#define MIN(x, y) ((x) < (y) ? (x) : (y))
-#endif
-#ifndef MAX
-#define MAX(x, y) ((x) > (y) ? (x) : (y))
-#endif
-
-/*
- * Solaris typedefs boolean_t to be an enum with B_TRUE and B_FALSE.
- * MacOS X typedefs boolean_t to be an int with #defines for TRUE & FALSE
- * I like the use of enum's for return codes so that compilers can catch
- * sloppy coding practices so I've defined a Boolean_t which is unique here.
- */
-typedef enum {
- False = 0,
- True = 1
-} Boolean_t;
-
-#ifndef DTYPE_OSD
-#define DTYPE_OSD 0x11
-#endif
-
-#define DOOR_MIN_SPACE 128
-
-#define ISCSI_TARGET_MGMT_DOOR "/var/run/iscsi_tgt_door"
-/*
- * XML element defines.
- */
-#define XML_ELEMENT_ERROR "error"
-#define XML_ELEMENT_CODE "code"
-#define XML_ELEMENT_MESSAGE "message"
-#define XML_ELEMENT_TRANSVERS "transport-version"
-#define XML_ELEMENT_PROPS "props"
-#define XML_ELEMENT_DATAOUT "data-out-size"
-#define XML_ELEMENT_BASEDIR "base-directory"
-#define XML_ELEMENT_CHAPSECRET "chap-secret"
-#define XML_ELEMENT_DELETE_CHAPSECRET "delete-chap-secret"
-#define XML_ELEMENT_CHAPNAME "chap-name"
-#define XML_ELEMENT_DELETE_CHAPNAME "delete-chap-name"
-#define XML_ELEMENT_RAD_ACCESS "radius-access"
-#define XML_ELEMENT_RAD_SERV "radius-server"
-#define XML_ELEMENT_DELETE_RAD_SERV "delete-radius-server"
-#define XML_ELEMENT_RAD_SECRET "radius-secret"
-#define XML_ELEMENT_DELETE_RAD_SECRET "delete-radius-secret"
-#define XML_ELEMENT_ISNS_ACCESS "isns-access"
-#define XML_ELEMENT_ISNS_SERV "isns-server"
-#define XML_ELEMENT_ISNS_SERVER_STATUS "isns-server-status"
-#define XML_ELEMENT_FAST "fast-write-ack"
-#define XML_ELEMENT_NAME "name"
-#define XML_ELEMENT_ACL "acl"
-#define XML_ELEMENT_ACLLIST "acl-list"
-#define XML_ELEMENT_TPGT "tpgt"
-#define XML_ELEMENT_TPGTLIST "tpgt-list"
-#define XML_ELEMENT_SIZE "size"
-#define XML_ELEMENT_LUN "lun"
-#define XML_ELEMENT_LUNLIST "lun-list"
-#define XML_ELEMENT_TYPE "type"
-#define XML_ELEMENT_ALIAS "alias"
-#define XML_ELEMENT_BACK "backing-store"
-#define XML_ELEMENT_DELETE_BACK "delete-backing-store"
-#define XML_ELEMENT_TARG "target"
-#define XML_ELEMENT_INIT "initiator"
-#define XML_ELEMENT_ZFS "zfs"
-#define XML_ELEMENT_ADMIN "admin"
-#define XML_ELEMENT_INAME "iscsi-name"
-#define XML_ELEMENT_MAXRECV "maxrecv"
-#define XML_ELEMENT_IPADDR "ip-address"
-#define XML_ELEMENT_IPADDRLIST "ip-address-list"
-#define XML_ELEMENT_ALL "all"
-#define XML_ELEMENT_VERBOSE "verbose"
-#define XML_ELEMENT_LIST "list"
-#define XML_ELEMENT_RESULT "result"
-#define XML_ELEMENT_TIMECON "time-connected"
-#define XML_ELEMENT_READCMDS "read-commands"
-#define XML_ELEMENT_WRITECMDS "write-commands"
-#define XML_ELEMENT_READBLKS "read-blks"
-#define XML_ELEMENT_WRITEBLKS "write-blks"
-#define XML_ELEMENT_STATS "statistics"
-#define XML_ELEMENT_CONN "connection"
-#define XML_ELEMENT_LUNINFO "lun-information"
-#define XML_ELEMENT_VID "vid"
-#define XML_ELEMENT_PID "pid"
-#define XML_ELEMENT_GUID "guid"
-#define XML_ELEMENT_DTYPE "dtype"
-#define XML_ELEMENT_IOSTAT "iostat"
-#define XML_ELEMENT_MACADDR "mac-addr"
-#define XML_ELEMENT_MGMTPORT "mgmt-port"
-#define XML_ELEMENT_ISCSIPORT "iscsi-port"
-#define XML_ELEMENT_TARGLOG "target-log"
-#define XML_ELEMENT_DBGLVL "dbg-lvl"
-#define XML_ELEMENT_LOGLVL "qlog-lvl"
-#define XML_ELEMENT_DBGDAEMON "daemonize"
-#define XML_ELEMENT_ENFORCE "enforce-strict-guid"
-#define XML_ELEMENT_VERS "version"
-#define XML_ELEMENT_MMAP_LUN "mmap-lun"
-#define XML_ELEMENT_RPM "rpm"
-#define XML_ELEMENT_HEADS "heads"
-#define XML_ELEMENT_CYLINDERS "cylinders"
-#define XML_ELEMENT_SPT "spt"
-#define XML_ELEMENT_BPS "bps"
-#define XML_ELEMENT_INTERLEAVE "interleave"
-#define XML_ELEMENT_PARAMS "params"
-#define XML_ELEMENT_MAXCMDS "max-outstanding-cmds"
-#define XML_ELEMENT_THIN_PROVO "thin-provisioning"
-#define XML_ELEMENT_DISABLE_TPGS "disable-tpgs"
-#define XML_ELEMENT_STATUS "status"
-#define XML_ELEMENT_PROGRESS "progress"
-#define XML_ELEMENT_TIMESTAMPS "time-stamps"
-#define XML_ELEMENT_INCORE "in-core"
-#define XML_ELEMENT_VALIDATE "validate"
-#define XML_ELEMENT_MORESPACE "more-space-required"
-#define XML_VALUE_TRUE "true"
-#define XML_ELEMENT_PGR_PERSIST "PGR-persist"
-#define XML_ELEMENT_PGR_BASEDIR "PGR-basedir"
-
-typedef enum {
- NodeFree,
- NodeAlloc,
- NodeName,
- NodeValue
-} tgt_node_state;
-
-typedef enum { MatchName, MatchBoth } match_type_t;
-
-typedef struct tgt_node {
- struct tgt_node *x_parent,
- *x_child,
- *x_sibling,
- *x_attr;
- char *x_name,
- *x_value;
- tgt_node_state x_state;
-} tgt_node_t;
-
-typedef enum val_type { Tag_String, Tag_Start, Tag_End } val_type_t;
-typedef enum xml_val_type { String, Int, Uint64 } xml_val_type_t;
-
-tgt_node_t *tgt_door_call(char *str, int smf_flags);
-void tgt_dump2buf(tgt_node_t *t, char **buf);
-
-tgt_node_t *tgt_node_alloc(char *name, xml_val_type_t type, void *value);
-void tgt_node_free(tgt_node_t *x);
-void tgt_node_replace(tgt_node_t *parent, tgt_node_t *child, match_type_t m);
-Boolean_t tgt_node_remove(tgt_node_t *parent, tgt_node_t *child,
- match_type_t m);
-tgt_node_t *tgt_node_next(tgt_node_t *n, char *name, tgt_node_t *cur);
-tgt_node_t *tgt_node_next_child(tgt_node_t *n, char *name, tgt_node_t *cur);
-tgt_node_t *tgt_node_dup(tgt_node_t *n);
-tgt_node_t *tgt_node_find(tgt_node_t *n, char *name);
-void tgt_node_add(tgt_node_t *p, tgt_node_t *c);
-void tgt_node_add_attr(tgt_node_t *p, tgt_node_t *a);
-Boolean_t tgt_node_process(xmlTextReaderPtr r, tgt_node_t **node);
-
-void tgt_buf_add(char **b, char *element, const char *cdata);
-void tgt_buf_add_tag(char **b, const char *str, val_type_t type);
-void tgt_buf_add_tag_and_attr(char **b, char *str, char *attr);
-
-Boolean_t tgt_xml_encode(uint8_t *ip, size_t ip_size, char **buf,
- size_t *buf_size);
-Boolean_t tgt_xml_decode(char *buf, uint8_t **ip, size_t *ip_size);
-Boolean_t tgt_find_value_str(tgt_node_t *n, char *name, char **value);
-Boolean_t tgt_find_value_int(tgt_node_t *n, char *name, int *value);
-Boolean_t tgt_find_value_intchk(tgt_node_t *n, char *name, int *value);
-Boolean_t tgt_find_value_boolean(tgt_node_t *n, char *name, Boolean_t *value);
-Boolean_t tgt_find_attr_str(tgt_node_t *n, char *attr, char **value);
-Boolean_t tgt_update_value_str(tgt_node_t *node, char *name, char *str);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _ISCSITGT_IMPL_H */
diff --git a/usr/src/lib/libiscsitgt/common/libiscsitgt.h b/usr/src/lib/libiscsitgt/common/libiscsitgt.h
deleted file mode 100644
index cf01a62fea..0000000000
--- a/usr/src/lib/libiscsitgt/common/libiscsitgt.h
+++ /dev/null
@@ -1,578 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _LIBISCSITGT_H
-#define _LIBISCSITGT_H
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Management API for the iSCSI Target.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * These includes resolve
- */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/iscsi_protocol.h>
-#include <sys/scsi/generic/inquiry.h>
-
-#define EUI64_SIZE 16
-#define VID_SIZE 8
-#define PID_SIZE 16
-
-/*
- * []------------------------------------------------------------------[]
- * | Structures and enums returned by the list functions |
- * []------------------------------------------------------------------[]
- */
-
-typedef enum { LU_Offline, LU_Online } iscsit_status_t;
-typedef enum { Target, Initiator, TPGT } iscsit_obj_type_t;
-
-/*
- * Logical Unit (LU) Structure.
- * Each iSCSI Target has one or more Logical Units.
- */
-typedef struct iscsit_lu {
- /* This is the LU number for SCSI commands */
- int l_num;
-
- /* Globally unique identifier */
- uint8_t l_guid[EUI64_SIZE];
-
- /*
- * VID/PID used in SCSI INQUIRY responses
- */
- char l_vid[VID_SIZE],
- l_pid[PID_SIZE];
- /*
- * Value will be one of DTYPE_DIRECT, DTYPE_SEQUENTIAL, etc ...
- * Look at sys/scsi/generic/inquiry.h for full list
- */
- uint8_t l_dtype;
-
- /* Size of device in blocks */
- diskaddr_t l_size;
-
- iscsit_status_t l_status;
-} iscsit_lu_t;
-
-/*
- * iSCSI Session information.
- */
-typedef struct iscsit_conn {
- char c_name[ISCSI_MAX_NAME_LEN],
- *c_alias;
-} iscsit_conn_t;
-
-typedef struct iscsit_target {
- /* This is the full IQN name of the target */
- char t_name[ISCSI_MAX_NAME_LEN];
-
- /*
- * The Alias which is the same as "friendly name" used during the
- * creation of the target.
- */
- char *t_alias;
-
- /*
- * The number of Logical Units associated with this target.
- * There will always be at least one LU with a value of 0.
- * If there are more than LU the order is not guaranteed.
- */
- int t_lu_count;
- iscsit_lu_t **t_lu_list;
-
- /*
- * A list of initiator which may access this target. This list
- * may be 0 in length.
- */
- int t_acl_count;
- char **t_acl_list;
-
- /*
- * Target Portal Group Tags. A value of zero for the count
- * is valid.
- */
- int t_tpgt_count;
- char **t_tpgt_list;
-
- /*
- * The number of sessions that are currently attached to the
- * target. Zero is valid.
- */
- int t_conn_count;
- iscsit_conn_t **t_conn_list;
-} iscsit_target_t;
-
-/*
- * Information stored locally about initiators. Local initiator information
- * is setup when administrators wish to control access to each target. The
- * use of iSNS will be the prefered method once it's supported.
- */
-typedef struct iscsit_initiator {
- char i_name[ISCSI_MAX_NAME_LEN],
- *i_chap_name;
- /*
- * While the target daemon has the CHAP secret available it's
- * never returned. The CHAP name and secret can be changed at
- * any time. This boolean will indicate if the CHAP secret is set
- * and if so will cause the daemon to perform unidirectional
- * authentication.
- */
- boolean_t i_chap_secret_set;
-} iscsit_initiator_t;
-
-/*
- * The list of IP addresses associated with a Target Portal Group Tag
- */
-typedef struct iscsit_tpgt {
- int t_ip_count;
- struct sockaddr_storage **t_ip_list;
-} iscsit_tpgt_t;
-
-/*
- * These are values which are used globally through the target daemon.
- */
-typedef struct iscsit_admin {
- /*
- * This is the targets CHAP information. When an initiator needs
- * to authenticate the target these values are used when creating
- * the response.
- */
- char *a_chap_name;
- boolean_t a_chap_secret_set;
-
- /*
- * The location of the target configuration and default storage for LUs
- */
- char *a_base_directory;
-
- struct sockaddr_storage a_radius_server;
- boolean_t a_radius_secret_set,
- a_isns_discovery;
- struct sockaddr_storage a_isns_ip;
- boolean_t a_fast_write_ack;
-} iscsit_admin_t;
-
-typedef void *iscsit_handle_t;
-
-/*
- * []------------------------------------------------------------------[]
- * | Funtion Prototypes |
- * []------------------------------------------------------------------[]
- */
-
-/*
- * []------------------------------------------------------------------[]
- * | Functions for ZFS |
- * []------------------------------------------------------------------[]
- */
-/*
- * iscsitgt_zfs_share -- advertise a ZFS volume through iSCSI
- * iscsitgt_zfs_unshare -- unadvertise a ZFS volume through iSCSI
- *
- * dataset = this must be a valid ZFS dataset which has a "type" property
- * of "volume".
- *
- * These functions will return 0 on success and -1 on failure setting errno
- * thusly:
- *
- * ENODEV - dataset not found
- * EINVAL - a share parameter has an invalid value
- * ENOSYS - the option string cannot be understood for any other reason
- */
-int iscsitgt_zfs_share(const char *dataset);
-int iscsitgt_zfs_unshare(const char *dataset);
-
-/*
- * iscsitgt_zfs_is_shared -- returns 1 and 0 otherwise
- */
-int iscsitgt_zfs_is_shared(const char *dataset);
-
-/*
- * []------------------------------------------------------------------[]
- * | Functions to create handles which are used by methods defined below|
- * []------------------------------------------------------------------[]
- */
-/*
- * iscsitgt_init -- Create a handle for each daemon
- *
- * A future release will enable this library to work to control multiple
- * daemons on different hosts. For now, the argument 'host' should be
- * set to NULL which will indicate the local host.
- */
-iscsit_handle_t iscsitgt_init(char *host);
-
-/*
- * iscsitgt_fini -- free resources allocated by iscsitgt_init()
- */
-void iscsitgt_fini(iscsit_handle_t h);
-
-/*
- * []------------------------------------------------------------------[]
- * | Funtions for creating base objects |
- * []------------------------------------------------------------------[]
- */
-/*
- * iscsitgt_creat_target -- creates a new target/lu
- *
- * h = This is handle which indicates to which target the request is sent.
- * If NULL, the target daemon on the current host is used.
- * friendly_name = any ASCII string with the following restrictions.
- * - it must be no more than 163 characters
- * - it must only contain charcters from the set of 'a-z', 'A-Z', '0-9',
- * ':', '.', or '-'
- * The friendly_name will also be used as the iSCSI TargetAlias which
- * is sent to the initiator as part of the log in parameters.
- * lun = If the friendly_name has never been used before then lun must be 0.
- * If friendly_name has already been created other luns will be created
- * under that target. 0 <= lun <= 65535. NOTE: Using LUNs larger than
- * 255 is not guaranteed to work for all initiators.
- * size = The requested size for the device in blocks. There must be
- * available space on the device for the create to succeed. size may
- * be zero if, and only if, a 'backing' argument is given which exists.
- * dtype = This indicates which type of emulation is performed by the
- * daemon. Currently DTYPE_DIRECT, DTYPE_SEQUENTIAL, and DTYPE_UNKNOWN
- * are supported. A dtype of DTYPE_UNKNOWN indicates to the daemon
- * that a pass through mode should be used. For the pass through mode
- * to work 'backing' must be a character device which supports the USCSI
- * ioctl. For ZVOLs the dtype should be DTYPE_DIRECT.
- * backing = optional location for the backing store. Normally the storage
- * for the LU is created in the directory supplied to iscsit_mod_adm_store().
- * If the 'backing' file name doesn't exist *and* a valid device 'size' is
- * given then the backing store will be created in that location. When the
- * target/lu is removed this backing store will also be removed.
- *
- * Return codes:
- * EINVAL = one or more of the arguments are invalid
- * ENOSPC = No space remains to create the backing store.
- * EEXIST = A target with the same friendly_name already exists
- */
-int iscsitgt_creat_target(iscsit_handle_t h, char *friendly_name,
- int lun, diskaddr_t size, int dtype, char *backing);
-
-/*
- * iscsitgt_creat_initiator -- creates an initiator object
- *
- * Associates a fully compliant iSCSI name (IQN or EUI type) with
- * a really human readable name.
- *
- * h = Handle used to communicate with remote target daemons. A NULL
- * value may be used to indicate that the local host target daemon
- * friendly_name = Any ASCII string.
- * iqn_name = An initiator IQN or EUI string. There will be no validation
- * of the name to determine if it complies with RFC3720. This way if
- * an initiator has a poorly formed name we can still be configured to
- * work with it.
- *
- * Return codes:
- * 0 = success
- * EEXIST = The friendly_name is already used.
- */
-int iscsitgt_creat_initiator(iscsit_handle_t h, char *friendly_name,
- char *iqn_name);
-
-/*
- * iscsitgt_creat_tpgt -- Create a Target Portal Group Tag
- *
- * Once a TPGT object has been created iscsitgt_add_tpgt_ip would be used
- * to associate certain IP addresses with this TPGT. This is used to
- * limit which NICs connections are accepted on for a given target.
- * Once a TPGT is setup it can be added to a target using:
- * iscsitgt_add_target_tpgt().
- *
- * h = See iscsitgt_creat_target
- * tpgt_num = a value between 1 and 65535 inclusive
- *
- * Return codes:
- * 0 = success
- * EEXIST = A tpgt with that number already exists.
- * EINVAL = TPGT must be a value between 1 and 65535 inclusive
- */
-int iscsitgt_creat_tpgt(iscsit_handle_t h, int tpgt_num);
-
-/*
- * []------------------------------------------------------------------[]
- * | Funtions for removing base objects |
- * []------------------------------------------------------------------[]
- */
-
-/*
- * iscsitgt_rem_target -- Removes a target/LU from the system
- *
- * Logical Unit Number 0 *must* be the last LUN removed from a target
- * If not, an error will be returned. When LUN0 is removed all references
- * to friendly_name are also removed from the system. e.g. Once the LU's
- * are removed there's nothing else required to remove the target.
- *
- * h = See iscsitgt_creat_target()
- * friendly_name = This is the same name used during the creation of
- * the target.
- * lun = Logical Unit Number
- *
- * Return codes:
- * 0 = success
- * ENOENT = either friendly_name wasn't found or lun not found
- * EINVAL = attempt made to remove LUN0 while other LUs still exist.
- */
-int iscsitgt_rem_target(iscsit_handle_t h, char *friendly_name,
- int lun);
-
-/*
- * iscsitgt_rem_initiator -- Removes initiator object
- *
- * This method removes just the initiator object, but not any references
- * to this object. For example let's say an initiator was called
- * payroll_server and that this server was replaced with a new server
- * that had the same function, but with a new IQN value and CHAP secret.
- * The user of this library could then remove the initiator object
- * and create a new one with the changes *without* needing to update all
- * of the target objects that have a reference to 'payroll_server' in
- * their ACLs. This is a security feature. If a target has a reference
- * to an initiator object which doesn't exist, nobody will be able to
- * log into the target. If the daemon we're to remove all references
- * along with the object it would then be possible for an initiator to
- * log into the target during the time the target didn't have a reference.
- *
- * h = See iscsitgt_creat_target()
- * friendly_name = same value as that used during create.
- *
- * Return codes:
- * 0 = success
- * ENOENT = Can't find friendly_name
- */
-int iscsitgt_rem_initiator(iscsit_handle_t h, char *friendly_name);
-
-/*
- * iscsitgt_rem_tpgt -- Removes a tpgt object
- *
- * Similar in function to iscsitgt_rem_initiator. This method only
- * removes the TPGT object, but not any references to the object. This
- * alows the administrator to remove an old TPGT and create a new one
- * without needing to update each and every target first.
- *
- * h = See iscsitgt_creat_target
- * tpgt_num = value used during create
- *
- * Return codes:
- * 0 = success
- * ENOENT = tpgt_num wasn't found
- * EINVAL = a value outside of the accepted range for tpgt_num was used.
- */
-int iscsitgt_rem_tpgt(iscsit_handle_t h, int tpgt_num);
-
-/*
- * []------------------------------------------------------------------[]
- * | Funtions for adding attributes to base objects |
- * []------------------------------------------------------------------[]
- */
-/*
- * iscsitgt_add_target_initiator -- Adds an initiator object to ACL for target
- *
- * h = See iscsitgt_creat_target
- * friendly_name = Existing target
- * initiator = name of initiator object which doesn't need to exist before
- * it's added.
- *
- * Return codes:
- * 0 = success
- * ENOENT = friendly_name doesn't exist.
- */
-int iscsitgt_add_target_initiator(iscsit_handle_t h, char *friendly_name,
- char *initiator);
-
-/*
- * iscsitgt_add_target_tpgt -- adds TPGT to the target
- *
- * h = See iscsitgt_creat_target()
- * friendly_name = Must be a valid target object name
- * tpgt_num = While the TPGT object doesn't need to exist, the value will
- * be validated to see if it's within the valid range of 1 to 65535 inclusive
- *
- * Return codes:
- * 0 = success
- * ENOENT = friendly_name not found
- * EINVAL = tpgt_num is not within the valid range.
- */
-int iscsitgt_add_target_tpgt(iscsit_handle_t h, char *friendly_name,
- int tpgt_num);
-
-/*
- * iscsitgt_add_tpgt_ip -- Adds IP address to TPGT object
- *
- * Return codes:
- * 0 = success
- * ENOENT = tpgt_num doesn't exist
- * EINVAL = tpgt_num is not within the valid range
- */
-int iscsitgt_add_tpgt_ip(iscsit_handle_t h, int tpgt_num,
- struct sockaddr_storage *s);
-
-/*
- * []------------------------------------------------------------------[]
- * | Funtions for deleting attributes from base objects |
- * []------------------------------------------------------------------[]
- */
-/*
- * iscsitgt_del_target_initiator -- Removes initiator from target ACL
- *
- * h = See iscsitgt_creat_target()
- * friendly_name = target object
- * initiator = initiator object to remove from ACL
- *
- * Return codes:
- * 0 = success
- * ENOENT = friendly_name or initiator don't exist
- */
-int iscsitgt_del_target_initiator(iscsit_handle_t h, char *friendly_name,
- char *initiator);
-
-/*
- * iscsitgt_del_target_tpgt -- Removes TPGT from specific target
- *
- * Return codes:
- * 0 = success
- * ENOENT = Either friendly_name or tpgt_num doesn't exist as a valid
- * type
- * EINVAL = tpgt_num is outside of the valid range (1 to 65535)
- */
-int iscsitgt_del_target_tpgt(iscsit_handle_t h, char *friendly_name,
- int tpgt_num);
-
-/*
- * iscsitgt_del_tpgt_ip -- Removes IP address from TPGT
- *
- * Return codes:
- * 0 = success
- * ENOENT = tpgt_num wasn't found or the IP address wasn't found within a valid
- * tpgt
- * EINVAL = tpgt_num is outside of the valid range (1 to 65535)
- */
-int iscsitgt_del_tpgt_ip(iscsit_handle_t h, int tpgt_num,
- struct sockaddr_storage *s);
-
-/*
- * []------------------------------------------------------------------[]
- * | Funtions for modifying singular attributes for base objects |
- * []------------------------------------------------------------------[]
- */
-/*
- * iscsitgt_mode_target_alias -- Modifies the TargetAlias associated with target
- *
- * By default the TargetAlias is the same as that given for the friendly_name.
- * If another name is desired then it can be changed using this interface.
- *
- * h = See iscsitgt_creat_target()
- * friendly_name = target object
- *
- * Return codes:
- * 0 = success
- * ENOENT = friendly_name doesn't exist
- */
-int iscsitgt_mod_target_alias(iscsit_handle_t h, char *friendly_name,
- char *alias);
-int iscsitgt_mod_target_maxrec(iscsit_handle_t h, char *friendly_name,
- size_t maxrecv);
-int iscsitgt_mod_initiator_chap(iscsit_handle_t h,
- char *friendly_name, char *chap_name, char *chap_secret);
-int iscsitgt_mod_adm_store(iscsit_handle_t h, char *base);
-int iscsitgt_mod_adm_chap(iscsit_handle_t h, char *chap_name,
- char *chap_secret);
-int iscsitgt_mod_adm_radius(iscsit_handle_t h, struct sockaddr_storage *s,
- char *secret);
-int iscsitgt_mod_adm_isns_discover(iscsit_handle_t h,
- boolean_t find);
-int iscsitgt_mod_adm_isns(iscsit_handle_t h,
- struct sockaddr_storage *s);
-int iscsitgt_mod_adm_fwa(iscsit_handle_t h, boolean_t enable);
-
-/*
- * []------------------------------------------------------------------[]
- * | Funtions for listing objects |
- * | |
- * | NOTE: Each of the following function have a specific free routine |
- * | which must be called to free the data. |
- * []------------------------------------------------------------------[]
- */
-/*
- * iscsit_list_find -- returns list of specific object names.
- *
- * There are three types of objects which are manipulated by these
- * interfaces (Target, Initiator, and TPGT). This function will return
- * an array of character strings which represent all of the available
- * objects of the specific type. These strings are the same ones that
- * where used during the creation.
- *
- * NOTE: Since there's no locking a call to this this function may
- * return a name which then doesn't exist when the user attempts to
- * get the specific information on that object. This would be caused
- * when another operator deletes an object between the first and second
- * calls.
- */
-char **iscsit_list_find(iscsit_handle_t h, iscsit_obj_type_t t);
-void iscsit_list_free(char **list);
-
-/*
- * iscsit_list_target -- returns detailed information about a target
- */
-iscsit_target_t *iscsit_list_target(iscsit_handle_t h, char *targ);
-void iscsit_list_target_free(iscsit_target_t *t);
-
-/*
- * iscsit_list_initiator -- returns detailed information about an initiator
- */
-iscsit_initiator_t *iscsit_list_initiator(iscsit_handle_t h, char *initiator);
-void iscsit_list_initiator_free(iscsit_initiator_t *t);
-
-/*
- * iscsit_list_tpgt -- returns detailed information about a target port group
- */
-iscsit_tpgt_t *iscsit_list_tpgt(iscsit_handle_t h, char *tpgt);
-void iscsit_list_tpgt_free(iscsit_tpgt_t *t);
-
-/*
- * iscsit_list_adm -- returns information about the global variables used.
- */
-iscsit_admin_t *iscsit_list_adm(iscsit_handle_t h);
-void iscsit_list_adm_free(iscsit_admin_t *t);
-
-/*
- * Misc functions
- */
-int iscsitgt_svc_online();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _LIBISCSITGT_H */
diff --git a/usr/src/lib/libiscsitgt/common/llib-liscsitgt b/usr/src/lib/libiscsitgt/common/llib-liscsitgt
deleted file mode 100644
index 2b28fe63ff..0000000000
--- a/usr/src/lib/libiscsitgt/common/llib-liscsitgt
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*LINTLIBRARY*/
-/*PROTOLIB1*/
-/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <libiscsitgt.h>
diff --git a/usr/src/lib/libiscsitgt/common/mapfile-vers b/usr/src/lib/libiscsitgt/common/mapfile-vers
deleted file mode 100644
index 792d56f156..0000000000
--- a/usr/src/lib/libiscsitgt/common/mapfile-vers
+++ /dev/null
@@ -1,72 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-# MAPFILE HEADER START
-#
-# WARNING: STOP NOW. DO NOT MODIFY THIS FILE.
-# Object versioning must comply with the rules detailed in
-#
-# usr/src/lib/README.mapfiles
-#
-# You should not be making modifications here until you've read the most current
-# copy of that file. If you need help, contact a gatekeeper for guidance.
-#
-# MAPFILE HEADER END
-#
-
-SUNWprivate_1.1 {
- global:
- iscsitgt_svc_online;
- iscsitgt_zfs_is_shared;
- iscsitgt_zfs_share;
- iscsitgt_zfs_unshare;
- tgt_door_call;
- tgt_node_free;
- tgt_dump2buf;
- tgt_node_process;
- tgt_find_attr_str;
- tgt_find_value_str;
- tgt_find_value_int;
- tgt_find_value_intchk;
- tgt_find_value_boolean;
- tgt_node_next;
- tgt_node_next_child;
- tgt_node_add;
- tgt_node_add_attr;
- tgt_node_alloc;
- tgt_node_remove;
- tgt_node_replace;
- tgt_node_find;
- tgt_node_dup;
- tgt_xml_encode;
- tgt_xml_decode;
- tgt_update_value_str;
- tgt_buf_add;
- tgt_buf_add_tag;
- tgt_buf_add_tag_and_attr;
- local:
- *;
-};
diff --git a/usr/src/lib/libiscsitgt/common/xml.c b/usr/src/lib/libiscsitgt/common/xml.c
deleted file mode 100644
index 3441bf2a42..0000000000
--- a/usr/src/lib/libiscsitgt/common/xml.c
+++ /dev/null
@@ -1,914 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <inttypes.h>
-#include <assert.h>
-#include <libxml/xmlreader.h>
-#include <strings.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <syslog.h>
-#include <sys/stat.h>
-
-#include "iscsitgt_impl.h"
-
-/*
- * Forward declarations
- */
-static char *strip_space(char *value);
-static tgt_node_t *node_alloc();
-static void node_free(tgt_node_t *x);
-static Boolean_t node_name(tgt_node_t *x, const xmlChar *n);
-static Boolean_t node_value(tgt_node_t *x, const xmlChar *n, Boolean_t s);
-static tgt_node_t *node_parent(tgt_node_t *x);
-static tgt_node_t *node_child(tgt_node_t *x);
-static tgt_node_t *node_alloc_attr(tgt_node_t *x);
-static void buf_add_node_attr(char **b, tgt_node_t *x);
-static void buf_add_comment(char **b, char *comment);
-static void buf_add_str(char **b, char *str);
-
-#define XML_COMMENT_STR "!--"
-#define XML_COMMENT_END "--"
-
-void
-tgt_node_free(tgt_node_t *n)
-{
- tgt_node_t *c;
- tgt_node_t *c1;
-
- if (n == NULL)
- return;
- for (c = n->x_child; c; ) {
- c1 = c->x_sibling;
- tgt_node_free(c);
- c = c1;
- }
- for (c = n->x_attr; c; ) {
- c1 = c->x_sibling;
- node_free(c);
- c = c1;
- }
- node_free(n);
-
-}
-
-/*
- * tgt_dump2buf -- dumps node tree to buffer, allocating memory as it goes
- *
- * It is up to the caller, when finished with 'buf', to call free()
- */
-void
-tgt_dump2buf(tgt_node_t *n, char **buf)
-{
- tgt_node_t *c;
-
- if (n == NULL)
- return;
- if (strcmp(n->x_name, XML_COMMENT_STR) == 0) {
- buf_add_comment(buf, n->x_value);
- return;
- }
- buf_add_node_attr(buf, n);
- if (n->x_value != NULL)
- tgt_buf_add_tag(buf, n->x_value, Tag_String);
- for (c = n->x_child; c; c = c->x_sibling)
- tgt_dump2buf(c, buf);
- tgt_buf_add_tag(buf, n->x_name, Tag_End);
-}
-
-char *common_attr_list[] = {
- XML_ELEMENT_NAME,
- XML_ELEMENT_VERS,
- XML_ELEMENT_INCORE,
- 0
-};
-
-Boolean_t
-tgt_node_process(xmlTextReaderPtr r, tgt_node_t **node)
-{
- const xmlChar *name;
- const xmlChar *value;
- char **ap;
- xmlElementType node_type;
- tgt_node_t *n;
- tgt_node_t *an;
-
- n = *node;
- if (n == NULL) {
- n = node_alloc();
- if (n == NULL)
- return (False);
- *node = n;
- }
-
- name = (xmlChar *)xmlTextReaderConstName(r);
- if (name == NULL) {
- node_free(n);
- *node = NULL;
- return (False);
- }
-
- node_type = (xmlElementType)xmlTextReaderNodeType(r);
-
- value = (xmlChar *)xmlTextReaderConstValue(r);
-
- if (node_type == XML_ELEMENT_NODE) {
- if (n->x_state != NodeAlloc) {
- n = node_child(n);
- *node = n;
- if (n == NULL)
- return (False);
- }
- if (xmlTextReaderAttributeCount(r) > 0) {
-
- for (ap = common_attr_list; *ap; ap++) {
- value = xmlTextReaderGetAttribute(r,
- (xmlChar *)*ap);
-
- if (value != NULL) {
- if ((an = node_alloc_attr(n)) == NULL)
- return (False);
- if (node_name(an, (xmlChar *)*ap) ==
- False) {
- node_free(an);
- return (False);
- }
- if (node_value(an, value, True) ==
- False) {
- node_free(an);
- return (False);
- }
- free((char *)value);
- }
- }
- }
-
- if (node_name(n, name) == False) {
- node_free(n);
- *node = NULL;
- return (False);
- }
- } else if ((value != NULL) && (node_type == XML_TEXT_NODE)) {
- if (node_value(n, value, True) == False) {
- node_free(n);
- *node = NULL;
- return (False);
- }
- } else if (node_type == XML_ELEMENT_DECL) {
- n = node_parent(n);
- if (n == NULL)
- return (False);
- *node = n;
- } else if (node_type == XML_COMMENT_NODE) {
- n = node_child(n);
- if (node_name(n, (xmlChar *)XML_COMMENT_STR) == False) {
- node_free(n);
- *node = NULL;
- return (False);
- }
- if (node_value(n, (xmlChar *)value, False) == False) {
- node_free(n);
- *node = NULL;
- return (False);
- }
- } else if (node_type != XML_DTD_NODE) {
- node_free(n);
- *node = NULL;
- return (False);
- }
- return (True);
-}
-
-Boolean_t
-tgt_find_attr_str(tgt_node_t *n, char *attr, char **value)
-{
- tgt_node_t *a;
-
- if ((n == NULL) || (n->x_attr == NULL))
- return (False);
-
- for (a = n->x_attr; a; a = a->x_sibling)
- if (strcmp(a->x_name, attr) == 0) {
- *value = a->x_value ? strdup(a->x_value) : NULL;
- return (True);
- }
- return (False);
-}
-
-Boolean_t
-tgt_find_value_str(tgt_node_t *n, char *name, char **value)
-{
- tgt_node_t *c;
-
- if ((n == NULL) || (n->x_name == NULL))
- return (False);
-
- if (strcmp(n->x_name, name) == 0) {
- *value = n->x_value ? strdup(n->x_value) : NULL;
- return (True);
- }
- for (c = n->x_child; c; c = c->x_sibling) {
- if (tgt_find_value_str(c, name, value) == True)
- return (True);
- }
- return (False);
-}
-
-Boolean_t
-tgt_find_value_int(tgt_node_t *n, char *name, int *value)
-{
- tgt_node_t *c;
-
- if ((n == NULL) || (n->x_name == NULL))
- return (False);
-
- if (strcmp(n->x_name, name) == 0) {
- if (n->x_value == NULL)
- return (False);
- *value = strtol(n->x_value, NULL, 0);
- return (True);
- }
- for (c = n->x_child; c; c = c->x_sibling) {
- if (tgt_find_value_int(c, name, value) == True)
- return (True);
- }
- return (False);
-}
-
-/*
- * []----
- * | xml_find_value_intchk -- if node exists, check to see if value is okay
- * []----
- */
-Boolean_t
-tgt_find_value_intchk(tgt_node_t *n, char *name, int *value)
-{
- char *str;
- char chk[32];
- Boolean_t rval;
-
- if (tgt_find_value_str(n, name, &str) == True) {
-
- *value = strtol(str, NULL, 0);
- /*
- * Validate that the input string hasn't overrun what
- * what an integer can handle. This is done by simply
- * printing out the result of the conversion into a buffer
- * and comparing it to the incoming string. That way when
- * someone enters 4294967296 which strtol returns as 0
- * we'll catch it.
- */
- if ((str[0] == '0') && (str[1] != '\0')) {
- if (str[1] == 'x')
- (void) snprintf(chk, sizeof (chk), "0x%x",
- *value);
- else if (str[1] == 'X')
- (void) snprintf(chk, sizeof (chk), "0X%x",
- *value);
- else
- (void) snprintf(chk, sizeof (chk), "0%o",
- *value);
- } else
- (void) snprintf(chk, sizeof (chk), "%d", *value);
- if (strcmp(chk, str) == 0)
- rval = True;
- else
- rval = False;
- free(str);
- return (rval);
- } else
- return (True);
-}
-
-Boolean_t
-tgt_find_value_boolean(tgt_node_t *n, char *name, Boolean_t *value)
-{
- tgt_node_t *c;
-
- if ((n == NULL) || (n->x_name == NULL))
- return (False);
-
- if (strcmp(n->x_name, name) == 0) {
- if (n->x_value == NULL)
- return (False);
- *value = strcmp(n->x_value, "true") == 0 ? True : False;
- return (True);
- }
- for (c = n->x_child; c; c = c->x_sibling) {
- if (tgt_find_value_boolean(c, name, value) == True)
- return (True);
- }
- return (False);
-}
-
-tgt_node_t *
-tgt_node_next(tgt_node_t *n, char *name, tgt_node_t *cur)
-{
- tgt_node_t *x;
- tgt_node_t *p;
-
- if (n == NULL)
- return (NULL);
-
- if (cur != NULL) {
- for (x = cur->x_sibling; x; x = x->x_sibling)
- if (strcmp(x->x_name, name) == 0)
- return (x);
- return (NULL);
- }
-
- if (n->x_name == NULL)
- return (NULL);
-
- if (strcmp(n->x_name, name) == 0)
- return (n);
- for (x = n->x_child; x; x = x->x_sibling)
- if ((p = tgt_node_next(x, name, 0)) != NULL)
- return (p);
- return (NULL);
-}
-
-tgt_node_t *
-tgt_node_next_child(tgt_node_t *n, char *name, tgt_node_t *cur)
-{
- if (cur != NULL) {
- n = cur->x_sibling;
- } else {
- if (n != NULL)
- n = n->x_child;
- else
- return (NULL);
- }
- while (n) {
- if (strcmp(n->x_name, name) == 0)
- return (n);
- n = n->x_sibling;
- }
- return (NULL);
-}
-
-void
-tgt_node_add(tgt_node_t *p, tgt_node_t *c)
-{
- if ((p == NULL) || (c == NULL))
- return;
-
- c->x_parent = p;
- if (p->x_child == NULL)
- p->x_child = c;
- else {
- c->x_sibling = p->x_child;
- p->x_child = c;
- }
-}
-
-void
-tgt_node_add_attr(tgt_node_t *p, tgt_node_t *a)
-{
- if ((p == NULL) || (a == NULL))
- return;
-
- if (p->x_attr == NULL)
- p->x_attr = a;
- else {
- a->x_sibling = p->x_attr;
- p->x_attr = a;
- }
-}
-
-tgt_node_t *
-tgt_node_alloc(char *name, xml_val_type_t type, void *value)
-{
- tgt_node_t *d = node_alloc();
- int value_len = 0;
- char *value_str = NULL;
-
- if (d == NULL)
- return (NULL);
- switch (type) {
- case String:
- if (value)
- value_len = strlen((char *)value) + 1;
- break;
- case Int:
- value_len = sizeof (int) * 2 + 3;
- break;
- case Uint64:
- value_len = sizeof (uint64_t) * 2 + 3;
- break;
- }
- if (value_len &&
- (value_str = (char *)calloc(sizeof (char), value_len)) == NULL)
- return (NULL);
- if (node_name(d, (xmlChar *)name) == False) {
- free(value_str);
- return (NULL);
- }
- if (value_str) {
- switch (type) {
- case String:
- (void) snprintf(value_str, value_len, "%s",
- (char *)value);
- break;
- case Int:
- (void) snprintf(value_str, value_len, "%d",
- *(int *)value);
- break;
- case Uint64:
- (void) snprintf(value_str, value_len, "0x%llx",
- *(uint64_t *)value);
- break;
- }
- }
- (void) node_value(d, (xmlChar *)value_str, True);
- free(value_str);
-
- return (d);
-}
-
-Boolean_t
-tgt_xml_encode(uint8_t *ip, size_t ip_size, char **buf, size_t *buf_size)
-{
- char *bp;
- *buf_size = (ip_size * 2) + 1;
-
- if ((*buf = (char *)malloc(*buf_size)) == NULL) {
- *buf_size = 0;
- return (False);
- }
-
- for (bp = *buf; ip_size; ip_size--) {
- (void) sprintf(bp, "%.2x", *ip);
- ip++;
- bp += 2;
- }
-
- /* make it null terminated */
- *bp = 0;
-
- return (True);
-}
-
-Boolean_t
-tgt_xml_decode(char *buf, uint8_t **ip, size_t *ip_size)
-{
- uint8_t *i;
- size_t buf_size = strlen(buf);
- *ip_size = buf_size / 2;
-
- if ((*ip = (uint8_t *)malloc(*ip_size)) == NULL) {
- *ip_size = 0;
- return (False);
- }
-
- for (i = *ip; buf_size; buf_size -= 2) {
- char x[3];
- bcopy(buf, x, 2);
- x[2] = 0;
- *i++ = strtol(x, NULL, 16);
- buf += 2;
- }
- return (True);
-}
-
-Boolean_t
-tgt_node_remove(tgt_node_t *parent, tgt_node_t *child, match_type_t m)
-{
- tgt_node_t *s;
- tgt_node_t *c = NULL;
-
- if ((parent == NULL) || (child == NULL))
- return (False);
-
- for (s = parent->x_child; s; c = s, s = s->x_sibling) {
-
- /*
- * See if the new child node matches one of the children
- * in the parent.
- */
- if ((strcmp(s->x_name, child->x_name) == 0) &&
- ((m == MatchName) || (strcmp(s->x_value,
- child->x_value) == 0))) {
-
- if (parent->x_child == s) {
- parent->x_child = s->x_sibling;
- } else {
- c->x_sibling = s->x_sibling;
- }
- tgt_node_free(s);
- break;
- }
- }
- if (s == NULL)
- return (False);
- else
- return (True);
-}
-
-void
-tgt_node_replace(tgt_node_t *parent, tgt_node_t *child, match_type_t m)
-{
- tgt_node_t *s;
- tgt_node_t *c;
-
- if ((parent == NULL) || (child == NULL))
- return;
-
- for (s = parent->x_child; s; s = s->x_sibling) {
-
- /*
- * See if the new child node matches one of the children
- * in the parent.
- */
- if ((strcmp(s->x_name, child->x_name) == 0) &&
- ((m == MatchName) || (strcmp(s->x_value,
- child->x_value) == 0))) {
-
- /*
- * We have a match. Now save the values of the new
- * child in this current node.
- */
- free(s->x_name);
- free(s->x_value);
- s->x_name = strdup(child->x_name);
- s->x_value = strdup(child->x_value);
- if (s->x_child) {
- tgt_node_free(s->x_child);
- s->x_child = NULL;
- }
- for (c = child->x_child; c; c = c->x_sibling)
- (void) tgt_node_add(s, tgt_node_dup(c));
- break;
- }
- }
-
- if (s == NULL) {
- /*
- * Never found the child so add it
- */
- (void) tgt_node_add(parent, tgt_node_dup(child));
- }
-}
-
-Boolean_t
-tgt_update_value_str(tgt_node_t *node, char *name, char *str)
-{
- if ((node == NULL) || (strcmp(name, node->x_name) != 0))
- return (False);
- if (node->x_value != NULL)
- free(node->x_value);
- node->x_value = strdup(str);
- node->x_state = NodeValue;
- return (True);
-}
-
-tgt_node_t *
-tgt_node_find(tgt_node_t *n, char *name)
-{
- tgt_node_t *rval;
-
- for (rval = n->x_child; rval; rval = rval->x_sibling)
- if (strcmp(rval->x_name, name) == 0)
- break;
- return (rval);
-}
-
-tgt_node_t *
-tgt_node_dup(tgt_node_t *n)
-{
- tgt_node_t *d = node_alloc();
- tgt_node_t *c;
-
- if (d == NULL)
- return (NULL);
- if (node_name(d, (xmlChar *)n->x_name) == False)
- return (NULL);
- if (n->x_value && (node_value(d, (xmlChar *)n->x_value, True) == False))
- return (NULL);
- for (c = n->x_child; c; c = c->x_sibling)
- (void) tgt_node_add(d, tgt_node_dup(c));
- for (c = n->x_attr; c; c = c->x_sibling)
- (void) tgt_node_add_attr(d, tgt_node_dup(c));
- return (d);
-}
-
-#define MAX_REPLACEMENT_ENTITY 8
-#define MAX_REPLACEMENT_BUFFER 1024
-void
-tgt_buf_add(char **b, char *element, const char *cdata)
-{
- char entity[MAX_REPLACEMENT_ENTITY];
- char buf[MAX_REPLACEMENT_BUFFER];
- int len, i;
-
- bzero(buf, sizeof (buf));
-
- tgt_buf_add_tag(b, element, Tag_Start);
- /*
- * we have to transform the predefined xml entities;
- */
- if (cdata != NULL) {
- len = strlen(cdata);
- for (i = 0; i < len; i++) {
- switch (cdata[i]) {
- case '&':
- (void) strcpy(entity, "&amp;");
- break;
- case '<':
- (void) strcpy(entity, "&lt;");
- break;
- case '>':
- (void) strcpy(entity, "&gt;");
- break;
- case '\'':
- (void) strcpy(entity, "&apos;");
- break;
- case '"':
- (void) strcpy(entity, "&quot;");
- break;
- default:
- entity[0] = cdata[i];
- entity[1] = '\0';
- break;
- }
- (void) strlcat(buf, entity, sizeof (buf));
- }
- tgt_buf_add_tag(b, buf, Tag_String);
- }
- tgt_buf_add_tag(b, element, Tag_End);
-}
-
-/*
- * []----
- * | tgt_buf_add_tag -- adds string to buffer allocating space, sets up tags too
- * |
- * | Helper function to build a string by allocating memory as we go.
- * | If the string argument 'str' is defined to be a start or end tag
- * | as declared by 'type' argument add the appropriate characters.
- * []----
- */
-void
-tgt_buf_add_tag(char **b, const char *str, val_type_t type)
-{
- char *buf;
- int len;
-
- /*
- * We will add potentially up to 3 extra characters plus the NULL byte
- */
- len = strlen(str) + 4;
- if ((buf = malloc(len)) == NULL)
- return;
-
- (void) snprintf(buf, len, "%s%s%s%s", type == Tag_String ? "" : "<",
- type == Tag_End ? "/" : "", str, type == Tag_String ? "" : ">");
- buf_add_str(b, buf);
- free(buf);
-}
-
-/*
- * []----
- * | tgt_buf_add_tag_and_attr -- variant on tgt_buf_add_tag which also gives
- * | attr
- * []----
- */
-void
-tgt_buf_add_tag_and_attr(char **b, char *str, char *attr)
-{
- char *buf;
- int len;
-
- /*
- * In addition to the 'str' and 'attr' strings the code will add
- * three characters plus a null byte.
- */
- len = strlen(str) + strlen(attr) + 4;
- if ((buf = malloc(len)) == NULL)
- return;
-
- (void) snprintf(buf, len, "<%s %s>", str, attr);
- buf_add_str(b, buf);
- free(buf);
-}
-
-/*
- * []----
- * | Utility functions
- * []----
- */
-static tgt_node_t *
-node_alloc()
-{
- tgt_node_t *x = (tgt_node_t *)calloc(sizeof (tgt_node_t), 1);
-
- if (x == NULL)
- return (NULL);
-
- x->x_state = NodeAlloc;
- return (x);
-}
-
-static void
-node_free(tgt_node_t *x)
-{
- x->x_state = NodeFree;
- if (x->x_name)
- free(x->x_name);
- if (x->x_value)
- free(x->x_value);
- free(x);
-}
-
-static Boolean_t
-node_name(tgt_node_t *x, const xmlChar *n)
-{
- assert(x->x_state == NodeAlloc);
- if ((n == NULL) || (strlen((char *)n) == 0))
- return (False);
-
- x->x_state = NodeName;
- x->x_name = strip_space((char *)n);
- return (True);
-}
-
-static Boolean_t
-node_value(tgt_node_t *x, const xmlChar *n, Boolean_t do_strip)
-{
- assert(x->x_state == NodeName);
- if ((n == NULL) || (strlen((char *)n) == NULL))
- return (False);
-
- x->x_state = NodeValue;
- x->x_value = (do_strip == True) ?
- strip_space((char *)n) : strdup((char *)n);
- return (True);
-}
-
-static tgt_node_t *
-node_parent(tgt_node_t *x)
-{
- return (x->x_parent);
-}
-
-static tgt_node_t *
-node_child(tgt_node_t *x)
-{
- tgt_node_t *n;
-
- if ((n = node_alloc()) == NULL)
- return (NULL);
-
- if (x->x_child == NULL) {
- x->x_child = n;
- } else {
- n->x_sibling = x->x_child;
- x->x_child = n;
- }
- n->x_parent = x;
- return (n);
-}
-
-static tgt_node_t *
-node_alloc_attr(tgt_node_t *x)
-{
- tgt_node_t *n;
- tgt_node_t *next;
-
- n = node_alloc();
- if (x->x_attr == NULL) {
- x->x_attr = n;
- } else {
- for (next = x->x_attr; next->x_sibling; next = next->x_sibling)
- ;
- next->x_sibling = n;
- }
- if (n != NULL)
- n->x_parent = x;
- return (n);
-}
-
-static void
-buf_add_str(char **b, char *str)
-{
- int len;
- int olen = 0;
- char *p = *b;
-
- /*
- * Make sure we have enough room for the string and tag characters
- * plus a NULL byte.
- */
- if (str == NULL)
- return;
-
- len = strlen(str) + 1;
- if (p == NULL) {
- if ((p = malloc(len)) == NULL)
- return;
- } else {
- olen = strlen(p);
- p = realloc(p, olen + len);
- }
- (void) strncpy(p + olen, str, len);
- *b = p;
-}
-
-static void
-buf_add_node_attr(char **b, tgt_node_t *x)
-{
- char *buf;
- tgt_node_t *n;
- int len;
-
- /* ---- null byte and starting '<' character ---- */
- len = strlen(x->x_name) + 2;
- if ((buf = malloc(len)) == NULL)
- return;
- (void) snprintf(buf, len, "<%s", x->x_name);
- buf_add_str(b, buf);
- free(buf);
-
- for (n = x->x_attr; n; n = n->x_sibling) {
- len = strlen(n->x_name) + strlen(n->x_value) + 5;
- if ((buf = malloc(len)) == NULL)
- return;
- (void) snprintf(buf, len, " %s='%s'", n->x_name, n->x_value);
- buf_add_str(b, buf);
- free(buf);
- }
- buf_add_str(b, ">");
-}
-
-static void
-buf_add_comment(char **b, char *comment)
-{
- char *p = *b;
- int len;
- int olen;
-
- if (comment == NULL)
- return;
-
- /*
- * Room for the strings, plus the brackets and NULL byte
- */
- len = strlen(comment) + strlen(XML_COMMENT_STR) +
- strlen(XML_COMMENT_END) + 3;
-
- if (p == NULL)
- p = malloc(len);
- else {
- olen = strlen(p);
- p = realloc(p, olen + len);
- }
- (void) snprintf(p + olen, len, "<%s%s%s>", XML_COMMENT_STR, comment,
- XML_COMMENT_END);
- *b = p;
-}
-
-static char *
-strip_space(char *value)
-{
- char *p;
- char *n;
-
- for (p = value; p && *p; p++)
- if (!isspace(*p))
- break;
- if ((p == NULL) || (*p == '\0'))
- return (NULL);
-
- p = strdup(p);
- for (n = (p + strlen(p) - 1); n >= p; n--)
- if (!isspace(*n)) {
- n++;
- break;
- }
- *n = '\0';
- return (p);
-}
diff --git a/usr/src/lib/libiscsitgt/i386/Makefile b/usr/src/lib/libiscsitgt/i386/Makefile
deleted file mode 100644
index a333224278..0000000000
--- a/usr/src/lib/libiscsitgt/i386/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../Makefile.com
-
-install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/usr/src/lib/libiscsitgt/sparc/Makefile b/usr/src/lib/libiscsitgt/sparc/Makefile
deleted file mode 100644
index a333224278..0000000000
--- a/usr/src/lib/libiscsitgt/sparc/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../Makefile.com
-
-install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/usr/src/lib/libiscsitgt/sparcv9/Makefile b/usr/src/lib/libiscsitgt/sparcv9/Makefile
deleted file mode 100644
index 2e8cdecf75..0000000000
--- a/usr/src/lib/libiscsitgt/sparcv9/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../Makefile.com
-include ../../Makefile.lib.64
-
-install: all $(ROOTLIBS64) $(ROOTLINKS64)