summaryrefslogtreecommitdiff
path: root/usr/src/lib
diff options
context:
space:
mode:
authorYuri Pankov <yuri.pankov@nexenta.com>2018-08-07 16:46:21 -0700
committerJoshua M. Clulow <josh@sysmgr.org>2018-08-07 16:46:22 -0700
commitcb41b9c565d4eec9e1f06e24d429696f59f2f07d (patch)
treeee8675f196c2ea84b5ac5c6f0dff8c9e5305f0ee /usr/src/lib
parent0e986b9d87352cd82909c748e7f684afe0ed579f (diff)
downloadillumos-joyent-cb41b9c565d4eec9e1f06e24d429696f59f2f07d.tar.gz
9674 Let's scrap AVS/sdbc
Reviewed by: Dan McDonald <danmcd@joyent.com> Reviewed by: Peter Tribble <peter.tribble@gmail.com> Approved by: Joshua M. Clulow <josh@sysmgr.org>
Diffstat (limited to 'usr/src/lib')
-rw-r--r--usr/src/lib/Makefile10
-rw-r--r--usr/src/lib/libdscfg/Makefile64
-rw-r--r--usr/src/lib/libdscfg/Makefile.com74
-rw-r--r--usr/src/lib/libdscfg/common/cfg.c3585
-rw-r--r--usr/src/lib/libdscfg/common/cfg.h180
-rw-r--r--usr/src/lib/libdscfg/common/cfg_cluster.c582
-rw-r--r--usr/src/lib/libdscfg/common/cfg_cluster.h344
-rw-r--r--usr/src/lib/libdscfg/common/cfg_impl.h247
-rw-r--r--usr/src/lib/libdscfg/common/cfg_local.c653
-rw-r--r--usr/src/lib/libdscfg/common/cfg_local.h42
-rw-r--r--usr/src/lib/libdscfg/common/cfg_lockd.h72
-rw-r--r--usr/src/lib/libdscfg/common/cfg_lockdlck.c135
-rw-r--r--usr/src/lib/libdscfg/common/cfg_lockdmsg.c324
-rw-r--r--usr/src/lib/libdscfg/common/cfg_vols.c1286
-rw-r--r--usr/src/lib/libdscfg/common/mapfile-vers100
-rw-r--r--usr/src/lib/libdscfg/i386/Makefile34
-rw-r--r--usr/src/lib/libdscfg/sparc/Makefile34
-rw-r--r--usr/src/lib/libnsctl/Makefile60
-rw-r--r--usr/src/lib/libnsctl/Makefile.com56
-rw-r--r--usr/src/lib/libnsctl/common/cache.c425
-rw-r--r--usr/src/lib/libnsctl/common/hash.c166
-rw-r--r--usr/src/lib/libnsctl/common/libnsctl.h62
-rw-r--r--usr/src/lib/libnsctl/common/llib-lnsctl52
-rw-r--r--usr/src/lib/libnsctl/common/machdep.c314
-rw-r--r--usr/src/lib/libnsctl/common/mapfile-vers70
-rw-r--r--usr/src/lib/libnsctl/common/nsc_hash.h49
-rw-r--r--usr/src/lib/libnsctl/i386/Makefile36
-rw-r--r--usr/src/lib/libnsctl/sparc/Makefile30
-rw-r--r--usr/src/lib/librdc/Makefile60
-rw-r--r--usr/src/lib/librdc/Makefile.com92
-rw-r--r--usr/src/lib/librdc/common/librdc.h113
-rw-r--r--usr/src/lib/librdc/common/llib-lrdc46
-rw-r--r--usr/src/lib/librdc/common/mapfile-vers84
-rw-r--r--usr/src/lib/librdc/common/netaddrs.c670
-rw-r--r--usr/src/lib/librdc/common/rdcconfig.c1318
-rw-r--r--usr/src/lib/librdc/common/rdcerr.c98
-rw-r--r--usr/src/lib/librdc/common/rdcerr.h74
-rw-r--r--usr/src/lib/librdc/common/rdcpersist.c716
-rw-r--r--usr/src/lib/librdc/common/rdcrules.c545
-rw-r--r--usr/src/lib/librdc/common/rdcrules.h46
-rw-r--r--usr/src/lib/librdc/i386/Makefile33
-rw-r--r--usr/src/lib/librdc/sparc/Makefile31
-rw-r--r--usr/src/lib/libunistat/Makefile96
-rw-r--r--usr/src/lib/libunistat/Makefile.com189
-rw-r--r--usr/src/lib/libunistat/common/README33
-rw-r--r--usr/src/lib/libunistat/common/dsw/dsw.err54
-rw-r--r--usr/src/lib/libunistat/common/llib-lunistat42
-rw-r--r--usr/src/lib/libunistat/common/mapfile-vers55
-rw-r--r--usr/src/lib/libunistat/common/rdc/rdc.err93
-rw-r--r--usr/src/lib/libunistat/common/sdbc/sdbc.err60
-rw-r--r--usr/src/lib/libunistat/common/solaris/solaris.err173
-rw-r--r--usr/src/lib/libunistat/common/spcs/spcs.err39
-rw-r--r--usr/src/lib/libunistat/common/spcs_errors.stub36
-rw-r--r--usr/src/lib/libunistat/common/spcs_etext.stub40
-rw-r--r--usr/src/lib/libunistat/common/spcs_etrinkets.stub49
-rw-r--r--usr/src/lib/libunistat/common/spcs_log.c115
-rw-r--r--usr/src/lib/libunistat/common/spcs_s_u.c246
-rw-r--r--usr/src/lib/libunistat/common/sv/sv.err45
-rw-r--r--usr/src/lib/libunistat/i386/Makefile35
-rw-r--r--usr/src/lib/libunistat/sparc/Makefile35
60 files changed, 0 insertions, 14447 deletions
diff --git a/usr/src/lib/Makefile b/usr/src/lib/Makefile
index 35b35800e8..90cffe62f7 100644
--- a/usr/src/lib/Makefile
+++ b/usr/src/lib/Makefile
@@ -117,7 +117,6 @@ SUBDIRS += \
libdlpi \
libdns_sd \
libdoor \
- libdscfg \
libdtrace \
libdtrace_jni \
libefi \
@@ -169,7 +168,6 @@ SUBDIRS += \
libndmp \
libnisdb \
libnls \
- libnsctl \
libnwam \
libofmt \
libpam \
@@ -185,7 +183,6 @@ SUBDIRS += \
libpthread \
libraidcfg \
librcm \
- librdc \
libreparse \
libresolv \
libresolv2 \
@@ -227,7 +224,6 @@ SUBDIRS += \
libtsnet \
libtsol \
libumem \
- libunistat \
libuuid \
libuutil \
libvolmgt \
@@ -392,7 +388,6 @@ HDRSUBDIRS= \
libdll \
libdlpi \
libdns_sd \
- libdscfg \
libdtrace \
libdtrace_jni \
libelfsign \
@@ -425,7 +420,6 @@ HDRSUBDIRS= \
libmlrpc \
libmtmalloc \
libndmp \
- libnsctl \
libnsl \
libnvpair \
libnwam \
@@ -440,7 +434,6 @@ HDRSUBDIRS= \
libproc \
libraidcfg \
librcm \
- librdc \
libreparse \
librestart \
librpcsvc \
@@ -473,7 +466,6 @@ HDRSUBDIRS= \
libtsnet \
libtsol \
libumem \
- libunistat \
libuutil \
libvolmgt \
libvrrpadm \
@@ -603,7 +595,6 @@ libdladm: libdevinfo libinetutil libscf librcm libexacct libkstat \
libdll: libast
libdlpi: libinetutil libdladm
libds: libsysevent
-libdscfg: libnsctl libunistat libadm
libdtrace: libproc libgen libctf libmapmalloc
libdtrace_jni: libuutil libdtrace
libefi: libuuid libsmbios
@@ -643,7 +634,6 @@ libproject: libpool libproc libsecdb
libprtdiag: libkstat
libprtdiag_psr: libprtdiag
libraidcfg: libdevinfo
-librdc: libnsctl libunistat libdscfg
librestart: libuutil libscf libpool libproject libsecdb libsysevent
libsasl: libgss pkcs11
libsaveargs: libdisasm
diff --git a/usr/src/lib/libdscfg/Makefile b/usr/src/lib/libdscfg/Makefile
deleted file mode 100644
index 8516e90e12..0000000000
--- a/usr/src/lib/libdscfg/Makefile
+++ /dev/null
@@ -1,64 +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 ../Makefile.lib
-
-HDRS= cfg.h\
- cfg_cluster.h\
- cfg_impl.h\
- cfg_lockd.h
-HDRDIR= common
-
-SUBDIRS= $(MACH)
-
-ROOTDIR= $(ROOT)/usr/include/sys/nsctl
-
-ROOTHDRS= $(HDRS:%=$(ROOTDIR)/%)
-
-all := TARGET= all
-clean := TARGET= clean
-clobber := TARGET= clobber
-install := TARGET= install
-lint := TARGET= lint
-_msg := TARGET= _msg
-
-.KEEP_STATE:
-
-all clean clobber install lint: $(SUBDIRS)
-
-$(MACH): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
-
-install_h: $(ROOTDIR) $(ROOTHDRS)
-
-check: $(CHECKHDRS)
-
-$(ROOTDIR)/%: common/%
- $(INS.file)
-
-$(ROOTDIR):
- $(INS.dir)
-
-
-FRC:
diff --git a/usr/src/lib/libdscfg/Makefile.com b/usr/src/lib/libdscfg/Makefile.com
deleted file mode 100644
index b12fb3a2b8..0000000000
--- a/usr/src/lib/libdscfg/Makefile.com
+++ /dev/null
@@ -1,74 +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.
-#
-
-LIBRARY= libdscfg.a
-VERS= .1
-
-OBJECTS= \
- cfg.o \
- cfg_cluster.o \
- cfg_local.o \
- cfg_lockdlck.o \
- cfg_lockdmsg.o \
- cfg_vols.o
-
-
-# include library definitions
-include ../../Makefile.lib
-
-SRCDIR= ../common
-SRCS= $(OBJECTS:%.o=../common/%.c)
-
-LIBS += $(DYNLIB) $(LINTLIB)
-
-# definitions for lint
-
-LINTFLAGS += -u
-LINTFLAGS += -erroff=E_FUNC_RET_ALWAYS_IGNOR2
-LINTFLAGS += -erroff=E_FUNC_RET_MAYBE_IGNORED2
-LINTFLAGS += -erroff=E_FUNC_SET_NOT_USED
-LINTFLAGS += -erroff=E_SEC_SCANF_UNBOUNDED_COPY
-LINTFLAGS += -erroff=E_BAD_FORMAT_ARG_TYPE2
-LINTOUT= lint.out
-LINTOUT_INTER= lintinter.out
-
-CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-unused-function
-CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
-CERRWARN += -_gcc=-Wno-address
-
-ROOTLINTDIR= $(ROOTLIBDIR)
-ROOTLINT= $(LINTSRC:%=$(ROOTLINTDIR)/%)
-
-CLEANFILES += $(LINTOUT) $(LINTOUT_INTER) $(LINT_INTER)
-
-LDLIBS += -lnsctl -lunistat -ladm -lsocket -lnsl -lc
-
-.KEEP_STATE:
-
-lint: lintcheck
-
-# include library targets
-include ../../Makefile.targ
diff --git a/usr/src/lib/libdscfg/common/cfg.c b/usr/src/lib/libdscfg/common/cfg.c
deleted file mode 100644
index 17f668744a..0000000000
--- a/usr/src/lib/libdscfg/common/cfg.c
+++ /dev/null
@@ -1,3585 +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 <sys/types.h>
-#include <sys/wait.h>
-#include <stdio.h>
-#include <sys/mnttab.h>
-#include <sys/vtoc.h>
-#include <errno.h>
-#include <limits.h>
-#include <fcntl.h>
-#include <string.h>
-#include <stdarg.h>
-#include <strings.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-
-#include <locale.h>
-#include <langinfo.h>
-#include <libintl.h>
-#include <stdarg.h>
-#include <netdb.h>
-#include <ctype.h>
-#include <sys/stat.h>
-#include <sys/utsname.h>
-
-#include "cfg_impl.h"
-#include "cfg.h"
-#include "cfg_lockd.h"
-
-#if 0
-#define DEBUG_CFGLIST
-#define DEBUG_EXTRA
-#define DEBUG_LIB
-#define DEBUG_NOISY
-#define DEBUG_OUT
-#endif
-
-#define MAX_CFG 16 /* Max. number of lines in /etc/dscfg_format */
-#define MAX_SET 12 /* number of chars in a set name */
-
-
-/* parser tree for config section */
-static struct parser chead[MAX_CFG] = { NULL };
-static int chead_loaded = 0;
-static char config_file[CFG_MAX_BUF];
-static char dectohex[] = { '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
-#define CHARS_TO_ENCODE "=;\t "
-#define min(a, b) ((a) > (b) ? (b) : (a))
-
-/* field to be sorted on in sorting routines */
-static struct sortby_s {
- char section[CFG_MAX_KEY];
- char field[CFG_MAX_KEY];
- int offset;
- int comperror;
-} sortby;
-
-int cfg_severity = 0;
-char *cfg_perror_str;
-static int cfg_read(cfp_t *);
-static void cfg_read_parser_config(cfp_t *);
-static int cfg_rdlock(CFGFILE *);
-static int cfg_wrlock(CFGFILE *);
-static int cfg_lockd;
-void cfg_replace_lists(cfp_t *);
-void cfg_free_parser_tree();
-void cfg_invalidate_hsizes(int, const char *);
-int cfg_map_cfglists(cfp_t *);
-int cfg_hdrcmp(cfp_t *);
-void cfg_free_cfglist(cfp_t *);
-
-extern cfg_io_t *cfg_block_io_provider(void);
-extern cfg_io_t *cfg_raw_io_provider(void);
-extern int cl_initialized;
-
-#ifdef DEBUG_LIB
-static void
-dump_status(cfp_t *cfp, char *str)
-{
- printf("called from %s\n", str);
- printf(gettext("Header info:\n"
- "\tmagic: %x\tstate: %x\n"),
- cfp->cf_head->h_magic, cfp->cf_head->h_state);
- printf(gettext("Parser section:\n"
- "Start: %x\tsize: %d\toffset: %d\n"),
- cfp->cf_mapped, cfp->cf_head->h_parsesize,
- cfp->cf_head->h_parseoff);
- printf(gettext("Config section:\n"
- "Start: %x\tsize:%d\tacsize: %d\n"),
- cfp->cf_head->h_cparse, cfp->cf_head->h_csize,
- cfp->cf_head->h_acsize);
- printf("\n\tccopy1: %x\tccopy2: %x\n",
- cfp->cf_head->h_ccopy1, cfp->cf_head->h_ccopy2);
- printf(gettext("Sequence:\n"
- "\tseq1: %d\t\tseq2: %d\n"),
- cfp->cf_head->h_seq1, cfp->cf_head->h_seq2);
-}
-#endif /* DEBUG */
-
-/*
- * cfg_get_item
- * return position from parser config given tag and field
- */
-static int
-cfg_get_item(struct parser *tbl, const char *tag, const char *field)
-{
- int i;
- struct lookup *p;
-
- for (i = 0; i < MAX_CFG; i++) {
- /* only as many lists as defined */
- if (tbl[i].tag.l_word[0] == '\0') {
- i = MAX_CFG;
- break;
- }
- if (strcmp(tbl[i].tag.l_word, tag) == 0)
- break;
- }
-
- /* Handle table size */
- if (i < MAX_CFG) {
- p = tbl[i].fld;
- while (p) {
- if (strcmp(p->l_word, field) == 0)
- return (p->l_value);
- p = p->l_next;
- }
- }
-
- /* Handle failure */
- return (-1);
-}
-
-/*
- * cfg_get_num_flds
- * return number of fields for given parser tag
- */
-static int
-cfg_get_num_flds(struct parser *tbl, const char *tag, int *table_index)
-{
- int i;
- int pos = 0;
- struct lookup *p;
-
- for (i = 0; i < MAX_CFG; i++) {
- /* only as many lists as defined */
- if (tbl[i].tag.l_word[0] == '\0') {
- i = MAX_CFG;
- break;
- }
- if (strcmp(tbl[i].tag.l_word, tag) == 0) {
- *table_index = i;
- break;
- }
- }
-
- /* Handle table size */
- if (i < MAX_CFG) {
- p = tbl[i].fld;
- while (p) {
- pos++;
- p = p->l_next;
- }
- return (pos);
- }
-
- return (0);
-}
-
-/*
- * count white space fields
- */
-static int
-cfg_cnt_flds(char *value)
-{
- char *ptr;
- char buf[CFG_MAX_BUF];
- int flds = 0;
-
- if ((value == NULL) || (strlen(value) >= CFG_MAX_BUF))
- return (0);
-
- bzero(buf, CFG_MAX_BUF);
- strcpy(buf, value);
- ptr = strtok(buf, " ");
- while (ptr) {
- flds++;
- ptr = strtok(NULL, " ");
- }
- return (flds);
-}
-
-/*
- * cfg_get_parser_offset
- * returns the index for each
- * section of the parser..
- * ie. parser info for sndr is chead[3].tag.l_word
- * this will help us find sndr quicker, as the
- * the memory picture of the sets mimic this ordering
- */
-static int
-cfg_get_parser_offset(const char *section)
-{
- int i;
-
- for (i = 0; i < MAX_CFG; i++) {
- /* only as many lists as defined */
- if (chead[i].tag.l_word[0] == '\0') {
- i = MAX_CFG;
- break;
- }
- if (strcmp(chead[i].tag.l_word, section) == 0)
- break;
- }
-
- /* Handle table size */
- if (i < MAX_CFG)
- return (i);
-
- /* Handle failure */
- cfg_perror_str = dgettext("cfg",
- "cfg_get_parser_offset: section not found");
- cfg_severity = CFG_EFATAL;
- errno = ESRCH;
- return (-1);
-}
-
-/*
- * cfg_fld_mov
- * move fields from old buffer to new
- * moving only specified fields
- * concates newbuf
- * returns fields moved
- */
-static int
-cfg_fld_mov(char *newbuf, char *oldbuf, int start, int end)
-{
- char buf[CFG_MAX_BUF];
- char *ptr;
- int flds = 0;
-
- bzero(buf, CFG_MAX_BUF);
- if (oldbuf == NULL)
- return (0);
-
- if ((start > end) || (strlen(oldbuf) >= CFG_MAX_BUF)) {
- return (0);
- }
- if (!start || !end)
- return (-1);
- strcpy(buf, oldbuf);
- ptr = strtok(buf, " ");
- while (ptr) {
- flds++;
- if (flds >= start && flds <= end) {
- strcat(newbuf, ptr);
- strcat(newbuf, " ");
- }
- ptr = strtok(NULL, " ");
- }
-
- return (flds);
-}
-
-/*
- * cfg_filter_node
- * return indication if this raw buf should be returned
- * checks cfg->cf_node for filtering
- * We already know that this buf meets most of our criteria
- * find the cnode field in the buf and see if it matches
- * returns
- * TRUE Good entry
- * FALSE Don't use it
- */
-static int
-cfg_filter_node(CFGFILE *cfg, struct parser *tbl, char *buf, char *tag)
-{
- char tmpbuf[CFG_MAX_BUF];
- int i = 1;
- int fld;
- char *ptr;
-
- if (!cfg->cf_node) /* no filter always good */
- return (TRUE);
- bzero(tmpbuf, CFG_MAX_BUF);
- fld = cfg_get_item(tbl, tag, "cnode");
- if (fld < 0) /* no cnode field always good */
- return (TRUE);
- strncpy(tmpbuf, buf, CFG_MAX_BUF);
- if (tmpbuf[CFG_MAX_BUF - 1] != '\0')
- return (FALSE);
- ptr = strtok(tmpbuf, " ");
- while (ptr && (i < fld)) {
- ptr = strtok(NULL, " ");
- i++;
- }
- if (!ptr)
- return (FALSE);
-#ifdef DEBUG_EXTRA
- (void) fprintf(stderr, "cfg_filter_node: node=%s:%d cnode=%s:%d\n",
- cfg->cf_node, strlen(cfg->cf_node), ptr, strlen(ptr));
-#endif
- if (strcmp(ptr, cfg->cf_node) == 0)
- return (TRUE);
- return (FALSE);
-}
-/*
- * cfg_insert_node
- * insert resource in bufs which contain cnode parser field
- */
-static void
-cfg_insert_node(CFGFILE *cfg, struct parser *tbl, char *buf, char *tag)
-{
- char tmpbuf[CFG_MAX_BUF];
- int fld;
- int nflds;
- int table_index;
-
- bzero(tmpbuf, CFG_MAX_BUF);
- strcpy(tmpbuf, " ");
- fld = cfg_get_item(tbl, tag, "cnode");
- nflds = cfg_get_num_flds(tbl, tag, &table_index);
- if ((fld < 0) && !(cfg->cf_node)) /* no cnode field always good */
- return;
-
- cfg_fld_mov(tmpbuf, buf, 1, (fld - 1));
- if (cfg->cf_node)
- strcat(tmpbuf, cfg->cf_node);
- else
- strcat(tmpbuf, "-");
- strcat(tmpbuf, " ");
- cfg_fld_mov(tmpbuf, buf, (fld + 1), nflds);
- bcopy(tmpbuf, buf, strlen(tmpbuf) + 1);
-}
-
-/*
- * cfg_is_cnode
- * Parser current buffer to see if a non-empty " - " cnode exists
- */
-/*ARGSUSED*/
-static int
-cfg_is_cnode(CFGFILE *cfg, struct parser *tbl, char *buf, char *tag)
-{
- char tmpbuf[CFG_MAX_BUF];
- int fld = cfg_get_item(tbl, tag, "cnode");
-
- if (fld >= 0) {
- tmpbuf[0] = '\0';
- cfg_fld_mov(tmpbuf, buf, fld, fld);
- return (strcmp(tmpbuf, "- ") ? TRUE : FALSE);
- }
- return (FALSE);
-}
-/*
- * cfg_get_cstring
- * key determines section and value
- * special considerations:
- * AA.BB.CC...
- * AA = data service tag
- * BB = set number relative to first set (1..n)
- * CC = field of set or if absent, all
- */
-int
-cfg_get_cstring(CFGFILE *cfg, const char *key, void *value, int value_len)
-{
- cfp_t *cfp;
- char buf[CFG_MAX_BUF];
- char tmpkey[CFG_MAX_KEY];
- char *section;
- char set[MAX_SET];
- char *setp;
- char *itemp;
- char *p;
- int pos = 1;
- int setnum;
- int relnum;
- int secnum;
- int numfound;
- int needed;
- int table_offset;
-
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
-
- if (!cfg_rdlock(cfg)) {
- cfg_perror_str = dgettext("cfg", CFG_NOTLOCKED);
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
-
- bzero(buf, sizeof (buf));
- bzero(set, sizeof (set));
- bzero(tmpkey, sizeof (tmpkey));
- strcpy(tmpkey, key);
- section = strtok(tmpkey, ".");
- setp = strtok(NULL, ".");
- itemp = strtok(NULL, ".");
-
-#ifdef DEBUG_EXTRA
- if (!itemp)
- (void) fprintf(stderr, "cfg_get_cstring:section:%s setp=%s\n",
- section, setp);
- else
- (void) fprintf(stderr,
- "cfg_get_cstring:section:%s setp=%s fld=%s\n",
- section, setp, itemp);
-#endif
-
- table_offset = cfg_get_parser_offset(section);
- setnum = atoi(setp + 3);
- if ((setnum < 1) || (setnum > 0x7ffd)) {
- errno = EINVAL;
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_ENONFATAL;
- return (-1);
- }
-
- /*
- * we have to figure out where this set is
- * in relation to other sets
- */
- relnum = 1;
- secnum = 0;
- numfound = 0;
- for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
- if (!cfp->cf_fd) continue;
- if (cfp->cf_head->h_state & CFG_HDR_INVALID) {
- if (!cfg_read(cfp)) {
- cfg_perror_str = dgettext("cfg", CFG_RDFAILED);
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
- }
- while (numfound < setnum) {
- if ((*cfp->cf_pp->readcf)
- (cfp, buf, table_offset, relnum - secnum) == NULL) {
- secnum = relnum - 1;
- break;
- }
- if (cfg_filter_node(cfg, &chead[0], buf, section))
- numfound++;
-
- if (numfound == setnum)
- break;
-
- relnum++;
- }
- if (numfound == setnum)
- break;
- }
-
- /* Fail to find anything? */
- if (cfp >= &cfg->cf[2]) {
- errno = ESRCH;
- cfg_perror_str = dgettext("cfg", strerror(errno));
- cfg_severity = CFG_ENONFATAL;
- return (-1);
- }
-
- if (buf) {
- if (!itemp) {
- strncpy(value, buf, value_len);
- return (0);
- }
-
- if (itemp) {
- needed = cfg_get_item(&chead[0], section, itemp);
- p = strtok(buf, " ");
- while (p) {
- if (needed == pos) {
- errno = 0;
- if (*p == '-') {
- strcpy(value, "");
- return (0);
- } else {
- if (strlen(p) > value_len) {
- errno = E2BIG;
- cfg_perror_str =
- dgettext("cfg",
- strerror(errno));
- cfg_severity =
- CFG_ENONFATAL;
- return (-1);
- }
- }
- strncpy(value, p, value_len);
-
- return (pos);
- }
- p = strtok(NULL, " ");
- if (!p)
- break;
- pos++;
- }
- }
- }
- errno = ESRCH;
- cfg_perror_str = dgettext("cfg", strerror(errno));
- cfg_severity = CFG_ENONFATAL;
- return (-1);
-}
-
-/*
- * cfg_find_cstring()
- * search for a string in the specified section
- * in the specified field(s)
- * if nfld is 0, then the string is searched for in
- * every field of the entry
- * the set number of the first occurence of target is returned
- * ie. if /dev/vx/rdsk/vol10 is found in sndr.set9, 9 will be returned
- * that is, of course, if the correct field was searched on.
- * -1 on error
- *
- */
-int
-cfg_find_cstring(CFGFILE *cfg, const char *target,
- const char *section, int numflds, ...)
-{
-
- char **list = NULL;
- va_list ap;
- char buf[CFG_MAX_BUF];
- char *field, *p;
- char **fldbuf = NULL;
- int i, j, rc;
- int pos = 1;
- int fieldnum;
- int nflds;
- int tbl_off;
-
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
-
- if (numflds == 0) {
- nflds = cfg_get_num_flds(&chead[0], section, &tbl_off);
-
- } else {
- nflds = numflds;
- }
- if ((fldbuf = calloc(nflds, CFG_MAX_KEY)) == NULL) {
- cfg_perror_str = dgettext("cfg", strerror(errno));
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
-
- if (numflds == 0) { /* search the whole string */
- if ((rc = cfg_get_section(cfg, &list, section)) <= 0) {
- for (i = 0; i < nflds; i++)
- free(fldbuf[i]);
- free(fldbuf);
- return (rc);
- }
- for (i = 0; i < rc; i++) {
- bzero(buf, sizeof (buf));
- strcpy(buf, list[i]);
- p = strtok(buf, " ");
- while (p) {
- if (strcmp(p, target) == 0) { /* we found it! */
- for (j = 0; j < rc; j++)
- free(list[j]);
- free(list);
- for (j = 0; j < nflds; j++)
- free(fldbuf[j]);
- free(fldbuf);
- return (i + 1);
- }
- p = strtok(NULL, " ");
- }
- }
- for (i = 0; i < nflds; i++)
- free(fldbuf[j]);
- for (i = 0; i < rc; i++)
- free(list[i]);
- free(fldbuf);
- free(list);
- return (0);
- }
-
- if ((rc = cfg_get_section(cfg, &list, section)) <= 0) {
- for (i = 0; i < nflds; i++)
- free(fldbuf[i]);
- free(fldbuf);
- return (rc);
- }
-
- va_start(ap, numflds);
- for (i = 0; i < numflds; i++) {
- fldbuf[i] = strdup(va_arg(ap, char *));
- }
-
- fldbuf[i] = NULL;
-
- for (j = 0; j < numflds; j++) {
- fieldnum = cfg_get_item(&chead[0], section, fldbuf[j]);
- for (i = 0; i < rc; i++) {
- bzero(buf, sizeof (buf));
- strcpy(buf, list[i]);
-
- field = strtok(buf, " ");
- pos = 1;
- while (pos < fieldnum) {
- field = strtok(NULL, " ");
- pos++;
- }
- if (field == NULL) {
- for (j = 0; j < numflds; j++)
- free(fldbuf[j]);
- for (j = 0; j < rc; j++)
- free(list[j]);
- free(fldbuf);
- free(list);
- return (-1);
- }
-
- if (strcmp(field, target) == 0) {
- for (j = 0; j < numflds; j++)
- free(fldbuf[j]);
- for (j = 0; j < rc; j++)
- free(list[j]);
- free(fldbuf);
- free(list);
-
- return (i + 1);
- }
-
- }
-
- }
- for (i = 0; i < nflds; i++)
- free(fldbuf[i]);
- for (i = 0; i < rc; i++)
- free(list[i]);
- free(fldbuf);
- free(list);
- return (0);
-}
-
-/*
- * cfg_put_cstring
- * modify entry or add an entry to configuration section
- * Key syntax supported
- * tag Add entry (in entirely) to config
- * tag.setn Add entry to setn If it exists overwrite old entry
- * tag.setn.field Change field in setn
- * value
- * string to change
- * NULL delete specified key
- *
- */
-
-int
-cfg_put_cstring(CFGFILE *cfg, const char *key, void *value, int val_len)
-{
- cfp_t *cfp;
- char buf[CFG_MAX_BUF];
- char newbuf[CFG_MAX_BUF];
- char *bufp;
- char tmpkey[CFG_MAX_KEY];
- char *section;
- char *setp;
- char *itemp;
- int nofield = 0;
- int noset = 0;
- int fldnum;
- int setnum = 0;
- int relnum;
- int secnum;
- int numfound;
- int addcnode = 1;
- int table_index;
- int table_offset;
-
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
-
- bzero(buf, sizeof (buf));
- strcpy(tmpkey, key);
- section = strtok(tmpkey, ".");
- setp = strtok(NULL, ".");
- itemp = strtok(NULL, ".");
-
- if (!cfg_wrlock(cfg)) {
- cfg_perror_str = dgettext("cfg", CFG_RDFAILED);
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
-
- if (!key) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_ENONFATAL;
- return (-1);
- }
- if (value && val_len == 0) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_ENONFATAL;
- return (-1);
- }
- if (!itemp)
- nofield++;
- if (!setp)
- noset++;
- else if (setp) {
- setnum = atoi(setp + 3);
- if (setnum < 1 || setnum > 0x7ffd) {
- errno = EINVAL;
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_ENONFATAL;
- return (-1);
- }
- }
-
- table_offset = cfg_get_parser_offset(section);
-
- /*
- * we have to figure out where this set is
- * in relation to other sets
- */
- relnum = 1;
- secnum = 0;
- numfound = 0;
-
- if (setp && nofield) {
- char tmpbuf[CFG_MAX_BUF];
- int rc;
- int nflds;
- int got;
-
- /*
- * Set specified but no field
- */
- for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
- if (!cfp->cf_fd) continue;
- if (cfp->cf_head->h_state & CFG_HDR_INVALID) {
- if (!cfg_read(cfp)) {
- cfg_perror_str =
- dgettext("cfg", CFG_RDFAILED);
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
- }
- while (numfound < setnum) {
- if ((*cfp->cf_pp->readcf)
- (cfp, tmpbuf, table_offset, relnum - secnum)
- == NULL) {
- secnum = relnum - 1;
- break;
- }
- if (cfg_filter_node(cfg, &chead[0], tmpbuf,
- section))
- numfound++;
-
- if (numfound == setnum)
- break;
-
- relnum++;
- }
- if (numfound == setnum)
- break;
- }
-
- /* Fail to find anything? */
- if (cfp >= &cfg->cf[2]) {
- errno = ESRCH;
- cfg_perror_str = dgettext("cfg", strerror(errno));
- cfg_severity = CFG_ENONFATAL;
- return (-1);
- }
-
- nflds = cfg_get_num_flds(&chead[0], section, &table_index);
-
- if (value == NULL) {
- /* Remove entry completely */
-
- rc = (*cfp->cf_pp->remcf)(cfp, table_index,
- relnum - secnum);
- if (rc < 0)
- return (rc);
- return (0);
- }
-
- got = cfg_cnt_flds(value);
- bzero(buf, sizeof (buf));
-
- strncpy(buf, " ", 1);
- if (strlen(value) > sizeof (buf) - 2) {
- errno = E2BIG;
- cfg_perror_str = dgettext("cfg", strerror(errno));
- cfg_severity = CFG_ENONFATAL;
- return (-1);
- }
- strncat(buf, value, val_len);
- if (got < nflds) {
- for (/* CSTYLED */; got < nflds; got++)
- strncat(buf, " - ", 3);
- } else if (got > nflds) {
- return (-1);
- } else {
- /* got == nflds, so cnode was included */
- addcnode = 0;
- }
-
- bufp = buf;
- if (addcnode) {
- cfg_insert_node(cfg, &chead[0], buf, section);
- }
-
- (*cfp->cf_pp->replacecf)(cfp, bufp, table_index,
- relnum - secnum);
-
- return (TRUE);
- }
-
- /*
- * Both Set and field are specified
- * needs to get current whole entry and old requested field
- * copy good fields to buf, replace new field in buf
- * move everything depending of new size
- * replace entry so set# does not change
- */
- if (setp && itemp) {
- int rc;
- int nflds;
- int cnodepos;
-
- for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
- if (!cfp->cf_fd) continue;
- if (cfp->cf_head->h_state & CFG_HDR_INVALID) {
- if (!cfg_read(cfp)) {
- cfg_perror_str =
- dgettext("cfg", CFG_RDFAILED);
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
- }
- while (numfound < setnum) {
- if ((*cfp->cf_pp->readcf)
- (cfp, buf, table_offset, relnum - secnum)
- == NULL) {
- secnum = relnum - 1;
- break;
- }
- if (cfg_filter_node(cfg, &chead[0], buf,
- section))
- numfound++;
-
- if (numfound == setnum)
- break;
-
- relnum++;
- }
- if (numfound == setnum)
- break;
- }
-
- /* Fail to find anything? */
- if (cfp >= &cfg->cf[2]) {
- errno = ESRCH;
- cfg_perror_str = dgettext("cfg", strerror(errno));
- cfg_severity = CFG_ENONFATAL;
- return (-1);
- }
-
- nflds = cfg_get_num_flds(&chead[0], section, &table_index);
- fldnum = cfg_get_item(&chead[0], section, itemp);
- bzero(newbuf, sizeof (newbuf));
- strncpy(newbuf, " ", 1);
-
- /* move good flds in */
- rc = cfg_fld_mov(newbuf, buf, 1, fldnum - 1);
- if (rc < 0)
- return (rc);
-
- /* move new fld in */
- strncat(newbuf, value, strlen(value));
- strcat(newbuf, " ");
-
- /* move remaining flds in */
- rc = cfg_fld_mov(newbuf, buf, fldnum + 1, nflds);
- if (rc < 0)
- return (rc);
-
- cnodepos = cfg_get_item(&chead[0], section, "cnode");
- if ((cnodepos >= 0) && strcmp(itemp, "cnode") != 0) {
- /* add cnode if user didn't specify it */
- cfg_insert_node(cfg, &chead[0],
- newbuf, section);
- }
-
- (*cfp->cf_pp->replacecf)(cfp, newbuf, table_index,
- relnum - secnum);
-
- return (TRUE);
- }
-
- if (noset) { /* blast entire thing in */
- int nflds;
- int got;
- int cnodepos;
-
- bufp = buf;
- if (!value) { /* we shouldn't be here */
- errno = EINVAL;
- return (-1);
- }
- strncat(buf, " ", 1);
- if (strlen(value) > sizeof (buf) - 2) {
- errno = E2BIG;
- return (-1);
- }
-
- strncat(buf, value, val_len);
- nflds = cfg_get_num_flds(&chead[0], section, &table_index);
- got = cfg_cnt_flds(value);
-
- cnodepos = cfg_get_item(&chead[0], section, "cnode");
- if (cnodepos < 0 || got >= cnodepos) {
- /* no cnode, or cnode was specified by caller */
- addcnode = 0;
- }
-
- if (got < nflds) {
- for (/* CSTYLED */; got < nflds; got++)
- strncat(buf, " - ", 3);
- } else if (got > nflds) {
- errno = EINVAL; /* specified too many fields */
- return (-1);
- } else {
- /* got == nflds, so cnode was included */
- addcnode = 0;
- }
-
- if (addcnode) {
- cfg_insert_node(cfg, &chead[0], buf, section);
- }
-
- /* Make sure we put this entry in the right database */
- if (cfg_is_cnode(cfg, &chead[0], buf, section) &&
- cfg->cf[1].cf_fd)
- cfp = &cfg->cf[1];
- else
- cfp = &cfg->cf[0];
-
- if (cfp->cf_head->h_state & CFG_HDR_INVALID) {
- if (!cfg_read(cfp)) {
- cfg_perror_str = dgettext("cfg", CFG_RDFAILED);
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
- }
- if (cfp->cf_head->h_csize + strlen(buf) > CFG_DEFAULT_SSIZE) {
- errno = ENOSPC;
- return (-1);
- }
-
- (*cfp->cf_pp->addcf)(cfp, bufp, table_index);
-
- return (TRUE);
- }
-
- errno = EINVAL;
- cfg_perror_str = strerror(errno);
- cfg_severity = CFG_ENONFATAL;
- return (-1);
-}
-
-/*
- * cfg_encode_char
- *
- * Encode a single character into % + hex ascii value
- */
-static void
-cfg_encode_char(char *result, char ch)
-{
- *result++ = '%';
- *result++ = dectohex[ (ch >> 4) & 0xf ];
- *result++ = dectohex[ ch & 0xf ];
-}
-
-/*
- * cfg_decode_char
- *
- * Reverses cfg_encode_char
- */
-static char
-cfg_decode_char(char *code)
-{
- char retval;
- if (*code != '%') {
- return ('\0');
- }
- ++code;
- if (!isxdigit(*code))
- return ('\0');
- retval = (isdigit(*code)? *code - '0' : *code - 'a' + 10);
- retval <<= 4;
- ++code;
- if (!isxdigit(*code))
- return ('\0');
- retval |= (isdigit(*code)? *code - '0' : *code - 'a' + 10);
-
- return (retval);
-}
-
-/*
- * cfg_encode_option
- *
- * Transforms the key and value strings so that special characters
- * can be used within the options field.
- *
- * Returns:
- * Length of encoded string; -1 on failure
- */
-static int
-cfg_encode_string(char *str, char *output, int outlen)
-{
- char *mem, *p, *q;
- int curlen;
-
-
- /* first, scan through the tag string converting %-signs */
- p = str;
- q = output;
- curlen = 0;
- while (*p && curlen < outlen) {
- if (*p == '%') {
- if (curlen + 3 >= outlen) {
- return (-1);
- }
- cfg_encode_char(q, *p);
- curlen += 3;
- q += 3;
- } else {
- *q++ = *p;
- ++curlen;
- }
- ++p;
- }
- if (curlen < outlen)
- *q = '\0';
-
- /* now encode special characters */
- p = mem = strdup(output);
- q = output;
- curlen = 0;
- while (*p && curlen < outlen) {
- if (strchr(CHARS_TO_ENCODE, *p) != 0) {
- if (curlen + 3 >= outlen) {
- free(mem);
- return (-1);
- }
- cfg_encode_char(q, *p);
- curlen += 3;
- q += 3;
- } else {
- *q++ = *p;
- ++curlen;
- }
- ++p;
- }
- free(mem);
-
- if (curlen < outlen)
- *q = '\0';
- /* LINTED possible ptrdiff_t overflow */
- return (q - output);
-}
-
-/*
- * cfg_decode_option
- *
- * Given a string, decodes any %-encodes on it.
- */
-static void
-cfg_decode_string(char *str, char *output, int outlen)
-{
- char *p, *q;
- int curlen;
-
- p = str;
- q = output;
- curlen = 0;
- while (*p && curlen < outlen) {
- if (*p == '%') {
- char ch = cfg_decode_char(p);
- if (!ch) {
- *q++ = *p++;
- ++curlen;
- } else {
- *q++ = ch;
- p += 3;
- ++curlen;
- }
- } else {
- *q++ = *p++;
- ++curlen;
- }
- }
- if (curlen < outlen)
- *q = '\0';
-}
-
-/*
- * cfg_get_options
- * return first options set from basekey
- * Subsequent calls with basekey = NULL return next option if any
- * into tag and val
- * returns
- * true success and more options data
- * -1 no options data
- */
-
-int
-cfg_get_options(CFGFILE *cfg, int section, const char *basekey, char *tag,
- int tag_len, char *val, int val_len)
-{
- static char buf[CFG_MAX_BUF];
- char decode_buf[CFG_MAX_BUF];
- int rc;
- char *ttag, *tval;
-
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
-
- errno = ENOSYS;
- if (basekey == 0) {
- ttag = strtok(NULL, "=");
- } else {
- bzero(buf, CFG_MAX_BUF);
- if (section == CFG_SEC_CONF) {
- rc = cfg_get_cstring(cfg, basekey, buf, CFG_MAX_BUF);
- } else
- return (-1);
- if (rc < 0)
- return (rc);
- /* buf now contains raw options data */
- ttag = strtok(buf, "=");
- }
- tval = strtok(NULL, ";");
- if (!(tval) || !(ttag))
- return (-1);
- if ((strlen(tval) > val_len) || (strlen(ttag) > tag_len)) {
- errno = E2BIG;
- return (-1);
- }
- cfg_decode_string(tval, decode_buf, CFG_MAX_BUF);
- strncpy(val, decode_buf, val_len);
- cfg_decode_string(ttag, decode_buf, CFG_MAX_BUF);
- strncpy(tag, decode_buf, tag_len);
- errno = 0;
- return (TRUE);
-}
-
-/*
- * cfg_put_options
- *
- * Replaces existing tag with new val. If tag doesn't exist,
- * then it adds a new tag with the specified val.
- *
- * Return:
- * true success
- * -1 incorrect section, or read error from cfg DB
- */
-int
-cfg_put_options(CFGFILE *cfg, int section, const char *basekey, char *tag,
- char *val)
-{
- char buf[CFG_MAX_BUF];
- char encode_buf[CFG_MAX_BUF];
- char *p;
- int enclen;
-
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
-
- errno = ENOSYS;
- bzero(buf, CFG_MAX_BUF);
- if (section != CFG_SEC_CONF) {
- cfg_severity = CFG_ENONFATAL;
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- return (-1);
- }
- if (!tag || !*tag || !val || !*val)
- return (-1);
- if (cfg_get_cstring(cfg, basekey, buf, CFG_MAX_BUF) < 0) {
- /* cfg severity & perror_str set up cfg_get_cstring() */
- return (-1);
- }
- *encode_buf = ';';
- enclen = cfg_encode_string(tag, &encode_buf[1], CFG_MAX_BUF - 1) + 1;
- if (enclen < 1 || (enclen + 1) >= CFG_MAX_BUF) {
- cfg_severity = CFG_ENONFATAL;
- cfg_perror_str = dgettext("cfg", "Buffer too small");
- return (-1);
- }
- encode_buf[enclen] = '=';
- encode_buf[enclen + 1] = '\0';
-
- /* check the start of the string */
- if (strncmp(buf, &encode_buf[1], enclen) == 0) {
- /* locate the end of this option */
- p = strchr(buf, ';');
- if (p && *(p + 1) != '\0') {
- /* add the new tag to the end */
- ++p;
- strcat(p, &encode_buf[1]);
- } else {
- /* completely overwrite the existing tag */
- p = buf;
- strcpy(p, &encode_buf[1]);
- }
- if (cfg_encode_string(val, encode_buf, CFG_MAX_BUF) < 0) {
- cfg_severity = CFG_ENONFATAL;
- cfg_perror_str = dgettext("cfg", "Buffer too small");
- return (-1);
- }
- strcat(p, encode_buf);
- strcat(p, ";");
- if (cfg_put_cstring(cfg, basekey, p, strlen(p)) < 0) {
- /* severity & perror_str set by cfg_put_cstring */
- return (-1);
- }
- errno = 0;
- return (TRUE);
- }
-
- /* it's hiding somewhere inside... */
- p = strstr(buf, encode_buf);
- if (p) {
- /* delete the old value */
- char *q = strchr(p + 1, ';');
- if (q) {
- strcpy(p + 1, q + 1);
- } else {
- *p = '\0';
- }
- strcat(buf, &encode_buf[1]);
- } else if (*buf) {
- strcat(buf, &encode_buf[1]);
- } else {
- strcpy(buf, &encode_buf[1]);
- }
- enclen = cfg_encode_string(val, encode_buf, CFG_MAX_BUF);
- if (enclen < 0 || (strlen(buf) + enclen) >= CFG_MAX_BUF) {
- cfg_severity = CFG_ENONFATAL;
- cfg_perror_str = dgettext("cfg", "Buffer too small");
- return (-1);
- }
- strcat(buf, encode_buf);
- strcat(buf, ";");
- if (cfg_put_cstring(cfg, basekey, buf, CFG_MAX_BUF) < 0) {
- /* severity & perror_str set by cfg_put_cstring */
- return (-1);
- }
- errno = 0;
- return (TRUE);
-}
-
-/*
- * cfg_get_single_option
- *
- * Scans the options string for the specified option and returns
- * the decoded value
- *
- * Return:
- * true success
- * -1 incorrect section, or read error from cfg DB
- */
-int
-cfg_get_single_option(CFGFILE *cfg, int section, const char *basekey, char *tag,
- char *val, int val_len)
-{
- char buf[CFG_MAX_BUF];
- char encode_buf[CFG_MAX_BUF];
- char *p, *q;
- int enclen;
-
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
-
- errno = ENOSYS;
- bzero(buf, CFG_MAX_BUF);
- if (section != CFG_SEC_CONF) {
- cfg_severity = CFG_ENONFATAL;
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- return (-1);
- }
- if (cfg_get_cstring(cfg, basekey, buf, CFG_MAX_BUF) < 0) {
- /* severity & perror_str set by cfg_get_cstring */
- return (-1);
- }
-
- *encode_buf = ';';
- enclen = cfg_encode_string(tag, &encode_buf[1], CFG_MAX_BUF - 1) + 1;
- if (enclen < 1 || (enclen + 1) >= CFG_MAX_BUF) {
- cfg_severity = CFG_ENONFATAL;
- cfg_perror_str = dgettext("cfg", "Buffer too small");
- return (-1);
- }
- encode_buf[enclen] = '=';
- encode_buf[enclen + 1] = '\0';
-
- /* check the start of the string */
- if (strncmp(buf, &encode_buf[1], enclen) == 0) {
- p = strchr(buf, '=');
- if (!p) {
- cfg_severity = CFG_ENONFATAL;
- cfg_perror_str = dgettext("cfg", "Option not found");
- return (-1);
- }
- ++p;
- q = strchr(p, ';');
- if (q) {
- *q = '\0';
- }
- cfg_decode_string(p, val, val_len);
- errno = 0;
- return (TRUE);
- }
-
- /* it's hiding somewhere inside... */
- p = strstr(buf, encode_buf);
- if (p) {
- p += enclen + 1;
- q = strchr(p, ';');
- if (q) {
- *q = '\0';
- }
- cfg_decode_string(p, val, val_len);
- errno = 0;
- return (TRUE);
- }
-
- /* key not found */
- return (-1);
-
-}
-
-/*
- * cfg_del_option
- *
- * Removes a single key=val pair from the specified option field
- *
- * Return:
- * true success
- * -1 unable to update config
- */
-int
-cfg_del_option(CFGFILE *cfg, int section, const char *basekey, char *tag)
-{
- char buf[CFG_MAX_BUF];
- char encode_buf[CFG_MAX_BUF];
- char *p, *q;
- int enclen, rc;
-
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
-
- bzero(buf, CFG_MAX_BUF);
- if (section != CFG_SEC_CONF) {
- cfg_severity = CFG_ENONFATAL;
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- return (-1);
- }
- if (cfg_get_cstring(cfg, basekey, buf, CFG_MAX_BUF) < 0) {
- /* severity & perror_str are set by cfg_get_cstring */
- return (-1);
- }
-
- *encode_buf = ';';
- enclen = cfg_encode_string(tag, &encode_buf[1], CFG_MAX_BUF - 1) + 1;
- if (enclen < 1 || (enclen + 1) >= CFG_MAX_BUF) {
- cfg_severity = CFG_ENONFATAL;
- cfg_perror_str = dgettext("cfg", "Buffer too small");
- return (-1);
- }
- encode_buf[enclen] = '=';
- encode_buf[enclen + 1] = '\0';
-
- /* check the start of the string */
- if (strncmp(buf, &encode_buf[1], enclen) == 0) {
- p = strchr(buf, ';');
- if (p && (*(p + 1) != '\0')) {
- rc = cfg_put_cstring(cfg, basekey, p + 1,
- strlen(p + 1));
- } else {
- rc = cfg_put_cstring(cfg, basekey, "-", 1);
- }
- /* severity & perror_str are set by cfg_put_cstring */
- return (rc);
- }
-
- /* sigh */
- p = strstr(buf, encode_buf);
- if (!p) {
- /* already removed */
- return (TRUE);
- }
- q = strchr(p + 1, ';');
-
- /*
- * Now the string looks like:
- * | first few options | *p | option to remove | *q | rest | '\0'
- */
-
- if (!q) {
- /* hum... */
- *p = '\0';
- } else {
- strcpy(p, q);
- }
-
- return (cfg_put_cstring(cfg, basekey, buf, strlen(buf)));
-}
-
-static void
-cfg_set_memorymap(cfp_t *cfp)
-{
- cfgheader_t *hd = cfp->cf_head;
-
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr, "callocing %d for initial reads\n", hd->h_csize);
-#endif
-
- hd->h_ccopy1 = (char *)calloc(hd->h_csize, sizeof (char));
- hd->h_ccopy2 = (char *)calloc(hd->h_csize, sizeof (char));
- hd->h_sizes1 = (int *)calloc(CFG_DEFAULT_PSIZE, sizeof (int));
- hd->h_sizes2 = (int *)calloc(CFG_DEFAULT_PSIZE, sizeof (int));
-}
-
-/*
- * cfg_init_header
- * fill in default header info
- */
-static void
-cfg_init_header(cfp_t *cfp)
-{
- time_t tloc;
- cfgheader_t *hd = cfp->cf_head;
-
- hd->h_magic = (int32_t)CFG_NEW_MAGIC;
- hd->h_stamp = time(&tloc);
- hd->h_lock = 0;
- /* parser config */
- hd->h_parsesize = 0;
- hd->h_parseoff = 0;
- hd->h_csize = 0;
- hd->h_psize = 0;
- hd->h_cfgs = NULL;
- hd->h_ncfgs = 0;
- hd->h_seq1 = hd->h_seq2 = 1;
- bzero(hd->h_cfgsizes, MAX_CFG * sizeof (int));
-}
-/*
- * cfg_read
- * read header and all sections of configuration file
- * gets new data for incore copy
- * removes invalid header state
- * works even if config and persistent sections are empty
- *
- */
-static int
-cfg_read(cfp_t *cfp)
-{
- int rc;
- cfgheader_t *hd;
- int readsize = 0;
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr, "cfg_read\n");
-#endif
-
- if (!cfp->cf_head) {
- if ((hd = calloc(1, sizeof (*hd))) == NULL)
- return (FALSE);
-#ifdef DEBUG_HDR
- (void) fprintf(stderr, "initial cfg header read\n");
-#endif
- cfp->cf_head = hd;
- }
-
- if ((*cfp->cf_pp->seek)(cfp, 0, SEEK_SET) < 0) {
-#ifdef DEBUG_LIB
- (void) fprintf(stderr, "cfg: seek header failed\n");
-#endif
- return (FALSE);
- }
-
- rc = (*cfp->cf_pp->read)(cfp, (char *)cfp->cf_head, 4);
- if (rc < 4) {
-#ifdef DEBUG_LIB
- (void) fprintf(stderr, "cfg: read magic number failed\n");
-#endif
- return (FALSE);
- }
-
- if ((*cfp->cf_pp->seek)(cfp, 0, SEEK_SET) < 0) {
-#ifdef DEBUG_LIB
- (void) fprintf(stderr, "cfg: seek header failed\n");
-#endif
- return (FALSE);
- }
-
- rc = (*cfp->cf_pp->read)(cfp, (char *)cfp->cf_head, sizeof (*hd));
- if (rc < sizeof (*hd)) {
-#ifdef DEBUG_LIB
- (void) fprintf(stderr, "cfg: read header failed\n");
-#endif
- return (FALSE);
- }
-
- cfp->cf_head->h_cfgs = NULL;
- cfg_set_memorymap(cfp);
- if (cfp->cf_head->h_magic != CFG_NEW_MAGIC) {
-#ifdef DEBUG_LIB
- (void) fprintf(stderr, "cfg_read: wrong MAGIC number %x\n",
- cfp->cf_head->h_magic);
-#endif
- return (FALSE);
- }
-
- cfp->cf_head->h_state &= ~(CFG_HDR_INVALID);
-
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr, "reading parser\n");
-#endif
- rc = (*cfp->cf_pp->read)(cfp, (char *)cfp->cf_mapped,
- CFG_DEFAULT_PARSE_SIZE);
- if (rc < sizeof (*hd)) {
-#ifdef DEBUG
- (void) fprintf(stderr, "cfg: read parse config failed\n");
-#endif
- return (FALSE);
- }
-
- readsize = cfp->cf_head->h_csize;
-
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr, "reading copy1 readsize = %d\n", readsize);
-#endif
- rc = (*cfp->cf_pp->read)(cfp, (char *)cfp->cf_head->h_ccopy1,
- readsize);
- if (rc < 0) {
- /* don't fail just return */
-#ifdef DEBUG
- (void) fprintf(stderr, "cfg: read ccopy1 section failed\n");
-#endif
- return (FALSE);
- }
-
- if ((*cfp->cf_pp->seek)
- (cfp, CFG_DEFAULT_SSIZE - rc, SEEK_CUR) < 0) {
-#ifdef DEBUG
- (void) fprintf(stderr, "cfg: seek (SEEK_CUR) failed\n");
-#endif
- return (FALSE);
- }
-
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr, "reading copy2 readsize = %d\n", readsize);
-#endif
-
- rc = (*cfp->cf_pp->read)(cfp, (char *)cfp->cf_head->h_ccopy2,
- readsize);
- if (rc < 0) {
- /* don't fail just return */
-#ifdef DEBUG
- (void) fprintf(stderr, "cfg: read ccopy2 section failed\n");
-#endif
- return (FALSE);
- }
-
- /* read the sizes of the lists from disk */
- if ((*cfp->cf_pp->seek)
- (cfp, CFG_DEFAULT_SSIZE - rc, SEEK_CUR) < 0) {
-#ifdef DEBUG
- (void) fprintf(stderr, "cfg: seek (SEEK_CUR) failed\n");
-#endif
- return (FALSE);
- }
-
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr, "reading sizes\n");
-#endif
- rc = (*cfp->cf_pp->read)(cfp, (int *)cfp->cf_head->h_sizes1,
- CFG_DEFAULT_PSIZE);
- if (rc < 0) {
-#ifdef DEBUG
- (void) fprintf(stderr, "cfg: read h_sizes1 failed\n");
-#endif
- return (FALSE);
- }
-
- rc = (*cfp->cf_pp->read)(cfp, (int *)cfp->cf_head->h_sizes2,
- CFG_DEFAULT_PSIZE);
- if (rc < 0) {
-#ifdef DEBUG
- (void) fprintf(stderr, "cfg: read h_sizes2 failed\n");
-#endif
- return (FALSE);
- }
-
- /*
- * If initial or invalid sequence, use first section
- */
- if ((cfp->cf_head->h_seq1 <= 0) && (cfp->cf_head->h_seq2 <= 0)) {
- cfp->cf_head->h_cparse = cfp->cf_head->h_ccopy1;
- cfp->cf_head->h_sizes = cfp->cf_head->h_sizes1;
- }
-
- if (cfp->cf_head->h_seq1 >= cfp->cf_head->h_seq2) {
- cfp->cf_head->h_cparse = cfp->cf_head->h_ccopy1;
- cfp->cf_head->h_sizes = cfp->cf_head->h_sizes1;
- } else {
- cfp->cf_head->h_cparse = cfp->cf_head->h_ccopy2;
- cfp->cf_head->h_sizes = cfp->cf_head->h_sizes2;
- }
-
-#ifdef DEBUG_LIB
- dump_status(cfp, "cfg_read");
-#endif
-
- return (TRUE);
-}
-
-/*
- * cfg_lock
- * Read-write locking of the configuration
- * reads into core all sections
- * builds parser trees for each section
- * Returns: TRUE if the lock was acquired, FALSE otherwise.
- */
-int
-cfg_lock(CFGFILE *cfg, CFGLOCK mode)
-{
- cfp_t *cfp;
- int is_locked = 0;
- int rc;
-
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return (FALSE);
- }
-
- if (mode == CFG_UPGRADE) {
- mode = CFG_WRLOCK;
- }
-
- if (mode == CFG_WRLOCK && (cfg->cf[0].cf_flag & CFG_RDONLY)) {
- goto fail;
- }
-
- /*
- * if you don't even give me the right lock request,
- * why should I give you one?
- */
- if (mode != CFG_RDLOCK && mode != CFG_WRLOCK)
- goto fail;
-
- if (cfg_lockd) {
- if (mode == CFG_WRLOCK)
- cfg_lockd_wrlock();
- else
- cfg_lockd_rdlock();
- is_locked = 1;
- } else {
-
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr, "cfg_lock\n");
-#endif
- /* Lock is always based on local file pointer */
- cfg->cf[1].cf_lock = cfg->cf[0].cf_lock = cfg->cf[0].cf_fd;
-
- if (!((cfg->cf[0].cf_flag & CFG_RDONLY) &&
- (mode == CFG_RDLOCK))) {
-
- struct flock lk = {0};
- lk.l_type = (mode == CFG_RDLOCK ? F_RDLCK : F_WRLCK);
- lk.l_whence = SEEK_SET;
- lk.l_start = (off_t)0;
- lk.l_len = (off_t)0;
-
- if (fcntl(cfg->cf[0].cf_lock, F_SETLKW, &lk) < 0)
- goto fail;
- }
- }
-
- /* Determine number of files open */
- for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
- if (!cfp->cf_fd) continue;
- if ((cfp->cf_head) &&
- (cfp->cf_head->h_state & CFG_HDR_INVALID)) {
- if ((rc = cfg_hdrcmp(cfp)) == 0) {
-#ifdef DEBUG_HDR
- (void) fprintf(stderr,
- "cfg header match, skipping re-read\n");
-#endif
- cfp->cf_head->h_state |= CFG_HDR_RDLOCK;
- if (mode == CFG_WRLOCK)
- cfp->cf_head->h_state |= CFG_HDR_WRLOCK;
-
- cfp->cf_head->h_state &= ~(CFG_HDR_INVALID);
- continue;
- }
-#ifdef DEBUG_HDR
- (void) fprintf(stderr, "re-reading cfg, header mismatch\n");
-#endif
- /*
- * dump what we have, info is stale
- */
- cfg_free_cfglist(cfp);
- cfg_free_parser_tree();
-
- if (cfp->cf_head->h_ccopy1) {
- free(cfp->cf_head->h_ccopy1);
- cfp->cf_head->h_ccopy1 = NULL;
- }
- if (cfp->cf_head->h_ccopy2) {
- free(cfp->cf_head->h_ccopy2);
- cfp->cf_head->h_ccopy2 = NULL;
- }
- if (cfp->cf_head->h_sizes1) {
- free(cfp->cf_head->h_sizes1);
- cfp->cf_head->h_sizes1 = NULL;
- }
- if (cfp->cf_head->h_sizes2) {
- free(cfp->cf_head->h_sizes2);
- cfp->cf_head->h_sizes2 = NULL;
- }
-
- if (cfp->cf_head)
- free(cfp->cf_head);
- cfp->cf_head = NULL;
- }
-
- if (cfp->cf_head == NULL) {
- if (!cfg_read(cfp)) {
- if (cfp->cf_head != NULL)
- cfg_init_header(cfp);
- else
- goto fail;
- } else {
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr,
- "reading parser config\n");
-#endif
- /* build parser trees */
- cfg_read_parser_config(cfp);
- }
-
- }
- cfp->cf_head->h_state |= CFG_HDR_RDLOCK;
- if (mode == CFG_WRLOCK) {
- if (cfp->cf_head->h_seq1 >= cfp->cf_head->h_seq2) {
-#ifdef DEBUG_LIB
- (void) fprintf(stderr,
- "cfg_lock: WRLOCK copying 1 to 2\n");
-#endif
- memcpy(cfp->cf_head->h_ccopy2,
- cfp->cf_head->h_ccopy1,
- cfp->cf_head->h_csize);
- memcpy(cfp->cf_head->h_sizes2,
- cfp->cf_head->h_sizes1,
- CFG_DEFAULT_PSIZE);
-
- cfp->cf_head->h_cparse = cfp->cf_head->h_ccopy2;
- cfp->cf_head->h_sizes = cfp->cf_head->h_sizes2;
- } else {
-#ifdef DEBUG_LIB
- (void) fprintf(stderr,
- "cfg_lock: WRLOCK copying 2 to 1\n");
-#endif
- memcpy(cfp->cf_head->h_ccopy1,
- cfp->cf_head->h_ccopy2,
- cfp->cf_head->h_csize);
- memcpy(cfp->cf_head->h_sizes1,
- cfp->cf_head->h_sizes2,
- CFG_DEFAULT_PSIZE);
-
- cfp->cf_head->h_cparse = cfp->cf_head->h_ccopy1;
- cfp->cf_head->h_sizes = cfp->cf_head->h_sizes1;
- }
-
- cfp->cf_head->h_state |= CFG_HDR_WRLOCK;
- }
-
- if (cfg_map_cfglists(cfp) < 0) {
-#ifdef DEBUG_LIB
- (void) fprintf(stderr, "cfg: map_cfglists failed\n");
-#endif
- goto fail;
- }
-
-#ifdef DEBUG_LIB
- dump_status(cfp, "cfg_lock");
-#endif
- }
-
- return (TRUE);
-
-fail:
- if (is_locked) {
- cfg_lockd_unlock();
- }
- cfg_perror_str = dgettext("cfg", CFG_EGENERIC);
- cfg_severity = CFG_ENONFATAL;
- return (FALSE);
-}
-
-/*
- * Unlock the database
- */
-void
-cfp_unlock(cfp_t *cfp)
-{
-
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr, "cfg_unlock\n");
-#endif
- if (cfg_lockd) {
- cfg_lockd_unlock();
- } else {
- struct flock lk = {0};
- lk.l_type = F_UNLCK;
- lk.l_whence = SEEK_SET;
- lk.l_start = (off_t)0;
- lk.l_len = (off_t)0;
- (void) fcntl(cfp->cf_lock, F_SETLKW, &lk);
- }
-
- if (cfp->cf_head != NULL) {
- cfp->cf_head->h_state &= ~(CFG_HDR_RDLOCK|CFG_HDR_WRLOCK);
- cfp->cf_head->h_state |= CFG_HDR_INVALID;
- }
-}
-void
-cfg_unlock(CFGFILE *cfg)
-{
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return;
- }
-
- cfp_unlock(&cfg->cf[0]);
- cfp_unlock(&cfg->cf[1]);
-}
-
-/*
- * Test for a read lock, set errno if failed.
- */
-static int
-cfg_rdlock(CFGFILE *cfg)
-{
- int rc;
- cfp_t *cfp;
-
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return (FALSE);
- }
-
- /* Determine number of files open */
- for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
- if (!cfp->cf_fd)
- continue;
- if (cfp->cf_head == NULL) {
-#ifdef DEBUG_LIB
- (void) fprintf(stderr, "cfg_rdlock: cf_head == NULL\n");
-#endif
- /*
- * 6335583, if header == NULL,
- * we can't call cfg_read to fill the header again
- * since it will change the lock state to
- * CFG_HDR_WRLOCK and dscfg will be the processer
- * that hold the lock,
- * just returning a FALSE if the case,
- * then retrieve the lock state from flock structure.
- */
- rc = FALSE;
- break;
- } else {
-#ifdef DEBUG_LIB
- (void) fprintf(stderr, "cfg_rdlock: cf_head != NULL\n");
-#endif
- if ((cfp->cf_head->h_state & CFG_HDR_RDLOCK)
- == CFG_HDR_RDLOCK) {
- rc = TRUE;
- } else {
- rc = FALSE;
- break;
- }
- }
- }
-
- if (!rc)
- errno = EPERM;
-
- return (rc);
-}
-
-/*
- * Test for a write lock, set errno if failed.
- */
-static int
-cfg_wrlock(CFGFILE *cfg)
-{
- int rc;
- cfp_t *cfp;
-
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return (FALSE);
- }
-
- /* Determine number of files open */
- for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
- if (!cfp->cf_fd)
- continue;
- if (cfp->cf_head == NULL) {
-#ifdef DEBUG_LIB
- (void) fprintf(stderr, "cfg wrlock: cf_head == NULL\n");
-#endif
- /*
- * 6335583, see comments on cfg_rdlock
- */
- rc = FALSE;
- break;
- } else {
-#ifdef DEBUG_LIB
- (void) fprintf(stderr, "cfg wrlock: cf_head != NULL\n");
-#endif
- if ((cfp->cf_head->h_state & CFG_HDR_WRLOCK)
- == CFG_HDR_WRLOCK) {
- rc = TRUE;
- } else {
- rc = FALSE;
- break;
- }
- }
- }
-
- if (!rc)
- errno = EPERM;
-
- return (rc);
-}
-
-/*
- * cfg_get_lock
- * Find lock status of CFG database.
- * Returns: TRUE and sets lock and pid if the lock is held, FALSE otherwise.
- */
-int
-cfg_get_lock(CFGFILE *cfg, CFGLOCK *lock, pid_t *pid)
-{
- struct flock lk;
- int rc;
-
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return (FALSE);
- }
-
- if (cfg_lockd) {
- switch (cfg_lockedby(pid)) {
- case LOCK_READ:
- *lock = CFG_RDLOCK;
- return (TRUE);
- case LOCK_WRITE:
- *lock = CFG_WRLOCK;
- return (TRUE);
- case LOCK_NOTLOCKED:
- default:
- return (FALSE);
- }
- } else {
- if (cfg_wrlock(cfg)) {
- *lock = CFG_WRLOCK;
- *pid = getpid();
- return (TRUE);
- }
-
- if (cfg_rdlock(cfg)) {
- *lock = CFG_RDLOCK;
- *pid = getpid();
- return (TRUE);
- }
- }
- /* Lock is always based on local file pointer */
- cfg->cf[1].cf_lock = cfg->cf[0].cf_lock = cfg->cf[0].cf_fd;
-
- bzero(&lk, sizeof (lk));
- lk.l_type = F_WRLCK;
- lk.l_whence = SEEK_SET;
- lk.l_start = (off_t)0;
- lk.l_len = (off_t)0;
-
- if (fcntl(cfg->cf[0].cf_lock, F_GETLK, &lk) < 0)
- rc = FALSE;
- else {
- if (lk.l_type == F_UNLCK)
- rc = FALSE;
- else {
- rc = TRUE;
- *pid = lk.l_pid;
- *lock = lk.l_type == F_WRLCK ? CFG_WRLOCK : CFG_RDLOCK;
- }
- }
-
- return (rc);
-}
-
-/*
- * cfg_commit
- * Write modified version of header, configuration and persistent
- * data using 2 stage commit.
- * If no valid data is found in header, it is assumed to be an initial
- * write and we will create the default header (could be dangerous)
- * another tricky part, if we are doing an upgrade we may be dealing
- * with an old database. we need to take care seeking and writing
- * until such time that it is upgraded.
- *
- * Mutual exclusion is checked using cfg_lock
- */
-
-int
-cfg_commit(CFGFILE *cfg)
-{
- cfp_t *cfp;
- int rc;
- time_t tloc;
- int section;
- int wrsize, *ip;
-
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return (FALSE);
- }
-
- if (!cfg_wrlock(cfg))
- return (FALSE);
-
- /* Determine number of files open */
- for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
- if (!cfp->cf_fd)
- continue;
-
- /*
- * lets put everything back into one char *
- */
- cfg_replace_lists(cfp);
-
- if ((*cfp->cf_pp->seek)(cfp, 0, SEEK_SET) < 0) {
-#ifdef DEBUG_LIB
- (void) fprintf(stderr, "cfg: seek header failed\n");
-#endif
- return (FALSE);
- }
-
- cfp->cf_head->h_size = cfp->cf_head->h_parsesize
- + cfp->cf_head->h_csize + cfp->cf_head->h_psize;
- cfp->cf_head->h_stamp = time(&tloc);
-
- /* seeking into database */
- if ((*cfp->cf_pp->seek)(cfp, sizeof (cfgheader_t),
- SEEK_CUR) < 0)
- return (FALSE);
-
- if (cfp->cf_head->h_ccopy1 == cfp->cf_head->h_cparse) {
- if (cfp->cf_head->h_seq1 < 0)
- cfp->cf_head->h_seq1 = 1;
- else
- cfp->cf_head->h_seq1 = cfp->cf_head->h_seq2 + 1;
- section = 1;
- } else {
- if (cfp->cf_head->h_seq2 < 0)
- cfp->cf_head->h_seq2 = 1;
- else
- cfp->cf_head->h_seq2 = cfp->cf_head->h_seq1 + 1;
- section = 2;
- }
-#ifdef DEBUG_LIB
- dump_status(cfp, "cfg_commit");
-#endif
- rc = (*cfp->cf_pp->write)(cfp, cfp->cf_mapped,
- CFG_DEFAULT_PARSE_SIZE);
-#ifdef DEBUG
- if (rc < 0) {
- (void) fprintf(stderr,
- "parse commit: rc %d h_parsesize %d\n",
- rc, cfp->cf_head->h_parsesize);
- }
-#endif
- if (section == 1) {
- rc = (*cfp->cf_pp->write) (cfp, cfp->cf_head->h_ccopy1,
- cfp->cf_head->h_csize);
-#ifdef DEBUG
- if (rc < 0) {
- (void) fprintf(stderr,
- "csection commit 1: rc %d h_csize %d\n",
- rc, cfp->cf_head->h_csize);
- }
-#endif
- if ((*cfp->cf_pp->seek)
- (cfp, (2 * CFG_DEFAULT_SSIZE) - rc, SEEK_CUR) < 0)
- return (FALSE);
-
- /*
- * limit the write to only what we need
- */
- ip = cfp->cf_head->h_sizes1;
- for (wrsize = 0; *ip; ip += *ip + 1)
- wrsize += *ip + 1;
-
- rc = (*cfp->cf_pp->write)(cfp, cfp->cf_head->h_sizes1,
- wrsize * sizeof (int));
-#ifdef DEBUG
- if (rc < 0) {
- (void) fprintf(stderr,
- "cfg: write list sizes1 failed rc\n");
- }
-#endif
- } else {
- if ((*cfp->cf_pp->seek)(cfp, CFG_DEFAULT_SSIZE,
- SEEK_CUR) < 0)
- return (FALSE);
-
- rc = (*cfp->cf_pp->write)(cfp, cfp->cf_head->h_ccopy2,
- cfp->cf_head->h_csize);
-#ifdef DEBUG
- if (rc < 0) {
- (void) fprintf(stderr,
- "csection commit 2: rc %d h_csize %d\n",
- rc, cfp->cf_head->h_csize);
- }
-#endif
- if ((*cfp->cf_pp->seek)
- (cfp, (CFG_DEFAULT_SSIZE + CFG_DEFAULT_PSIZE) - rc,
- SEEK_CUR) < 0)
- return (FALSE);
-
- /*
- * limit the write to only what we need
- */
- ip = cfp->cf_head->h_sizes2;
- for (wrsize = 0; *ip; ip += *ip + 1)
- wrsize += *ip + 1;
-
- rc = (*cfp->cf_pp->write)(cfp, cfp->cf_head->h_sizes2,
- wrsize * sizeof (int));
-#ifdef DEBUG
- if (rc < 0) {
- (void) fprintf(stderr,
- "cfg: write list sizes2 failed\n");
- }
-#endif
-
- }
-
-
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr,
- "writing h_csize %d\n", cfp->cf_head->h_csize);
-#endif
- if ((*cfp->cf_pp->seek)(cfp, 0, SEEK_SET) < 0)
- return (FALSE);
-
- cfp->cf_head->h_size = cfp->cf_head->h_parsesize +
- cfp->cf_head->h_csize + cfp->cf_head->h_psize;
-
- rc = (*cfp->cf_pp->write)(cfp, cfp->cf_head,
- sizeof (cfgheader_t));
- if (rc < 0) {
- cfg_perror_str = dgettext("cfg",
- "cfg_commit: header write failed");
- cfg_severity = CFG_EFATAL;
- return (FALSE);
- }
- }
-
- return (TRUE);
-}
-
-/*
- * cfg_rewind
- * rewind internal file pointer for specified section
- * empty now, rewind not necessary. But don't break
- * old code.
- */
-/*ARGSUSED*/
-void
-cfg_rewind(CFGFILE *cfg, int section)
-{
- switch (section) {
- case CFG_SEC_CONF:
- break;
- case CFG_SEC_ALL:
- break;
- };
-}
-
-/*
- * cfg_location
- * set or return the default location file to
- * determine the partition name of the configuration partition
- * location is stored in well known file location
- */
-char *
-cfg_location(char *location, int mode, char *altroot)
-{
- int fd;
- int fmode;
- int rc;
- char wellknown[NSC_MAXPATH];
- char loc[NSC_MAXPATH];
-
- if (mode == CFG_LOC_GET_LOCAL) {
- return (CFG_LOCAL_LOCATION);
- } else if (mode == CFG_LOC_GET_CLUSTER) {
- fmode = O_RDONLY;
- } else {
- fmode = O_RDWR | O_CREAT;
- }
-
- if (altroot) {
- strcpy(wellknown, altroot);
- strcat(wellknown, CFG_CLUSTER_LOCATION);
- } else
- strcpy(wellknown, CFG_CLUSTER_LOCATION);
-
- fd = open(wellknown, fmode, 0644);
- if (fd < 0) {
- cfg_perror_str = dgettext("cfg", strerror(errno));
- cfg_severity = CFG_ENONFATAL;
- return (NULL);
- }
-
- if (mode == CFG_LOC_SET_CLUSTER) {
- if (location == NULL || (strlen(location) > NSC_MAXPATH)) {
- cfg_perror_str = dgettext("cfg",
- "cfg_location: filename too big or missing");
- cfg_severity = CFG_EFATAL;
- return (NULL);
- }
-
- /*
- * 5082142
- * If we're in a cluster, make sure that the config location
- * is a raw device. Using non-raw did devices in a cluster
- * can result in data corruption, since inconsistent data
- * may reside in the block cache on one node, but has not
- * been flushed to disk.
- */
- if (cfg_iscluster() > 0) {
- struct stat dscfg_stat;
- if (stat(location, &dscfg_stat) != 0) {
- cfg_perror_str = dgettext("cfg",
- "Unable to access dscfg location");
- cfg_severity = CFG_EFATAL;
- return (NULL);
- }
- if (!S_ISCHR(dscfg_stat.st_mode)) {
- cfg_perror_str = dgettext("cfg",
- "dscfg location must be a raw device");
- cfg_severity = CFG_EFATAL;
- return (NULL);
- }
- }
-
- if (ftruncate(fd, 0) < 0)
- return (NULL);
-
- rc = write(fd, location, strlen(location));
- if (rc < 0) {
- cfg_perror_str = dgettext("cfg",
- "cfg_location: write to well known failed");
- cfg_severity = CFG_EFATAL;
- return (NULL);
- }
- bzero(config_file, sizeof (config_file));
- }
- if (lseek(fd, 0, SEEK_SET) < 0)
- return (NULL);
-
- bzero(config_file, sizeof (config_file));
- rc = read(fd, config_file, sizeof (config_file));
- if (rc < 0) {
- cfg_perror_str = dgettext("cfg",
- "cfg_location: read from well known failed");
- cfg_severity = CFG_EFATAL;
- return (NULL);
- }
- close(fd);
- if (altroot) {
- strcpy(loc, altroot);
- strcat(loc, config_file);
- bzero(config_file, sizeof (config_file));
- strcpy(config_file, loc);
- }
-
- /*
- * scan string out of config_file, to strip whitespace
- */
- sscanf(config_file, "%s", loc);
- strcpy(config_file, loc);
-
- return (config_file);
-}
-
-/*
- * cfg_update_parser_config
- * If tag and key exist return -1
- *
- * XXX Currently does not append new field to existing parser rule
- */
-
-int
-cfg_update_parser_config(CFGFILE *cfg, const char *key, int section)
-{
- cfp_t *cfp;
- int size;
- char buf[CFG_MAX_BUF];
- struct parser *tbl;
- char tmpkey[CFG_MAX_KEY];
- char *ky, *fld;
- errno = 0;
-
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
-
- cfp = FP_SUN_CLUSTER(cfg);
- if (!cfg_wrlock(cfg))
- return (-1);
-
- bzero(buf, CFG_MAX_BUF);
- bzero(tmpkey, sizeof (tmpkey));
- strcpy(tmpkey, key);
- if (section == CFG_PARSE_CONF) {
- strcat(buf, "C:");
- tbl = chead;
- } else {
- errno = EINVAL;
- return (-1);
- }
- ky = strtok(tmpkey, ".");
- fld = strtok(NULL, ".");
- while (fld) {
- size = cfg_get_item(tbl, ky, fld);
-
- /*
- * Assure we are loading a clean table, with do duplicates
- * based on our File Descriptor
- */
- if (chead_loaded && (chead_loaded != cfp->cf_fd)) {
- if (size <= 0)
- return (-1);
- } else {
- if (size > 0)
- return (-1);
- }
- fld = strtok(NULL, ".");
- }
- size = strlen(key) + 2;
- strncat(buf, key, size);
-#ifdef DEBUG_LIB
- (void) fprintf(stderr, "update parser config %s size %d\n", buf, size);
-#endif
- if ((size + cfp->cf_head->h_parseoff) > CFG_DEFAULT_PARSE_SIZE) {
- cfg_perror_str = dgettext("cfg",
- "cfg_update_parser_config: header overrun");
- cfg_severity = CFG_EFATAL;
-#ifdef DEBUG_LIB
- (void) fprintf(stderr, "update parser config: "
- "overrun siz %d poff %d parsesize %d\n",
- size, cfp->cf_head->h_parseoff, cfp->cf_head->h_parsesize);
-#endif
- errno = E2BIG;
- return (-1);
- }
- bcopy(buf, (cfp->cf_mapped + cfp->cf_head->h_parseoff), size);
- cfp->cf_head->h_parseoff += size;
- cfp->cf_head->h_state |= CFG_HDR_INVALID;
- if (cfp->cf_mapped[cfp->cf_head->h_parseoff - 1] != '\n') {
- cfp->cf_mapped[cfp->cf_head->h_parseoff] = '\n';
- cfp->cf_head->h_parseoff++;
- }
- cfp->cf_head->h_parsesize = cfp->cf_head->h_parseoff;
- cfg_read_parser_config(cfp);
- return (TRUE);
-}
-/*
- * cfg_read_parser_config
- * reads parser config from file
- * converts it to internal tree for parsing
- * chead for configuration parser entries
- *
- */
-static
-void
-cfg_read_parser_config(cfp_t *cfp)
-{
- struct lookup *p, *q;
- struct parser *thead;
- int off, foff;
- char *part;
- char *key;
- char *fld;
- int fldnum;
- char c;
- char buf[CFG_MAX_BUF];
- int i = 0;
- int n = 0;
-
- off = foff = 0;
- /*CONSTCOND*/
- while (TRUE) {
- off = 0;
- bzero(buf, CFG_MAX_BUF);
- /* LINTED it assigns value to c */
- while (c = cfp->cf_mapped[foff++]) {
- if (c == '\n')
- break;
- buf[off++] = c;
- }
- part = strtok(buf, ":");
- if (!part)
- break;
- if (*part == 'C') {
- thead = chead;
- n = i;
- }
- key = strtok(NULL, ".");
- if (!key)
- break;
- strcpy(thead[n].tag.l_word, key);
- thead[n].tag.l_value = 0;
- thead[n].fld = NULL;
- fldnum = 1;
- while ((fld = strtok(NULL, ".")) != NULL) {
- p = thead[n].fld;
- if (p == NULL) {
- q = thead[n].fld = calloc(1,
- sizeof (struct lookup));
- } else {
- for (q = thead[n].fld; q; q = q->l_next)
- p = q;
- q = calloc(1, sizeof (struct lookup));
- p->l_next = q;
- }
- strcpy(q->l_word, fld);
- q->l_value = fldnum;
- q->l_next = NULL;
-#ifdef DEBUG_EXTRA
- (void) fprintf(stderr,
- "read parser: q: word %s value %d\n",
- q->l_word, q->l_value);
-#endif
- fldnum++;
- }
- if (*part == 'C')
- i++;
- }
-
- /* All done, indicate parser table is loaded */
- if (i && (chead_loaded == 0))
- chead_loaded = cfp->cf_fd;
-
- /*
- * before I go and alloc, why am I here?
- * do I need a bunch of cfglists, or do I just
- * need to accommodate a just added parser entry
- * if the latter, we already have a base, just set
- * i to the index of the cfg which members need allocing
- */
- if ((cfp->cf_head->h_cfgs == NULL) ||
- (cfp->cf_head->h_cfgs[n-1].l_entry == NULL)) {
- cfp->cf_head->h_cfgs = (cfglist_t *)calloc(MAX_CFG,
- sizeof (cfglist_t));
- i = 0;
- }
- else
- i = n;
-
- if (cfp->cf_head->h_cfgs) {
-
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr, "alloced %d cfg lists \n", n + 1);
-#endif
- for (cfp->cf_head->h_ncfgs = n + 1;
- i < min(cfp->cf_head->h_ncfgs, MAX_CFG); i++) {
- cfp->cf_head->h_cfgs[i].l_name = '\0';
- cfp->cf_head->h_cfgs[i].l_name =
- strdup(chead[i].tag.l_word);
- cfp->cf_head->h_cfgs[i].l_index = i;
- cfp->cf_head->h_cfgs[i].l_entry =
- calloc(DEFAULT_ENTRY_SIZE, sizeof (char));
- cfp->cf_head->h_cfgs[i].l_nentry = 0;
- cfp->cf_head->h_cfgs[i].l_esiz =
- calloc(DEFAULT_NENTRIES, sizeof (int));
- cfp->cf_head->h_cfgs[i].l_size = 0;
- cfp->cf_head->h_cfgs[i].l_free = DEFAULT_ENTRY_SIZE;
- if ((cfp->cf_head->h_cfgs[i].l_entry == NULL) ||
- (cfp->cf_head->h_cfgs[i].l_esiz == NULL)) {
- cfg_perror_str = dgettext("cfg", "unable to"
- " allocate cfglist members");
- cfg_severity = CFG_EFATAL;
- }
- }
- } else {
- cfg_perror_str = dgettext("cfg", "unable to alloc cfglist");
- cfg_severity = CFG_EFATAL;
- }
-}
-
-/*
- * cfg_map_cfglists()
- * go through list of list sizes in header
- * and create separate lists
- */
-int
-cfg_map_cfglists(cfp_t *cfp)
-{
- int i;
- int offset = 0;
- int *ip;
- int list_size = 0;
- int slot_inc;
- char *p;
- cfgheader_t *ch;
-
- ch = cfp->cf_head;
- p = ch->h_cparse;
-
- /* get the first list size */
- ip = ch->h_sizes;
-
- for (i = 0; i < min(ch->h_ncfgs, MAX_CFG); i++) {
- if (ch->h_cfgsizes[i] > 0) {
- if (ch->h_cfgsizes[i] > DEFAULT_ENTRY_SIZE) {
-
- ch->h_cfgs[i].l_entry = (char *)
- realloc(ch->h_cfgs[i].l_entry,
- ch->h_cfgsizes[i] * sizeof (char));
- /* set free to 0, we'll get more when we add */
- ch->h_cfgs[i].l_free = 0;
-
- } else
- ch->h_cfgs[i].l_free -= ch->h_cfgsizes[i];
-
- /* get lists and marry up to each cfgs structure */
-
-
- list_size = *ip;
- ip++;
-
- if (list_size > DEFAULT_NENTRIES) {
- /*
- * we're gonna need more slots
- * we want to alloc on DEFAULT_NENTRIES
- * boundry. ie. always a multiple of it
- * later on, when we add to the list
- * we can see if we need to add by mod'ding
- * l_nentry and DEFAULT_NENTRIES and check for 0
- */
- slot_inc = DEFAULT_NENTRIES -
- (list_size % DEFAULT_NENTRIES);
- if (slot_inc == DEFAULT_NENTRIES)
- slot_inc = 0; /* addcfline reallocs */
-
- ch->h_cfgs[i].l_esiz = (int *)realloc(
- ch->h_cfgs[i].l_esiz,
- (list_size + slot_inc) * sizeof (int));
- }
- memcpy(ch->h_cfgs[i].l_esiz, ip,
- list_size * sizeof (int));
-
- ch->h_cfgs[i].l_nentry = list_size;
-
- ip += list_size;
-
- } else
-
- continue;
-
- if (ch->h_cfgs[i].l_entry != NULL) {
- p = ch->h_cparse + offset;
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr, "mapping list %d size %d offset %d, addr 0x%x\n",
- i, ch->h_cfgsizes[i], offset, p);
-#endif
- memcpy(ch->h_cfgs[i].l_entry,
- p, ch->h_cfgsizes[i]);
- ch->h_cfgs[i].l_size = ch->h_cfgsizes[i];
- offset += ch->h_cfgsizes[i];
- } else {
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr, "NULL l_entry\n");
-#endif
- return (-1);
- }
- }
-
-
- return (1);
-
-}
-
-void
-cfg_replace_lists(cfp_t *cfp)
-{
- int i;
- int offset = 0;
- int size_offset = 0;
-
- int section = 0;
- cfgheader_t *cf;
- cfglist_t *cfl;
-
- cf = cfp->cf_head;
-
- if ((cfl = cfp->cf_head->h_cfgs) == NULL)
- return;
-
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr, "cfg_replace_lists\n");
-#endif
-
- if (cf->h_cparse == cf->h_ccopy1)
- section = 1;
-
- /*
- * check to see if we are using copy1 or 2,
- * grow or shrink the size, fix h_cparse reference
- * in case realloc gave us a funky new address.
- * put stuff in it.
- */
- cf->h_ccopy1 = (char *)
- realloc(cf->h_ccopy1, cf->h_csize * sizeof (char));
- cf->h_ccopy2 = (char *)
- realloc(cf->h_ccopy2, cf->h_csize * sizeof (char));
- if (section == 1) {
- /* we used copy1 */
- cf->h_cparse = cf->h_ccopy1;
- } else
- cf->h_cparse = cf->h_ccopy2;
-
- /*
- * just because, we'll zero out h_csize and recalc
- * after all, this is the number the next guy gets
- */
- cf->h_csize = cf->h_sizes[0] = 0;
- for (i = 0; i < MAX_CFG; i++) {
- /* only as many lists as chead has */
- if (chead[i].tag.l_word[0] == '\0') {
- break;
- }
- if (cfl[i].l_entry && cfl[i].l_entry[0] != '\0') {
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr,
- "copying list %d at %x size %d\n",
- i, cf->h_cparse + offset,
- cfl[i].l_size);
-#endif
- memcpy((cf->h_cparse + offset),
- cfl[i].l_entry, cfl[i].l_size);
- offset += cfl[i].l_size;
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr,
- "cfl[%d].l_nentry %d cfl[%d].l_esiz[%d] %d"
- " size offset %d\n",
- i, cfl[i].l_nentry, i, cfl[i].l_nentry - 1,
- cfl[i].l_esiz[cfl[i].l_nentry - 1], size_offset);
-#endif
- /*
- * first write the number of entries
- * then copy over the array ie.
- * a list with 5 elements would be copied
- * as a 6 element array slot 0 being the
- * number of elements
- */
- cf->h_sizes[size_offset++] = cfl[i].l_nentry;
- memcpy((cf->h_sizes + size_offset), cfl[i].l_esiz,
- cfl[i].l_nentry * sizeof (int));
- size_offset += cfl[i].l_nentry;
- cf->h_sizes[size_offset] = 0;
- }
- cf->h_csize += cfl[i].l_size;
- }
-}
-
-void
-cfg_free_cfglist(cfp_t *cfp)
-{
- int i;
-
- if (!cfp->cf_head || !cfp->cf_head->h_cfgs)
- return;
-
- for (i = 0; cfp->cf_head && i < MAX_CFG; i++) {
- if (cfp->cf_head->h_cfgs[i].l_entry) {
- free(cfp->cf_head->h_cfgs[i].l_entry);
- cfp->cf_head->h_cfgs[i].l_entry = NULL;
- }
-
- if (cfp->cf_head->h_cfgs[i].l_name) {
- free(cfp->cf_head->h_cfgs[i].l_name);
- cfp->cf_head->h_cfgs[i].l_entry = NULL;
- }
-
- if (cfp->cf_head->h_cfgs[i].l_esiz) {
- free(cfp->cf_head->h_cfgs[i].l_esiz);
- cfp->cf_head->h_cfgs[i].l_esiz = NULL;
- }
- }
-
- if (cfp->cf_head) {
- free(cfp->cf_head->h_cfgs);
- cfp->cf_head->h_cfgs = NULL;
- }
-}
-
-void
-cfg_free_parser_tree()
-{
- struct lookup *p = NULL;
- struct lookup *q = NULL;
- int i;
-
- for (i = 0; i < MAX_CFG; i++) {
- if (chead)
- p = chead[i].fld;
- while (p) {
- q = p->l_next;
- if (p) {
- free(p);
- p = NULL;
- }
- p = q;
- }
- }
- bzero(chead, MAX_CFG * sizeof (struct parser));
-}
-
-void
-cfg_close(CFGFILE *cfg)
-{
- cfp_t *cfp;
-
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return;
- }
-
- /* Determine number of files open */
- for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
- if (!cfp->cf_fd) continue;
-
- (*cfp->cf_pp->close)(cfp);
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr, "freeing cfglists\n");
-#endif
- cfg_free_cfglist(cfp);
-
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr, "freeing cfp->cf_mapped\n");
-#endif
- free(cfp->cf_mapped);
- cfp->cf_mapped = NULL;
-
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr,
- "freeing copy1, copy2, h_sizes and cf\n");
-#endif
- if (cfp->cf_head) {
- if (cfp->cf_head->h_ccopy1) {
- free(cfp->cf_head->h_ccopy1);
- cfp->cf_head->h_ccopy1 = NULL;
- }
- if (cfp->cf_head->h_ccopy2) {
- free(cfp->cf_head->h_ccopy2);
- cfp->cf_head->h_ccopy2 = NULL;
- }
- if (cfp->cf_head->h_sizes1) {
- free(cfp->cf_head->h_sizes1);
- cfp->cf_head->h_sizes1 = NULL;
- }
- if (cfp->cf_head->h_sizes2) {
- free(cfp->cf_head->h_sizes2);
- cfp->cf_head->h_sizes2 = NULL;
- }
-
- }
- if (cfp->cf_head)
- free(cfp->cf_head);
- }
-
- free(cfg);
- cfg = NULL;
- cfg_free_parser_tree();
-
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr, "cfg_close\n");
-#endif
-}
-
-
-char *
-cfg_get_resource(CFGFILE *cfg)
-{
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return (NULL);
- }
-
- return (cfg->cf_node);
-}
-
-/*
- * cfg_resource
- * set or clear the cluster node filter for get/put
- */
-
-void
-cfg_resource(CFGFILE *cfg, const char *node)
-{
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return;
- }
-
- if (cfg->cf_node) {
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr,
- "cfg_resource: changing node from %s to %s\n",
- cfg->cf_node, (node?node:"NULL"));
-#endif
- free(cfg->cf_node);
- cfg->cf_node = NULL;
- }
-
- /*
- * just in case someone passes in a non-NULL
- * node, but has no valid value
- */
- if ((node) && (node[0] != '\0')) {
- cfg->cf_node = strdup(node);
- }
-}
-
-/*
- * cfg_open
- * Open the current configuration file
- */
-CFGFILE *
-cfg_open(char *name)
-{
- CFGFILE *cfg;
- cfp_t *cfp;
- int32_t magic;
- long needed;
- int rc;
-
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr, "cfg_open\n");
-#endif
-
- cfg_severity = 0;
- if ((cfg = (CFGFILE *)calloc(1, sizeof (*cfg))) == NULL) {
- cfg_perror_str = dgettext("cfg",
- "cfg_open: malloc failed");
- cfg_severity = CFG_EFATAL;
- return (NULL);
- }
-
- cfp = &cfg->cf[0];
- if ((name) && strlen(name)) {
-#ifdef DEBUG
- (void) fprintf(stderr, "cfg_open: Using non-standard name\n");
-#endif
- cfp->cf_name = name;
- cfp->cf_pp = (strstr(cfp->cf_name, "/rdsk/") == NULL) ?
- cfg_block_io_provider() : cfg_raw_io_provider();
- } else {
- cfp->cf_name = cfg_location(NULL, CFG_LOC_GET_LOCAL, NULL);
- cfp->cf_pp = cfg_block_io_provider();
-
- /* Handle cfg_open(""), which is an open from boot tools */
- if (name)
- cl_initialized = 1;
- if (cfg_iscluster() > 0) {
- cfp = &cfg->cf[1];
- cfp->cf_name =
- cfg_location(NULL, CFG_LOC_GET_CLUSTER, NULL);
- if (cfp->cf_name) {
- cfp->cf_pp = cfg_raw_io_provider();
- }
- }
- }
-
- /*
- * Open one or two configuration files
- */
- for (cfp = &cfg->cf[0]; cfp->cf_name && (cfp <= &cfg->cf[1]); cfp++) {
- if ((*cfp->cf_pp->open)(cfp, cfp->cf_name) == NULL) {
- cfg_perror_str = dgettext("cfg",
- "cfg_open: unable to open configuration location");
- cfg_severity = CFG_EFATAL;
- break;
- }
-
- /* block device smaller than repository? */
- rc = (*cfp->cf_pp->read)(cfp, &magic, sizeof (magic));
- if (rc < sizeof (magic)) {
- cfg_perror_str = dgettext("cfg",
- "cfg_open: unable to read configuration header");
- cfg_severity = CFG_EFATAL;
- break;
- }
-
- if ((*cfp->cf_pp->seek)(cfp, 0, SEEK_SET) < 0) {
- cfg_perror_str = dgettext("cfg",
- "cfg_open: unable to seek configuration header");
- cfg_severity = CFG_EFATAL;
- break;
- }
-
- /*
- * we can't enforce size rules on an old database
- * so check the magic number before we test for size
- */
- if (magic == CFG_NEW_MAGIC) {
- needed = FBA_NUM(FBA_SIZE(1) - 1 +
- (sizeof (struct cfgheader) + CFG_CONFIG_SIZE));
- } else {
- needed = 0;
- }
-
- if (cfp->cf_size < needed) {
- cfg_perror_str = dgettext("cfg",
- "cfg_open: configuration file too small");
- cfg_severity = CFG_EFATAL;
- errno = ENOMEM;
- break;
- }
-
- cfp->cf_mapped = (char *)malloc(CFG_DEFAULT_PARSE_SIZE);
- if (cfp->cf_mapped == NULL) {
- cfg_perror_str = dgettext("cfg",
- "cfg_open: malloc failed");
- cfg_severity = CFG_EFATAL;
- break;
- }
-
- bzero(cfp->cf_mapped, CFG_DEFAULT_PARSE_SIZE);
- cfp->cf_lock = -1;
- }
-
- /* Processing errors, take care of one or more cfp pointers */
- if (cfg_severity && (cfp <= &cfg->cf[1])) {
- cfp = &cfg->cf[0];
- if (cfp->cf_fd)
- (*cfp->cf_pp->close)(cfp);
- cfp = &cfg->cf[1];
- if (cfp->cf_fd)
- (*cfp->cf_pp->close)(cfp);
- free(cfg);
- return (NULL);
- }
-
- cfg_lockd = cfg_lockd_init();
-
-
-#ifdef DEBUG_CFGLIST
- (void) fprintf(stderr, "cfg_open ok\n");
-#endif
- return (cfg);
-}
-
-void
-cfg_invalidate_hsizes(int fd, const char *loc)
-{
- int offset;
- int rc = -1;
- int hdrsz;
-
- char buf[2 * CFG_DEFAULT_PSIZE];
-
- hdrsz = sizeof (cfgheader_t) + 512 -
- (sizeof (cfgheader_t) % 512);
-
- offset = hdrsz + CFG_DEFAULT_PARSE_SIZE +
- (CFG_DEFAULT_SSIZE * 2);
-
- if (cfg_shldskip_vtoc(fd, loc) > 0)
- offset += CFG_VTOC_SKIP;
-
- bzero(buf, sizeof (buf));
-
- if (lseek(fd, offset, SEEK_SET) > 0)
- rc = write(fd, buf, sizeof (buf));
- if (rc < 0)
- (void) fprintf(stderr, "cfg: invalidate hsizes failed\n");
-
-}
-
-char *
-cfg_error(int *severity)
-{
- if (severity != NULL)
- *severity = cfg_severity;
- return (cfg_perror_str ? cfg_perror_str : CFG_EGENERIC);
-}
-/*
- * cfg_cfg_isempty
- */
-int
-cfg_cfg_isempty(CFGFILE *cfg)
-{
- cfp_t *cfp;
-
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return (FALSE);
- }
-
- cfp = FP_SUN_CLUSTER(cfg);
- if (cfp->cf_head->h_csize == 0)
- return (TRUE);
- else
- return (FALSE);
-}
-
-/*
- * cfg_get_num_entries
- * return the number of entries in a given section of database
- * sndr, ii, ndr_ii...
- */
-int
-cfg_get_num_entries(CFGFILE *cfg, char *section)
-{
- int count = 0;
- int table_offset;
- cfp_t *cfp;
-
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
-
- if ((table_offset = cfg_get_parser_offset(section)) < 0) {
- errno = ESRCH;
- return (-1);
- }
-
- /* Determine number of files open */
- for (cfp = &cfg->cf[0]; cfp->cf_fd && (cfp <= &cfg->cf[1]); cfp++)
- count += cfp->cf_head->h_cfgs[table_offset].l_nentry;
-
- return (count);
-}
-
-/*
- * cfg_get_section
- * all etries in a config file section is placed in
- * buf, allocation is done inside
- * freeing buf is responisbility of the caller
- * number of entries in section is returned
- * -1 on failure, errno is set
- */
-int
-cfg_get_section(CFGFILE *cfg, char ***list, const char *section)
-{
- int table_offset;
- int i, count;
- cfglist_t *cfl;
- char *p = NULL;
- char **buf;
- cfp_t *cfp;
-
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return (FALSE);
- }
-
- if ((table_offset = cfg_get_parser_offset(section)) < 0) {
- errno = ESRCH;
- return (-1);
- }
-
- /* Determine number of files open */
- count = 0;
- for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
- if (!cfp->cf_fd) continue;
- if (cfp->cf_head->h_state & CFG_HDR_INVALID) {
- if (!cfg_read(cfp)) {
- cfg_perror_str = dgettext("cfg", CFG_RDFAILED);
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
- }
-
- cfl = &cfp->cf_head->h_cfgs[table_offset];
- if (cfl->l_nentry == 0) /* empty list */
- continue;
-
- if (count == 0)
- buf = (char **)malloc(cfl->l_nentry * sizeof (char *));
- else
- buf = (char **)realloc(buf, (cfl->l_nentry + count) *
- sizeof (char *));
- if (buf == NULL) {
- errno = ENOMEM;
- return (-1);
- } else {
- bzero(&buf[count], cfl->l_nentry * sizeof (char *));
- }
-
- p = cfl->l_entry;
- for (i = 0; i < cfl->l_nentry; i++) {
- if ((buf[i + count] = strdup(p)) == NULL) {
- errno = ENOMEM;
- return (-1);
- }
- p += cfl->l_esiz[i];
- }
- count += cfl->l_nentry;
- }
-
- *list = buf;
- return (count);
-}
-
-/*
- * cluster upgrade helper functions. These support old database operations
- * while upgrading nodes on a cluster.
- */
-
-/*
- * returns the list of configured tags
- * return -1 on error, else the number
- * of tags returned in taglist
- * caller frees
- */
-int
-cfg_get_tags(CFGFILE *cfg, char ***taglist)
-{
- char **list;
- int i = 0;
-
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
-
- if (!cfg_rdlock(cfg)) {
- return (-1);
- }
- list = calloc(1, MAX_CFG * sizeof (char *));
- if (list == NULL) {
- errno = ENOMEM;
- return (-1);
- }
-
- while ((i < MAX_CFG) && (chead[i].tag.l_word[0] != '\0')) {
- list[i] = strdup(chead[i].tag.l_word);
- if (list[i] == NULL) {
- for (/* CSTYLE */; i >= 0; i--) {
- if (list[i])
- free(list[i]);
- }
- free(list);
- errno = ENOMEM;
- return (-1);
- }
- i++;
- }
- *taglist = list;
- return (i);
-
-}
-
-/*
- * is this a database?
- * check the header for the magic number
- * 0 no match 1 match, -1 on error
- */
-int
-cfg_is_cfg(CFGFILE *cfg)
-{
- int32_t magic;
- int rc;
- cfp_t *cfp = FP_SUN_CLUSTER(cfg);
-
- rc = (cfp->cf_pp->read)(cfp, &magic, sizeof (magic));
- if (rc < sizeof (magic)) {
- cfg_perror_str = dgettext("cfg", "Fail to read configuration");
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
-
- if (magic == CFG_NEW_MAGIC)
- return (1);
-
- cfg_perror_str = dgettext("cfg",
- "configuration not initialized, bad magic");
- cfg_severity = CFG_EFATAL;
-
- return (0);
-}
-
-int
-compare(const void* a, const void *b)
-{
- char *p;
- char *pbuf;
- char *q;
- char *qbuf;
- int needed;
- int cmp;
- int pos;
-
- pbuf = strdup(a);
- qbuf = strdup(b);
-
- if (!qbuf || !pbuf)
- return (0);
-
- pos = 1;
- needed = sortby.offset;
-
- p = strtok(pbuf, " ");
- while (p) {
- if (needed == pos) {
- break;
- }
- p = strtok(NULL, " ");
- if (!p)
- break;
- pos++;
- }
-
- pos = 1;
- q = strtok(qbuf, " ");
- while (q) {
- if (needed == pos) {
- break;
- }
- q = strtok(NULL, " ");
- if (!q)
- break;
- pos++;
- }
- if (!p || !q) {
- sortby.comperror++;
- free(pbuf);
- free(qbuf);
- return (0);
- }
- cmp = strcmp(p, q);
- free(pbuf);
- free(qbuf);
- return (cmp);
-
-
-}
-/*
- * cfg_get_srtdsec
- * returns the section, sorted by supplied field
- * caller frees mem
- */
-int
-cfg_get_srtdsec(CFGFILE *cfg, char ***list, const char *section,
- const char *field)
-{
- cfglist_t *cfl;
- cfp_t *cfp;
- char **buf;
- char *tmplst;
- char *p, *q;
- int table_offset;
- int count, i;
-
- if (cfg == NULL) {
- cfg_perror_str = dgettext("cfg", CFG_EINVAL);
- cfg_severity = CFG_EFATAL;
- return (FALSE);
- }
-
- if ((table_offset = cfg_get_parser_offset(section)) < 0) {
- cfg_perror_str = dgettext("cfg", CFG_RDFAILED);
- errno = ESRCH;
- return (-1);
- }
-
- /*
- * do essentially what get_section does,
- * except stick entries in a static size
- * buf to make things easier to qsort
- */
- count = 0;
- for (cfp = &cfg->cf[0]; cfp <= &cfg->cf[1]; cfp++) {
- if (!cfp->cf_fd) continue;
- if (cfp->cf_head->h_state & CFG_HDR_INVALID) {
- if (!cfg_read(cfp)) {
- cfg_perror_str = dgettext("cfg", CFG_RDFAILED);
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
- }
-
- cfl = &cfp->cf_head->h_cfgs[table_offset];
- if (cfl->l_nentry == 0) /* empty list */
- continue;
-
- if (count == 0)
- buf = (char **)malloc(cfl->l_nentry * sizeof (char *));
- else
- buf = (char **)realloc(buf, (cfl->l_nentry + count) *
- sizeof (char *));
- if (buf == NULL) {
- errno = ENOMEM;
- cfg_perror_str = dgettext("cfg", "cfg_get_srtdsec: "
- "malloc failed");
- cfg_severity = CFG_EFATAL;
- return (-1);
- } else {
- bzero(&buf[count], cfl->l_nentry * sizeof (char *));
- }
-
- /*
- * allocate each line
- */
- for (i = count; i < cfl->l_nentry + count; i++) {
- buf[i] = calloc(1, CFG_MAX_BUF);
- if (buf[i] == NULL) {
- free(buf);
- errno = ENOMEM;
- return (-1);
- }
- }
-
- if (count == 0)
- tmplst = (char *)malloc(cfl->l_nentry * CFG_MAX_BUF);
- else
- tmplst = (char *)realloc(tmplst,
- (cfl->l_nentry + count) * CFG_MAX_BUF);
- if (tmplst == NULL) {
- cfg_perror_str = dgettext("cfg", "cfg_get_srtdsec: "
- "malloc failed");
- cfg_severity = CFG_EFATAL;
- free(buf);
- return (-1);
- } else {
- bzero(&tmplst[count], cfl->l_nentry * CFG_MAX_BUF);
- }
-
- /*
- * put the section in tmplst and sort
- */
- p = &tmplst[count];
- q = cfl->l_entry;
- for (i = 0; i < cfl->l_nentry; i++) {
- bcopy(q, p, cfl->l_esiz[i]);
- p += CFG_MAX_BUF;
- q += cfl->l_esiz[i];
- }
- count += cfl->l_nentry;
- }
-
- bzero(sortby.section, CFG_MAX_KEY);
- bzero(sortby.field, CFG_MAX_KEY);
-
- strcpy(sortby.section, section);
- strcpy(sortby.field, field);
- sortby.comperror = 0;
- sortby.offset = cfg_get_item(&chead[0], section, field);
-
- qsort(tmplst, count, CFG_MAX_BUF, compare);
-
- if (sortby.comperror) {
- sortby.comperror = 0;
- cfg_perror_str = dgettext("cfg", "cfg_get_srtdsec: "
- "comparison error");
- cfg_severity = CFG_ENONFATAL;
- cfg_free_section(&buf, cfl->l_nentry);
- free(tmplst);
- *list = NULL;
- return (-1);
- }
-
- p = tmplst;
- for (i = 0; i < count; i++) {
- bcopy(p, buf[i], CFG_MAX_BUF);
- p += CFG_MAX_BUF;
- }
-
- free(tmplst);
- *list = buf;
- return (count);
-}
-
-/*
- * free an array alloc'd by get_*section
- * or some other array of size size
- */
-
-void
-cfg_free_section(char ***section, int size)
-{
- int i;
- char **secpp = *section;
-
- for (i = 0; i < size; i++) {
- if (secpp[i]) {
- free(secpp[i]);
- secpp[i] = NULL;
- }
- }
- if (secpp) {
- free(secpp);
- secpp = NULL;
- }
- section = NULL;
-}
-
-
-int
-cfg_shldskip_vtoc(int fd, const char *loc)
-{
- struct vtoc vtoc;
- struct stat sb;
- int slice;
- int rfd;
- char char_name[PATH_MAX];
- char *p;
-
- if (fstat(fd, &sb) == -1) {
- cfg_perror_str = dgettext("cfg", "unable to stat config");
- cfg_severity = CFG_EFATAL;
- return (-1);
- }
- if (S_ISREG(sb.st_mode))
- return (0);
-
- if (S_ISCHR(sb.st_mode)) {
- if ((slice = read_vtoc(fd, &vtoc)) < 0)
- return (-1);
-
- if (vtoc.v_part[slice].p_start < CFG_VTOC_SIZE)
- return (1);
- else
- return (0);
- }
-
- if (S_ISBLK(sb.st_mode)) {
- p = strstr(loc, "/dsk/");
- if (p == NULL)
- return (-1);
- strcpy(char_name, loc);
- char_name[strlen(loc) - strlen(p)] = 0;
- strcat(char_name, "/rdsk/");
- strcat(char_name, p + 5);
-
- if ((rfd = open(char_name, O_RDONLY)) < 0) {
- return (-1);
- }
- if ((slice = read_vtoc(rfd, &vtoc)) < 0) {
- close(rfd);
- return (-1);
- }
- close(rfd);
- if (vtoc.v_part[slice].p_start < CFG_VTOC_SIZE)
- return (1);
- else
- return (0);
- }
-
- return (-1);
-}
-
-/*
- * comapares incore header with one on disk
- * returns 0 if equal, 1 if not, -1 error
- */
-int
-cfg_hdrcmp(cfp_t *cfp)
-{
- cfgheader_t *dskhdr, *memhdr;
- int rc;
-
- if ((dskhdr = calloc(1, sizeof (*dskhdr))) == NULL) {
- cfg_perror_str = dgettext("cfg", "cfg_hdrcmp: No memory");
- cfg_severity = CFG_ENONFATAL;
- }
-
- if ((*cfp->cf_pp->seek)(cfp, 0, SEEK_SET) < 0) {
- cfg_perror_str = dgettext("cfg", "cfg_hdrcmp: seek failed");
- cfg_severity = CFG_ENONFATAL;
- free(dskhdr);
- return (-1);
- }
-
- rc = (*cfp->cf_pp->read)(cfp, (char *)dskhdr, sizeof (*dskhdr));
- if (rc < 0) {
- cfg_perror_str = dgettext("cfg", "cfg_hdrcmp: read failed");
- cfg_severity = CFG_ENONFATAL;
- free(dskhdr);
- return (-1);
- }
-
- memhdr = cfp->cf_head;
-
- if ((memhdr->h_seq1 == dskhdr->h_seq1) &&
- (memhdr->h_seq2 == dskhdr->h_seq2))
- rc = 0;
- else
- rc = 1;
-
-
- free(dskhdr);
- return (rc);
-}
diff --git a/usr/src/lib/libdscfg/common/cfg.h b/usr/src/lib/libdscfg/common/cfg.h
deleted file mode 100644
index 84e64b8ebe..0000000000
--- a/usr/src/lib/libdscfg/common/cfg.h
+++ /dev/null
@@ -1,180 +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.
- */
-
-#ifndef _CFG_H
-#define _CFG_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <sys/nsctl/nsctl.h>
-
-#define CFG_MAX_BUF 1024 /* maximum buffer size for cfg_get_?string() */
-#define CFG_MAX_KEY 256 /* maximum key size for cfg_get_?string() */
-
-#ifndef _CFG_IMPL_H
-/*
- * These are really declared in cfg_impl.h, declare as dummy's here to
- * allow clients to compile without including cfg_impl.h.
- */
-typedef struct cfgfile CFGFILE;
-typedef struct cfp cfp_t;
-
-#endif /* _CFG_IMPL_H */
-
-int cfg_get_cstring(CFGFILE *cfg, const char *key, void *value, int value_len);
-int cfg_put_cstring(CFGFILE *cfg, const char *key, void *value, int value_len);
-int cfg_find_cstring(CFGFILE *cfg, const char *target, const char *section,
- int numflds, ...);
-int cfg_get_options(CFGFILE *cfg, int section, const char *basekey,
- char *tag, int tag_len, char *val, int val_len);
-int cfg_put_options(CFGFILE *cfg, int section, const char *basekey,
- char *tag, char *val);
-int cfg_get_single_option(CFGFILE *, int, const char *, char *, char *, int);
-int cfg_del_option(CFGFILE *, int, const char *, char *);
-
-int cfg_get_num_entries(CFGFILE *cfg, char *section);
-
-int cfg_get_tags(CFGFILE *cfg, char ***taglist);
-
-int cfg_cfg_isempty(CFGFILE *cfg);
-int cfg_get_section(CFGFILE *cfg, char ***buf, const char *section);
-CFGFILE *cfg_open(char *filename);
-void cfg_rewind(CFGFILE *cfg, int section);
-int cfg_is_cfg(CFGFILE *cfg);
-int cfg_shldskip_vtoc(int fd, const char *loc);
-int cfg_get_srtdsec(CFGFILE *cfg, char ***list,
- const char *sec, const char *field);
-void cfg_free_section(char ***, int);
-
-
-/*
- * Handle cluster configuration
- */
-#define FP_SUN_CLUSTER(x) \
- (((x->cf_node) && (x->cf[1].cf_fd)) ? &x->cf[1] : &x->cf[0])
-
-/*
- * rewind sections
- */
-#define CFG_SEC_CONF 0 /* configuration section */
-#define CFG_SEC_PERS 1 /* persistent section */
-#define CFG_SEC_ALL 2 /* rewind both sections */
-
-int cfg_update_parser_config(CFGFILE *, const char *key, int section);
-/*
- * parser sections
- */
-#define CFG_PARSE_CONF 0 /* config section key */
-#define CFG_PARSE_PERS 1 /* persistent section key */
-
-char *cfg_error(int *severity);
-/*
- * error codes
- */
-#define CFG_ENONFATAL 0 /* non fatal error */
-#define CFG_EFATAL 1 /* fatal error exit */
-
-/*
- * some error strings
- */
-#define CFG_NOTLOCKED "Configuration not locked"
-#define CFG_RDFAILED "Unable to read configuration"
-#define CFG_EINVAL "Invalid Argument"
-#define CFG_EGENERIC "Generic cfg failure"
-
-
-char *cfg_location(char *location, int mode, char *altroot);
-
-/*
- * location modes
- */
-#define CFG_LOC_SET_LOCAL 0
-#define CFG_LOC_GET_LOCAL 1
-#define CFG_LOC_SET_CLUSTER 2
-#define CFG_LOC_GET_CLUSTER 3
-
-/*
- * location strings
- */
-#define CFG_LOCAL_LOCATION "/etc/dscfg_local"
-#define CFG_CLUSTER_LOCATION "/etc/dscfg_cluster"
-
-void cfg_close(CFGFILE *);
-
-/*
- * lock mode
- */
-typedef enum {
- CFG_RDLOCK,
- CFG_WRLOCK,
- CFG_UPGRADE
-} CFGLOCK;
-
-int cfg_lock(CFGFILE *, CFGLOCK); /* lock the configuration */
-void cfp_unlock(cfp_t *); /* unlock the configuration */
-void cfg_unlock(CFGFILE *);
-int cfg_get_lock(CFGFILE *, CFGLOCK *, pid_t *); /* get config lock */
-
-int cfg_commit(CFGFILE *);
-void cfg_resource(CFGFILE *, const char *); /* Set/clear cluster node */
-char *cfg_get_resource(CFGFILE *); /* get current cluster node */
-char *cfg_dgname(const char *, char *, size_t); /* parse dg from pathname */
-char *cfg_l_dgname(const char *, char *, size_t); /* parse dg from pathname */
-int cfg_dgname_islocal(char *, char **); /* find locality of dg */
-int cfg_iscluster(void); /* running in a cluster? */
-int cfg_issuncluster(void); /* running in a Sun Cluster? */
-void cfg_invalidate_sizes(int);
-
-/*
- * add/rem result codes
- */
-#define CFG_USER_ERR 1
-#define CFG_USER_OK 2
-#define CFG_USER_FIRST 3
-#define CFG_USER_LAST 4
-#define CFG_USER_GONE 5
-#define CFG_USER_REPEAT 6
-
-int cfg_add_user(CFGFILE *, char *, char *, char *); /* add volume user */
-int cfg_rem_user(CFGFILE *, char *, char *, char *); /* remove vol user */
-int cfg_vol_enable(CFGFILE *, char *, char *, char *); /* enable volume */
-int cfg_vol_disable(CFGFILE *, char *, char *, char *); /* disable volume */
-
-int cfg_load_dsvols(CFGFILE *); /* load dsvol: section */
-void cfg_unload_dsvols(); /* unload dsvol: section */
-int cfg_load_svols(CFGFILE *); /* load sv: section */
-void cfg_unload_svols(); /* unload sv: section */
-int cfg_load_shadows(CFGFILE *); /* load shadows & bitmaps from ii: */
-void cfg_unload_shadows(); /* unload ii: */
-
-int cfg_get_canonical_name(CFGFILE *, const char *, char **);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _CFG_H */
diff --git a/usr/src/lib/libdscfg/common/cfg_cluster.c b/usr/src/lib/libdscfg/common/cfg_cluster.c
deleted file mode 100644
index c94b12c91e..0000000000
--- a/usr/src/lib/libdscfg/common/cfg_cluster.c
+++ /dev/null
@@ -1,582 +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.
- */
-
-/*
- * This file contains the glue code that allows the NWS software to
- * determine whether a cluster disk service is local to this node or
- * not.
- *
- * See PSARC/1999/462 for more information on the interfaces from
- * suncluster that are used here.
- */
-
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/mkdev.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <strings.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <dlfcn.h>
-
-#include <sys/ncall/ncall.h>
-#include <sys/nsctl/nsc_hash.h>
-
-#include "cfg_cluster.h"
-#include "cfg_impl.h"
-#include "cfg.h"
-
-/*
- * Static variables
- */
-
-static scconf_nodeid_t cl_nodeid = (uint_t)0xffff;
-static char *cl_nodename = NULL;
-
-static void *libscstat;
-static void *libscconf;
-
-static hash_node_t **schash;
-static int init_sc_entry();
-
-typedef struct hash_data_s {
- scstat_node_name_t scstat_node_name;
-} hash_data_t;
-
-/*
- * Global variables
- */
-int cl_initialized = 0;
-
-
-/*
- * Tell the linker to keep quiet.
- */
-
-#pragma weak scconf_get_nodename
-#pragma weak scconf_strerr
-#pragma weak scconf_get_ds_by_devt
-
-#pragma weak scstat_get_ds_status
-#pragma weak scstat_free_ds_status
-#pragma weak scstat_strerr
-
-
-/*
- * Initialise the library if we have not done so before.
- *
- * - IMPORTANT -
- *
- * This must -never- be called from any command that can be started
- * from /usr/cluster/lib/sc/run_reserve (and hence
- * /usr/cluster/sbin/reconfig) or the system will deadlock
- * during switchover. This includes:
- *
- * - svadm (no options, "print") -- called during sv switchover
- * - all boot commands
- *
- * - grab this node's cluster nodeid
- * - attempt to dlopen() the suncluster shared libraries we need
- * - grab this node's cluster nodename
- *
- * Returns:
- * 0 - success
- * -1 - error, errno is set
- */
-
-int
-cfg_cluster_init(void)
-{
- const char *scconf = "/usr/cluster/lib/libscconf.so.1";
- const char *scstat = "/usr/cluster/lib/libscstat.so.1";
-#ifdef DEBUG
- char errbuf[SCCONF_MAXSTRINGLEN];
-#endif
- scconf_nodeid_t id;
- scconf_errno_t err;
- char *name;
- FILE *pipe;
- int rc;
-
- /*
- * First check to see if we really are a cluster as clinfo -n can lie
- */
- if (cl_nodeid == 0xffff) {
- rc = system("/usr/sbin/clinfo");
- if (rc != -1 && WEXITSTATUS(rc) == 1) {
- /* not a cluster */
- cl_initialized = 1;
- cl_nodeid = 0;
- return (0);
- }
-
- pipe = popen("/usr/sbin/clinfo -n 2>/dev/null || echo 0", "r");
- if (pipe == NULL) {
-#ifdef DEBUG
- fprintf(stderr, "unable to get nodeid: %s\n",
- strerror(errno));
-#endif
- return (-1);
- }
-
- if ((rc = fscanf(pipe, "%d", &id)) != 1) {
-#ifdef DEBUG
- fprintf(stderr, "unable to get nodeid: %s\n",
- strerror(errno));
-#endif
- return (-1);
- }
-
- pclose(pipe);
-
- cl_nodeid = id;
- }
-
- /* Already loaded the Sun Cluster device tree */
- if (cl_initialized)
- return (0);
-
- /*
- * Try and dlopen the various libraries that we need
- */
-
- libscconf = dlopen(scconf, RTLD_LAZY | RTLD_GLOBAL);
- if (libscconf == NULL)
- goto error;
-
- libscstat = dlopen(scstat, RTLD_LAZY | RTLD_GLOBAL);
- if (libscstat == NULL)
- goto error;
-
- err = scconf_get_nodename(id, &name);
- if (err == SCCONF_EPERM) {
- cl_nodename = NULL;
- } else if (err != SCCONF_NOERR) {
-#ifdef DEBUG
- scconf_strerr(errbuf, err);
- fprintf(stderr, "scconf_get_nodename: %d: %s\n", err, errbuf);
-#endif
- goto error;
- } else
- cl_nodename = name;
-
- /* Load the Sun Cluster device tree */
- init_sc_entry();
- cl_initialized = 1;
- return (0);
-
-error: /* error cleanup */
- if (libscconf)
- dlclose(libscconf);
-
- if (libscstat)
- dlclose(libscstat);
-
- libscconf = NULL;
- libscstat = NULL;
-
- errno = ENOSYS;
- return (-1);
-}
-
-
-/*
- * cfg_issuncluster()
- *
- * Description:
- * Return the SunCluster nodeid of this node.
- *
- * Returns:
- * >0 - running in a SunCluster (value is nodeid of this node)
- * 0 - not running in a cluster
- * -1 - failure; errno is set
- */
-
-int
-cfg_issuncluster()
-{
- if (cfg_cluster_init() >= 0)
- return ((int)cl_nodeid);
- else
- return (-1);
-}
-int
-cfg_iscluster()
-{
- return (cfg_issuncluster());
-}
-
-/*
- * cfg_l_dgname_islocal()
- * Check if disk group is local on a non-SunCluster.
- *
- * Returns as cfg_dgname_islocal().
- */
-#ifndef lint
-static int
-cfg_l_dgname_islocal(char *dgname, char **othernode)
-{
- const char *metaset = "/usr/sbin/metaset -s %s -o > /dev/null 2>&1";
- char command[1024];
- int rc;
-
- if (snprintf(command, sizeof (command), metaset, dgname) >=
- sizeof (command)) {
- errno = ENOMEM;
- return (-1);
- }
-
- rc = system(command);
- if (rc < 0) {
- return (-1);
- }
-
- if (WEXITSTATUS(rc) != 0) {
- if (othernode) {
- /* metaset doesn't tell us */
- *othernode = "unknown";
- }
-
- return (0);
- }
-
- return (1);
-}
-#endif
-
-/*
- * cfg_dgname_islocal(char *dgname, char **othernode)
- * -- determine if the named disk service is mastered on this node
- *
- * If the disk service is mastered on another node, that nodename
- * will be returned in othernode (if not NULL). It is up to the
- * calling program to call free() on this value at a later time to
- * free the memory allocated.
- *
- * Returns:
- * 1 - disk service is mastered on this node
- * 0 - disk service is not mastered on this node (*othernode set)
- * -1 - error (errno will be set)
- */
-
-int
-cfg_dgname_islocal(char *dgname, char **othernode)
-{
- hash_data_t *data;
-
- if (dgname == NULL || *dgname == '\0' || othernode == NULL) {
- errno = EINVAL;
- return (-1);
- }
-
- /* Handle non-cluster configurations */
- if (cfg_cluster_init() < 0) {
- return (-1);
- } else if (cl_nodeid == 0) {
- /* it has to be local */
- return (1);
- }
-
- /*
- * lookup the current diskgroup name
- */
- if (data = (hash_data_t *)nsc_lookup(schash, dgname)) {
- if (strcmp(data->scstat_node_name, cl_nodename)) {
- if (othernode)
- *othernode = strdup(data->scstat_node_name);
- return (0);
- } else {
- return (1);
- }
- } else {
- errno = ENODEV;
- return (-1);
- }
-}
-
-/*
- * cfg_l_dgname()
- * parse the disk group name from the a device pathname on a non-SunCluster.
- *
- * Returns as cfg_dgname().
- */
-
-char *
-cfg_l_dgname(const char *pathname, char *buffer, size_t buflen)
-{
- const char *dev = "/dev/";
- const char *vx = "vx/";
- const char *md = "md/";
- const char *dsk = "dsk/";
- const char *start, *cp;
- int ll, len, chkdsk;
-
- bzero(buffer, buflen);
- chkdsk = 0;
-
- ll = strlen(dev);
- if (strncmp(pathname, dev, ll) != 0) {
- /* not a device pathname */
- errno = EINVAL;
- return ((char *)NULL);
- }
-
- start = pathname + ll;
-
- if (strncmp(start, vx, (ll = strlen(vx))) == 0) {
- /*
- * Veritas --
- * /dev/vx/{r}dsk/dgname/partition
- */
-
- start += ll;
-
- ll = strlen(dsk);
-
- if (*start == 'r' && strncmp((start + 1), dsk, ll) == 0)
- start += ll + 1;
- else if (strncmp(start, dsk, ll) == 0)
- start += ll;
- else {
- /* no dgname */
- return (buffer);
- }
- } else {
- /* no dgname */
- return (buffer);
- }
-
- for (cp = start, len = 0; *cp != '\0' && *cp != '/'; cp++)
- len++; /* count length of dgname */
-
- if (*cp == '\0') {
- /* no dgname */
- return (buffer);
- }
-
-#ifdef DEBUG
- if (*cp != '/') {
- fprintf(stderr,
- "cfg_dgname: parse error: *cp = '%c', expected '/'\n", *cp);
- errno = EPROTO;
- return ((char *)NULL);
- }
-#endif
-
- if (chkdsk) {
- cp++; /* skip the NULL */
-
- ll = strlen(dsk);
-
- if ((*cp != 'r' || strncmp((cp + 1), dsk, ll) != 0) &&
- strncmp(cp, dsk, ll) != 0) {
- /* no dgname */
- return (buffer);
- }
- }
-
- if (len >= buflen) {
- errno = E2BIG;
- return ((char *)NULL);
- }
-
- (void) strncpy(buffer, start, len);
- return (buffer);
-}
-
-
-/*
- * cfg_dgname()
- * determine which cluster resource group the pathname belongs to, if any
- *
- * Returns:
- * NULL - error (errno is set)
- * ptr to NULL-string - no dgname
- * pointer to string - dgname
- */
-
-char *
-cfg_dgname(const char *pathname, char *buffer, size_t buflen)
-{
- scconf_errno_t conferr;
- char *dsname = NULL;
- struct stat stb;
-#ifdef DEBUG
- char errbuf[SCCONF_MAXSTRINGLEN];
-#endif
-
- bzero(buffer, buflen);
-
- if (pathname == NULL || *pathname == '\0') {
- errno = EINVAL;
- return ((char *)NULL);
- }
-
- /* Handle non-cluster configurations */
- if (cfg_cluster_init() < 0) {
- errno = EINVAL;
- return ((char *)NULL);
- } else if (cl_nodeid == 0) {
- /* must be local - return NULL-string dgname */
- return (buffer);
- }
-
- if (stat(pathname, &stb) < 0) {
- errno = EINVAL;
- return ((char *)NULL);
- }
-
- conferr = scconf_get_ds_by_devt(major(stb.st_rdev),
- minor(stb.st_rdev), &dsname);
-
- if (conferr == SCCONF_ENOEXIST) {
- return (buffer);
- } else if (conferr != SCCONF_NOERR) {
-#ifdef DEBUG
- scconf_strerr(errbuf, conferr);
- fprintf(stderr,
- "scconf_get_ds_by_devt: %d: %s\n", conferr, errbuf);
-#endif
- errno = EINVAL;
- return ((char *)NULL);
- }
-
- strncpy(buffer, dsname, buflen);
- free(dsname);
-
- return (buffer);
-}
-
-
-/*
- * init_sc_entry
- *
- * Add an entry into the sclist and the schash for future lookups.
- *
- * - IMPORTANT -
- *
- * This must -never- be called from any command that can be started
- * from /usr/cluster/lib/sc/run_reserve (and hence
- * /usr/cluster/sbin/reconfig) or the system will deadlock
- * during switchover. This includes:
- *
- * - svadm (no options, "print") -- called during sv switchover
- * - all boot commands
- *
- * Return values:
- * -1 An error occurred.
- * 0 Entry added
- * 1 Entry already exists.
- */
-static int
-init_sc_entry()
-{
- scstat_ds_node_state_t *dsn;
- scstat_ds_name_t dsname;
- scstat_ds_t *dsstatus, *dsp;
- scstat_errno_t err;
-#ifdef DEBUG
- char errbuf[SCCONF_MAXSTRINGLEN];
-#endif
-
- hash_data_t *hdp;
-
- /*
- * Allocate a hash table
- */
- if ((schash = nsc_create_hash()) == NULL)
- return (-1);
-
- /*
- * the API is broken here - the function is written to expect
- * the first argument to be (scstat_ds_name_t), but the function
- * declaration in scstat.h requires (scstat_ds_name_t *).
- *
- * We just cast it to get rid of the compiler warnings.
- * If "dsname" is NULL, information for all device services is returned
- */
- dsstatus = NULL;
- dsname = NULL;
- /* LINTED pointer alignment */
- err = scstat_get_ds_status((scstat_ds_name_t *)dsname, &dsstatus);
- if (err != SCSTAT_ENOERR) {
-#ifdef DEBUG
- scstat_strerr(err, errbuf);
- fprintf(stderr, "scstat_get_ds_status(): %d: %s\n",
- err, errbuf);
-#endif
- errno = ENOSYS;
- return (-1);
- }
-
- if (dsstatus == NULL) {
- errno = ENODEV;
- return (-1);
- }
-
- /*
- * Traverse scstat_ds list, saving away resource in out hash table
- */
- for (dsp = dsstatus; dsp; dsp = dsp->scstat_ds_next) {
-
- /* Skip over NULL scstat_ds_name's */
- if ((dsp->scstat_ds_name == NULL) ||
- (dsp->scstat_ds_name[0] == '\0'))
- continue;
-
- /* See element exits already, error if so */
- if (nsc_lookup(schash, dsp->scstat_ds_name)) {
- fprintf(stderr, "scstat_get_ds_status: duplicate %s",
- dsp->scstat_ds_name);
- errno = EEXIST;
- return (-1);
- }
-
- /* Traverse the node status list */
- for (dsn = dsp->scstat_node_state_list; dsn;
- dsn = dsn->scstat_node_next) {
- /*
- * Only keep trace of primary nodes
- */
- if (dsn->scstat_node_state != SCSTAT_PRIMARY)
- continue;
-
- /* Create an element to insert */
- hdp = (hash_data_t *)malloc(sizeof (hash_data_t));
- hdp->scstat_node_name = strdup(dsn->scstat_node_name);
- nsc_insert_node(schash, hdp, dsp->scstat_ds_name);
- }
- }
-
- /*
- * Free up scstat resources
- */
- scstat_free_ds_status(dsstatus);
- return (0);
-}
diff --git a/usr/src/lib/libdscfg/common/cfg_cluster.h b/usr/src/lib/libdscfg/common/cfg_cluster.h
deleted file mode 100644
index 56f07219f7..0000000000
--- a/usr/src/lib/libdscfg/common/cfg_cluster.h
+++ /dev/null
@@ -1,344 +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.
- */
-
-#ifndef _CFG_CLUSTER_H
-#define _CFG_CLUSTER_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * This file is a combination of interfaces culled from scstat.h,
- * scconf.h and the header files that they include.
- *
- * It exposes a subset of the interfaces defined in PSARC/2001/261
- * for use in NWS software.
- */
-
-#include <sys/errno.h>
-#include <sys/types.h>
-
-/*
- * From sc_syslog_msg.h
- */
-
-typedef enum sc_state_code_enum {
- ONLINE = 1, /* resource is running */
- OFFLINE, /* resource is stopped due to user action */
- FAULTED, /* resource is stopped due to a failure */
- DEGRADED, /* resource is running but has a minor problem */
- WAIT, /* resource is in transition from a state to another */
-
- /*
- * resource is monitored but state of the resource is
- * not known because either the monitor went down or
- * the monitor cannot report resource state temporarily.
- */
- UNKNOWN,
-
- NOT_MONITORED /* There is no monitor to check state of the resource */
-} sc_state_code_t;
-
-/*
- * End sc_syslog_msg.h
- */
-
-
-/*
- * From scstat.h
- */
-
-#define SCSTAT_MAX_STRING_LEN 1024
-
-/* Error codes returned by scstat functions. */
-/* This definition is covered by PSARC/2001/261. DO NOT change it. */
-typedef enum scstat_errno {
- SCSTAT_ENOERR, /* normal return - no error */
- SCSTAT_EUSAGE, /* syntax error */
- SCSTAT_ENOMEM, /* not enough memory */
- SCSTAT_ENOTCLUSTER, /* not a cluster node */
- SCSTAT_ENOTCONFIGURED, /* not found in CCR */
- SCSTAT_ESERVICENAME, /* dcs: invalid service name */
- SCSTAT_EINVAL, /* scconf: invalid argument */
- SCSTAT_EPERM, /* not root */
- SCSTAT_ECLUSTERRECONFIG, /* cluster is reconfiguring */
- SCSTAT_ERGRECONFIG, /* RG is reconfiguring */
- SCSTAT_EOBSOLETE, /* Resource/RG has been updated */
- SCSTAT_EUNEXPECTED /* internal or unexpected error */
-} scstat_errno_t;
-
-/* States a resource can be in */
-/* This definition is covered by PSARC/2001/261. DO NOT change it. */
-typedef enum scstat_state_code {
- SCSTAT_ONLINE = ONLINE, /* resource is running */
- SCSTAT_OFFLINE = OFFLINE, /* resource stopped due to user action */
- SCSTAT_FAULTED = FAULTED, /* resource stopped due to a failure */
- SCSTAT_DEGRADED = DEGRADED, /* resource running with a minor problem */
- SCSTAT_WAIT = WAIT, /* resource is in transition */
- SCSTAT_UNKNOWN = UNKNOWN, /* resource state is unknown */
- SCSTAT_NOTMONITORED = NOT_MONITORED /* resource is not monitored */
-} scstat_state_code_t;
-
-/* States a replica of a resource can be in */
-/* This definition is covered by PSARC/2001/261. DO NOT change it. */
-typedef enum scstat_node_pref {
- SCSTAT_PRIMARY, /* replica is a primary */
- SCSTAT_SECONDARY, /* replica is a secondary */
- SCSTAT_SPARE, /* replica is a spare */
- SCSTAT_INACTIVE, /* replica is inactive */
- SCSTAT_TRANSITION, /* replica is changing state */
- SCSTAT_INVALID /* replica is in an invalid state */
-} scstat_node_pref_t;
-
-/* component name */
-typedef char *scstat_name_t;
-typedef scstat_name_t scstat_cluster_name_t; /* cluster name */
-typedef scstat_name_t scstat_node_name_t; /* node name */
-typedef scstat_name_t scstat_adapter_name_t; /* adapter name */
-typedef scstat_name_t scstat_path_name_t; /* path name */
-typedef scstat_name_t scstat_ds_name_t; /* device service name */
-typedef scstat_name_t scstat_quorumdev_name_t; /* quorum device name */
-typedef scstat_name_t scstat_rs_name_t; /* resource name */
-typedef scstat_name_t scstat_rg_name_t; /* rg name */
-
-/* status string */
-typedef char *scstat_statstr_t;
-typedef scstat_statstr_t scstat_node_statstr_t; /* node status */
-typedef scstat_statstr_t scstat_path_statstr_t; /* path status */
-typedef scstat_statstr_t scstat_ds_statstr_t; /* DS status */
-typedef scstat_statstr_t scstat_node_quorum_statstr_t; /* node quorum status */
-typedef scstat_statstr_t scstat_quorumdev_statstr_t; /* quorum device stat */
-
-/* ha device node status list */
-/* This definition is covered by PSARC/2001/261. DO NOT change it. */
-typedef struct scstat_ds_node_state_struct {
- /* node name */
- scstat_node_name_t scstat_node_name;
- /* node status */
- scstat_node_pref_t scstat_node_state;
- /* next */
- struct scstat_ds_node_state_struct *scstat_node_next;
-} scstat_ds_node_state_t;
-
-/* Cluster node status */
-/* This definition is covered by PSARC/2001/261. DO NOT change it. */
-typedef struct scstat_node_struct {
- scstat_node_name_t scstat_node_name; /* node name */
- scstat_state_code_t scstat_node_status; /* cluster membership */
- scstat_node_statstr_t scstat_node_statstr; /* node status string */
- void *pad; /* Padding for */
- /* PSARC/2001/261. */
- struct scstat_node_struct *scstat_node_next; /* next */
-} scstat_node_t;
-
-/* Cluster ha device status */
-/* This definition is covered by PSARC/2001/261. DO NOT change it. */
-typedef struct scstat_ds_struct {
- /* ha device name */
- scstat_ds_name_t scstat_ds_name;
- /* ha device status */
- scstat_state_code_t scstat_ds_status;
- /* ha device statstr */
- scstat_ds_statstr_t scstat_ds_statstr;
- /* node preference list */
- scstat_ds_node_state_t *scstat_node_state_list;
- /* next */
- struct scstat_ds_struct *scstat_ds_next;
-} scstat_ds_t;
-
-/*
- * scstat_strerr
- *
- * Map scstat_errno_t to a string.
- *
- * The supplied "errbuffer" should be of at least SCSTAT_MAX_STRING_LEN
- * in length.
- */
-/* This definition is covered by PSARC/2001/261. DO NOT change it. */
-void scstat_strerr(scstat_errno_t, char *);
-
-/*
- * Upon success, a list of objects of scstat_node_t are returned.
- * The caller is responsible for freeing the space.
- *
- * Possible return values:
- *
- * SCSTAT_NOERR - success
- * SCSTAT_ENOMEM - not enough memory
- * SCSTAT_EPERM - not root
- * SCSTAT_ENOTCLUSTER - there is no cluster
- * SCCONF_EINVAL - invalid argument
- * SCSTAT_EUNEXPECTED - internal or unexpected error
- */
-/* This definition is covered by PSARC/2001/261. DO NOT change it. */
-scstat_errno_t scstat_get_nodes(scstat_node_t **pplnodes);
-
-/*
- * Free all memory associated with a scstat_node_t structure.
- */
-/* This definition is covered by PSARC/2001/261. DO NOT change it. */
-void scstat_free_nodes(scstat_node_t *plnodes);
-
-/*
- * If the device service name passed in is NULL, then this function returns
- * the status of all device services, otherwise it returns the status of the
- * device service specified.
- * The caller is responsible for freeing the space.
- *
- * Possible return values:
- *
- * SCSTAT_ENOERR - success
- * SCSTAT_ENOMEM - not enough memory
- * SCSTAT_EPERM - not root
- * SCSTAT_ENOTCLUSTER - there is no cluster
- * SCCONF_EINVAL - invalid argument
- * SCSTAT_ESERVICENAME - invalid device group name
- * SCSTAT_EUNEXPECTED - internal or unexpected error
- */
-/* This definition is covered by PSARC/2001/261. DO NOT change it. */
-scstat_errno_t scstat_get_ds_status(scstat_ds_name_t *dsname,
- scstat_ds_t **dsstatus);
-
-/*
- * Free memory associated with a scstat_ds_t structure.
- */
-/* This definition is covered by PSARC/2001/261. DO NOT change it. */
-void scstat_free_ds_status(scstat_ds_t *dsstatus);
-
-/*
- * End scstat.h
- */
-
-/*
- * From scconf.h
- */
-
-/* Maximum message string length */
-#define SCCONF_MAXSTRINGLEN 1024
-
-/* This definition is covered by PSARC/2001/261. DO NOT change it. */
-typedef enum scconf_errno {
- SCCONF_NOERR = 0, /* normal return - no error */
- SCCONF_EPERM = 1, /* permission denied */
- SCCONF_EEXIST = 2, /* object already exists */
- SCCONF_ENOEXIST = 3, /* object does not exist */
- SCCONF_ESTALE = 4, /* object or handle is stale */
- SCCONF_EUNKNOWN = 5, /* unkown type */
- SCCONF_ENOCLUSTER = 6, /* cluster does not exist */
- SCCONF_ENODEID = 7, /* ID used in place of node name */
- SCCONF_EINVAL = 8, /* invalid argument */
- SCCONF_EUSAGE = 9, /* command usage error */
- SCCONF_ETIMEDOUT = 10, /* call timed out */
- SCCONF_EINUSE = 11, /* already in use */
- SCCONF_EBUSY = 12, /* busy, try again later */
- SCCONF_EINSTALLMODE = 13, /* install mode */
- SCCONF_ENOMEM = 14, /* not enough memory */
- SCCONF_ESETUP = 15, /* setup attempt failed */
- SCCONF_EUNEXPECTED = 16, /* internal or unexpected error */
- SCCONF_EBADVALUE = 17, /* bad ccr table value */
- SCCONF_EOVERFLOW = 18, /* message buffer overflow */
- SCCONF_EQUORUM = 19, /* operation would compromise quorum */
- SCCONF_TM_EBADOPTS = 20, /* bad transport TM "options" */
- SCCONF_TM_EINVAL = 21, /* other transport TM error */
- SCCONF_DS_ESUSPENDED = 22, /* Device service in suspended state */
- SCCONF_DS_ENODEINVAL = 23, /* Node specified is not in cluster */
- SCCONF_EAUTH = 24, /* authentication error */
- SCCONF_DS_EINVAL = 25, /* Device service in an invalid state */
- SCCONF_EIO = 26 /* IO error */
-} scconf_errno_t;
-
-/* IDs */
-/* This definition is covered by PSARC/2001/261. DO NOT change it. */
-typedef uint_t scconf_id_t;
-
-/* This definition is covered by PSARC/2001/261. DO NOT change it. */
-typedef scconf_id_t scconf_nodeid_t; /* node ID */
-
-/* Cluster transport handle */
-/* This definition is covered by PSARC/2001/261. DO NOT change it. */
-typedef void * scconf_cltr_handle_t;
-
-/* This definition is covered by PSARC/2001/261. DO NOT change it. */
-extern scconf_errno_t scconf_get_nodeid(char *nodename,
- scconf_nodeid_t *nodeidp);
-
-/*
- * Get the name of a node from its "nodeid". Upon success,
- * a pointer to the nodename is left in "nodenamep".
- *
- * It is the caller's responsibility to free memory allocated
- * for "nodename" using free(3C).
- *
- * Possible return values:
- *
- * SCCONF_NOERR - success
- * SCCONF_EPERM - not root
- * SCCONF_ENOCLUSTER - there is no cluster
- * SCCONF_ENOMEM - not enough memory
- * SCCONF_EINVAL - invalid argument
- * SCCONF_EUNEXPECTED - internal or unexpected error
- */
-/* This definition is covered by PSARC/2001/261. DO NOT change it. */
-extern scconf_errno_t scconf_get_nodename(scconf_nodeid_t nodeid,
- char **nodenamep);
-
-/*
- * Map scconf_errno_t to a string.
- *
- * The supplied "errbuffer" should be of at least SCCONF_MAXSTRINGLEN
- * in length.
- */
-/* This definition is covered by PSARC/2001/261. DO NOT change it. */
-extern void scconf_strerr(char *errbuffer, scconf_errno_t err);
-
-/*
- * Given a dev_t value, return the name of device service that contains this
- * device.
- *
- * The caller is responsible for freeing the memory returned in "name".
- *
- * Possible return values:
- *
- * SCCONF_NOERR - success
- * SCCONF_EPERM - not root
- * SCCONF_ENOEXIST - the given device is not configured
- * SCCONF_ENOMEM - not enough memory
- * SCCONF_ENOCLUSTER - cluster config does not exist
- * SCCONF_EUNEXPECTED - internal or unexpected error
- */
-/* This definition is covered by PSARC/2001/261. DO NOT change it. */
-extern scconf_errno_t scconf_get_ds_by_devt(major_t maj, minor_t min,
- char **dsname);
-
-/*
- * End scconf.h
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _CFG_CLUSTER_H */
diff --git a/usr/src/lib/libdscfg/common/cfg_impl.h b/usr/src/lib/libdscfg/common/cfg_impl.h
deleted file mode 100644
index a972b2525f..0000000000
--- a/usr/src/lib/libdscfg/common/cfg_impl.h
+++ /dev/null
@@ -1,247 +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.
- */
-
-#ifndef _CFG_IMPL_H
-#define _CFG_IMPL_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define MAX_CFG 16 /* Max. number of lines in /etc/dscfg_format */
-
-#define CFG_MAX_KEY 256
-#define CFG_MAX_BUF 1024
-#define CFG_BLOCK_SIZE 512
-#define CFG_VTOC_SIZE 16
-#define CFG_VTOC_SKIP CFG_VTOC_SIZE * CFG_BLOCK_SIZE
-
-/*
- * Parser and file handling routines for Configuration parser.
- *
- * General layout on disk
- *
- * header cfgheader_t
- * parser configuration tag.field1.field2\n
- * configuration data copy1 freeform strings
- * configuration data copy2 freeform strings
- *
- * Strings in freeform fields are seperated by whitespace.
- * End of entry seperated by null.
- */
-
-struct lookup {
- char l_word[CFG_MAX_KEY];
- int l_value;
- struct lookup *l_next;
-};
-
-struct parser {
- struct lookup tag;
- struct lookup *fld;
- struct parser *next;
-};
-
-
-/*
- * cfglist description
- *
- * ________
- * | | the header has (with other things) an array
- * | header | of h_cfg[n].l_size entries. index 4
- * disk layout | | contains cfp->cf_head->h_cfg[4].l_size.
- * |________|
- * cfgfile-mapped->| |
- * CFG_DEFAULT_PARSE_SIZE | parser | cache_hint.device.wrthru.nordcache.cnode
- * | |
- * |________|
- * cfp->cf_head->h_ccopy1>| |
- * CFG_DEFAULT_SSIZE | data | null terminated strings grouped together
- * | copy 1 | in order of cfglist offset. ie data at
- * |________| offset 0 is from h_cfgs[0].l_entry
- * cfp->cf_head->h_ccopy2>| |
- * CFG_DEFAULT_SSIZE | data |
- * | copy 2 | same as above, used for two stage commit
- * |________|
- * cfp->cf_head->h_sizes1>| | here is where lists of sizes go for each
- * CFG_DEFAULT_PSIZE | sizes | cfglist. each array is preceded by the num
- * | copy 1 | of entries. |5|120|130|140|103|125|10|25 is
- * |________| a list with 5 entries 120,130,140,103,125
- * cfp->cf_head->h_sizes2>| | these numbers are used to rebuild l_nentry
- * CFG_DEFAULT_PSIZE | sizes | and l_esiz fields in h_cfg[n]
- * | copy 2 | this list is done as a two stage commit
- * |________|
- *
- *
- *
- * Data is read into cfp->cf_head->h_ccopy1 and cfp->cf_head->h_ccopy2
- * along with thier corresponding size metadata in cfp->cf_head->h_sizes1
- * and cfp->cf_head->h_sizes2. This infomation is used to rebuild the
- * cfglist structures seen below. The data in the cfglist structure is then
- * the ONLY valid data. Additions and/or deletions to the database is done
- * by moving around the cfglists and doing the right things with the size
- * arrays, the actual entries, total list sizes, the total of all the sizes of
- * all the cfglists and memory allocation. After addition/deletions are done,
- * and cfg_close is called, all of the lists are placed back into h_cparse
- * (which is really h_ccopy1 or h_ccopy2) the persistent lists are placed
- * into h_sizes (which is really h_sizes1 or h_sizes2).
- * A copy of each cfglist[n].l_size is kept in the header
- * (cfgheader->cfgsizes[n]).
- *
- *
- *
- *
- * h_cfgs h_cfgs[3]
- * head |-[0]- /|-l_name == sndr
- * |- /|-[1]- / |-l_entry == host dev bmap host..ip sync '\0' ...
- * file |- / |-[2]- / |-l_esiz[0..l_nentry - 1] == [130, 132, 135, 133,..]
- * |--|---------|-[3]---- |-l_enabled[0..l_nentry - 1] == [1,0,0,1,1]
- * |- \ |-[4]- \ |-l_nentry == 5
- * |- \|-[5]- \ |-l_index == 3
- * |-[n]- \|-l_free == 50537
- * |-l_size == 663 (130 + 132 + 135 + 133 + 133)
- *
- *
- *
- * l_name - is set when the parser is read.
- * It is the first tag of a line of parser text.
- * l_entry - is a pointer to the beginning of the null terminated string
- * list that belongs to the cfglist tagged with l_name.
- * l_esiz - is a list of sizes of the strings contained in l_entry.
- * l_esiz[0] tells the size of the string at l_entry[0].
- * l_esiz[n] is the size of the string that begins
- * at l_entry + l_esiz[0] + l_esiz[1]..+ l_esize[n - 1]
- * l_enabled - is a list of ones and zeros telling if this entry is alive
- * in the kernel. indexing is the same as l_esiz. (not implemented)
- * l_index - is the index of the parser tree that corresponds to l_name
- * and is set when the parser tree is built
- * l_free - is how memory is managed. Memory is allocated on a
- * DEFAULT_ENTRY_SIZE boundry.
- * the size of the balance of available memory at the end of l_entry
- * is kept here. when this number is lower than the string we need to add,
- * another block of memory is allocated for l_entry and the balance of
- * the size is added to l_free.
- * l_size - is size of this list. It is the summation of l_esiz[0..n]
- *
- */
-
-typedef struct cfglist {
- char *l_name; /* name of list sndr, ii.. */
- char *l_entry; /* start of list */
- int *l_esiz; /* array of sizes of entries */
- int l_nentry; /* number of entries */
- int l_index; /* index in relation to parser position */
- uint_t l_free; /* num of characters available */
- int l_size; /* size of list */
-} cfglist_t;
-
-/* note: this does not imply DEFAULT_NENTRIES * DEFAULT_ENTRY_SIZE */
-#define DEFAULT_NENTRIES 100 /* value for l_esiz sizes array */
-#define DEFAULT_ENTRY_SIZE (50 * CFG_MAX_BUF) /* 50K for each l_entry */
-
-
-typedef struct cfgheader {
- int32_t h_magic;
- int h_state; /* State flag see below */
- time_t h_stamp; /* time stamp of last update */
- long h_lock; /* lock for update */
- long h_size; /* total file size */
- int h_parseoff; /* parser config offset */
- int h_parsesize; /* parser config size */
- char *h_cparse; /* start of configuration */
- int h_csize; /* size of config section */
- int h_acsize; /* size of alternate config section */
- int *h_sizes; /* sizes of lists */
- int h_psize; /* size of persistent section */
- int h_apsize; /* size of alternate persistent section */
- char *h_ccopy1; /* base of config section 1 */
- char *h_ccopy2; /* base of config section 2 */
- int *h_sizes1; /* sizes of lists on disk 1 */
- int *h_sizes2; /* sizes of lists on disk 2 */
- int h_seq1; /* Sequenece number copy 1 both sections */
- int h_seq2; /* Sequenece number copy 2 both sections */
- char h_ncfgs; /* number of cfgs */
- cfglist_t *h_cfgs; /* start of cfg lists */
- int h_cfgsizes[MAX_CFG]; /* Sizes of configs */
-} cfgheader_t;
-
-#define CFG_HDR_GOOD 0x1
-#define CFG_HDR_INVALID 0x2
-#define CFG_HDR_RDLOCK 0x4
-#define CFG_HDR_WRLOCK 0x8
-
-struct cfg_io_s; /* forward reference */
-typedef struct cfp {
- int cf_fd; /* file descriptor */
- int cf_flag; /* flags - see below */
- long cf_size; /* size of file in fbas */
- int cf_lock; /* lock file descriptor */
- char *cf_mapped; /* mapped location via mmap */
- char *cf_name; /* file name */
- cfgheader_t *cf_head; /* header */
- struct cfg_io_s *cf_pp; /* i/o provider */
-} cfp_t;
-
-typedef struct cfgfile {
- void *cf_node; /* node filter */
- cfp_t cf[2]; /* local & optional cluster file */
-} CFGFILE;
-
-typedef struct cfg_io_s {
- struct cfg_io_s *next; /* Link to next module */
- char *name; /* name of provider */
- cfp_t *(*open)(cfp_t *, char *); /* Open device */
- void (*close)(cfp_t *); /* Close device */
- int (*seek)(cfp_t *, int, int); /* Seek */
- int (*read)(cfp_t *, void *, int); /* read */
- int (*write)(cfp_t *, void *, int); /* write */
- char *(*readcf)(cfp_t *, char *, int, int); /* Read mem config */
- int (*addcf)(cfp_t *, char *, int); /* add to mem config */
- int (*remcf)(cfp_t *, int, int); /* remove an entry */
- int (*replacecf)(cfp_t *, char *, int, int); /* replace entry */
-} cfg_io_t;
-
-#define CFG_FILE 0x1 /* database is in a regular file */
-#define CFG_NOREWIND 0x4 /* don't rewind for each get_string */
-#define CFG_NOWRVTOC 0x8 /* sector starts in vtoc land, skip it */
-#define CFG_RDONLY 0x10 /* database is read only */
-
-/*
- * constants
- */
-#define CFG_RDEV_LOCKFILE "/var/tmp/.dscfg.lck"
-#define CFG_NEW_MAGIC 0x4d414749 /* MAGI */
-#define CFG_DEFAULT_PARSE_SIZE (16 * 1024)
-#define CFG_DEFAULT_SSIZE (2 * 1024 * 1024)
-#define CFG_DEFAULT_PSIZE (512 * 1024)
-#define CFG_DEFAULT_OLDSIZE (96 * 1024)
-#define CFG_CONFIG_SIZE (CFG_DEFAULT_PARSE_SIZE + \
- (2 * CFG_DEFAULT_SSIZE) + \
- (2 * CFG_DEFAULT_PSIZE))
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _CFG_IMPL_H */
diff --git a/usr/src/lib/libdscfg/common/cfg_local.c b/usr/src/lib/libdscfg/common/cfg_local.c
deleted file mode 100644
index 1b243b1a6d..0000000000
--- a/usr/src/lib/libdscfg/common/cfg_local.c
+++ /dev/null
@@ -1,653 +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 <sys/types.h>
-#include <sys/vtoc.h>
-#include <sys/wait.h>
-#include <stdio.h>
-#include <sys/mnttab.h>
-#include <errno.h>
-#include <limits.h>
-#include <fcntl.h>
-#include <string.h>
-#include <strings.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/mman.h>
-
-#include <locale.h>
-#include <langinfo.h>
-#include <libintl.h>
-#include <stdarg.h>
-#include <netdb.h>
-#include <ctype.h>
-#include <sys/stat.h>
-#include <sys/utsname.h>
-
-#include "cfg_impl.h"
-#include "cfg.h"
-#include "cfg_local.h"
-
-#if 0
-#define DEBUG_CFGLIST
-#define DEBUG_CFGLISTRM
-#endif
-
-extern int cfg_severity;
-extern char *cfg_perror_str;
-
-long
-get_bsize(cfp_t *cfp, char *name)
-{
- char char_name[PATH_MAX];
- char *rest;
- struct vtoc vtoc;
- int slice;
- int fd;
-
- if (strlen(name) >= PATH_MAX - 1)
- return (0);
-
- rest = strstr(name, "/dsk/");
- if (rest == NULL) {
- if ((rest = strstr(name, "/rdsk/")) == NULL)
- return (0);
- strcpy(char_name, name);
- goto do_open;
-
- }
- strcpy(char_name, name);
- char_name[strlen(name) - strlen(rest)] = 0;
- strcat(char_name, "/rdsk/");
- strcat(char_name, rest + 5);
-
-do_open:
- fd = open(char_name, O_RDONLY);
- if (fd < 0)
- return (0);
-
- slice = read_vtoc(fd, &vtoc);
- if (slice < 0) {
- (void) close(fd);
- return (0);
- }
-
- (void) close(fd);
- if (vtoc.v_part[slice].p_start < CFG_VTOC_SIZE)
- cfp->cf_flag |= CFG_NOWRVTOC;
-
- return (vtoc.v_part[slice].p_size);
-}
-
-/*
- * round up to the next block size
- */
-int
-get_block_size(int size)
-{
- int ret;
-
- if (size % CFG_BLOCK_SIZE != 0)
- ret = size + CFG_BLOCK_SIZE - (size % CFG_BLOCK_SIZE);
- else
- ret = size;
- return (ret);
-}
-
-/*
- * get a chunk of mem rounded up to next block size
- */
-char *
-get_block_buf(int size)
-{
- int blk_size;
- char *blk_buf;
-
- blk_size = get_block_size(size);
-
- if ((blk_buf = (char *)calloc(blk_size, sizeof (char))) == NULL) {
- cfg_severity = CFG_EFATAL;
- cfg_perror_str = dgettext("cfg", strerror(errno));
- return (NULL);
- }
- return (blk_buf);
-}
-
-void
-free_block_buf(char *buf)
-{
- if (buf)
- free(buf);
-}
-
-void
-localcf_close(cfp_t *cfp)
-{
- fsync(cfp->cf_fd);
- cfp_unlock(cfp);
- close(cfp->cf_fd);
-}
-
-
-/*
- * cfg_open
- * Open the current configuration file
- * Sets file descriptor in cfp->cf_fd for use by other routines
- */
-cfp_t *
-localcf_open(cfp_t *cfp, char *name)
-{
- struct stat sb;
- int rc;
-
-
- if (name == NULL) {
- cfg_perror_str = dgettext("cfg",
- "cfg_open: unable to open configuration location");
- cfg_severity = CFG_EFATAL;
- return (NULL);
- }
-
- cfp->cf_fd = open(name, O_RDWR|O_CREAT|O_DSYNC|O_RSYNC, 0640);
- if (cfp->cf_fd == -1) {
- if ((cfp->cf_fd = open(name, O_RDONLY, 0640)) == -1) {
- cfg_perror_str = dgettext("cfg",
- "cfg_open: unable to open configuration location");
- cfg_severity = CFG_EFATAL;
- return (NULL);
- }
- cfp->cf_flag |= CFG_RDONLY;
- }
-
- if (fstat(cfp->cf_fd, &sb) == -1) {
- close(cfp->cf_fd);
- cfg_perror_str = dgettext("cfg",
- "cfg_open: unable to stat configuration location");
- cfg_severity = CFG_EFATAL;
- return (NULL);
- }
-
-
- if (S_ISBLK(sb.st_mode) || S_ISCHR(sb.st_mode)) {
- cfp->cf_size = get_bsize(cfp, name);
-
- /* skip the vtoc if necessary */
- if (cfp->cf_flag & CFG_NOWRVTOC) {
- do {
- rc = lseek(cfp->cf_fd, CFG_VTOC_SKIP, SEEK_SET);
- } while (rc == -1 && errno == EINTR);
-
- if (rc == -1) {
- cfg_perror_str = dgettext("cfg",
- strerror(errno));
- cfg_severity = CFG_EFATAL;
- close(cfp->cf_fd);
- return (NULL);
- }
- }
-
- } else if (S_ISREG(sb.st_mode)) {
- cfp->cf_flag |= CFG_FILE;
- cfp->cf_size = FBA_NUM(FBA_SIZE(1) - 1 + sb.st_size);
- } else {
- cfg_perror_str = dgettext("cfg", "cfg_open: unknown file type");
- cfg_severity = CFG_EFATAL;
- close(cfp->cf_fd);
- cfp->cf_fd = NULL;
- return (NULL);
- }
- return (cfp);
-}
-
-int
-localcf_seekblk(cfp_t *cfp, int off, int mode)
-{
- int rc;
-
- do {
- rc = lseek(cfp->cf_fd, off, mode);
- } while (rc == -1 && errno == EINTR);
-
- return (rc);
-}
-
-int
-localcf_readblk(cfp_t *cfp, void *buf, int size)
-{
- int rc;
-
- do {
- rc = read(cfp->cf_fd, buf, size);
- } while (rc == -1 && errno == EINTR);
-
- return (rc);
-}
-
-int
-localcf_writeblk(cfp_t *cfp, void *buf, int size)
-{
- int rc;
-
- do {
- rc = write(cfp->cf_fd, buf, size);
- } while (rc == -1 && errno == EINTR);
-
- return (rc);
-}
-
-int
-localcf_seek(cfp_t *cfp, int off, int mode)
-{
- int rc;
- int offset;
-
- offset = get_block_size(off);
-
- if ((mode == SEEK_SET) && (cfp->cf_flag & CFG_NOWRVTOC)) {
- offset += CFG_VTOC_SKIP;
- }
-
- do {
- rc = lseek(cfp->cf_fd, offset, mode);
- } while (rc == -1 && errno == EINTR);
-
- return (rc);
-}
-
-int
-localcf_read(cfp_t *cfp, void *buf, int size)
-{
- int rc;
- int blk_size;
- char *blk_buf;
-
- blk_size = get_block_size(size);
- if ((blk_buf = get_block_buf(size)) == NULL)
- return (-1);
-
- do {
- rc = read(cfp->cf_fd, blk_buf, blk_size);
- } while (rc == -1 && errno == EINTR);
-
- bcopy(blk_buf, buf, size);
- free_block_buf(blk_buf);
-
- return (rc);
-}
-
-int
-localcf_write(cfp_t *cfp, void *buf, int size)
-{
- int rc;
- int blk_size;
- char *blk_buf;
-
- blk_size = get_block_size(size);
- if ((blk_buf = get_block_buf(size)) == NULL)
- return (-1);
-
- bcopy(buf, blk_buf, size);
-
- do {
- rc = write(cfp->cf_fd, blk_buf, blk_size);
- } while (rc == -1 && errno == EINTR);
-
- free_block_buf(blk_buf);
-
- return (rc);
-}
-/*
- * Routines which operate on internal version of configuration
- */
-
-/*
- * Add entry to end of configuration section
- */
-
-int
-addcfline(cfp_t *cfp, char *line, int table_index)
-{
- int len = strlen(line)+1;
- int newsize = DEFAULT_ENTRY_SIZE / 2;
- cfgheader_t *hd;
- cfglist_t *cfl;
- char *q;
-
-#ifdef DEBUG_CFGLIST
- fprintf(stderr, "addcfline: pre l_size %d h_cfgsizes[%d]"
- " %d l_free %u adding len %d\n",
- cfp->cf_head->h_cfgs[table_index].l_size, table_index,
- cfp->cf_head->h_cfgsizes[table_index],
- cfp->cf_head->h_cfgs[table_index].l_free, len);
-#endif
-
- hd = cfp->cf_head;
- cfl = &cfp->cf_head->h_cfgs[table_index];
- if (cfl->l_free < len) {
-
-#ifdef DEBUG_CFGLIST
- fprintf(stderr, "resizing l_entry from %d to %d\n",
- cfl->l_size + cfl->l_free, cfl->l_size +
- cfl->l_free + newsize);
-#endif
- cfl->l_entry = (char *)realloc(cfl->l_entry, (cfl->l_size +
- cfl->l_free + newsize) * sizeof (char));
- if (cfl->l_entry == NULL) {
- errno = ENOMEM;
- return (-1);
- }
- cfl->l_free += newsize;
-
- }
- cfl->l_free -= len;
-
- /* out of list slots, get some more */
- if (cfl->l_nentry % DEFAULT_NENTRIES == 0) {
- /*
- * first, figure out how much bigger, than realloc
- */
-
-#ifdef DEBUG_CFGLIST
- fprintf(stderr,
- "list %d getting more nentries, I have %d\n",
- table_index, cfl->l_nentry);
-#endif
- cfl->l_esiz = (int *)
- realloc(cfl->l_esiz, (cfl->l_nentry + DEFAULT_NENTRIES) *
- sizeof (int));
- if (cfl->l_esiz == NULL) {
- errno = ENOMEM;
- return (-1);
- }
- }
-
-
- cfl->l_esiz[cfl->l_nentry] = len;
- cfl->l_nentry++;
-
- /* add line to end of list */
- q = cfl->l_entry + cfl->l_size;
-
- strcpy(q, line);
- q += len;
-
- /* set sizes */
- hd->h_cfgs[table_index].l_size += len;
- hd->h_cfgsizes[table_index] = cfl->l_size;
- cfp->cf_head->h_csize += len;
-
-#ifdef DEBUG_CFGLIST
- fprintf(stderr, "addcfline: post l_size %d h_cfgsizes[%d]"
- " %d l_free %u\n h_csize %d\n",
- cfp->cf_head->h_cfgs[table_index].l_size,
- table_index, cfp->cf_head->h_cfgsizes[table_index],
- cfp->cf_head->h_cfgs[table_index].l_free, cfp->cf_head->h_csize);
-#endif
-
- return (1);
-}
-
-/*
- * remove entry from configuration section
- */
-int
-remcfline(cfp_t *cfp, int table_offset, int setnum)
-{
- cfgheader_t *ch;
- char *p, *q;
- int len;
- int copylen;
- int i;
- cfglist_t *cfl;
- ch = cfp->cf_head;
-
- cfl = &cfp->cf_head->h_cfgs[table_offset];
-
- q = cfl->l_entry;
-
- if (cfl->l_size == 0) {
- /* list is empty */
- return (-1);
- }
-
- if (!q) { /* somethings wrong here */
- return (-1);
- }
-
-
- for (i = 1; i < setnum; i++) {
- q += cfl->l_esiz[i - 1];
- if (i >= cfl->l_nentry) { /* end of list */
- return (-1);
- }
- }
-
- if (q >= cfl->l_entry + cfl->l_size)
- return (-1);
-
- len = cfl->l_esiz[i - 1];
-
-
-#ifdef DEBUG_CFGLISTRM
- fprintf(stderr, "remcfline: pre: l_size %d h_cfgsizes[%d] %d free %d"
- " removing len %d\n",
- ch->h_cfgs[table_offset].l_size, table_offset,
- ch->h_cfgsizes[table_offset],
- ch->h_cfgs[table_offset].l_free, len);
-#endif
-
- p = q + len; /* next string */
-
- if (!(p >= cfl->l_entry + cfl->l_size)) {
- /* if we didn't delete the last string in list */
- /* LINTED possible overflow */
- copylen = cfl->l_entry + cfl->l_size - p;
- bcopy(p, q, copylen);
- copylen = (cfl->l_nentry - i) * sizeof (int);
- bcopy(&cfl->l_esiz[i], &cfl->l_esiz[i - 1], copylen);
- }
-
- /* decrement the number of sets in this list */
- cfl->l_nentry--;
- /* not really necessary, but.. */
- cfl->l_esiz[cfl->l_nentry] = 0;
-
- cfl->l_size -= len;
- cfl->l_free += len;
-
- p = cfl->l_entry + cfl->l_size;
- bzero(p, cfl->l_free);
-
- ch->h_cfgsizes[table_offset] = cfl->l_size;
- ch->h_csize -= len;
-
-
-#ifdef DEBUG_CFGLIST
- fprintf(stderr,
- "remcfline: post: l_size %d h_cfgsizes[%d] %d free %d\n ",
- ch->h_cfgs[table_offset].l_size, table_offset,
- ch->h_cfgsizes[table_offset], ch->h_cfgs[table_offset].l_free);
-#endif
-
- return (0);
-
-}
-/*
- * Read entry from configuration section
- */
-char *
-readcfline(cfp_t *cfp, char *buf, int table_offset, int num)
-{
-
- char *q;
- int i;
- cfgheader_t *ch;
- cfglist_t *cfl;
-
- /* this means they couldn't even find it in the parser tree */
- if (table_offset < 0)
- return (NULL);
-
- ch = cfp->cf_head;
- cfl = &ch->h_cfgs[table_offset];
-
- q = cfl->l_entry;
-
- for (i = 1; i < num; i++) {
- q += cfl->l_esiz[i - 1];
- if (i >= cfl->l_nentry) /* end of list */
- return (NULL);
- }
-
- if (q >= cfl->l_entry + cfl->l_size)
- return (NULL);
- strcpy(buf, q);
- return (q);
-}
-
-
-/*
- * overwrite from current position with new value
- */
-int
-replacecfline(cfp_t *cfp, char *line, int table_offset, int num)
-{
-/*
- * take a table offset and a num to replace
- * index in, bump the list up, leaving a hole big
- * enough for the new string, or bcopying the rest of the list
- * down only leaving a hole big enough.
- * make sure not to overflow the
- * allocated list size.
- */
- cfgheader_t *ch;
- cfglist_t *cfl;
- char *p, *q;
- int len = strlen(line) + 1;
- int diff = 0;
- int i;
- int newsize = DEFAULT_ENTRY_SIZE / 2;
-
-
- ch = cfp->cf_head;
- cfl = &ch->h_cfgs[table_offset];
-
- q = cfl->l_entry;
- for (i = 1; i < num; i++) {
- q += cfl->l_esiz[i - 1];
- if (i >= cfl->l_nentry) /* end of list */
- return (-1);
- }
- diff = len - cfl->l_esiz[i - 1];
- /* check for > 0, comparing uint to int */
- if ((diff > 0) && (diff > cfl->l_free)) {
- /*
- * we are going to overflow, get more mem, but only
- * 1/2 as much as initial calloc, we don't need to be greedy
- */
-#ifdef DEBUG_CFGLIST
- fprintf(stderr,
- "resizing at replacecfline from %d to %d \n",
- cfl->l_size + cfl->l_free, cfl->l_size +
- cfl->l_free + newsize);
-#endif
- cfl->l_entry = (char *)realloc(cfl->l_entry,
- (cfl->l_size + cfl->l_free + newsize) * sizeof (char));
- if (cfl->l_entry == NULL) {
- errno = ENOMEM;
- return (-1);
- }
- cfl->l_free += (DEFAULT_ENTRY_SIZE / 2);
-
- /* re-find q, we could have a whole new chunk of memory here */
- q = cfl->l_entry;
- for (i = 1; i < num; i++) {
- q += cfl->l_esiz[i - 1];
- if (i >= cfl->l_nentry) /* end of list */
- return (-1);
- }
- }
-
- p = q + cfl->l_esiz[i - 1]; /* next string */
- cfl->l_esiz[i - 1] += diff; /* the new entry size */
- if (diff != 0) { /* move stuff over/back for correct fit */
- /* LINTED possible overflow */
- bcopy(p, p + diff, (cfl->l_entry + cfl->l_size - p));
- cfl->l_free -= diff; /* 0 - (-1) = 1 */
- cfl->l_size += diff;
-
- /* total of all h_cfgs[n].l_entry */
- cfp->cf_head->h_csize += diff;
- cfp->cf_head->h_cfgsizes[table_offset] = cfl->l_size; /* disk */
- bzero((cfl->l_entry + cfl->l_size), cfl->l_free);
- }
-
- strcpy(q, line);
- return (1);
-
-}
-
-static cfg_io_t _cfg_raw_io_def = {
- NULL,
- "Local",
- localcf_open,
- localcf_close,
- localcf_seek,
- localcf_read,
- localcf_write,
- readcfline,
- addcfline,
- remcfline,
- replacecfline,
-
-};
-
-static cfg_io_t _cfg_block_io_def = {
- NULL,
- "Local",
- localcf_open,
- localcf_close,
- localcf_seekblk,
- localcf_readblk,
- localcf_writeblk,
- readcfline,
- addcfline,
- remcfline,
- replacecfline,
-};
-
-cfg_io_t *
-cfg_raw_io_provider(void)
-{
- return (&_cfg_raw_io_def);
-}
-
-cfg_io_t *
-cfg_block_io_provider(void)
-{
- return (&_cfg_block_io_def);
-}
diff --git a/usr/src/lib/libdscfg/common/cfg_local.h b/usr/src/lib/libdscfg/common/cfg_local.h
deleted file mode 100644
index 5dff884baf..0000000000
--- a/usr/src/lib/libdscfg/common/cfg_local.h
+++ /dev/null
@@ -1,42 +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.
- */
-
-#ifndef _CFG_LOCAL_H
-#define _CFG_LOCAL_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-char *readcfline(cfp_t *cfp, char *buf, int table_index, int offset);
-int addcfline(cfp_t *cfp, char *line, int table_index);
-int replacecfline(cfp_t *cfp, char *line, int table_index, int offset);
-int remcfline(cfp_t *cfp, int table_index, int offset);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _CFG_LOCAL_H */
diff --git a/usr/src/lib/libdscfg/common/cfg_lockd.h b/usr/src/lib/libdscfg/common/cfg_lockd.h
deleted file mode 100644
index 42fbc6d676..0000000000
--- a/usr/src/lib/libdscfg/common/cfg_lockd.h
+++ /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 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _CFG_LOCKD_H
-#define _CFG_LOCKD_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum { LOCK_NOTLOCKED, /* Unlock message */
- LOCK_READ, /* ask for read lock */
- LOCK_WRITE, /* ask for write lock */
- LOCK_LOCKED, /* lock has been taken */
- LOCK_LOCKEDBY, /* who has lock? */
- LOCK_STAT, /* ask daemon to print its state */
- LOCK_ACK /* acknowledge a notlocked msg */
- } cfglockd_t;
-
-typedef struct sockaddr_in daemonaddr_t;
-
-struct lock_msg {
- int32_t message;
- pid_t pid;
- int32_t order;
- uint8_t seq;
-};
-
-#define CFG_PIDFILE "/var/tmp/.cfglockd.pid"
-#define CFG_SERVER_PORT 50121u
-#define CFG_LF_EOF -1
-#define CFG_LF_OKAY 1
-#define CFG_LF_AGAIN 0
-void cfg_lfinit();
-int cfg_filelock(int segment, int flag);
-int cfg_fileunlock(int segment);
-void cfg_readpid(int segment, pid_t *pidp);
-void cfg_writepid(int segment, pid_t pid);
-void cfg_enterpid();
-int cfg_lockd_init();
-cfglockd_t cfg_lockedby(pid_t *);
-void cfg_lockd_rdlock();
-void cfg_lockd_wrlock();
-void cfg_lockd_unlock();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _CFG_LOCKD_H */
diff --git a/usr/src/lib/libdscfg/common/cfg_lockdlck.c b/usr/src/lib/libdscfg/common/cfg_lockdlck.c
deleted file mode 100644
index 14f7cb4b1d..0000000000
--- a/usr/src/lib/libdscfg/common/cfg_lockdlck.c
+++ /dev/null
@@ -1,135 +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 <signal.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <strings.h>
-#include <errno.h>
-#include <assert.h>
-
-#include "cfg_impl.h"
-#include "cfg_lockd.h"
-
-
-#define segment_off(s) ((off_t)(s) * sizeof (pid_t))
-
-static int local_lockfd;
-static int local_lockfda;
-
-void
-cfg_lfinit()
-{
- local_lockfd = open(CFG_RDEV_LOCKFILE, O_RDWR|O_CREAT, 0644);
- local_lockfda = open(CFG_RDEV_LOCKFILE, O_RDWR|O_APPEND, 0644);
-}
-
-int
-cfg_filelock(int segment, int flag)
-{
- struct flock lk;
- struct stat sb;
- pid_t pid = 0;
- off_t off = segment_off(segment);
- int rc;
-
- while (fstat(local_lockfd, &sb) == -1 && errno == EINTR)
- ;
- if (sb.st_size < off + sizeof (pid_t)) {
- if ((flag&O_CREAT) == 0)
- return (CFG_LF_EOF);
- write(local_lockfda, &pid, sizeof (pid_t));
- }
- bzero(&lk, sizeof (lk));
- lk.l_type = F_WRLCK;
- lk.l_whence = SEEK_SET;
- lk.l_start = off;
- lk.l_len = (off_t)sizeof (pid_t);
-
- while ((rc = fcntl(local_lockfd, F_SETLK, &lk)) < 0 && errno == EINTR)
- ;
- if (rc == -1 && errno == EAGAIN)
- return (CFG_LF_AGAIN);
-
- return (CFG_LF_OKAY);
-}
-
-
-int
-cfg_fileunlock(int segment)
-{
- struct flock lk;
- off_t off = segment_off(segment);
-
- bzero(&lk, sizeof (lk));
- lk.l_type = F_UNLCK;
- lk.l_whence = SEEK_SET;
- lk.l_start = off;
- lk.l_len = (off_t)sizeof (pid_t);
-
- while (fcntl(local_lockfd, F_SETLK, &lk) < 0 && errno == EINTR)
- ;
- return (1);
-}
-
-void
-cfg_readpid(int segment, pid_t *pidp)
-{
- off_t off = segment_off(segment);
- lseek(local_lockfd, off, SEEK_SET);
- read(local_lockfd, pidp, sizeof (pid_t));
-}
-
-void
-cfg_writepid(int segment, pid_t pid)
-{
- off_t off = segment_off(segment);
- lseek(local_lockfd, off, SEEK_SET);
- write(local_lockfd, &pid, sizeof (pid_t));
-}
-
-void
-cfg_enterpid()
-{
- int i;
- pid_t pid;
-
- for (i = 0; ; i++) {
- if (cfg_filelock(i, O_CREAT) == CFG_LF_OKAY) {
- cfg_readpid(i, &pid);
- if (pid != (pid_t)0) {
- cfg_fileunlock(i);
- continue;
- }
- pid = getpid();
- cfg_writepid(i, pid);
- break;
- }
- }
-}
diff --git a/usr/src/lib/libdscfg/common/cfg_lockdmsg.c b/usr/src/lib/libdscfg/common/cfg_lockdmsg.c
deleted file mode 100644
index 238c75967e..0000000000
--- a/usr/src/lib/libdscfg/common/cfg_lockdmsg.c
+++ /dev/null
@@ -1,324 +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 <signal.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <netdb.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#include "cfg_lockd.h"
-
-static daemonaddr_t clientaddr;
-static daemonaddr_t server;
-
-static unsigned short server_port = CFG_SERVER_PORT;
-static int lock_soc = 0;
-static int pf_inet = AF_INET;
-static int locked;
-static int initdone;
-static int initresult;
-static pid_t socket_pid;
-
-static void cfg_lockd_reinit();
-
-static int last_cmd = -1;
-static uint8_t seq = 0;
-
-static void
-send_cmd(int cmd)
-{
- struct lock_msg message_buf;
- int rc;
-
- if (last_cmd == cmd) {
- message_buf.seq = seq;
- } else {
- message_buf.seq = ++seq;
- last_cmd = cmd;
- }
- message_buf.message = cmd;
- if ((message_buf.pid = getpid()) != socket_pid)
- cfg_lockd_reinit();
-
- do {
- rc = sendto(lock_soc, &message_buf, sizeof (message_buf), 0,
- (struct sockaddr *)&server, sizeof (server));
- } while (rc == -1 && errno == EINTR);
-#ifdef CFG_LOCKD_DEBUG
- if (rc < 0) {
- perror("send");
- }
-#endif
-}
-
-static void
-read_msg(struct lock_msg *mp)
-{
- struct sockaddr from;
- int rc, len;
-
- /* wait for response */
- do {
- struct pollfd fds;
-
- fds.fd = lock_soc;
- fds.events = POLLIN;
- fds.revents = 0;
-
- rc = poll(&fds, 1, 500);
- if (!rc) {
-#ifdef CFG_LOCKD_DEBUG
- fprintf(stderr, "LOCKD: resending last command (%d)\n",
- last_cmd);
-#endif
- send_cmd(last_cmd);
- }
- } while (rc == 0 ||
- (rc == -1 && errno == EINTR));
-
- do {
- len = sizeof (from);
- rc = recvfrom(lock_soc, mp, sizeof (*mp), 0,
- &from, &len);
- } while (rc == -1 && errno == EINTR);
-#ifdef CFG_LOCKD_DEBUG
- if (rc < 0) {
- perror("revcfrom");
- }
-#endif
-}
-
-static void
-read_reply()
-{
- struct lock_msg message_buf;
-
- do {
- read_msg(&message_buf);
- } while (message_buf.seq != seq || message_buf.message != LOCK_LOCKED);
-}
-
-static void
-read_ack()
-{
- struct lock_msg message_buf;
-
- do {
- read_msg(&message_buf);
- } while (message_buf.seq != seq || message_buf.message != LOCK_ACK);
-}
-
-void
-cfg_lockd_rdlock()
-{
-#ifdef CFG_LOCKD_DEBUG
- FILE *fp;
-#endif
-
- send_cmd(LOCK_READ);
- locked = 1;
- read_reply();
-
-#ifdef CFG_LOCKD_DEBUG
- fp = fopen("/tmp/locktag", "a");
- if (fp) {
- time_t t = time(0);
- fprintf(fp, "%19.19s read lock acquired\n", ctime(&t));
- fclose(fp);
- }
- sleep(3);
-#endif
-}
-
-void
-cfg_lockd_wrlock()
-{
-#ifdef CFG_LOCKD_DEBUG
- FILE *fp;
-#endif
-
- send_cmd(LOCK_WRITE);
- locked = 1;
- read_reply();
-
-#ifdef CFG_LOCKD_DEBUG
- fp = fopen("/tmp/locktag", "a");
- if (fp) {
- time_t t = time(0);
- fprintf(fp, "%19.19s write lock acquired\n", ctime(&t));
- fclose(fp);
- }
- sleep(3);
-#endif
-}
-
-void
-cfg_lockd_unlock()
-{
-#ifdef CFG_LOCKD_DEBUG
- FILE *fp;
-#endif
-
- send_cmd(LOCK_NOTLOCKED);
- read_ack();
- locked = 0;
-
-#ifdef CFG_LOCKD_DEBUG
- fp = fopen("/tmp/locktag", "a");
- if (fp) {
- time_t t = time(0);
- fprintf(fp, "%19.19s ----- lock released\n", ctime(&t));
- fclose(fp);
- }
- sleep(3);
-#endif
-}
-
-void
-cfg_lockd_stat()
-{
- send_cmd(LOCK_STAT);
-}
-
-cfglockd_t
-cfg_lockedby(pid_t *pidp)
-{
- struct lock_msg message_buf;
- send_cmd(LOCK_LOCKEDBY);
- read_msg(&message_buf);
- *pidp = message_buf.pid;
- return ((cfglockd_t)message_buf.message);
-}
-
-static void
-cfg_atexit()
-{
- if (locked)
- cfg_lockd_unlock();
-}
-
-static int
-cfg_lockd_socket()
-{
- if ((lock_soc = socket(pf_inet, SOCK_DGRAM, 0)) < 0) {
-#ifdef CFG_LOCKD_DEBUG
- fprintf(stderr, "libcfg: failed to create socket\n");
- perror("socket");
-#endif
- return (-1);
- }
- clientaddr.sin_family = AF_INET;
- clientaddr.sin_addr.s_addr = INADDR_ANY;
- clientaddr.sin_port = htons(0);
- if (bind(lock_soc, (struct sockaddr *)&clientaddr,
- sizeof (clientaddr)) < 0) {
-#ifdef CFG_LOCKD_DEBUG
- perror("bind");
-#endif
- return (-1);
- }
- socket_pid = getpid();
- return (0);
-}
-
-/*
- * Re-initialise after a fork has been detected.
- *
- * Needs to create a new socket for new process to receive messages
- * from the lock daemon and enter pid into lock file so that the daemon
- * can detect new processes exit if it doesn't call unlock first.
- */
-
-static void
-cfg_lockd_reinit()
-{
- if (lock_soc)
- close(lock_soc);
- lock_soc = 0;
- if (cfg_lockd_socket()) {
- initresult = 0;
- return;
- }
- cfg_enterpid();
- initresult = 1;
-}
-
-int
-cfg_lockd_init()
-{
- struct hostent *hp;
- FILE *fp;
- int pid = 0x12345678;
-
- if (initdone) {
- /* only perform reinit if init worked first time */
- if (getpid() != socket_pid && initresult != 0)
- cfg_lockd_reinit();
- return (initresult);
- }
-
- initdone = 1;
- initresult = 0;
-
- /* check if there's a lock daemon out there */
- if ((fp = fopen(CFG_PIDFILE, "r")) == NULL)
- return (0);
- if (fscanf(fp, "%d\n", &pid) != 1) {
- fclose(fp);
- return (0);
- }
- fclose(fp);
- if (kill((pid_t)pid, 0) != 0)
- return (0);
-
- /* there is a lock daemon */
- cfg_lfinit();
- cfg_enterpid();
- if (cfg_lockd_socket())
- return (0);
-
- if ((hp = gethostbyname("localhost")) == NULL) {
-#ifdef CFG_LOCKD_DEBUG
- fprintf(stderr, "Can't find hostent for %s\n", "localhost");
-#endif
- return (0);
- }
- (void) memcpy(&(server.sin_addr.s_addr), *(hp->h_addr_list),
- sizeof (server.sin_addr));
- server.sin_port = htons(server_port);
- server.sin_family = hp->h_addrtype;
- endhostent();
- atexit(cfg_atexit);
- initresult = 1;
- return (1);
-}
diff --git a/usr/src/lib/libdscfg/common/cfg_vols.c b/usr/src/lib/libdscfg/common/cfg_vols.c
deleted file mode 100644
index 6f0f8bb447..0000000000
--- a/usr/src/lib/libdscfg/common/cfg_vols.c
+++ /dev/null
@@ -1,1286 +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 <sys/types.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/mkdev.h>
-#include <strings.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <locale.h>
-#include <errno.h>
-
-#include <sys/nsctl/cfg.h>
-
-#include <sys/unistat/spcs_s.h>
-#include <sys/unistat/spcs_s_u.h>
-#include <sys/unistat/spcs_errors.h>
-#include <sys/unistat/spcs_s_impl.h>
-
-#include <sys/nsctl/sv.h>
-#include <sys/nsctl/nsc_hash.h>
-
-#define DEV_EXPAND 32
-
-#define DO_DISABLE 0
-#define DO_ENABLE 1
-
-/*
- * Utility functions for iiadm and rdcadm/sndradm.
- */
-
-typedef struct hash_data_s {
- union {
- char *users;
- char *mode;
- } u;
- char *path;
- char *node;
- int setno;
-} hash_data_t;
-
-typedef struct {
- dev_t rdev;
- mode_t mode;
- char *path;
-} device_t;
-
-static hash_data_t *make_svol_data(char *, char *, char *, int);
-static hash_data_t *make_dsvol_data(char *, char *, char *, int);
-static void delete_svol_data(void *);
-static void delete_dsvol_data(void *);
-static int sv_action(char *, CFGFILE *, char *, int);
-
-static int add_dev_entry(const char *);
-static int compare(const void *, const void *);
-static char *find_devid(const char *);
-static void free_dev_entries();
-static void rebuild_devhash();
-
-static hash_node_t **dsvol;
-static int dsvol_loaded = 0;
-
-static hash_node_t **svol;
-static int svol_loaded = 0;
-
-static hash_node_t **shadowvol;
-
-static hash_node_t **devhash;
-static device_t *devlist;
-static int devcount = 0;
-static int devalloc = 0;
-
-/*
- * cfg_add_user
- *
- * Description:
- * Adds the calling tool as a user of the volume.
- *
- * Inputs:
- * char *path: The pathname of the volume to be enabled.
- * char *cnode: The device group name, or NULL if -C local or not cluster
- * CFGFILE *cfg: A pointer to the current config file, or NULL if this
- * function is to open/write/commit/close the change itself.
- *
- * Return values:
- * CFG_USER_FIRST: Indicates that this is the first user of this
- * particular volume.
- * CFG_USER_OK: Indicates that the volume has already been entered into
- * the config file.
- * CFG_USER_ERR: Indicates that some failure has occurred and no changes
- * to the config file have been made.
- * CFG_USER_REPEAT: Indicates that this user has already registered for
- * the volume.
- */
-int
-cfg_add_user(CFGFILE* cfg, char *path, char *cnode, char *user)
-{
- int self_open, self_loaded, change_made;
- char *ctag, search_key[ CFG_MAX_KEY ], buf[ CFG_MAX_BUF ];
- int retval, rc;
- hash_data_t *data;
-
- self_open = (cfg == NULL);
- self_loaded = 0;
- change_made = 0;
-
- if (self_open) {
- cfg = cfg_open(NULL);
- if (cfg == NULL) {
- return (CFG_USER_ERR);
- }
-
- if (!cfg_lock(cfg, CFG_WRLOCK)) {
- /* oops */
- cfg_close(cfg);
- return (CFG_USER_ERR);
- }
- }
-
- /* Check cnode */
- ctag = cfg_get_resource(cfg);
- if (cnode) {
- if (ctag) {
- if (strcmp(cnode, ctag))
- return (CFG_USER_ERR);
- } else
- cfg_resource(cfg, cnode);
- } else
- cnode = ctag;
-
- if (!dsvol_loaded) {
- if (cfg_load_dsvols(cfg) < 0) {
- if (self_open) {
- cfg_close(cfg);
- }
- return (CFG_USER_ERR);
- }
- self_loaded = 1;
- }
-
- /* find the volume */
- (void) snprintf(search_key, CFG_MAX_KEY, "%s:%s", path, cnode);
- data = nsc_lookup(dsvol, search_key);
-
- if (!data) {
- /* whoops, not found. Add as new user */
- cfg_rewind(cfg, CFG_SEC_CONF);
- (void) snprintf(buf, CFG_MAX_BUF, "%s %s %s", path, cnode,
- user);
- rc = cfg_put_cstring(cfg, "dsvol", buf, strlen(buf));
- if (rc < 0) {
- if (self_loaded) {
- cfg_unload_dsvols();
- }
- if (self_open) {
- cfg_close(cfg);
- }
- return (CFG_USER_ERR);
- }
- /* reload hash, if we need to */
- if (!self_loaded) {
- cfg_unload_dsvols();
- if (cfg_load_dsvols(cfg) < 0) {
- if (self_open) {
- cfg_close(cfg);
- }
- return (CFG_USER_ERR);
- }
- }
- retval = CFG_USER_FIRST;
- change_made = 1;
- } else {
- /* Check to ensure we're not already listed */
- char *p = strdup(data->u.users);
- char *q = strtok(p, ",");
- while (q && (strcmp(q, user) != 0)) {
- q = strtok(0, ",");
- }
- free(p); /* not using data; only testing 'q' ptr */
-
- if (!q) {
- /* not listed as a user */
- cfg_rewind(cfg, CFG_SEC_CONF);
- (void) snprintf(buf, CFG_MAX_BUF, "%s %s %s,%s",
- data->path, data->node, data->u.users, user);
- (void) snprintf(search_key, CFG_MAX_KEY, "dsvol.set%d",
- data->setno);
- if (cfg_put_cstring(cfg, search_key, buf,
- strlen(buf)) < 0) {
- if (self_loaded) {
- cfg_unload_dsvols();
- }
- if (self_open) {
- cfg_close(cfg);
- }
- return (CFG_USER_ERR);
- }
-
- /*
- * Since we deleted an entry from the config
- * file, we don't know what all the new
- * set numbers are. We need to reload
- * everything
- */
- if (!self_loaded) {
- cfg_unload_dsvols();
- if (cfg_load_dsvols(cfg) < 0) {
- if (self_open) {
- cfg_close(cfg);
- }
- return (CFG_USER_ERR);
- }
- }
- change_made = 1;
- retval = CFG_USER_OK;
- } else {
- retval = CFG_USER_REPEAT;
- }
- }
-
- if (self_loaded) {
- cfg_unload_dsvols();
- }
-
- if (self_open) {
- if (change_made)
- (void) cfg_commit(cfg);
- cfg_close(cfg);
- }
-
- return (retval);
-}
-
-/*
- * cfg_rem_user
- *
- * Description:
- * Removes a user from the config file.
- *
- * Inputs:
- * char *path: The pathname of the volume to be enabled.
- * char *cnode: The device group name, or NULL if -C local or not cluster
- * char *user: The subsystem that is adding this tag (sv, ii, sndr)
- * CFGFILE *cfg: A pointer to the current config file, or NULL if this
- * function is to open/write/commit/close the change itself.
- * Return values:
- * CFG_USER_ERR: An error occurred during the processing of this
- * directive.
- * CFG_USER_OK: User successfully removed; volume in use by other(s).
- * CFG_USER_LAST: User successfuly removed; no other users registered
- * CFG_USER_GONE: The volume is no longer listed in the dsvol section,
- * indicating some sort of application-level error.
- *
- */
-int
-cfg_rem_user(CFGFILE *cfg, char *path, char *cnode, char *user)
-{
- int self_open, self_loaded, change_made;
- char *ctag, search_key[ CFG_MAX_KEY ], buf[ CFG_MAX_BUF ];
- char cfg_key[ CFG_MAX_KEY ];
- hash_data_t *data;
- int retval;
- int force_remove;
-
- self_open = (cfg == NULL);
- self_loaded = 0;
- change_made = 0;
- force_remove = (strcmp(user, "sv") == 0);
-
- if ('-' == *user) {
- ++user;
- }
-
- /* Check cnode */
- ctag = cfg_get_resource(cfg);
- if (cnode) {
- if (ctag) {
- if (strcmp(cnode, ctag))
- return (CFG_USER_ERR);
- } else
- cfg_resource(cfg, cnode);
- } else
- cnode = ctag;
-
- if (self_open) {
- cfg = cfg_open(NULL);
- if (cfg == NULL) {
- return (CFG_USER_ERR);
- }
-
- if (!cfg_lock(cfg, CFG_WRLOCK)) {
- /* oops */
- cfg_close(cfg);
- return (CFG_USER_ERR);
- }
- }
-
-
- change_made = 0;
- if (!dsvol_loaded) {
- if (cfg_load_dsvols(cfg) < 0) {
- if (self_open) {
- cfg_close(cfg);
- }
- return (CFG_USER_ERR);
- }
- self_loaded = 1;
- }
-
- /* find the volume */
- (void) snprintf(search_key, CFG_MAX_KEY, "%s:%s", path, cnode);
- data = nsc_lookup(dsvol, search_key);
-
- if (!data) {
- /* yipes */
- retval = CFG_USER_GONE;
- } else if (force_remove) {
- retval = CFG_USER_LAST;
- cfg_rewind(cfg, CFG_SEC_CONF);
- (void) snprintf(cfg_key, CFG_MAX_KEY, "dsvol.set%d",
- data->setno);
- if (cfg_put_cstring(cfg, cfg_key, NULL, 0) < 0) {
- if (self_loaded) {
- cfg_unload_dsvols();
- }
- if (self_open) {
- cfg_close(cfg);
- }
- return (CFG_USER_ERR);
- }
- if (!self_loaded) {
- cfg_unload_dsvols();
- if (cfg_load_dsvols(cfg) < 0) {
- if (self_open) {
- cfg_close(cfg);
- }
- return (CFG_USER_ERR);
- }
- }
- } else {
- char *p = strdup(data->u.users);
- char *q = strtok(p, ",");
- int appended = 0;
-
- (void) snprintf(buf, CFG_MAX_BUF, "%s %s ", data->path,
- data->node);
- while (q && (strcmp(q, user) != 0)) {
- if (appended) {
- strcat(buf, ",");
- strcat(buf, q);
- } else {
- strcat(buf, q);
- appended = 1;
- }
- q = strtok(0, ",");
- }
-
- if (!q) {
- /* uh-oh */
- retval = CFG_USER_GONE;
- } else {
- /* old user skipped; add in remaining users */
- while (q = strtok(0, ", ")) {
- if (appended) {
- strcat(buf, ",");
- strcat(buf, q);
- } else {
- strcat(buf, q);
- appended = 1;
- }
- }
-
- if (appended) {
- retval = CFG_USER_OK;
- cfg_rewind(cfg, CFG_SEC_CONF);
- (void) snprintf(cfg_key, CFG_MAX_KEY,
- "dsvol.set%d", data->setno);
- if (cfg_put_cstring(cfg, cfg_key, buf,
- strlen(buf)) < 0) {
- if (self_loaded) {
- cfg_unload_dsvols();
- }
- if (self_open) {
- cfg_close(cfg);
- }
- return (CFG_USER_ERR);
- }
- if (!self_loaded) {
- cfg_unload_dsvols();
- if (cfg_load_dsvols(cfg) < 0) {
- if (self_open) {
- cfg_close(cfg);
- }
- return (CFG_USER_ERR);
- }
- }
- } else {
- retval = CFG_USER_LAST;
- cfg_rewind(cfg, CFG_SEC_CONF);
- (void) snprintf(cfg_key, CFG_MAX_KEY,
- "dsvol.set%d", data->setno);
- if (cfg_put_cstring(cfg, cfg_key, NULL,
- 0) < 0) {
- if (self_loaded) {
- cfg_unload_dsvols();
- }
- if (self_open) {
- cfg_close(cfg);
- }
- return (CFG_USER_ERR);
- }
- /*
- * Since we deleted an entry from the config
- * file, we don't know what all the new
- * set numbers are. We need to reload
- * everything
- */
- if (!self_loaded) {
- cfg_unload_dsvols();
- if (cfg_load_dsvols(cfg) < 0) {
- if (self_open) {
- cfg_close(cfg);
- }
- return (CFG_USER_ERR);
- }
- }
- }
- change_made = 1;
- }
- }
-
- if (self_loaded) {
- cfg_unload_dsvols();
- }
-
- if (self_open) {
- if (change_made)
- (void) cfg_commit(cfg);
- cfg_close(cfg);
- }
-
- return (retval);
-}
-
-/*
- * Enable a volume under SV control (or add this char *user to the list
- * of users of that volume).
- *
- * Parameters:
- * cfg - The config file to use.
- * path - The pathname of the volume
- * ctag - The cluster tag for this volume (if any)
- * user - The user (sv, ii, sndr) of the volume.
- */
-int
-cfg_vol_enable(CFGFILE *cfg, char *path, char *ctag, char *user)
-{
- int rc;
- int retval;
-
- if (!ctag || *ctag == '\0') {
- ctag = "-";
- }
-
- retval = -1;
- rc = cfg_add_user(cfg, path, ctag, user);
- switch (rc) {
- case CFG_USER_ERR:
- spcs_log("dsvol", NULL,
- gettext("unable to set up dsvol section of config for %s"),
- path);
- break;
- case CFG_USER_OK:
- retval = 0;
- break;
- case CFG_USER_FIRST:
- /* enable sv! */
- retval = sv_action(path, cfg, ctag, DO_ENABLE);
- if (retval < 0) {
- (void) cfg_rem_user(cfg, path, ctag, user);
- }
- break;
- default:
- spcs_log("dsvol", NULL,
- gettext("unexpected return from cfg_add_user(%d)"), rc);
- break;
- }
-
- return (retval);
-}
-
-/*
- * Disable a volume from SV control (or remove this char *user from the list
- * of users of that volume).
- *
- * Parameters:
- * cfg - The config file to use.
- * path - The pathname of the volume
- * ctag - The cluster tag for this volume (if any)
- * user - The user (sv, ii, sndr) of the volume.
- */
-int
-cfg_vol_disable(CFGFILE *cfg, char *path, char *ctag, char *user)
-{
- int rc;
- int retval;
-
- if (!ctag || *ctag == '\0') {
- ctag = "-";
- }
-
- retval = -1;
- rc = cfg_rem_user(cfg, path, ctag, user);
- switch (rc) {
- case CFG_USER_ERR:
- spcs_log("dsvol", NULL,
- gettext("unable to set up dsvol section of config for %s"),
- path);
- break;
- case CFG_USER_OK:
- retval = 0;
- break;
- case CFG_USER_GONE:
- spcs_log("dsvol", NULL,
- gettext("%s tried to remove non-existent tag for %s"),
- user, path);
- break;
- case CFG_USER_LAST:
- /* diable sv! */
- retval = sv_action(path, cfg, ctag, DO_DISABLE);
- break;
- default:
- spcs_log("dsvol", NULL,
- gettext("unexpected return from cfg_rem_user(%d)"), rc);
- break;
- }
-
- return (retval);
-}
-
-/*
- * cfg_load_dsvols
- *
- * Description:
- * Loads the dsvol section of the config file into a giant hash, to
- * make searching faster. The important bit to remember is to not
- * release the write lock between calling cfg_load_dsvols() and the
- * cfg_*_user() functions.
- *
- * Assumptions:
- * 1/ cfg file is open
- * 2/ cfg file has been write-locked
- * 3/ user of this routine may already be using hcreate/hsearch
- *
- * Return value:
- * -1 if error, or total number of sets found
- */
-int
-cfg_load_dsvols(CFGFILE *cfg)
-{
- int set, rc, entries;
- char search_key[ CFG_MAX_KEY ];
- char *buf;
- char **entry, *path, *cnode, *users;
- hash_data_t *data;
- int devs_added = 0;
- int offset = 0;
- char *ctag = cfg_get_resource(cfg);
- if (!ctag || *ctag == '\0') {
- ctag = "-";
- }
-
- dsvol = nsc_create_hash();
- if (!dsvol) {
- return (-1);
- }
-
- rc = 0;
- cfg_rewind(cfg, CFG_SEC_CONF);
- entries = cfg_get_section(cfg, &entry, "dsvol");
- for (set = 1; set <= entries; set++) {
- buf = entry[set - 1];
-
- /* split up the line */
- if (!(path = strtok(buf, " "))) {
- /* oops, now what? */
- free(buf);
- break;
- }
- if (!(cnode = strtok(0, " "))) {
- free(buf);
- break;
- }
- if (ctag && (strcmp(cnode, ctag) != 0)) {
- ++offset;
- free(buf);
- continue;
- }
-
- if (!(users = strtok(0, " "))) {
- free(buf);
- break;
- }
-
- data = make_dsvol_data(path, cnode, users, set - offset);
- if (!data) {
- free(buf);
- break;
- }
- (void) snprintf(search_key, CFG_MAX_KEY, "%s:%s", path, cnode);
- rc = nsc_insert_node(dsvol, data, search_key);
- if (rc < 0) {
- free(buf);
- break;
- }
-
- /* we also need to keep track of node information */
- rc = add_dev_entry(path);
- if (rc < 0) {
- free(buf);
- break;
- } else if (rc)
- ++devs_added;
-
- free(buf);
- rc = 0;
- }
-
- while (set < entries)
- free(entry[set++]);
- if (entries)
- free(entry);
-
- if (devs_added) {
- qsort(devlist, devcount, sizeof (device_t), compare);
- rebuild_devhash();
- }
-
- dsvol_loaded = 1;
- return (rc < 0? rc : entries);
-}
-
-/*
- * cfg_unload_dsvols
- *
- * Description:
- * Free all memory allocated with cfg_load_dsvols.
- */
-void
-cfg_unload_dsvols()
-{
- if (dsvol) {
- nsc_remove_all(dsvol, delete_dsvol_data);
- dsvol = 0;
- dsvol_loaded = 0;
- }
-}
-
-/*
- * cfg_load_svols
- *
- * Description:
- * Loads the sv section of the config file into a giant hash, to make
- * searching faster. The important bit to remember is to not release
- * the write lock between calling cfg_load_svols() and the cfg_*_user()
- * functions.
- *
- * Assumptions:
- * 1/ cfg file is open
- * 2/ cfg file has been write-locked
- * 3/ user of this routine may already be using builtin hcreate/hsearch
- */
-int
-cfg_load_svols(CFGFILE *cfg)
-{
- int set, entries, offset = 0;
- char *buf, **entry;
- char *path, *mode, *cnode;
- hash_data_t *data;
- char *ctag = cfg_get_resource(cfg);
- if (!ctag || *ctag == '\0') {
- ctag = "-";
- }
-
- svol = nsc_create_hash();
- if (!svol) {
- return (-1);
- }
-
- cfg_rewind(cfg, CFG_SEC_CONF);
- entries = cfg_get_section(cfg, &entry, "sv");
- for (set = 1; set <= entries; set++) {
- buf = entry[set - 1];
-
- /* split up the line */
- if (!(path = strtok(buf, " "))) {
- free(buf);
- break;
- }
- if (!(mode = strtok(0, " "))) {
- free(buf);
- break;
- }
- if (!(cnode = strtok(0, " "))) {
- cnode = "";
- }
-
- if (ctag && (strcmp(cnode, ctag) != 0)) {
- ++offset;
- free(buf);
- continue;
- }
-
- data = make_svol_data(path, mode, cnode, set - offset);
- if (!data) {
- free(buf);
- break;
- }
- if (nsc_insert_node(svol, data, path) < 0) {
- free(buf);
- break;
- }
- free(buf);
- }
- while (set < entries)
- free(entry[set++]);
- if (entries)
- free(entry);
-
- svol_loaded = 1;
- return (0);
-}
-
-/*
- * cfg_unload_svols
- *
- * Description:
- * Frees all memory allocated with cfg_load_dsvols
- */
-void
-cfg_unload_svols()
-{
- if (svol) {
- nsc_remove_all(svol, delete_svol_data);
- svol = 0;
- svol_loaded = 0;
- }
-}
-
-/*
- * cfg_get_canonical_name
- *
- * Description:
- * Find out whether a device is already known by another name in
- * the config file.
- *
- * Parameters:
- * cfg - The config file to use
- * path - The pathname of the device
- * result - (output) The name it is otherwise known as. This parameter
- * must be freed by the caller.
- *
- * Return values:
- * -1: error
- * 0: name is as expected, or is not known
- * 1: Name is known by different name (stored in 'result')
- */
-int
-cfg_get_canonical_name(CFGFILE *cfg, const char *path, char **result)
-{
- int self_loaded;
- char *alt_path;
- int retval;
-
- if (devlist) {
- self_loaded = 0;
- } else {
- if (cfg_load_shadows(cfg) < 0) {
- return (-1);
- }
- self_loaded = 1;
- }
-
- /* see if it exists under a different name */
- alt_path = find_devid(path);
- if (!alt_path || strcmp(path, alt_path) == 0) {
- *result = NULL;
- retval = 0;
- } else {
- /* a-ha */
- *result = strdup(alt_path);
- retval = 1;
- }
-
- if (self_loaded) {
- free_dev_entries();
- }
-
- return (retval);
-}
-
-/*
- * cfg_load_shadows
- *
- * Description:
- * Load in shadow and bitmap volumes from the II section of the
- * config file. SNDR's volumes are handled already by cfg_load_dsvols.
- * Not all shadow volumes are listed under dsvol: they can be exported.
- *
- * Parameters:
- * cfg - The config file to use
- *
- * Return values:
- * -1: error
- * 0: success
- */
-int
-cfg_load_shadows(CFGFILE *cfg)
-{
- int set, self_loaded, rc, entries;
- char *buf, **entry, *ptr;
- int devs_added = 0;
-
- if (dsvol_loaded) {
- self_loaded = 0;
- } else {
- if (cfg_load_dsvols(cfg) < 0) {
- return (-1);
- }
- self_loaded = 1;
- }
-
- shadowvol = nsc_create_hash();
- if (!shadowvol) {
- return (-1);
- }
-
- rc = 0;
- cfg_rewind(cfg, CFG_SEC_CONF);
- entries = cfg_get_section(cfg, &entry, "ii");
- for (set = 1; set <= entries; set++) {
- buf = entry[set - 1];
-
- /* skip the master vol */
- ptr = strtok(buf, " ");
-
- /* shadow is next */
- ptr = strtok(NULL, " ");
-
- rc = add_dev_entry(ptr);
- if (rc < 0) {
- free(buf);
- break;
- } else if (rc)
- ++devs_added;
-
- /* and next is bitmap */
- ptr = strtok(NULL, " ");
-
- rc = add_dev_entry(ptr);
- if (rc < 0) {
- free(buf);
- break;
- } else if (rc)
- ++devs_added;
- rc = 0;
- free(buf);
- }
- while (set < entries)
- free(entry[set++]);
- if (entries)
- free(entry);
-
- if (self_loaded) {
- cfg_unload_dsvols();
- }
-
- if (devs_added) {
- /* sort it, in preparation for lookups */
- qsort(devlist, devcount, sizeof (device_t), compare);
- rebuild_devhash();
- }
-
- return (rc);
-}
-
-void
-cfg_unload_shadows()
-{
- /* do nothing */
-}
-
-/* ---------------------------------------------------------------------- */
-
-static hash_data_t *
-make_dsvol_data(char *path, char *cnode, char *users, int set)
-{
- hash_data_t *data;
-
- data = (hash_data_t *)malloc(sizeof (hash_data_t));
- if (!data) {
- return (0);
- }
-
- data->u.users = strdup(users);
- data->path = strdup(path);
- data->node = strdup(cnode);
- data->setno = set;
-
- return (data);
-}
-
-static void
-delete_dsvol_data(void *data)
-{
- hash_data_t *p = (hash_data_t *)data;
-
- free(p->u.users);
- free(p->path);
- free(p->node);
- free(p);
-}
-
-static hash_data_t *
-make_svol_data(char *path, char *mode, char *cnode, int set)
-{
- hash_data_t *data;
-
- data = (hash_data_t *)malloc(sizeof (hash_data_t));
- if (!data) {
- return (0);
- }
-
- data->u.mode = strdup(mode);
- data->path = strdup(path);
- data->node = strdup(cnode);
- data->setno = set;
-
- return (data);
-}
-
-
-static void
-delete_svol_data(void *data)
-{
- hash_data_t *p = (hash_data_t *)data;
-
- free(p->u.mode);
- free(p->path);
- free(p->node);
- free(p);
-}
-
-static int
-sv_action(char *path, CFGFILE *caller_cfg, char *ctag, int enable)
-{
- struct stat stb;
- sv_conf_t svc;
- int fd = -1;
- int cfg_changed = 0;
- CFGFILE *cfg;
- int print_log = 0;
- int err = 0, rc;
- int sv_ioctl, spcs_err, self_loaded;
- char *log_str1, *log_str2;
- char key[ CFG_MAX_KEY ];
- char buf[ CFG_MAX_BUF ];
- hash_data_t *node;
- device_t *statinfo = 0;
-
- if (caller_cfg == NULL) {
- cfg = cfg_open(NULL);
- if (cfg == NULL)
- return (-1);
-
- if (ctag)
- cfg_resource(cfg, ctag);
- } else
- cfg = caller_cfg;
-
-
- self_loaded = 0;
- sv_ioctl = (enable? SVIOC_ENABLE : SVIOC_DISABLE);
- log_str1 = (enable? gettext("enabled %s") : gettext("disabled %s"));
- log_str2 = (enable? gettext("unable to enable %s") :
- gettext("unable to disable %s"));
- spcs_err = (enable? SV_EENABLED : SV_EDISABLED);
- bzero(&svc, sizeof (svc));
-
- if (devhash)
- statinfo = nsc_lookup(devhash, path);
-
- if (statinfo) {
- if (!S_ISCHR(statinfo->mode))
- goto error;
- svc.svc_major = major(statinfo->rdev);
- svc.svc_minor = minor(statinfo->rdev);
- } else {
- if (stat(path, &stb) != 0)
- goto error;
-
- if (!S_ISCHR(stb.st_mode))
- goto error;
- svc.svc_major = major(stb.st_rdev);
- svc.svc_minor = minor(stb.st_rdev);
- }
-
- strncpy(svc.svc_path, path, sizeof (svc.svc_path));
-
- fd = open(SV_DEVICE, O_RDONLY);
- if (fd < 0)
- goto error;
-
- svc.svc_flag = (NSC_DEVICE | NSC_CACHE);
- svc.svc_error = spcs_s_ucreate();
-
- do {
- rc = ioctl(fd, sv_ioctl, &svc);
- } while (rc < 0 && errno == EINTR);
-
- if (rc < 0) {
- if (errno != spcs_err) {
- spcs_log("sv", &svc.svc_error, log_str2, svc.svc_path);
- if (enable)
- goto error;
- else
- err = errno;
- } else
- err = spcs_err;
- }
-
- spcs_log("sv", NULL, log_str1, svc.svc_path);
-
- /* SV enable succeeded */
- if (caller_cfg == NULL) /* was not previously locked */
- if (!cfg_lock(cfg, CFG_WRLOCK))
- goto error;
-
- if (err != spcs_err) { /* already enabled, already in config */
- if (enable) {
- cfg_rewind(cfg, CFG_SEC_CONF);
- (void) snprintf(buf, CFG_MAX_BUF, "%s - %s", path,
- ctag? ctag : "-");
- if (cfg_put_cstring(cfg, "sv", buf, CFG_MAX_BUF) < 0) {
- /* SV config not updated, so SV disable again */
- (void) ioctl(fd, SVIOC_DISABLE, &svc);
- print_log++;
- } else
- cfg_changed = 1;
- } else {
- /* pull it out of the config */
- if (!svol_loaded) {
- if (cfg_load_svols(cfg) < 0) {
- if (NULL == caller_cfg) {
- cfg_close(cfg);
- }
- return (-1);
- }
- self_loaded = 1;
- }
- node = nsc_lookup(svol, svc.svc_path);
- if (node) {
- cfg_rewind(cfg, CFG_SEC_CONF);
- (void) snprintf(key, CFG_MAX_KEY, "sv.set%d",
- node->setno);
- if (cfg_put_cstring(cfg, key, NULL, NULL) < 0) {
- spcs_log("sv", NULL,
- gettext("failed to remove %s from "
- "sv config"), svc.svc_path);
- }
- /*
- * Since we deleted an entry from the config
- * file, we don't know what all the new
- * set numbers are. We need to reload
- * everything
- */
- if (!self_loaded) {
- cfg_unload_svols();
- if (cfg_load_svols(cfg) < 0) {
- if (NULL == caller_cfg) {
- cfg_close(cfg);
- }
- return (-1);
- }
- }
- cfg_changed = 1;
- }
- if (self_loaded) {
- cfg_unload_svols();
- self_loaded = 0;
- }
- }
- }
-
-#ifdef lint
- (void) printf("extra line to shut lint up %s\n", module_names[0]);
-#endif
-
-error:
- if (fd >= 0)
- (void) close(fd);
-
- if (cfg == NULL)
- return (-1);
-
- if (cfg_changed)
- if (caller_cfg == NULL) /* we opened config */
- (void) cfg_commit(cfg);
-
- if (caller_cfg == NULL)
- cfg_close(cfg);
- if ((cfg_changed) || (err == spcs_err))
- return (1);
- if (print_log)
- spcs_log("sv", NULL,
- gettext("unable to add to configuration, disabled %s"),
- svc.svc_path);
- spcs_s_ufree(&svc.svc_error);
-
- return (-1);
-}
-
-/*
- * add_dev_entry
- *
- * Add an entry into the devlist and the devhash for future lookups.
- *
- * Return values:
- * -1 An error occurred.
- * 0 Entry added
- * 1 Entry already exists.
- */
-static int
-add_dev_entry(const char *path)
-{
- struct stat buf;
- device_t *newmem;
- hash_data_t *data;
-
- if (!devhash) {
- devhash = nsc_create_hash();
- if (!devhash) {
- return (-1);
- }
- } else {
- data = nsc_lookup(devhash, path);
- if (data) {
- return (1);
- }
- }
-
- if (stat(path, &buf) < 0) {
- /* ignore error, we are most likely deleting entry anyway */
- buf.st_rdev = 0;
- }
-
- if (devcount >= devalloc) {
- /* make some room */
- devalloc += DEV_EXPAND;
- newmem = (device_t *)realloc(devlist, devalloc *
- sizeof (device_t));
- if (!newmem) {
- free_dev_entries();
- return (-1);
- } else {
- devlist = newmem;
- }
- }
-
- devlist[ devcount ].path = strdup(path);
- devlist[ devcount ].rdev = buf.st_rdev;
- devlist[ devcount ].mode = buf.st_mode;
-
- if (nsc_insert_node(devhash, &devlist[devcount], path) < 0) {
- return (-1);
- }
-
- ++devcount;
- return (0);
-}
-
-static void
-rebuild_devhash()
-{
- int i;
-
- if (!devhash)
- nsc_remove_all(devhash, 0);
-
- devhash = nsc_create_hash();
- if (!devhash)
- return;
-
- for (i = 0; i < devcount; i++) {
- nsc_insert_node(devhash, &devlist[i], devlist[i].path);
- }
-}
-
-static int
-compare(const void *va, const void *vb)
-{
- device_t *a = (device_t *)va;
- device_t *b = (device_t *)vb;
-
- return (b->rdev - a->rdev);
-}
-
-static char *
-find_devid(const char *path)
-{
- device_t key;
- device_t *result;
- struct stat buf;
-
- if (!devlist || !devhash)
- return (NULL);
-
- /* See if we already know the device id by this name */
- result = (device_t *)nsc_lookup(devhash, path);
- if (result) {
- return (NULL);
- }
-
- /* try to find it by another name */
- if (stat(path, &buf) < 0)
- return (NULL);
-
- key.rdev = buf.st_rdev;
-
- /* it's storted, so we use the binary-chop method to find it */
- result = bsearch(&key, devlist, devcount, sizeof (device_t), compare);
-
- if (result) {
- return (result->path);
- }
-
- return (NULL);
-}
-
-static void
-free_dev_entries()
-{
- int i;
- device_t *p;
-
- if (!devlist) {
- return;
- }
- for (i = 0, p = devlist; i < devcount; i++, p++) {
- free(p->path);
- }
- free(devlist);
- devlist = NULL;
- devcount = 0;
- devalloc = 0;
-
- if (devhash) {
- nsc_remove_all(devhash, 0);
- devhash = NULL;
- }
-}
diff --git a/usr/src/lib/libdscfg/common/mapfile-vers b/usr/src/lib/libdscfg/common/mapfile-vers
deleted file mode 100644
index 0e1f4f4cae..0000000000
--- a/usr/src/lib/libdscfg/common/mapfile-vers
+++ /dev/null
@@ -1,100 +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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
-#
-#
-
-#
-# 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
-#
-
-#
-# Generic interface definition for usr/src/lib/libcfg.
-#
-
-
-$mapfile_version 2
-
-SYMBOL_VERSION SUNWprivate_1.1 {
- global:
- cfg_get_cstring;
- cfg_put_cstring;
- cfg_find_cstring;
- cfg_get_options;
- cfg_put_options;
- cfg_open;
- cfg_close;
- cfg_rewind;
- cfg_update_parser_config;
- cfg_lock;
- cfg_unlock;
- cfg_get_lock;
- cfg_resource;
- cfg_commit;
- cfg_location;
- cfg_error;
- cfg_iscluster;
- cfg_issuncluster;
- cfg_dgname;
- cfg_dgname_islocal;
- cfg_lfinit;
- cfg_filelock;
- cfg_fileunlock;
- cfg_readpid;
- cfg_writepid;
- cfg_lockd_stat;
- cfg_invalidate_hsizes;
- cfg_cfg_isempty;
- cfg_get_section;
- cfg_get_num_entries;
- cfg_add_user;
- cfg_rem_user;
- cfg_vol_enable;
- cfg_vol_disable;
- cfg_load_dsvols;
- cfg_unload_dsvols;
- cfg_load_svols;
- cfg_unload_svols;
- cfg_load_shadows;
- cfg_unload_shadows;
- cfg_get_canonical_name;
- cfg_get_tags;
- cfg_is_cfg;
- cfg_get_srtdsec;
- cfg_free_section;
- cfg_shldskip_vtoc;
- cfg_get_single_option;
- cfg_del_option;
- cfg_get_resource;
- cfg_l_dgname;
- local:
- *;
-};
diff --git a/usr/src/lib/libdscfg/i386/Makefile b/usr/src/lib/libdscfg/i386/Makefile
deleted file mode 100644
index 0e5cdedf26..0000000000
--- a/usr/src/lib/libdscfg/i386/Makefile
+++ /dev/null
@@ -1,34 +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 ../Makefile.com
-
-.KEEP_STATE:
-
-all: $(LIBS)
-
-install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTARLINK)
-
-lint:
-lintinter:
diff --git a/usr/src/lib/libdscfg/sparc/Makefile b/usr/src/lib/libdscfg/sparc/Makefile
deleted file mode 100644
index 7dce46d064..0000000000
--- a/usr/src/lib/libdscfg/sparc/Makefile
+++ /dev/null
@@ -1,34 +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 ../Makefile.com
-
-.KEEP_STATE:
-
-all: $(LIBS)
-
-install: all $(ROOTLIBS) $(ROOTLINKS)
-lint:
-lintinter:
-
diff --git a/usr/src/lib/libnsctl/Makefile b/usr/src/lib/libnsctl/Makefile
deleted file mode 100644
index 47eb07f597..0000000000
--- a/usr/src/lib/libnsctl/Makefile
+++ /dev/null
@@ -1,60 +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.
-#
-# lib/libnsctl/Makefile
-
-include ../Makefile.lib
-
-HDRS= nsc_hash.h
-HDRDIR= common
-
-SUBDIRS = $(MACH)
-
-ROOTHDRDIR= $(ROOT)/usr/include/sys/nsctl
-
-ROOTHDRS= $(HDRS:%=$(ROOTHDRDIR)/%)
-
-all := TARGET= all
-clean := TARGET= clean
-clobber := TARGET= clobber
-install := TARGET= install
-lint := TARGET= lint
-
-.KEEP_STATE:
-
-all clean clobber delete install lint: $(SUBDIRS)
-
-$(MACH): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
-
-install_h: $(ROOTHDRDIR) $(ROOTHDRS)
-
-$(ROOTHDRDIR)/%: common/%
- $(INS.file)
-
-$(ROOTHDRDIR):
- $(INS.dir)
-
-check: $(CHECKHDRS)
-
-FRC:
diff --git a/usr/src/lib/libnsctl/Makefile.com b/usr/src/lib/libnsctl/Makefile.com
deleted file mode 100644
index 36042e4c6f..0000000000
--- a/usr/src/lib/libnsctl/Makefile.com
+++ /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 2008 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# lib/libnsctl/Makefile.com
-
-LIBRARY= libnsctl.a
-VERS= .1
-
-OBJECTS= cache.o machdep.o hash.o
-
-# include library definitions
-include ../../Makefile.lib
-
-LIBS= $(DYNLIB) $(LINTLIB)
-
-SRCDIR= ../common
-
-INCS += -I$(SRCDIR)
-
-CSTD= $(CSTD_GNU99)
-C99LMODE= -Xc99=%all
-
-LDLIBS += -lc
-CPPFLAGS += $(INCS)
-LINTFLAGS += -erroff=E_FUNC_RET_MAYBE_IGNORED2
-LINTFLAGS += -erroff=E_FUNC_RET_ALWAYS_IGNOR2
-
-$(LINTLIB) := SRCS = $(SRCDIR)/$(LINTSRC)
-
-.KEEP_STATE:
-
-all: $(LIBS)
-
-lint: lintcheck
-
-include ../../Makefile.targ
diff --git a/usr/src/lib/libnsctl/common/cache.c b/usr/src/lib/libnsctl/common/cache.c
deleted file mode 100644
index e4bbc21f25..0000000000
--- a/usr/src/lib/libnsctl/common/cache.c
+++ /dev/null
@@ -1,425 +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 <sys/types.h>
-#include <sys/fcntl.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <strings.h>
-#include <unistd.h>
-#include <stdio.h>
-
-#include "libnsctl.h"
-#include <nsctl.h>
-
-
-static int _nsc_open_path(nsc_fd_t *);
-static int _nsc_open_check(nsc_fd_t *);
-
-
-/*
- * Turn off ckdchk checking of nsc_open()'d volumes since we have no CKD
- * formatted volumes right now. If/when we come back with CKD volumes,
- * we could do this more sanely by completing the implementation of the
- * CKD module, and having nsc_open() prevent any non-NSC_CKD_DISK open
- * of a CKD volume.
- * -- Simon, Thu Feb 18 10:49:46 GMT 1999
- */
-static int ckdchk = 0;
-
-
-nsc_fd_t *
-nsc_open(path, flag, mode)
-char *path;
-int flag, mode;
-{
- nsc_fd_t *fd;
-
- if (strlen(path) >= NSC_MAXPATH) {
- errno = ENAMETOOLONG;
- return (0);
- }
-
- if (!(fd = (nsc_fd_t *)calloc(1, sizeof (nsc_fd_t))))
- return (0);
-
- if ((mode & O_ACCMODE) == O_WRONLY) {
- mode &= ~O_ACCMODE;
- mode |= O_RDWR;
- }
-
- fd->sf_flag = flag;
- fd->sf_fmode = mode;
-
- strcpy(fd->sf_path, path);
-
- if (!_nsc_open_path(fd)) {
- free(fd);
- return (0);
- }
-
- if (ckdchk && !_nsc_open_check(fd)) {
- (void) nsc_close(fd);
- return (0);
- }
-
- return (fd);
-}
-
-
-nsc_fd_t *
-nsc_fdopen(id, path, mode)
-int id, mode;
-char *path;
-{
- struct flock lk;
- nsc_fd_t *fd;
- int i;
-
- if (strlen(path) >= NSC_MAXPATH) {
- errno = ENAMETOOLONG;
- return (0);
- }
-
- if (!(fd = (nsc_fd_t *)calloc(1, sizeof (nsc_fd_t))))
- return (0);
-
- lk.l_type = F_WRLCK;
- lk.l_whence = SEEK_SET;
- lk.l_start = 0;
- lk.l_len = 0;
-
- if (fcntl(id, F_SETLKW, &lk) < 0)
- return (0);
-
- i = fcntl(id, F_GETFL);
-
- if ((mode & O_ACCMODE) != O_RDONLY) {
- if ((i & O_ACCMODE) == O_RDONLY) {
- errno = EBADF;
- return (0);
- }
- }
-
- if ((mode & O_ACCMODE) != O_WRONLY) {
- if ((i & O_ACCMODE) == O_WRONLY) {
- errno = EBADF;
- return (0);
- }
- }
-
- mode = (i & O_ACCMODE) | (mode & ~O_ACCMODE);
-
- if (fcntl(id, F_SETFL, mode) < 0)
- return (0);
-
- if (lseek(id, 0, SEEK_SET) < 0)
- return (0);
-
- fd->sf_fd = id;
- fd->sf_fmode = mode;
-
- strcpy(fd->sf_path, path);
-
- return (fd);
-}
-
-
-static int
-_nsc_open_path(fd)
-nsc_fd_t *fd;
-{
- struct nscioc_open op;
-
- memset(&op, 0, sizeof (op));
-
- op.flag = fd->sf_flag;
- op.mode = fd->sf_fmode;
- strcpy(op.path, fd->sf_path);
-
- if ((fd->sf_fd = open(_NSC_DEV_PATH, fd->sf_fmode)) < 0)
- return (0);
-
- if (ioctl(fd->sf_fd, NSCIOC_OPEN, &op) == 0)
- return (1);
-
- close(fd->sf_fd);
- return (0);
-}
-
-
-static int
-_nsc_open_check(fd)
-nsc_fd_t *fd;
-{
- struct flock lk;
- char s[30];
- pid_t pid;
- int i;
-
- if ((fd->sf_fmode & O_ACCMODE) == O_RDONLY)
- return (1);
-
- if (access(_NSC_CKDCHK_PATH, X_OK) != 0)
- return (0);
-
- lk.l_type = F_WRLCK;
- lk.l_whence = SEEK_SET;
- lk.l_start = 0;
- lk.l_len = 0;
-
- if (fcntl(fd->sf_fd, F_SETLKW, &lk) < 0)
- return (0);
-
- if ((pid = fork()) == 0) {
- for (i = 1; i <= NSIG; i++)
- signal(i, SIG_IGN);
-
- for (i = fd->sf_fd; i <= 2 && (i = dup(i)) != -1; )
- fd->sf_fd = i;
-
- for (i = sysconf(_SC_OPEN_MAX); i >= 0; i--)
- if (i != fd->sf_fd)
- close(i);
-
- fcntl(fd->sf_fd, F_SETFD, 0);
-
- (void) open("/dev/null", 0);
- (void) open(_NSC_CKDCHK_LOG, O_WRONLY|O_CREAT|O_APPEND, 0666);
- (void) open(_NSC_CKDCHK_LOG, O_WRONLY|O_CREAT|O_APPEND, 0666);
-
- (void) sprintf(s, "%d", fd->sf_fd);
-
- (void) execl(_NSC_CKDCHK_PATH, "ckdchk", "-u", "-F",
- s, fd->sf_path, 0);
-
- exit(1);
- }
-
- return (pid != -1);
-}
-
-
-int
-nsc_close(fd)
-nsc_fd_t *fd;
-{
- int rc;
-
- if (!fd)
- return (0);
-
- rc = close(fd->sf_fd);
- free(fd);
-
- return (rc);
-}
-
-
-int
-nsc_reserve(fd)
-nsc_fd_t *fd;
-{
- return ((fd) ? ioctl(fd->sf_fd, NSCIOC_RESERVE, 0) : 0);
-}
-
-
-int
-nsc_release(fd)
-nsc_fd_t *fd;
-{
- if (!fd)
- return (0);
-
- if (ckdchk && (fd->sf_fmode & O_ACCMODE) != O_RDONLY) {
- errno = EINVAL;
- return (-1);
- }
-
- return (ioctl(fd->sf_fd, NSCIOC_RELEASE, 0));
-}
-
-
-int
-nsc_partsize(nsc_fd_t *fd, nsc_size_t *rvp)
-{
- struct nscioc_partsize partsize;
- int rc;
-
- if (!fd)
- return (0);
-
- rc = ioctl(fd->sf_fd, NSCIOC_PARTSIZE, &partsize);
- if (rc != 0) {
- return (rc);
- }
-
- *rvp = (nsc_size_t)partsize.partsize;
- return (0);
-}
-
-
-int
-nsc_fileno(fd)
-nsc_fd_t *fd;
-{
- return ((fd) ? fd->sf_fd : -1);
-}
-
-
-void
-_nsc_nocheck()
-{
- ckdchk = 0;
-}
-
-
-static int
-_nsc_do_ioctl(cmd, arg)
-int cmd;
-void *arg;
-{
- int fd, rc, save_errno;
-
- fd = open(_NSC_DEV_PATH, O_RDONLY);
- if (fd < 0)
- return (-1);
-
- rc = save_errno = 0;
- rc = ioctl(fd, cmd, arg);
- if (rc < 0)
- save_errno = errno;
-
- close(fd);
-
- errno = save_errno;
- return (rc);
-}
-
-
-/*
- * int
- * nsc_freeze(char *path)
- * Freeze a pathname
- *
- * Calling/Exit State:
- * Returns 0 for success, or -1 and sets errno.
- *
- * Description:
- * This is the user level interface to the nsctl freeze operation.
- * See uts/common/ns/nsctl/nsc_freeze.c for more information.
- */
-int
-nsc_freeze(path)
-char *path;
-{
- if (strlen(path) >= NSC_MAXPATH) {
- errno = ENAMETOOLONG;
- return (-1);
- }
-
- return (_nsc_do_ioctl(NSCIOC_FREEZE, path));
-}
-
-/*
- * int
- * nsc_unfreeze(char *path)
- * Unfreeze a pathname
- *
- * Calling/Exit State:
- * Returns 0 for success, or -1 and sets errno.
- *
- * Description:
- * This is the user level interface to the nsctl unfreeze operation.
- * See uts/common/ns/nsctl/nsc_freeze.c for more information.
- */
-int
-nsc_unfreeze(path)
-char *path;
-{
- if (strlen(path) >= NSC_MAXPATH) {
- errno = ENAMETOOLONG;
- return (-1);
- }
-
- return (_nsc_do_ioctl(NSCIOC_UNFREEZE, path));
-}
-
-
-/*
- * int
- * nsc_isfrozen(char *path)
- * Test if a pathname is frozen
- *
- * Calling/Exit State:
- * Returns:
- * 0 path is frozen
- * 1 path is not frozen
- * -1 error (errno will be set)
- *
- * Description
- * This is the user level interface to to the nsctl isfrozen operation.
- * See uts/common/ns/nsctl/nsc_freeze.c for more information.
- */
-int
-nsc_isfrozen(path)
-char *path;
-{
- if (strlen(path) >= NSC_MAXPATH) {
- errno = ENAMETOOLONG;
- return (-1);
- }
-
- return (_nsc_do_ioctl(NSCIOC_ISFROZEN, path));
-}
-
-int
-nsc_gmem_sizes(int *size)
-{
- return (_nsc_do_ioctl(NSCIOC_GLOBAL_SIZES, size));
-}
-
-int
-nsc_gmem_data(char *addr)
-{
- return (_nsc_do_ioctl(NSCIOC_GLOBAL_DATA, addr));
-}
-
-/*
- * int
- * nsc_nvclean()
- * mark nvmem clean, to prevent a warmstart of the cache on reboot
- */
-int
-nsc_nvclean(int force)
-{
- int cmd;
-
- cmd = force ? NSCIOC_NVMEM_CLEANF : NSCIOC_NVMEM_CLEAN;
-
- return (_nsc_do_ioctl(cmd, (void *)0));
-}
diff --git a/usr/src/lib/libnsctl/common/hash.c b/usr/src/lib/libnsctl/common/hash.c
deleted file mode 100644
index 1cc7e8f257..0000000000
--- a/usr/src/lib/libnsctl/common/hash.c
+++ /dev/null
@@ -1,166 +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 <string.h>
-#include <stdlib.h>
-#include <sys/nsctl/nsc_hash.h>
-
-#define HASH_PRIME 2039
-
-static int calc_hash(const char *);
-
-hash_node_t **
-nsc_create_hash()
-{
- hash_node_t **hash;
-
- hash = (hash_node_t **)calloc(HASH_PRIME, sizeof (hash_node_t *));
- return (hash);
-}
-
-int
-nsc_insert_node(hash_node_t **hash, void *data, const char *key)
-{
- int index;
- hash_node_t *node;
-
- node = (hash_node_t *)malloc(sizeof (hash_node_t));
- if (!node) {
- return (-1);
- }
- node->key = strdup(key);
- node->data = data;
-
- /*
- * possible enhancement would be to search
- * in this index for a duplicate
- */
- index = calc_hash(key);
- node->next = hash[ index ];
- hash[ index ] = node;
-
- return (0);
-}
-
-/*
- * lookup
- *
- * Description:
- * Searches the hash to find a node.
- *
- * Return values:
- * 0 if not found.
- * pointer to node if found.
- */
-void *
-nsc_lookup(hash_node_t **hash, const char *key)
-{
- int index;
- hash_node_t *node;
-
- index = calc_hash(key);
- node = hash[ index ];
- while (node) {
- if (strcmp(node->key, key) == 0)
- return (node->data);
- node = node->next;
- }
- return (0);
-}
-
-void *
-nsc_remove_node(hash_node_t **hash, char *key)
-{
- int index;
- hash_node_t *node, *prev;
- void *retval;
-
- index = calc_hash(key);
- if (!hash[ index ]) {
- return (0);
- }
-
- if (strcmp(hash[ index ]->key, key) == 0) {
- node = hash[ index ];
- retval = node->data;
- hash[ index ] = hash[ index ]->next;
- free(node->key);
- free(node);
- return (retval);
- }
- prev = hash[ index ];
- node = prev->next;
- while (node && (strcmp(node->key, key) != 0)) {
- prev = node;
- node = node->next;
- }
-
- /* did we find it? */
- if (node) {
- prev->next = node->next;
- retval = node->data;
- free(node->key);
- free(node);
- return (retval);
- }
- return (0);
-}
-
-void
-nsc_remove_all(hash_node_t **hash, void (*callback)(void *))
-{
- int i;
- hash_node_t *p, *next;
-
- for (i = 0; i < HASH_PRIME; i++) {
- p = hash[ i ];
- while (p) {
- next = p->next;
- if (callback) {
- callback(p->data);
- }
- free(p->key);
- free(p);
- p = next;
- }
- }
- free(hash);
-}
-
-/* ---------------------------------------------------------------------- */
-
-/*
- * Basic rotating hash, as per Knuth.
- */
-static int
-calc_hash(const char *key)
-{
- unsigned int hash, i;
- int len = strlen(key);
- for (hash = len, i = 0; i < len; i++) {
- hash = (hash << 5) ^ (hash >> 27) ^ key[ i ];
- }
- return (hash % HASH_PRIME);
-}
diff --git a/usr/src/lib/libnsctl/common/libnsctl.h b/usr/src/lib/libnsctl/common/libnsctl.h
deleted file mode 100644
index abd165ce42..0000000000
--- a/usr/src/lib/libnsctl/common/libnsctl.h
+++ /dev/null
@@ -1,62 +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.
- */
-
-
-#ifndef _LIBNSCTL_H
-#define _LIBNSCTL_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <sys/nsctl/nsctl.h>
-#include <sys/nsctl/nsc_ioctl.h>
-
-
-/*
- * Standard Definitions.
- */
-
-#ifdef sun
-#define _NSC_DEV_PATH "/dev/nsctl"
-#else
-#define _NSC_DEV_PATH "/dev/sd"
-#endif
-#define _NSC_CKDCHK_PATH "/usr/install/simckd/bin/ckdchk"
-#define _NSC_CKDCHK_LOG "/rsvd/dumps/ckdchk.log"
-
-
-typedef struct nsc_fd_s {
- int sf_fd; /* SD device */
- int sf_flag; /* Open flags */
- int sf_fmode; /* File modes */
- char sf_path[NSC_MAXPATH]; /* Pathname */
-} nsc_fd_t;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _LIBNSCTL_H */
diff --git a/usr/src/lib/libnsctl/common/llib-lnsctl b/usr/src/lib/libnsctl/common/llib-lnsctl
deleted file mode 100644
index 7defea0425..0000000000
--- a/usr/src/lib/libnsctl/common/llib-lnsctl
+++ /dev/null
@@ -1,52 +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 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <sys/types.h>
-#include <nsctl.h>
-#include <sys/nsctl/nsc_hash.h>
-
-void _nsc_nocheck(void);
-nsc_fd_t *nsc_open(char *path, int flag, int mode);
-nsc_fd_t *nsc_fdopen(int id, char *path, int mode);
-int nsc_close(nsc_fd_t *fd);
-int nsc_fileno(nsc_fd_t *fd);
-int nsc_reserve(nsc_fd_t *fd);
-int nsc_release(nsc_fd_t *fd);
-int nsc_partsize(nsc_fd_t *fd, nsc_size_t *size);
-int nsc_freeze(char *path);
-int nsc_unfreeze(char *path);
-int nsc_isfrozen(char *path);
-int nsc_getsystemid(int *id);
-int nsc_name_to_id(char *name, int *id);
-int nsc_id_to_name(char **name, int id);
-int nsc_check_release(const char *build_rel, nsc_release_t *map, char **reqd);
-hash_node_t **nsc_create_hash();
-int nsc_insert_node(hash_node_t **, void *, const char *);
-void *nsc_lookup(hash_node_t **, const char *);
-void *nsc_remove_node(hash_node_t **, char *);
-void nsc_remove_all(hash_node_t **, void (*)(void *));
diff --git a/usr/src/lib/libnsctl/common/machdep.c b/usr/src/lib/libnsctl/common/machdep.c
deleted file mode 100644
index d577995ad1..0000000000
--- a/usr/src/lib/libnsctl/common/machdep.c
+++ /dev/null
@@ -1,314 +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 <sys/types.h>
-#include <sys/utsname.h>
-#include <fcntl.h>
-#include <sys/param.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "libnsctl.h"
-#include <nsctl.h>
-#include <sys/ncall/ncall.h>
-
-
-
-/*
- * Internal routine to fetch all the current nodes that are
- * considered 'up'.
- * Returns the number of ncall_info structures that are valid
- * returned via the nodelist pointer, or -1 on an error.
- * If the call succeeds, then the memory returned via the
- * nodelist pointer needs to be freed by the caller.
- */
-
-static int
-nsc_getcurrentnodes(ncall_node_t **nodelist)
-{
- ncall_node_t *mynodelist;
- int size;
- int fd;
- int rc = -1;
- int save_errno = 0;
- int ioctlcmd;
-
- if (nodelist == NULL) {
- errno = EINVAL;
- return (-1);
- }
- *nodelist = NULL;
- if ((fd = open("/dev/ncall", O_RDONLY)) < 0) {
- return (-1);
- }
- if ((size = ioctl(fd, NC_IOC_GETNETNODES, NULL)) < 1) {
- size = 1;
- ioctlcmd = NC_IOC_GETNODE;
- } else {
- ioctlcmd = NC_IOC_GETNETNODES;
- }
-
- mynodelist = malloc(size * sizeof (*mynodelist));
- if (mynodelist == NULL) {
- save_errno = ENOMEM;
- } else {
- rc = ioctl(fd, ioctlcmd, mynodelist);
- if (rc < 0) {
- save_errno = errno;
- free(mynodelist);
- } else {
- /* fixup return value for single node ioctl */
- if (ioctlcmd == NC_IOC_GETNODE)
- rc = 1;
- *nodelist = mynodelist;
- }
- }
- close(fd);
- errno = save_errno;
- return (rc);
-}
-
-
-/*
- * return the system id (the current value in the kernel
- * currently running).
- *
- * on error return -1 and set errno.
- */
-int
-nsc_getsystemid(int *id)
-{
- ncall_node_t node;
- int rval = 0;
- int save_errno = 0;
- int fd;
-
- *id = 0;
-
- fd = open("/dev/ncall", O_RDONLY);
- if (fd < 0)
- return (-1);
-
- memset(&node, 0, sizeof (node));
-
- rval = ioctl(fd, NC_IOC_GETNODE, &node);
- if (rval < 0)
- save_errno = errno;
- else {
- *id = node.nc_nodeid;
- /*
- * Return 0, not the mirror node id as returned
- * from the ioctl.
- */
- rval = 0;
- }
-
- close(fd);
-
- errno = save_errno;
- return (rval);
-}
-
-
-/*
- * Runtime Solaris release checking.
- *
- * Compare the build release to the runtime release to check for an
- * acceptable match.
- *
- * Arguments:
- * build_ver - the string Solaris build release (e.g. "5.8")
- * map - optional array of nsc_release_t defining
- * acceptable build release / runtime release
- * matches. If supplied, must end will a NULL
- * array element. See src/head/nsctl.h for info.
- * reqd - used to return the required OS versions if the
- * return value is not -1. The returned string
- * is readonly.
- *
- * Returns:
- * TRUE - acceptable match
- * FALSE - no match (component should not continue to run)
- * -1 - error (errno is set)
- */
-
-int
-nsc_check_release(const char *build_rel, nsc_release_t *map, char **reqd)
-{
- struct utsname uts;
- nsc_release_t *mp;
- const char *sep = ", ";
- char *cp, *tofree, *last;
- int rc;
-
- if (reqd)
- *reqd = NULL;
-
- if (build_rel == NULL || *build_rel == '\0') {
- errno = EINVAL;
- return (-1);
- }
-
- /* assume that build_rel is the required release for now */
- if (reqd)
- *reqd = (char *)build_rel;
-
- if (uname(&uts) < 0)
- return (-1);
-
- /* build release == runtime release is always acceptable */
- if (strcmp(build_rel, uts.release) == 0)
- return (TRUE);
-
- if (map == NULL)
- return (FALSE);
-
- rc = FALSE;
- tofree = NULL;
-
- for (mp = map; mp->build != NULL && mp->runtime != NULL; mp++) {
- if (strcmp(mp->build, build_rel) == 0) {
- /*
- * found an entry for this build release
- * - search for a match in the runtime releases
- */
-
- /* reset reqd to this entry */
- if (reqd)
- *reqd = (char *)mp->runtime;
-
- /*
- * operate on a copy of the string since strtok
- * is destructive.
- */
- tofree = cp = strdup(mp->runtime);
- if (cp == NULL) {
- errno = ENOMEM;
- rc = -1;
- break;
- }
-
- cp = strtok_r(cp, sep, &last);
- while (cp != NULL) {
- if (strcmp(cp, uts.release) == 0) {
- rc = TRUE;
- break;
- }
-
- cp = strtok_r(NULL, sep, &last);
- }
-
- break;
- }
- }
-
- if (tofree)
- free(tofree);
-
- return (rc);
-}
-
-
-/*
- * return the system id corresponding to name
- *
- * on error return -1 and set errno.
- */
-int
-nsc_name_to_id(char *name, int *id)
-{
- ncall_node_t *nodes;
- int rval = 0;
- int nodecnt;
- int slot;
-
- *id = 0;
-
- nodecnt = nsc_getcurrentnodes(&nodes);
- if (nodecnt < 0) {
- rval = -1;
- } else {
- for (slot = 0; slot < nodecnt; slot++) {
- if (strcmp(name, nodes[slot].nc_nodename) == 0) {
- *id = nodes[slot].nc_nodeid;
- break;
- }
- }
- if (slot >= nodecnt) {
- errno = ENOENT;
- rval = -1;
- }
- free(nodes);
- }
- return (rval);
-}
-
-/*
- * return the node name corresponding to system id
- *
- * on error return -1 and set errno.
- * The returned string has been strdup() and needs
- * to be freed by the caller.
- */
-int
-nsc_id_to_name(char **name, int id)
-{
- ncall_node_t *nodes;
- int rval = 0;
- int nodecnt;
- int slot;
- char *foundname;
-
- *name = 0;
- foundname = NULL;
-
- nodecnt = nsc_getcurrentnodes(&nodes);
- if (nodecnt < 0) {
- rval = -1;
- } else {
- for (slot = 0; slot < nodecnt; slot++) {
- if (nodes[slot].nc_nodeid == id) {
- foundname = strdup(nodes[slot].nc_nodename);
- if (foundname) {
- *name = foundname;
- } else {
- errno = ENOMEM;
- rval = -1;
- }
- break;
- }
- }
- if (slot >= nodecnt) {
- errno = ENOENT;
- rval = -1;
- }
- free(nodes);
- }
- return (rval);
-}
diff --git a/usr/src/lib/libnsctl/common/mapfile-vers b/usr/src/lib/libnsctl/common/mapfile-vers
deleted file mode 100644
index eb399179e2..0000000000
--- a/usr/src/lib/libnsctl/common/mapfile-vers
+++ /dev/null
@@ -1,70 +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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
-#
-
-#
-# 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
-#
-
-$mapfile_version 2
-
-#
-# Generic interface definition for usr/src/lib/libnsctl.
-#
-
-SYMBOL_VERSION SUNWprivate_1.1 {
- global:
- _nsc_nocheck;
- nsc_check_release;
- nsc_close;
- nsc_fdopen;
- nsc_fileno;
- nsc_freeze;
- nsc_getsystemid;
- nsc_gmem_data;
- nsc_gmem_sizes;
- nsc_id_to_name;
- nsc_isfrozen;
- nsc_name_to_id;
- nsc_nvclean;
- nsc_open;
- nsc_partsize;
- nsc_release;
- nsc_reserve;
- nsc_unfreeze;
- nsc_create_hash;
- nsc_insert_node;
- nsc_lookup;
- nsc_remove_node;
- nsc_remove_all;
- local:
- *;
-};
diff --git a/usr/src/lib/libnsctl/common/nsc_hash.h b/usr/src/lib/libnsctl/common/nsc_hash.h
deleted file mode 100644
index 80cf846861..0000000000
--- a/usr/src/lib/libnsctl/common/nsc_hash.h
+++ /dev/null
@@ -1,49 +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.
- */
-
-#ifndef _NSC_HASH_H
-#define _NSC_HASH_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct hash_node_s {
- struct hash_node_s *next;
- char *key;
- void *data;
-} hash_node_t;
-
-hash_node_t **nsc_create_hash();
-int nsc_insert_node(hash_node_t **, void *, const char *);
-void *nsc_lookup(hash_node_t **, const char *);
-void *nsc_remove_node(hash_node_t **, char *);
-void nsc_remove_all(hash_node_t **, void (*)(void *));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _NSC_HASH_H */
diff --git a/usr/src/lib/libnsctl/i386/Makefile b/usr/src/lib/libnsctl/i386/Makefile
deleted file mode 100644
index a360cc9a91..0000000000
--- a/usr/src/lib/libnsctl/i386/Makefile
+++ /dev/null
@@ -1,36 +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.
-#
-# lib/libnsctl/i386/Makefile
-
-include ../Makefile.com
-
-.KEEP_STATE:
-
-all: $(LIBS)
-
-install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTARLINK)
-
-lint:
-lintinter:
-
diff --git a/usr/src/lib/libnsctl/sparc/Makefile b/usr/src/lib/libnsctl/sparc/Makefile
deleted file mode 100644
index 9e5f62fb13..0000000000
--- a/usr/src/lib/libnsctl/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 2008 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# lib/libnsctl/sparc/Makefile
-
-include ../Makefile.com
-
-all: $(LIBS)
-
-install: all $(ROOTLIBS) $(ROOTLINKS)
diff --git a/usr/src/lib/librdc/Makefile b/usr/src/lib/librdc/Makefile
deleted file mode 100644
index 8c56e8f017..0000000000
--- a/usr/src/lib/librdc/Makefile
+++ /dev/null
@@ -1,60 +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.
-#
-# lib/librdc/Makefile
-
-include ../Makefile.lib
-
-HDRS= librdc.h rdcerr.h rdcrules.h
-HDRDIR= common
-
-SUBDIRS= $(MACH)
-
-ROOTHDRDIR= $(ROOT)/usr/include/sys/nsctl
-
-ROOTHDRS= $(HDRS:%=$(ROOTHDRDIR)/%)
-
-all := TARGET= all
-clean := TARGET= clean
-clobber := TARGET= clobber
-install := TARGET= install
-lint := TARGET= lint
-
-.KEEP_STATE:
-
-all clean clobber install lint: $(SUBDIRS)
-
-$(MACH): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
-
-install_h: $(ROOTHDRDIR) $(ROOTHDRS)
-
-$(ROOTHDRDIR)/%: common/%
- $(INS.file)
-
-$(ROOTHDRDIR):
- $(INS.dir)
-
-check: $(CHECKHDRS)
-
-FRC:
diff --git a/usr/src/lib/librdc/Makefile.com b/usr/src/lib/librdc/Makefile.com
deleted file mode 100644
index 1819191a1c..0000000000
--- a/usr/src/lib/librdc/Makefile.com
+++ /dev/null
@@ -1,92 +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.
-#
-# lib/librdc/Makefile.com
-
-LIBRARY= librdc.a
-VERS= .1
-
-OBJECTS= netaddrs.o rdcerr.o rdcconfig.o rdc_ioctl.o rdcpersist.o rdcrules.o
-
-# include library definitions
-include ../../Makefile.lib
-
-SRCS= ../common/*.c ../../../cmd/avs/rdc/rdc_ioctl.c
-SRCDIR= ../common
-
-LIBS += $(DYNLIB) $(LINTLIB)
-
-# definitions for lint
-
-LINTFLAGS += -u -I.. -DDEBUG
-LINTFLAGS += -erroff=E_FUNC_SET_NOT_USED
-LINTFLAGS += -erroff=E_STATIC_UNUSED
-LINTFLAGS += -erroff=E_SEC_PRINTF_VAR_FMT
-LINTFLAGS += -erroff=E_SEC_SCANF_UNBOUNDED_COPY
-LINTFLAGS += -erroff=E_FUNC_RET_ALWAYS_IGNOR2
-LINTFLAGS += -erroff=E_FUNC_RET_MAYBE_IGNORED2
-LINTFLAGS += -erroff=E_INCONS_VAL_TYPE_DECL2
-LINTFLAGS += -erroff=E_BAD_FORMAT_ARG_TYPE2
-LINTOUT= lint.out
-LINTOUT_INTER= lintinter.out
-
-CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-address
-
-LINTSRC= $(LINTLIB:%.ln=%)
-ROOTLINTDIR= $(ROOTLIBDIR)
-ROOTLINT= $(LINTSRC:%=$(ROOTLINTDIR)/%)
-
-CLEANFILES += $(LINTOUT) $(LINTLIB) $(LINTOUT_INTER) $(LINT_INTER)
-
-CPPFLAGS += -DBUILD_REV_STR='"5.11"'
-CFLAGS += -I..
-CFLAGS64 += -I..
-LDLIBS += -lsocket -lnsl -lnsctl -lc -lunistat -ldscfg
-
-$(LINTLIB) := SRCS = ../common/llib-lrdc
-$(LINTLIB) := LINTFLAGS = -nvx
-$(LINTLIB) := LINTFLAGS64 = -nvx
-
-$(LINT_INTER) := SRCS += ../common/llib-lrdc
-
-.KEEP_STATE:
-
-lint: lintcheck $(LINTLIB)
-lintinter: $(LINT_INTER)
-
-# include library targets
-include ../../Makefile.targ
-
-objs/%.o pics/%.o: ../common/%.c
- $(COMPILE.c) -o $@ $<
- $(POST_PROCESS_O)
-
-objs/rdc_ioctl.o pics/rdc_ioctl.o: ../../../cmd/avs/rdc/rdc_ioctl.c
- $(COMPILE.c) -o $@ ../../../cmd/avs/rdc/rdc_ioctl.c
- $(POST_PROCESS_O)
-
-# install rule for lint library target
-$(ROOTLINTDIR)/%: ../common/%
- $(INS.file)
diff --git a/usr/src/lib/librdc/common/librdc.h b/usr/src/lib/librdc/common/librdc.h
deleted file mode 100644
index 99ac34afe7..0000000000
--- a/usr/src/lib/librdc/common/librdc.h
+++ /dev/null
@@ -1,113 +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.
- */
-
-#ifndef _LIBRDC_H
-#define _LIBRDC_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern int Is_ipv6present(void);
-extern int self_check(char *);
-extern int gethost_netaddrs(char *, char *, char *, char *);
-extern struct hostent *gethost_byname(const char *);
-extern struct netbuf *get_addr(char *, ulong_t, ulong_t, struct netconfig **,
- char *, char *, struct t_info *, int);
-extern int convert_nconf_to_knconf(struct netconfig *, struct knetconfig *);
-extern int rdc_check_release(char **);
-
-#if !defined(NSC_MAXPATH)
-#define NSC_MAXPATH 64
-#endif
-
-#define RDC_MAX_THREADS 1024
-/* user interface to sndr */
-typedef struct rdcconfig_s {
- char phost[NSC_MAXPATH];
- char pfile[NSC_MAXPATH];
- char pbmp[NSC_MAXPATH];
- char shost[NSC_MAXPATH];
- char sfile[NSC_MAXPATH];
- char sbmp[NSC_MAXPATH];
- char direct[NSC_MAXPATH];
- char mode[NSC_MAXPATH];
- char group[NSC_MAXPATH];
- char ctag[NSC_MAXPATH];
- char options[NSC_MAXPATH];
- int persist; /* 0 no, 1 yes */
- struct rdcconfig_s *next;
-} rdcconfig_t;
-
-#define RDC_ERR_SIZE 256
-
-typedef struct rdc_rc_s {
- int rc;
- char msg[RDC_ERR_SIZE];
- struct rdc_rc_s *next;
- rdcconfig_t set;
-} rdc_rc_t;
-
-#define RDC_FREEONE 0 /* free one rdcconfig_t* */
-#define RDC_FREEALL 1 /* free entire chain of rdcconfig_t* */
-
-/* and it's operations */
-extern rdcconfig_t *rdc_alloc_config(const char *phost, const char *pfile,
- const char *pbmp, const char *shost, const char *sfile, const char *sbmp,
- const char *mode, const char *group, const char *ctag, const char *options,
- int persist);
-extern void rdc_free_config(rdcconfig_t *rdc, int all);
-extern void rdc_free_rclist(rdc_rc_t *rc);
-extern rdc_rc_t *new_rc(void);
-extern rdc_rc_t *rdc_enable(rdcconfig_t *rdc);
-extern rdc_rc_t *rdc_enable_clrbmp(rdcconfig_t *rdc);
-extern rdc_rc_t *rdc_disable(rdcconfig_t *rdc);
-extern rdc_rc_t *rdc_log(rdcconfig_t *rdc);
-extern rdc_rc_t *rdc_usync(rdcconfig_t *rdc);
-extern rdc_rc_t *rdc_fsync(rdcconfig_t *rdc);
-extern rdc_rc_t *rdc_rsync(rdcconfig_t *rdc);
-extern rdc_rc_t *rdc_ursync(rdcconfig_t *rdc);
-extern rdc_rc_t *rdc_wait(rdcconfig_t *rdc);
-extern rdc_rc_t *rdc_set_autosync(rdcconfig_t *rdc, int autosync);
-extern rdc_rc_t *rdc_set_maxqfbas(rdcconfig_t *rdc, int maxqfbas);
-extern rdc_rc_t *rdc_set_maxqitems(rdcconfig_t *rdc, int maxqitems);
-extern int rdc_get_maxqfbas(rdcconfig_t *rdc);
-extern int rdc_get_maxqitems(rdcconfig_t *rdc);
-extern int rdc_get_autosync(rdcconfig_t *rdc);
-extern rdc_rc_t *rdc_reconfig_pbmp(rdcconfig_t *rdc, char *pbmp);
-extern rdc_rc_t *rdc_reconfig_sbmp(rdcconfig_t *rdc, char *sbmp);
-extern rdc_rc_t *rdc_reconfig_group(rdcconfig_t *rdc, char *group);
-extern rdc_rc_t *rdc_reconfig_ctag(rdcconfig_t *rdc, char *ctag);
-extern rdc_rc_t *rdc_set_sync(rdcconfig_t *rdc);
-extern rdc_rc_t *rdc_set_async(rdcconfig_t *rdc);
-extern rdc_rc_t *rdc_health(rdcconfig_t *rdc);
-extern rdc_rc_t *rdc_reverse_role(rdcconfig_t *rdc);
-extern char *rdc_error(int *sev);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _LIBRDC_H */
diff --git a/usr/src/lib/librdc/common/llib-lrdc b/usr/src/lib/librdc/common/llib-lrdc
deleted file mode 100644
index 03b796f3be..0000000000
--- a/usr/src/lib/librdc/common/llib-lrdc
+++ /dev/null
@@ -1,46 +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 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <sys/types.h>
-#include <sys/stream.h>
-#include <sys/socket.h>
-#include <sys/poll.h>
-#include <rpc/rpc.h>
-#include <netconfig.h>
-#include "librdc.h"
-
-int Is_ipv6present(void);
-int self_check(char *hostname);
-int gethost_netaddrs(char *fromhost, char *tohost, char *fromnetaddr,
- char *tonetaddr);
-struct hostent *gethost_byname(const char *name);
-struct netbuf *get_addr(char *hostname, ulong_t prog, ulong_t vers,
- struct netconfig **nconfp, char *proto, char *srvport,
- struct t_info *tinfo, int portmap);
-int convert_nconf_to_knconf(struct netconfig *nconf, struct knetconfig *knconf);
-int rdc_check_release(char **reqd);
diff --git a/usr/src/lib/librdc/common/mapfile-vers b/usr/src/lib/librdc/common/mapfile-vers
deleted file mode 100644
index e38650b2a3..0000000000
--- a/usr/src/lib/librdc/common/mapfile-vers
+++ /dev/null
@@ -1,84 +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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
-#
-
-#
-# 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
-#
-
-#
-# Generic interface definition for usr/src/lib/librdc.
-#
-
-$mapfile_version 2
-
-SYMBOL_VERSION SUNWprivate_1.1 {
- global:
- Is_ipv6present;
- convert_nconf_to_knconf;
- get_addr;
- gethost_byname;
- gethost_netaddrs;
- rdc_check_release;
- rdc_set_error;
- rdc_alloc_config;
- rdc_free_config;
- rdc_free_rclist;
- self_check;
- rdc_enable;
- rdc_enable_clrbmp;
- rdc_disable;
- rdc_log;
- rdc_usync;
- rdc_fsync;
- rdc_rsync;
- rdc_ursync;
- rdc_wait;
- rdc_set_autosync;
- rdc_set_maxqfbas;
- rdc_set_maxqitems;
- rdc_get_maxqfbas;
- rdc_get_maxqitems;
- rdc_get_autosync;
- rdc_reconfig_pbmp;
- rdc_reconfig_sbmp;
- rdc_reconfig_group;
- rdc_reconfig_ctag;
- rdc_set_sync;
- rdc_set_async;
- rdc_health;
- rdc_reverse_role;
- rdc_error;
-
- local:
- *;
-};
diff --git a/usr/src/lib/librdc/common/netaddrs.c b/usr/src/lib/librdc/common/netaddrs.c
deleted file mode 100644
index ed90358618..0000000000
--- a/usr/src/lib/librdc/common/netaddrs.c
+++ /dev/null
@@ -1,670 +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 <locale.h>
-#include <stdio.h>
-#include <string.h>
-#include <memory.h>
-#include <varargs.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <sys/param.h>
-#include <rpc/rpc.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <netdb.h>
-#include <sys/pathconf.h>
-#include <netdir.h>
-#include <netconfig.h>
-#include <sys/sockio.h>
-#include <net/if.h>
-#include <syslog.h>
-#include <netinet/in.h>
-#include <nfs/nfs_sec.h>
-#include <strings.h>
-#include <sys/nsctl/rdc_prot.h>
-#include <nsctl.h>
-
-#include "librdc.h"
-
-#define MAXIFS 32
-
-/* number of transports to try */
-#define MNT_PREF_LISTLEN 2
-#define FIRST_TRY 1
-#define SECOND_TRY 2
-
-
-int
-Is_ipv6present(void)
-{
-#ifdef AF_INET6
- int sock;
- struct lifnum lifn;
-
- sock = socket(AF_INET6, SOCK_DGRAM, 0);
- if (sock < 0)
- return (0);
-
- lifn.lifn_family = AF_INET6;
- lifn.lifn_flags = 0;
- if (ioctl(sock, SIOCGLIFNUM, (char *)&lifn) < 0) {
- close(sock);
- return (0);
- }
- close(sock);
- if (lifn.lifn_count == 0)
- return (0);
- return (1);
-#else
- return (0);
-#endif
-}
-
-/*
- * The following is stolen from autod_nfs.c
- */
-static void
-getmyaddrs(struct ifconf *ifc)
-{
- int sock;
- int numifs;
- char *buf;
- int family;
-
- ifc->ifc_buf = NULL;
- ifc->ifc_len = 0;
-
-#ifdef AF_INET6
- family = AF_INET6;
-#else
- family = AF_INET;
-#endif
- if ((sock = socket(family, SOCK_DGRAM, 0)) < 0) {
-#ifdef DEBUG
- perror("getmyaddrs(): socket");
-#endif
- return;
- }
-
- if (ioctl(sock, SIOCGIFNUM, (char *)&numifs) < 0) {
-#ifdef DEBUG
- perror("getmyaddrs(): SIOCGIFNUM");
-#endif
- numifs = MAXIFS;
- }
-
- buf = (char *)malloc(numifs * sizeof (struct ifreq));
- if (buf == NULL) {
-#ifdef DEBUG
- fprintf(stderr, "getmyaddrs(): malloc failed\n");
-#endif
- (void) close(sock);
- return;
- }
-
- ifc->ifc_buf = buf;
- ifc->ifc_len = numifs * sizeof (struct ifreq);
-
- if (ioctl(sock, SIOCGIFCONF, (char *)ifc) < 0) {
-#ifdef DEBUG
- perror("getmyaddrs(): SIOCGIFCONF");
-#else
- ;
- /*EMPTY*/
-#endif
- }
-
- (void) close(sock);
-}
-
-int
-self_check(char *hostname)
-{
- int n;
- struct sockaddr_in *s1, *s2;
- struct ifreq *ifr;
- struct nd_hostserv hs;
- struct nd_addrlist *retaddrs;
- struct netconfig *nconfp;
- struct ifconf *ifc;
- int retval;
-
- ifc = malloc(sizeof (struct ifconf));
- if (ifc == NULL)
- return (0);
- memset((char *)ifc, 0, sizeof (struct ifconf));
- getmyaddrs(ifc);
- /*
- * Get the IP address for hostname
- */
- nconfp = getnetconfigent("udp");
- if (nconfp == NULL) {
-#ifdef DEBUG
- fprintf(stderr, "self_check(): getnetconfigent failed\n");
-#endif
- retval = 0;
- goto out;
- }
- hs.h_host = hostname;
- hs.h_serv = "rpcbind";
- if (netdir_getbyname(nconfp, &hs, &retaddrs) != ND_OK) {
- freenetconfigent(nconfp);
- retval = 0;
- goto out;
- }
- freenetconfigent(nconfp);
- /* LINTED pointer alignment */
- s1 = (struct sockaddr_in *)retaddrs->n_addrs->buf;
-
- /*
- * Now compare it against the list of
- * addresses for the interfaces on this
- * host.
- */
- ifr = ifc->ifc_req;
- n = ifc->ifc_len / sizeof (struct ifreq);
- s2 = NULL;
- for (; n > 0; n--, ifr++) {
- if (ifr->ifr_addr.sa_family != AF_INET)
- continue;
-
- /* LINTED pointer alignment */
- s2 = (struct sockaddr_in *)&ifr->ifr_addr;
-
- if (memcmp((char *)&s2->sin_addr,
- (char *)&s1->sin_addr, sizeof (s1->sin_addr)) == 0) {
- netdir_free((void *)retaddrs, ND_ADDRLIST);
- retval = 1;
- goto out; /* it's me */
- }
- }
- netdir_free((void *)retaddrs, ND_ADDRLIST);
- retval = 0;
-
-out:
- if (ifc->ifc_buf != NULL)
- free(ifc->ifc_buf);
- free(ifc);
- return (retval);
-}
-
-
-int
-convert_nconf_to_knconf(struct netconfig *nconf, struct knetconfig *knconf)
-{
- struct stat sb;
-
- if (stat(nconf->nc_device, &sb) < 0) {
- (void) syslog(LOG_ERR, "can't find device for transport %s\n",
- nconf->nc_device);
- return (-1);
- }
-#ifdef DEBUG_ADDR
- printf("lib knconf %x %s %s %x\n", nconf->nc_semantics,
- nconf->nc_protofmly, nconf->nc_proto, sb.st_rdev);
-#endif
-
- knconf->knc_semantics = nconf->nc_semantics;
- knconf->knc_protofmly = nconf->nc_protofmly;
- knconf->knc_proto = nconf->nc_proto;
- knconf->knc_rdev = sb.st_rdev;
-
- return (0);
-}
-
-struct hostent *
-gethost_byname(const char *name)
-{
- int errnum;
-#ifdef AF_INET6
- return (getipnodebyname(name, AF_INET6, AI_DEFAULT, &errnum));
-#else /* !AF_INET6 */
- return (gethostbyname(name));
-#endif /* AF_INET6 */
-}
-
-int
-gethost_netaddrs(char *fromhost, char *tohost,
- char *fromnetaddr, char *tonetaddr)
-{
- struct hostent *host;
- int j;
- int errnum;
-
-#ifdef AF_INET6
- host = getipnodebyname(fromhost, AF_INET6, AI_DEFAULT, &errnum);
- if (host == NULL) {
-#ifdef DEBUG
- (void) fprintf(stderr, dgettext("sndr",
- "Could not find host %s"), fromhost);
-#endif
- return (-1);
- }
- for (j = 0; j < host->h_length; j++)
- fromnetaddr[j] = host->h_addr[j];
- freehostent(host);
-#else /* !AF_INET6 */
- host = gethostbyname(fromhost);
- if (host == NULL) {
-#ifdef DEBUG
- (void) fprintf(stderr, dgettext("sndr",
- "Could not find host %s"), fromhost);
-#endif
- return (-1);
- }
-
- if (host->h_length < 4) {
-#ifdef DEBUG
- fprintf(stderr, "host->h_length(%d) < 4!\n", host->h_length);
-#endif
- return (-1);
- }
-
- for (j = 0; j < host->h_length; j++)
- fromnetaddr[j] = host->h_addr[j];
-#endif /* AF_INET6 */
-
-#ifdef AF_INET6
- host = getipnodebyname(tohost, AF_INET6, AI_DEFAULT, &errnum);
- if (host == NULL) {
-#ifdef DEBUG
- (void) fprintf(stderr, dgettext("sndr",
- "Could not find host %s"), tohost);
-#endif
- return (-1);
- }
- for (j = 0; j < host->h_length; j++)
- tonetaddr[j] = host->h_addr[j];
- freehostent(host);
-#else /* !AF_INET6 */
- host = gethostbyname(tohost);
- if (host == NULL) {
-#ifdef DEBUG
- (void) fprintf(stderr, dgettext("sndr",
- "Could not find host %s"), tohost);
-#endif
- return (-1);
- }
-
- if (host->h_length < 4) {
-#ifdef DEBUG
- fprintf(stderr, "host->h_length(%d) < 4!\n", host->h_length);
-#endif
- return (-1);
- }
-
- for (j = 0; j < host->h_length; j++)
- tonetaddr[j] = host->h_addr[j];
-#endif /* AF_INET6 */
- return (0);
-}
-
-/*
- * Get the network address on "hostname" for program "prog"
- * with version "vers" by using the nconf configuration data
- * passed in.
- *
- * If the address of a netconfig pointer is null then
- * information is not sufficient and no netbuf will be returned.
- *
- * Finally, ping the null procedure of that service.
- *
- */
-static struct netbuf *
-get_the_addr(char *hostname, ulong_t prog, ulong_t vers,
- struct netconfig *nconf, ushort_t port, struct t_info *tinfo,
- int portmap)
-{
- struct netbuf *nb = NULL;
- struct t_bind *tbind = NULL;
- CLIENT *cl = NULL;
- struct timeval tv;
- int fd = -1;
- AUTH *ah = NULL;
-
- if (nconf == NULL)
- return (NULL);
-
- if ((fd = t_open(nconf->nc_device, O_RDWR, tinfo)) == -1)
- goto done;
-
- /* LINTED pointer alignment */
- if ((tbind = (struct t_bind *)t_alloc(fd, T_BIND, T_ADDR)) == NULL)
- goto done;
-
- if (portmap) { /* contact rpcbind */
- if (rpcb_getaddr(prog, vers, nconf, &tbind->addr,
- hostname) == FALSE) {
- goto done;
- }
-
- if (port) {
- if (strcmp(nconf->nc_protofmly, NC_INET) == 0)
- /* LINTED pointer alignment */
- ((struct sockaddr_in *)tbind->addr.buf)->sin_port
- = port;
-#ifdef NC_INET6
- else if (strcmp(nconf->nc_protofmly, NC_INET6) == 0)
- /* LINTED pointer alignment */
- ((struct sockaddr_in6 *)tbind->addr.buf)->sin6_port
- = port;
-#endif
- }
-
- /* Simon -- we never use the client we create?! */
- cl = clnt_tli_create(fd, nconf, &tbind->addr, prog, vers, 0, 0);
- if (cl == NULL)
- goto done;
-
- ah = authsys_create_default();
- if (ah != NULL)
- cl->cl_auth = ah;
-
- tv.tv_sec = 5;
- tv.tv_usec = 0;
-
- (void) clnt_control(cl, CLSET_TIMEOUT, (char *)&tv);
- } else { /* create our own address and skip rpcbind */
- struct netbuf *nb;
- struct hostent *hp;
- int j;
- int errnum;
- unsigned short family;
- nb = &(tbind->addr);
-
-#ifdef AF_INET6
- if (strcmp(nconf->nc_protofmly, NC_INET6) == 0) {
- hp = getipnodebyname(hostname, AF_INET6, 0, &errnum);
- family = AF_INET6;
- nb->len = nb->maxlen = sizeof (struct sockaddr_in6);
- } else {
- hp = getipnodebyname(hostname, AF_INET, 0, &errnum);
- family = AF_INET;
- nb->len = nb->maxlen = sizeof (struct sockaddr_in);
- }
- if (hp == NULL) {
-#ifdef DEBUG_ADDR
- (void) fprintf(stderr, dgettext("sndr",
- "Could not find host %s\n"), hostname);
-#endif
- goto done;
- }
- nb->buf = (char *)calloc(1, nb->maxlen);
- if (nb->buf == NULL) {
- (void) printf(dgettext("sndr", "no memory\n"));
- goto done;
- }
-
- if (family == AF_INET) {
- for (j = 0; j < hp->h_length; j++)
- nb->buf[j+4] = hp->h_addr[j];
- /* LINTED pointer alignment */
- ((struct sockaddr_in *)(nb->buf))->sin_port = port;
- /* LINTED pointer alignment */
- ((struct sockaddr_in *)(nb->buf))->sin_family = AF_INET;
- } else {
- for (j = 0; j < hp->h_length; j++)
- nb->buf[j+8] = hp->h_addr[j];
- /* LINTED pointer alignment */
- ((struct sockaddr_in6 *)(nb->buf))->sin6_port = port;
- /* LINTED pointer alignment */
- ((struct sockaddr_in6 *)(nb->buf))->sin6_family =
- AF_INET6;
- }
- freehostent(hp);
-#else
- hp = gethostbyname(hostname);
- if (hp == NULL) {
-#ifdef DEBUG
- (void) fprintf(stderr, dgettext("sndr",
- "Could not find host %s"), hostname);
-#endif
- goto done;
- }
-
- nb->len = nb->maxlen = sizeof (struct sockaddr_in);
- nb->buf = (char *)calloc(1, nb->maxlen);
- if (nb->buf == NULL) {
- (void) printf(dgettext("sndr", "no memory\n"));
- free(nb);
- nb = NULL;
- goto done;
- }
-
- for (j = 0; j < hp->h_length; j++)
- nb->buf[j+4] = hp->h_addr[j];
-
- if (hp->h_addrtype == AF_INET) {
- ((struct sockaddr_in *)(nb->buf))->sin_port = port;
- ((struct sockaddr_in *)(nb->buf))->sin_family = AF_INET;
- }
-#endif
- }
-
- /*
- * Make a copy of the netbuf to return
- */
- nb = (struct netbuf *)calloc(1, sizeof (*nb));
- if (nb == NULL) {
- (void) printf(dgettext("sndr", "no memory\n"));
- goto done;
- }
-
- *nb = tbind->addr; /* structure copy */
-
- nb->buf = (char *)calloc(1, nb->maxlen);
- if (nb->buf == NULL) {
- (void) printf(dgettext("sndr", "no memory\n"));
- free(nb);
- nb = NULL;
- goto done;
- }
-
- (void) memcpy(nb->buf, tbind->addr.buf, tbind->addr.len);
-
-done:
- if (cl) {
- if (ah != NULL) {
- AUTH_DESTROY(cl->cl_auth);
- cl->cl_auth = NULL;
- }
-
- clnt_destroy(cl);
- cl = NULL;
- }
-
- if (tbind) {
- t_free((char *)tbind, T_BIND);
- tbind = NULL;
- }
-
- if (fd >= 0)
- (void) t_close(fd);
- return (nb);
-}
-
-/*
- * Get a network address on "hostname" for program "prog"
- * with version "vers". If the port number is specified (non zero)
- * then try for a TCP/UDP transport and set the port number of the
- * resulting IP address.
- *
- * If the address of a netconfig pointer was passed and
- * if it's not null, use it as the netconfig otherwise
- * assign the address of the netconfig that was used to
- * establish contact with the service.
- * If portmap is false, we return a similiar address and we do not
- * contact rpcbind
- *
- */
-struct netbuf *
-get_addr(char *hostname, ulong_t prog, ulong_t vers, struct netconfig **nconfp,
- char *proto, char *srvport, struct t_info *tinfo, int portmap)
-{
- struct netbuf *nb = NULL;
- struct netconfig *nconf = NULL;
- NCONF_HANDLE *nc = NULL;
- int nthtry = FIRST_TRY;
- struct servent *svp;
- ushort_t port;
-
- /*
- * First lets get the requested port
- */
-
- if ((svp = getservbyname(srvport, proto)) == NULL)
- goto done;
- port = svp->s_port;
- /*
- * No nconf passed in.
- *
- * Try to get a nconf from /etc/netconfig filtered by
- * the NETPATH environment variable.
- * First search for COTS, second for CLTS unless proto
- * is specified. When we retry, we reset the
- * netconfig list so that we would search the whole list
- * all over again.
- */
- if ((nc = setnetpath()) == NULL)
- goto done;
-
- /*
- * If proto is specified, then only search for the match,
- * otherwise try COTS first, if failed, try CLTS.
- */
- if (proto) {
- while (nconf = getnetpath(nc)) {
- if (strcmp(nconf->nc_netid, proto) == 0) {
- /*
- * If the port number is specified then TCP/UDP
- * is needed. Otherwise any cots/clts will do.
- */
- if (port == 0)
- break;
-
- if ((strcmp(nconf->nc_protofmly, NC_INET) == 0
-#ifdef NC_INET6
- /* CSTYLED */
- || strcmp(nconf->nc_protofmly, NC_INET6) == 0
-#endif
- /* CSTYLED */
- ) &&
- (strcmp(nconf->nc_proto, NC_TCP) == 0 ||
- strcmp(nconf->nc_proto, NC_UDP) == 0))
- break;
- else {
- nconf = NULL;
- break;
- }
- }
- }
- if (nconf == NULL)
- goto done;
- if ((nb = get_the_addr(hostname, prog, vers, nconf, port,
- tinfo, portmap)) == NULL) {
- goto done;
- }
- } else {
-retry:
- while (nconf = getnetpath(nc)) {
- if (nconf->nc_flag & NC_VISIBLE) {
- if (nthtry == FIRST_TRY) {
- if ((nconf->nc_semantics == NC_TPI_COTS_ORD) ||
- (nconf->nc_semantics == NC_TPI_COTS)) {
- if (port == 0)
- break;
- if ((strcmp(nconf->nc_protofmly,
- NC_INET) == 0
-#ifdef NC_INET6
- /* CSTYLED */
- || strcmp(nconf->nc_protofmly,
- NC_INET6) == 0
-#endif
- /* CSTYLED */
- ) &&
- (strcmp(nconf->nc_proto, NC_TCP) == 0))
- break;
- }
- }
- }
- } /* while */
- if (nconf == NULL) {
- if (++nthtry <= MNT_PREF_LISTLEN) {
- endnetpath(nc);
- if ((nc = setnetpath()) == NULL)
- goto done;
- goto retry;
- } else
- goto done;
- } else {
- if ((nb = get_the_addr(hostname, prog, vers, nconf,
- port, tinfo, portmap)) == NULL) {
- /*
- * Continue the same search path in the
- * netconfig db until no more matched
- * nconf (nconf == NULL).
- */
- goto retry;
- }
-#ifdef AF_INET6
- if ((nb->len == 8) &&
- (strcmp(nconf->nc_protofmly, NC_INET6) == 0)) {
- /*
- * We have a mismatch in the netconfig retry
- */
- free(nb);
- goto retry;
- }
-#endif
- }
- }
-
- /*
- * Got nconf and nb. Now dup the netconfig structure (nconf)
- * and return it thru nconfp.
- */
- *nconfp = getnetconfigent(nconf->nc_netid);
- if (*nconfp == NULL) {
- syslog(LOG_ERR, "no memory\n");
- free(nb);
- nb = NULL;
- }
-done:
- if (nc)
- endnetpath(nc);
- return (nb);
-}
-
-
-/* return values as for nsc_check_release() */
-int
-rdc_check_release(char **reqd)
-{
- /* librdc.so must be built on the runtime OS release */
- return (nsc_check_release(BUILD_REV_STR, NULL, reqd));
-}
diff --git a/usr/src/lib/librdc/common/rdcconfig.c b/usr/src/lib/librdc/common/rdcconfig.c
deleted file mode 100644
index b8fc2ade37..0000000000
--- a/usr/src/lib/librdc/common/rdcconfig.c
+++ /dev/null
@@ -1,1318 +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 <sys/types.h>
-#include <stdio.h>
-#include <errno.h>
-#include <strings.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <netdb.h>
-#include <sys/stream.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <ctype.h>
-#include <thread.h>
-#include <pthread.h>
-
-#include <sys/unistat/spcs_s.h>
-#include <sys/unistat/spcs_s_u.h>
-#include <sys/unistat/spcs_s_impl.h>
-#include <sys/unistat/spcs_errors.h>
-
-#include <sys/nsctl/rdc_io.h>
-#include <sys/nsctl/rdc_ioctl.h>
-#include <sys/nsctl/rdc_prot.h>
-#include <sys/nsctl/librdc.h>
-#include <sys/nsctl/rdcrules.h>
-#include <sys/nsctl/rdcerr.h>
-#include <sys/nsctl/cfg.h>
-
-#include <sys/unistat/spcs_dtrinkets.h>
-#include <sys/unistat/spcs_etrinkets.h>
-
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netinet/tcp.h>
-#include <rpc/rpc_com.h>
-#include <rpc/rpc.h>
-
-struct netbuf svaddr, *svp;
-struct netconfig nconf, *conf;
-struct knetconfig knconf;
-
-/*
- * libdscfg type stuff here
- */
-extern int sv_enable(CFGFILE *cfg, rdcconfig_t *rdc);
-extern int add_to_rdc_cfg(rdcconfig_t *rdcs);
-extern int remove_from_rdc_cfg(rdcconfig_t *rdcs);
-extern int replace_cfgfield(rdcconfig_t *rdcs, char *field, char *value);
-extern int reverse_in_cfg(rdcconfig_t *rdcs);
-
-rdcconfig_t *
-rdc_dup_config(rdcconfig_t *orig)
-{
- rdcconfig_t *rc;
-
- rc = (rdcconfig_t *)calloc(1, sizeof (*rc));
- if (!rc) {
- rdc_set_error(NULL, RDC_OS, RDC_FATAL, NULL);
- return (NULL);
- }
-
- *rc = *orig;
- rc->next = NULL; /* don't want to hook into wrong chaing */
- return (rc);
-}
-
-/*
- * takes in a chain of rdcconfig_t's and a chain
- * of rdc_rc_t's, checks for success in the rdc_rc_t,
- * then adds the corresponding rdcconfig_t to the return
- * chain.
- */
-rdcconfig_t *
-chain_successful(rdcconfig_t *rdcs, rdc_rc_t *rcs)
-{
- rdc_rc_t *rcp;
- rdcconfig_t *rdcp;
- rdcconfig_t *ret = NULL;
- rdcconfig_t *retp = NULL;
-
- rcp = rcs;
- rdcp = rdcs;
-
- while (rcp) {
- if (rcp->rc == 0) {
- if ((ret == NULL) && (rdcp->persist)) {
- retp = ret = rdc_dup_config(rdcp);
-
- } else if ((ret) && (rdcp->persist)) {
- retp->next = rdc_dup_config(rdcp);
- retp = retp->next;
- }
- }
- rcp = rcp->next;
- rdcp = rdcp->next;
- }
- return (ret);
-
-}
-
-rdc_set_t
-config2set(rdcconfig_t *rdc)
-{
- rdc_set_t urdc;
-
- bzero(&urdc, sizeof (rdc_set_t));
- strncpy(urdc.primary.intf, rdc->phost, MAX_RDC_HOST_SIZE);
- strncpy(urdc.primary.file, rdc->pfile, NSC_MAXPATH);
- strncpy(urdc.primary.bitmap, rdc->pbmp, NSC_MAXPATH);
- strncpy(urdc.secondary.intf, rdc->shost, MAX_RDC_HOST_SIZE);
- strncpy(urdc.secondary.file, rdc->sfile, NSC_MAXPATH);
- strncpy(urdc.secondary.bitmap, rdc->sbmp, NSC_MAXPATH);
- strncpy(urdc.group_name, rdc->group, NSC_MAXPATH);
-
- return (urdc);
-}
-
-rdc_rc_t *
-new_rc()
-{
- rdc_rc_t *rc;
-
- rc = (rdc_rc_t *)calloc(1, sizeof (*rc));
- if (rc == NULL) {
- rdc_set_error(NULL, RDC_OS, RDC_FATAL, NULL);
- return (NULL);
- }
- return (rc);
-}
-
-rdc_rc_t
-rdc_config(rdc_config_t *rdccfg)
-{
- rdc_rc_t rc;
- rdc_set_t *set;
- spcs_s_info_t ustatus;
-
- bzero(&rc, sizeof (rc));
- ustatus = spcs_s_ucreate();
-
- if (self_check(rdccfg->rdc_set->primary.intf)) {
- rdccfg->options |= RDC_OPT_PRIMARY;
- /* this needs changin if we do campus */
- rdccfg->rdc_set->direct_file[0] = 0;
- } else {
- rdccfg->options |= RDC_OPT_SECONDARY;
- }
-
- /* set up return stuff.. */
- set = &rdccfg->rdc_set[0];
- strncpy(rc.set.phost, set->primary.intf, MAX_RDC_HOST_SIZE);
- strncpy(rc.set.pfile, set->primary.file, NSC_MAXPATH);
- strncpy(rc.set.shost, set->secondary.intf, MAX_RDC_HOST_SIZE);
- strncpy(rc.set.sfile, set->secondary.file, NSC_MAXPATH);
-
- rc.rc = RDC_IOCTL(RDC_CONFIG, rdccfg, NULL, 0, 0, 0, ustatus);
-
- if (rc.rc < 0) {
- rdc_set_error(&ustatus, RDC_SPCS, 0, 0);
- strncpy(rc.msg, rdc_error(NULL), RDC_ERR_SIZE);
- }
-
- return (rc);
-}
-
-void *
-rdc_mtconfig(void *rdc)
-{
- rdc_rc_t *rc[1];
- rdc_set_t *set;
- spcs_s_info_t ustatus;
- rdc_config_t *rdccfg = (rdc_config_t *)rdc;
-
- ustatus = spcs_s_ucreate();
-
- if (self_check(rdccfg->rdc_set->primary.intf)) {
- rdccfg->options |= RDC_OPT_PRIMARY;
- /* this needs changin if we do campus */
- rdccfg->rdc_set->direct_file[0] = 0;
- } else {
- rdccfg->options |= RDC_OPT_SECONDARY;
- }
-
- set = &rdccfg->rdc_set[0];
- *rc = new_rc();
-
- strncpy(rc[0]->set.phost, set->primary.intf, MAX_RDC_HOST_SIZE);
- strncpy(rc[0]->set.pfile, set->primary.file, NSC_MAXPATH);
- strncpy(rc[0]->set.pbmp, set->primary.bitmap, NSC_MAXPATH);
- strncpy(rc[0]->set.shost, set->secondary.intf, MAX_RDC_HOST_SIZE);
- strncpy(rc[0]->set.sfile, set->secondary.file, NSC_MAXPATH);
- strncpy(rc[0]->set.sbmp, set->secondary.bitmap, NSC_MAXPATH);
-
- rc[0]->rc = RDC_IOCTL(RDC_CONFIG, rdccfg, NULL, 0, 0, 0, ustatus);
-
- if (rc[0]->rc < 0) {
- rdc_set_error(&ustatus, RDC_SPCS, 0, 0);
- strncpy(rc[0]->msg, rdc_error(NULL), RDC_ERR_SIZE);
- }
-
- sleep(1); /* give thr_join a chance to be called */
- free(rdccfg);
- thr_exit((void **) *rc);
- return (NULL);
-}
-int
-populate_addrs(rdc_set_t *urdc, int isenable)
-{
- struct t_info tinfo;
- struct hostent *hp;
- char toname[MAX_RDC_HOST_SIZE];
- char fromname[MAX_RDC_HOST_SIZE];
-
- strncpy(fromname, urdc->primary.intf, MAX_RDC_HOST_SIZE);
- strncpy(toname, urdc->secondary.intf, MAX_RDC_HOST_SIZE);
-
- if ((fromname[0] == '\0') || (fromname[0] == '\0')) {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_FATAL,
- "NULL hostname recieved");
- return (-1);
- }
-
- hp = gethost_byname(fromname);
- strncpy(fromname, hp->h_name, MAX_RDC_HOST_SIZE);
- hp = gethost_byname(toname);
- strncpy(toname, hp->h_name, MAX_RDC_HOST_SIZE);
-
- if (self_check(fromname) && self_check(toname)) {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_FATAL, "");
- }
-
- if (isenable) {
- svp = get_addr(toname, RDC_PROGRAM, RDC_VERS_MIN,
- &conf, NULL, "rdc", &tinfo, 0);
- if (svp == NULL)
- return (-1);
- svaddr = *svp;
- } else {
- bzero(&svaddr, sizeof (svaddr));
- }
-
- urdc->secondary.addr.len = svaddr.len;
- urdc->secondary.addr.maxlen = svaddr.maxlen;
- urdc->secondary.addr.buf = (void*)svaddr.buf;
-
- if (isenable) {
- svp = get_addr(fromname, RDC_PROGRAM, RDC_VERS_MIN,
- &conf, NULL, "rdc", &tinfo, 0);
- if (svp == NULL)
- return (-1);
- svaddr = *svp;
- } else {
- bzero(&svaddr, sizeof (svaddr));
- }
-
- urdc->primary.addr.len = svaddr.len;
- urdc->primary.addr.maxlen = svaddr.maxlen;
- urdc->primary.addr.buf = (void*)svaddr.buf;
-
- if (isenable) {
- convert_nconf_to_knconf(conf, &knconf);
- urdc->netconfig = &knconf;
- } else {
- urdc->netconfig = NULL;
- }
- urdc->syshostid = (int32_t)gethostid();
-
- return (1);
-
-}
-void
-rdc_free_config(rdcconfig_t *rdc, int all)
-{
- rdcconfig_t *rdcp;
- rdcconfig_t *rdcq;
-
- rdcp = rdc;
- if (all == RDC_FREEONE) {
- free(rdcp);
- } else while (rdcp) {
- rdcq = rdcp->next;
- free(rdcp);
- rdcp = rdcq;
- }
- rdc = NULL;
-}
-
-void
-rdc_free_rclist(rdc_rc_t *rc)
-{
- rdc_rc_t *rcp, *rcq;
-
- rcp = rc;
- while (rcp) {
- rcq = rcp->next;
- free(rcp);
- rcp = rcq;
- }
-
-}
-/*ARGSUSED*/
-rdcconfig_t *
-rdc_alloc_config(const char *phost, const char *pfile,
- const char *pbmp, const char *shost, const char *sfile, const char *sbmp,
- const char *mode, const char *group, const char *ctag, const char *options,
- int persist)
-{
- rdcconfig_t *rc;
-
- rc = (rdcconfig_t *)calloc(1, sizeof (*rc));
- if (!rc) {
- rdc_set_error(NULL, RDC_OS, RDC_FATAL, NULL);
- return (NULL);
- }
- if (phost)
- strncpy(rc->phost, phost, NSC_MAXPATH);
- if (pfile)
- strncpy(rc->pfile, pfile, NSC_MAXPATH);
- if (pbmp)
- strncpy(rc->pbmp, pbmp, NSC_MAXPATH);
- if (shost)
- strncpy(rc->shost, shost, NSC_MAXPATH);
- if (sfile)
- strncpy(rc->sfile, sfile, NSC_MAXPATH);
- if (sbmp)
- strncpy(rc->sbmp, sbmp, NSC_MAXPATH);
-
- strncpy(rc->direct, "ip", 2);
-
- if (mode)
- strncpy(rc->mode, mode, NSC_MAXPATH);
- if (ctag)
- strncpy(rc->ctag, ctag, NSC_MAXPATH);
- if (options)
- strncpy(rc->options, options, NSC_MAXPATH);
-
- rc->persist = persist;
- rc->next = NULL;
-
- return (rc);
-
-}
-
-void
-populate_rc(rdc_rc_t *rcp, rdcconfig_t *rdcp)
-{
- rcp->rc = -1;
- strncpy(rcp->msg, rdc_error(NULL), RDC_ERR_SIZE);
- strncpy(rcp->set.phost, rdcp->phost, NSC_MAXPATH);
- strncpy(rcp->set.pfile, rdcp->pfile, NSC_MAXPATH);
- strncpy(rcp->set.shost, rdcp->shost, NSC_MAXPATH);
- strncpy(rcp->set.sfile, rdcp->sfile, NSC_MAXPATH);
-}
-
-/*
- * rdc_enable
- * return values
- * NULL on error
- * pointer to rdc_rc_t list of return values
- */
-rdc_rc_t *
-rdc_enable(rdcconfig_t *rdc)
-{
- rdc_config_t rdccfg;
- rdcconfig_t *rdcp = NULL;
- rdcconfig_t *cfg_rdcs = NULL;
- rdc_rc_t *rc = NULL;
- rdc_rc_t *rcp = NULL;
-
- rdcp = rdc;
- rc = new_rc();
- if (!rc) { /* error already set */
- return (NULL);
- }
- rcp = rc;
- while (rdcp) {
- if (!rdcp->mode) {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- RDC_EINVAL);
- return (NULL);
- }
- bzero(&rdccfg, sizeof (rdc_config_t));
- rdccfg.rdc_set[0] = config2set(rdcp);
- rdccfg.command = RDC_CMD_ENABLE;
- rdccfg.options = RDC_OPT_SETBMP;
- if (strncmp(rdcp->mode, "sync", NSC_MAXPATH) == 0) {
- rdccfg.options |= RDC_OPT_SYNC;
- } else if (strncmp(rdc->mode, "async", NSC_MAXPATH) == 0) {
- rdccfg.options |= RDC_OPT_ASYNC;
- } else {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- RDC_EINVAL);
- return (NULL);
- }
-
- populate_addrs(&rdccfg.rdc_set[0], 1);
-
- if (can_enable(rdcp)) {
- /* do the operation */
- *rcp = rdc_config(&rdccfg);
-
- } else { /* set up what rdc_config would've set up */
-
- populate_rc(rcp, rdcp);
-
- }
- if ((rcp->rc == 0) && (!rdcp->persist)) {
- /*
- * if we are not persisting, do this now,
- * otherwise we will do it when
- * we have a lock on the cfg in add_to_rdc_cfg
- */
- sv_enable(NULL, rdcp);
- }
-
- rdcp = rdcp->next;
- if (!rdcp)
- break;
-
- rcp->next = new_rc();
- rcp = rcp->next;
- if (!rcp) {
- /* dont free here, return what you have */
- break;
- }
- }
-
- /*
- * travel the rc chain and rdc chain checking results,
- * building a new chain, and updating dscfg
- */
- rcp = rc;
- rdcp = rdc;
-
- cfg_rdcs = chain_successful(rdcp, rcp);
-
- if (add_to_rdc_cfg(cfg_rdcs) < 0) {
- /* XXX should disable or something here */
- return (rc);
- }
- rdc_free_config(cfg_rdcs, RDC_FREEALL);
- return (rc);
-
-}
-
-rdc_rc_t *
-rdc_enable_clrbmp(rdcconfig_t *rdc)
-{
- rdc_config_t rdccfg;
- rdcconfig_t *rdcp = NULL;
- rdcconfig_t *cfg_rdcs = NULL;
- rdc_rc_t *rc = NULL;
- rdc_rc_t *rcp = NULL;
-
- rdcp = rdc;
- rc = (rdc_rc_t *)calloc(1, sizeof (rdc_rc_t));
- if (!rc) {
- rdc_set_error(NULL, RDC_OS, RDC_FATAL, NULL);
- return (NULL);
- }
- rcp = rc;
- while (rdcp) {
- if (!rdcp->mode) {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- RDC_EINVAL);
- return (NULL);
- }
- bzero(&rdccfg, sizeof (rdc_config_t));
- rdccfg.rdc_set[0] = config2set(rdcp);
- rdccfg.command = RDC_CMD_ENABLE;
- rdccfg.options = RDC_OPT_CLRBMP;
- if (strncmp(rdcp->mode, "sync", NSC_MAXPATH) == 0) {
- rdccfg.options |= RDC_OPT_SYNC;
- } else if (strncmp(rdc->mode, "async", NSC_MAXPATH) == 0) {
- rdccfg.options |= RDC_OPT_ASYNC;
- } else {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- RDC_EINVAL);
- return (NULL);
- }
-
- populate_addrs(&rdccfg.rdc_set[0], 1);
-
- if (can_enable(rdcp)) {
- /* do the operation */
- *rcp = rdc_config(&rdccfg);
-
- } else { /* set up what rdc_config would've set up */
-
- populate_rc(rcp, rdcp);
-
- }
- rdcp = rdcp->next;
- if (!rdcp)
- break;
-
- rcp->next = (rdc_rc_t *)calloc(1, sizeof (rdc_rc_t));
- rcp = rcp->next;
- if (!rcp)
- break;
- }
-
- /*
- * travel the rc chain and rdc chain checking results,
- * building a new chain, and updating dscfg
- */
- rcp = rc;
- rdcp = rdc;
-
- cfg_rdcs = chain_successful(rdcp, rcp);
-
- if (add_to_rdc_cfg(cfg_rdcs) < 0) {
- /* XXX should disable or something here */
- return (rc);
- }
- rdc_free_config(cfg_rdcs, RDC_FREEALL);
-
- return (rc);
-
-}
-
-rdc_rc_t *
-rdc_disable(rdcconfig_t *rdc)
-{
- rdc_config_t rdccfg;
- rdcconfig_t *rdcp = NULL;
- rdcconfig_t *cfg_rdcs = NULL;
- rdc_rc_t *rc = NULL;
- rdc_rc_t *rcp = NULL;
-
- rdcp = rdc;
- rc = new_rc();
- if (!rc) {
- return (NULL);
- }
- rcp = rc;
-
- while (rdcp) {
-
- bzero(&rdccfg, sizeof (rdc_config_t));
- rdccfg.rdc_set[0] = config2set(rdcp);
- rdccfg.command = RDC_CMD_DISABLE;
- populate_addrs(&rdccfg.rdc_set[0], 0);
-
- *rcp = rdc_config(&rdccfg);
-
- rdcp = rdcp->next;
- if (!rdcp)
- break;
-
- rcp->next = new_rc();
- rcp = rcp->next;
- if (!rcp)
- return (rc);
-
- }
- rcp = rc;
- rdcp = rdc;
-
- cfg_rdcs = chain_successful(rdcp, rcp);
-
- remove_from_rdc_cfg(cfg_rdcs);
-
- rdc_free_config(cfg_rdcs, RDC_FREEALL);
-
- return (rc);
-}
-
-rdc_rc_t *
-rdc_log(rdcconfig_t *rdc)
-{
- rdc_config_t rdccfg;
- rdcconfig_t *rdcp = NULL;
- rdc_rc_t *rc = NULL;
- rdc_rc_t *rcp = NULL;
-
- rdcp = rdc;
- rc = new_rc();
- if (!rc) {
- return (NULL);
- }
- rcp = rc;
-
- while (rdcp) {
- bzero(&rdccfg, sizeof (rdc_config_t));
- rdccfg.rdc_set[0] = config2set(rdcp);
- rdccfg.command = RDC_CMD_LOG;
- populate_addrs(&rdccfg.rdc_set[0], 0);
-
- *rcp = rdc_config(&rdccfg);
-
- rdcp = rdcp->next;
- if (!rdcp)
- break;
-
- rcp->next = new_rc();
- rcp = rcp->next;
- if (!rcp)
- break;
- }
- return (rc);
-}
-
-rdc_rc_t *
-rdc_usync(rdcconfig_t *rdc)
-{
- rdc_config_t *rdccfg;
- rdcconfig_t *rdcp = NULL;
- rdc_rc_t *rc = NULL;
- rdc_rc_t *rcp = NULL;
- rdc_rc_t *tmprc;
-
- rdcp = rdc;
-
- while (rdcp) {
- /* freed in rdc_mtconfig */
- rdccfg = (rdc_config_t *)calloc(1, sizeof (rdc_config_t));
- rdccfg->rdc_set[0] = config2set(rdcp);
- rdccfg->command = RDC_CMD_COPY;
- rdccfg->options = RDC_OPT_UPDATE|RDC_OPT_FORWARD;
- populate_addrs(&rdccfg->rdc_set[0], 0);
- (void) thr_create(NULL, 0, rdc_mtconfig,
- (void **) rdccfg, THR_BOUND, NULL);
- rdcp = rdcp->next;
- if (!rdcp)
- break;
-
- }
-
- /*
- * collect status here from thr_join-status,
- * and add to rdc_rc_t chain ?
- * this will block, but caller could always thread too
- */
- while (thr_join(NULL, NULL, (void**) &tmprc) == 0) {
- if (rc == NULL) {
- rcp = rc = (rdc_rc_t *)tmprc;
- } else {
- rcp->next = (rdc_rc_t *)tmprc;
- rcp = rcp->next;
- }
- }
-
- return (rc);
-}
-
-rdc_rc_t *
-rdc_fsync(rdcconfig_t *rdc)
-{
- rdc_config_t *rdccfg;
- rdcconfig_t *rdcp = NULL;
- rdc_rc_t *rc = NULL;
- rdc_rc_t *rcp = NULL;
- rdc_rc_t *tmprc = NULL;
-
- rdcp = rdc;
- rc = new_rc();
- if (!rc) {
- return (NULL);
- }
- rcp = rc;
-
- while (rdcp) {
- /* freed in rdc_mtconfig */
- rdccfg = (rdc_config_t *)calloc(1, sizeof (rdc_config_t));
- rdccfg->rdc_set[0] = config2set(rdcp);
- rdccfg->command = RDC_CMD_COPY;
- rdccfg->options = RDC_OPT_FULL|RDC_OPT_FORWARD;
- populate_addrs(&rdccfg->rdc_set[0], 0);
- (void) thr_create(NULL, 0, rdc_mtconfig,
- (void **) rdccfg, THR_BOUND, NULL);
- rdcp = rdcp->next;
- if (!rdcp)
- break;
-
- }
-
- /*
- * collect status here from thr_join-status,
- * and add to rdc_rc_t chain ?
- * this will block, but caller could always thread too
- */
- while (thr_join(NULL, NULL, (void**) &tmprc) == 0) {
- if (rc == NULL) {
- rcp = rc = (rdc_rc_t *)tmprc;
- } else {
- rcp->next = (rdc_rc_t *)tmprc;
- rcp = rcp->next;
- }
- }
-
- return (rc);
-}
-
-rdc_rc_t *
-rdc_rsync(rdcconfig_t *rdc)
-{
- rdc_config_t *rdccfg;
- rdcconfig_t *rdcp = NULL;
- rdc_rc_t *rc = NULL;
- rdc_rc_t *rcp = NULL;
- rdc_rc_t *tmprc = NULL;
-
- rdcp = rdc;
- rc = new_rc();
- if (!rc) {
- return (NULL);
- }
- rcp = rc;
-
- while (rdcp) {
- tmprc = cant_rsync(rdcp);
- if (tmprc != NULL) {
- if (rc == NULL) {
- rcp = rc = tmprc;
- } else {
- rcp->next = tmprc;
- rcp = rcp->next;
- }
- goto next;
- }
-
- /* freed in rdc_mtconfig */
- rdccfg = (rdc_config_t *)calloc(1, sizeof (rdc_config_t));
- rdccfg->rdc_set[0] = config2set(rdcp);
- rdccfg->command = RDC_CMD_COPY;
- rdccfg->options = RDC_OPT_REVERSE|RDC_OPT_FULL;
- populate_addrs(&rdccfg->rdc_set[0], 0);
- (void) thr_create(NULL, 0, rdc_mtconfig,
- (void **) rdccfg, THR_BOUND, NULL);
-next:
- rdcp = rdcp->next;
- if (!rdcp)
- break;
- }
-
- /*
- * collect status here from thr_join-status,
- * and add to rdc_rc_t chain ?
- * this will block, but caller could always thread too
- */
- while (thr_join(NULL, NULL, (void**) &tmprc) == 0) {
- if (rc == NULL) {
- rcp = rc = (rdc_rc_t *)tmprc;
- } else {
- rcp->next = (rdc_rc_t *)tmprc;
- rcp = rcp->next;
- }
- }
-
- return (rc);
-}
-
-rdc_rc_t *
-rdc_ursync(rdcconfig_t *rdc)
-{
- rdc_config_t *rdccfg;
- rdcconfig_t *rdcp = NULL;
- rdc_rc_t *rc = NULL;
- rdc_rc_t *rcp = NULL;
- rdc_rc_t *tmprc = NULL;
-
- rdcp = rdc;
-
- while (rdcp) {
- tmprc = cant_rsync(rdcp);
- if (tmprc != NULL) {
- if (rc == NULL) {
- rcp = rc = tmprc;
- } else {
- rcp->next = tmprc;
- rcp = rcp->next;
- }
- goto next;
- }
-
- /* freed in rdc_mtconfig */
- rdccfg = (rdc_config_t *)calloc(1, sizeof (rdc_config_t));
- rdccfg->rdc_set[0] = config2set(rdcp);
- rdccfg->command = RDC_CMD_COPY;
- rdccfg->options = RDC_OPT_REVERSE | RDC_OPT_UPDATE;
- populate_addrs(&rdccfg->rdc_set[0], 0);
- (void) thr_create(NULL, 0, rdc_mtconfig,
- (void **) rdccfg, THR_BOUND, NULL);
-next:
- rdcp = rdcp->next;
- if (!rdcp)
- break;
-
- }
-
- /*
- * collect status here from thr_join-status,
- * and add to rdc_rc_t chain ?
- * this will block, but caller could always thread too
- */
- while (thr_join(NULL, NULL, (void**) &tmprc) == 0) {
- if (rc == NULL) {
- rcp = rc = (rdc_rc_t *)tmprc;
- } else {
- rcp->next = (rdc_rc_t *)tmprc;
- rcp = rcp->next;
- }
- }
-
- return (rc);
-}
-
-rdc_rc_t *
-rdc_wait(rdcconfig_t *rdc)
-{
- rdc_config_t rdccfg;
- rdcconfig_t *rdcp = NULL;
- rdc_rc_t *rc = NULL;
- rdc_rc_t *rcp = NULL;
-
- rdcp = rdc;
- rc = new_rc();
- if (!rc) {
- return (NULL);
- }
- rcp = rc;
-
- while (rdcp) {
- bzero(&rdccfg, sizeof (rdc_config_t));
- rdccfg.rdc_set[0] = config2set(rdcp);
- rdccfg.command = RDC_CMD_WAIT;
- populate_addrs(&rdccfg.rdc_set[0], 0);
-
- *rcp = rdc_config(&rdccfg);
-
- rdcp = rdcp->next;
- if (!rdcp)
- break;
-
- rcp->next = new_rc();
- rcp = rcp->next;
- if (!rcp)
- break;
- }
- return (rc);
-}
-
-rdc_rc_t *
-rdc_set_autosync(rdcconfig_t *rdc, int autosync)
-{
- rdc_config_t rdccfg;
- rdcconfig_t *rdcp = NULL;
- rdc_rc_t *rc = NULL;
- rdc_rc_t *rcp = NULL;
-
- rdcp = rdc;
- rc = new_rc();
- if (!rc) {
- return (NULL);
- }
- rcp = rc;
-
- while (rdcp) {
- bzero(&rdccfg, sizeof (rdc_config_t));
- rdccfg.rdc_set[0] = config2set(rdcp);
- rdccfg.command = RDC_CMD_TUNABLE;
- rdccfg.rdc_set[0].autosync = autosync;
- rdccfg.rdc_set[0].maxqitems = -1;
- rdccfg.rdc_set[0].maxqfbas = -1;
- populate_addrs(&rdccfg.rdc_set[0], 0);
-
- *rcp = rdc_config(&rdccfg);
-
- rdcp = rdcp->next;
- if (!rdcp)
- break;
-
- rcp->next = new_rc();
- rcp = rcp->next;
- if (!rcp)
- break;
- }
- return (rc);
-}
-
-rdc_rc_t *
-rdc_set_maxqfbas(rdcconfig_t *rdc, int maxqfbas)
-{
- rdc_config_t rdccfg;
- rdcconfig_t *rdcp = NULL;
- rdc_rc_t *rc = NULL;
- rdc_rc_t *rcp = NULL;
-
- rdcp = rdc;
- rc = new_rc();
- if (!rc) {
- return (NULL);
- }
- rcp = rc;
-
- while (rdcp) {
- bzero(&rdccfg, sizeof (rdc_config_t));
- rdccfg.rdc_set[0] = config2set(rdcp);
- rdccfg.command = RDC_CMD_TUNABLE;
- rdccfg.rdc_set[0].autosync = -1;
- rdccfg.rdc_set[0].maxqitems = -1;
- rdccfg.rdc_set[0].maxqfbas = maxqfbas;
- populate_addrs(&rdccfg.rdc_set[0], 0);
-
- *rcp = rdc_config(&rdccfg);
-
- rdcp = rdcp->next;
- if (!rdcp)
- break;
-
- rcp->next = new_rc();
- rcp = rcp->next;
- if (!rcp)
- break;
- }
- return (rc);
-}
-
-rdc_rc_t *
-rdc_set_maxqitems(rdcconfig_t *rdc, int maxqitems)
-{
- rdc_config_t rdccfg;
- rdcconfig_t *rdcp = NULL;
- rdc_rc_t *rc = NULL;
- rdc_rc_t *rcp = NULL;
-
- rdcp = rdc;
- rc = new_rc();
-
- if (!rc) {
- return (NULL);
- }
- rcp = rc;
-
- while (rdcp) {
- bzero(&rdccfg, sizeof (rdc_config_t));
- rdccfg.rdc_set[0] = config2set(rdc);
- rdccfg.command = RDC_CMD_TUNABLE;
- rdccfg.rdc_set[0].autosync = -1;
- rdccfg.rdc_set[0].maxqitems = maxqitems;
- rdccfg.rdc_set[0].maxqfbas = -1;
- populate_addrs(&rdccfg.rdc_set[0], 0);
-
- *rcp = rdc_config(&rdccfg);
-
- rdcp = rdcp->next;
- if (!rdcp)
- break;
-
- rcp->next = new_rc();
- rcp = rcp->next;
- if (!rcp)
- break;
- }
- return (rc);
-}
-
-rdc_set_t
-rdc_status(rdcconfig_t *rdc)
-{
- rdc_config_t rdccfg;
-
- bzero(&rdccfg, sizeof (rdc_config_t));
- rdccfg.rdc_set[0] = config2set(rdc);
- rdccfg.command = RDC_CMD_STATUS;
- populate_addrs(&rdccfg.rdc_set[0], 0);
- rdc_config(&rdccfg);
-
- return (rdccfg.rdc_set[0]);
-}
-
-int
-rdc_get_autosync(rdcconfig_t *rdc)
-{
- rdc_set_t rdcset;
-
- rdcset = rdc_status(rdc);
- return (rdcset.autosync);
-}
-
-int
-rdc_get_maxqfbas(rdcconfig_t *rdc)
-{
- rdc_set_t rdcset;
-
- rdcset = rdc_status(rdc);
- return (rdcset.maxqfbas);
-
-}
-
-int
-rdc_get_maxqitems(rdcconfig_t *rdc)
-{
- rdc_set_t rdcset;
-
- rdcset = rdc_status(rdc);
- return (rdcset.maxqitems);
-
-}
-
-int
-set_mode(rdcconfig_t *rdc)
-{
- if (strcmp(rdc->mode, "async") == 0)
- return (RDC_OPT_ASYNC);
- else
- return (RDC_OPT_SYNC);
-}
-
-/*
- * reconfig bitmaps are single set only ops
- * for obvious reasons
- */
-rdc_rc_t *
-rdc_reconfig_pbmp(rdcconfig_t *rdc, char *pbmp)
-{
- rdc_config_t rdccfg;
- rdc_rc_t *rc;
-
- rc = new_rc();
- if ((!rc) || (!pbmp))
- return (NULL);
-
- bzero(&rdccfg, sizeof (rdc_config_t));
- rdccfg.rdc_set[0] = config2set(rdc);
- strncpy(rdccfg.rdc_set[0].primary.bitmap, pbmp, NSC_MAXPATH);
- rdccfg.command = RDC_CMD_RECONFIG;
- rdccfg.options |= set_mode(rdc);
- populate_addrs(&rdccfg.rdc_set[0], 0);
-
- if (can_reconfig_pbmp(rdc, pbmp))
- *rc = rdc_config(&rdccfg);
- else
- populate_rc(rc, rdc);
-
- if ((rc->rc == 0) && (rdc->persist))
- if (replace_cfgfield(rdc, "pbitmap", pbmp) < 0) {
- rc->rc = -1;
- strncpy(rc->msg, rdc_error(NULL), RDC_ERR_SIZE);
- }
- return (rc);
-}
-
-rdc_rc_t *
-rdc_reconfig_sbmp(rdcconfig_t *rdc, char *sbmp)
-{
- rdc_config_t rdccfg;
- rdc_rc_t *rc;
-
- rc = new_rc();
- if (!rc)
- return (NULL);
-
- bzero(&rdccfg, sizeof (rdc_config_t));
- rdccfg.rdc_set[0] = config2set(rdc);
- strncpy(rdccfg.rdc_set[0].secondary.bitmap, sbmp, NSC_MAXPATH);
- rdccfg.command = RDC_CMD_RECONFIG;
- rdccfg.options |= set_mode(rdc);
- populate_addrs(&rdccfg.rdc_set[0], 0);
-
- if (can_reconfig_sbmp(rdc, sbmp))
- *rc = rdc_config(&rdccfg);
- else
- populate_rc(rc, rdc);
-
- if ((rc->rc == 0) && (rdc->persist))
- replace_cfgfield(rdc, "sbitmap", sbmp);
-
- return (rc);
-}
-
-rdc_rc_t *
-rdc_reconfig_group(rdcconfig_t *rdc, char *group)
-{
- rdc_config_t rdccfg;
- rdcconfig_t *rdcp = NULL;
- rdcconfig_t *cfg_rdcs = NULL;
- rdc_rc_t *rc = NULL;
- rdc_rc_t *rcp = NULL;
-
- rdcp = rdc;
- rc = new_rc();
- if (!rc) {
- return (NULL);
- }
- rcp = rc;
-
- while (rdcp) {
- bzero(&rdccfg, sizeof (rdc_config_t));
- /* just in case */
- strncpy(rdcp->group, group, NSC_MAXPATH);
- rdccfg.rdc_set[0] = config2set(rdcp);
- rdccfg.command = RDC_CMD_RECONFIG;
- rdccfg.options |= set_mode(rdcp);
- populate_addrs(&rdccfg.rdc_set[0], 0);
-
- /* reconfig group rules enforced in kernel */
- *rcp = rdc_config(&rdccfg);
-
- rdcp = rdcp->next;
- if (!rdcp)
- break;
-
- rcp->next = new_rc();
- rcp = rcp->next;
- if (!rcp)
- break;
- }
- rcp = rc;
- rdcp = rdc;
- cfg_rdcs = chain_successful(rdcp, rcp);
- replace_cfgfield(cfg_rdcs, "group", group);
- rdc_free_config(cfg_rdcs, RDC_FREEALL);
-
- return (rc);
-}
-/*ARGSUSED*/
-rdc_rc_t *
-rdc_reconfig_ctag(rdcconfig_t *rdc, char *ctag)
-{
- return (NULL);
-}
-
-rdc_rc_t *
-rdc_set_sync(rdcconfig_t *rdc)
-{
- rdc_config_t rdccfg;
- rdcconfig_t *rdcp = NULL;
- rdcconfig_t *cfg_rdcs = NULL;
- rdc_rc_t *rc = NULL;
- rdc_rc_t *rcp = NULL;
-
- rdcp = rdc;
- rc = new_rc();
- if (!rc) {
- return (NULL);
- }
- rcp = rc;
-
- while (rdcp) {
- bzero(&rdccfg, sizeof (rdc_config_t));
- rdccfg.rdc_set[0] = config2set(rdc);
- rdccfg.command = RDC_CMD_RECONFIG;
- rdccfg.options |= RDC_OPT_SYNC;
- populate_addrs(&rdccfg.rdc_set[0], 0);
-
- *rcp = rdc_config(&rdccfg);
-
- rdcp = rdcp->next;
- if (!rdcp)
- break;
-
- rcp->next = new_rc();
- rcp = rcp->next;
- if (!rcp)
- break;
- }
-
- rcp = rc;
- rdcp = rdc;
- cfg_rdcs = chain_successful(rdcp, rcp);
- replace_cfgfield(cfg_rdcs, "mode", "sync");
- rdc_free_config(cfg_rdcs, RDC_FREEALL);
-
- return (rc);
-}
-
-rdc_rc_t *
-rdc_set_async(rdcconfig_t *rdc)
-{
- rdc_config_t rdccfg;
- rdcconfig_t *rdcp = NULL;
- rdcconfig_t *cfg_rdcs = NULL;
- rdc_rc_t *rc = NULL;
- rdc_rc_t *rcp = NULL;
-
- rdcp = rdc;
- rc = new_rc();
- if (!rc) {
- return (NULL);
- }
- rcp = rc;
-
- while (rdcp) {
- bzero(&rdccfg, sizeof (rdc_config_t));
- rdccfg.rdc_set[0] = config2set(rdcp);
- rdccfg.command = RDC_CMD_RECONFIG;
- rdccfg.options |= RDC_OPT_ASYNC;
- populate_addrs(&rdccfg.rdc_set[0], 0);
-
- *rcp = rdc_config(&rdccfg);
-
- rdcp = rdcp->next;
- if (!rdcp)
- break;
-
- rcp->next = new_rc();
- rcp = rcp->next;
- if (!rcp)
- break;
- }
- rcp = rc;
- rdcp = rdc;
- cfg_rdcs = chain_successful(rdcp, rcp);
- replace_cfgfield(cfg_rdcs, "mode", "async");
- rdc_free_config(cfg_rdcs, RDC_FREEALL);
-
- return (rc);
-}
-
-rdc_rc_t *
-rdc_health(rdcconfig_t *rdc)
-{
- rdc_config_t rdccfg;
- rdcconfig_t *rdcp = NULL;
- rdc_rc_t *rc = NULL;
- rdc_rc_t *rcp = NULL;
-
- rdcp = rdc;
- rc = new_rc();
- if (!rc) {
- return (NULL);
- }
- rcp = rc;
-
- while (rdcp) {
- bzero(&rdccfg, sizeof (rdc_config_t));
- rdccfg.rdc_set[0] = config2set(rdcp);
- rdccfg.command = RDC_CMD_HEALTH;
- populate_addrs(&rdccfg.rdc_set[0], 0);
-
- *rcp = rdc_config(&rdccfg);
-
- rdcp = rdcp->next;
- if (!rdcp)
- break;
-
- rcp->next = new_rc();
- rcp = rcp->next;
-
- if (!rcp)
- break;
-
- }
- return (rc);
-}
-
-rdc_rc_t *
-rdc_reverse_role(rdcconfig_t *rdc)
-{
- rdc_config_t rdccfg;
- rdcconfig_t *rdcp = NULL;
- rdcconfig_t *cfg_rdcs = NULL;
- rdc_rc_t *rc = NULL;
- rdc_rc_t *rcp = NULL;
-
- rdcp = rdc;
- rc = new_rc();
- if (!rc) {
- return (NULL);
- }
- rcp = rc;
-
- while (rdcp) {
- bzero(&rdccfg, sizeof (rdc_config_t));
- rdccfg.rdc_set[0] = config2set(rdcp);
- rdccfg.command = RDC_CMD_RECONFIG;
- rdccfg.options |= RDC_OPT_REVERSE_ROLE;
- rdccfg.options |= set_mode(rdcp);
- populate_addrs(&rdccfg.rdc_set[0], 0);
-
- *rcp = rdc_config(&rdccfg);
-
- rdcp = rdcp->next;
- if (!rdcp)
- break;
-
- rcp->next = new_rc();
- rcp = rcp->next;
- if (!rcp)
- break;
- }
- rcp = rc;
- rdcp = rdc;
- cfg_rdcs = chain_successful(rdcp, rcp);
- reverse_in_cfg(cfg_rdcs);
- rdc_free_config(cfg_rdcs, RDC_FREEALL);
-
- return (rc);
-}
diff --git a/usr/src/lib/librdc/common/rdcerr.c b/usr/src/lib/librdc/common/rdcerr.c
deleted file mode 100644
index 6328371ecd..0000000000
--- a/usr/src/lib/librdc/common/rdcerr.c
+++ /dev/null
@@ -1,98 +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 <sys/types.h>
-#include <stdio.h>
-#include <errno.h>
-#include <libintl.h>
-#include <locale.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-#include <sys/nsctl/rdcerr.h>
-#include <sys/nsctl/cfg.h>
-
-#include <sys/unistat/spcs_dtrinkets.h>
-#include <sys/unistat/spcs_etrinkets.h>
-#include <sys/unistat/spcs_s.h>
-#include <sys/unistat/spcs_s_u.h>
-#include <sys/unistat/spcs_s_impl.h>
-#include <sys/unistat/spcs_errors.h>
-
-
-int rdc_severity;
-char *rdc_error_str;
-char err[RDC_ERR_SIZE];
-
-void
-rdc_set_error(spcs_s_info_t *ustatus, int context, int severity,
- char *errorstr, ...)
-{
- char msg[1024];
- va_list ap;
-
- bzero(err, RDC_ERR_SIZE);
- switch (context) {
- case RDC_INTERNAL:
- rdc_severity = severity;
- if (errorstr) {
- va_start(ap, errorstr);
- vsprintf(err, errorstr, ap);
- va_end(ap);
- }
- rdc_error_str = dgettext("librdc", err ? err : "");
- break;
-
- case RDC_OS:
- rdc_severity = severity ? severity : RDC_FATAL;
- rdc_error_str = strerror(errno);
- break;
-
- case RDC_SPCS:
- rdc_severity = severity ? severity : RDC_FATAL;
- rdc_error_str = spcs_s_string(*ustatus, msg);
- break;
-
- case RDC_DSCFG:
- rdc_error_str = cfg_error(&rdc_severity);
- break;
-
- default:
- break;
- }
-
- spcs_log("librdc", NULL, dgettext("librdc", "%s"),
- rdc_error_str ? rdc_error_str : "");
-
-}
-
-char *
-rdc_error(int *severity)
-{
- if (severity != NULL)
- *severity = rdc_severity;
- return (rdc_error_str ? rdc_error_str : "");
-}
diff --git a/usr/src/lib/librdc/common/rdcerr.h b/usr/src/lib/librdc/common/rdcerr.h
deleted file mode 100644
index f8c8b83423..0000000000
--- a/usr/src/lib/librdc/common/rdcerr.h
+++ /dev/null
@@ -1,74 +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.
- */
-
-#ifndef _RDCERR_H
-#define _RDCERR_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <strings.h>
-#include <stdlib.h>
-
-#include <sys/unistat/spcs_s.h>
-#include <sys/unistat/spcs_s_u.h>
-#include <sys/unistat/spcs_s_impl.h>
-#include <sys/unistat/spcs_errors.h>
-
-/* serious error? */
-#define RDC_FATAL 0x02
-#define RDC_NONFATAL 0x03
-
-/* types of errors */
-#define RDC_INTERNAL 0x01
-#define RDC_OS 0X02
-#define RDC_SPCS 0x04
-#define RDC_DSCFG 0x08
-
-/* errors */
-#define RDC_EINVAL "Invalid argument"
-
-#define RDC_NAME_DU_JOUR "Remote Mirror"
-
-#ifndef RDC_ERR_SIZE
-#define RDC_ERR_SIZE 256
-#endif
-
-
-void
-rdc_set_error(spcs_s_info_t *ustatus, int context, int severity,
-char *errorstr, ...);
-
-char *
-rdc_err(int *severity);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _RDCERR_H */
diff --git a/usr/src/lib/librdc/common/rdcpersist.c b/usr/src/lib/librdc/common/rdcpersist.c
deleted file mode 100644
index 703c8eef11..0000000000
--- a/usr/src/lib/librdc/common/rdcpersist.c
+++ /dev/null
@@ -1,716 +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 <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mkdev.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stropts.h>
-#include <stdio.h>
-#include <errno.h>
-#include <libintl.h>
-#include <locale.h>
-#include <stdlib.h>
-
-#include <sys/nsctl/rdcerr.h>
-#include <sys/nsctl/rdc_ioctl.h>
-#include <sys/nsctl/librdc.h>
-#include <sys/nsctl/cfg.h>
-#include <sys/nsctl/nsc_hash.h>
-#include <sys/nsctl/sv.h>
-
-#include <sys/unistat/spcs_dtrinkets.h>
-#include <sys/unistat/spcs_etrinkets.h>
-#include <sys/unistat/spcs_s.h>
-#include <sys/unistat/spcs_s_u.h>
-#include <sys/unistat/spcs_s_impl.h>
-#include <sys/unistat/spcs_errors.h>
-
-typedef struct volcount_s {
- int count;
-} volcount_t;
-
-hash_node_t **volhash = NULL;
-
-char *
-config2buf(char *buf, rdcconfig_t *rdc)
-{
- snprintf(buf, CFG_MAX_BUF, "%s %s %s %s %s %s %s %s %s %s %s",
- rdc->phost, rdc->pfile, rdc->pbmp, rdc->shost, rdc->sfile,
- rdc->sbmp, rdc->direct, rdc->mode, rdc->group ? rdc->group : "",
- rdc->ctag ? rdc->ctag : "", rdc->options ? rdc->options : "");
- return (buf);
-
-}
-
-/*
- * SV type functions.
- */
-
-static void
-load_rdc_vols(CFGFILE *cfg)
-{
- int set;
- char key[ CFG_MAX_KEY ];
- char buf[ CFG_MAX_BUF ];
- char *vol, *bmp, *host1, *host2;
- volcount_t *volcount;
-
- if (volhash) {
- return;
- }
-
- cfg_rewind(cfg, CFG_SEC_CONF);
- volhash = nsc_create_hash();
- for (set = 1; /*CSTYLED*/; set++) {
- snprintf(key, CFG_MAX_KEY, "sndr.set%d", set);
- if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF)) {
- break;
- }
-
- host1 = strtok(buf, " ");
- vol = strtok(NULL, " ");
- bmp = strtok(NULL, " ");
-
- if (!self_check(host1)) {
- /* next one had better be ours */
- host2 = strtok(NULL, " ");
- vol = strtok(NULL, " ");
- bmp = strtok(NULL, " ");
-
- if (!self_check(host2)) {
- continue;
- }
- }
-
- /* primary vol may be used more than once */
- volcount = (volcount_t *)nsc_lookup(volhash, vol);
- if (volcount) {
- volcount->count++;
- } else {
- volcount = (volcount_t *)malloc(sizeof (volcount_t));
- volcount->count = 1;
- nsc_insert_node(volhash, volcount, vol);
- }
-
- /* bitmap ought to be only used once */
- volcount = (volcount_t *)nsc_lookup(volhash, bmp);
- if (volcount) {
- /* argh */
- volcount->count++;
- } else {
- volcount = (volcount_t *)malloc(sizeof (volcount_t));
- volcount->count = 1;
- nsc_insert_node(volhash, volcount, bmp);
- }
- }
-}
-
-int
-sv_enable_one_nocfg(char *vol)
-{
- struct stat sb;
- sv_conf_t svc;
- int fd;
-
- bzero(&svc, sizeof (svc));
- if (stat(vol, &sb) != 0) {
- rdc_set_error(NULL, RDC_OS, 0, "unable to stat %s", vol);
- return (-1);
- }
- if (!S_ISCHR(sb.st_mode)) {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL, "%s is not"
- " a character device", vol);
- return (-1);
- }
-
- svc.svc_major = major(sb.st_rdev);
- svc.svc_minor = minor(sb.st_rdev);
- strncpy(svc.svc_path, vol, sizeof (svc.svc_path));
-
- fd = open(SV_DEVICE, O_RDONLY);
- if (fd < 0) {
- rdc_set_error(NULL, RDC_OS, 0, 0);
- return (-1);
- }
-
- svc.svc_flag = (NSC_DEVICE | NSC_CACHE);
- svc.svc_error = spcs_s_ucreate();
-
- if (ioctl(fd, SVIOC_ENABLE, &svc) < 0) {
- if (errno != SV_EENABLED) {
- rdc_set_error(&svc.svc_error, RDC_INTERNAL,
- RDC_NONFATAL, 0);
- return (-1);
- }
- }
-
- spcs_log("sv", NULL, gettext("enabled %s"), svc.svc_path);
-
- close(fd);
- return (1);
-}
-
-int
-sv_enable_nocfg(rdcconfig_t *rdc)
-{
- struct stat stbv;
- struct stat stbb;
- sv_conf_t svcv;
- sv_conf_t svcb;
- char vol[NSC_MAXPATH];
- char bmp[NSC_MAXPATH];
- int fd = -1;
-
-
- if (self_check(rdc->phost)) {
- strncpy(vol, rdc->pfile, NSC_MAXPATH);
- strncpy(bmp, rdc->pbmp, NSC_MAXPATH);
- } else {
- strncpy(vol, rdc->sfile, NSC_MAXPATH);
- strncpy(bmp, rdc->sbmp, NSC_MAXPATH);
- }
-
- bzero(&svcv, sizeof (svcv));
- bzero(&svcb, sizeof (svcb));
-
- if ((stat(vol, &stbv) != 0) || (stat(bmp, &stbb) != 0))
- return (-1);
-
- if ((!S_ISCHR(stbv.st_mode)) || (!S_ISCHR(stbb.st_mode)))
- return (-1);
-
- svcv.svc_major = major(stbv.st_rdev);
- svcb.svc_minor = minor(stbb.st_rdev);
-
- strncpy(svcv.svc_path, vol, sizeof (svcv.svc_path));
- strncpy(svcb.svc_path, bmp, sizeof (svcb.svc_path));
-
- fd = open(SV_DEVICE, O_RDONLY);
- if (fd < 0)
- return (-1);
-
- /* SV enable the volume */
- svcv.svc_flag = (NSC_DEVICE | NSC_CACHE);
- svcv.svc_error = spcs_s_ucreate();
-
- if (ioctl(fd, SVIOC_ENABLE, &svcv) < 0) {
- if (errno != SV_EENABLED) {
- spcs_log("sv", &svcv.svc_error,
- gettext("unable to enable %s"),
- svcv.svc_path);
- spcs_s_ufree(&svcv.svc_error);
- return (-1);
- }
- }
-
- /* SV enable the bitmap disable the vol on error */
- svcb.svc_flag = (NSC_DEVICE | NSC_CACHE);
- svcb.svc_error = spcs_s_ucreate();
-
- if (ioctl(fd, SVIOC_ENABLE, &svcb) < 0) {
- if (errno != SV_EENABLED) {
- spcs_log("sv", &svcb.svc_error,
- gettext("unable to enable %s"),
- svcb.svc_path);
- if (ioctl(fd, SVIOC_DISABLE, &svcv) < 0)
- spcs_log("sv", &svcv.svc_error,
- gettext("unable to disable %s"),
- svcv.svc_path);
-
- spcs_s_ufree(&svcv.svc_error);
- spcs_s_ufree(&svcb.svc_error);
- return (-1);
- }
- }
-
-
- spcs_log("sv", NULL, gettext("enabled %s"), svcv.svc_path);
- spcs_log("sv", NULL, gettext("enabled %s"), svcb.svc_path);
- spcs_s_ufree(&svcv.svc_error);
- spcs_s_ufree(&svcb.svc_error);
-
-
- if (fd >= 0)
- (void) close(fd);
-
- return (1);
-}
-
-int
-do_autosv_enable(CFGFILE *cfg, rdcconfig_t *rdc)
-{
- char vol[NSC_MAXPATH];
- char bmp[NSC_MAXPATH];
-
- cfg_load_svols(cfg);
- cfg_load_dsvols(cfg);
- cfg_load_shadows(cfg);
- load_rdc_vols(cfg);
-
- if (self_check(rdc->phost)) {
- strncpy(vol, rdc->pfile, NSC_MAXPATH);
- strncpy(bmp, rdc->pbmp, NSC_MAXPATH);
- } else {
- strncpy(vol, rdc->sfile, NSC_MAXPATH);
- strncpy(bmp, rdc->sbmp, NSC_MAXPATH);
- }
- if (nsc_lookup(volhash, vol) == NULL) {
- if (cfg_vol_enable(cfg, vol, rdc->ctag, "sndr") < 0) {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- "auto sv enable failed for %s", vol);
- return (-1);
- }
- }
- if (nsc_lookup(volhash, bmp) == NULL) {
- if (cfg_vol_enable(cfg, bmp, rdc->ctag, "sndr") < 0) {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- "auto sv enable failed for %s", vol);
- return (-1);
- }
- }
-
- nsc_remove_all(volhash, free);
- volhash = NULL;
-
- cfg_unload_shadows();
- cfg_unload_dsvols();
- cfg_unload_svols();
-
- return (1);
-}
-
-int
-do_autosv_disable(CFGFILE *cfg, rdcconfig_t *rdc)
-{
- char vol[NSC_MAXPATH];
- char bmp[NSC_MAXPATH];
- volcount_t *vc;
-
- cfg_load_svols(cfg);
- cfg_load_dsvols(cfg);
- cfg_load_shadows(cfg);
- load_rdc_vols(cfg);
-
- if (self_check(rdc->phost)) {
- strncpy(vol, rdc->pfile, NSC_MAXPATH);
- strncpy(bmp, rdc->pbmp, NSC_MAXPATH);
- } else {
- strncpy(vol, rdc->sfile, NSC_MAXPATH);
- strncpy(bmp, rdc->sbmp, NSC_MAXPATH);
- }
-
- vc = nsc_lookup(volhash, vol);
- if (vc && (vc->count == 1)) {
- if (cfg_vol_disable(cfg, vol, rdc->ctag, "sndr") < 0)
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- "auto sv disable failed for %s", vol);
- } else if (!vc) {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- "Unable to find %s in config", vol);
- }
- vc = nsc_lookup(volhash, bmp);
- if (vc && (vc->count == 1)) {
- if (cfg_vol_disable(cfg, bmp, rdc->ctag, "sndr") < 0)
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- "auto sv disable failed for %s", bmp);
-
- } else if (!vc) {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- "Unable to find %s in config", bmp);
- }
-
- return (1);
-
-}
-
-/*
- * do sv enables for the appropriate vol
- * and bitmap. If called without persistance
- * it will follow a chain and sv enable all
- * otherwise, it will enable only the one
- * set.
- */
-int
-sv_enable(CFGFILE *cfg, rdcconfig_t *rdcs)
-{
- rdcconfig_t *rdcp = NULL;
-
- rdcp = rdcs;
- if (!rdcp->persist) {
-
- return (sv_enable_nocfg(rdcp));
-
- } else if (cfg == NULL) {
-
- return (-1);
-
- }
-
- do_autosv_enable(cfg, rdcp);
-
- return (1);
-}
-
-int
-sv_disable(CFGFILE *cfg, rdcconfig_t *rdcs)
-{
- rdcconfig_t *rdcp;
-
- rdcp = rdcs;
- if (!rdcp->persist) { /* don't disable */
-
- return (1);
-
- } else if (cfg == NULL) {
-
- return (-1);
-
- }
-
- do_autosv_disable(cfg, rdcp);
-
- return (1);
-
-}
-
-/*
- * disable the appropriate bitmap in rdc
- * and replace it with bitmap
- */
-int
-sv_reconfig(CFGFILE *cfg, rdcconfig_t *rdc, char *oldbmp, char *newbmp)
-{
- rdcconfig_t *rdcp;
- int fail = 0;
-
- rdcp = rdc;
- if (!rdcp->persist) { /* just enable, don't disable */
-
- sv_enable_one_nocfg(newbmp);
-
- } else if (rdcp->persist) { /* do sv disable and enable */
- volcount_t *vc;
-
- cfg_load_svols(cfg);
- cfg_load_dsvols(cfg);
- cfg_load_shadows(cfg);
- load_rdc_vols(cfg);
-
- vc = (volcount_t *)nsc_lookup(volhash, oldbmp);
- if (vc && (vc->count == 1)) {
- if (cfg_vol_disable(cfg, oldbmp, rdc->ctag, "sndr") < 0)
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- "auto sv disable failed for %s", oldbmp);
-
- }
- if (nsc_lookup(volhash, newbmp) == NULL) {
- if (cfg_vol_enable(cfg,
- newbmp, rdc->ctag, "sndr") < 0) {
-
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- "auto sv enable failed for %s", newbmp);
- fail++;
- }
- }
- nsc_remove_all(volhash, free);
- volhash = NULL;
-
- cfg_unload_shadows();
- cfg_unload_dsvols();
- cfg_unload_svols();
- if (fail)
- return (-1);
-
- }
- return (1);
-
-}
-
-/*
- * SNDR functions
- */
-
-/*
- * add_to_rdc_cfg
- * this adds the successfully created rdc sets to libdscfg,
- * also, as auto_sv stuff is part of libdscfg, it does the
- * auto_sv stuff and enables the correct volumes
- */
-int
-add_to_rdc_cfg(rdcconfig_t *rdcs)
-{
- CFGFILE *cfg;
- rdcconfig_t *rdcp;
- char *buf;
-
-
- buf = calloc(CFG_MAX_BUF, sizeof (char));
- if (!buf) {
- rdc_set_error(NULL, RDC_OS, RDC_FATAL, NULL);
- return (NULL);
- }
-
- if ((cfg = cfg_open(NULL)) == NULL) {
- rdc_set_error(NULL, RDC_DSCFG, 0, 0);
- return (-1);
- }
- if ((cfg_lock(cfg, CFG_WRLOCK)) < 0) {
- rdc_set_error(NULL, RDC_DSCFG, 0, 0);
- return (-1);
- }
-
- rdcp = rdcs;
- while (rdcp) {
- buf = config2buf(buf, rdcp);
- if ((sv_enable(cfg, rdcp) < 0) ||
- (cfg_put_cstring(cfg, "sndr", buf, CFG_MAX_BUF) < 0)) {
- rdc_set_error(NULL, RDC_DSCFG, 0, 0);
- free(buf);
- return (-1);
- }
- rdcp = rdcp->next;
- }
- if (!cfg_commit(cfg)) {
- rdc_set_error(NULL, RDC_DSCFG, 0, NULL);
- return (-1);
- }
-
- cfg_close(cfg);
-
- return (0);
-}
-
-int
-cfg_lookup(CFGFILE *cfg, char *shost, char *sfile)
-{
- char buf[CFG_MAX_BUF];
- char key[CFG_MAX_KEY];
- int setnum;
- int numsets = 0;
-
- numsets = cfg_get_num_entries(cfg, "sndr");
- for (setnum = 1; setnum <= numsets; setnum++) {
- bzero(key, CFG_MAX_KEY);
- snprintf(key, CFG_MAX_KEY, "sndr.set%d.shost", setnum);
- if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0) {
- rdc_set_error(NULL, RDC_DSCFG, 0, 0);
- return (-1);
- }
- if (strncmp(buf, shost, strlen(shost)))
- continue;
-
- bzero(key, CFG_MAX_KEY);
- snprintf(key, CFG_MAX_KEY, "sndr.set%d.secondary", setnum);
- if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0) {
- rdc_set_error(NULL, RDC_DSCFG, 0, 0);
- return (-1);
- }
- if (strncmp(buf, sfile, strlen(sfile)))
- continue;
- break;
- }
- return (setnum);
-}
-
-void
-remove_from_rdc_cfg(rdcconfig_t *rdcs)
-{
- CFGFILE *cfg;
- rdcconfig_t *rdcp;
- char key[CFG_MAX_KEY];
-
- rdcp = rdcs;
- cfg = cfg_open(NULL);
- cfg_lock(cfg, CFG_WRLOCK);
-
- while (rdcp) {
- snprintf(key, CFG_MAX_KEY, "sndr.set%d",
- cfg_lookup(cfg, rdcp->shost, rdcp->sfile));
- if ((sv_disable(cfg, rdcp) < 0) ||
- (cfg_put_cstring(cfg, key, NULL, 0)) < 0) {
- rdc_set_error(NULL, RDC_DSCFG, 0, 0);
- }
-
- rdcp = rdcp->next;
- }
- cfg_commit(cfg);
- cfg_close(cfg);
-}
-/*ARGSUSED*/
-int
-replace_entry(int offset, char *entry)
-{
- return (1);
-}
-
-/*
- * this will set the value at "field" in dscfg to the
- * value contained in entry.
- * for things like bitmap reconfigs, only pass one rdc
- * not a chain
- */
-int
-replace_cfgfield(rdcconfig_t *rdc, char *field, char *entry)
-{
- CFGFILE *cfg;
- rdcconfig_t *rdcp;
- char key[CFG_MAX_KEY];
- char newentry[CFG_MAX_BUF];
- char oldbmp[CFG_MAX_BUF];
- int setnum;
- int ispbmp = 0;
- int issbmp = 0;
-
- if (strncmp(field, "pbitmap", NSC_MAXPATH) == 0)
- ispbmp++;
- if (strncmp(field, "sbitmap", NSC_MAXPATH) == 0)
- issbmp++;
-
- bzero(newentry, sizeof (newentry));
- if (!entry || strlen(entry) == 0)
- *newentry = '-';
- else
- strncpy(newentry, entry, CFG_MAX_BUF);
-
-
- if ((cfg = cfg_open(NULL)) == NULL) {
- rdc_set_error(NULL, RDC_DSCFG, 0, 0);
- return (-1);
- }
- if ((cfg_lock(cfg, CFG_WRLOCK)) < 0) {
- rdc_set_error(NULL, RDC_DSCFG, 0, 0);
- return (-1);
- }
-
- rdcp = rdc;
- while (rdcp) {
- if ((setnum = cfg_lookup(cfg, rdcp->shost, rdcp->sfile)) < 0) {
- rdc_set_error(NULL, RDC_DSCFG, 0, 0);
- return (-1);
- }
- snprintf(key, CFG_MAX_KEY, "sndr.set%d.%s", setnum, field);
- if (!((ispbmp || issbmp) &&
- (cfg_get_cstring(cfg, key, oldbmp, CFG_MAX_BUF)) == 0)) {
- rdc_set_error(NULL, RDC_DSCFG, 0, "unable to get %s",
- key);
- }
- if (((ispbmp && self_check(rdcp->phost)) ||
- (issbmp && self_check(rdcp->shost))) &&
- (sv_reconfig(cfg, rdcp, oldbmp, newentry) < 0)) {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- "unable to sv reconfig %s to %s", oldbmp, newentry);
- return (-1);
- }
-
- if ((cfg_put_cstring(cfg, key, newentry, CFG_MAX_BUF)) < 0) {
- rdc_set_error(NULL, RDC_DSCFG, 0, 0);
- return (-1);
- }
- rdcp = rdcp->next;
- }
- cfg_commit(cfg);
- cfg_close(cfg);
- return (1);
-}
-
-/*
- * reverse_in_cfg
- * used by RDC_OPT_REVERSE_ROLE
- * swaps primary info and secondary info
- */
-int
-reverse_in_cfg(rdcconfig_t *rdc)
-{
- CFGFILE *cfg;
- rdcconfig_t *rdcp = NULL;
- char key[CFG_MAX_KEY];
- int setnum;
-
- if ((cfg = cfg_open(NULL)) == NULL) {
- rdc_set_error(NULL, RDC_DSCFG, 0, 0);
- return (-1);
- }
- if ((cfg_lock(cfg, CFG_WRLOCK)) < 0) {
- rdc_set_error(NULL, RDC_DSCFG, 0, 0);
- return (-1);
- }
-
- rdcp = rdc;
- while (rdcp) {
- if ((setnum = cfg_lookup(cfg, rdcp->shost, rdcp->sfile)) < 0) {
- rdc_set_error(NULL, RDC_DSCFG, 0, 0);
- goto badconfig;
- }
- bzero(key, CFG_MAX_KEY);
- snprintf(key, CFG_MAX_KEY, "sndr.set%d.phost", setnum);
- if ((cfg_put_cstring(cfg, key, rdcp->shost, CFG_MAX_BUF)) < 0) {
- rdc_set_error(NULL, RDC_DSCFG, 0, 0);
- goto badconfig;
- }
- bzero(key, CFG_MAX_KEY);
- snprintf(key, CFG_MAX_KEY, "sndr.set%d.primary", setnum);
- if ((cfg_put_cstring(cfg, key, rdcp->sfile, CFG_MAX_BUF)) < 0) {
- rdc_set_error(NULL, RDC_DSCFG, 0, 0);
- goto badconfig;
- }
- bzero(key, CFG_MAX_KEY);
- snprintf(key, CFG_MAX_KEY, "sndr.set%d.pbitmap", setnum);
- if ((cfg_put_cstring(cfg, key, rdcp->sbmp, CFG_MAX_BUF)) < 0) {
- rdc_set_error(NULL, RDC_DSCFG, 0, 0);
- goto badconfig;
- }
- bzero(key, CFG_MAX_KEY);
- snprintf(key, CFG_MAX_KEY, "sndr.set%d.shost", setnum);
- if ((cfg_put_cstring(cfg, key, rdcp->phost, CFG_MAX_BUF)) < 0) {
- rdc_set_error(NULL, RDC_DSCFG, 0, 0);
- goto badconfig;
- }
- bzero(key, CFG_MAX_KEY);
- snprintf(key, CFG_MAX_KEY, "sndr.set%d.secondary", setnum);
- if ((cfg_put_cstring(cfg, key, rdcp->pfile, CFG_MAX_BUF)) < 0) {
- rdc_set_error(NULL, RDC_DSCFG, 0, 0);
- goto badconfig;
- }
- bzero(key, CFG_MAX_KEY);
- snprintf(key, CFG_MAX_KEY, "sndr.set%d.sbitmap", setnum);
- if ((cfg_put_cstring(cfg, key, rdcp->pbmp, CFG_MAX_BUF)) < 0) {
- rdc_set_error(NULL, RDC_DSCFG, 0, 0);
- goto badconfig;
- }
- rdcp = rdcp->next;
- }
- if (!cfg_commit(cfg)) {
- cfg_close(cfg);
- return (-1);
- }
- cfg_close(cfg);
- return (0);
-
-badconfig:
- cfg_close(cfg);
- return (-1);
-}
diff --git a/usr/src/lib/librdc/common/rdcrules.c b/usr/src/lib/librdc/common/rdcrules.c
deleted file mode 100644
index 76fe39d48d..0000000000
--- a/usr/src/lib/librdc/common/rdcrules.c
+++ /dev/null
@@ -1,545 +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 <sys/types.h>
-#include <sys/utsname.h>
-#include <sys/mdb_modapi.h>
-#include <stdio.h>
-#include <errno.h>
-#include <strings.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <netdb.h>
-#include <libintl.h>
-#include <sys/stream.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <ctype.h>
-#include <thread.h>
-#include <pthread.h>
-
-#include <sys/unistat/spcs_s.h>
-#include <sys/unistat/spcs_s_u.h>
-#include <sys/unistat/spcs_s_impl.h>
-#include <sys/unistat/spcs_errors.h>
-
-#include <sys/nsctl/rdc_io.h>
-#include <sys/nsctl/rdc_ioctl.h>
-#include <sys/nsctl/rdc_prot.h>
-#include <sys/nsctl/librdc.h>
-#include <sys/nsctl/rdcerr.h>
-#include <sys/nsctl/cfg.h>
-
-#include <sys/unistat/spcs_dtrinkets.h>
-#include <sys/unistat/spcs_etrinkets.h>
-
-#include <sys/socket.h>
-#include <sys/mnttab.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netinet/tcp.h>
-#include <rpc/rpc_com.h>
-#include <rpc/rpc.h>
-
-#define RDC_LOCAL_TAG "local"
-
-/*
- * bitmap_in_use
- * return 1 if in use
- * return 0 if not in use
- * return -1 on error
- */
-
-int
-bitmap_in_use(int cmd, char *hostp, char *bmp)
-{
- int i, setnumber;
- CFGFILE *cfg;
- char host[CFG_MAX_BUF];
- char shost[CFG_MAX_BUF];
- char pri[CFG_MAX_BUF]; /* rdc primary vol */
- char sec[CFG_MAX_BUF]; /* rdc secondary vol */
- char sbm[CFG_MAX_BUF]; /* rdc secondary bitmap */
- char bit[CFG_MAX_BUF]; /* a bitmap */
- char mas[CFG_MAX_BUF]; /* II master */
- char sha[CFG_MAX_BUF]; /* II shadow */
- char mod[CFG_MAX_BUF]; /* II mode */
- char ovr[CFG_MAX_BUF]; /* II overflow */
- char buf[CFG_MAX_BUF];
- char key[CFG_MAX_KEY];
- int rc;
- int ret = 0;
-
-
- if ((cfg = cfg_open(NULL)) == NULL) {
- rdc_set_error(NULL, RDC_DSCFG, 0, NULL);
- return (-1);
- }
- if (!cfg_lock(cfg, CFG_RDLOCK)) {
- rdc_set_error(NULL, RDC_DSCFG, 0, NULL);
- cfg_close(cfg);
- return (-1);
- }
-
- /*
- * look into II config to see if this is being used elsewhere
- */
- /*CSTYLED*/
- for (i = 0; ; i++) {
- setnumber = i + 1;
- snprintf(key, sizeof (key), "ii.set%d", setnumber);
- if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
- break;
-
- rc = sscanf(buf, "%s %s %s %s %s", mas, sha, bit, mod, ovr);
- if (rc != 5) {
- rdc_set_error(NULL, RDC_OS, 0, NULL);
- ret = -1;
- goto done;
- }
-
- /*
- * got master shadow bitmap, now compare
- */
- if ((strcmp(bmp, mas) == 0) ||
- (strcmp(bmp, sha) == 0) ||
- (strcmp(bmp, bit) == 0) ||
- (strcmp(bmp, ovr) == 0)) {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- "bitmap %s is in use by"
- "Point-in-Time Copy", bmp);
- ret = 1;
- goto done;
- }
- }
- /*
- * and last but not least, make sure sndr is not using vol for anything
- */
- /*CSTYLED*/
- for (i = 0; ; i++) {
- setnumber = i + 1;
- snprintf(key, sizeof (key), "sndr.set%d", setnumber);
- if (cfg_get_cstring(cfg, key, buf, CFG_MAX_BUF) < 0)
- break;
- /*
- * I think this is quicker than
- * having to double dip into the config
- */
- (void) sscanf(buf, "%s %s %s %s %s %s", host, pri, bit,
- shost, sec, sbm);
- if (cmd == RDC_CMD_ENABLE) {
- if (self_check(host)) {
- if ((strcmp(bmp, pri) == 0) ||
- (strcmp(bmp, bit) == 0)) {
- rdc_set_error(NULL, RDC_INTERNAL,
- RDC_NONFATAL, dgettext("librdc",
- "bitmap %s is in use by %s"),
- bmp, RDC_NAME_DU_JOUR);
-
-
- ret = 1;
- goto done;
- }
- } else {
- if ((strcmp(bmp, sec) == 0) ||
- (strcmp(bmp, sbm) == 0)) {
- rdc_set_error(NULL, RDC_INTERNAL,
- RDC_NONFATAL, dgettext("librdc",
- "bitmap %s is in use by %s"),
- bmp, RDC_NAME_DU_JOUR);
- ret = 1;
- goto done;
- }
- }
- } else if (cmd == RDC_CMD_RECONFIG) {
-
- /*
- * read this logic 1000 times and consider
- * multi homed, one to many, many to one (marketing)
- * etc, etc, before changing
- */
- if (self_check(hostp)) {
- if (self_check(host)) {
- if ((strcmp(bmp, pri) == 0) ||
- (strcmp(bmp, bit) == 0)) {
- rdc_set_error(NULL,
- RDC_INTERNAL, RDC_NONFATAL,
- dgettext("librdc", "bitmap"
- " %s is in use by %s"),
- bmp, RDC_NAME_DU_JOUR);
- ret = 1;
- goto done;
- }
- } else {
- if ((strcmp(hostp, shost) == 0) &&
- (strcmp(bmp, sec) == 0) ||
- (strcmp(bmp, sbm) == 0)) {
- rdc_set_error(NULL,
- RDC_INTERNAL, RDC_NONFATAL,
- dgettext("librdc", "bitmap"
- " %s is in use by %s"),
- bmp, RDC_NAME_DU_JOUR);
- ret = 1;
- goto done;
- }
- }
- } else { /* self_check(hostp) failed */
- if (self_check(host)) {
- if ((strcmp(shost, hostp) == 0) &&
- (strcmp(bmp, sec) == 0) ||
- (strcmp(bmp, sbm) == 0)) {
- rdc_set_error(NULL,
- RDC_INTERNAL, RDC_NONFATAL,
- dgettext("librdc", "bitmap"
- " %s is in use by %s"),
- bmp, RDC_NAME_DU_JOUR);
- ret = 1;
- goto done;
- }
- } else {
- if ((strcmp(host, hostp) == 0) &&
- (strcmp(bmp, pri) == 0) ||
- (strcmp(bmp, bit) == 0)) {
- rdc_set_error(NULL,
- RDC_INTERNAL, RDC_NONFATAL,
- dgettext("librdc", "bitmap"
- " %s is in use by %s"),
- bmp, RDC_NAME_DU_JOUR);
- ret = 1;
- goto done;
- }
- }
- }
-
- }
-
- }
-done:
- cfg_close(cfg);
- return (ret);
-
-}
-
-int
-check_dgislocal(char *dgname)
-{
- char *othernode;
- int rc;
-
- /*
- * check where this disk service is mastered
- */
-
- rc = cfg_dgname_islocal(dgname, &othernode);
- if (rc < 0) {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- gettext("unable to find "
- "disk service, %s: %s"), dgname, strerror(errno));
- return (-1);
- }
-
- if (rc == 0) {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- gettext("disk service, %s, is "
- "active on node \"%s\"\nPlease re-issue "
- "the command on that node"), dgname, othernode);
- return (-1);
- }
- return (DCMD_OK);
-}
-
-int
-ctag_check(rdcconfig_t *rdc)
-{
- char *file_dgname;
- char *bmp_dgname;
- char *fromhost, *tohost;
- char *fromfile, *tofile;
- char *frombitmap, *tobitmap;
- char *localfile;
- char *ctag;
- char file_buf[MAX_RDC_HOST_SIZE];
- char bmp_buf[MAX_RDC_HOST_SIZE];
- int is_primary;
- int islocal = 0;
- struct hostent *hp;
- char fromname[MAXHOSTNAMELEN], toname[MAXHOSTNAMELEN];
-
- fromhost = rdc->phost;
- fromfile = rdc->pfile;
- frombitmap = rdc->pbmp;
- tohost = rdc->shost;
- tofile = rdc->sfile;
- tobitmap = rdc->sbmp;
- ctag = rdc->ctag;
-
- /*
- * Check for the special (local) cluster tag
- */
- if (!cfg_iscluster())
- return (0);
-
- if (ctag != NULL && strcmp(rdc->ctag, RDC_LOCAL_TAG) == 0) {
- strcpy(rdc->ctag, "-");
- islocal = TRUE;
- } else {
- islocal = FALSE;
- }
-
- hp = gethost_byname(fromhost);
- strncpy(fromname, hp->h_name, MAXHOSTNAMELEN);
- hp = gethost_byname(tohost);
- strncpy(toname, hp->h_name, MAXHOSTNAMELEN);
- if (!self_check(fromname) && !self_check(toname)) {
- /*
- * If we could get a list of logical hosts on this cluster
- * then we could print something intelligent about where
- * the volume is mastered. For now, just print some babble
- * about the fact that we have no idea.
- */
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- gettext("either %s:%s or %s:%s is not local"),
- fromhost, fromfile, tohost, tofile);
- return (-1);
- }
-
- is_primary = self_check(fromname);
-
- /*
- * If implicit disk group name and no ctag specified by user,
- * we set the ctag to it.
- * If implicit disk group name, it must match any supplied ctag.
- */
- if (is_primary)
- localfile = fromfile;
- else
- localfile = tofile;
- file_dgname = cfg_dgname(localfile, file_buf, sizeof (file_buf));
- if (file_dgname != NULL && file_dgname[0] != '\0')
- if (check_dgislocal(file_dgname) < 0) {
- /* errors already set */
- return (-1);
- }
-
- if (strlen(ctag) == 0 && file_dgname && strlen(file_dgname))
- strncpy(ctag, file_dgname, MAX_RDC_HOST_SIZE);
-
- /*
- * making an exception here for users giving the "local"tag
- * this overrides this error message. (rdc_islocal ! = 1)
- */
- if (strlen(ctag) != 0 && file_dgname && islocal != 1 &&
- strlen(file_dgname) != 0 &&
- strncmp(ctag, file_dgname, MAX_RDC_HOST_SIZE) != 0) {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- gettext("ctag \"%s\" does not "
- "match disk group name \"%s\" of volume %s"), ctag,
- file_dgname, localfile);
- return (-1);
- }
- if ((file_dgname == NULL) || ((strlen(ctag) == 0) &&
- (strlen(file_dgname) == 0))) {
- /*
- * we must have a non-volume managed disk here
- * so ask for a tag and get out
- */
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- gettext("volume \"%s\" is not part"
- " of a disk group,\nplease specify resource ctag\n"),
- localfile);
-
- }
-
- /*
- * Local bitmap must also have same ctag.
- */
- if (is_primary)
- localfile = frombitmap;
- else
- localfile = tobitmap;
- bmp_dgname = cfg_dgname(localfile, bmp_buf, sizeof (bmp_buf));
- if (bmp_dgname != NULL && bmp_dgname[0] != '\0')
- if (check_dgislocal(bmp_dgname) < 0) {
- /* error already set */
- return (-1);
- }
-
- if (file_dgname && strlen(file_dgname) != 0) {
- /* File is in a real disk group */
- if ((bmp_dgname == NULL) || (strlen(bmp_dgname) == 0)) {
- /* Bitmap is not in a real disk group */
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- gettext("bitmap %s is not in disk group \"%s\""),
- localfile, islocal < 1?file_dgname:ctag);
- return (-1);
- }
- }
- if (strlen(ctag) != 0 && bmp_dgname && islocal != 1 &&
- strlen(bmp_dgname) != 0 &&
- strncmp(ctag, bmp_dgname, MAX_RDC_HOST_SIZE) != 0) {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- gettext("ctag \"%s\" does not "
- "match disk group name \"%s\" of bitmap %s"),
- ctag, bmp_dgname, localfile);
- return (-1);
- }
-
- return (0);
-}
-int
-mounted(char *device)
-{
- char target[NSC_MAXPATH];
- struct mnttab mntref;
- struct mnttab mntent;
- FILE *mntfp;
- int rdsk;
- char *s;
- int rc;
- int i;
-
- rdsk = i = 0;
- for (s = target; i < NSC_MAXPATH && (*s = *device++); i++) {
- if (*s == 'r' && rdsk == 0 && strncmp(device, "dsk/", 4) == 0)
- rdsk = 1;
- else
- s++;
- }
- *s = '\0';
-
- mntref.mnt_special = target;
- mntref.mnt_mountp = NULL;
- mntref.mnt_fstype = NULL;
- mntref.mnt_mntopts = NULL;
- mntref.mnt_time = NULL;
-
- mntfp = fopen(MNTTAB, "r");
-
- if (mntfp == NULL) {
- /* Assume the worst, that it is mounted */
- return (1);
- }
-
- if ((rc = getmntany(mntfp, &mntent, &mntref)) != -1) {
- /* found something before EOF */
- fclose(mntfp);
- return (1);
- }
-
- fclose(mntfp);
- return (0);
-}
-
-int
-can_enable(rdcconfig_t *rdc)
-{
- struct stat stb;
-
- if ((strcmp(rdc->pfile, rdc->pbmp) == 0) ||
- (strcmp(rdc->sfile, rdc->sbmp) == 0)) {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- dgettext("librdc", "volumes and bitmaps must not match"));
- return (0);
- }
- if (ctag_check(rdc) < 0) {
- /* rdc_error should already be set */
- return (0);
- }
-
- if (self_check(rdc->phost)) {
- if (stat(rdc->pfile, &stb) != 0) {
- rdc_set_error(NULL, RDC_OS, RDC_FATAL, NULL);
- return (0);
- }
- if (!S_ISCHR(stb.st_mode)) {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- dgettext("librdc", "%s is not a character device"),
- rdc->pfile);
- return (0);
- }
- return (rdc->persist ?
- !bitmap_in_use(RDC_CMD_ENABLE, rdc->phost, rdc->pbmp) : 1);
- } else { /* on the secondary */
- if (stat(rdc->sfile, &stb) != 0) {
- rdc_set_error(NULL, RDC_OS, 0,
- dgettext("librdc", "unable to access %s: %s"),
- rdc->sfile, strerror(errno));
- }
- if (!S_ISCHR(stb.st_mode)) {
- rdc_set_error(NULL, RDC_INTERNAL, RDC_NONFATAL,
- dgettext("librdc",
- "%s is not a character device"), rdc->sfile);
- }
- return (rdc->persist ?
- !bitmap_in_use(RDC_CMD_ENABLE, rdc->shost, rdc->sbmp) : 1);
- }
-}
-
-int
-can_reconfig_pbmp(rdcconfig_t *rdc, char *bmp)
-{
- if (!rdc->persist)
- return (0);
-
- return (!bitmap_in_use(RDC_CMD_RECONFIG, rdc->phost, bmp));
-}
-
-int
-can_reconfig_sbmp(rdcconfig_t *rdc, char *bmp)
-{
- if (!rdc->persist)
- return (0);
-
- return (!bitmap_in_use(RDC_CMD_RECONFIG, rdc->shost, bmp));
-}
-
-rdc_rc_t *
-cant_rsync(rdcconfig_t *rdc)
-{
- rdc_rc_t *rc;
-
- if (mounted(rdc->pfile)) {
- rc = new_rc();
- if (rc == NULL)
- return (NULL);
- strncpy(rc->set.phost, rdc->phost, MAX_RDC_HOST_SIZE);
- strncpy(rc->set.pfile, rdc->pfile, NSC_MAXPATH);
- strncpy(rc->set.pbmp, rdc->pbmp, NSC_MAXPATH);
- strncpy(rc->set.shost, rdc->shost, MAX_RDC_HOST_SIZE);
- strncpy(rc->set.sfile, rdc->sfile, NSC_MAXPATH);
- strncpy(rc->set.sbmp, rdc->sbmp, NSC_MAXPATH);
-
- rc->rc = -1;
-
- rdc_set_error(NULL, RDC_INTERNAL, 0, "unable to sync %s volume"
- " is currently mounted", rdc->pfile);
- strncpy(rc->msg, rdc_error(NULL), RDC_ERR_SIZE);
-
- return (rc);
- }
- return (NULL);
-}
diff --git a/usr/src/lib/librdc/common/rdcrules.h b/usr/src/lib/librdc/common/rdcrules.h
deleted file mode 100644
index ab111fbdce..0000000000
--- a/usr/src/lib/librdc/common/rdcrules.h
+++ /dev/null
@@ -1,46 +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.
- */
-
-#ifndef _RDCRULES_H
-#define _RDCRULES_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* insert handy rule enforcing functions here */
-
-extern int bitmap_in_use(int cmd, char *hostp, char *bmp);
-extern int mounted(char *);
-extern int can_enable(rdcconfig_t *rdc);
-extern int can_reconfig_pbmp(rdcconfig_t *rdc, char *bmp);
-extern int can_reconfig_sbmp(rdcconfig_t *rdc, char *bmp);
-extern rdc_rc_t *cant_rsync(rdcconfig_t *rdc);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _RDCRULES_H */
diff --git a/usr/src/lib/librdc/i386/Makefile b/usr/src/lib/librdc/i386/Makefile
deleted file mode 100644
index d3a87b4acc..0000000000
--- a/usr/src/lib/librdc/i386/Makefile
+++ /dev/null
@@ -1,33 +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.
-#
-# lib/librdc/i386/Makefile
-
-include ../Makefile.com
-
-.KEEP_STATE:
-
-all: $(LIBS)
-
-install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTARLINK)
-lint:
diff --git a/usr/src/lib/librdc/sparc/Makefile b/usr/src/lib/librdc/sparc/Makefile
deleted file mode 100644
index d96edd5d5e..0000000000
--- a/usr/src/lib/librdc/sparc/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 2008 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-include ../Makefile.com
-
-.KEEP_STATE:
-
-all: $(LIBS)
-
-install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTARLINK)
-lint:
diff --git a/usr/src/lib/libunistat/Makefile b/usr/src/lib/libunistat/Makefile
deleted file mode 100644
index c27cb5079a..0000000000
--- a/usr/src/lib/libunistat/Makefile
+++ /dev/null
@@ -1,96 +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.
-#
-# lib/libunistat/Makefile
-
-include ../Makefile.lib
-
-UTSBASE= ../../uts
-
-SUBDIRS= $(MACH)
-
-all := TARGET= all
-clean := TARGET= clean
-clobber := TARGET= clobber
-delete := TARGET= delete
-install := TARGET= install
-lint := TARGET= lint
-lintinter := TARGET= lintinter
-_msg := TARGET= _msg
-package := TARGET= package
-
-LIBRARY= libunistat.a
-
-HDRS= spcs_dtrinkets.h \
- spcs_etrinkets.h \
- spcs_errors.h \
- spcs_etext.h
-HDRDIR= common
-
-ROOTHDRDIR= $(ROOT)/usr/include/sys/unistat
-ROOTHDRS= $(HDRS:%=$(ROOTHDRDIR)/%)
-
-.KEEP_STATE:
-
-all clean clobber delete lint package lintinter: $(SUBDIRS)
-
-install: $(SUBDIRS)
-install_h: $(ROOTHDRDIR) $(ROOTHDRS)
-
-check:
-
-# install rule for install_h target
-$(ROOTHDRDIR):
- $(INS.dir)
-
-$(ROOTHDRDIR)/spcs_errors.h: $(MACH)/spcs_errors.h
- $(INS.file) $(MACH)/spcs_errors.h
-
-$(MACH)/spcs_errors.h: FRC
- @ cd $(MACH); pwd; $(MAKE) spcs_errors.h
-
-$(ROOTHDRDIR)/spcs_s_u.h: common/spcs_s_u.h
- $(INS.file) common/spcs_s_u.h
-
-$(ROOTHDRDIR)/spcs_etext.h: $(MACH)/spcs_etext.h
- $(INS.file) $(MACH)/spcs_etext.h
-
-$(MACH)/spcs_etext.h: FRC
- @ cd $(MACH); pwd; $(MAKE) spcs_etext.h
-
-$(ROOTHDRDIR)/spcs_dtrinkets.h: $(MACH)/spcs_dtrinkets.h
- $(INS.file) $(MACH)/spcs_dtrinkets.h
-
-$(MACH)/spcs_dtrinkets.h: FRC
- @ cd $(MACH); pwd; $(MAKE) spcs_dtrinkets.h
-
-$(ROOTHDRDIR)/spcs_etrinkets.h: $(MACH)/spcs_etrinkets.h
- $(INS.file) $(MACH)/spcs_etrinkets.h
-
-$(MACH)/spcs_etrinkets.h: FRC
- @ cd $(MACH); pwd; $(MAKE) spcs_etrinkets.h
-
-$(MACH) $(MACH64): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
diff --git a/usr/src/lib/libunistat/Makefile.com b/usr/src/lib/libunistat/Makefile.com
deleted file mode 100644
index 522a938a4b..0000000000
--- a/usr/src/lib/libunistat/Makefile.com
+++ /dev/null
@@ -1,189 +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.
-#
-# lib/libunistat/Makefile.com
-#
-# include global definitions
-include ../../../Makefile.master
-
-LIBRARY= libunistat.a
-VERS= .1
-
-OBJECTS= spcs_s_u.o spcs_log.o
-
-# include library definitions
-include ../../Makefile.lib
-
-SRCS= $(OBJECTS:%.o=../common/%.c)
-SRCDIR= ../common
-
-LIBS += $(DYNLIB) $(LINTLIB)
-
-# definitions for lint
-
-LINTFLAGS += -u -I..
-LINTFLAGS += -erroff=E_UNDEFINED_SYMBOL
-LINTFLAGS += -erroff=E_STATIC_UNUSED
-LINTFLAGS += -erroff=E_BAD_PTR_INT_COMB_ARG
-LINTFLAGS += -erroff=E_VAR_USED_BEFORE_SET
-LINTFLAGS += -erroff=E_SEC_FORBIDDEN_WARN_CFTIME
-LINTFLAGS += -erroff=E_SEC_PRINTF_VAR_FMT
-LINTFLAGS += -erroff=E_OLD_STYLE_DECL_OR_BAD_TYPE
-LINTFLAGS += -erroff=E_YACC_ERROR
-LINTFLAGS += -erroff=E_FUNC_RET_MAYBE_IGNORED2
-LINTFLAGS += -erroff=E_FUNC_RET_ALWAYS_IGNOR2
-LINTOUT= lint.out
-LINTOUT_INTER= lintinter.out
-
-CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-unused-variable
-
-LINTSRC= $(LINTLIB:%.ln=%)
-ROOTLINTDIR= $(ROOTLIBDIR)
-ROOTLINT= $(LINTSRC:%=$(ROOTLINTDIR)/%)
-
-CLEANFILES += $(LINTOUT) $(LINTLIB) $(LINTOUT_INTER) $(LINT_INTER)
-
-all:= TARGET= all
-clean:= TARGET= clean
-clobber:= TARGET= clobber
-install:= TARGET= install
-lint:= TARGET= lint
-lintinter:= TARGET= lintinter
-
-MODS= dsw \
- rdc \
- spcs \
- sdbc \
- solaris \
- sv
-
-ERRS= $(MODS:%=$(SRCDIR)/%/%.err)
-MSGS= $(MODS:%=$(SRCDIR)/%/%.msg)
-EDEFS= $(MODS:%=$(SRCDIR)/%/%.edef)
-TRNKS= $(MODS:%=$(SRCDIR)/%/%.trnk)
-DTRNKS= $(MODS:%=$(SRCDIR)/%/%.dtrnk)
-
-ERRGEN_DIR= $(SRC)/cmd/avs/errgen
-ERRGEN= $(ERRGEN_DIR)/errgen
-
-# production (non-debug)
-DFLAGS = -DISSTATIC=static
-
-# development (debug) - cstyle prohibits use of "STATIC"
-DFLAGS = -g -DISSTATIC=" "
-
-CFLAGS += $(CCVERBOSE) $(DFLAGS) -I. -DLIBSPCS_CLIENT\
- -I$(JAVAINC) -I$(JAVAINCSOL)\
- -DLIBUNISTAT_LOCALE=\"/usr/install/unistat/locale\"
-CFLAGS64 += $(CCVERBOSE) $(DFLAGS) -I. -DLIBSPCS_CLIENT\
- -I$(JAVAINC) -I$(JAVAINCSOL)\
- -DLIBUNISTAT_LOCALE=\"/usr/install/unistat/locale\"
-LDLIBS += -lc
-
-$(LINTLIB) := SRCS = ../common/llib-lunistat
-$(LINTLIB) := LINTFLAGS = -nvx -DLIBSPCS_CLIENT -I$(JAVAINC) -I$(JAVAINCSOL)\
- -DISSTATIC=static \
- -DLIBUNISTAT_LOCALE=\"/usr/install/unistat/locale\"
-$(LINTLIB) := LINTFLAGS64 = -nvx -Xarch=v9 -DLIBSPCS_CLIENT \
- -I$(JAVAINC) -I$(JAVAINCSOL) \
- -DISSTATIC=static \
- -DLIBUNISTAT_LOCALE=\"/usr/install/unistat/locale\"
-
-$(LINT_INTER) := SRCS += ../common/llib-lunistat
-$(LINT_INTER) := LINTFLAGS = -nvx -DLIBSPCS_CLIENT -I$(JAVAINC) -I$(JAVAINCSOL)\
- -DISSTATIC=static \
- -DLIBUNISTAT_LOCALE=\"/usr/install/unistat/locale\"
-$(LINT_INTER) := LINTFLAGS64 = -nvx -Xarch=v9 -DLIBSPCS_CLIENT \
- -I$(JAVAINC) -I$(JAVAINCSOL) \
- -DISSTATIC=static \
- -DLIBUNISTAT_LOCALE=\"/usr/install/unistat/locale\"
-
-COMMENT= "/* THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT */"
-
-CLEANFILES += *.h *.po\
- $(SRCDIR)/*/*.msg\
- $(SRCDIR)/*/*.properties\
- $(SRCDIR)/*/*.exc\
- $(SRCDIR)/*/*.edef\
- $(SRCDIR)/*/*.trnk\
- $(SRCDIR)/*/*.dtrnk
-
-# note that the properties files are generated in ../libspcs/java
-
-.SUFFIXES: .err .exc .properties .edef .msg .trnk .dtrnk
-
-.err.msg:
- $(ERRGEN) -m `basename $*` <$*.err >$*.msg
-
-.err.edef:
- $(ERRGEN) -c `basename $*` <$*.err >$*.edef
-
-.err.trnk:
- $(ERRGEN) -t `basename $*` <$*.err >$*.trnk
-
-.err.dtrnk:
- $(ERRGEN) -x `basename $*` <$*.err >$*.dtrnk
-
-all: spcs_etext.h spcs_errors.h spcs_etrinkets.h spcs_dtrinkets.h $(LIB)
-
-spcs_dtrinkets.h: $(ERRGEN) $(DTRNKS)
- @echo $(COMMENT) > $@
- cat $(DTRNKS) >>spcs_dtrinkets.h
-
-spcs_etrinkets.h: $(ERRGEN) $(TRNKS)
- @echo $(COMMENT) > $@
- cat $(TRNKS) $(SRCDIR)/spcs_etrinkets.stub >> $@
-
-spcs_etext.h: $(ERRGEN) $(MSGS)
- @echo $(COMMENT) > $@
- $(CAT) $(MSGS) $(SRCDIR)/spcs_etext.stub >> $@
- $(SED) "s/ \"/ gettext(\"/" < $@ |\
- sed "s/\",/\"),/" > temp
- xgettext -d unistat temp ; rm temp
-
-spcs_errors.h: $(ERRGEN) $(EDEFS)
- @echo $(COMMENT) > $@
- $(CAT) $(EDEFS) $(SRCDIR)/spcs_errors.stub >> $@
-
-$(ERRGEN):
- @cd $(ERRGEN_DIR); pwd; $(MAKE) install
-
-
-.KEEP_STATE:
-
-FRC:
-
-lint: lintcheck $(LINTLIB)
-lintinter: $(LINT_INTER)
-
-# include library targets
-include ../../Makefile.targ
-
-objs/%.o pics/%.o: ../common/%.c
- $(COMPILE.c) -o $@ $<
- $(POST_PROCESS_O)
-
-# install rule for lint library target
-$(ROOTLINTDIR)/%: ../common/%
- $(INS.file)
diff --git a/usr/src/lib/libunistat/common/README b/usr/src/lib/libunistat/common/README
deleted file mode 100644
index e651404de7..0000000000
--- a/usr/src/lib/libunistat/common/README
+++ /dev/null
@@ -1,33 +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.
-#
-The error resource files in *.err of the subdirectories must only contain
-embedded "%s" format descriptors for info to be edited into messages returned
-from ioctls. Special "bytestream" data to be passed with status
-(implementation TBD) is signified by "@@@" as the last three characters of
-the message text. Don't try to use this to pass a bytestream back via an
-ioctl: it will just trigger an error.
-
-After early development when the first creation of foreign language locale
-files by the company for a product takes place you are NOT free to make edits
-to existing messages or their status code labels nor do any insertions. You
-may ONLY ONLY ONLY append new lines to the end of the file.
diff --git a/usr/src/lib/libunistat/common/dsw/dsw.err b/usr/src/lib/libunistat/common/dsw/dsw.err
deleted file mode 100644
index 960a41122a..0000000000
--- a/usr/src/lib/libunistat/common/dsw/dsw.err
+++ /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 2008 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-EMPTY = Empty string
-HDRBMP = Unable to read or write bitmap header
-INVALBMP = Bitmap magic number is not valid
-MISMATCH = Arguments inconsistent with current bitmap
-SHDSIZE = Shadow too small
-BMPSIZE = Bitmap too small
-REGISTER = Registration failed
-DIRTY = Bitmap is dirty
-SHUTDOWN = Shadow shutting down
-OPEN = nsc_open failed
-INUSE = Volume in use
-NOTFOUND = Volume not enabled
-COPYING = Volume copy in progress
-IO = I/O error copying data
-ABORTED = Copy operation aborted
-PARTSIZE = nsc_partsize failed
-DEPENDENCY = Volumes are not currently independent
-MAPMEMORY = Could not allocate memory for bitmaps in interface library (malloc)
-RSRVFAIL = nsc_reserve failed
-OPACKAGE = Another package would not allow target to be changed at this moment
-INCOMPLETE = Source shadow volume is not complete due to earlier overflow
-NOTEXPORTED = Shadow volume is not exported
-ALREADY = Operation already successfully performed
-WRONGTYPE = Wrong type of shadow group
-OMAGIC = Overflow volume magic number or name does not match
-ODEPENDENCY = Volumes are currently dependent on overflow volume
-OFFLINE = Volume offline
-NOTLOCKED = Set not pid-locked
-CNOTFOUND = Cluster resource group not found
-GNOTFOUND = No such group defined
-DISABLE = One or more sets failed to be disabled
-ISEXPORTED = Update or copy not allowed on an exported shadow volume
diff --git a/usr/src/lib/libunistat/common/llib-lunistat b/usr/src/lib/libunistat/common/llib-lunistat
deleted file mode 100644
index 9b31630c45..0000000000
--- a/usr/src/lib/libunistat/common/llib-lunistat
+++ /dev/null
@@ -1,42 +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 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <sys/unistat/spcs_s.h>
-#include <sys/unistat/spcs_s_u.h>
-
-void spcs_s_uinit(spcs_s_info_t ustatus);
-spcs_s_info_t spcs_s_ucreate(void);
-char *spcs_s_string(spcs_s_info_t ustatus, char *msg);
-void spcs_s_report(spcs_s_info_t ustatus, FILE *fd);
-void spcs_s_exception(spcs_s_info_t ustatus, void *env);
-void spcs_s_ufree(spcs_s_info_t *ustatus_a);
-void spcs_log(const char *product, spcs_s_info_t *status,
- const char *format, ...);
diff --git a/usr/src/lib/libunistat/common/mapfile-vers b/usr/src/lib/libunistat/common/mapfile-vers
deleted file mode 100644
index 8c4028fc96..0000000000
--- a/usr/src/lib/libunistat/common/mapfile-vers
+++ /dev/null
@@ -1,55 +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 (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
-#
-
-#
-# 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
-#
-
-#
-# Generic interface definition for usr/src/lib/libunistat.
-#
-
-$mapfile_version 2
-
-SYMBOL_VERSION SUNWprivate {
- global:
- spcs_s_uinit;
- spcs_s_ucreate;
- spcs_s_string;
- spcs_s_report;
- spcs_s_exception;
- spcs_s_ufree;
- spcs_log;
- local:
- *;
-};
diff --git a/usr/src/lib/libunistat/common/rdc/rdc.err b/usr/src/lib/libunistat/common/rdc/rdc.err
deleted file mode 100644
index a06b5476f8..0000000000
--- a/usr/src/lib/libunistat/common/rdc/rdc.err
+++ /dev/null
@@ -1,93 +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.
-#
-EPERM = Must be super-user to execute
-EINVAL = Invalid flag %s
-ALREADY = %s ==> %s not already enabled
-DISABLEPENDING = Disable pending on %s ==> %s, try again later
-ENABLEPENDING = Enable pending on %s ==> %s, try again later
-OPNSECSRC = Host %s: Source %s, open remote host failed
-OPNPRISRC = Host %s: Source %s, open failed
-OPNSECTGT = Host %s: Target %s, open remote host failed
-OPNPRITGT = Host %s: Target %s, open failed
-NOLOCHOST = Disks %s,%s do not reside on host %s or host %s
-NOTREMOTE = Master %s and Slave %s have same id %s
-MASTERNOTLOCAL = Master %s does not reside on this host: %s
-YOUNGER = %s is failed from %s..cannot proceed
-NODISABLE = Currently syncing, unable to disable
-CONN = Unable to connect to %s: local disable complete, remote disable aborted
-FLUSH = Will disable when ATM queue flushes on %s ==> %s
-SYNCING = Request not serviced, %s is currently being synced.
-INITREMOTE = Could not initialize remote data structures on %s ==> %s set
-INITLOCAL = Could not initialize local data structures on %s ==> %s set
-NOSLAVE = Target %s is failed, cannot set up for sync operation
-SIZE = Size of Primary %s:%s(%s) must be less than or equal to size of Secondary %s:%s(%s)
-SIZCHG = Device size change in dual copy set
-NOBMAP = Recovery bitmaps not allocated
-INITAFTERSYNC = Could not initialize data structures on %s ==> %s set after sync
-FAIL = Dual copy failed, offset:%s
-MIRRORDOWN = Mirror node is down
-GETSIZE = %s:%s has invalid size (%s)..cannot proceed
-UPDATE = Update sync %s:%s ==> %s:%s only allowed for an rdc device set
-EQUAL = Illegal device set %s:%s to itself
-MATCH = Device %s:%s belongs to another RDC device set
-MASTER = Changing the primary SNDR device %s:%s to become secondary and the secondary SNDR device %s:%s to become primary is not allowed in advanced configs
-CONNOPEN = Could not open file %s:%s on remote node
-NOPROC = Could not create rdc_config process
-BITMAP = Allocation of bitmap device %s failed
-MIRRORUP = Change request denied, volume mirror is up
-VERSION = Change request denied, don't understand request version
-EMPTY = Empty string
-ENABLED = %s:%s ==> %s:%s is already enabled
-OPEN = Unable to open %s:%s
-ADDTOIF = Unable to add interface %s to %s
-REGISTER = Unable to register %s
-NOTPRIMARY = Not primary, cannot sync %s:%s and %s:%s
-RSYNCNEEDED = Reverse sync needed, cannot sync %s:%s ==> %s:%s
-NOTHREADS = Unable to initialize the kernel thread set
-NETCONFIG = NULL struct knetconfig passed down from user program
-NETBUF = NULL struct netbuf passed down from user program for %s
-STATE = The state of %s:%s ==> %s:%s prevents this operation
-MANY2ONE = Cannot enable %s:%s ==> %s:%s, secondary in use in another set
-RSTATE = The remote state of %s:%s ==> %s:%s prevents this operation
-BMPINUSE = The bitmap %s is already in use
-VOLINUSE = The volume %s is already in use
-MULTI = Cannot use direct I/O on first leg of multi hop config
-GROUP = Cannot add %s:%s ==> %s:%s to group %s
-GROUPMODE = Cannot reconfigure sync/async on members of a group
-NOTLOGGING = Cannot reconfig %s:%s to %s:%s, Must be in logging mode
-BMPRECONFIG = Bitmap reconfig failed %s:%s
-BMAPLOGGING = Cannot overwrite bitmap as the set %s:%s is not in logging mode
-QDISABLEPEND = Disable pending on diskq %s, try again later
-QNOTLOGGING = Cannot change disk queue %s, all associated sets must be in logging mode
-QALREADY = %s:%s ==> %s:%s already has a disk queue attached
-QNOQUEUE = Disk queue does not exist for set %s:%s ==> %s:%s
-QFLUSHING = Operation not possible. Disk queue %s is flushing, try again later
-QWRONGMODE = Disk queue operations on synchronous sets not allowed
-DISKQINUSE = Disk queue %s is already in use
-QNOADD = Unable to enable disk queue %s
-QINITFAIL = Initialization of disk queue %s failed
-QNOTEMPTY = Operation not possible, disk queue %s is not empty.
-QUEISREP = Disk queue %s operation not possible, set is in replicating mode
-QNORSYNC = Cannot reverse sync %s:%s <== %s:%s, set is in queuing mode
-SETNOTLOGGING = can not start sync as set %s:%s is not logging
-BITMAP2SMALL = Allocation of bitmap device %s failed, volume is too small
diff --git a/usr/src/lib/libunistat/common/sdbc/sdbc.err b/usr/src/lib/libunistat/common/sdbc/sdbc.err
deleted file mode 100644
index b7583c85ea..0000000000
--- a/usr/src/lib/libunistat/common/sdbc/sdbc.err
+++ /dev/null
@@ -1,60 +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.
-#
-DUMMY = SDBC Place holder until definitions checked in by coresw dev.
-OBSOLETE = Obsolete sdbc ioctl used
-DISABLE = Cache deconfig failed. Not initialized
-CLUSTER_SIZE = Get cluster size operation failed. Cache not initialized
-CLUSTER_DATA = Get cluster data operation failed. Cache not initialized
-GLMUL_SIZE = Get global size operation failed. Cache not initialized
-GLMUL_INFO = Get global info operation failed. Cache not initialized
-TOGGLE_FLUSH = Cache flushing mode is (mode %s)
-UNSUPPORTED = Unknown ioctl: unsupported (cmd %s)
-DISABLEFAIL = Cache not deconfigured
-PINNED = Pinned data on %s
-ACTIVERDC = Active RDC pair not closed
-UNREG = Could not unregister sdbc io module
-ALREADY = Cache enable failed. Already initialized.
-ENABLEFAIL = Cache enable failed.
-SIZE = Cache block size %s not supported.
-MAGIC = Mismatched versions of scmadm and sdbc module.
-NONETMEM = Insufficient memory for cache.
-NOIOBMEM = No memory for iobuf hooks.
-NOIOBCB = Missing iobuf driver callback.
-NOHANDLEMEM = No memory for buffer handles.
-MEMCONFIG = Cache memory initialzation error.
-FLUSHTHRD = Flush threads create failure.
-NOHASH = Cannot create hash table
-NOCB = Cannot allocate cache block structures
-NOCCTL = Cannot allocate cctl sync structures
-NOCD = Cannot allocate cache data structures
-NOMIRRORCD = Cannot allocate cache data structures for mirror areas
-NOSHAREDFILE = Cannot allocate shared file area
-NOSFNV = Cannot allocate shared file area in nvmem
-NOREFRESH = Unable to refresh host memory
-INVHOSTID = Hostid %s greater than maximum (%s)
-NOTSAME = Self host %s and mirror host %s cannot be the same
-NORMLOCKS = No RM locks configured
-GLDMAFAIL = Global information transfer failed
-MODELCONVERT = 64 bit conversion called on a 32 bit system
-ABUFS = Anonymous buffers currently allocated from sdbc
-NODEVENABLED = Device not enabled in cache
diff --git a/usr/src/lib/libunistat/common/solaris/solaris.err b/usr/src/lib/libunistat/common/solaris/solaris.err
deleted file mode 100644
index 41b6ab6a00..0000000000
--- a/usr/src/lib/libunistat/common/solaris/solaris.err
+++ /dev/null
@@ -1,173 +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.
-#
-PERM = Not super-user
-NOENT = No such file or directory
-SRCH = No such process
-INTR = interrupted system call
-IO = I/O error
-NXIO = No such device or address
-2BIG = Arg list too long
-NOEXEC = Exec format error
-BADF = Bad file number
-CHILD = No children
-AGAIN = Resource temporarily unavailable
-NOMEM = Not enough core
-ACCES = Permission denied
-FAULT = Bad address
-NOTBLK = Block device required
-BUSY = Mount device busy
-EXIST = File exists
-XDEV = Cross-device link
-NODEV = No such device
-NOTDIR = Not a directory
-ISDIR = Is a directory
-INVAL = Invalid argument
-NFILE = File table overflow
-MFILE = Too many open files
-NOTTY = Inappropriate ioctl for device
-TXTBSY = Text file busy
-FBIG = File too large
-NOSPC = No space left on device
-SPIPE = Illegal seek
-ROFS = Read only file system
-MLINK = Too many links
-PIPE = Broken pipe
-DOM = Math arg out of domain of func
-RANGE = Math result not representable
-NOMSG = No message of desired type
-IDRM = Identifier removed
-CHRNG = Channel number out of range
-L2NSYNC = Level 2 not synchronized
-L3HLT = Level 3 halted
-L3RST = Level 3 reset
-LNRNG = Link number out of range
-UNATCH = Protocol driver not attached
-NOCSI = No CSI structure available
-L2HLT = Level 2 halted
-DEADLK = Deadlock condition.
-NOLCK = No record locks available.
-CANCELED = Operation canceled
-NOTSUP = Operation not supported
-DQUOT = Disc quota exceeded
-BADE = invalid exchange
-BADR = invalid request descriptor
-XFULL = exchange full
-NOANO = no anode
-BADRQC = invalid request code
-BADSLT = invalid slot
-DEADLOCK = file locking deadlock error
-BFONT = bad font file fmt
-UNUSED58 = not defined
-UNUSED59 = not defined
-NOSTR = Device not a stream
-NODATA = no data (for no delay io)
-TIME = timer expired
-NOSR = out of streams resources
-NONET = Machine is not on the network
-NOPKG = Package not installed
-REMOTE = The object is remote
-NOLINK = the link has been severed
-ADV = advertise error
-SRMNT = srmount error
-COMM = Communication error on send
-PROTO = Protocol error
-UNISED72 = undefined
-UNISED73 = undefined
-MULTIHOP = multihop attempted
-UNISED75 = undefined
-UNISED76 = undefined
-BADMSG = trying to read unreadable message
-NAMETOOLONG = path name is too long
-OVERFLOW = value too large to be stored in data type
-NOTUNIQ = given log. name not unique
-BADFD = f.d. invalid for this operation
-REMCHG = Remote address changed
-LIBACC = Can't access a needed shared lib.
-LIBBAD = Accessing a corrupted shared lib.
-LIBSCN = .lib section in a.out corrupted.
-LIBMAX = Attempting to link in too many libs.
-LIBEXEC = Attempting to exec a shared library.
-ILSEQ = Illegal byte sequence.
-NOSYS = Unsupported file system operation
-LOOP = Symbolic link loop
-RESTART = Restartable system call
-STRPIPE = if pipe/FIFO, don't sleep in stream head
-NOTEMPTY = directory not empty
-USERS = Too many users (for UFS)
-NOTSOCK = Socket operation on non-socket
-DESTADDRREQ = Destination address required
-MSGSIZE = Message too long
-PROTOTYPE = Protocol wrong type for socket
-NOPROTOOPT = Protocol not available
-UNUSED100 = undefined
-UNUSED101 = undefined
-UNUSED102 = undefined
-UNUSED103 = undefined
-UNUSED104 = undefined
-UNUSED105 = undefined
-UNUSED106 = undefined
-UNUSED107 = undefined
-UNUSED108 = undefined
-UNUSED109 = undefined
-UNUSED110 = undefined
-UNUSED111 = undefined
-UNUSED112 = undefined
-UNUSED113 = undefined
-UNUSED114 = undefined
-UNUSED115 = undefined
-UNUSED116 = undefined
-UNUSED117 = undefined
-UNUSED118 = undefined
-UNUSED119 = undefined
-PROTONOSUPPORT = Protocol not supported
-SOCKTNOSUPPORT = Socket type not supported
-OPNOTSUPP = Operation not supported on socket
-PFNOSUPPORT = Protocol family not supported
-AFNOSUPPORT = Address family not supported by protocol family
-ADDRINUSE = Address already in use
-ADDRNOTAVAIL = Can't assign requested address operational errors
-NETDOWN = Network is down
-NETUNREACH = Network is unreachable
-NETRESET = Network dropped connection because of reset
-CONNABORTED = Software caused connection abort
-CONNRESET = Connection reset by peer
-NOBUFS = No buffer space available
-ISCONN = Socket is already connected
-NOTCONN = Socket is not connected
-XENIX135 = XENIX 135
-XENIX136 = XENIX 136
-XENIX137 = XENIX 137
-XENIX138 = XENIX 138
-XENIX139 = XENIX 139
-XENIX140 = XENIX 140
-XENIX141 = XENIX 141
-XENIX142 = XENIX 142
-SHUTDOWN = Can't send after socket shutdown
-TOOMANYREFS = Too many references: can't splice
-TIMEDOUT = Connection timed out
-CONNREFUSED = Connection refused
-HOSTDOWN = Host is down
-HOSTUNREACH = No route to host
-ALREADY = operation already in progress
-INPROGRESS = operation now in progress
-STALE = Stale NFS file handle
diff --git a/usr/src/lib/libunistat/common/spcs/spcs.err b/usr/src/lib/libunistat/common/spcs/spcs.err
deleted file mode 100644
index 44f526a795..0000000000
--- a/usr/src/lib/libunistat/common/spcs/spcs.err
+++ /dev/null
@@ -1,39 +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.
-#
-# TODO: In order to put %s in these, since most are "internal errors" where a
-# direct Throw() or ThrowNew() is being done, need to use unistat and
-# call spcs_s_exception instead.
-OVERFLOW = status codes and/or supporting information lost
-BADHANDLE = The handle presented for access is not valid
-ACCESS = Unable to grant access
-INTERNAL = An internal error happened
-INUSE = The handle is already in use
-NODRIVER = The referenced SPCS driver could not be loaded:
-VERSION = Expected version not found, got libspcs.jar version:
-UNEXPECTED = The libspcs.jar version does not match the libspcs.so version
-WRONGMOD = Handle presented belongs to some other SPCS module
-# BUG: there is a weird bug, probably in errgen, that deletes the "i" from
-# required in this message when creating the java resource file!
-NEEDROOT = Root privilege required for libspcs access
-# developer test status: will never appear to a customer
-ASYNCTEST = Test of asynch status output@@
diff --git a/usr/src/lib/libunistat/common/spcs_errors.stub b/usr/src/lib/libunistat/common/spcs_errors.stub
deleted file mode 100644
index 19d5e814d4..0000000000
--- a/usr/src/lib/libunistat/common/spcs_errors.stub
+++ /dev/null
@@ -1,36 +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.
-*/
-/*
- * The SPCS subsystem numbers
- * TODO: derive the static finals in Spcs.java from these or visa versa!
- */
-
-#define SPCS_SOLARIS 0
-#define SPCS_SPCS 1
-#define SPCS_DSW 2
-#define SPCS_SV 3
-#define SPCS_RDC 4
-#define SPCS_SDBC 5
-#define SPCS_MAX_SUBSYSTEM 5
diff --git a/usr/src/lib/libunistat/common/spcs_etext.stub b/usr/src/lib/libunistat/common/spcs_etext.stub
deleted file mode 100644
index c37e5599ba..0000000000
--- a/usr/src/lib/libunistat/common/spcs_etext.stub
+++ /dev/null
@@ -1,40 +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.
-*/
-static char **SPCS_S_MSG[] = {
- SPCS_MSG_SOLARIS,
- SPCS_MSG_SPCS,
- SPCS_MSG_DSW,
- SPCS_MSG_SV,
- SPCS_MSG_RDC,
- SPCS_MSG_SDBC
-};
-static int SPCS_S_MSGLEN[] = {
- SPCS_MSGLEN_SOLARIS,
- SPCS_MSGLEN_SPCS,
- SPCS_MSGLEN_DSW,
- SPCS_MSGLEN_SV,
- SPCS_MSGLEN_RDC,
- SPCS_MSGLEN_SDBC
-};
diff --git a/usr/src/lib/libunistat/common/spcs_etrinkets.stub b/usr/src/lib/libunistat/common/spcs_etrinkets.stub
deleted file mode 100644
index 04889cd61b..0000000000
--- a/usr/src/lib/libunistat/common/spcs_etrinkets.stub
+++ /dev/null
@@ -1,49 +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.
- */
-
-static char **SPCS_S_TRNK[] = {
- SPCS_TRNK_SOLARIS,
- SPCS_TRNK_SPCS,
- SPCS_TRNK_DSW,
- SPCS_TRNK_SV,
- SPCS_TRNK_RDC,
- SPCS_TRNK_SDBC
-};
-static int SPCS_S_TRNKLEN[] = {
- SPCS_TRNKLEN_SOLARIS,
- SPCS_TRNKLEN_SPCS,
- SPCS_TRNKLEN_DSW,
- SPCS_TRNKLEN_SV,
- SPCS_TRNKLEN_RDC,
- SPCS_TRNKLEN_SDBC
-};
-static char *SPCS_S_EXC_PATH[] = {
- "com/sun/esm/library/spcs/SolarisException",
- "com/sun/esm/library/spcs/SpcsException",
- "com/sun/esm/library/spcs/dsw/DswException",
- "com/sun/esm/library/spcs/sv/SvException",
- "com/sun/esm/library/spcs/rdc/RdcException",
- "com/sun/esm/library/spcs/sdbc/SdbcException"
-};
diff --git a/usr/src/lib/libunistat/common/spcs_log.c b/usr/src/lib/libunistat/common/spcs_log.c
deleted file mode 100644
index 476529c11f..0000000000
--- a/usr/src/lib/libunistat/common/spcs_log.c
+++ /dev/null
@@ -1,115 +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 <sys/types.h>
-#include <sys/time.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <values.h>
-#include <locale.h>
-#include <sys/stat.h>
-#include <strings.h>
-#include <stdarg.h>
-#include <sys/param.h>
-#include <sys/nsctl/nsctl.h>
-
-#include <sys/unistat/spcs_s.h>
-#include <sys/unistat/spcs_s_u.h>
-#include <sys/unistat/spcs_errors.h>
-
-#define MAX_SESSION_LOG (10 * 1024 * 1024) /* allowable log file size */
-
-static char sessionlog[] = "/var/adm/ds.log";
-static char sessionlog_bak[] = "/var/adm/ds.log.bak";
-
-static char *spcstime();
-
-void
-spcs_log(const char *product, spcs_s_info_t *status, const char *format, ...)
-{
- struct stat st;
- FILE *fp = NULL;
- struct flock lk;
- va_list ap;
-
- bzero(&lk, sizeof (lk));
-
- /*
- * check the file size, if > than MAX_SESSION_LOG bytes make a .bak
- * and truncate
- */
- if (stat(sessionlog, &st) == 0) {
- if (st.st_size > MAX_SESSION_LOG) {
- rename(sessionlog, sessionlog_bak);
- }
- }
-
- va_start(ap, format);
- if ((fp = fopen(sessionlog, "a")) == (FILE *)NULL)
- goto fail;
- lk.l_type = F_WRLCK;
- lk.l_whence = SEEK_SET;
- lk.l_start = (off_t)0;
- lk.l_len = (off_t)0;
-
- if (fcntl(fileno(fp), F_SETLKW, &lk) < 0)
- goto fail;
-
-
- fprintf(fp, "%s %s: ", spcstime(), product);
- (void) vfprintf(fp, format, ap);
- fputs("\n", fp);
- if (status)
- spcs_s_report(*status, fp);
-
- fflush(fp);
-
- lk.l_type = F_UNLCK;
-
- (void) fcntl(fileno(fp), F_SETLKW, &lk);
-
-fail:
- if (fp)
- fclose(fp);
- va_end(ap);
-}
-
-/*
- * spcstime(): gets current time
- */
-static char *
-spcstime()
-{
- static char timeptr[20];
- time_t tnow;
-
- tnow = time((time_t *)0);
- cftime(timeptr, "%b %d %T", &tnow);
- return (timeptr);
-}
diff --git a/usr/src/lib/libunistat/common/spcs_s_u.c b/usr/src/lib/libunistat/common/spcs_s_u.c
deleted file mode 100644
index f5f946b31b..0000000000
--- a/usr/src/lib/libunistat/common/spcs_s_u.c
+++ /dev/null
@@ -1,246 +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.
- */
-/*
- * The SPCS status support user utilities
- * See spcs_s_u.h and the docs subdirectory for functional spec
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <locale.h>
-#include <libintl.h>
-#include <sys/unistat/spcs_s.h>
-#include <sys/unistat/spcs_s_u.h>
-#include <sys/unistat/spcs_s_impl.h>
-#include <sys/unistat/spcs_errors.h>
-#include <sys/unistat/spcs_etext.h>
-#include <sys/unistat/spcs_etrinkets.h>
-#include <sys/unistat/spcs_dtrinkets.h>
-
-/*
- * Initialize ioctl status storage to "remove" any old status present
- */
-
-void
-spcs_s_uinit(spcs_s_info_t ustatus)
-{
- spcs_s_pinfo_t *p = (spcs_s_pinfo_t *)ustatus;
- p->major = SPCS_S_MAJOR_REV;
- p->minor = SPCS_S_MINOR_REV;
- p->icount = 0;
- p->scount = 0;
- p->tcount = 0;
-}
-
-/*
- * Create and initialize local status. Call this prior to invoking
- * an ioctl.
- */
-
-spcs_s_info_t
-spcs_s_ucreate()
-{
- static int need_to_bind = 1;
- spcs_s_pinfo_t *ustatus;
-
- if (need_to_bind) {
- (void) setlocale(LC_ALL, "");
- (void) bindtextdomain("unistat", LIBUNISTAT_LOCALE);
- need_to_bind = 0;
- };
-
- ustatus = (spcs_s_pinfo_t *)malloc(sizeof (spcs_s_pinfo_t));
- spcs_s_uinit((spcs_s_info_t)ustatus);
-
- return ((spcs_s_info_t)ustatus);
-}
-
-/*
- * Return the idata index of the last status code in the array (i.e.
- * the "youngest" code present). The assumption is that the caller has
- * checked to see that pcount is nonzero.
- */
-
-ISSTATIC int
-last_code_idx(spcs_s_pinfo_t *p)
-{
- int last = 0;
- int idx = 0;
-
- while (idx < p->icount) {
- last = idx;
- idx += p->idata[idx].f.sup_count + 1;
- }
- return (last);
-}
-
-/*
- * Return a string with the module label and error message text or NULL
- * if none left
- */
-
-char *
-spcs_s_string(spcs_s_info_t ustatus, char *msg)
-{
- spcs_s_pinfo_t *p = (spcs_s_pinfo_t *)ustatus;
- int idx;
- int sup;
- int s;
- char *format;
- char *sp[SPCS_S_MAXSUPP];
- char mtemp[SPCS_S_MAXLINE];
-
- if (p->icount > 0) {
- idx = last_code_idx(p);
- strcpy(msg, module_names[p->idata[idx].f.module]);
- strcat(msg, ": ");
- sup = p->idata[idx].f.sup_count;
-
- if (p->idata[idx].f.module)
- /*
- * The gettext formal parameter is a const char*
- * I guess the gettext creator couldn't imagine
- * needing a variable string. If there is an underlying
- * routine that can be called it should be used.
- * otherwise there will be a compiler warning about this
- * line FOREVER (TS).
- */
- format = (char *)dgettext("unistat",
- SPCS_S_MSG[p->idata[idx].f.module]
- [p->idata[idx].f.code]);
-
- else
- format = strerror(p->idata[idx].f.code);
-
- /*
- * step across the status code to the first supplemental data
- * descriptor.
- */
-
- idx += 1;
-
- /*
- * Initialize the array with empty string pointers so we don't
- * seg fault if there are actually fewer values than "%s"
- * format descriptors.
- */
- for (s = 0; s < SPCS_S_MAXSUPP; s++)
- sp[s] = "";
-
- /*
- * Walk through the supplemental value descriptors and build
- * an array of string pointers.
- */
-
- for (s = 0; s < sup; s++) {
- sp[s] = (char *)(p->sdata + p->idata[idx+s].su.offset);
- }
-
- /*
- * Now format the message. The unused string pointers will be
- * ignored.
- * NOTE: Any change to SPCS_S_MAXSUPP requires a change to
- * this sprintf.
- */
-
- sprintf(mtemp, format, sp[0], sp[1], sp[2], sp[3], sp[4], sp[5],
- sp[6], sp[7]);
-
- /* remove the code and its supplemental info */
-
- p->icount -= (sup + 1);
-
- return (strcat(msg, mtemp));
- } else
- return (NULL);
-}
-
-/*
- * Write status info
- */
-
-void
-spcs_s_report(spcs_s_info_t ustatus, FILE *fd)
-{
- spcs_s_pinfo_t *p = (spcs_s_pinfo_t *)ustatus;
- short saved_count = p->icount;
- char msg[SPCS_S_MAXTEXT];
- char *sp;
- char *se;
- int first_time = 1;
-
- do {
- if (sp = spcs_s_string(ustatus, msg))
- fprintf(fd, "%s\n", sp);
- else if (first_time && (errno > 0)) {
- /*
- * This covers the case where Solaris aborted the
- * operation or the ioctl service code got an EFAULT
- * or something from copyin or couldn't allocate the
- * kernel status structure. If errno > 0 but not a
- * valid Solaris error code the extended error is
- * decoded and printed.
- */
- se = strerror(errno);
- if (se)
- fprintf(fd, "%s\n", se);
- else {
- spcs_s_udata_t spcs_errno;
-
- spcs_errno.i = errno;
- fprintf(fd, "%s: %s\n",
- module_names[spcs_errno.f.module],
- dgettext("unistat",
- SPCS_S_MSG[spcs_errno.f.module]
- [spcs_errno.f.code]));
-
- }
- }
- first_time = 0;
- } while (sp);
-
- p->icount = saved_count;
-}
-
-/*ARGSUSED*/
-void
-spcs_s_exception(spcs_s_info_t ustatus, void *env)
-{
-}
-
-/*
- * Release (free) ioctl status storage.
- */
-
-void
-spcs_s_ufree(spcs_s_info_t *ustatus_a)
-{
- free((void *)*ustatus_a);
- *ustatus_a = NULL;
-}
diff --git a/usr/src/lib/libunistat/common/sv/sv.err b/usr/src/lib/libunistat/common/sv/sv.err
deleted file mode 100644
index 87a782777c..0000000000
--- a/usr/src/lib/libunistat/common/sv/sv.err
+++ /dev/null
@@ -1,45 +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.
-#
-NOSLOTS = No more SVs available
-ARRBOUNDS = Array bounds check (min %s, max %s, got %s)
-DEVEXIST = Device already present in kernel
-NOSSTATE = Soft state alloc failed
-BADSSTATE = Soft state corrupted
-MKNOD = failed
-NODEV = Device not present in kernel configuration
-ENABLED = Device already enabled
-LOAD = Unable to load/hold underlying disk driver
-SDOPEN = Error from nsc_open()
-DISABLED = Device not enabled
-BUSY = Unable to disable device - device in use
-BADDEV = Bad dev_t in config structure
-STRATEGY = Recursive strategy functions
-GENERIC = Libspcs detected a nonspecific SV error
-STAT = Error from stat()
-KERNEL = User access to this device is not allowed by StorageTek kernel software
-AMODE = Illegal access mode
-GUARDVER = Incompatible guard magic or version number
-LOOKUP = Unable to translate pathname to major/minor number
-NOGCLIENT = Unable to match guard client module to internal module id
-GUSER = Unable to create kernel only guard, device already user enabled
-LYROPEN = Error from layered driver open
diff --git a/usr/src/lib/libunistat/i386/Makefile b/usr/src/lib/libunistat/i386/Makefile
deleted file mode 100644
index 0c2cdfaf46..0000000000
--- a/usr/src/lib/libunistat/i386/Makefile
+++ /dev/null
@@ -1,35 +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.
-#
-# lib/libunistat/i386/Makefile
-
-include ../Makefile.com
-
-.KEEP_STATE:
-
-all: $(LIBS)
-
-install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTARLINK)
-
-lint:
-lintinter:
diff --git a/usr/src/lib/libunistat/sparc/Makefile b/usr/src/lib/libunistat/sparc/Makefile
deleted file mode 100644
index 50b8adbfd8..0000000000
--- a/usr/src/lib/libunistat/sparc/Makefile
+++ /dev/null
@@ -1,35 +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.
-#
-# lib/libunistat/sparc/Makefile
-
-include ../Makefile.com
-
-.KEEP_STATE:
-
-all: $(LIBS)
-
-install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTARLINK)
-lint:
-lintinter:
-