diff options
Diffstat (limited to 'usr/src')
375 files changed, 20 insertions, 170515 deletions
diff --git a/usr/src/Makefile.lint b/usr/src/Makefile.lint index 6eb4120f27..9684b8fb9c 100644 --- a/usr/src/Makefile.lint +++ b/usr/src/Makefile.lint @@ -1,27 +1,4 @@ -# -# 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) 2003, 2010, Oracle and/or its affiliates. All rights reserved. -# # include global definitions include Makefile.master @@ -202,7 +179,6 @@ COMMON_SUBDIRS = \ cmd/mkfile \ cmd/mkmsgs \ cmd/mknod \ - cmd/mms \ cmd/mpathadm \ cmd/modload \ cmd/msgfmt \ @@ -444,7 +420,6 @@ COMMON_SUBDIRS = \ lib/libzoneinfo \ lib/lvm \ lib/madv \ - lib/mms \ lib/mpss \ lib/nametoaddr \ lib/ncad_addr \ diff --git a/usr/src/cmd/Makefile b/usr/src/cmd/Makefile index 1d523b2c61..addd681c04 100644 --- a/usr/src/cmd/Makefile +++ b/usr/src/cmd/Makefile @@ -1,26 +1,4 @@ -# -# 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) 1989, 2010, Oracle and/or its affiliates. All rights reserved. -# include ../Makefile.master @@ -259,7 +237,6 @@ COMMON_SUBDIRS= \ mknod \ mkpwdict \ mktemp \ - mms \ modload \ more \ mpathadm \ diff --git a/usr/src/cmd/Makefile.check b/usr/src/cmd/Makefile.check index dbc2800416..74e64e78c3 100644 --- a/usr/src/cmd/Makefile.check +++ b/usr/src/cmd/Makefile.check @@ -1,26 +1,4 @@ -# -# 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) 2009, 2010, Oracle and/or its affiliates. All rights reserved. -# include ../Makefile.master @@ -51,7 +29,6 @@ MANIFEST_TOPDIRS= \ ldapcachemgr \ ldmad \ lms \ - mms \ dlmgmtd \ ndmpd \ nscd \ diff --git a/usr/src/cmd/mms/Makefile b/usr/src/cmd/mms/Makefile deleted file mode 100644 index 5d32f5c662..0000000000 --- a/usr/src/cmd/mms/Makefile +++ /dev/null @@ -1,58 +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. -# - -include $(SRC)/cmd/Makefile.cmd - -MANIFEST = mms.xml -ROOTMANIFESTDIR = $(ROOTSVCAPPLICATIONMANAGEMENT) -SVCMETHOD = mmsdb - -SUBDIRS = \ - dm \ - lm \ - mgmt \ - mm \ - utility \ - wcr - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint -check := TARGET = check - -all clean clobber lint: $(SUBDIRS) - -install: $(SUBDIRS) $(ROOTMANIFEST) $(ROOTSVCMETHOD) - -$(SUBDIRS): FRC - @cd $@; pwd; VERSION='$(VERSION)' $(MAKE) $(TARGET) - -check: $(CHKMANIFEST) - -FRC: - -include ../Makefile.targ diff --git a/usr/src/cmd/mms/Makefile.subdirs b/usr/src/cmd/mms/Makefile.subdirs deleted file mode 100644 index 39529b59ca..0000000000 --- a/usr/src/cmd/mms/Makefile.subdirs +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -.KEEP_STATE: - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; VERSION='$(VERSION)' $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/cmd/mms/dm/Makefile b/usr/src/cmd/mms/dm/Makefile deleted file mode 100644 index 9912e2b4e7..0000000000 --- a/usr/src/cmd/mms/dm/Makefile +++ /dev/null @@ -1,28 +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. -# - -SUBDIRS = $(MACH) - -include ../Makefile.subdirs diff --git a/usr/src/cmd/mms/dm/Makefile.com b/usr/src/cmd/mms/dm/Makefile.com deleted file mode 100644 index 557f079e75..0000000000 --- a/usr/src/cmd/mms/dm/Makefile.com +++ /dev/null @@ -1,79 +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. -# - -.KEEP_STATE: -.SUFFIXES: - -SRCS = dm.c dm_ask.c dm_command.c dm_mem_debug.c dm_msg.c dm_request.c \ - dm_target.c dm_uscsi.c dm_util.c - -PROG = mmsdm - -OBJS = $(SRCS:%.c=%.o) -lint_SRCS = $(SRCS:%.c=%.ln) - -include ../../../Makefile.cmd - -ROOTCMDDIR= $(ROOT)/usr/lib - -$(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I. -I../common -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/lib/mms/mms/common -I$(SRC)/uts/common/io/mms/dda -CPPFLAGS += -I$(SRC)/uts/common/io/mms/dmd - -CFLAGS += $(CTF_FLAGS) $(CC_VERBOSE) - -LDLIBS += -lc -lgen -lsecdb -LDLIBS += -L$(SRC)/lib/mms/mms/$(MACH) -lmms - -.NO_PARALLEL: -.PARALLEL: $(OBJS) $(LINTFILES) - -C99MODE= $(C99_ENABLE) - -all: $(PROG) - -$(PROG): $(OBJS) - $(LINK.c) $(OBJS) -o $@ $(LDLIBS) - $(CTFMERGE) -L VERSION -o $@ $(OBJS) - $(POST_PROCESS) - -%.o: ../common/%.c - $(COMPILE.c) $< - $(CTFCONVERT_O) - -clean: - $(RM) $(OBJS) $(lint_SRCS) - -lint: $(lint_SRCS) - -%.ln: ../common/%.c - $(LINT.c) -c $< - -install: all $(ROOTCMD) - -include ../../../Makefile.targ diff --git a/usr/src/cmd/mms/dm/common/dm.c b/usr/src/cmd/mms/dm/common/dm.c deleted file mode 100644 index fb6fae6bc2..0000000000 --- a/usr/src/cmd/mms/dm/common/dm.c +++ /dev/null @@ -1,1666 +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. - */ - - -#include <limits.h> -#include <pthread.h> -#include <synch.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <sys/stat.h> -#include <sys/mkdev.h> -#include <dirent.h> -#include <netdb.h> -#include <syslog.h> -#include <ctype.h> -#include <signal.h> -#include <sys/time.h> -#include <unistd.h> -#include <stropts.h> -#include <fcntl.h> -#include <strings.h> -#include <errno.h> -#include <stdlib.h> -#include <stdio.h> -#include <dlfcn.h> -#include <link.h> -#include <netdb.h> -#include <sys/scsi/impl/uscsi.h> -#include <sys/scsi/generic/sense.h> -#include <sys/scsi/generic/status.h> -#include <sys/mtio.h> -#include <sys/param.h> -#include <libgen.h> -#include <mms_list.h> -#include <mms_parser.h> -#include <dmd_impl.h> -#include <dm_impl.h> -#include <mms_network.h> -#include <dm_drive.h> -#include <mms_sym.h> -#include <dm_msg.h> -#include <mms_trace.h> -#include <mms_dmd.h> -#include <dm_proto.h> -#include <host_ident.h> -#include <mms_strapp.h> -#include <mms_cores.h> -#include <mms_cat.h> - -static char *_SrcFile = __FILE__; - -static int dm_debug = MMS_SEV_DEVP; /* DM's default */ -static int dm_caught_usr1 = 0; -static int dm_caught_usr2 = 0; -static int dm_caught_term = 0; -static int dm_caught_int = 0; -static dm_wka_t dm_wka; -static drv_drive_t drv_drv; -static drv_jtab_t drv_jtab; -static drv_mount_t drv_mount; -static drv_scsi_err_t drv_scsi_err; -static uchar_t drv_iobuf[DRV_IOBUF_LEN]; -static drv_cart_access_t drv_dca; - -dm_wka_t *wka = &dm_wka; -drv_jtab_t *jtab = &drv_jtab; -drv_mount_t *mnt = &drv_mount; -drv_drive_t *drv = &drv_drv; -drv_scsi_err_t *serr = &drv_scsi_err; -drv_cart_access_t *dca = &drv_dca; -mms_list_t dm_msg_hdr_list; - -/* - * Function name - * dm_init_log(void) - * - * Parameters: - * none - * - * Description: - * open a trace file for DM. - * - * Note: - * - * - */ -void -dm_init_log(void) -{ - char *trfile; - - trfile = mms_strnew("%s/%s.debug", DM_TRACE_DIR, DMNAME); - if (mms_trace_open(trfile, MMS_ID_DM, dm_debug, -1, 1, 1)) { - syslog(LOG_NOTICE, "Unable to open mms_trace file \"%s\"", - trfile); - } - free(trfile); -} - -/* - * Function name - * dm_init_wka - * - * Parameters: - * none - * - * Description: - * initialize work area. - * The work area hold objects needed by DM, including mutexes, - * condition variables, lists pointers, etc. - * - * Return code: - * none - * - * Note: - * - * - */ - -void -dm_init_wka(void) -{ - memset(wka, 0, sizeof (dm_wka_t)); - mms_list_create(&wka->dm_pend_ack_queue, sizeof (dm_command_t), - offsetof(dm_command_t, cmd_next)); - mms_list_create(&wka->dm_cmd_queue, sizeof (dm_command_t), - offsetof(dm_command_t, cmd_next)); - - pthread_mutex_init(&wka->dm_io_mutex, NULL); - pthread_mutex_init(&wka->dm_worker_mutex, NULL); - pthread_mutex_init(&wka->dm_queue_mutex, NULL); - pthread_mutex_init(&wka->dm_tdv_close_mutex, NULL); - - pthread_cond_init(&wka->dm_work_cv, NULL); - pthread_cond_init(&wka->dm_tdv_close_cv, NULL); - pthread_cond_init(&wka->dm_accept_cv, NULL); - - wka->dm_pid = getpid(); - gethostname(wka->dm_local_hostname, sizeof (wka->dm_local_hostname)); - - memset(drv, 0, sizeof (drv_drv)); - memset(dca, 0, sizeof (drv_dca)); - drv->drv_iobuf = drv_iobuf; - drv->drv_lbl_blksize = -1; - drv->drv_file_blksize = -1; - wka->dm_pwbuf_size = sysconf(_SC_GETPW_R_SIZE_MAX); - if (wka->dm_pwbuf_size <= 0) { - wka->dm_pwbuf_size = 1024; - } - wka->dm_pwbuf = malloc(wka->dm_pwbuf_size); - TRACE((MMS_DEVP, "dm_init_wka: wka initialized")); -} - -/* - * Function name - * dm_init_dev_lib(void *hdl) - * - * Parameters: - * hdl pointer to the handle of the shared library that was - * opened by dlopen and contains device - * dependent code. - * - * Description: - * This function fills in the jump table used by DM to call device - * dependent functions and the drive table that holds some device - * specific information. - * DM initializes device libraries twice. Firstthe default library which - * has all the default functions and information. Then the device - * specific library which has only device specific information. - * Anything in the device specific library replaces those of the - * default library. - * - * Return code: - * none - * - * Note: - * - * - */ - -void -dm_init_dev_lib(void *hdl, int init) -{ -#define DM_INIT_DRV(x, type) { \ - addr = dlsym(hdl, # x); \ - if (addr != NULL) { \ - drv->x = type addr; \ - } else if (init) { \ - drv->x = NULL; \ - } \ - } - -#define DM_INIT_JTAB(x) { \ - addr = dlsym(hdl, # x); \ - if (addr != NULL) { \ - jtab->x = (x ## _t *)addr; \ - } else if (init) { \ - jtab->x = NULL; \ - } \ - } - - void *addr; - - DM_INIT_DRV(drv_prsv_supported, (int *)); - if (drv->drv_prsv_supported != NULL) { - if (*(drv->drv_prsv_supported) == 1) { - /* persistent reservation supported */ - drv->drv_flags |= DRV_USE_PRSV; - } else { - drv->drv_flags &= ~DRV_USE_PRSV; - } - } - - DM_INIT_DRV(drv_dev_dir, (char *)); - DM_INIT_DRV(drv_density, (mms_sym_t *)); - DM_INIT_DRV(drv_shape, (char **)); - DM_INIT_DRV(drv_shape_den, (drv_shape_density_t *)); - DM_INIT_DRV(drv_timeout, (drv_timeout_t *)); - DM_INIT_DRV(drv_drive_type, (char *)); - DM_INIT_DRV(drv_disallowed_cmds, (int *)); - DM_INIT_DRV(drv_num_disallowed_cmds, (int *)); - DM_INIT_DRV(drv_disallowed_ioctls, (int *)); - DM_INIT_DRV(drv_num_disallowed_ioctls, (int *)); - DM_INIT_DRV(drv_skaa_tab, (drv_skaa_t *)); - - /* - * Fill the jump table with devlib functions - */ - DM_INIT_JTAB(drv_init_dev); - DM_INIT_JTAB(drv_get_statistics); - DM_INIT_JTAB(drv_get_density); - DM_INIT_JTAB(drv_set_density); - DM_INIT_JTAB(drv_mk_prsv_key); - DM_INIT_JTAB(drv_disallowed); - DM_INIT_JTAB(drv_rebind_target); - DM_INIT_JTAB(drv_get_drivetype); - DM_INIT_JTAB(drv_get_targ); - DM_INIT_JTAB(drv_set_blksize); - DM_INIT_JTAB(drv_get_blksize); - DM_INIT_JTAB(drv_read); - DM_INIT_JTAB(drv_write); - DM_INIT_JTAB(drv_get_capacity); - DM_INIT_JTAB(drv_get_avail_capacity); - DM_INIT_JTAB(drv_log_sense); - DM_INIT_JTAB(drv_read_attribute); - DM_INIT_JTAB(drv_bind_raw_dev); - - /* - * The following are functions to execute scsi commands - */ - DM_INIT_JTAB(drv_clrerr); - DM_INIT_JTAB(drv_proc_error); - DM_INIT_JTAB(drv_inquiry); - DM_INIT_JTAB(drv_req_sense); - DM_INIT_JTAB(drv_wtm); - DM_INIT_JTAB(drv_tur); - DM_INIT_JTAB(drv_load); - DM_INIT_JTAB(drv_unload); - DM_INIT_JTAB(drv_rewind); - DM_INIT_JTAB(drv_mode_sense); - DM_INIT_JTAB(drv_mode_select); - DM_INIT_JTAB(drv_seek); - DM_INIT_JTAB(drv_tell); - DM_INIT_JTAB(drv_fsf); - DM_INIT_JTAB(drv_bsf); - DM_INIT_JTAB(drv_fsb); - DM_INIT_JTAB(drv_bsb); - DM_INIT_JTAB(drv_eom); - DM_INIT_JTAB(drv_get_pos); - DM_INIT_JTAB(drv_mtgetpos); - DM_INIT_JTAB(drv_mtrestpos); - DM_INIT_JTAB(drv_locate); - DM_INIT_JTAB(drv_blk_limit); - DM_INIT_JTAB(drv_reserve); - DM_INIT_JTAB(drv_release); - DM_INIT_JTAB(drv_get_serial_num); - DM_INIT_JTAB(drv_prsv_register); - DM_INIT_JTAB(drv_prsv_reserve); - DM_INIT_JTAB(drv_prsv_release); - DM_INIT_JTAB(drv_prsv_clear); - DM_INIT_JTAB(drv_prsv_preempt); - DM_INIT_JTAB(drv_prsv_read_keys); - DM_INIT_JTAB(drv_prsv_read_rsv); - DM_INIT_JTAB(drv_get_write_protect); - DM_INIT_JTAB(drv_set_compression); -} - -/* - * Function name - * dm_load_default_lib(void) - * - * Parameters: - * none - * - * Description: - * loads the default library and initialize the jump table. - * - * Return code: - * 0 success - * -1 failed - * - * Note: - * - * - */ - -int -dm_load_default_lib(void) -{ - char *libpath; - - memset(jtab, 0, sizeof (drv_jtab_t)); - - /* - * Load the default device library - */ - libpath = mms_strnew("%s/%s", DM_DEV_LIB_DIR, "libdm_default.so"); - wka->dm_default_lib_hdl = - dlopen(libpath, RTLD_NOW | RTLD_GLOBAL | RTLD_PARENT); - if (wka->dm_default_lib_hdl == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "default device library %s open error: %s", - libpath, dlerror())); - free(libpath); - return (-1); - } - - /* Init jtab with default lib */ - dm_init_dev_lib(wka->dm_default_lib_hdl, 1); - wka->dm_flags |= DM_DFLT_LIB_LOADED; - TRACE((MMS_OPER, "device library %s initialized", libpath)); - free(libpath); - return (0); -} - -/* - * Function name - * dm_load_devlib(void) - * - * Parameters: - * none - * - * Description: - * get the device type and dlopen the device dependent library. - * initialize jump table with it. - * - * Return code: - * 0 success - * -1 error - * - * Note: - * - * - */ - -int -dm_load_devlib(void) -{ - char *libpath; - - /* - * get device library name - */ - if (dm_get_dev_lib_name() != 0) { - return (-1); - } - - libpath = mms_strnew("%s/%s", DM_DEV_LIB_DIR, wka->dm_dev_lib); - TRACE((MMS_DEVP, "Loading device library %s", libpath)); - wka->dm_dev_lib_hdl = - dlopen(libpath, RTLD_NOW | RTLD_GLOBAL | RTLD_PARENT); - if (wka->dm_dev_lib_hdl == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "dynamic library open error: %s", dlerror())); - free(libpath); - return (-1); - } - - /* Init jtab with device lib */ - dm_init_dev_lib(wka->dm_dev_lib_hdl, 0); - wka->dm_flags |= DM_DEV_LIB_LOADED; - dm_clear_dev(); - - TRACE((MMS_OPER, "device library %s initialized", libpath)); - free(libpath); - return (0); - -} - -/* - * Function name - * dm_read_cfg(char *cfgname) - * - * Parameters: - * pointer to config file name - * - * Description: - * read the confige file passed to DM on the command line. - * Parse it and collect specified values. - * - * Return code: - * 0 success - * -1 error - * - * Note: - * - * - */ - -int -dm_read_cfg(char *cfgname) -{ - int fd; - struct stat statbuf; - char *buf; - int i; - mms_par_node_t *cfg; - mms_par_node_t *node; - mms_par_node_t *val; - mms_par_err_t *err; - mms_list_t err_list; - char *kw; - - fd = open(cfgname, O_RDONLY); - if (fd < 0) { - syslog(LOG_ERR, "Unable to open DM config file %s: %s\n", - cfgname, strerror(errno)); - DM_EXIT(DM_NO_RESTART); - } - - /* - * Allocate a buffer to read in the entire config file - */ - if (fstat(fd, &statbuf)) { - syslog(LOG_ERR, "Unable to stat DM config file %s: %s\n", - cfgname, strerror(errno)); - DM_EXIT(DM_NO_RESTART); - } - buf = malloc(statbuf.st_size + 1); - if (buf == NULL) { - syslog(LOG_ERR, "Unable to alloc buffer for " - "DM config file %s: %s\n", cfgname, strerror(errno)); - DM_EXIT(DM_NO_RESTART); - } - - /* - * Read in config file - */ - i = read(fd, buf, statbuf.st_size); - if (i < 0) { - syslog(LOG_ERR, "Unable to read DM config file %s: %s\n", - cfgname, strerror(errno)); - DM_EXIT(DM_NO_RESTART); - } - buf[i] = '\0'; - - /* - * Parse the config file - */ - i = mms_config_parse(&cfg, &err_list, buf); - if (i < 0) { - mms_list_foreach(&err_list, err) { - syslog(LOG_ERR, - "line %d, col %d, near token %s, " - "err code %d, %s\n", - err->pe_line, - err->pe_col, - err->pe_token, - err->pe_code, err->pe_msg); - } - syslog(LOG_ERR, "DM config file %s has errors\n", cfgname); - DM_EXIT(DM_NO_RESTART); - } - free(buf); - - /* - * Pick up the args - */ - MMS_PN_LOOKUP(node, cfg, kw = "host", MMS_PN_KEYWORD, NULL); - MMS_PN_LOOKUP(val, node, NULL, MMS_PN_STRING, NULL); - wka->dm_host = strdup(mms_pn_token(val)); - - MMS_PN_LOOKUP(node, cfg, kw = "port", MMS_PN_KEYWORD, NULL); - MMS_PN_LOOKUP(val, node, NULL, MMS_PN_STRING, NULL); - wka->dm_port = strdup(mms_pn_token(val)); - - MMS_PN_LOOKUP(node, cfg, kw = "name", MMS_PN_KEYWORD, NULL); - MMS_PN_LOOKUP(val, node, NULL, MMS_PN_STRING, NULL); - DRVNAME = strdup(mms_pn_token(val)); - - MMS_PN_LOOKUP(node, cfg, kw = "instance", MMS_PN_KEYWORD, NULL); - MMS_PN_LOOKUP(val, node, NULL, MMS_PN_STRING, NULL); - DMNAME = strdup(mms_pn_token(val)); - - MMS_PN_LOOKUP(node, cfg, kw = "password", MMS_PN_KEYWORD, NULL); - MMS_PN_LOOKUP(val, node, NULL, MMS_PN_STRING, NULL); - wka->dm_passwd = strdup(mms_pn_token(val)); - - if (node = mms_pn_lookup(cfg, kw = "mm_password", - MMS_PN_KEYWORD, NULL)) { - MMS_PN_LOOKUP(val, node, NULL, MMS_PN_STRING, NULL); - wka->dm_mm_passwd = strdup(mms_pn_token(val)); - } - - if (node = mms_pn_lookup(cfg, kw = "ssl_enabled", - MMS_PN_KEYWORD, NULL)) { - MMS_PN_LOOKUP(val, node, NULL, MMS_PN_STRING, NULL); - if (strcasecmp(mms_pn_token(val), "true") == 0) - wka->dm_ssl_enabled = 1; - } - - if (node = mms_pn_lookup(cfg, kw = "ssl_cert_file", - MMS_PN_KEYWORD, NULL)) { - MMS_PN_LOOKUP(val, node, NULL, MMS_PN_STRING, NULL); - wka->dm_ssl_cert_file = strdup(mms_pn_token(val)); - } - - if (node = mms_pn_lookup(cfg, kw = "ssl_pass", - MMS_PN_KEYWORD, NULL)) { - MMS_PN_LOOKUP(val, node, NULL, MMS_PN_STRING, NULL); - wka->dm_ssl_pass = strdup(mms_pn_token(val)); - } - - if (node = mms_pn_lookup(cfg, kw = "ssl_pass_file", - MMS_PN_KEYWORD, NULL)) { - MMS_PN_LOOKUP(val, node, NULL, MMS_PN_STRING, NULL); - wka->dm_ssl_pass_file = strdup(mms_pn_token(val)); - } - - if (node = mms_pn_lookup(cfg, kw = "ssl_crl_file", - MMS_PN_KEYWORD, NULL)) { - MMS_PN_LOOKUP(val, node, NULL, MMS_PN_STRING, NULL); - wka->dm_ssl_crl_file = strdup(mms_pn_token(val)); - } - - if (node = mms_pn_lookup(cfg, kw = "ssl_peer_file", - MMS_PN_KEYWORD, NULL)) { - MMS_PN_LOOKUP(val, node, NULL, MMS_PN_STRING, NULL); - wka->dm_ssl_peer_file = strdup(mms_pn_token(val)); - } - - if (node = mms_pn_lookup(cfg, kw = "ssl_cipher", - MMS_PN_KEYWORD, NULL)) { - MMS_PN_LOOKUP(val, node, NULL, MMS_PN_STRING, NULL); - wka->dm_ssl_cipher = strdup(mms_pn_token(val)); - } - - MMS_PN_LOOKUP(node, cfg, kw = "path", MMS_PN_KEYWORD, NULL); - MMS_PN_LOOKUP(val, node, NULL, MMS_PN_STRING, NULL); - wka->dm_drm_path = strdup(mms_pn_token(val)); - - mms_pe_destroy(&err_list); - mms_pn_destroy(cfg); - - return (0); - -not_found: - syslog(LOG_ERR, "Missing \"%s\" from DM config file %s\n", kw, - cfgname); - DM_EXIT(DM_NO_RESTART); - return (0); -} - -/* - * Function name - * dm_ssl_cfg(void) - * - * Parameters: - * none - * - * Description: - * Configure SSL if it is enabled - * - * Return code: - * 0 success - * DM_NO_RESTART terminate DM if error - * - * Note: - * - * - */ - -static int -dm_ssl_cfg(void) -{ - mms_network_cfg_t net; - mms_err_t err; - char ebuf[MMS_EBUF_LEN]; - -#ifdef MMS_OPENSSL - if (wka->dm_ssl_enabled) { - memset(&net, 0, sizeof (mms_network_cfg_t)); - net.ssl_enabled = wka->dm_ssl_enabled; - net.ssl_cert_file = wka->dm_ssl_cert_file; - net.ssl_pass = wka->dm_ssl_pass; - net.ssl_pass_file = wka->dm_ssl_pass_file; - net.ssl_crl_file = wka->dm_ssl_crl_file; - net.ssl_peer_file = wka->dm_ssl_peer_file; - net.ssl_cipher = wka->dm_ssl_cipher; - if (mms_ssl_client(&net, &wka->dm_ssl_data, &err)) { - mms_get_error_string(&err, ebuf, MMS_EBUF_LEN); - TRACE((MMS_ERR, "ssl init - %s", ebuf)); - DM_EXIT(DM_NO_RESTART); - } - } -#endif /* MMS_OPENSSL */ - - return (0); -} - -/* - * Function name - * void dm_rem_old_handle(void) - * - * Parameters: - * none - * - * Description: - * deletes handles left over from the previous - * run. - * - * Return code: - * none - * - * Note: - * - * - */ - -void -dm_rem_old_handle(void) -{ - DIR *dirp; - struct dirent *dp; - int len; - char *hdl; - int err; - - TRACE((MMS_DEVP, "dm_rem_old_handle: Removing old handles")); - dirp = opendir(MMS_HDL_DIR); - if (dirp == NULL) { - err = errno; - TRACE((MMS_CRIT, "Unable to open handle directory %s: %s", - MMS_HDL_DIR, strerror(err))); - /* - * If directory doe not exist, then create one. - */ - if (err == ENOENT) { - TRACE((MMS_DEBUG, "Createing handle directory %s", - MMS_HDL_DIR)); - /* - * create a directory named MMS_HDL_DIR, - * with read, write, and search permissions for - * owner and group, and with read and search - * permissions for others. - */ - if (mkdirp(MMS_HDL_DIR, 0755)) { - /* - * create handle directory error - */ - err = errno; - if (err == EEXIST) { - TRACE((MMS_DEBUG, "%s " - "already created by another DM", - MMS_HDL_DIR)); - return; - } - TRACE((MMS_CRIT, "Unable to create handle " - "directory %s: %s", - MMS_HDL_DIR, strerror(err))); - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Unable to create handle directory %s: %s", - MMS_HDL_DIR, strerror(err))); - DM_MSG_SEND((DM_ADM_ERR, DM_6529_MSG, - DM_MSG_REASON)); - DM_EXIT(DM_NO_RESTART); - } - /* - * Created new handle directoru - */ - TRACE((MMS_DEBUG, "created %s", MMS_HDL_DIR)); - return; - } - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Unable to open handle directory %s: %s", - MMS_HDL_DIR, strerror(err))); - DM_MSG_SEND((DM_ADM_ERR, DM_6525_MSG, DM_MSG_REASON)); - DM_EXIT(DM_NO_RESTART); - } - - len = strlen(wka->dm_hdl_prefix); - while ((dp = readdir(dirp)) != NULL) { - if (strncmp(dp->d_name, wka->dm_hdl_prefix, len) == 0) { - /* found an old handle */ - hdl = mms_strapp(NULL, - "%s/%s", MMS_HDL_DIR, dp->d_name); - TRACE((MMS_DEVP, - "dm_rem_old_handle: Removing handle %s", - dp->d_name)); - unlink(hdl); - free(hdl); - } - } - closedir(dirp); -} - -/* - * Function name - * dm_init(int argc, char **argv) - * - * Parameters: - * the command line arguments which is the pathname of - * the config file. - * - * Description: - * - close all files and reopen the std* files. - * - read config file - * - initialize log, wka and ssl - * - open the drm device - * - * Return code: - * 0 success - * exit DM if error. - * - * Note: - * - * - */ - -/* ARGSUSED */ -int -dm_init(int argc, char **argv) -{ - int i; - int retries = 0; - char *corename; - - TRACE((MMS_DEVP, "dm_init: Initializing DM")); - - /* - * Close all opened files. - */ - for (i = 0; i < OPEN_MAX; i++) - close(i); - - /* - * Direct stdin, stdout and stderr to /dev/null - */ - fopen("/dev/null", "r"); - fopen("/dev/null", "w"); - fopen("/dev/null", "w"); - - setsid(); /* become session leader */ - umask(0); /* clear file mode create mask */ - - /* - * Init message catalog - */ - mms_cat_open(); - - /* - * Initialize work area - */ - dm_init_wka(); - - /* - * Read config file - * Path of config file is argv[1] - */ - if (dm_read_cfg(argv[1])) { - DM_EXIT(DM_NO_RESTART); - } - - /* Move to where core files will be placed */ - if (mms_set_core(MMS_CORES_DIR, DMNAME)) { - TRACE((MMS_ERR, "dm_init: DM's core setup failed %s", - strerror(errno))); - } - - corename = mms_strnew("core.mmsdm.%s", DMNAME); - /* Check to see how many core files exist */ - if (mms_man_cores(MMS_CORES_DIR, corename)) { - TRACE((MMS_ERR, "dm_init: DM's mms_man_cores failed %s", - strerror(errno))); - } - free(corename); - - /* - * Init message logging - */ - dm_init_log(); - TRACE((MMS_OPER, "dm_init: ******** Starting DM %s ********", - DMNAME)); - - /* - * Open the DM device - */ - wka->dm_drm_fd = -1; /* not opened yet */ - while (dm_open_dm_device() < 0) { - if (errno == EBUSY && retries <= DM_OPEN_RETRIES) { - /* device is still opened */ - sleep(DM_OPEN_INTERVAL); - retries++; - } - TRACE((MMS_ERR, "Unable to open DM device: %s", - strerror(errno))); - DM_EXIT(DM_NO_RESTART); - } - - /* - * Init ssl - */ - if (dm_ssl_cfg()) { - DM_EXIT(DM_NO_RESTART); - } - - /* - * Start session with SMM - */ - if (dm_init_session(0)) { - TRACE((MMS_CRIT, "Unable to start a session with SMM")); - DM_EXIT(DM_NO_RESTART); - } - - return (0); -} - -/* - * Function name - * dm_get_dev_lib_name(void) - * - * Parameters: - * none - * - * Description: - * Get device dependent library name and save it in work area. - * Library name is constructed from the vendor and product ID's from - * the inquiry data like this: - * lib<vendor>-<product>.o - * where : - * <vendor> is the vendor id with trailing blanks removed and - * each remaining blank substituted with a '_' character. - * <product> is the product id with trailing blanks removed and - * each remaining blank substituted with a '_' character. - * - * Return code: - * 0 success - * -1 error - * - * Note: - * - * - */ - -int -dm_get_dev_lib_name(void) -{ - char vendor[9]; - char prod[17]; - int i; - - if (drv->drv_flags & DRV_FATAL) { - return (EIO); - } - - /* - * Read the inquiry data - */ - if (DRV_CALL(drv_get_drivetype, ())) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get vendor and product ID: %s", - strerror(errno))); - mms_trace_flush(); - return (-1); - } - - (void) strlcpy(vendor, drv->drv_vend, sizeof (vendor)); - /* trim trailing blanks */ - for (i = strlen(vendor) - 1; i >= 0 && vendor[i] == ' '; i--) { - vendor[i] = '\0'; - } - (void) strlcpy(prod, drv->drv_prod, sizeof (prod)); - for (i = strlen(prod) - 1; i >= 0 && prod[i] == ' '; i--) { - prod[i] = '\0'; - } - - /* Convert remaining blanks to '_' */ - for (i = 0; vendor[i] != '\0'; i++) { - if (vendor[i] == ' ') { - vendor[i] = '_'; - } - } - for (i = 0; prod[i] != '\0'; i++) { - if (prod[i] == ' ') { - prod[i] = '_'; - } - } - - wka->dm_dev_lib = mms_strnew("lib%s_%s.so", vendor, prod); - TRACE((MMS_INFO, "Device lib name = %s", wka->dm_dev_lib)); - return (0); -} - -/* - * Function name - * dm_init_session(int retries) - * - * Parameters: - * number of retries - * - * Description: - * initialize a session with the Media Manager - * retry until success or until the number of retries is exceeded. - * - * Return code: - * fd If a welcome response was received from MM, then - * this routine returns the file descriptor that the - * client will use to communicate with MM. - * MMS_ERROR If an error occurred while processing or if an - * unwelcome response was receieved from MM. - * - * - * Note: - * - * - */ - -int -dm_init_session(int retries) -{ - int rc; - mms_network_cfg_t cfg; - int err; - char *tag = NULL; - - TRACE((MMS_DEVP, "dm_init_session: Initializing session")); - /* - * 0 retries means forever - */ - if (retries == 0) { - retries = 0x7fffffff; - } - - memset(&cfg, 0, sizeof (mms_network_cfg_t)); - cfg.cli_host = strdup(wka->dm_host); - cfg.cli_port = strdup(wka->dm_port); - cfg.cli_name = strdup(drv->drv_drvname); - cfg.cli_inst = strdup(drv->drv_dmname); - cfg.cli_lang = MMS_DMP_LANG; - cfg.cli_vers = MMS_DMP_VERSION; - cfg.cli_pass = strdup(wka->dm_passwd); - if (wka->dm_mm_passwd) { - cfg.mm_pass = strdup(wka->dm_mm_passwd); - } - - for (; retries > 0; retries--) { - if ((rc = mms_mmconnect(&cfg, wka->dm_ssl_data, - &wka->dm_mms_conn, &err, tag)) != 0) { - /* - * Unable to connect to mm - */ - TRACE((MMS_WARN, "DM %s unable to connect " - "to MM: %d: %s", DMNAME, - err, mms_sym_code_to_str(err))); - if (retries > 1) { - wka->dm_flags |= DM_SILENT; - sleep(DM_CONNECT_INTERVAL); - } else { - break; - } - } else { - /* - * Successfully connected to MM - */ - wka->dm_flags &= ~DM_SILENT; - wka->dm_flags |= DM_HAVE_SESSION; - TRACE((MMS_OPER, "dm_init_session: " - "DM %s connected to MM on %s %s", - DMNAME, wka->dm_host, wka->dm_port)); - break; - } - } - - return (rc); -} - -/* - * Signal catching functions - */ - -/* - * Function name - * dm_sigusr1(void) - * - * Parameters: - * none - * - * Description: - * SIGUSR1 catcher - * - * Return code: - * none - * - * Note: - * - * - */ - -void -dm_sigusr1(void) -{ - TRACE((MMS_DEVP, "dm_sigusr1: Caught SIGUSR1")); - dm_caught_usr1 = 1; -} - -/* - * Function name - * dm_sigusr2(void) - * - * Parameters: - * none - * - * Description: - * SIGUSR2 catcher - * - * Return code: - * none - * - * Note: - * - * - */ - -void -dm_sigusr2(void) -{ - TRACE((MMS_DEVP, "dm_sigusr2: Caught SIGUSR2")); - dm_caught_usr2 = 1; -} - - -/* - * Function name - * dm_sigint(void) - * - * Parameters: - * void - * - * Description: - * SIGINT catcher - * - * Return code: - * none - * - * Note: - * - * - */ - -void -dm_sigint(void) -{ - /* - * Terminate this drive manager - */ - TRACE((MMS_DEVP, "dm_sigint: Caught SIGINT")); - mms_trace_flush(); - dm_caught_int = 1; -} - -/* - * Function name - * dm_sigterm(void) - * - * Parameters: - * none - * - * Description: - * SIGTERM catcher - * - * Return code: - * none - * - * Note: - * - * - */ - -void -dm_sigterm(void) -{ - /* - * Terminate this drive manager - */ - TRACE((MMS_DEVP, "dm_sigterm: Caught SIGTERM")); - mms_trace_flush(); - dm_caught_term = 1; -} - -/* - * Function name - * dm_sighup(void) - * - * Parameters: - * none - * - * Description: - * SIGHUP catcher - * - * Return code: - * none - * - * Note: - * - * - */ - -void -dm_sighup(void) -{ - /* - * Ignore Sighup - */ - TRACE((MMS_DEVP, "dm_sighup: Caught SIGHUP")); - mms_trace_flush(); - /* Ignore sighup */ -} - -/* - * Function name - * dm_signal(int sig, void (*handler) ()) - * - * Parameters: - * sig signal number - * handler signal handler - * - * Description: - * install signal handler - * - * Return code: - * none if success - * exit if error - * - * Note: - * - * - */ - -void -dm_signal(int sig, void (*handler) ()) -{ - /* - * Setup to catch signals - */ - struct sigaction act, oact; - - TRACE((MMS_DEVP, "dm_signal: Setting signal handler")); - memset(&act, 0, sizeof (act)); - act.sa_sigaction = handler; - sigemptyset(&act.sa_mask); - act.sa_flags = 0; - if (sig != SIGALRM) { - /* - * Allow alarm signal to interrupt - */ - act.sa_flags |= SA_RESTART; - } - if (sigaction(sig, &act, &oact) < 0) { - TRACE((MMS_ERR, "Can't set signal handler for " - "signal %d: %s", sig, strerror(errno))); - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Unable to set signal handler for " - "signal %d: %s", sig, strerror(errno))); - DM_MSG_SEND((DM_ADM_ERR, DM_6525_MSG, DM_MSG_REASON)); - DM_EXIT(DM_NO_RESTART); - } -} - -/* - * Function name - * dm_setup_sig_handler(void) - * - * Parameters: - * none - * - * Description: - * setup to install all signal handlers - * - * Return code: - * none - * - * Note: - * - * - */ - - -void -dm_setup_sig_handler(void) -{ - /* - * Setup SIGTERM handler - * Terminate drive manager - */ - TRACE((MMS_DEVP, "dm_setup_sig_handler: Catching SIGTERM")); - dm_signal(SIGTERM, dm_sigterm); - - /* - * Setup SIGUSR1 handler - * Driver request - */ - TRACE((MMS_DEVP, "dm_setup_sig_handler: Catching SIGUSR1")); - dm_signal(SIGUSR1, dm_sigusr1); - - /* - * Setup SIGUSR2 handler - * tdv device closed - */ - TRACE((MMS_DEVP, "dm_setup_sig_handler: Catching SIGUSR2")); - dm_signal(SIGUSR2, dm_sigusr2); - - /* - * Setup SIGHUP handler - */ - TRACE((MMS_DEVP, "dm_setup_sig_handler: Catching SIGHUP")); - dm_signal(SIGHUP, dm_sighup); - - /* - * Setup SIGINT handler - */ - TRACE((MMS_DEVP, "dm_setup_sig_handler: Catching SIGINT")); - dm_signal(SIGINT, dm_sigint); -} - -int -main(int argc, char **argv) -{ - sigset_t new_mask; - sigset_t old_mask; - pthread_t tid; - int rc = 0; - fd_set fdset; - timespec_t *tvp; - int nfds; - int always = 1; - - /* - * Initialize message - */ - mms_list_create(&dm_msg_hdr_list, sizeof (dm_msg_hdr_t), - offsetof(dm_msg_hdr_t, msg_next)); - dm_msg_create_hdr(); - - /* - * Init the drive manager - */ - if (dm_init(argc, argv)) { - TRACE((MMS_ERR, - "Unable to initialize the drive manager\n")); - DM_EXIT(DM_NO_RESTART); - } - - /* - * Create handle prefix - */ - wka->dm_hdl_prefix = mms_strapp(NULL, - "%s.%s.%s", - wka->dm_local_hostname, DMNAME, DRVNAME); - - /* - * Setup to block signals DM cares about. - * This is inherited by the worker thread so that it will not - * be interrupted by signals. - */ - sigemptyset(&new_mask); - sigaddset(&new_mask, SIGUSR1); - sigaddset(&new_mask, SIGUSR2); - sigaddset(&new_mask, SIGINT); - sigaddset(&new_mask, SIGTERM); - sigaddset(&new_mask, SIGHUP); - pthread_sigmask(SIG_BLOCK, &new_mask, &old_mask); - - /* - * DM successfully started - */ - TRACE((MMS_OPER, "DM initialized: DMName = %s, DriveName = %s", - DMNAME, DRVNAME)); - /* - * Start processing threads. - */ - pthread_create(&tid, NULL, dm_worker, wka); - - /* - * Setup signal handlers - */ - dm_setup_sig_handler(); - - /* - * Main loop - */ - while (always) { - - /* wakeup worker thread to do work */ - pthread_mutex_lock(&wka->dm_worker_mutex); - wka->dm_work_todo = 1; - pthread_cond_broadcast(&wka->dm_work_cv); - pthread_mutex_unlock(&wka->dm_worker_mutex); - - /* - * Setup for pselect - */ - nfds = 0; - if (wka->dm_flags & DM_HAVE_SESSION) { - nfds = wka->dm_mms_conn.mms_fd + 1; - FD_ZERO(&fdset); - FD_SET(wka->dm_mms_conn.mms_fd, &fdset); - tvp = NULL; - } - - /* - * pselect will unblock signals blocked earlier - */ - rc = pselect(nfds, &fdset, NULL, NULL, tvp, &old_mask); - - if (dm_caught_term) { - dm_caught_term = 0; - TRACE((MMS_DEBUG, "DM exit: caught SIGTERM")); - DM_EXIT(DM_NO_RESTART); - } - - if (dm_caught_int) { - dm_caught_int = 0; - TRACE((MMS_DEBUG, "DM restart: caught SIGINT")); - DM_EXIT(DM_RESTART); - } - - if (dm_caught_usr2) { - dm_caught_usr2 = 0; - TRACE((MMS_DEBUG, "caught SIGUSR2: " - "Waking up waiting command")); - pthread_mutex_lock(&wka->dm_tdv_close_mutex); - pthread_cond_broadcast(&wka->dm_tdv_close_cv); - pthread_mutex_unlock(&wka->dm_tdv_close_mutex); - } - - if (dm_caught_usr1) { - dm_caught_usr1 = 0; - dm_get_request(); - } - - if (rc > 0) { - /* Input pending */ - if (FD_ISSET(wka->dm_mms_conn.mms_fd, &fdset)) { - /* Read input and put it on input list */ - dm_read_input(); - } - } - - /* - * If connection to MM is closed, try reconnect - */ - if ((wka->dm_flags & DM_HAVE_SESSION) == 0) { - wka->dm_flags |= DM_SILENT; - dm_restart_session(); - wka->dm_flags &= ~DM_SILENT; - } - if (wka->dm_flags & DM_HAVE_SESSION) { - /* Try sending accept again */ - pthread_mutex_lock(&wka->dm_queue_mutex); - if (!mms_list_empty(&wka->dm_pend_ack_queue)) { - pthread_mutex_unlock(&wka->dm_queue_mutex); - dm_accept_cmds(); - pthread_mutex_lock(&wka->dm_queue_mutex); - } - pthread_mutex_unlock(&wka->dm_queue_mutex); - } - - } - return (0); -} - -/* - * Function name - * dm_restart_session(void) - * - * Parameters: - * none - * - * Description: - * restart a session with MM if it was disconnected - * - * Return code: - * none - * - * Note: - * - * - */ - -void -dm_restart_session(void) -{ - TRACE((MMS_OPER, "dm_restart_session: Restarting session")); - (void) dm_init_session(1); -} - -/* - * Function name - * dm_worker(void *arg) - * - * Parameters: - * arg work area pointer - * - * Description: - * main loop of worker thread. This is where all the work is done. - * - * Return code: - * none - * - * Note: - * - * - */ - -void * -dm_worker(void *arg) -{ - dm_wka_t *wka = arg; - int always = 1; - - TRACE((MMS_DEVP, "dm_worker: Starting worker thread")); - - dm_msg_create_hdr(); - - /* - * Remove old handles created by this DM - */ - dm_rem_old_handle(); - - /* - * Dispatch any commands from MM - */ - dm_dispatch_cmds(); - - /* - * Wait for work to do - */ - while (always) { - mms_trace_flush(); /* flush mms_trace buffer */ - /* - * Wait for work to do - */ - pthread_mutex_lock(&wka->dm_worker_mutex); - while (wka->dm_work_todo == 0) { - pthread_cond_wait(&wka->dm_work_cv, - &wka->dm_worker_mutex); - } - wka->dm_work_todo = 0; - pthread_mutex_unlock(&wka->dm_worker_mutex); - - if (wka->dm_flags & DM_HAVE_SESSION) { - /* - * Update capacity - */ - if (wka->dm_flags & DM_SEND_CAPACITY) { - (void) dm_send_capacity(&drv->drv_cap); - wka->dm_flags &= ~DM_SEND_CAPACITY; - } - /* - * Update EOF pos - */ - if (wka->dm_flags & DM_SEND_EOF_POS) { - (void) dm_send_eof_pos(); - wka->dm_flags &= ~DM_SEND_EOF_POS; - } - } - - if (wka->dm_request) { - dm_proc_request(); - } - - dm_dispatch_cmds(); - } - return (NULL); -} - -/* - * Function name - * dm_exit(int code, char *file, int line) - * - * Parameters: - * code exit code, DM_RESTART/DM_NO_RESTART - * file source file from which dm_exit is called - * line line number in file - * - * Description: - * close and flush trace file before exiting - * - * Return code: - * none - * - * Note: - * - * - */ - -/* - * Exit DM - */ -void -dm_exit(int code, char *file, int line) -{ - TRACE((MMS_OPER, "######## Exiting DM %s, from " - "file %s, line %d with %s ########", - DMNAME, file, line, - code == DM_NO_RESTART ? "DM_NO_RESTART" : "DM_RESTART")); - mms_trace_close(); - exit(code); -} - -/* - * Function name - * dm_mk_prsv_key(void) - * - * Parameters: - * none - * - * Description: - * Make a persistent reservation key - * 1st 4 bytes are a constant character array (DRV_PRSV_KEY_PFX) - * followed by 4 bytes of IP mms_address (in hex). - * - * Return code: - * none - * - * Note: - * - * - */ - -void -dm_mk_prsv_key(void) -{ - char host_name[MMS_HOST_IDENT_LEN + 1]; - char host_ip[MMS_IP_IDENT_LEN + 1]; - char *ipp; - char *cp; - int tmp; - uint32_t ip = 0; - char dumpbuf[512]; - int i; - - /* - * Get IP mms_address - a string - */ - (void) mms_host_info(host_name, host_ip); - TRACE((MMS_DEVP, "host_ip = %s", host_ip)); - - /* - * Convert to 4 hex digits. - */ - ipp = host_ip; - for (i = 0; i < 4; i++) { - cp = strchr(ipp, '.'); - if (cp != NULL) { - *cp = '\0'; - } - sscanf(ipp, "%d", &tmp); - ip |= (tmp << ((4 - i - 1) * 8)); - ipp = cp + 1; - } - - (void) memcpy((char *)drv->drv_prsv_key, DRV_PRSV_KEY_PFX, - sizeof (drv->drv_prsv_key)); - int32_to_char(ip, (uchar_t *)drv->drv_prsv_key + 4, 4); - - (void) mms_trace_dump((char *)drv->drv_prsv_key, 8, - dumpbuf, sizeof (dumpbuf)); - TRACE((MMS_DEVP, "PRSV key: %s", dumpbuf)); - - /* - * Tell driver - */ - ioctl(wka->dm_drm_fd, DRM_PRSV_KEY, drv->drv_prsv_key); -} - -/* - * Function name - * dm_silent(void) - * - * Parameters: - * none - * - * Description: - * return silent mode status - * - * Return code: - * 0 not silent - * > 0 silent - * - * Note: - * - * - */ - -int -dm_silent(void) -{ - return (wka->dm_flags & DM_SILENT); -} - -/* - * Function name - * dm_trace(mms_trace_sev_t severity, char *file, int line, char *fmt, ...) - * - * Parameters: - * severity severity of trace msg - * file source filename - * line source file line number - * fmt, ... format and args of printf - * - * Description: - * trace function for DM. If in silent mode, don't trace. - * - * Return code: - * 1 dm_trace returns 1 in macro DRV_CALL so that it may - * trace and call the function. - * - * Note: - * - * - */ - -int -dm_trace(mms_trace_sev_t severity, char *file, int line, char *fmt, ...) -{ - va_list args; - - if (!dm_silent()) { - va_start(args, fmt); - mms_trace_va(severity, file, line, fmt, args); - va_end(args); - } - return (1); -} diff --git a/usr/src/cmd/mms/dm/common/dm_ask.c b/usr/src/cmd/mms/dm/common/dm_ask.c deleted file mode 100644 index 681073f769..0000000000 --- a/usr/src/cmd/mms/dm/common/dm_ask.c +++ /dev/null @@ -1,245 +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. - */ - - -/* - * A collection of functions to ask operator questions - * - * These functions must be reworked when the operator interface is available - */ - -#include <sys/types.h> -#include <sys/siginfo.h> -#include <sys/scsi/impl/uscsi.h> -#include <stdlib.h> -#include <ctype.h> -#include <sys/varargs.h> -#include <string.h> -#include <dm_msg.h> -#include <dm_impl.h> -#include <dm_proto.h> -#include <mms_trace.h> - -static char *_SrcFile = __FILE__; - - -/* - * Function name - * dm_ask_reply(char *reply) - * - * Parameters: - * reply address of reply buffer - * - * Description: - * check standard replies from operator - * - * Return code: - * DM_REP_YES - * DM_REP_NO - * DM_REP_UNATTENDED - * DM_REP_ABORT - * DM_REP_RETRY - * DM_REP_STRING reply is none above. - * - * Note: - * - * - */ - -int -dm_ask_reply(char *reply) -{ - int rc; - - if (strcmp(reply, "yes") == 0) { - rc = DM_REP_YES; - } else if (strcmp(reply, "no") == 0) { - rc = DM_REP_NO; - } else if (strcmp(reply, "unattended") == 0) { - rc = DM_REP_UNATTENDED; - } else if (strcmp(reply, "abort") == 0) { - rc = DM_REP_ABORT; - } else if (strcmp(reply, "retry") == 0) { - rc = DM_REP_RETRY; - } else { - rc = DM_REP_STRING; - } - - return (rc); -} - -/* - * Function name - * dm_ask_preempt(void) - * - * Parameters: - * none - * - * Description: - * Ask operator if reservation should be preempted - * - * Return code: - * return code from dm_ask_reply() - * DM_REP_ERROR error - * - * Note: - * - * - */ - -int -dm_ask_preempt(void) -{ - char *reply = NULL; - int rc; - - dm_send_request(&reply, DM_6502_MSG, DM_MSG_REASON); - if (reply == NULL) { - return (DM_REP_ERROR); - } - rc = dm_ask_reply(reply); - free(reply); - return (rc); -} - -/* - * Function name - * dm_ask_freserve(void) - * - * Parameters: - * none - * - * Description: - * Ask operator if DM should reserve the tape unit by breaking - * reservation held by another host - * - * Return code: - * return code from dm_ask_reply() - * DM_REP_ERROR error - * - * Note: - * - * - */ - -int -dm_ask_freserve(void) -{ - char *reply = NULL; - int rc; - - dm_send_request(&reply, DM_6502_MSG, DM_MSG_REASON); - if (reply == NULL) { - return (DM_REP_ERROR); - } - rc = dm_ask_reply(reply); - free(reply); - return (rc); -} - -/* - * Function name - * dm_ask_write_lbl(char *from, char *to, char *pcl) - * - * Parameters: - * from from label type - * to to label type - * pcl cartridge PCL of new label - * - * Description: - * ask for permission to write a new VOL1 label - * - * Return code: - * 0 success - * -1 operator replied no or error - * - * Note: - * - * - */ - -int -dm_ask_write_lbl(char *from, char *to, char *pcl) -{ - int rc; - int ask_lsw = 0; - int ask_wo = 0; - char *reply = NULL; - - if ((drv->drv_flags & (DRV_SWITCH_LBL | DRV_ASK_SWITCH_LBL)) == 0) { - /* No switch labels */ - return (-1); - } - if ((drv->drv_flags & DRV_ASK_SWITCH_LBL) != 0) { - ask_lsw = 1; - } - - if ((drv->drv_flags & DRV_BLANK) == 0) { - /* Not a blank tape */ - if (drv->drv_flags & (DRV_SWITCH_LBL | DRV_ASK_SWITCH_LBL)) { - if ((drv->drv_flags & DRV_ASK_WRITEOVER) != 0) { - ask_wo = 1; - } - } else { - /* No writeover */ - return (-1); - } - } - - if (ask_lsw == 0 && ask_wo == 0) { - /* Write label without asking */ - return (0); - } - - if (ask_lsw == 1 && ask_wo == 1) { - dm_send_request(&reply, DM_6520_MSG, - "from", from, "to", to, "pcl", pcl, DM_MSG_REASON); - } else if (ask_lsw == 1) { - dm_send_request(&reply, DM_6519_MSG, "from", from, - "to", to, DM_MSG_REASON); - } else { - dm_send_request(&reply, DM_6518_MSG, "pcl", pcl, - DM_MSG_REASON); - } - if (reply == NULL) { - /* Can't get reply - means "no" */ - return (-1); - } - rc = dm_ask_reply(reply); - free(reply); - if (rc == DM_REP_ERROR) { - /* Ask got an error, assume "no" */ - return (-1); - } - if (rc == DM_REP_NO) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "write label denied by operator")); - return (-1); - } - - /* - * Can write label - */ - return (0); -} diff --git a/usr/src/cmd/mms/dm/common/dm_command.c b/usr/src/cmd/mms/dm/common/dm_command.c deleted file mode 100644 index 8e290aebaf..0000000000 --- a/usr/src/cmd/mms/dm/common/dm_command.c +++ /dev/null @@ -1,4660 +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. - */ - - -#include <stdlib.h> -#include <stdio.h> -#include <pwd.h> -#include <stdarg.h> -#include <ctype.h> -#include <strings.h> -#include <unistd.h> -#include <fcntl.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/mkdev.h> -#include <sys/stat.h> -#include <libgen.h> -#include <time.h> -#include <sys/varargs.h> -#include <pthread.h> -#include <sys/mkdev.h> -#include <sys/varargs.h> -#include <errno.h> -#include <sys/siginfo.h> -#include <sys/scsi/impl/uscsi.h> -#include <dlfcn.h> -#include <mms_network.h> -#include <mms_trace.h> -#include <mms_sym.h> -#include <dm_impl.h> -#include <mms_dmd.h> -#include <dm_msg.h> -#include <dm_proto.h> -#include <mms_strapp.h> -#include <mms_cat.h> - -static char *_SrcFile = __FILE__; - -/* - * Function name - * dm_bld_task(char *cmd) - * - * Parameters: - * cmd command name pointer - * - * Description: - * create a task id for use with a DMP command - * - * Return code: - * pointer to the task id. Caller must free after its use - * - * Note: - * - * - */ - -char * -dm_bld_task(char *cmd) -{ - char *task; - - task = mms_strnew("%s:%s:%s:%s:%ld-%d", wka->dm_local_hostname, - DMNAME, DRVNAME, cmd, (long)wka->dm_pid, wka->dm_counter++); - return (task); -} - -/* - * Function name - * dm_parse_err(mms_par_node_t *root, mms_list_t *err_list) - * - * Parameters: - * root root of parse tree - * err_list list of errors - * - * Description: - * trace parser error - * put the first error in the parse tree in the response - * - * Return code: - * none - * - * Note: - * - * - */ - -void -dm_parse_err(mms_par_node_t *root, mms_list_t *err_list) -{ - mms_par_node_t *node; - mms_par_err_t *err; - - if (root == NULL) { - node = NULL; - } else { - node = mms_pn_lookup(root, NULL, MMS_PN_CMD, NULL); - } - mms_list_foreach(err_list, err) { - TRACE((MMS_ERR, "Parse error: %s command, line %d, col %d, " - "near token %s, err code %d, %s", - node == NULL ? "Unknown" : mms_pn_token(node), - err->pe_line, - err->pe_col, - err->pe_token, - err->pe_code, err->pe_msg)); - } - - /* - * Return the first error message - */ - err = (mms_par_err_t *)mms_list_head(err_list); - DM_MSG_ADD((MMS_INVALID, MMS_E_SYNTAX_ERR, - "command %s, " - "line %d, " - "col %d, " - "token %s, " - "code %d, " - "%s", - node == NULL ? "unknown" : mms_pn_token(node), - err->pe_line, - err->pe_col, - err->pe_token, err->pe_code, err->pe_msg)); - - dm_resp_unacceptable(DM_6500_MSG, DM_MSG_REASON); -} - - -/* - * Function name - * dm_reader(char **cmdbuf) - * - * Parameters: - * cmdbuf pointer to the buffer address - * - * Description: - * read a message from the socket connection to MM - * - * Return code: - * > 0 number of bytes of message - * 0 EOF - * -1 error - * - * Note: - * - * - */ - -int -dm_reader(char **cmdbuf) -{ - int rc; - int err; - - pthread_mutex_lock(&wka->dm_io_mutex); - rc = mms_reader(&wka->dm_mms_conn, cmdbuf); - err = errno; - pthread_mutex_unlock(&wka->dm_io_mutex); - if (rc == 0) { - TRACE((MMS_INFO, "Socket EOF")); - } else if (rc > 0) { - TRACE((MMS_INFO, "input read: %s", *cmdbuf)); - } else { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_IO, - "Read error: %s", strerror(err))); - } - return (rc); -} - -/* - * Function name - * dm_writer_accept(char *cmdbuf) - * - * Parameters: - * cmdbuf command buffer - * - * Description: - * send accepted and unacceptable command - * - * Return code: - * 0 success - * -1 Error - * -2 incomplete write, write interrupted - * - * Note: - * - * - */ - -int -dm_writer_accept(char *cmdbuf) -{ - return (dm_writer_aux(cmdbuf, DM_WRITE_ACCEPT)); -} - -/* - * Function name - * dm_writer(char *cmdbuf) - * - * Parameters: - * cmdbuf command buffer - * - * Description: - * send a command - * - * Return code: - * 0 success - * -1 Error - * -2 incomplete write, write interrupted - * - * Note: - * - * - */ - -int -dm_writer(char *cmdbuf) -{ - return (dm_writer_aux(cmdbuf, ~DM_WRITE_ACCEPT)); -} - -/* - * Function name - * dm_writer_aux(char *cmdbuf) - * - * Parameters: - * cmdbuf command buffer - * - * Description: - * send a command - * wait until no outstanding accept before sending a command - * - * Return code: - * 0 success - * -1 Error - * -2 incomplete write, write interrupted - * - * Note: - * - * - */ - -int -dm_writer_aux(char *cmdbuf, int accept) -{ - int rc; - - TRACE((MMS_INFO, "Sending cmd: %s", cmdbuf)); - - if (accept == DM_WRITE_ACCEPT) { - /* write accept, just write it */ - pthread_mutex_lock(&wka->dm_io_mutex); - } else { - /* Wait for all accept is done */ - mms_trace_flush(); /* flush mms_trace buffer */ - pthread_mutex_lock(&wka->dm_queue_mutex); - while (!mms_list_empty(&wka->dm_pend_ack_queue)) { - pthread_cond_wait(&wka->dm_accept_cv, - &wka->dm_queue_mutex); - } - /* accept is sent */ - pthread_mutex_unlock(&wka->dm_queue_mutex); - pthread_mutex_lock(&wka->dm_io_mutex); - } - - rc = mms_writer(&wka->dm_mms_conn, cmdbuf); - pthread_mutex_unlock(&wka->dm_io_mutex); - if (rc > 0) { - if (rc == strlen(cmdbuf)) { - /* success */ - rc = 0; - } else { - /* partial write */ - rc = -2; - } - } else { - /* error */ - rc = -1; - } - return (rc); -} - - -/* - * Function name - * dm_get_task(mms_par_node_t *root) - * - * Parameters: - * root root of parse tree - * - * Description: - * return the task id of a command from the parse tree - * - * Return code: - * task id string - * - * Note: - * - * - */ - -char * -dm_get_task(mms_par_node_t *root) -{ - mms_par_node_t *node; - mms_par_node_t *tasknode; - char *task; - - if (root == NULL) { - return (NULL); /* no tree to lookup */ - } - - node = mms_pn_lookup(root, "task", MMS_PN_CLAUSE, NULL); - if (node == NULL) { - DM_MSG_ADD((MMS_INVALID, MMS_DM_E_INTERNAL, - "No task clause")); - return (NULL); - } - tasknode = mms_pn_lookup(node, NULL, MMS_PN_STRING, NULL); - if (tasknode == NULL) { - DM_MSG_ADD((MMS_INVALID, MMS_DM_E_INTERNAL, "No task id")); - return (NULL); - } - task = strdup(mms_pn_token(tasknode)); - return (task); -} - -/* - * Function name - * dm_get_hostpath - * - * Parameters: - * none - * - * Description: - * Get the host specific library path if it is set. - * - * Return code: - * 0 - good - * -1 - error - * - * Note: - * - * - */ - -int -dm_get_hostpath(void) -{ - char *show_cmd; - char *val; - char *task; - dm_command_t *cmd; - mms_par_node_t *root; - - if (drv->drv_disk_libpath) { - free(drv->drv_disk_libpath); - drv->drv_disk_libpath = NULL; - } - - task = dm_bld_task("show-hostpath"); - show_cmd = mms_strnew("show task['%s'] reportmode[namevalue] " - "match[ and( streq(DM.'DMName' '%s') " - "streq(LIBRARYACCESS.'HostName' '%s')) ] " - "report[ LIBRARYACCESS.'LibraryPath' ] " - ";", - task, drv->drv_dmname, wka->dm_local_hostname); - - cmd = dm_send_cmd(show_cmd, dm_cmd_response, task); - free(task); - free(show_cmd); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "send show hostpath error")); - goto error; - } - - root = cmd->cmd_root; - val = dm_get_attr_value(root, "LIBRARYACCESS", "LibraryPath"); - if (val != NULL) { - drv->drv_disk_libpath = strdup(val); - } - - dm_destroy_cmd(cmd); - return (0); - -error: - if (cmd != NULL) { - dm_destroy_cmd(cmd); - } - return (-1); -} - -/* - * Function name - * dm_get_default_lib_path - * - * Parameters: - * none - * - * Description: - * Get the default library path from the LIBRARY object the - * DM belongs to. - * - * Return code: - * 0 - OK - * -1 - error - * - * Note: - * - * - */ - -int -dm_get_default_lib_path(void) -{ - char *show_cmd; - char *val; - char *task; - dm_command_t *cmd; - mms_par_node_t *root; - int err; - - if (drv->drv_disk_libpath) { - free(drv->drv_disk_libpath); - drv->drv_disk_libpath = NULL; - } - - task = dm_bld_task("show-default_lib_path"); - show_cmd = mms_strnew("show task['%s'] reportmode[namevalue] " - "match[ streq(DM.'DMName' '%s') ] " - "report[ LIBRARY.'DefaultLibraryPath' ] " - ";", - task, drv->drv_dmname); - - cmd = dm_send_cmd(show_cmd, dm_cmd_response, task); - free(task); - free(show_cmd); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "send show default lib path error")); - goto error; - } - - root = cmd->cmd_root; - val = dm_get_attr_value(root, "LIBRARY", "DefaultLibraryPath"); - if (val == NULL || val[0] == '\0') { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "no library path specified")); - goto error; - } - if (mkdirp(val, 0755) == 0) { - TRACE((MMS_DEBUG, "Created DISK lib %s", val)); - } else if (errno != EEXIST) { - err = errno; - /* Unable to create it */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to access library path %s: %s", - val, strerror(err))); - goto error; - } - drv->drv_disk_libpath = strdup(val); /* save lib path */ - - dm_destroy_cmd(cmd); - return (0); - -error: - if (cmd != NULL) { - dm_destroy_cmd(cmd); - } - return (-1); -} - -/* - * Function name - * dm_get_cmd_by_task(char *task) - * - * Parameters: - * task task id - * - * Description: - * return the dm_command_t that has the task id - * - * Return code: - * dm_command_t pointer - * NULL can't find a command with matching task id - * - * Note: - * - * - */ - -dm_command_t * -dm_get_cmd_by_task(char *task) -{ - dm_command_t *cmd; - - pthread_mutex_lock(&wka->dm_queue_mutex); - mms_list_foreach(&wka->dm_cmd_queue, cmd) { - if (strcmp(task, cmd->cmd_task) == 0) { - /* found cmd with matching task */ - pthread_mutex_unlock(&wka->dm_queue_mutex); - return (cmd); - } - } - /* Not found */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "No command for task %s", task)); - pthread_mutex_unlock(&wka->dm_queue_mutex); - return (NULL); -} - -/* - * Function name - * dm_read_input(void) - * - * Parameters: - * none - * - * Description: - * read commands from the connection socket. - * If a command from MM is read, put it in a dm_command_t and - * put it in the command list. - * If a response to a command sent to MM is read, then set the - * command dispatchable. - * - * Return code: - * none - * - * Note: - * - * - */ - -/* - * dm_read_input - * Read input command from MM and put it on input list - */ -void -dm_read_input(void) -{ - char *buf = NULL; - int rc; - dm_command_t *cmd; - mms_par_node_t *root; - mms_par_node_t *node; - mms_list_t err_list; - char *task; - - rc = dm_reader(&buf); - if (rc > 0) { - /* - * Read a command - */ - rc = mms_dmpm_parse(&root, &err_list, buf); - if (rc == 1) { - dm_parse_err(root, &err_list); - mms_pe_destroy(&err_list); - mms_pn_destroy(root); - TRACE((MMS_ERR, "Command in error: %s", buf)); - free(buf); - return; - } - node = mms_pn_lookup(root, NULL, MMS_PN_CMD, NULL); - task = dm_get_task(node); - if (strcmp(mms_pn_token(node), "response") == 0) { - /* - * MM responded to a command sent by DM - */ - if (task != NULL) { - TRACE((MMS_DEBUG, "Get cmd by task %s", task)); - mms_trace_flush(); - cmd = dm_get_cmd_by_task(task); - free(task); - task = NULL; - } else { - /* Must be response unacceptable */ - TRACE((MMS_DEBUG, "Got unacceptable response")); - DM_EXIT(DM_RESTART); - } - mms_trace_flush(); - if (cmd == NULL) { - DM_MSG_SEND((DM_ADM_ERR, DM_6505_MSG, - DM_MSG_REASON)); - mms_pn_destroy(root); - free(buf); - return; - } - cmd->cmd_root = root; - TRACE((MMS_DEBUG, "Calling cmd function")); - mms_trace_flush(); - rc = (*cmd->cmd_func) (cmd); - TRACE((MMS_DEBUG, "Back from cmd function")); - mms_trace_flush(); - if (rc == DM_COMPLETE) { - /* - * Command completed - */ - pthread_mutex_lock(&cmd->cmd_done_mutex); - cmd->cmd_flags |= CMD_COMPLETE; - pthread_cond_broadcast(&cmd->cmd_done_cv); - pthread_mutex_unlock(&cmd->cmd_done_mutex); - } else { - /* - * Command not complete, free the parse tree - */ - mms_pn_destroy(root); - } - } else { - /* - * A new command from MM - */ - cmd = (dm_command_t *)malloc(sizeof (dm_command_t)); - if (cmd == NULL) { - DM_MSG_ADD((MMS_INTERNAL, - MMS_DM_E_INTERNAL, "Out of memory")); - dm_resp_unacceptable(DM_6506_MSG, - DM_MSG_REASON); - mms_pn_destroy(root); - free(buf); - return; - } - - memset(cmd, 0, sizeof (dm_command_t)); - cmd->cmd_flags |= CMD_INCOMING; - cmd->cmd_root = root; - cmd->cmd_task = task; - if (dm_setup_incoming_cmd(cmd) != 0) { /* setup cmd */ - /* Failed */ - dm_resp_unacceptable(DM_6506_MSG, - DM_MSG_REASON); - dm_destroy_cmd(cmd); - free(buf); - return; - } else { - pthread_mutex_lock(&wka->dm_queue_mutex); - mms_list_insert_tail(&wka->dm_pend_ack_queue, - cmd); - pthread_mutex_unlock(&wka->dm_queue_mutex); - } - } - } else if (rc == 0) { - /* - * Hit end of file or connection closed by MM - */ - TRACE((MMS_WARN, "dm_read_input: mms_reader error: hit EOF", - strerror(errno))); - if (buf != NULL) { - TRACE((MMS_INFO, "cmd = %s", buf)); - } - - /* - * Close current connection - */ - mms_close(&wka->dm_mms_conn); - wka->dm_mms_conn.mms_fd = -1; - wka->dm_flags &= ~DM_HAVE_SESSION; - TRACE((MMS_OPER, "Exiting DM")); - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Lost connection to MM")); - DM_MSG_SEND((DM_ADM_ERR, DM_6526_MSG, DM_MSG_REASON)); - DM_EXIT(DM_RESTART); - } else { - /* - * Got an error - */ - TRACE((MMS_CRIT, "dm_read_input: mms_reader error: %s", - strerror(errno))); - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "mms_reader error: %s", strerror(errno))); - DM_MSG_SEND((DM_ADM_ERR, DM_6526_MSG, DM_MSG_REASON)); - DM_EXIT(DM_RESTART); - } - free(buf); -} - -/* - * Function name - * dm_responded_with(dm_command_t *cmd, char *keyword) - * - * Parameters: - * cmd dm_command_t with the command - * keyword keyword of response type - * - * Description: - * Check to see if the response matches the input keyword - * - * Return code: - * 1 type matched - * 0 type not matched - * - * Note: - * - * - */ - -int -dm_responded_with(dm_command_t *cmd, char *keyword) -{ - if (mms_pn_lookup(cmd->cmd_root, keyword, MMS_PN_KEYWORD, NULL) || - mms_pn_lookup(cmd->cmd_root, keyword, MMS_PN_CLAUSE, NULL)) { - /* Found respond with keyword */ - return (1); - } else { - return (0); - } -} - -/* - * Function name - * dm_accept_cmds(void) - * - * Parameters: - * none - * - * Description: - * send accepted commands to all commands that have not been accepted - * - * Return code: - * none - * - * Note: - * - * - */ - -void -dm_accept_cmds(void) -{ - dm_command_t *cmd; - dm_command_t *next; - int rc; - - pthread_mutex_lock(&wka->dm_queue_mutex); - mms_list_foreach_safe(&wka->dm_pend_ack_queue, cmd, next) { - pthread_mutex_unlock(&wka->dm_queue_mutex); - rc = dm_accept_cmd_aux(cmd); - pthread_mutex_lock(&wka->dm_queue_mutex); - next = mms_list_next(&wka->dm_pend_ack_queue, cmd); - if (rc == 0) { - /* Accept sent, move cmd to dispatch list */ - mms_list_remove(&wka->dm_pend_ack_queue, cmd); - /* no error */ - mms_list_insert_tail(&wka->dm_cmd_queue, cmd); - pthread_mutex_lock(&wka->dm_worker_mutex); - /* wakeup worker thread to do work */ - cmd->cmd_flags |= CMD_DISPATCHABLE; - wka->dm_cmd_dispatchable = 1; - wka->dm_work_todo = 1; - pthread_cond_broadcast(&wka->dm_work_cv); - pthread_mutex_unlock(&wka->dm_worker_mutex); - } - } - if (mms_list_empty(&wka->dm_pend_ack_queue)) { - /* all commands accepted. enable writing commands */ - pthread_cond_broadcast(&wka->dm_accept_cv); - } - pthread_mutex_unlock(&wka->dm_queue_mutex); -} - -/* - * Function name - * dm_accept_cmd_aux(dm_command_t *cmd) - * - * Parameters: - * cmd dm_command_t pointer - * - * Description: - * construct an accepted command and send it - * - * Return code: - * 0 success - * -1 error - * - * Note: - * - * - */ - -int -dm_accept_cmd_aux(dm_command_t *cmd) -{ - char *accept; - int rc; - int err; - - if (cmd->cmd_task == NULL) { - cmd->cmd_task = dm_get_task(cmd->cmd_root); - } - - accept = mms_strnew("response task [ '%s' ] accepted;", cmd->cmd_task); - rc = dm_writer_accept(accept); - err = errno; - if (rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to send accept to task %s: %s", - cmd->cmd_task, strerror(err))); - dm_resp_unacceptable(DM_6507_MSG, DM_MSG_REASON); - free(accept); - return (-1); - } - free(accept); - return (0); -} - -/* - * Function name - * dm_resp_unacceptable(int msgid, ...) - * - * Parameters: - * msgid message id - * ... argument list, terminated by NULL. - * - * Description: - * send response unacceptable command - * - * Return code: - * none - * - * Note: - * - * - */ - -void -dm_resp_unacceptable(int msgid, ...) -{ - char *msgcl; - char *unacc; - int rc; - va_list args; - - /* - * Build a message clause - */ - va_start(args, msgid); - msgcl = mms_bld_msgcl(msgid, args); - va_end(args); - - unacc = mms_strnew("response unacceptable %s ;", msgcl); - free(msgcl); - - rc = dm_writer_accept(unacc); - if (rc == DM_ERROR) { - TRACE((MMS_ERR, "dm_accept_cmd: mms_writer error: %s", - strerror(errno))); - } else if (rc == DM_PARTIAL_WRITE) { - TRACE((MMS_ERR, "dm_accept_cmd: mms_writer error: %s", - strerror(errno))); - } - free(unacc); -} - -/* - * Function name - * dm_resp_error(int msgid, ...) - * - * Parameters: - * msgid message id - * ... argument list, terminated by NULL. - * - * Description: - * send response error command - * - * Return code: - * none - * - * Note: - * - * - */ - -void -dm_resp_error(char *task, int msgid, ...) -{ - char *rep; - char *msgcl; - va_list args; - int rc; - - /* - * Build a message clause - */ - va_start(args, msgid); - msgcl = mms_bld_msgcl(msgid, args); - va_end(args); - - rep = mms_strnew("response task [ '%s' ] " - "error [ '%s' '%s' ] %s ;", - task, - mms_sym_code_to_str(dm_msg_class()), - mms_sym_code_to_str(dm_msg_code()), - msgcl); - free(msgcl); - rc = dm_writer(rep); - free(rep); - if (rc == DM_ERROR) { - TRACE((MMS_ERR, "dm_resp_error: mms_writer error: %s", - strerror(errno))); - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "mms_writer error: %s", strerror(errno))); - DM_MSG_SEND((DM_ADM_ERR, DM_6526_MSG, DM_MSG_REASON)); - DM_EXIT(DM_RESTART); - } else if (rc == DM_PARTIAL_WRITE) { - TRACE((MMS_ERR, "dm_resp_error: mms_writer error: %s", - strerror(errno))); - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "mms_writer error: %s", strerror(errno))); - DM_MSG_SEND((DM_ADM_ERR, DM_6526_MSG, DM_MSG_REASON)); - DM_EXIT(DM_RESTART); - } -} - - -/* - * Function name - * dm_resp_success(char *task, char *text) - * - * Parameters: - * task task id - * text content of text clause - * - * Description: - * send response success command - * - * Return code: - * none - * - * Note: - * - * - */ - -void -dm_resp_success(char *task, char *text) -{ - char *rep; - char *textcl = NULL; - int rc; - - if (text != NULL && text[0] != '\0') { - textcl = mms_strnew("text [ '%s' ] ", text); - } - rep = mms_strnew("response task [ '%s' ] success %s;", - task, textcl == NULL ? "" : textcl); - rc = dm_writer(rep); - free(rep); - free(textcl); - if (rc == DM_ERROR) { - TRACE((MMS_ERR, "dm_resp_success: mms_writer error: %s", - strerror(errno))); - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "mms_writer error: %s", strerror(errno))); - DM_MSG_SEND((DM_ADM_ERR, DM_6526_MSG, DM_MSG_REASON)); - DM_EXIT(DM_RESTART); - } else if (rc == DM_PARTIAL_WRITE) { - TRACE((MMS_DEBUG, "dm_resp_success: mms_writer error: %s", - strerror(errno))); - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "mms_writer error: %s", strerror(errno))); - DM_MSG_SEND((DM_ADM_ERR, DM_6526_MSG, DM_MSG_REASON)); - DM_EXIT(DM_RESTART); - } -} - -/* - * Function name - * dm_send_message(char *who, char *severity, int msgid, ...) - * - * Parameters: - * who who to send message to - * severity severity of message - * msgid message id - * ... variable list of arguments of the message ending with NULL - * - * Description: - * send a message to the administrator - * - * Return code: - * none - * - * Note: - * - * - */ - -void -dm_send_message(char *who, char *severity, int msgid, ...) -{ - char *msg_cmd; - char *task; - dm_command_t *cmd; - char *msgcl; - va_list ap; - - task = dm_bld_task("message"); - va_start(ap, msgid); - msgcl = mms_bld_msgcl(msgid, ap); - va_end(ap); - msg_cmd = mms_strnew("message task [ '%s' ] who [ %s ] " - "severity [ %s ] %s ;", task, who, severity, msgcl); - cmd = dm_send_cmd(msg_cmd, dm_cmd_response, task); - free(task); - free(msgcl); - free(msg_cmd); - if (cmd == NULL || cmd->cmd_rc != 0) { - TRACE((MMS_ERR, "Unable to send message command")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return; - } - dm_destroy_cmd(cmd); - dm_msg_destroy(); /* clean up message queue */ -} - -/* - * Function name - * dm_send_ready(int msgid, ...) - * - * Parameters: - * msgid message id - * ... variable list of arguments ending with NULL - * - * Description: - * send a ready command - * - * Return code: - * - * - * Note: - * - * - */ - -int -dm_send_ready(int msgid, ...) -{ - va_list ap; - int rc; - - va_start(ap, msgid); - rc = dm_send_ready_aux(NULL, msgid, ap); - va_end(ap); - return (rc); -} - -/* - * Function name - * dm_send_ready_broken(int msgid, ...) - * - * Parameters: - * msgid message id - * ... arguments for message ending with NULL - * - * Description: - * send ready broken message - * - * Return code: - * 0 success - * -1 error - * - * Note: - * - * - */ - -int -dm_send_ready_broken(int msgid, ...) -{ - va_list ap; - int rc; - - va_start(ap, msgid); - rc = dm_send_ready_aux("broken", msgid, ap); - va_end(ap); - return (rc); -} - -/* - * Function name - * dm_send_ready_disconnected(int msgid, ...) - * - * Parameters: - * msgid message id - * ... arguments for message ending with NULL - * - * Description: - * send ready disconnected message - * - * Return code: - * 0 success - * -1 error - * - * Note: - * - * - */ - -int -dm_send_ready_disconnected(int msgid, ...) -{ - va_list ap; - int rc; - - va_start(ap, msgid); - rc = dm_send_ready_aux("disconnected", msgid, ap); - va_end(ap); - return (rc); -} - -/* - * Function name - * dm_send_ready_not(int msgid, ...) - * - * Parameters: - * msgid message id - * ... arguments for message ending with NULL - * - * Description: - * send ready not message - * - * Return code: - * 0 success - * -1 error - * - * Note: - * - * - */ - -int -dm_send_ready_not(int msgid, ...) -{ - va_list ap; - int rc; - - va_start(ap, msgid); - rc = dm_send_ready_aux("not", msgid, ap); - va_end(ap); - return (rc); -} - -/* - * Function name - * dm_send_ready_aux(char *spec, int msgid, va_list args) - * - * Parameters: - * spec specific ready type - * msgid message id - * args variable length arg list terminated by NULL - * - * Description: - * construct a ready message and send it - * - * Return code: - * 0 success - * -1 error - * - * Note: - * - * - */ - -int -dm_send_ready_aux(char *spec, int msgid, va_list args) -{ - dm_command_t *cmd; - char *ready_cmd; - char *task; - char *msgcl; - - /* - * Build a message clause - */ - msgcl = mms_bld_msgcl(msgid, args); - - task = dm_bld_task("ready"); - if (spec == NULL) { - spec = ""; - } - ready_cmd = mms_strnew("ready task['%s'] %s %s;", task, spec, msgcl); - cmd = dm_send_cmd(ready_cmd, dm_cmd_response, task); - free(task); - free(msgcl); - free(ready_cmd); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "send ready command error")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - dm_destroy_cmd(cmd); - return (0); -} - -/* - * Function name - * dm_update_capacity(void) - * - * Parameters: - * none - * - * Description: - * get capacity of cartridge and update the partition size in - * the PARTITION object. - * - * Return code: - * 0 success - * -1 error - * - * Note: - * - * - */ - -int -dm_update_capacity(void) -{ - int rc = 0; - - if (drv->drv_flags & DRV_LOADED) { - /* - * Read capacity from tape - */ - if (DRV_CALL(drv_get_capacity, (&drv->drv_cap)) == 0) { - /* update capacity */ - if (dm_send_capacity(&drv->drv_cap) != 0) { - DM_MSG_ADD((MMS_INTERNAL, - MMS_DM_E_INTERNAL, - "update capacity error")); - rc = -1; - } - } else { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "cannot get cartridge capacity")); - } - } - return (rc); -} - -/* - * Function name - * dm_send_capacity(mms_capacity_t *cap) - * - * Parameters: - * cap addr of mms_capacity_t - * - * Description: - * send capacity to MM to update capacity - * - * Return code: - * o success - * -1 error - * - * Note: - * - * - */ - -int -dm_send_capacity(mms_capacity_t *cap) -{ - char *attr_cmd; - char *task; - dm_command_t *cmd; - - if ((wka->dm_flags & DM_HAVE_SESSION) == 0) { - TRACE((MMS_ERR, "No connection to MM")); - return (-1); - } - - task = dm_bld_task("send-capacity"); - attr_cmd = mms_strnew("attribute task['%s'] " - "match[ and (streq(CARTRIDGE.'CartridgePCL' '%s') " - "streq(PARTITION.'PartitionName' '%s') " - "streq(DRIVE.'DriveName' '%s'))]" - "set[PARTITION.'PartitionSize' '%lld'] " - "set[PARTITION.'PartitionAvailable' '%lld'] " - "set[PARTITION.'PartitionPercentAvailable' '%d'] " - "set[CARTRIDGETYPE.'CartridgeTypeMediaLength' '%lld'] " - ";", - task, dca->dca_pcl, dca->dca_part_name, drv->drv_drvname, - cap->mms_max, cap->mms_avail, cap->mms_pc_avail, cap->mms_max); - - cmd = dm_send_cmd(attr_cmd, dm_cmd_response, task); - free(task); - free(attr_cmd); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "update capacity error")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - dm_destroy_cmd(cmd); - return (0); -} - -/* - * Function name - * dm_send_loaded(void) - * - * Parameters: - * none - * - * Description: - * update DriveStateHard to loaded - * - * Return code: - * 0 success - * -1 error - * - * Note: - * - * - */ - -int -dm_send_loaded(void) -{ - char *attr_cmd; - char *task; - dm_command_t *cmd; - - task = dm_bld_task("send-loaded"); - attr_cmd = mms_strnew("attribute task['%s'] " - "match[ streq(DRIVE.'DriveName' '%s') ] " - "set[DRIVE.'DriveStateHard' 'loaded'] " - "set[DRIVE.'DMName' '%s'] ;", task, DRVNAME, DMNAME); - - cmd = dm_send_cmd(attr_cmd, dm_cmd_response, task); - free(task); - free(attr_cmd); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "send loaded error")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - dm_destroy_cmd(cmd); - return (0); -} - -/* - * Function name - * dm_get_capacity(mms_par_node_t *root) - * - * Parameters: - * root pointer to the parse tree - * - * Description: - * get capacity from the response of a show command and save it - * in drv->drv_avail. - * - * Return code: - * 0 success - * -1 error - * - * Note: - * - * - */ - -int -dm_get_capacity(mms_par_node_t *root) -{ - char *val; - - /* - * Save tape capacity - */ - val = dm_get_attr_value(root, "PARTITION", "PartitionSize"); - if (val == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get partition size")); - return (-1); - } - - sscanf(val, "%lld", (int64_t *)&drv->drv_capacity); - - val = dm_get_attr_value(root, "PARTITION", "PartitionAvailable"); - if (val == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get partition available")); - return (-1); - } - - sscanf(val, "%lld", (int64_t *)&drv->drv_avail); - - val = dm_get_attr_value(root, "PARTITION", "PartitionPercentAvailable"); - if (val == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get partition % available")); - return (-1); - } - - sscanf(val, "%d", (int32_t *)&drv->drv_pc_avail); - return (0); -} - -/* - * Function name - * dm_show_mount_point(mms_par_node_t **typeroot) - * - * Parameters: - * typeroot addr of pointer to root of response parse tree - * - * Description: - * Show mount points of all cartridges that can be mounted on - * the drive controlled by this DM. - * - * Return code: - * 0 success - root of parse tree returned in typeroot. - * -1 error - * - * Note: - * - * - */ - -int -dm_show_mount_point(mms_par_node_t **typeroot) -{ - char *show_cmd; - char *task; - dm_command_t *cmd; - - /* - * Show mount points of all cartridges that can be mounted on - * the drive controlled by this DM. - */ - task = dm_bld_task("show-mount-point"); - show_cmd = mms_strnew("show task['%s'] reportmode[namevalue unique] " - "match[and(streq(DM.'DMName' '%s') " - "streq(CARTRIDGETYPE.'CartridgeShapeName' 'DISK'))] " - "report[CARTRIDGE.'CartridgeMountPoint'] " - ";", task, drv->drv_dmname); - cmd = dm_send_cmd(show_cmd, dm_cmd_response, task); - free(task); - free(show_cmd); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "show mount point error")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - - *typeroot = cmd->cmd_root; - cmd->cmd_root = NULL; - dm_destroy_cmd(cmd); - return (0); -} - -/* - * Function name - * dm_show_virt_cart_path(void) - * - * Parameters: - * none - * - * Description: - * show the path to a DISK cartridge - * - * Return code: - * pointer to path string. Caller must free after use. - * NULL can't get path - * - * Note: - * - * - */ - -char * -dm_show_virt_cart_path(void) -{ - char *show_cmd; - char *task; - mms_par_node_t *root; - dm_command_t *cmd; - char *mp; - char *fn; - char *path; - int len; - - task = dm_bld_task("show-virt-cart-type"); - show_cmd = mms_strnew("show task['%s'] reportmode[namevalue] " - "match[streq(CARTRIDGE.'CartridgePCL' '%s') ] " - "report[CARTRIDGE.'CartridgeMountPoint' CARTRIDGE.'CartridgePath' ]" - ";", task, mnt->mnt_pcl); - cmd = dm_send_cmd(show_cmd, dm_cmd_response, task); - free(task); - free(show_cmd); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "show virt cart type error")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (NULL); - } - root = cmd->cmd_root; - mp = dm_get_attr_value(root, "CARTRIDGE", "CartridgeMountPoint"); - len = strlen(mp); - if (mp[len - 1] == '/') { - mp[len - 1] = '\0'; - } - fn = dm_get_attr_value(root, "CARTRIDGE", "CartridgePath"); - - path = mms_strnew("%s/%s", mp, fn); - dm_destroy_cmd(cmd); - return (path); -} - -int -dm_show_eof_pos(void) -{ - char *show_cmd; - char *task; - mms_par_node_t *root; - dm_command_t *cmd; - char *val; - int eof; - int pmode; - - task = dm_bld_task("show-eof-pos"); - show_cmd = mms_strnew("show task['%s'] reportmode[namevalue] " - "match[ and (streq(CARTRIDGE.'CartridgePCL' '%s') " - "streq(SIDE.'SideName' '%s') " - "streq(PARTITION.'PartitionName' '%s') " - "streq(DRIVE.'DriveName' '%s'))]" - "report[ PARTITION.'PartitionEOFPos' ]" - ";", - task, dca->dca_pcl, dca->dca_side_name, dca->dca_part_name, - drv->drv_drvname); - cmd = dm_send_cmd(show_cmd, dm_cmd_response, task); - free(task); - free(show_cmd); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "show eof position error")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - root = cmd->cmd_root; - - /* - * Save EOF position - */ - val = dm_get_attr_value(root, "PARTITION", "PartitionEOFPos"); - if (val == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get EOF position")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - - drv->drv_flags &= ~DRV_VALID_EOF_POS; /* assume no eof pos */ - if (strcmp(val, "none") != 0) { - /* EOF position is valid */ - if (sscanf(val, "%lld %d %d %d %d %d", - (int64_t *)&drv->drv_eof_pos.lgclblkno, - &drv->drv_eof_pos.fileno, - &drv->drv_eof_pos.blkno, - &drv->drv_eof_pos.partition, - &eof, &pmode) == 6) { - drv->drv_eof_pos.eof = eof; - drv->drv_eof_pos.pmode = pmode; - - drv->drv_flags |= DRV_VALID_EOF_POS; - } - } - - dm_destroy_cmd(cmd); - return (0); -} - -int -dm_send_eof_pos(void) -{ - char *attr_cmd; - char *task; - dm_command_t *cmd; - - if ((wka->dm_flags & DM_HAVE_SESSION) == 0) { - TRACE((MMS_ERR, "No connection to MM")); - return (-1); - } - - task = dm_bld_task("update-eof-pos"); - if (drv->drv_flags & DRV_VALID_EOF_POS) { - attr_cmd = mms_strnew("attribute task['%s'] " - "match[ and (streq(CARTRIDGE.'CartridgePCL' '%s') " - "streq(SIDE.'SideName' '%s') " - "streq(PARTITION.'PartitionName' '%s') " - "streq(DRIVE.'DriveName' '%s'))]" - "set[PARTITION.'PartitionEOFPos' '%lld %d %d %d %d %d '] " - ";", - task, dca->dca_pcl, dca->dca_side_name, dca->dca_part_name, - drv->drv_drvname, - drv->drv_eof_pos.lgclblkno, - drv->drv_eof_pos.fileno, - drv->drv_eof_pos.blkno, - drv->drv_eof_pos.partition, - drv->drv_eof_pos.eof, - drv->drv_eof_pos.pmode); - } else { - attr_cmd = mms_strnew("attribute task['%s'] " - "match[ and (streq(CARTRIDGE.'CartridgePCL' '%s') " - "streq(SIDE.'SideName' '%s') " - "streq(PARTITION.'PartitionName' '%s') " - "streq(DRIVE.'DriveName' '%s'))]" - "unset[PARTITION.'PartitionEOFPos'] " - ";", - task, dca->dca_pcl, dca->dca_side_name, dca->dca_part_name, - drv->drv_drvname); - } - cmd = dm_send_cmd(attr_cmd, dm_cmd_response, task); - free(task); - free(attr_cmd); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "send eof position error")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - dm_destroy_cmd(cmd); - return (0); -} - -int -dm_send_write_protect(int wp) -{ - char *attr_cmd; - char *task; - dm_command_t *cmd; - - if ((wka->dm_flags & DM_HAVE_SESSION) == 0) { - TRACE((MMS_ERR, "No connection to MM")); - return (-1); - } - - task = dm_bld_task("update-write-protect"); - attr_cmd = mms_strnew("attribute task['%s'] " - "match[ and (streq(CARTRIDGE.'CartridgePCL' '%s') " - "streq(SIDE.'SideName' '%s') " - "streq(PARTITION.'PartitionName' '%s') " - "streq(DRIVE.'DriveName' '%s'))]" - "set[CARTRIDGE.'CartridgeWriteProtected' '%s'] " - ";", - task, dca->dca_pcl, dca->dca_side_name, dca->dca_part_name, - drv->drv_drvname, - wp ? "yes" : "no"); - cmd = dm_send_cmd(attr_cmd, dm_cmd_response, task); - free(task); - free(attr_cmd); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "send write protect error")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - dm_destroy_cmd(cmd); - return (0); -} - -int -dm_show_dca_info(mms_par_node_t **rt) -{ - char *show_cmd; - char *val; - char *task; - dm_command_t *cmd; - mms_par_node_t *root; - - memset(dca, 0, sizeof (drv_cart_access_t)); - task = dm_bld_task("show-dca-info"); - show_cmd = mms_strnew("show task['%s'] reportmode[namevalue] " - "match[ and( streq(DRIVE.'DriveName' '%s') " - "streq(VOLUME.'VolumeName' '%s')) ] " - "report[ " - "DRIVE.'DriveTimeMountedLast' " - "DRIVE.'DriveShapeName' " - "CARTRIDGETYPE.'CartridgeShapeName' " - "CARTRIDGETYPE.'CartridgeTypeMediaType' " - "CARTRIDGE.'CartridgeNumberMounts' " - "PARTITION.'SideName' " - "PARTITION.'PartitionName' " - "PARTITION.'CartridgeID' " - "PARTITION.'PartitionRWMode' " - "PARTITION.'PartitionSize' " - "PARTITION.'PartitionAvailable' " - "PARTITION.'PartitionPercentAvailable' " - "PARTITION.'PartitionEOFPos' " - "] ;", task, DRVNAME, mnt->mnt_volumename); - cmd = dm_send_cmd(show_cmd, dm_cmd_response, task); - free(task); - free(show_cmd); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "send show dca info error")); - goto error; - } - - root = cmd->cmd_root; - val = dm_get_attr_value(root, "PARTITION", "SideName"); - if (val == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get side name")); - goto error; - } - dca->dca_side_name = strdup(val); - - val = dm_get_attr_value(root, "PARTITION", "PartitionName"); - if (val == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get partition name")); - goto error; - } - dca->dca_part_name = strdup(val); - - val = dm_get_attr_value(root, "CARTRIDGE", "CartridgeID"); - if (val == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get cartridge ID")); - goto error; - } - dca->dca_cart_id = strdup(val); - - val = dm_get_attr_value(root, "DRIVE", "DriveTimeMountedLast"); - if (val == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get DriveTimeMountedLast")); - goto error; - } - dm_mms_to_db_time(val); - dca->dca_mounted_last = strdup(val); - - val = dm_get_attr_value(root, "CARTRIDGETYPE", "CartridgeShapeName"); - if (val == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get CartridgeShapeName")); - goto error; - } - dca->dca_cart_shape_name = strdup(val); - - val = dm_get_attr_value(root, "DRIVE", "DriveShapeName"); - if (val == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get DriveShapeName")); - goto error; - } - dca->dca_drv_shape_name = strdup(val); - - dca->dca_pcl = strdup(mnt->mnt_pcl); - - dca->dca_flags |= DRV_DCA_VALID; - *rt = cmd->cmd_root; - cmd->cmd_root = NULL; - dm_destroy_cmd(cmd); - return (0); - -error: - dm_destroy_dca(); - if (cmd != NULL) { - dm_destroy_cmd(cmd); - } - return (-1); -} - -int -dm_show_application(mms_par_node_t **rt) -{ - char *show_cmd; - char *task; - dm_command_t *cmd; - - task = dm_bld_task("show-application"); - show_cmd = mms_strnew("show task['%s'] reportmode[namevalue] " - "match[ streq(VOLUME.'VolumeName' '%s') ] " - "report[ " - "APPLICATION " - "] ;", task, mnt->mnt_volumename); - cmd = dm_send_cmd(show_cmd, dm_cmd_response, task); - free(task); - free(show_cmd); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "send show application error")); - goto error; - } - - *rt = cmd->cmd_root; - cmd->cmd_root = NULL; - dm_destroy_cmd(cmd); - return (0); - -error: - if (cmd != NULL) { - dm_destroy_cmd(cmd); - } - return (-1); -} - -int -dm_send_error(void) -{ - char *create_cmd; - char *ts; - char sense[200]; - char cdb[64]; - char *task; - dm_command_t *cmd; - - if ((wka->dm_flags & DM_HAVE_SESSION) == 0) { - TRACE((MMS_ERR, "No connection to MM")); - return (-1); - } - - /* - * Create DRIVECARTRIDGEERROR - */ - task = dm_bld_task("create-drive-cart-error"); - ts = dm_timestamp(); - create_cmd = mms_strnew("create task['%s'] " - "type [ DRIVECARTRIDGEERROR ] " - "set[DRIVECARTRIDGEERROR.'DriveName' '%s' ] " - "set[DRIVECARTRIDGEERROR.'DMName' '%s' ] " - "set[DRIVECARTRIDGEERROR.'CartridgeID' '%s' ] " - "set[DRIVECARTRIDGEERROR.'SideName' '%s' ] " - "set[DRIVECARTRIDGEERROR.'PartitionName' '%s' ] " - "set[DRIVECARTRIDGEERROR.'ApplicationName' '%s' ] " - "set[DRIVECARTRIDGEERROR.'CartridgePCL' '%s' ] " - "set[DRIVECARTRIDGEERROR.'DriveSerialNum' '%s' ] " - "set[DRIVECARTRIDGEERROR.'CartridgeShapeName' '%s' ] " - "set[DRIVECARTRIDGEERROR.'DriveShapeName' '%s' ] " - "set[DRIVECARTRIDGEERROR.'SCSICommand' '%s' ] " - "set[DRIVECARTRIDGEERROR.'TimeStamp' '%s' ] " - "set[DRIVECARTRIDGEERROR.'CDB' '%s' ] " - "set[DRIVECARTRIDGEERROR.'IOStatus' '%s' ] " - "set[DRIVECARTRIDGEERROR.'SenseKey' '%s' ] " - "set[DRIVECARTRIDGEERROR.'AdditionalSenseCode' '%2.2x' ] " - "set[DRIVECARTRIDGEERROR.'AdditionalSenseCodeQualifier' '%2.2x' ] " - "set[DRIVECARTRIDGEERROR.'SenseBytes' '%s' ] " - "set[DRIVECARTRIDGEERROR.'ErrorText' '%s' ] " - ";", - task, DRVNAME, DMNAME, - dca->dca_cart_id == NULL ? "None" : dca->dca_cart_id, - dca->dca_side_name == NULL ? "None" : dca->dca_side_name, - dca->dca_part_name == NULL ? "None" : dca->dca_part_name, - dca->dca_app_name == NULL ? "None" : dca->dca_app_name, - dca->dca_pcl == NULL ? "None" : dca->dca_pcl, - drv->drv_serial_num == NULL ? "None" : drv->drv_serial_num, - dca->dca_cart_shape_name == - NULL ? "None" : dca->dca_cart_shape_name, - dca->dca_drv_shape_name == NULL ? "None" : dca->dca_drv_shape_name, - mms_scsi_cmd(serr->se_cdb[0]), - ts, - dm_char_to_hex(serr->se_cdb, serr->se_cdblen, cdb, sizeof (cdb)), - mms_scsi_status(serr->se_status), - mms_scsi_sensekey(serr->se_senkey), - serr->se_asc, - serr->se_ascq, - serr->se_senkey == KEY_NO_SENSE ? "No sense" : - dm_char_to_hex(serr->se_sense, serr->se_senlen, - sense, sizeof (sense)), - (serr->se_err_text == NULL) ? "unknown error" : serr->se_err_text); - free(ts); - cmd = dm_send_cmd(create_cmd, dm_cmd_response, task); - free(task); - free(create_cmd); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "send drive cartridge error error")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - - dm_destroy_cmd(cmd); - return (0); -} - -int -dm_send_clean_request(void) -{ - char *clean_cmd; - char *task; - dm_command_t *cmd; - - if ((wka->dm_flags & DM_HAVE_SESSION) == 0) { - TRACE((MMS_ERR, "No connection to MM")); - return (-1); - } - - task = dm_bld_task("cleaning-request"); - clean_cmd = mms_strnew("private task['%s'] " - "set[DRIVE.'DriveNeedsCleaning' 'true'] " - ";", task); - - cmd = dm_send_cmd(clean_cmd, dm_cmd_response, task); - free(task); - free(clean_cmd); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "send drive needs cleaning error")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - - dm_destroy_cmd(cmd); - return (0); -} - -int -dm_send_statistics(void) -{ - char *create_cmd; - char *unmnttime; - char *task; - dm_command_t *cmd; - - if ((wka->dm_flags & DM_HAVE_SESSION) == 0) { - TRACE((MMS_ERR, "No connection to MM")); - return (-1); - } - - /* - * Create DRIVECARTRIDGEACCESS - */ - task = dm_bld_task("create-drive-cart-access"); - unmnttime = dm_timestamp(); - create_cmd = mms_strnew("create task['%s'] " - "type [ DRIVECARTRIDGEACCESS ] " - "set[DRIVECARTRIDGEACCESS.'DriveName' '%s' ] " - "set[DRIVECARTRIDGEACCESS.'DMName' '%s' ] " - "set[DRIVECARTRIDGEACCESS.'CartridgeID' '%s' ] " - "set[DRIVECARTRIDGEACCESS.'SideName' '%s' ] " - "set[DRIVECARTRIDGEACCESS.'PartitionName' '%s' ] " - "set[DRIVECARTRIDGEACCESS.'ApplicationName' '%s' ] " - "set[DRIVECARTRIDGEACCESS.'CartridgePCL' '%s' ] " - "set[DRIVECARTRIDGEACCESS.'DriveSerialNum' '%s' ] " - "set[DRIVECARTRIDGEACCESS.'CartridgeShapeName' '%s' ] " - "set[DRIVECARTRIDGEACCESS.'DriveShapeName' '%s' ] " - "set[DRIVECARTRIDGEACCESS.'DriveCartridgeAccessTimeMount' '%s' ] " - "set[DRIVECARTRIDGEACCESS." - "'DriveCartridgeAccessTimeUnmount' '%s' ] " - "set[DRIVECARTRIDGEACCESS." - "'DriveCartridgeAccessByteReadCount' '%lld' ] " - "set[DRIVECARTRIDGEACCESS." - "'DriveCartridgeAccessMediumByteReadCount' '%lld' ] " - "set[DRIVECARTRIDGEACCESS." - "'DriveCartridgeAccessByteWriteCount' '%lld' ] " - "set[DRIVECARTRIDGEACCESS." - "'DriveCartridgeAccessMediumByteWriteCount' '%lld' ] " - "set[DRIVECARTRIDGEACCESS." - "'DriveCartridgeAccessHardReadErrorCount' '%d' ] " - "set[DRIVECARTRIDGEACCESS." - "'DriveCartridgeAccessSoftReadErrorCount' '%d' ] " - "set[DRIVECARTRIDGEACCESS." - "'DriveCartridgeAccessHardWriteErrorCount' '%d' ] " - "set[DRIVECARTRIDGEACCESS." - "'DriveCartridgeAccessSoftWriteErrorCount' '%d' ] " - ";", task, DRVNAME, DMNAME, - dca->dca_cart_id == NULL ? "None" : dca->dca_cart_id, - dca->dca_side_name == NULL ? "None" : dca->dca_side_name, - dca->dca_part_name == NULL ? "None" : dca->dca_part_name, - dca->dca_app_name == NULL ? "None" : dca->dca_app_name, - dca->dca_pcl == NULL ? "None" : dca->dca_pcl, - drv->drv_serial_num == NULL ? "None" : drv->drv_serial_num, - dca->dca_cart_shape_name == - NULL ? "None" : dca->dca_cart_shape_name, - dca->dca_drv_shape_name == NULL ? "None" : dca->dca_drv_shape_name, - dca->dca_mounted_last, - unmnttime, - dca->dca_bytes_read, - dca->dca_bytes_read_med, - dca->dca_bytes_written, - dca->dca_bytes_written_med, - dca->dca_read_err, - dca->dca_rcvd_read_err, - dca->dca_write_err, - dca->dca_rcvd_write_err); - free(unmnttime); - cmd = dm_send_cmd(create_cmd, dm_cmd_response, task); - free(task); - free(create_cmd); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "send drive cartridge access error")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - - dm_destroy_dca(); - dm_destroy_cmd(cmd); - return (0); -} - -void -dm_destroy_dca(void) -{ - if (dca->dca_side_name) - free(dca->dca_side_name); - if (dca->dca_part_name) - free(dca->dca_part_name); - if (dca->dca_app_name) - free(dca->dca_app_name); - if (dca->dca_cart_id) - free(dca->dca_cart_id); - if (dca->dca_mounted_last) - free(dca->dca_mounted_last); - if (dca->dca_cart_shape_name) - free(dca->dca_cart_shape_name); - if (dca->dca_drv_shape_name) - free(dca->dca_drv_shape_name); - if (dca->dca_pcl) - free(dca->dca_pcl); - memset(dca, 0, sizeof (drv_cart_access_t)); -} - -char * -dm_timestamp(void) -{ - struct timeval tv; - struct tm *cl; - char *buf; - - gettimeofday(&tv, NULL); - time(&tv.tv_sec); - cl = localtime(&tv.tv_sec); - buf = mms_strnew("%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d.%3.3d", - cl->tm_year + 1900, - cl->tm_mon + 1, - cl->tm_mday, - cl->tm_hour, - cl->tm_min, - cl->tm_sec, - (int32_t)tv.tv_usec / 1000); - return (buf); -} - -void -dm_mms_to_db_time(char *db) -{ - db[4] = '-'; - db[7] = '-'; - db[13] = ':'; - db[16] = ':'; - db[19] = '.'; -} - -int -dm_send_drive_broken(void) -{ - char *attr_cmd; - char *task; - dm_command_t *cmd; - - if ((wka->dm_flags & DM_HAVE_SESSION) == 0) { - TRACE((MMS_ERR, "No connection to MM")); - return (-1); - } - - task = dm_bld_task("set-drive-broken"); - attr_cmd = mms_strnew("attribute task['%s'] " - "match[ streq(DRIVE.'DriveName' '%s') ] " - "set[DRIVE.'DriveBroken' '%s'] " - ";", task, DRVNAME, "true"); - cmd = dm_send_cmd(attr_cmd, dm_cmd_response, task); - free(attr_cmd); - free(task); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "send drive broken error")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - dm_destroy_cmd(cmd); - return (0); -} - -int -dm_send_cartridge_media_error(void) -{ - char *attr_cmd; - char *task; - dm_command_t *cmd; - - if ((wka->dm_flags & DM_HAVE_SESSION) == 0) { - TRACE((MMS_ERR, "No connection to MM")); - return (-1); - } - - task = dm_bld_task("set-cart-media-error"); - attr_cmd = mms_strnew("attribute task['%s'] " - "match[ and (streq(CARTRIDGE.'CartridgePCL' '%s') " - "streq(SIDE.'SideName' '%s') " - "streq(PARTITION.'PartitionName' '%s') " - "streq(DRIVE.'DriveName' '%s'))]" - "set[CARTRIDGE.'CartridgeMediaError' '%s'] " - ";", - task, dca->dca_pcl, dca->dca_side_name, dca->dca_part_name, - drv->drv_drvname, - "yes"); - cmd = dm_send_cmd(attr_cmd, dm_cmd_response, task); - free(attr_cmd); - free(task); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "send cartridge media error error")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - dm_destroy_cmd(cmd); - return (0); -} - -int -dm_show_drive_dmname(char **dmname) -{ - char *show_cmd; - char *task; - mms_par_node_t *root; - dm_command_t *cmd; - char *val; - - *dmname = NULL; - task = dm_bld_task("drive-dmname"); - show_cmd = mms_strnew("show task['%s'] reportmode[namevalue] " - "match[ streq(DRIVE.'DriveName' '%s') ] " - "report[DRIVE.'DMName'] ;", task, DRVNAME); - cmd = dm_send_cmd(show_cmd, dm_cmd_response, task); - free(show_cmd); - free(task); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "send show command error")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - root = cmd->cmd_root; - - /* - * Save drive dmname - */ - val = dm_get_attr_value(root, "DRIVE", "DMName"); - if (val == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get drive DMName")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - - *dmname = strdup(val); - - dm_destroy_cmd(cmd); - return (0); -} - -int -dm_show_system(mms_par_node_t ** root) -{ - char *show_cmd; - char *task; - dm_command_t *cmd; - - task = dm_bld_task("show-system"); - show_cmd = mms_strnew("show task['%s'] reportmode[namevalue] " - "report[SYSTEM] ;", task); - cmd = dm_send_cmd(show_cmd, dm_cmd_response, task); - free(show_cmd); - free(task); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to send show SYSTEM command")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - - *root = cmd->cmd_root; - cmd->cmd_root = NULL; - dm_destroy_cmd(cmd); - return (0); -} - -int -dm_show_drive(mms_par_node_t ** root) -{ - char *show_cmd; - char *task; - dm_command_t *cmd; - - task = dm_bld_task("show-drive"); - show_cmd = mms_strnew("show task['%s'] reportmode[namevalue] " - "match[ streq(DRIVE.'DriveName' '%s') ] " - "report[DRIVE] ;", - task, DRVNAME); - cmd = dm_send_cmd(show_cmd, dm_cmd_response, task); - free(show_cmd); - free(task); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "send show drive error")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - *root = cmd->cmd_root; - cmd->cmd_root = NULL; - dm_destroy_cmd(cmd); - return (0); -} - -int -dm_cmd_response(dm_command_t *cmd) -{ - mms_par_node_t *root; - mms_par_node_t *id = NULL; - mms_par_node_t *man = NULL; - mms_par_node_t *mod = NULL; - mms_par_node_t *msgid = NULL; - mms_par_node_t *work = NULL; - - root = mms_pn_lookup(cmd->cmd_root, NULL, MMS_PN_CMD, NULL); - switch (cmd->cmd_state) { - case 0: - /* - * check for accept - */ - if (dm_responded_with(cmd, "accepted")) { - TRACE((MMS_INFO, "Command %s accepted", - mms_pn_token(root))); - cmd->cmd_state++; - return (DM_CONTINUE); - } else if (dm_responded_with(cmd, "unacceptable")) { - id = mms_pn_lookup(root, "id", MMS_PN_CLAUSE, - NULL); - if (id != NULL) { - work = NULL; - man = mms_pn_lookup(id, NULL, - MMS_PN_STRING, &work); - mod = mms_pn_lookup(id, NULL, - MMS_PN_STRING, &work); - msgid = mms_pn_lookup(id, NULL, - MMS_PN_STRING, &work); - } - TRACE((MMS_ERR, "Command %s unacceptable, " - "manufacturer '%s', model '%s', msgid '%s'", - mms_pn_token(root), - man == NULL ? "[none]" : mms_pn_token(man), - mod == NULL ? "[none]" : mms_pn_token(mod), - msgid == NULL ? "[none]" : mms_pn_token(msgid))); - cmd->cmd_rc = -1; - } else if (dm_responded_with(cmd, "cancelled")) { - id = mms_pn_lookup(root, "id", MMS_PN_CLAUSE, - NULL); - if (id != NULL) { - work = NULL; - man = mms_pn_lookup(id, NULL, - MMS_PN_STRING, &work); - mod = mms_pn_lookup(id, NULL, - MMS_PN_STRING, &work); - msgid = mms_pn_lookup(id, NULL, - MMS_PN_STRING, &work); - } - TRACE((MMS_ERR, "Command %s cancelled, " - "manufacturer '%s', model '%s', msgid '%s'", - mms_pn_token(root), - man == NULL ? "[none]" : mms_pn_token(man), - mod == NULL ? "[none]" : mms_pn_token(mod), - msgid == NULL ? "[none]" : - mms_pn_token(msgid))); - cmd->cmd_rc = -1; - } - return (DM_COMPLETE); - - case 1: - /* - * check for success - */ - if (dm_responded_with(cmd, "success")) { - return (DM_COMPLETE); - } else if (dm_responded_with(cmd, "cancelled")) { - TRACE((MMS_CRIT, "Unable to config DM, " - "command cancelled")); - cmd->cmd_rc = -1; - return (DM_COMPLETE); - } else if (dm_responded_with(cmd, "error")) { - TRACE((MMS_CRIT, "Unable to config DM, " - "command had error")); - cmd->cmd_rc = -1; - return (DM_COMPLETE); - } else { - TRACE((MMS_CRIT, "Unexpected response from MM")); - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Unexpected response from MM")); - DM_MSG_SEND((DM_ADM_ERR, DM_6526_MSG, DM_MSG_REASON)); - DM_EXIT(DM_NO_RESTART); - } -default: - /* - * Should not happen - */ - TRACE((MMS_CRIT, "Unexpected cmd state: %d", cmd->cmd_state)); - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Unexpected cmd state: %d", cmd->cmd_state)); - DM_MSG_SEND((DM_ADM_ERR, DM_6526_MSG, DM_MSG_REASON)); - DM_EXIT(DM_RESTART); - } - - return (DM_COMPLETE); -} - -void -dm_dispatch_cmds(void) -{ - dm_command_t *cmd; - dm_command_t *next; - int rc = DM_NOT_COMPLETE; /* not complete yet */ - - pthread_mutex_lock(&wka->dm_worker_mutex); - while (wka->dm_cmd_dispatchable) { - wka->dm_cmd_dispatchable = 0; - pthread_mutex_unlock(&wka->dm_worker_mutex); - /* Dispatch commands */ - pthread_mutex_lock(&wka->dm_queue_mutex); - mms_list_foreach_safe(&wka->dm_cmd_queue, cmd, next) { - if (cmd->cmd_flags & CMD_DISPATCHABLE) { - cmd->cmd_flags &= ~CMD_DISPATCHABLE; - /* - * dispatch the command - */ - dm_msg_destroy(); /* clean up messages */ - if (cmd->cmd_func != NULL) { - pthread_mutex_unlock(&wka-> - dm_queue_mutex); - rc = (cmd->cmd_func) (cmd); - pthread_mutex_lock(&wka-> - dm_queue_mutex); - next = mms_list_next(&wka->dm_cmd_queue, - cmd); - } - if (rc == DM_COMPLETE) { - if (cmd->cmd_flags & CMD_INCOMING) { - /* Incoming command completes */ - mms_list_remove(&wka-> - dm_cmd_queue, cmd); - dm_destroy_cmd(cmd); - } - } - dm_msg_destroy(); /* clean up messages */ - } - } - pthread_mutex_unlock(&wka->dm_queue_mutex); - pthread_mutex_lock(&wka->dm_worker_mutex); - } - pthread_mutex_unlock(&wka->dm_worker_mutex); -} - -void -dm_destroy_cmd(dm_command_t *cmd) -{ - if (cmd->cmd_root) { - mms_pn_destroy(cmd->cmd_root); - } - if (cmd->cmd_task) { - free(cmd->cmd_task); - } - if (cmd->cmd_textcmd) { - free(cmd->cmd_textcmd); - } - free(cmd); -} - -dm_command_t * -dm_send_cmd(char *cmdbuf, int (*cmd_func) (dm_command_t *), char *task) -{ - dm_command_t *cmd; - - /* Build dm_command_t */ - cmd = (dm_command_t *)malloc(sizeof (dm_command_t)); - if (cmd == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "send command error: out of memory")); - return (NULL); - } - memset(cmd, 0, sizeof (dm_command_t)); - cmd->cmd_textcmd = strdup(cmdbuf); - cmd->cmd_func = cmd_func; - cmd->cmd_task = strdup(task); - pthread_cond_init(&cmd->cmd_done_cv, NULL); - pthread_mutex_init(&cmd->cmd_done_mutex, NULL); - - /* Put command in cmd_queue */ - pthread_mutex_lock(&wka->dm_queue_mutex); - mms_list_insert_tail(&wka->dm_cmd_queue, cmd); - pthread_mutex_unlock(&wka->dm_queue_mutex); - /* send cmd */ - if (dm_writer(cmdbuf) != 0) { - pthread_mutex_lock(&wka->dm_queue_mutex); - mms_list_remove(&wka->dm_cmd_queue, cmd); - TRACE((MMS_DEBUG, "send cmd %p removed from dm_cmd_queue", - cmd)); - pthread_mutex_unlock(&wka->dm_queue_mutex); - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_COMMUNICATION, - "unable to send command to MM: socket write error")); - dm_destroy_cmd(cmd); - return (NULL); - } - - /* - * Wait for command to complete - */ - mms_trace_flush(); - pthread_mutex_lock(&cmd->cmd_done_mutex); - while ((cmd->cmd_flags & CMD_COMPLETE) == 0) { - pthread_cond_wait(&cmd->cmd_done_cv, &cmd->cmd_done_mutex); - } - pthread_mutex_unlock(&cmd->cmd_done_mutex); - - pthread_mutex_lock(&wka->dm_queue_mutex); - mms_list_remove(&wka->dm_cmd_queue, cmd); - pthread_mutex_unlock(&wka->dm_queue_mutex); - - pthread_cond_destroy(&cmd->cmd_done_cv); - pthread_mutex_destroy(&cmd->cmd_done_mutex); - - return (cmd); -} - -int -dm_setup_incoming_cmd(dm_command_t *cmd) -{ - mms_par_node_t *root; - - mms_trace_flush(); - root = mms_pn_lookup(cmd->cmd_root, NULL, MMS_PN_CMD, NULL); - if (strcmp(mms_pn_token(root), "activate") == 0) { - cmd->cmd_func = dm_activate_cmd; - } else if (strcmp(mms_pn_token(root), "attach") == 0) { - cmd->cmd_func = dm_attach_cmd; - } else if (strcmp(mms_pn_token(root), "private") == 0) { - cmd->cmd_func = dm_dmpm_private_cmd; - } else if (strcmp(mms_pn_token(root), "load") == 0) { - cmd->cmd_func = dm_load_cmd; - } else if (strcmp(mms_pn_token(root), "identify") == 0) { - cmd->cmd_func = dm_identify_cmd; - } else if (strcmp(mms_pn_token(root), "detach") == 0) { - cmd->cmd_func = dm_detach_cmd; - } else if (strcmp(mms_pn_token(root), "unload") == 0) { - cmd->cmd_func = dm_unload_cmd; - } else if (strcmp(mms_pn_token(root), "reset") == 0) { - cmd->cmd_func = (int (*)(dm_command_t *))dm_reset_cmd; - } else if (strcmp(mms_pn_token(root), "exit") == 0) { - cmd->cmd_func = (int (*)(dm_command_t *))dm_exit_cmd; - } else { - /* Unknown command */ - DM_MSG_ADD((MMS_INVALID, MMS_DM_E_UNSUPPORTED, - "Unsupported command %s", mms_pn_token(root))); - return (-1); - } - return (0); -} - -int -dm_send_config(void) -{ - char *cfg_cmd; - char *task; - dm_command_t *cmd; - - task = dm_bld_task("config"); - cfg_cmd = dm_bld_config_cmd(task); - if (cfg_cmd == NULL) { - free(task); - return (-1); - } - cmd = dm_send_cmd(cfg_cmd, dm_cmd_response, task); - free(task); - free(cfg_cmd); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "send config command error")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - - dm_destroy_cmd(cmd); - return (0); -} - -int -dm_activate_cmd(dm_command_t *cmd) -{ - mms_par_node_t *node; - int rc; - - node = mms_pn_lookup(cmd->cmd_root, NULL, MMS_PN_KEYWORD, NULL); - if (strcmp(mms_pn_token(node), "enable") == 0) { - /* Enable DM */ - rc = dm_activate_enable(cmd); - } else if (strcmp(mms_pn_token(node), "disable") == 0) { - /* Disable DM */ - rc = dm_activate_disable(cmd); - } else if (strcmp(mms_pn_token(node), "reserve") == 0) { - /* Reserve Drive */ - rc = dm_activate_reserve(cmd); - } else if (strcmp(mms_pn_token(node), "release") == 0) { - /* Release Drive */ - rc = dm_activate_release(cmd); - } - - return (rc); -} - -/* - * Activate DM - * - send contact drive and send config - */ -int -dm_activate_enable(dm_command_t *cmd) -{ - if (drv->drv_flags & DRV_ENABLED) { - /* Already enabled */ - DM_MSG_ADD((MMS_STATE, MMS_DM_E_ENABLED, - "already enabled")); - goto error; - } - - /* - * Have to re-open the DM device to unbind the target device - * so that we may probe all the devices to find the one with - * the matching serial number. - */ - if (dm_open_dm_device() != 0) { - DM_MSG_ADD((MMS_STATE, MMS_DM_E_INTERNAL, - "reopen DM device error")); - goto error; - } - - /* - * default size of sense data - */ - drv->drv_mtee_stat_len = sizeof (struct scsi_extended_sense); - - /* - * Close all the device dynamic libraries - */ - if (wka->dm_default_lib_hdl) { - dlclose(wka->dm_default_lib_hdl); - } - if (wka->dm_dev_lib_hdl) { - dlclose(wka->dm_dev_lib_hdl); - } - - /* - * Load default device library - */ - if (dm_load_default_lib() != 0) { - goto error1; - } - - /* - * Get system options - */ - if (dm_get_system_options() != 0) { - goto error1; - } - - /* - * Get DM target path - */ - if (dm_get_target_base() != 0 || - wka->dm_target_base == NULL) { - goto error1; - } - - /* - * configure device - */ - if (dm_stat_targ_base() != 0) { - goto error1; - } - - /* - * Connect to target drive - */ - if (dm_bind_target() != 0) { - goto error1; - } - /* - * Load the device dependent library - */ - if (dm_load_devlib() != 0) { - goto error1; - } - - if (DRV_CALL(drv_rebind_target, ()) != 0) { - goto error1; - } - - if (DRV_CALL(drv_init_dev, ())) { - goto error1; - } - - /* - * Get sense data size - */ - dm_init_sense_buf(); - - if (dm_update_drivetype() != 0) { - goto error1; - } - - /* - * Make prsv key and set it in dmd. - */ - DRV_CALL(drv_mk_prsv_key, ()); - - /* - * Set up disallowed USCSI commands and ioctl - */ - DRV_CALL(drv_disallowed, ()); - - /* - * Tell driver we are ready - */ - ioctl(wka->dm_drm_fd, DRM_DM_READY, 1); - TRACE((MMS_DEVP, "main: DM is ready")); - - /* - * Send config to MM - */ - if (dm_send_config() != 0) { - goto error1; - } - - drv->drv_flags |= DRV_ENABLED; - dm_resp_success(cmd->cmd_task, NULL); - - return (DM_COMPLETE); - -error1: - (void) dm_send_ready_disconnected(DM_6501_MSG, "type", "enable", - DM_MSG_REASON); -error: - dm_resp_error(cmd->cmd_task, DM_6501_MSG, "type", "enable", - DM_MSG_REASON); - return (DM_COMPLETE); -} - -/* - * Activate DM - * - reserve the drive - */ -int -dm_activate_reserve(dm_command_t *cmd) -{ - /* - * Start timing mount time - */ - gettimeofday(&wka->dm_mnt_start, NULL); - - /* - * Get system options. Use what we know if error. - */ - if (dm_get_system_options() != 0) { - goto error; - } - - /* - * Check if reserve drive - */ - if ((wka->dm_flags & DM_RESERVE_DRIVE) == 0) { - /* Don't reserve drive */ - goto success; - } - - /* - * Reserve target - */ - if (dm_reserve_target() != 0) { - goto error; - } -success: - dm_resp_success(cmd->cmd_task, NULL); - return (DM_COMPLETE); - -error: - dm_resp_error(cmd->cmd_task, DM_6501_MSG, "type", "reserve", - DM_MSG_REASON); - return (DM_COMPLETE); -} - -int -dm_activate_release(dm_command_t *cmd) -{ - if ((wka->dm_flags & DM_RESERVE_DRIVE) == 0) { - /* Didn't reserve drive */ - dm_resp_success(cmd->cmd_task, NULL); - return (DM_COMPLETE); - } - - if (drv->drv_flags & DRV_RESERVED) { - /* - * Release is always successful. - * If there is any problem, let - * activate reserve take care of it. - */ - if (drv->drv_flags & DRV_USE_PRSV) { - /* Do persistent release */ - if (DRV_CALL(drv_prsv_register, ()) || - DRV_CALL(drv_prsv_release, ())) { - goto error; - } - /* Do SCSI release */ - } else if (DRV_CALL(drv_release, ()) != 0) { - goto error; - } - } - dm_resp_success(cmd->cmd_task, NULL); - return (DM_COMPLETE); - -error: - dm_resp_error(cmd->cmd_task, DM_6501_MSG, "type", "release", - DM_MSG_REASON); - return (DM_COMPLETE); -} - -int -dm_activate_disable(dm_command_t *cmd) -{ - /* success */ - drv->drv_flags &= ~DRV_ENABLED; - dm_resp_success(cmd->cmd_task, NULL); - - return (DM_COMPLETE); -} - -int -dm_dmpm_private_cmd(dm_command_t *cmd) -{ - int len; - - memset(mnt, 0, sizeof (drv_mount_t)); - mnt->mnt_blksize = -1; - mnt->mnt_fseq = -1; /* fseq not specified */ - if (dm_get_mount_options(cmd) != 0) { - /* had error */ - dm_resp_error(cmd->cmd_task, DM_6507_MSG, DM_MSG_REASON); - return (DM_COMPLETE); - } - /* - * If a private cmd for mounting, check to see if authorized to - * use tape - */ - if (mnt->mnt_user) { - if (dm_chk_dev_auth(mnt->mnt_user) != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "User %s is not authorized to use MMS", - mnt->mnt_user)); - dm_resp_error(cmd->cmd_task, DM_6527_MSG, - DM_MSG_REASON); - return (DM_COMPLETE); - } - } - - /* - * Set up default options - */ - if (mnt->mnt_fseq == -1) { - mnt->mnt_fseq = 1; - } - if (mnt->mnt_vid == NULL && mnt->mnt_pcl != NULL) { - mnt->mnt_vid = strdup(mnt->mnt_pcl); - } - if (mnt->mnt_fname == NULL && mnt->mnt_volumename != NULL) { - /* Filename defaults to volumename */ - mnt->mnt_fname = malloc(18); - if (mnt->mnt_fname == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "out of memory")); - dm_resp_error(cmd->cmd_task, DM_6506_MSG, - DM_MSG_REASON); - return (DM_COMPLETE); - } - memset(mnt->mnt_fname, ' ', 17); - mnt->mnt_fname[17] = '\0'; - len = strlen(mnt->mnt_volumename); - if (len > 17) { - strncpy(mnt->mnt_fname, - mnt->mnt_volumename + (len - 17), 17); - } else { - strncpy(mnt->mnt_fname, mnt->mnt_volumename, len); - } - } - if (mnt->mnt_flags & MNT_MMS) { - /* In MMS mode */ - if (!(mnt->mnt_flags & (MNT_BSD | MNT_NOBSD | MNT_MMS_TM))) { - /* set default if no TM processing option */ - mnt->mnt_flags |= MNT_MMS_TM; - } - } else { - /* - * Raw mode - */ - if (!(mnt->mnt_flags & (MNT_BSD | MNT_NOBSD | MNT_MMS_TM))) { - /* set default if no TM processing option */ - mnt->mnt_flags |= MNT_NOBSD; - } - } - - dm_resp_success(cmd->cmd_task, NULL); - - return (DM_COMPLETE); -} - -int -dm_get_mount_options(dm_command_t *cmd) -{ - mms_par_node_t *name; - mms_par_node_t *val; - mms_par_node_t *set; - mms_par_node_t *work = NULL; - char *np; - char *vp; - char *errtok; - int len; - mms_trace_sev_t sev; - - /* - * Check if mount options - */ - for (set = mms_pn_lookup(cmd->cmd_root, "set", - MMS_PN_CLAUSE, &work); - set != NULL; - set = mms_pn_lookup(cmd->cmd_root, "set", - MMS_PN_CLAUSE, &work)) { - /* look for set cap. If found then this is mount option */ - if (mms_pn_lookup(set, "cap", MMS_PN_STRING, NULL)) { - /* Mount options, clean out mnttab */ - dm_destroy_mnt(); - } - } - - work = NULL; - for (set = mms_pn_lookup(cmd->cmd_root, "set", - MMS_PN_CLAUSE, &work); - set != NULL; - set = mms_pn_lookup(cmd->cmd_root, "set", - MMS_PN_CLAUSE, &work)) { - mnt->mnt_flags &= ~MNT_PRIVILEGED; - mms_list_pair_foreach(&set->pn_arglist, name, val) { - np = mms_pn_token(name); - vp = mms_pn_token(val); - if (strcmp(np, "filename") == 0) { - dm_trim_tail(vp); - if (strlen(vp) > DRV_LBN_LEN) { - vp += (strlen(vp) - DRV_LBN_LEN); - } - dm_to_upper(vp); - mnt->mnt_fname = malloc(18); - memset(mnt->mnt_fname, ' ', 17); - mnt->mnt_fname[17] = '\0'; - len = strlen(vp); - if (len > 17) { - /* Get last 17 chars from name */ - strncpy(mnt->mnt_fname, - vp + (len - 17), 17); - } else { - strncpy(mnt->mnt_fname, vp, len); - } - } else if (strcmp(np, "volumeid") == 0) { - /* VID must be in uppercase */ - dm_to_upper(vp); - mnt->mnt_vid = malloc(7); - memset(mnt->mnt_vid, ' ', 6); - mnt->mnt_vid[6] = '\0'; - strncpy(mnt->mnt_vid, vp, strlen(vp)); - } else if (strcmp(np, "CartridgePCL") == 0) { - dm_to_upper(vp); - mnt->mnt_pcl = strdup(vp); - } else if (strcmp(np, "user") == 0) { - mnt->mnt_user = strdup(vp); - } else if (strcmp(np, "VolumeName") == 0) { - mnt->mnt_volumename = strdup(vp); - } else if (strcmp(np, "blocksize") == 0) { - sscanf(vp, "%d", &mnt->mnt_blksize); - } else if (strcmp(np, "defaultblocksize") == 0) { - sscanf(vp, "%d", &mnt->mnt_dflt_blksize); - } else if (strcmp(np, "cap") == 0) { - errtok = dm_get_capabilities(vp); - if (errtok != NULL) { - /* Have an invalid capability */ - return (-1); - } - } else if (strcmp(np, "DMMessageLevel") == 0) { - wka->dm_msg_level = mms_msg_get_severity(vp); - } else if (strcmp(np, "TraceLevel") == 0) { - (void) mms_trace_str2sev(vp, &sev); - (void) mms_trace_filter(sev); - } else if (strcmp(np, "TraceFileSize") == 0) { - (void) mms_trace_set_fsize(vp); - } else if (strcmp(np, "privileged") == 0) { - if (strcmp(vp, "true") == 0) { - mnt->mnt_flags |= MNT_PRIVILEGED; - } - } else if (strcmp(np, "SystemDiskMountTimeout") == 0) { - sscanf(vp, "%d", &drv->drv_disk_mount_timeout); - } - /* Ignore unknown attributes */ - } - } - return (0); -} - -int -dm_attach_cmd(dm_command_t *cmd) -{ - mms_par_node_t *approot; - mms_par_node_t *root; - char *handle; - struct passwd pwd; - struct passwd *pwent; - time_t t; - int err; - int i; - char tbuf[] = "YYYYMMDDhhmmss"; - uint64_t max_cap; - int try = 0; - char *val; - - if (drv->drv_flags & DRV_ATTACHED) { - /* Drive already attached */ - DM_MSG_ADD((MMS_STATE, MMS_DM_E_INTERNAL, - "already attached")); - dm_resp_error(cmd->cmd_task, DM_6508_MSG, DM_MSG_REASON); - /* - * Something is very wrong here because MM has not done - * a detach. Restart and cleanup. - */ - DM_MSG_SEND((DM_ADM_ERR, DM_6524_MSG, DM_MSG_REASON)); - DM_EXIT(DM_RESTART); - } - - /* - * Create a handle for application - */ - time(&t); - strftime(tbuf, sizeof (tbuf), "%Y""%m""%d""%H""%M""%S", localtime(&t)); - handle = mms_strnew("%s/%s.%d.%s-%s", MMS_HDL_DIR, wka->dm_hdl_prefix, - wka->dm_counter++, tbuf, mnt->mnt_pcl); - /* Replace blanks in handle with '-' */ - for (i = 0; handle[i] != '\0'; i++) { - if (handle[i] == ' ') { - handle[i] = '-'; - } - } - wka->dm_targ_hdl = handle; - wka->dm_hdl_major = wka->dm_drm_major; - - /* - * Get a minor dev number for handle which must be > 255. - */ - wka->dm_hdl_minor = dm_hdl_minor(); - TRACE((MMS_DEBUG, "Handle: %s (%d,%d)", wka->dm_targ_hdl, - wka->dm_hdl_major, wka->dm_hdl_minor)); - - if (mknod(wka->dm_targ_hdl, S_IFCHR | S_IRUSR | S_IWUSR, - makedev(wka->dm_hdl_major, wka->dm_hdl_minor))) { - err = errno; - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_MAKEHANDLE, - "make handle error: %s: %s", - wka->dm_targ_hdl, strerror(err))); - dm_resp_error(cmd->cmd_task, DM_6508_MSG, DM_MSG_REASON); - free(wka->dm_targ_hdl); - return (DM_COMPLETE); - } - - /* - * Tell dmd driver about the current minor dev number - */ - ioctl(wka->dm_drm_fd, DRM_TARG_MINOR, wka->dm_hdl_minor); - - if (mnt->mnt_user) { - /* Change owner of handle to user */ - setpwent(); /* to beginning of PW file */ - pwent = getpwnam_r(mnt->mnt_user, &pwd, - wka->dm_pwbuf, wka->dm_pwbuf_size); - endpwent(); - - if (pwent == NULL) { - /* - * Can't find user - */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_USER, - "no user")); - dm_resp_error(cmd->cmd_task, DM_6508_MSG, - DM_MSG_REASON); - free(wka->dm_targ_hdl); - return (DM_COMPLETE); - } - - if (chown(wka->dm_targ_hdl, pwent->pw_uid, pwent->pw_gid)) { - /* chown error */ - TRACE((MMS_ERR, "Can't chown to user")); - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_USER, - "cannot chown handle to user")); - dm_resp_error(cmd->cmd_task, DM_6508_MSG, - DM_MSG_REASON); - free(wka->dm_targ_hdl); - return (DM_COMPLETE); - } - } - - drv->drv_rdbytes = 0; - drv->drv_wrbytes = 0; - - - /* - * Get info from databse - */ - if (dm_show_application(&approot) != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get APPLICATION")); - dm_resp_error(cmd->cmd_task, DM_6508_MSG, - DM_MSG_REASON); - return (DM_COMPLETE); - } - - dm_destroy_dca(); - while ((dca->dca_flags & DRV_DCA_VALID) == 0 && try < 10) { - if (dm_show_dca_info(&root) != 0) { - dm_destroy_dca(); - sleep(1); - try++; - continue; - } - dca->dca_flags |= DRV_DCA_VALID; - } - - val = dm_get_attr_value(approot, "APPLICATION", "ApplicationName"); - if (val == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get application name")); - dm_resp_error(cmd->cmd_task, DM_6508_MSG, - DM_MSG_REASON); - mms_pn_destroy(root); - mms_pn_destroy(approot); - return (DM_COMPLETE); - } - dca->dca_app_name = strdup(val); - - if ((dca->dca_flags & DRV_DCA_VALID) == 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get info for DRIVECARTRIDGEACCESS")); - dm_resp_error(cmd->cmd_task, DM_6508_MSG, - DM_MSG_REASON); - mms_pn_destroy(root); - mms_pn_destroy(approot); - return (DM_COMPLETE); - } - - /* - * Get application options - */ - if (dm_get_app_options(approot) != 0 || - dm_get_part_rwmode(root) != 0 || dm_update_write_protect() != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get info for application/partition")); - dm_resp_error(cmd->cmd_task, DM_6508_MSG, - DM_MSG_REASON); - mms_pn_destroy(root); - mms_pn_destroy(approot); - return (DM_COMPLETE); - } - - /* - * Override options with mount command options - */ - if (mnt->mnt_flags & MNT_VALIDATE_VID) { - drv->drv_flags |= DRV_VALIDATE_VID; - } else if (mnt->mnt_flags & MNT_NO_VALIDATE_VID) { - drv->drv_flags &= ~DRV_VALIDATE_VID; - } - - if (mnt->mnt_flags & MNT_VALIDATE_XDATE) { - drv->drv_flags |= DRV_VALIDATE_XDATE; - } else if (mnt->mnt_flags & MNT_NO_VALIDATE_XDATE) { - drv->drv_flags &= ~DRV_VALIDATE_XDATE; - } - - if (mnt->mnt_flags & MNT_VALIDATE_FNAME) { - drv->drv_flags |= DRV_VALIDATE_FNAME; - } else if (mnt->mnt_flags & MNT_NO_VALIDATE_FNAME) { - drv->drv_flags &= ~DRV_VALIDATE_FNAME; - } - - if (mnt->mnt_flags & MNT_PREEMPT_RSV) { - wka->dm_flags &= ~DM_ASK_PREEMPT_RSV; - wka->dm_flags |= DM_PREEMPT_RSV; - } else if (mnt->mnt_flags & MNT_ASK_PREEMPT_RSV) { - wka->dm_flags &= ~DM_PREEMPT_RSV; - wka->dm_flags |= DM_ASK_PREEMPT_RSV; - } else if (mnt->mnt_flags & MNT_NO_PREEMPT_RSV) { - wka->dm_flags &= ~(DM_PREEMPT_RSV | DM_ASK_PREEMPT_RSV); - } - - if (mnt->mnt_flags & MNT_SWITCH_LBL) { - drv->drv_flags &= ~DRV_ASK_SWITCH_LBL; - drv->drv_flags |= DRV_SWITCH_LBL; - } else if (mnt->mnt_flags & MNT_ASK_SWITCH_LBL) { - drv->drv_flags &= ~DRV_SWITCH_LBL; - drv->drv_flags |= DRV_ASK_SWITCH_LBL; - } else if (mnt->mnt_flags & MNT_NO_SWITCH_LBL) { - drv->drv_flags &= ~(DRV_SWITCH_LBL | DRV_ASK_SWITCH_LBL); - } - - if (mnt->mnt_flags & MNT_WRITEOVER) { - drv->drv_flags &= ~DRV_ASK_WRITEOVER; - drv->drv_flags |= DRV_WRITEOVER; - } else if (mnt->mnt_flags & MNT_ASK_WRITEOVER) { - drv->drv_flags &= ~DRV_WRITEOVER; - drv->drv_flags |= DRV_ASK_WRITEOVER; - } else if (mnt->mnt_flags & MNT_NO_WRITEOVER) { - drv->drv_flags &= ~(DRV_WRITEOVER | DRV_ASK_WRITEOVER); - } - - /* - * Tell dmd driver the operation mode - raw/mms. - */ - ioctl(wka->dm_drm_fd, DRM_MMS_MODE, - (mnt->mnt_flags & MNT_MMS) ? 1 : 0); - - dm_trace_drv_flags(); - dm_trace_mnt_flags(); - - /* - * get tape capacity from DB - */ - if (dm_get_capacity(root) != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get info for application/partition")); - dm_resp_error(cmd->cmd_task, DM_6508_MSG, - DM_MSG_REASON); - mms_pn_destroy(root); - mms_pn_destroy(approot); - return (DM_COMPLETE); - } - max_cap = drv->drv_capacity; - - /* - * Update capacity - */ - if (drv->drv_capacity != max_cap || - drv->drv_capacity == (uint64_t)(-1LL) || - drv->drv_avail == (uint64_t)(-1LL) || - drv->drv_pc_avail == (uint32_t)(-1)) { - /* Uninitialized capacity */ - if (dm_update_capacity() != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to update capacity")); - dm_resp_error(cmd->cmd_task, DM_6508_MSG, - DM_MSG_REASON); - mms_pn_destroy(root); - mms_pn_destroy(approot); - return (DM_COMPLETE); - } - } - - mms_pn_destroy(root); - mms_pn_destroy(approot); - - /* Success */ - drv->drv_flags |= DRV_ATTACHED; - dm_resp_success(cmd->cmd_task, wka->dm_targ_hdl); - - return (DM_COMPLETE); -} - -int -dm_get_app_options(mms_par_node_t *root) -{ - mms_par_node_t *attr; - mms_par_node_t *name; - mms_par_node_t *val; - - attr = mms_pn_lookup(root, "attrlist", MMS_PN_CLAUSE, NULL); - if (attr == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get attrlist")); - mms_pn_destroy(root); - return (-1); - } - - mms_list_pair_foreach(&attr->pn_arglist, name, val) { - if (strcmp(mms_pn_token(name), "ValidateFileName") == 0) { - if (strcmp(mms_pn_token(val), "yes") == 0) { - drv->drv_flags |= DRV_VALIDATE_FNAME; - } else { - drv->drv_flags &= ~DRV_VALIDATE_FNAME; - } - } else if (strcmp(mms_pn_token(name), - "ValidateVolumeID") == 0) { - if (strcmp(mms_pn_token(val), "yes") == 0) { - drv->drv_flags |= DRV_VALIDATE_VID; - } else { - drv->drv_flags &= ~DRV_VALIDATE_VID; - } - } else if (strcmp(mms_pn_token(name), - "ValidateExpirationDate") == 0) { - if (strcmp(mms_pn_token(val), "yes") == 0) { - drv->drv_flags |= DRV_VALIDATE_XDATE; - } else { - drv->drv_flags &= ~DRV_VALIDATE_XDATE; - } - } else if (strcmp(mms_pn_token(name), "SwitchLabel") == 0) { - drv->drv_flags &= - ~(DRV_SWITCH_LBL | DRV_ASK_SWITCH_LBL); - if (strcmp(mms_pn_token(val), "yes") == 0) { - drv->drv_flags |= DRV_SWITCH_LBL; - } else if (strcmp(mms_pn_token(val), "ask") == 0) { - drv->drv_flags |= DRV_ASK_SWITCH_LBL; - } - } else if (strcmp(mms_pn_token(name), - "WriteOverExistingData") == 0) { - drv->drv_flags &= - ~(DRV_WRITEOVER | DRV_ASK_WRITEOVER); - if (strcmp(mms_pn_token(val), "yes") == 0) { - drv->drv_flags |= DRV_WRITEOVER; - } else if (strcmp(mms_pn_token(val), "ask") == 0) { - drv->drv_flags |= DRV_ASK_WRITEOVER; - } - } else if (strcmp(mms_pn_token(name), "Retention") == 0) { - sscanf(mms_pn_token(val), "%d", - &drv->drv_retention); - } - } - - return (0); -} - -int -dm_get_part_rwmode(mms_par_node_t *root) -{ - char *val; - - val = dm_get_attr_value(root, "PARTITION", "PartitionRWMode"); - if (val == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get partition RW mode, assume readonly")); - mms_pn_destroy(root); - return (-1); - } - - if (strcmp(val, "readonly") == 0) { - mnt->mnt_flags |= MNT_READONLY; - mnt->mnt_flags &= ~MNT_READWRITE; - TRACE((MMS_DEBUG, "Volume is readonly")); - } - - return (0); -} - -int -dm_update_write_protect(void) -{ - int wp; - - /* - * Read mode sense data - */ - if (DRV_CALL(drv_get_write_protect, (&wp))) { - /* Error getting WP flag */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get WP flag")); - return (-1); - } - if (dm_send_write_protect(wp) != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "update write protect error")); - return (-1); - } - - - if (wp == 1) { - /* Cartridge is write protected */ - drv->drv_flags |= DRV_WRITEPROTECTED; - } - - return (0); -} - -int -dm_update_drivetype(void) -{ - char *attr_cmd; - char *task; - dm_command_t *cmd; - - if ((wka->dm_flags & DM_HAVE_SESSION) == 0) { - TRACE((MMS_ERR, "No connection to MM")); - return (-1); - } - - task = dm_bld_task("send-drivetype"); - attr_cmd = mms_strnew("attribute task['%s'] " - "match[ streq(DRIVE.'DriveName' '%s') ] " - "set[DRIVE.'DriveVendorID' '%s'] " - "set[DRIVE.'DriveProductID' '%s'] " - "set[DRIVE.'DriveTypeName' '%s'] " - "set[DM.'DMTargetPath' '%s'] " - ";", task, drv->drv_drvname, - drv->drv_vend, drv->drv_prod, drv->drv_typename, - wka->dm_target_base); - - cmd = dm_send_cmd(attr_cmd, dm_cmd_response, task); - free(attr_cmd); - free(task); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "update drivetype error")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - dm_destroy_cmd(cmd); - return (0); -} - -int -dm_load_cmd(dm_command_t *cmd) -{ - TRACE((MMS_DEBUG, "Loading drive")); - - /* - * If the tape is already loaded, check to see if access mode - * asks for a load command to be issued. - */ - if ((drv->drv_flags & DRV_LOADED) && (drv->drv_flags & DRV_UDATA)) { - if (mnt->mnt_flags & MNT_NOLOAD) { - /* Don't issue load command */ - dm_resp_success(cmd->cmd_task, NULL); - return (DM_COMPLETE); - } - } - - /* - * Save DRV_LOAD_FLAGS - */ - drv->drv_flags &= DRV_LOAD_FLAGS; - - /* issue a load command */ - if (DRV_CALL(drv_load, ()) != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_DRIVE, - "load failed, drive not ready")); - dm_resp_error(cmd->cmd_task, DM_6517_MSG, DM_MSG_REASON); - return (DM_COMPLETE); - } - - drv->drv_flags |= (DRV_LOADED | DRV_BOM); - - /* - * Get rid of any pending attention - */ - while (DRV_CALL(drv_tur, ()) != 0) { - ; - } - - dm_resp_success(cmd->cmd_task, NULL); - return (DM_COMPLETE); -} - - -int -dm_identify_cmd(dm_command_t *cmd) -{ - drv_vol1_t *vol1 = &drv->drv_vol1; - int rc; - char *resp; - - if ((drv->drv_flags & DRV_LOADED) == 0) { - DM_MSG_ADD((MMS_STATE, MMS_DM_E_LOAD, "drive not loaded")); - dm_resp_error(cmd->cmd_task, DM_6510_MSG, DM_MSG_REASON); - return (DM_COMPLETE); - } - - if ((mnt->mnt_flags & MNT_MMS) == 0) { - /* No MMS control */ - dm_resp_success(cmd->cmd_task, "No Signature"); - goto done; - } - - /* - * If tape has already been identified, then return VSN. - * else rewind the tape and read VOL1. - */ - - if (drv->drv_flags & DRV_IDENTIFIED) { - dm_resp_success(cmd->cmd_task, drv->drv_vid); - goto done; - } - - /* No VSN, must determine VSN */ - if (DRV_CALL(drv_rewind, ()) != 0) { - /* I/O error */ - drv->drv_flags |= DRV_LOST_POS; - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_IO, "rewind error")); - dm_resp_error(cmd->cmd_task, DM_6510_MSG, DM_MSG_REASON); - return (DM_COMPLETE); - } - - if (dm_set_label_blksize() != 0) { - /* I/O error */ - TRACE((MMS_DEBUG, "Can't set label blksize")); - dm_resp_error(cmd->cmd_task, DM_6510_MSG, DM_MSG_REASON); - return (DM_COMPLETE); - } - - drv->drv_vid[0] = '\0'; /* No VSN yet */ - - rc = DRV_CALL(drv_read, ((char *)vol1, 80)); - if (rc != 80) { - /* Did not read a label */ - drv->drv_lbl_type = DRV_NL; /* a non labeled tape */ - } else if (strncmp(vol1->vol1_id, VOL1_ID, 4) == 0) { - drv->drv_lbl_type = DRV_AL; - } else { - drv->drv_lbl_type = DRV_NL; - } - if (rc > 0 || (drv->drv_flags & DRV_TM)) { - /* - * Read something ot hit a tapemark. Not a blank tape anymore. - */ - drv->drv_flags &= ~DRV_BLANK; - } - if (drv->drv_flags & DRV_EOM) { - /* Hit EOM, must be a blank tape */ - drv->drv_flags |= DRV_BLANK; - } - - if (drv->drv_lbl_type == DRV_NL) { - - if (DRV_CALL(drv_rewind, ()) != 0) { - /* I/O error */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_IO, - "rewind error")); - dm_resp_error(cmd->cmd_task, DM_6510_MSG, - DM_MSG_REASON); - return (DM_COMPLETE); - } - drv->drv_fseq = 1; /* at file seq 1 */ - drv->drv_flags |= (DRV_BOF | DRV_UDATA); - if (dm_get_bof_pos() != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get BOF position")); - dm_resp_error(cmd->cmd_task, DM_6510_MSG, - DM_MSG_REASON); - return (DM_COMPLETE); - } - resp = "No Signature"; - } else { - - drv->drv_flags |= DRV_VOL1; /* has VOL1 lable */ - drv->drv_fseq = 1; /* at file seq 1 */ - if (strncmp(vol1->vol1_impid, DRV_IMPID, DRV_IMPID_LEN) == 0 || - strncmp(vol1->vol1_impid, DRV_IMPID2, DRV_IMPID_LEN) == 0) { - /* Created by SUN mms */ - drv->drv_flags |= DRV_MMS_LBL; - } - - /* Return VSN */ - strncpy(drv->drv_vid, vol1->vol1_vid, 6); - drv->drv_vid[6] = '\0'; - - /* - * Verify the mounted cartridge has the requested VSN - */ - if (drv->drv_flags & DRV_VALIDATE_VID) { - if ((mnt->mnt_flags & MNT_NO_VALIDATE_VID) == 0) { - if (strcmp(drv->drv_vid, mnt->mnt_vid) != 0) { - /* Wrong cartridge mounted */ - DM_MSG_ADD((MMS_INTERNAL, - MMS_DM_E_VOLUME_ID, - "incorrect volume id: " - "requested %s, mounted %s", - mnt->mnt_vid, drv->drv_vid)); - dm_resp_error(cmd->cmd_task, - DM_6510_MSG, DM_MSG_REASON); - return (DM_COMPLETE); - } - } - } - resp = drv->drv_vid[0] == '\0' ? "Null VSN" : drv->drv_vid; - } - drv->drv_flags |= DRV_IDENTIFIED; - dm_resp_success(cmd->cmd_task, resp); -done: - /* - * Calculate mount time - */ - gettimeofday(&wka->dm_mnt_done, NULL); - wka->dm_mnt_time.tv_sec = - wka->dm_mnt_done.tv_sec - wka->dm_mnt_start.tv_sec; - wka->dm_mnt_time.tv_usec = - wka->dm_mnt_done.tv_usec - wka->dm_mnt_start.tv_usec; - if (wka->dm_mnt_time.tv_usec < 0) { - wka->dm_mnt_time.tv_usec += 1000000; - wka->dm_mnt_time.tv_sec--; - } - TRACE((MMS_OPER, "Mount time = %ld.%l6.6d", - wka->dm_mnt_time.tv_sec, wka->dm_mnt_time.tv_usec)); - - return (DM_COMPLETE); -} - -int -dm_detach_cmd(dm_command_t *cmd) -{ - mms_par_node_t *handle; - mms_par_node_t *stale; - - TRACE((MMS_DEBUG, "Enter dm_detach_cmd")); - - handle = - mms_pn_lookup(cmd->cmd_root, "drivehandle", MMS_PN_CLAUSE, - NULL); - handle = mms_pn_lookup(handle, NULL, MMS_PN_STRING, NULL); - - stale = - mms_pn_lookup(cmd->cmd_root, "stale", MMS_PN_CLAUSE, NULL); - stale = mms_pn_lookup(stale, NULL, MMS_PN_KEYWORD, NULL); - - - if (wka->dm_targ_hdl == NULL) { - DM_MSG_ADD((MMS_INVALID, MMS_DM_E_NOEXISTHANDLE, - "no handle")); - dm_resp_error(cmd->cmd_task, DM_6511_MSG, DM_MSG_REASON); - return (DM_COMPLETE); - } else if (strcmp(mms_pn_token(handle), wka->dm_targ_hdl) != 0) { - /* unknown handle name */ - DM_MSG_ADD((MMS_INVALID, MMS_DM_E_BADHANDLE, - "unknown handle")); - dm_resp_error(cmd->cmd_task, DM_6511_MSG, DM_MSG_REASON); - return (DM_COMPLETE); - } else if (wka->dm_app_pid != 0) { - DM_MSG_ADD((MMS_INVALID, MMS_DM_E_HANDLEINUSE, - "handle in use by pid %d", (int)wka->dm_app_pid)); - dm_resp_error(cmd->cmd_task, DM_6511_MSG, DM_MSG_REASON); - return (DM_COMPLETE); - } else if ((drv->drv_flags & DRV_ATTACHED) == 0) { - DM_MSG_ADD((MMS_STATE, MMS_DM_E_DEVDET, "not attached")); - dm_resp_error(cmd->cmd_task, DM_6511_MSG, DM_MSG_REASON); - return (DM_COMPLETE); - } - - if (strcmp(mms_pn_token(stale), "false") == 0) { - /* - * Not a stale handle. Must be a detach from normal - * unmount processing. - * Remove the handle. - */ - - ioctl(wka->dm_drm_fd, DRM_TARG_MINOR, NULL); - - unlink(mms_pn_token(handle)); - if (wka->dm_targ_hdl != NULL) { - free(wka->dm_targ_hdl); - wka->dm_targ_hdl = NULL; - } - drv->drv_flags &= ~DRV_ATTACHED; - - /* - * Clean up mnt table - */ - dm_destroy_mnt(); - dm_destroy_dca(); - drv->drv_flags &= ~DRV_VALIDATED_FNAME; - - dm_resp_success(cmd->cmd_task, NULL); - } else { - /* - * A stale handle - */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "stale handle")); - dm_resp_error(cmd->cmd_task, DM_6511_MSG, DM_MSG_REASON); - } - - return (DM_COMPLETE); -} - -int -dm_unload_cmd(dm_command_t *cmd) -{ - int release = 0; - - if ((wka->dm_flags & (DM_DFLT_LIB_LOADED | DM_DEV_LIB_LOADED)) == 0) { - /* library not loaded */ - TRACE((MMS_DEBUG, - "dm_unload_cmd: device libraries not loaded")); - dm_resp_success(cmd->cmd_task, NULL); - return (DM_COMPLETE); - } - - /* - * Update capacity - */ - if (wka->dm_flags & DM_SEND_CAPACITY) { - if (dm_send_capacity(&drv->drv_cap) != 0) { - TRACE((MMS_ERR, "Can't send capacity")); - } else { - wka->dm_flags &= ~DM_SEND_CAPACITY; - } - } - /* - * Update EOF pos - */ - if (wka->dm_flags & DM_SEND_EOF_POS) { - if (dm_send_eof_pos()) { - TRACE((MMS_ERR, "Can't send eof pos")); - } else { - wka->dm_flags &= ~DM_SEND_EOF_POS; - } - } - - /* - * If not reserved, then reserve it to prevent st from reserving it - */ - if ((drv->drv_flags & DRV_RESERVED) == 0) { - if (DRV_CALL(drv_prsv_register, ()) == 0 && - DRV_CALL(drv_prsv_reserve, ()) == 0) { - release = 1; - } - } - - /* - * Get drive statistics before unloading - */ - if (dca->dca_flags & DRV_DCA_VALID) { - if (DRV_CALL(drv_get_statistics, ()) == 0) { - (void) dm_send_statistics(); - } - dm_destroy_dca(); - } - - /* - * Ignore any unload error so MM can unload the tape - */ - DRV_CALL(drv_unload, ()); - dm_resp_success(cmd->cmd_task, NULL); - - if (release == 1) { - DRV_CALL(drv_prsv_register, ()); - DRV_CALL(drv_prsv_release, ()); - } - - /* - * Save DRV_ATTACH flag - */ - drv->drv_flags &= DRV_LOAD_FLAGS; - - return (DM_COMPLETE); -} - -void -dm_exit_cmd(dm_command_t *cmd) -{ - dm_resp_success(cmd->cmd_task, NULL); - dm_exit(DM_NO_RESTART, __FILE__, __LINE__); -} - -void -dm_reset_cmd(dm_command_t *cmd) -{ - dm_resp_success(cmd->cmd_task, NULL); - dm_exit(DM_RESTART, __FILE__, __LINE__); -} - -void -dm_destroy_mnt(void) -{ - if (mnt->mnt_volumename) { - free(mnt->mnt_volumename); - mnt->mnt_volumename = NULL; - } - if (mnt->mnt_vid) { - free(mnt->mnt_vid); - mnt->mnt_vid = NULL; - } - if (mnt->mnt_pcl) { - free(mnt->mnt_pcl); - mnt->mnt_pcl = NULL; - } - if (mnt->mnt_fname) { - free(mnt->mnt_fname); - mnt->mnt_fname = NULL; - } - if (mnt->mnt_user) { - free(mnt->mnt_user); - mnt->mnt_user = NULL; - } - if (mnt->mnt_dencode) { - free(mnt->mnt_dencode); - mnt->mnt_dencode = NULL; - } - if (mnt->mnt_shape) { - free(mnt->mnt_shape); - mnt->mnt_shape = NULL; - } -} - -char * -dm_bld_config_cmd(char *task) -{ - int kwlen; - int i; - char *conf = NULL; - char *fmt = DRV_CONFIG; - char **cp; - drv_shape_density_t *sd; - mms_sym_t *mms_sym; - - /* - * Now, substitute values - */ - for (i = 0, cp = 0; fmt[i] != '\0'; i += kwlen) { - kwlen = 0; - if (strncmp(fmt + i, CONF_TASK, - kwlen = strlen(CONF_TASK)) == 0) { - conf = mms_strapp(conf, "%s", task); - } else if (strncmp(fmt + i, CONF_DMNAME, - kwlen = strlen(CONF_DMNAME)) == 0) { - conf = mms_strapp(conf, "%s", drv->drv_dmname); - } else if (strncmp(fmt + i, CONF_DENSITY_RW, - kwlen = strlen(CONF_DENSITY_RW)) == 0) { - for (sd = drv->drv_shape_den; - sd->drv_shape != NULL; sd++) { - if (sd->drv_den != NULL && - strcmp(sd->drv_bit, sd->drv_den) == 0) { - conf = mms_strapp(conf, - "'%s' ", sd->drv_den); - } - } - } else if (strncmp(fmt + i, CONF_DENSITY_RO, - kwlen = strlen(CONF_DENSITY_RO)) == 0) { - for (sd = drv->drv_shape_den; - sd->drv_shape != NULL; sd++) { - if (sd->drv_den == NULL) { - conf = mms_strapp(conf, - "'%s' ", sd->drv_bit); - } - } - } else if (strncmp(fmt + i, CONF_BITFORMAT, - kwlen = strlen(CONF_BITFORMAT)) == 0) { - for (mms_sym = drv->drv_density; - mms_sym->sym_token != NULL; mms_sym++) { - conf = mms_strapp(conf, - "'bit_%s' ", - mms_sym->sym_token); - } - } else if (strncmp(fmt + i, CONF_BITFORMAT_RW, - kwlen = strlen(CONF_BITFORMAT_RW)) == 0) { - for (sd = drv->drv_shape_den; - sd->drv_shape != NULL; sd++) { - if (sd->drv_den != NULL && - strcmp(sd->drv_bit, sd->drv_den) == 0) { - conf = mms_strapp(conf, - "'bit_%s' ", - sd->drv_den); - } - } - } else if (strncmp(fmt + i, CONF_BITFORMAT_RO, - kwlen = strlen(CONF_BITFORMAT_RO)) == 0) { - for (sd = drv->drv_shape_den; - sd->drv_shape != NULL; sd++) { - if (sd->drv_den == NULL) { - conf = mms_strapp(conf, - "'bit_%s'", - sd->drv_bit); - } - } - } else if (strncmp(fmt + i, CONF_BITFORMAT_WO, - kwlen = strlen(CONF_BITFORMAT_WO)) == 0) { - for (sd = drv->drv_shape_den; - sd->drv_shape != NULL; sd++) { - if (sd->drv_den != NULL && - strcmp(sd->drv_bit, sd->drv_den) != 0) { - conf = mms_strapp(conf, - "'bit_%s'", - sd->drv_bit); - } - } - } else if (strncmp(fmt + i, CONF_BIT_CLAUSE, - kwlen = strlen(CONF_BIT_CLAUSE)) == 0) { - for (sd = drv->drv_shape_den; - sd->drv_shape != NULL; sd++) { - if (dm_duplicate_bit(sd)) { - continue; - } - conf = mms_strapp(conf, - "bitformat " - "['bitformat_%s' 'bit_%s'] ", - sd->drv_bit, sd->drv_bit); - } - } else if (strncmp(fmt + i, CONF_SHAPE, - kwlen = strlen(CONF_SHAPE)) == 0) { - for (cp = drv->drv_shape; *cp != NULL; cp++) { - conf = mms_strapp(conf, - "'%s' ", *cp); - } - } else if (strncmp(fmt + i, CONF_SHAPE_RW, - kwlen = strlen(CONF_SHAPE_RW)) == 0) { - for (sd = drv->drv_shape_den; - sd->drv_shape != NULL; sd++) { - if (sd->drv_den == NULL || - strcmp(sd->drv_bit, sd->drv_den) != 0 || - dm_duplicate_shape(sd, "rw")) { - continue; - } - conf = mms_strapp(conf, - "'%s' ", sd->drv_shape); - } - } else if (strncmp(fmt + i, CONF_SHAPE_RO, - kwlen = strlen(CONF_SHAPE_RO)) == 0) { - for (sd = drv->drv_shape_den; - sd->drv_shape != NULL; sd++) { - if (sd->drv_den != NULL || - dm_rw_shape(sd->drv_shape) || - dm_duplicate_shape(sd, "ro")) { - continue; - } - conf = mms_strapp(conf, - "'%s' ", sd->drv_shape); - } - } else if (strncmp(fmt + i, CONF_DRIVE_SPEC, - kwlen = strlen(CONF_DRIVE_SPEC)) == 0) { - conf = mms_strapp(conf, - "'%s' '%s' '%s' ", drv->drv_dmname, - drv->drv_drvname, wka->dm_target_base); - } else if (strncmp(fmt + i, CONF_DRIVE_TYPE, - kwlen = strlen(CONF_DRIVE_TYPE)) == 0) { - conf = mms_strapp(conf, "%s", drv->drv_drive_type); - } else if (strncmp(fmt + i, CONF_CAP_DENSITY_CLAUSE, - kwlen = strlen(CONF_CAP_DENSITY_CLAUSE)) == 0) { - if (dm_cap_clause(&conf) != 0) { - goto err; - } - } else { - conf = mms_strnapp(conf, 1, fmt + i); - kwlen = 1; - } - } - - return (conf); - -err: - free(conf); - return (NULL); -} - -int -dm_cap_clause(char **pconf) -{ - drv_shape_density_t *sd; - char *readwrite = DRV_CAP_READWRITE; - char *writeover = DRV_CAP_WRITEOVER; - - for (sd = drv->drv_shape_den; sd->drv_shape != NULL; sd++) { - if (sd->drv_den != NULL && - strcmp(sd->drv_bit, sd->drv_den) == 0) { - /* Readwrite density */ - if (dm_cap_clause_aux(readwrite, pconf, sd) != 0) { - return (-1); - } - } else if (sd->drv_den != NULL) { - /* Writeover density */ - if (dm_cap_clause_aux(writeover, pconf, sd) != 0) { - return (-1); - } - } - } - return (0); -} - -int -dm_cap_clause_aux(char *fmt, char **pconf, drv_shape_density_t *sd) -{ - int i; - char *conf = *pconf; - int kwlen; - char *buf; - - for (i = 0; fmt[i] != '\0'; i += kwlen) { - if (strncmp(fmt + i, CONF_DRIVE_SPEC, - kwlen = strlen(CONF_DRIVE_SPEC)) == 0) { - conf = mms_strapp(conf, - "'%s' '%s' '%s' ", drv->drv_dmname, - drv->drv_drvname, wka->dm_target_base); - } else if (strncmp(fmt + i, CONF_DMNAME, - kwlen = strlen(CONF_DMNAME)) == 0) { - conf = mms_strapp(conf, "%s", drv->drv_dmname); - } else if (strncmp(fmt + i, CONF_DRIVE_TYPE, - kwlen = strlen(CONF_DRIVE_TYPE)) == 0) { - conf = mms_strapp(conf, "%s", drv->drv_drive_type); - } else if (strncmp(fmt + i, CUR_DENSITY_RW, - kwlen = strlen(CUR_DENSITY_RW)) == 0) { - conf = mms_strapp(conf, "%s", sd->drv_den); - } else if (strncmp(fmt + i, CUR_BITFORMAT_RW, - kwlen = strlen(CUR_BITFORMAT_RW)) == 0) { - conf = mms_strapp(conf, - "bit_%s", sd->drv_bit); - } else if (strncmp(fmt + i, CUR_BITFORMAT_WO, - kwlen = strlen(CUR_BITFORMAT_WO)) == 0) { - conf = mms_strapp(conf, - "bit_%s", sd->drv_bit); - } else if (strncmp(fmt + i, CUR_SHAPE_RW, - kwlen = strlen(CUR_SHAPE_RW)) == 0) { - conf = mms_strapp(conf, "%s", sd->drv_shape); - } else if (fmt[i] == '$') { - buf = mms_strnew("%-50.50", fmt + i); - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Unknown keyword %s", buf)); - free(buf); - goto err; - } else { - conf = mms_strnapp(conf, 1, fmt + i); - kwlen = 1; - } - } - - *pconf = conf; - return (0); -err: - return (-1); -} - -int -dm_rw_shape(char *shape) -{ - drv_shape_density_t *sd; - - for (sd = drv->drv_shape_den; sd->drv_shape != NULL; sd++) { - if (strcmp(sd->drv_shape, shape) == 0) { - if (sd->drv_den != NULL && - strcmp(sd->drv_bit, sd->drv_den) == 0) { - return (1); - } - } - } - return (0); -} - -int -dm_duplicate_bit(drv_shape_density_t *sd) -{ - drv_shape_density_t *sd1; - - for (sd1 = drv->drv_shape_den; sd1 < sd; sd1++) { - if (strcmp(sd1->drv_bit, sd->drv_bit) == 0) { - return (1); - } - } - return (0); -} - -int -dm_duplicate_shape(drv_shape_density_t *sd, char *type) -{ - drv_shape_density_t *sd1; - int rw; - - rw = strcmp(type, "rw") == 0; - for (sd1 = drv->drv_shape_den; sd1 < sd; sd1++) { - if (rw) { - /* Readwrite shape */ - if (sd1->drv_den != NULL && - strcmp(sd1->drv_bit, sd1->drv_den) == 0) { - if (strcmp(sd1->drv_shape, sd->drv_shape) - == 0) { - return (1); - } - } - } else { - /* Readonly shape */ - if (sd1->drv_den == NULL) { - if (strcmp(sd1->drv_shape, sd->drv_shape) - == 0) { - return (1); - } - } - } - } - return (0); -} - -/* - * drv_get_capabilities - get capabilities values from string - * If no error, return NULL, otherwise, return the token in error. - */ - -char * -dm_get_capabilities(char *tokens) -{ - char *cp; - char *tok = tokens; - mms_sym_t *mms_sym; - drv_shape_density_t *sd; - - mnt->mnt_flags = 0; - for (cp = strchr(tok, ':'); - tok[0] != '\0' && cp != NULL; - tok = cp + 1, cp = strchr(tok, ':')) { - cp[0] = '\0'; - if (strcmp(tok, "*load") == 0) { - mnt->mnt_flags &= ~MNT_NOLOAD; - } else if (strcmp(tok, "noload") == 0) { - mnt->mnt_flags |= MNT_NOLOAD; - } else if (strcmp(tok, "*rewind") == 0) { - mnt->mnt_flags &= ~MNT_NOREWIND; - } else if (strcmp(tok, "norewind") == 0) { - mnt->mnt_flags |= MNT_NOREWIND; - } else if (strcmp(tok, "fixed") == 0 || - strcmp(tok, "block") == 0) { - mnt->mnt_flags |= MNT_FIXED; - mnt->mnt_flags &= ~MNT_VARIABLE; - } else if (strcmp(tok, "variable") == 0) { - mnt->mnt_flags |= MNT_VARIABLE; - mnt->mnt_flags &= ~MNT_FIXED; - } else if (strcmp(tok, "*dflt_vldt_vid") == 0) { - mnt->mnt_flags &= ~(MNT_VALIDATE_VID | - MNT_NO_VALIDATE_VID); - } else if (strcmp(tok, "validate_vid") == 0) { - mnt->mnt_flags &= ~(MNT_VALIDATE_VID | - MNT_NO_VALIDATE_VID); - mnt->mnt_flags |= MNT_VALIDATE_VID; - } else if (strcmp(tok, "no_validate_vid") == 0) { - mnt->mnt_flags &= ~(MNT_VALIDATE_VID | - MNT_NO_VALIDATE_VID); - mnt->mnt_flags |= MNT_NO_VALIDATE_VID; - } else if (strcmp(tok, "*dflt_vldt_xdate") == 0) { - mnt->mnt_flags &= ~(MNT_VALIDATE_XDATE | - MNT_NO_VALIDATE_XDATE); - } else if (strcmp(tok, "validate_xdate") == 0) { - mnt->mnt_flags &= ~(MNT_VALIDATE_XDATE | - MNT_NO_VALIDATE_XDATE); - mnt->mnt_flags |= MNT_VALIDATE_XDATE; - } else if (strcmp(tok, "no_validate_xdate") == 0) { - mnt->mnt_flags &= ~(MNT_VALIDATE_XDATE | - MNT_NO_VALIDATE_XDATE); - mnt->mnt_flags |= MNT_NO_VALIDATE_XDATE; - } else if (strcmp(tok, "*dflt_vldt_filename") == 0) { - mnt->mnt_flags &= ~(MNT_VALIDATE_FNAME | - MNT_NO_VALIDATE_FNAME); - } else if (strcmp(tok, "validate_filename") == 0) { - mnt->mnt_flags &= ~(MNT_VALIDATE_FNAME | - MNT_NO_VALIDATE_FNAME); - mnt->mnt_flags |= MNT_VALIDATE_FNAME; - } else if (strcmp(tok, "no_validate_filename") == 0) { - mnt->mnt_flags &= ~(MNT_VALIDATE_FNAME | - MNT_NO_VALIDATE_FNAME); - mnt->mnt_flags |= MNT_NO_VALIDATE_FNAME; - } else if (strcmp(tok, "*dflt_preempt_rsv") == 0) { - mnt->mnt_flags &= ~(MNT_PREEMPT_RSV | - MNT_ASK_PREEMPT_RSV | MNT_NO_PREEMPT_RSV); - } else if (strcmp(tok, "preempt_rsv") == 0) { - mnt->mnt_flags &= ~(MNT_PREEMPT_RSV | - MNT_ASK_PREEMPT_RSV | MNT_NO_PREEMPT_RSV); - mnt->mnt_flags |= MNT_PREEMPT_RSV; - } else if (strcmp(tok, "ask_preempt_rsv") == 0) { - mnt->mnt_flags &= ~(MNT_PREEMPT_RSV | - MNT_ASK_PREEMPT_RSV | MNT_NO_PREEMPT_RSV); - mnt->mnt_flags |= MNT_ASK_PREEMPT_RSV; - } else if (strcmp(tok, "nopreempt_rsv") == 0) { - mnt->mnt_flags &= ~(MNT_PREEMPT_RSV | - MNT_ASK_PREEMPT_RSV | MNT_NO_PREEMPT_RSV); - mnt->mnt_flags |= MNT_NO_PREEMPT_RSV; - } else if (strcmp(tok, "*dflt_writeover") == 0) { - mnt->mnt_flags &= ~(MNT_WRITEOVER | - MNT_ASK_WRITEOVER | MNT_NO_WRITEOVER); - } else if (strcmp(tok, "writeover") == 0) { - mnt->mnt_flags &= ~(MNT_WRITEOVER | - MNT_ASK_WRITEOVER | MNT_NO_WRITEOVER); - mnt->mnt_flags |= MNT_WRITEOVER; - } else if (strcmp(tok, "ask_writeover") == 0) { - mnt->mnt_flags &= ~(MNT_WRITEOVER | - MNT_ASK_WRITEOVER | MNT_NO_WRITEOVER); - mnt->mnt_flags |= MNT_ASK_WRITEOVER; - } else if (strcmp(tok, "no_writeover") == 0) { - mnt->mnt_flags &= ~(MNT_WRITEOVER | - MNT_ASK_WRITEOVER | MNT_NO_WRITEOVER); - mnt->mnt_flags |= MNT_NO_WRITEOVER; - } else if (strcmp(tok, "*dflt_switch_lbl") == 0) { - mnt->mnt_flags &= ~(MNT_SWITCH_LBL | - MNT_ASK_SWITCH_LBL | MNT_NO_SWITCH_LBL); - } else if (strcmp(tok, "switch_lbl") == 0) { - mnt->mnt_flags &= ~(MNT_SWITCH_LBL | - MNT_ASK_SWITCH_LBL | MNT_NO_SWITCH_LBL); - mnt->mnt_flags |= MNT_SWITCH_LBL; - } else if (strcmp(tok, "ask_switch_lbl") == 0) { - mnt->mnt_flags &= ~(MNT_SWITCH_LBL | - MNT_ASK_SWITCH_LBL | MNT_NO_SWITCH_LBL); - mnt->mnt_flags |= MNT_ASK_SWITCH_LBL; - } else if (strcmp(tok, "no_switch_lbl") == 0) { - mnt->mnt_flags &= ~(MNT_SWITCH_LBL | - MNT_ASK_SWITCH_LBL | MNT_NO_SWITCH_LBL); - mnt->mnt_flags |= MNT_NO_SWITCH_LBL; - } else if (strcmp(tok, "mms") == 0) { - mnt->mnt_flags |= MNT_MMS; - } else if (strcmp(tok, "raw") == 0) { - mnt->mnt_flags &= ~MNT_MMS; - } else if (strcmp(tok, "*nocompression") == 0) { - mnt->mnt_flags &= ~MNT_COMPRESSION; - } else if (strcmp(tok, "compression") == 0) { - mnt->mnt_flags |= MNT_COMPRESSION; - mnt->mnt_flags &= - ~(MNT_LOW | MNT_MEDIUM | MNT_HIGH | MNT_ULTRA); - } else if (strcmp(tok, "low") == 0) { - mnt->mnt_flags &= - ~(MNT_LOW | MNT_MEDIUM | MNT_HIGH | MNT_ULTRA); - mnt->mnt_flags |= MNT_LOW; - } else if (strcmp(tok, "medium") == 0) { - mnt->mnt_flags &= - ~(MNT_LOW | MNT_MEDIUM | MNT_HIGH | MNT_ULTRA); - mnt->mnt_flags |= MNT_MEDIUM; - } else if (strcmp(tok, "high") == 0) { - mnt->mnt_flags &= - ~(MNT_LOW | MNT_MEDIUM | MNT_HIGH | MNT_ULTRA); - mnt->mnt_flags |= MNT_HIGH; - } else if (strcmp(tok, "ultra") == 0) { - mnt->mnt_flags &= - ~(MNT_LOW | MNT_MEDIUM | MNT_HIGH | MNT_ULTRA); - mnt->mnt_flags |= MNT_ULTRA; - } else if (strcmp(tok, "mms_tm") == 0) { - mnt->mnt_flags &= - ~(MNT_BSD | MNT_NOBSD | MNT_MMS_TM); - mnt->mnt_flags |= MNT_MMS_TM; - } else if (strcmp(tok, "st_bsd") == 0) { - mnt->mnt_flags &= - ~(MNT_BSD | MNT_NOBSD | MNT_MMS_TM); - mnt->mnt_flags |= MNT_BSD; - } else if (strcmp(tok, "st_nobsd") == 0) { - mnt->mnt_flags &= - ~(MNT_BSD | MNT_NOBSD | MNT_MMS_TM); - mnt->mnt_flags |= MNT_NOBSD; - } else if (strcmp(tok, "readonly") == 0) { - mnt->mnt_flags |= MNT_READONLY; - mnt->mnt_flags &= ~MNT_READWRITE; - } else if (strcmp(tok, "readwrite") == 0) { - mnt->mnt_flags &= ~MNT_READONLY; - mnt->mnt_flags |= MNT_READWRITE; - } else if (strcmp(tok, "*readwrite") == 0) { - mnt->mnt_flags &= ~(MNT_READONLY | MNT_READWRITE); - } else if (strcmp(tok, "al") == 0 || - strcmp(tok, "*default_lbl") == 0) { - mnt->mnt_lbl_type = DRV_AL; - } else if (strcmp(tok, "sl") == 0) { - mnt->mnt_lbl_type = DRV_SL; - } else if (strcmp(tok, "nl") == 0) { - mnt->mnt_lbl_type = DRV_NL; - } else if (strcmp(tok, "blp") == 0) { - mnt->mnt_lbl_type = DRV_BLP; - } else if (strcmp(tok, "*oflag") == 0) { - mnt->mnt_flags &= ~(MNT_CREAT | MNT_OLD); - } else if (strcmp(tok, "old") == 0) { - mnt->mnt_flags |= MNT_OLD; - mnt->mnt_flags &= ~MNT_CREAT; - } else if (strcmp(tok, "creat") == 0 || - strcmp(tok, "new") == 0) { - mnt->mnt_flags &= ~MNT_OLD; - mnt->mnt_flags |= MNT_CREAT; - } else if (strcmp(tok, "*auto_density") == 0) { - mnt->mnt_flags |= MNT_AUTO_DEN; - } else if (strcmp(tok, "*auto_drive") && - strcmp(tok, "*bit_unknown") && - strcmp(tok, DMNAME) && - strcmp(tok, DRVNAME) && - strcmp(tok, "*default_tm") && - strcmp(tok, wka->dm_target_base)) { - /* - * Look for drive type name - */ - if (strcmp(tok, drv->drv_drive_type) == 0) { - /* Matching drive type name */ - continue; - } - /* - * Look for read/write supported density - */ - if (mms_sym = dm_sym_in(drv->drv_density, tok)) { - for (sd = drv->drv_shape_den; - sd->drv_shape != NULL; sd++) { - if (sd->drv_den != NULL && - strcmp(sd->drv_bit, - sd->drv_den) != 0 && - strcmp(sd->drv_den, tok) != 0) { - break; - } - } - if (sd->drv_shape != NULL) { - /* Found a matching R/W density */ - mnt->mnt_density = mms_sym; - continue; - } - } - /* - * Look for bitformat - */ - /* skip "bit_" to get density */ - if (mms_sym = dm_sym_in(drv->drv_density, tok + 4)) { - /* Found matching bitformat */ - mnt->mnt_bitformat = mms_sym; - continue; - } - /* - * Look for matching shape - */ - for (sd = drv->drv_shape_den; - sd->drv_shape != NULL; sd++) { - if (strcmp(sd->drv_shape, tok) == 0) { - /* found a matching shape */ - break; - } - } - if (sd->drv_shape == NULL) { - /* Unknown token, error */ - DM_MSG_ADD((MMS_INVALID, MMS_DM_E_BADVAL, - "unsupported capability: %s", tok)); - return (tok); - } - } - } - - return (NULL); -} - -int -dm_drv_assigned(void) -{ - char *dmname; - - if (dm_show_drive_dmname(&dmname) != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Can't read DRIVE.'DMName'")); - return (-1); - } - if (dmname != NULL && strcmp(dmname, "none") == 0) { - /* drive not assigned */ - TRACE((MMS_DEBUG, "Drive not assigned")); - free(dmname); - return (-1); - } - - /* Drive assigned */ - TRACE((MMS_DEBUG, "Drive assigned to %s", dmname)); - free(dmname); - return (0); -} - -int -dm_get_system_options(void) -{ - mms_par_node_t *root; - char *val; - - if (dm_show_system(&root) != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "cannot get SYSTEM attributes")); - return (-1); - } - - /* - * Save system options - */ - - val = dm_get_attr_value(root, "SYSTEM", "PreemptReservation"); - if (val == NULL) { - mms_pn_destroy(root); - return (-1); - } - - wka->dm_flags &= ~(DM_PREEMPT_RSV | DM_ASK_PREEMPT_RSV); - if (strcmp(val, "yes") == 0) { - wka->dm_flags |= DM_PREEMPT_RSV; - } else if (strcmp(val, "ask") == 0) { - wka->dm_flags &= ~DM_ASK_PREEMPT_RSV; - } - - val = dm_get_attr_value(root, "SYSTEM", "DefaultBlocksize"); - if (val == NULL) { - mms_pn_destroy(root); - return (-1); - } - - sscanf(val, "%d", &drv->drv_dflt_blksize); - mms_pn_destroy(root); - - /* - * Get attributes from drive - */ - if (dm_show_drive(&root) != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "cannot get DRIVE attributes")); - return (-1); - } - - /* - * Save drive options - */ - - val = dm_get_attr_value(root, "DRIVE", "ReserveDrive"); - if (val == NULL) { - mms_pn_destroy(root); - return (-1); - } - if (strcmp(val, "yes") == 0) { - wka->dm_flags |= DM_RESERVE_DRIVE; - } else { - wka->dm_flags &= ~DM_RESERVE_DRIVE; - } - - val = dm_get_attr_value(root, "DRIVE", "DriveSerialNum"); - if (val == NULL) { - mms_pn_destroy(root); - return (-1); - } - memset(drv->drv_serial_num, 0, sizeof (drv->drv_serial_num)); - strncpy(drv->drv_serial_num, val, sizeof (drv->drv_serial_num) - 1); - mms_pn_destroy(root); - return (0); -} - -void -dm_send_request(char **reply, int msgid, ...) -{ - char *req_cmd; - char *task; - mms_par_node_t *root; - dm_command_t *cmd; - mms_par_node_t *text; - mms_par_node_t *val; - mms_par_node_t *work = NULL; - char *msgcl; - va_list args; - - *reply = NULL; - task = dm_bld_task("request"); - va_start(args, msgid); - msgcl = mms_bld_msgcl(msgid, args); - va_end(args); - req_cmd = mms_strnew("request task ['%s'] type[DM] " - "priority ['1000'] %s ;", task, msgcl); - cmd = dm_send_cmd(req_cmd, dm_cmd_response, task); - free(req_cmd); - free(task); - free(msgcl); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to send request")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return; - } - root = cmd->cmd_root; - - /* - * Get reply - */ - text = mms_pn_lookup(root, "text", MMS_PN_CLAUSE, NULL); - /* Skip down to the replied value */ - val = mms_pn_lookup(text, NULL, MMS_PN_STRING, &work); - val = mms_pn_lookup(text, NULL, MMS_PN_STRING, &work); - val = mms_pn_lookup(text, NULL, MMS_PN_STRING, &work); - *reply = val->pn_string; - val->pn_string = NULL; - - dm_destroy_cmd(cmd); -} - -char * -dm_get_attr_value(mms_par_node_t *root, char *obj, char *attr) -{ - mms_par_node_t *name; - mms_par_node_t *val; - mms_par_node_t *work = NULL; - - name = mms_pn_lookup(root, attr, MMS_PN_STRING, &work); - if (name == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "%s.'%s' not found", obj, attr)); - return (NULL); - } - - val = mms_pn_lookup(root, "", MMS_PN_STRING, &work); - if (val == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "%s.'%s' has no value", obj, attr)); - return (NULL); - } - TRACE((MMS_DEBUG, "'%s' '%s'", attr, mms_pn_token(val))); - return (mms_pn_token(val)); -} - -int -dm_update_bitformat(void) -{ - int den; - mms_sym_t *mms_sym; - char *cmdbuf; - char *task; - dm_command_t *cmd; - - /* - * Get current density - */ - if (DRV_CALL(drv_get_density, (&den, NULL)) != 0) { - return (-1); - } - - /* - * If current density matches density of requested bitformat density, - * then no need to update. - */ - if (mnt->mnt_bitformat != NULL) { - if (den == (mnt->mnt_bitformat->sym_code & 0xff)) { - return (0); - } - } - - /* - * Lookup density name - */ - for (mms_sym = drv->drv_density; mms_sym->sym_token != NULL; - mms_sym++) { - if (mms_sym->sym_code == den) { - break; - } - } - if (mms_sym->sym_token == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_DENSITY, - "Unsupported density 0x%x", den)); - return (-1); - } - mnt->mnt_bitformat = mms_sym; - - /* - * Update bitformat - */ - task = dm_bld_task("update-bitformat"); - cmdbuf = mms_strnew("attribute task['%s'] " - "match[ and (streq(CARTRIDGE.'CartridgePCL' '%s') " - "streq(SIDE.'SideName' '%s') " - "streq(PARTITION.'PartitionName' '%s') " - "streq(DRIVE.'DriveName' '%s'))]" - "set [ PARTITION.'PartitionBitFormat' 'bitformat_%s' ] ;", - task, dca->dca_pcl, dca->dca_side_name, dca->dca_part_name, - drv->drv_drvname, - mms_sym->sym_token); - cmd = dm_send_cmd(cmdbuf, dm_cmd_response, task); - free(cmdbuf); - free(task); - if (cmd == NULL || cmd->cmd_rc != 0) { - TRACE((MMS_ERR, "Unable to update bitformat")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - - dm_destroy_cmd(cmd); - return (0); -} - -mms_sym_t * -dm_sym_in(mms_sym_t *arr, char *token) -{ - mms_sym_t *mms_sym; - - for (mms_sym = arr; mms_sym->sym_token != NULL; mms_sym++) { - if (strcmp(mms_sym->sym_token, token) == 0) { - /* mms_sym in arr */ - return (mms_sym); - } - } - /* - * Symbol not in array - */ - return (NULL); -} - -void -dm_trace_drv_flags(void) -{ - char on[] = "on"; - char off[] = "off"; - char *buf = NULL; - -#define DM_DRV_FLAGS(f) \ - buf = mms_strapp(buf, "\n" #f " - %s", \ - (drv->drv_flags & f) ? on : off); - - buf = mms_strapp(buf, "drv_flags =\n"); - - DM_DRV_FLAGS(DRV_LOADED); - DM_DRV_FLAGS(DRV_IDENTIFIED); - DM_DRV_FLAGS(DRV_MMS_LBL); - DM_DRV_FLAGS(DRV_VALIDATED_FNAME); - DM_DRV_FLAGS(DRV_VOL1); - DM_DRV_FLAGS(DRV_HDR1); - DM_DRV_FLAGS(DRV_HDR2); - DM_DRV_FLAGS(DRV_TERM_FILE); - DM_DRV_FLAGS(DRV_OPENED); - DM_DRV_FLAGS(DRV_UDATA); - DM_DRV_FLAGS(DRV_FATAL); - DM_DRV_FLAGS(DRV_ENABLED); - DM_DRV_FLAGS(DRV_BOF); - DM_DRV_FLAGS(DRV_EOF); - DM_DRV_FLAGS(DRV_TM); - DM_DRV_FLAGS(DRV_BLANK); - DM_DRV_FLAGS(DRV_ATTACHED); - DM_DRV_FLAGS(DRV_BOM); - DM_DRV_FLAGS(DRV_EOM); - DM_DRV_FLAGS(DRV_FIXED); - DM_DRV_FLAGS(DRV_VARIABLE); - DM_DRV_FLAGS(DRV_EOF1); - DM_DRV_FLAGS(DRV_EOF2); - DM_DRV_FLAGS(DRV_VALID_BOF_POS); - DM_DRV_FLAGS(DRV_LOST_POS); - DM_DRV_FLAGS(DRV_VALID_STAT); - DM_DRV_FLAGS(DRV_VALID_EOF_POS); - DM_DRV_FLAGS(DRV_UPDATE_EOF_POS); - DM_DRV_FLAGS(DRV_UPDATE_CAPACITY); - DM_DRV_FLAGS(DRV_READONLY); - DM_DRV_FLAGS(DRV_RESERVED); - DM_DRV_FLAGS(DRV_WRITEOVER); - DM_DRV_FLAGS(DRV_ASK_WRITEOVER); - DM_DRV_FLAGS(DRV_SWITCH_LBL); - DM_DRV_FLAGS(DRV_ASK_SWITCH_LBL); - DM_DRV_FLAGS(DRV_VALIDATE_FNAME); - DM_DRV_FLAGS(DRV_VALIDATE_VID); - DM_DRV_FLAGS(DRV_VALIDATE_XDATE); - DM_DRV_FLAGS(DRV_WRITEPROTECTED); - DM_DRV_FLAGS(DRV_CREAT); - DM_DRV_FLAGS(DRV_APPEND); - DM_DRV_FLAGS(DRV_USE_PRSV); - - TRACE((MMS_DEBUG, buf)); - free(buf); -} - -void -dm_trace_mnt_flags(void) -{ - char on[] = "on"; - char off[] = "off"; - char *buf = NULL; - -#define DM_MNT_FLAGS(f) \ - buf = mms_strapp(buf, "\n" #f " - %s", \ - (mnt->mnt_flags & f) ? on : off); - - buf = mms_strapp(buf, "mnt_flags =\n"); - - DM_MNT_FLAGS(MNT_FIXED); - DM_MNT_FLAGS(MNT_VARIABLE); - DM_MNT_FLAGS(MNT_MMS); - DM_MNT_FLAGS(MNT_NOT_USED); - DM_MNT_FLAGS(MNT_NOREWIND); - DM_MNT_FLAGS(MNT_AVAIL_0); - DM_MNT_FLAGS(MNT_COMPRESSION); - DM_MNT_FLAGS(MNT_AVAIL_1); - DM_MNT_FLAGS(MNT_LOW); - DM_MNT_FLAGS(MNT_MEDIUM); - DM_MNT_FLAGS(MNT_HIGH); - DM_MNT_FLAGS(MNT_ULTRA); - DM_MNT_FLAGS(MNT_AUTO_DEN); - DM_MNT_FLAGS(MNT_BSD); - DM_MNT_FLAGS(MNT_NOBSD); - DM_MNT_FLAGS(MNT_MMS_TM); - DM_MNT_FLAGS(MNT_NOLOAD); - DM_MNT_FLAGS(MNT_PRIVILEGED); - DM_MNT_FLAGS(MNT_VALIDATE_VID); - DM_MNT_FLAGS(MNT_NO_VALIDATE_VID); - DM_MNT_FLAGS(MNT_VALIDATE_XDATE); - DM_MNT_FLAGS(MNT_NO_VALIDATE_XDATE); - DM_MNT_FLAGS(MNT_VALIDATE_FNAME); - DM_MNT_FLAGS(MNT_NO_VALIDATE_FNAME); - DM_MNT_FLAGS(MNT_PREEMPT_RSV); - DM_MNT_FLAGS(MNT_ASK_PREEMPT_RSV); - DM_MNT_FLAGS(MNT_NO_PREEMPT_RSV); - DM_MNT_FLAGS(MNT_SWITCH_LBL); - DM_MNT_FLAGS(MNT_ASK_SWITCH_LBL); - DM_MNT_FLAGS(MNT_NO_SWITCH_LBL); - DM_MNT_FLAGS(MNT_WRITEOVER); - DM_MNT_FLAGS(MNT_ASK_WRITEOVER); - DM_MNT_FLAGS(MNT_NO_WRITEOVER); - DM_MNT_FLAGS(MNT_READONLY); - DM_MNT_FLAGS(MNT_READWRITE); - DM_MNT_FLAGS(MNT_OLD); - DM_MNT_FLAGS(MNT_CREAT); - - TRACE((MMS_DEBUG, buf)); - free(buf); -} diff --git a/usr/src/cmd/mms/dm/common/dm_drive.h b/usr/src/cmd/mms/dm/common/dm_drive.h deleted file mode 100644 index c79d1acfd1..0000000000 --- a/usr/src/cmd/mms/dm/common/dm_drive.h +++ /dev/null @@ -1,1116 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - - -#ifndef __DM_DRIVE_H -#define __DM_DRIVE_H - - -#include <sys/scsi/impl/uscsi.h> -#include <mms_dmd.h> -#include <mms_sym.h> -#include <mms_list.h> -#include <mms_scsi.h> -#include <sys/mtio.h> -#include <mms_trace.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define DRV_LOAD_TUR 600 /* Try this many TURs before */ - /* Issueing the load command */ -#define DMNAME (drv->drv_dmname) -#define DRVNAME (drv->drv_drvname) - -/* - * an MTIOCTOP/MTIOCLTOP request - */ -typedef struct drv_req { - uint16_t drv_op; - int64_t drv_count; -} drv_req_t; - - -/* - * For DRIVECARTRIDGEACCESS object - */ -typedef struct drv_cart_access { - int dca_flags; - char *dca_side_name; - char *dca_part_name; - char *dca_app_name; - char *dca_cart_id; - char *dca_mounted_last; - char *dca_cart_shape_name; - char *dca_drv_shape_name; - char *dca_pcl; - int64_t dca_bytes_read; /* uncompressed bytes read */ - /* by app */ - int64_t dca_bytes_read_med; /* compressed bytes read */ - /* from medium */ - int64_t dca_bytes_written; /* uncompressed bytes written */ - /* by app */ - int64_t dca_bytes_written_med; /* compressed bytes written */ - /* on medium */ - int dca_read_err; - int dca_rcvd_read_err; - int dca_write_err; - int dca_rcvd_write_err; -} drv_cart_access_t; - -#define DRV_DCA_VALID 1 /* DCA has valid info */ - -/* - * Hold dm mount request attributes - */ -typedef struct drv_mount { - uint64_t mnt_flags; /* yes/no option flags */ - uint32_t mnt_tm; /* tapemark processing option */ - int mnt_blksize; /* blocksize in mount cmd */ - int mnt_dflt_blksize; /* default blksize */ - int mnt_lbl_type; /* label type - al, sl, nl */ - int mnt_fseq; - int mnt_retention; - /* - * Don't free the following - */ - mms_sym_t *mnt_bitformat; - mms_sym_t *mnt_density; - /* - * End of don't free - */ - /* - * Must free the following from here to ... - */ - char *mnt_volumename; - char *mnt_vid; - char *mnt_pcl; - char *mnt_fname; /* filename */ - char *mnt_user; - char *mnt_dencode; - char *mnt_shape; /* cartridge shape */ - /* - * End of must free - */ -} drv_mount_t; - -#define MNT_FIXED (1LL << 0) /* fixed block */ -#define MNT_VARIABLE (1LL << 1) /* variable block */ -#define MNT_MMS (1LL << 2) /* MMS mode or raw mode */ -#define MNT_NOT_USED (1LL << 3) -#define MNT_NOREWIND (1LL << 4) /* rewind/norewind at close */ -#define MNT_AVAIL_0 (1LL << 5) -#define MNT_COMPRESSION (1LL << 6) /* Turn compression on */ -#define MNT_AVAIL_1 (1LL << 7) -#define MNT_LOW (1LL << 8) /* Low density */ -#define MNT_MEDIUM (1LL << 9) /* Medium density */ -#define MNT_HIGH (1LL << 10) /* High density */ -#define MNT_ULTRA (1LL << 11) /* Ultra density */ -#define MNT_AUTO_DEN (1LL << 12) /* Use auto den */ -#define MNT_BSD (1LL << 13) /* Use Solaris BSD mode */ -#define MNT_NOBSD (1LL << 14) /* Use Solaris NOBSD */ -#define MNT_MMS_TM (1LL << 15) /* Use MMS TM behavior */ -#define MNT_NOLOAD (1LL << 16) /* don't issue load command */ -#define MNT_PRIVILEGED (1LL << 17) /* From a privileged client */ -#define MNT_VALIDATE_VID (1LL << 18) -#define MNT_NO_VALIDATE_VID (1LL << 19) -#define MNT_VALIDATE_XDATE (1LL << 20) -#define MNT_NO_VALIDATE_XDATE (1LL << 21) -#define MNT_VALIDATE_FNAME (1LL << 22) -#define MNT_NO_VALIDATE_FNAME (1LL << 23) -#define MNT_PREEMPT_RSV (1LL << 24) -#define MNT_ASK_PREEMPT_RSV (1LL << 25) -#define MNT_NO_PREEMPT_RSV (1LL << 26) -#define MNT_SWITCH_LBL (1LL << 27) -#define MNT_ASK_SWITCH_LBL (1LL << 28) -#define MNT_NO_SWITCH_LBL (1LL << 29) -#define MNT_WRITEOVER (1LL << 30) -#define MNT_ASK_WRITEOVER (1LL << 31) -#define MNT_NO_WRITEOVER (1LL << 32) -#define MNT_READONLY (1LL << 33) /* readonly */ -#define MNT_READWRITE (1LL << 34) /* readwrite */ -#define MNT_OLD (1LL << 35) -#define MNT_CREAT (1LL << 36) - -/* - * If you add a new flag, make sure you also add it to the * - * function dm_trace_mnt_flags(). * - */ - -#define DRV_IOBUF_LEN 10240 -#define DRV_LBN_LEN 17 -#define DRV_SENSE_LEN 255 /* sense buf size */ -#define DRV_INQ_LEN 64 /* inquiry data buf size */ -#define DRV_LOGICAL_CROSS_TM 1 /* Cross TM */ - - -/* - * Uscsi request - */ -typedef struct drv_scsi_err { - int se_flags; - uchar_t se_cdb[MMS_MAX_CDB_LEN]; /* save cdb if error */ - int se_cdblen; - union { - uchar_t se_senbytes[DRV_SENSE_LEN]; - struct scsi_extended_sense se_xsense; - } se_u_sense; - int se_senlen; - uchar_t se_errcl; /* error class */ - drm_mtget_t se_mtget; - int se_errno; - char *se_err_text; -} drv_scsi_err_t; - -#define DRV_SE_USCSI 0x01 /* A uscsi error */ -#define DRV_SE_SEN_VALID 0x02 /* sense is valid */ -#define DRV_SE_ILI 0x04 /* Ilegal length */ - -#define se_sense se_u_sense.se_senbytes -#define se_extsen se_u_sense.se_xsense -#define se_cmd se_cdb[0] -#define se_asc se_sense[12] -#define se_ascq se_sense[13] -#define se_type se_mtget.drm_type -#define se_dsreg se_mtget.drm_dsreg -#define se_erreg se_mtget.drm_erreg -#define se_status se_dsreg -#define se_senkey se_erreg -#define se_resid se_mtget.drm_resid -#define se_fileno se_mtget.drm_fileno -#define se_blkno se_mtget.drm_blkno -#define se_mt_flags se_mtget.drm_mt_flags -#define se_mt_bf se_mtget.drm_mt_bf - -/* - * Define error class - */ -typedef enum { - DRV_EC_ERROR = 1, - DRV_EC_NOT_READY, - DRV_EC_NO_SENSE, - DRV_EC_TM, - DRV_EC_EOD, - DRV_EC_EOM, - DRV_EC_BOM, - DRV_EC_NEEDS_CLEANING, - DRV_EC_FORMAT, - DRV_EC_INTER_REQ, - DRV_EC_RESET, - DRV_EC_UNIT_ATTN, - DRV_EC_LOST_PRSV, - DRV_EC_RCVD_ERR, - DRV_EC_MEDIUM_ERR, - DRV_EC_HW_ERR, - DRV_EC_ILLEGAL_REQ, - DRV_EC_DATA_PROTECT, - DRV_EC_BLANK_CHECK, - DRV_EC_VENDOR, - DRV_EC_COPY_ABORTED, - DRV_EC_ABORTED, - DRV_EC_VOL_OVERFLOW, - DRV_EC_MISCOMPARE, - DRV_EC_NREADY_TO_READY, - - /* Add additional erorr classes before this line */ - DRV_EC_UNKNOWN_ERR /* End of table */ -} drv_err_class_t; - -typedef struct drv_skaa { - uchar_t drv_senkey; - uchar_t drv_asc; - uchar_t drv_ascq; - drv_err_class_t drv_ec; /* error class */ - char *drv_text; -} drv_skaa_t; - - - -#define DRV_IMPID "SUNMICRO MMS " -#define DRV_IMPID2 "SUNMICRO SMMS" -#define DRV_IMPID_LEN (sizeof (((drv_vol1_t *)0)->vol1_impid)) - - -typedef struct drv_vol1 { - char vol1_id[4]; /* Label ID */ - char vol1_vid[6]; /* Vol ID */ - char vol1_acc; /* Accessability */ - char vol1_reserved[13]; - char vol1_impid[13]; /* implemenation ID */ - char vol1_owner[14]; /* Owner */ - char vol1_reserved2[28]; - char vol1_ver; /* Standard Version (4) */ -} drv_vol1_t; - -#define VOL1_ID "VOL1" -#define VOL1_OWNER "SUNMICROSYSTEM" -#define VOL1_VER "4 " - - -typedef struct drv_hdr1 { - char hdr1_id[4]; /* Label ID */ - char hdr1_fid[17]; /* File ID */ - char hdr1_fsid[6]; /* File set ID */ - char hdr1_fsnum[4]; /* File section number */ - char hdr1_fseq[4]; /* File sequence number */ - char hdr1_gnum[4]; /* Generation number */ - char hdr1_gver[2]; /* Generation version */ - char hdr1_cdate[6]; /* Creation date */ - char hdr1_xdate[6]; /* Expiration date */ - char hdr1_acc; /* File accessability */ - char hdr1_bcount[6]; /* Block count */ - char hdr1_impid[13]; /* Implementation ID */ - char hdr1_reserved[7]; -} drv_hdr1_t; - -#define HDR1_ID "HDR1" - -typedef struct drv_hdr2 { - char hdr2_id[4]; - char hdr2_rformat; - char hdr2_blklen[5]; - char hdr2_rcdlen[5]; - union { - char hdr2_impuse[35]; /* for use by implimentation */ - char hdr2_blksize_u[10]; /* blocksize */ - } hdr2_impuse_u; - char hdr2_off[2]; - char hdr2_reserved[28]; -} drv_hdr2_t; - -#define hdr2_blksize hdr2_impuse_u.hdr2_blksize_u - -#define HDR2_ID "HDR2" - -typedef struct drv_eof1 { - char eof1_id[4]; /* Label ID */ - char eof1_fid[17]; /* File ID */ - char eof1_fsid[6]; /* File set ID */ - char eof1_fsnum[4]; /* File section number */ - char eof1_fseq[4]; /* File sequence number */ - char eof1_gnum[4]; /* Generation number */ - char eof1_gver[2]; /* Generation version */ - char eof1_cdate[6]; /* Creation date */ - char eof1_xdate[6]; /* Expiration date */ - char eof1_acc; /* File accessability */ - char eof1_bcount[6]; /* Block count */ - char eof1_impid[13]; /* Implementation ID */ - char eof1_reserved[7]; -} drv_eof1_t; - -#define EOF1_ID "EOF1" - -typedef struct drv_eof2 { - char eof2_id[4]; - char eof2_rformat; - char eof2_blklen[5]; - char eof2_rcdlen[5]; - union { - char eof2_impuse[35]; /* for use by implimentation */ - char eof2_blksize_u[10]; /* blocksize */ - } eof2_impuse_u; - char eof2_off[2]; - char eof2_reserved[28]; -} drv_eof2_t; - -#define eof2_blksize eof2_impuse_u.eof2_blksize_u - -#define EOF2_ID "EOF2" - - -typedef struct drv_eov1 { - char eov1_id[4]; /* Label ID */ - char eov1_fid[17]; /* File ID */ - char eov1_fsid[6]; /* File set ID */ - char eov1_fsnum[4]; /* File section number */ - char eov1_fseq[4]; /* File sequence number */ - char eov1_gnum[4]; /* Generation number */ - char eov1_gver[2]; /* Generation version */ - char eov1_cdate[6]; /* Creation date */ - char eov1_xdate[6]; /* Expiration date */ - char eov1_acc; /* File accessability */ - char eov1_bcount[6]; /* Block count */ - char eov1_impid[13]; /* Implementation ID */ - char eov1_reserved[7]; -} drv_eov1_t; - -#define EOV1_ID "EOV1" - -typedef struct drv_eov2 { - char eov2_id[4]; - char eov2_rformat; - char eov2_blklen[5]; - char eov2_rcdlen[5]; - union { - char eov2_impuse[35]; /* for use by implimentation */ - char eov2_blksize_u[10]; /* blocksize */ - } eov2_impuse_u; - char eov2_off[2]; - char eov2_reserved[28]; -} drv_eov2_t; - -#define eov2_blksize eov2_impuse_u.eov2_blksize_u - -#define EOV2_ID "EOV2" - -typedef struct drv_timeout { - short drv_long_timeout; /* For really long commands */ - short drv_timeout; /* Normal commands */ - short drv_short_timeout; /* short commands */ -} drv_timeout_t; - -/* - * Define a structure that specifies which density can be written on a shape - */ -typedef struct drv_shape_density { - char *drv_shape; /* shape name */ - char *drv_bit; /* density on cartridge */ - char *drv_den; /* write density */ -} drv_shape_density_t; - -/* - * drv_drive - states of drive with volume mounted - */ -typedef struct drv_drive { - uint64_t drv_flags; - char drv_typename[65]; - char drv_vend[9]; - char drv_prod[17]; - mms_capacity_t drv_cap; /* Capacity of tape */ - int drv_fd; /* file descriptor of drive */ - int drv_numopens; /* num. of opens since loaded */ - int drv_fseq; - int drv_lbl_type; /* label type */ - int drv_file_blksize; /* block size of file */ - int drv_cur_blksize; /* current blocksize */ - int drv_lbl_blksize; /* block size on the label */ - int drv_dflt_blksize; - int drv_retention; - int drv_xdate; /* expiration date */ - int drv_disk_mount_timeout; - drv_vol1_t drv_vol1; - drv_hdr1_t drv_hdr1; - drv_hdr2_t drv_hdr2; - drv_eof1_t drv_eof1; - drv_eof2_t drv_eof2; - drv_eov1_t drv_eov1; - drv_eov2_t drv_eov2; - uint32_t drv_oflags; - tapepos_t drv_bof_pos; - tapepos_t drv_eof_pos; - tapepos_t drv_cur_pos; - drm_mtget_t drv_mtget; - daddr_t drv_rdbytes; - daddr_t drv_wrbytes; - int drv_cur_den; - mms_sym_t *drv_density; - char **drv_shape; - drv_shape_density_t *drv_shape_den; - char *drv_libname; - char *drv_dmname; - char *drv_drvname; - char *drv_dev_dir; - char *drv_drive_type; /* drive type */ - uchar_t *drv_iobuf; - drv_timeout_t *drv_timeout; - drv_skaa_t *drv_skaa_tab; - char drv_vid[10]; - char drv_fid[18]; - char drv_serial_num[MMS_SER_NUM_LEN + 1]; - char drv_sernum[MMS_SER_NUM_LEN + 1]; - /* serial num from DRIVE obj */ - uchar_t drv_prsv_key[8]; - char *drv_disk_libpath; /* DISK library path */ - int drv_mtee_stat_len; /* mtee status len */ - int drv_num_sen_bytes; - int *drv_disallowed_cmds; - int *drv_num_disallowed_cmds; - int *drv_disallowed_ioctls; - int *drv_num_disallowed_ioctls; - int *drv_prsv_supported; -} drv_drive_t; - -/* - * Drive Flags - */ -#define DRV_LOADED (1LL << 0) -#define DRV_IDENTIFIED (1LL << 1) -#define DRV_MMS_LBL (1LL << 2) -#define DRV_VALIDATED_FNAME (1LL << 3) -#define DRV_VOL1 (1LL << 4) /* vol has VOL1 label */ -#define DRV_HDR1 (1LL << 5) /* vol has HDR1 label */ -#define DRV_HDR2 (1LL << 6) /* vol has HDR2 label */ -#define DRV_TERM_FILE (1LL << 7) /* Need to terminate file */ -#define DRV_OPENED (1LL << 8) /* User opened file */ -#define DRV_UDATA (1LL << 9) /* vol in user data */ -#define DRV_FATAL (1LL << 10) /* a fatal error occurred */ -#define DRV_ENABLED (1LL << 11) /* DM is enabled */ -#define DRV_BOF (1LL << 12) /* at BOF */ -#define DRV_EOF (1LL << 13) /* at EOF */ -#define DRV_TM (1LL << 14) /* hit a tapemark */ -#define DRV_BLANK (1LL << 15) /* A blank tape */ -#define DRV_ATTACHED (1LL << 16) /* drive attached */ -#define DRV_BOM (1LL << 17) /* at BOM */ -#define DRV_EOM (1LL << 18) /* at EOM */ -#define DRV_FIXED (1LL << 19) /* Fixed format */ -#define DRV_VARIABLE (1LL << 20) /* Variable format */ -#define DRV_EOF1 (1LL << 21) /* Has EOF1 label */ -#define DRV_EOF2 (1LL << 22) /* Has EOF2 label */ -#define DRV_VALID_BOF_POS (1LL << 23) /* BOF position is valid */ -#define DRV_LOST_POS (1LL << 24) /* DM lost position of drive */ -#define DRV_VALID_STAT (1LL << 25) /* Drive status is valid */ -#define DRV_VALID_EOF_POS (1LL << 26) /* EOF position is valid */ -#define DRV_UPDATE_EOF_POS (1LL << 27) /* Must update eof at close */ -#define DRV_UPDATE_CAPACITY (1LL << 28) /* Update capacity at close */ -#define DRV_READONLY (1LL << 29) /* Readonly cartridge */ -#define DRV_RESERVED (1LL << 30) /* Drive reserved */ -#define DRV_WRITEOVER (1LL << 31) /* Writeover silently */ -#define DRV_ASK_WRITEOVER (1LL << 32) /* Ask writeover */ -#define DRV_SWITCH_LBL (1LL << 33) /* Do label switch silently */ -#define DRV_ASK_SWITCH_LBL (1LL << 34) /* Ask label switch */ -#define DRV_VALIDATE_FNAME (1LL << 35) /* Validate filename */ -#define DRV_VALIDATE_VID (1LL << 36) /* Validate VID */ -#define DRV_VALIDATE_XDATE (1LL << 37) /* Validate expiration date */ -#define DRV_WRITEPROTECTED (1LL << 38) /* Cart is writeprotected */ -#define DRV_CREAT (1LL << 39) /* Create new file */ -#define DRV_APPEND (1LL << 40) /* append file */ -#define DRV_USE_PRSV (1LL << 41) /* Use persistent reservation */ - -/* - * If you add a new flag, make sure you also add it to the * - * function dm_trace_drv_flags(). * - * * - * Also add it to DRV_LOAD_FLAGS below if it must be kept across * - * cartridge load/unload. * - */ - -#define DRV_LOAD_FLAGS (DRV_ENABLED | DRV_ATTACHED | \ - DRV_RESERVED | DRV_WRITEOVER | DRV_ASK_WRITEOVER | DRV_SWITCH_LBL | \ - DRV_VALIDATE_FNAME | DRV_VALIDATE_VID | DRV_VALIDATE_XDATE | \ - DRV_CREAT | DRV_APPEND | DRV_USE_PRSV) - -#define DRV_MOVE_FLAGS (DRV_BOM | DRV_BOF | DRV_TM | DRV_EOF | DRV_EOM) - -#define drv_capacity drv_cap.mms_max -#define drv_avail drv_cap.mms_avail -#define drv_pc_avail drv_cap.mms_pc_avail - -#define DRV_SAVE_STAT 1 - -/* - * Define label type - */ -#define DRV_AL 1 -#define DRV_SL 2 -#define DRV_NL 3 -#define DRV_BLP 4 - -typedef int (drv_init_dev_t)(void); -drv_init_dev_t drv_init_dev; -typedef minor_t (drv_get_targ_t)(minor_t); -drv_get_targ_t drv_get_targ; -typedef int (drv_set_blksize_t)(uint64_t); -drv_set_blksize_t drv_set_blksize; -typedef int (drv_get_blksize_t)(uint64_t *); -drv_get_blksize_t drv_get_blksize; -typedef int (drv_get_density_t)(int *, int *); -drv_get_density_t drv_get_density; -typedef int (drv_set_density_t)(int); -drv_set_density_t drv_set_density; -typedef int (drv_read_t)(char *, int); -drv_read_t drv_read; -typedef int (drv_write_t)(char *, int); -drv_write_t drv_write; -typedef int (drv_get_capacity_t)(mms_capacity_t *); -drv_get_capacity_t drv_get_capacity; -typedef int64_t (drv_get_avail_capacity_t)(void); -drv_get_avail_capacity_t drv_get_avail_capacity; -typedef int (drv_clrerr_t)(void); -drv_clrerr_t drv_clrerr; -typedef void (drv_proc_error_t)(void); -drv_proc_error_t drv_proc_error; -typedef int (drv_inquiry_t)(void); -drv_inquiry_t drv_inquiry; -typedef int (drv_req_sense_t)(int); -drv_req_sense_t drv_req_sense; -typedef int (drv_wtm_t)(uint64_t); -drv_wtm_t drv_wtm; -typedef int (drv_tur_t)(void); -drv_tur_t drv_tur; -typedef int (drv_load_t)(void); -drv_load_t drv_load; -typedef int (drv_unload_t)(void); -drv_unload_t drv_unload; -typedef int (drv_rewind_t)(void); -drv_rewind_t drv_rewind; -typedef int (drv_mode_sense_t)(int, int, int); -drv_mode_sense_t drv_mode_sense; -typedef int (drv_mode_select_t)(int, int); -drv_mode_select_t drv_mode_select; -typedef int (drv_seek_t)(uint64_t); -drv_seek_t drv_seek; -typedef int (drv_tell_t)(uint64_t *); -drv_tell_t drv_tell; -typedef int (drv_fsf_t)(uint64_t); -drv_fsf_t drv_fsf; -typedef int (drv_bsf_t)(uint64_t); -drv_bsf_t drv_bsf; -typedef int (drv_fsb_t)(uint64_t, int); -drv_fsb_t drv_fsb; -typedef int (drv_bsb_t)(uint64_t, int); -drv_bsb_t drv_bsb; -typedef int (drv_eom_t)(void); -drv_eom_t drv_eom; -typedef int (drv_get_pos_t)(tapepos_t *); -drv_get_pos_t drv_get_pos; -typedef int (drv_mtgetpos_t)(tapepos_t *); -drv_mtgetpos_t drv_mtgettpos; -typedef int (drv_mtrestpos_t)(tapepos_t *); -drv_mtrestpos_t drv_mtrestpos; -typedef int (drv_get_statistics_t)(void); -drv_get_statistics_t drv_get_statistics; -typedef int (drv_locate_t)(tapepos_t *); -drv_locate_t drv_locate; -typedef int (drv_log_sense_t)(uchar_t *, int, int, int); -drv_log_sense_t drv_log_sense; -typedef int (drv_read_attribute_t)(uchar_t *, int32_t, int, - int32_t); -drv_read_attribute_t drv_read_attribute; -typedef int (drv_blk_limit_t)(mms_blk_limit_t *); -drv_blk_limit_t drv_blk_limit; -typedef int (drv_reserve_t)(void); -drv_reserve_t drv_reserve; -typedef int (drv_release_t)(void); -drv_release_t drv_release; -typedef int (drv_get_serial_num_t)(char *); -drv_get_serial_num_t drv_get_serial_num; -typedef int (drv_get_write_protect_t)(int *); -drv_get_write_protect_t drv_get_write_protect; -typedef int (drv_prsv_register_t)(void); -drv_prsv_register_t drv_prsv_register; -typedef int (drv_prsv_reserve_t)(void); -drv_prsv_reserve_t drv_prsv_reserve; -typedef int (drv_prsv_release_t)(void); -drv_prsv_release_t drv_prsv_release; -typedef int (drv_prsv_clear_t)(void); -drv_prsv_clear_t drv_prsv_clear; -typedef int (drv_prsv_preempt_t)(char *); -drv_prsv_preempt_t drv_prsv_preempt; -typedef int (drv_prsv_read_keys_t)(char *, int); -drv_prsv_read_keys_t drv_prsv_read_keys; -typedef int (drv_prsv_read_rsv_t)(char *, int); -drv_prsv_read_rsv_t drv_prsv_read_rsv; -typedef int (drv_set_compression_t)(int); -drv_set_compression_t drv_set_compression; - -typedef int (drv_get_drivetype_t)(void); -drv_get_drivetype_t drv_get_drivetype; -typedef int (drv_rebind_target_t)(void); -drv_rebind_target_t drv_rebind_target; -typedef void (drv_mk_prsv_key_t)(void); -drv_mk_prsv_key_t drv_mk_prsv_key; -typedef void (drv_disallowed_t)(void); -drv_disallowed_t drv_disallowed; -typedef int (drv_bind_raw_dev_t)(int); -drv_bind_raw_dev_t drv_bind_raw_dev; - -typedef struct drv_jtab { - drv_init_dev_t *drv_init_dev; - drv_bind_raw_dev_t *drv_bind_raw_dev; - drv_disallowed_t *drv_disallowed; - drv_mk_prsv_key_t *drv_mk_prsv_key; - drv_rebind_target_t *drv_rebind_target; - drv_get_drivetype_t *drv_get_drivetype; - drv_get_targ_t *drv_get_targ; - drv_set_blksize_t *drv_set_blksize; - drv_get_blksize_t *drv_get_blksize; - drv_get_density_t *drv_get_density; - drv_set_density_t *drv_set_density; - drv_read_t *drv_read; - drv_write_t *drv_write; - drv_get_capacity_t *drv_get_capacity; - drv_get_avail_capacity_t *drv_get_avail_capacity; - drv_get_statistics_t *drv_get_statistics; - - drv_clrerr_t *drv_clrerr; - drv_proc_error_t *drv_proc_error; - drv_inquiry_t *drv_inquiry; - drv_req_sense_t *drv_req_sense; - drv_wtm_t *drv_wtm; - drv_tur_t *drv_tur; - drv_load_t *drv_load; - drv_unload_t *drv_unload; - drv_rewind_t *drv_rewind; - drv_mode_sense_t *drv_mode_sense; - drv_mode_select_t *drv_mode_select; - drv_seek_t *drv_seek; - drv_tell_t *drv_tell; - drv_fsf_t *drv_fsf; - drv_bsf_t *drv_bsf; - drv_fsb_t *drv_fsb; - drv_bsb_t *drv_bsb; - drv_eom_t *drv_eom; - drv_get_pos_t *drv_get_pos; - drv_mtgetpos_t *drv_mtgetpos; - drv_mtrestpos_t *drv_mtrestpos; - drv_locate_t *drv_locate; - drv_log_sense_t *drv_log_sense; - drv_read_attribute_t *drv_read_attribute; - drv_blk_limit_t *drv_blk_limit; - drv_reserve_t *drv_reserve; - drv_release_t *drv_release; - drv_get_serial_num_t *drv_get_serial_num; - drv_get_write_protect_t *drv_get_write_protect; - drv_prsv_register_t *drv_prsv_register; - drv_prsv_reserve_t *drv_prsv_reserve; - drv_prsv_release_t *drv_prsv_release; - drv_prsv_clear_t *drv_prsv_clear; - drv_prsv_preempt_t *drv_prsv_preempt; - drv_prsv_read_keys_t *drv_prsv_read_keys; - drv_prsv_read_keys_t *drv_prsv_read_rsv; - drv_set_compression_t *drv_set_compression; -} drv_jtab_t; - - -extern drv_jtab_t *jtab; -extern drv_mount_t *mnt; -extern drv_drive_t *drv; -extern drv_scsi_err_t *serr; -extern drv_cart_access_t *dca; - -int dm_uscsi(struct uscsi_cmd *us); -int dm_mtiocltop(drv_req_t *op); -int dm_ioctl(int cmd, void *arg); -void dm_get_mtstat(int); -void dm_err_trace(void); -void dm_disallowed(void); -void dm_mk_prsv_key(void); -int dm_rebind_target(void); -int dm_bind_raw_dev(int); -void dm_get_mt_error(int err); -int dm_get_log_sense_parm(uchar_t *page, int code, uint64_t *val); -int dm_send_clean_request(void); -void int32_to_char(int32_t val, uchar_t *start, int len); -void int64_to_char(int64_t val, uchar_t *start, int len); -void char_to_int32(signed char *start, int len, int32_t *val); -void char_to_uint32(uchar_t *start, int len, uint32_t *val); -void char_to_int64(signed char *start, int len, int64_t *val); -void char_to_uint64(uchar_t *start, int len, uint64_t *val); -int dm_send_error(void); -int dm_send_drive_broken(void); -int dm_send_cartridge_media_error(void); - -#define CONF_TASK "$taskid$" -#define CONF_DMNAME "$dmname$" -#define CONF_SHAPE "$shape$" -#define CONF_SHAPE_RW "$shape_rw$" -#define CONF_SHAPE_RO "$shape_ro$" -#define CONF_DENSITY_RW "$density_rw$" -#define CONF_DENSITY_RO "$density_ro$" -#define CONF_DENSITY_WO "$density_wo$" -#define CONF_DRIVE_SPEC "$drivespec$" -#define CONF_DRIVE_TYPE "$drivetype$" -#define CONF_BITFORMAT "$bitformat$" -#define CONF_BITFORMAT_RW "$bitformat_rw$" -#define CONF_BITFORMAT_RO "$bitformat_ro$" -#define CONF_BITFORMAT_WO "$bitformat_writeover$" -#define CONF_BIT_CLAUSE "$bitformat_clause$" -#define CONF_SHAPE_PRIORITY "$shape_priority$" -#define CONF_DEN_PRIORITY "$den_priority$" -#define CUR_SHAPE_RW "$cur_shape_rw$" -#define CUR_DENSITY_RW "$cur_density_rw$" -#define CUR_DENSITY_RO "$cur_density_ro$" -#define CUR_BITFORMAT_RW "$cur_bitformat_rw$" -#define CUR_BITFORMAT_WO "$cur_bitformat_wo$" -#define CONF_CAP_READWRITE "$conf_cap_readwrite$" -#define CONF_CAP_DENSITY_CLAUSE "$conf_cap_density_clause$" - - -#define DRV_CAP_WRITEOVER "" \ - /* \ - * Device that uses specific densities \ - * to overwrite existing density \ - */ \ - \ - "cap ['writeover-" \ - CONF_DMNAME"-"CUR_SHAPE_RW"-"CUR_BITFORMAT_RW"-"CUR_DENSITY_RW"' " \ - " caplist [ 'mms' \n" \ - " '*nocompression' 'compression' \n" \ - " '*default_tm' 'mms_tm' 'st_bsd' 'st_nobsd' \n" \ - " 'variable' 'block' 'fixed' \n" \ - " '*load' 'noload'\n" \ - " '*auto_drive' " CONF_DRIVE_SPEC "'" CONF_DRIVE_TYPE "'\n" \ - " '*oflag' 'creat' 'old' 'trunc' 'append' \n" \ - " '*default_lbl' 'al' 'sl' 'nl' 'blp' \n" \ - " '*rewind' 'norewind' \n" \ - " '*dflt_vldt_filename' 'validate_filename' " \ - " 'no_validate_filename' \n" \ - " '*dflt_vldt_vid' 'validate_vid' 'no_validate_vid' \n" \ - " '*dflt_vldt_xdate' 'validate_xdate' 'no_validate_xdate'\n" \ - " '*dflt_switch_lbl' 'switch_lbl' 'ask_switch_lbl' " \ - " 'no_switch_lbl'\n" \ - " '*dflt_writeover' 'writeover' 'ask_writeover' " \ - " 'no_writeover'\n" \ - " '*dflt_preempt_rsv' 'preempt_rsv' 'ask_preempt_rsv' " \ - " 'no_preempt_rsv'\n" \ - " '*readwrite' 'readwrite' \n" \ - " '" CUR_DENSITY_RW "'\n" \ - " '*bit_unknown' '" CUR_BITFORMAT_WO "'\n" \ - " '" CUR_SHAPE_RW "'\n" \ - " ]] \n" - -#define DRV_CAP_READWRITE "" \ - /* \ - * Device that uses specific densities \ - * for readwrite \ - */ \ - \ - "cap ['readwrite-" \ - CONF_DMNAME"-"CUR_SHAPE_RW"-"CUR_BITFORMAT_RW"-"CUR_DENSITY_RW"' " \ - " caplist [ 'mms' \n" \ - " '*nocompression' 'compression' \n" \ - " '*default_tm' 'mms_tm' 'st_bsd' 'st_nobsd' \n" \ - " 'variable' 'block' 'fixed' \n" \ - " '*load' 'noload'\n" \ - " '*auto_drive' " CONF_DRIVE_SPEC "'" CONF_DRIVE_TYPE "'\n" \ - " '*oflag' 'creat' 'old' 'trunc' 'append' \n" \ - " '*default_lbl' 'al' 'sl' 'nl' 'blp' \n" \ - " '*rewind' 'norewind' \n" \ - " '*dflt_vldt_filename' 'validate_filename' " \ - " 'no_validate_filename' \n" \ - " '*dflt_vldt_vid' 'validate_vid' 'no_validate_vid' \n" \ - " '*dflt_vldt_xdate' 'validate_xdate' 'no_validate_xdate'\n" \ - " '*dflt_switch_lbl' 'switch_lbl' 'ask_switch_lbl' " \ - " 'no_switch_lbl'\n" \ - " '*dflt_writeover' 'writeover' 'ask_writeover' " \ - " 'no_writeover'\n" \ - " '*dflt_preempt_rsv' 'preempt_rsv' 'ask_preempt_rsv' " \ - " 'no_preempt_rsv'\n" \ - " '*readwrite' 'readwrite' \n" \ - " '" CUR_DENSITY_RW "'\n" \ - " '" CUR_BITFORMAT_RW "'\n" \ - " '" CUR_SHAPE_RW "'\n" \ - " ]] \n" - - - -/* - * format of config command - * Default capabilities that begin with '*' are default capabilities which - * are meant to be hidden from the user and should not be documented in user - * manuals. - */ -#define DRV_CONFIG "" \ - "config task ['" CONF_TASK "'] scope [full]\n" \ - \ - "group ['st-device' 'interchange' " \ - "'*nocompression' 'compression' 'high' 'low' 'medium' 'ultra' ] \n" \ - \ - "group ['specific-density' 'interchange' " \ - "'*auto_density' " \ - CONF_DENSITY_RW CONF_DENSITY_RO "] \n" \ - \ - "group ['bitformat-list' 'interchange' " \ - "'*bit_unknown' " CONF_BITFORMAT "]\n" \ - \ - "group ['data-block-format' 'access' " \ - "'variable' 'block' 'fixed']\n" \ - \ - "group ['shape' 'access' " \ - CONF_SHAPE_RW CONF_SHAPE_RO " ] \n" \ - \ - "group ['do-load' 'access' " \ - "'*load' 'noload']\n" \ - \ - "group ['tm-behavor' 'access' " \ - "'*default_tm' 'mms_tm' 'st_nobsd' 'st_bsd' ]\n" \ - \ - "group ['specific-drive' 'access' " \ - "'*auto_drive' " CONF_DRIVE_SPEC "'" CONF_DRIVE_TYPE "']\n" \ - \ - "group ['file-disposition' 'access' " \ - "'*oflag' 'old' 'creat' 'new' 'trunc' 'append'] \n" \ - \ - "group ['operation-mode' 'access' " \ - "'mms' 'raw'] \n" \ - \ - "group ['lable-type' 'access' " \ - "'*default_lbl' 'al' 'nl' 'sl' 'blp'] \n" \ - \ - "group ['readwrite-mode' 'access' " \ - "'*readwrite' 'readwrite' 'readonly'] \n" \ - \ - "group ['rewind-at-close' 'access' " \ - "'*rewind' 'norewind' ] \n" \ - \ - "group ['filename-validation' 'access' " \ - "'*dflt_vldt_filename' 'validate_filename' 'no_validate_filename'] \n" \ - \ - "group ['vid-validation' 'access' " \ - "'*dflt_vldt_vid' 'validate_vid' 'no_validate_vid' ]\n" \ - \ - "group ['xdate-validation' 'access' " \ - "'*dflt_vldt_xdate' 'validate_xdate' 'no_validate_xdate' ]\n" \ - \ - "group ['switch-label' 'access' " \ - "'*dflt_switch_lbl' 'switch_lbl' 'ask_switch_lbl' " \ - "'no_switch_lbl' ]\n" \ - \ - "group ['write-over' 'access' " \ - "'*dflt_writeover' 'writeover' 'ask_writeover' 'no_writeover' ]\n" \ - \ - "group ['preempt-reservation' 'access' " \ - "'*dflt_preempt_rsv' 'preempt_rsv' 'ask_preempt_rsv' " \ - "'no_preempt_rsv' ]\n" \ - \ - CONF_BIT_CLAUSE "\n" \ - \ - /* \ - * Raw devices - readwrite \ - */ \ - "cap ['raw-rw-" CONF_DMNAME "' caplist [ \n" \ - " 'raw' \n" \ - " '*nocompression' 'compression' " \ - " 'high' 'low' 'medium' 'ultra' \n" \ - " '*auto_density' \n" \ - " 'variable' \n" \ - " '*default_tm' 'st_bsd' 'st_nobsd' \n" \ - " '*load' \n" \ - " '*auto_drive' " CONF_DRIVE_SPEC "'" CONF_DRIVE_TYPE "'\n" \ - " '*oflag' \n" \ - " '*default_lbl' \n" \ - " '*rewind' 'norewind' \n" \ - " '*dflt_vldt_filename' \n" \ - " '*dflt_vldt_vid' \n" \ - " '*dflt_vldt_xdate' \n" \ - " '*dflt_switch_lbl' \n" \ - " '*dflt_writeover' \n" \ - " '*dflt_preempt_rsv' 'preempt_rsv' 'ask_preempt_rsv' \n" \ - " '*readwrite' 'readwrite' \n" \ - " '*bit_unknown' " CONF_BITFORMAT_RW CONF_BITFORMAT_WO \ - " " CONF_SHAPE_RW "\n" \ - " ]] \n" \ - \ - /* \ - * Raw devices - readonly \ - */ \ - "cap ['raw-ro-" CONF_DMNAME "' caplist [ \n" \ - " 'raw' \n" \ - " '*nocompression' 'compression' " \ - " 'high' 'low' 'medium' 'ultra' \n" \ - " '*auto_density' \n" \ - " 'variable' \n" \ - " '*default_tm' 'st_bsd' \n" \ - " '*load' \n" \ - " '*auto_drive' " CONF_DRIVE_SPEC "'" CONF_DRIVE_TYPE "'\n" \ - " '*oflag' \n" \ - " '*default_lbl' \n" \ - " '*rewind' 'norewind' \n" \ - " '*dflt_vldt_filename' \n" \ - " '*dflt_vldt_vid' \n" \ - " '*dflt_vldt_xdate' \n" \ - " '*dflt_switch_lbl' \n" \ - " '*dflt_writeover' \n" \ - " '*dflt_preempt_rsv' 'preempt_rsv' 'ask_preempt_rsv' \n" \ - " 'readonly' \n" \ - " '*bit_unknown' " CONF_BITFORMAT_RW CONF_BITFORMAT_RO "\n" \ - " " CONF_SHAPE_RW CONF_SHAPE_RO "\n" \ - " ]] \n" \ - \ - /* \ - * MMS device that uses st densities \ - * for readwrite \ - */ \ - \ - "cap ['mms-readwrite" CONF_DMNAME "' caplist [ \n" \ - " 'mms' \n" \ - " '*nocompression' 'compression' " \ - " 'low' 'medium' 'high' 'ultra' \n" \ - " '*default_tm' 'mms_tm' 'st_bsd' 'st_nobsd' \n" \ - " 'variable' 'block' 'fixed' \n" \ - " '*load' 'noload'\n" \ - " '*auto_drive' " CONF_DRIVE_SPEC "'" CONF_DRIVE_TYPE "'\n" \ - " '*oflag' 'old' 'trunc' 'append' \n" \ - " '*default_lbl' 'al' 'sl' 'nl' 'blp' \n" \ - " '*rewind' 'norewind' \n" \ - " '*dflt_vldt_filename' 'validate_filename' " \ - " 'no_validate_filename' \n" \ - " '*dflt_vldt_vid' 'validate_vid' 'no_validate_vid' \n" \ - " '*dflt_vldt_xdate' 'validate_xdate' 'no_validate_xdate'\n" \ - " '*dflt_switch_lbl' 'switch_lbl' 'ask_switch_lbl' " \ - " 'no_switch_lbl'\n" \ - " '*dflt_writeover' 'writeover' 'ask_writeover' " \ - " 'no_writeover'\n" \ - " '*dflt_preempt_rsv' 'preempt_rsv' 'ask_preempt_rsv' " \ - " 'no_preempt_rsv'\n" \ - " '*readwrite' 'readwrite' \n" \ - " '*auto_density' \n" \ - " '*bit_unknown' " \ - " " CONF_BITFORMAT_RW "\n" \ - " " CONF_SHAPE_RW "\n" \ - " ]]\n" \ - \ - "cap ['mms-writeover-" CONF_DMNAME "' caplist [ \n" \ - " 'mms' \n" \ - " '*nocompression' 'compression' " \ - " 'low' 'medium' 'high' 'ultra' \n" \ - " '*default_tm' 'mms_tm' 'st_bsd' 'st_nobsd' \n" \ - " 'variable' 'block' 'fixed' \n" \ - " '*load' 'noload'\n" \ - " '*auto_drive' " CONF_DRIVE_SPEC "'" CONF_DRIVE_TYPE "'\n" \ - " 'creat' \n" \ - " '*default_lbl' 'al' 'sl' 'nl' 'blp' \n" \ - " '*rewind' 'norewind' \n" \ - " '*dflt_vldt_filename' 'validate_filename' " \ - " 'no_validate_filename' \n" \ - " '*dflt_vldt_vid' 'validate_vid' 'no_validate_vid' \n" \ - " '*dflt_vldt_xdate' 'validate_xdate' 'no_validate_xdate'\n" \ - " '*dflt_switch_lbl' 'switch_lbl' 'ask_switch_lbl' " \ - " 'no_switch_lbl'\n" \ - " '*dflt_writeover' 'writeover' 'ask_writeover' " \ - " 'no_writeover'\n" \ - " '*dflt_preempt_rsv' 'preempt_rsv' 'ask_preempt_rsv' " \ - " 'no_preempt_rsv'\n" \ - " '*readwrite' 'readwrite' \n" \ - " '*auto_density' \n" \ - " '*bit_unknown' " \ - " " CONF_BITFORMAT_RW CONF_BITFORMAT_WO "\n" \ - " " CONF_SHAPE_RW "\n" \ - " ]]\n" \ - \ - /* \ - * MMS device that uses st densities \ - * for readonly bitformat \ - */ \ - \ - "cap ['mms-readonly-" CONF_DMNAME "' caplist [ \n" \ - " 'mms' \n" \ - " '*nocompression' 'compression' " \ - " 'low' 'medium' 'high' 'ultra' \n" \ - " '*default_tm' 'mms_tm' 'st_bsd' 'st_nobsd' \n" \ - " 'variable' 'block' 'fixed' \n" \ - " '*load' 'noload'\n" \ - " '*auto_drive' " CONF_DRIVE_SPEC "'" CONF_DRIVE_TYPE "'\n" \ - " '*oflag' 'old' \n" \ - " '*default_lbl' 'al' 'sl' 'nl' 'blp' \n" \ - " '*rewind' 'norewind' \n" \ - " '*dflt_vldt_filename' 'validate_filename' " \ - " 'no_validate_filename' \n" \ - " '*dflt_vldt_vid' 'validate_vid' 'no_validate_vid' \n" \ - " '*dflt_vldt_xdate' 'validate_xdate' 'no_validate_xdate'\n" \ - " '*dflt_switch_lbl'" \ - " 'no_switch_lbl'\n" \ - " '*dflt_writeover'" \ - " '*dflt_preempt_rsv' 'preempt_rsv' 'ask_preempt_rsv' " \ - " 'no_preempt_rsv'\n" \ - " 'readonly' \n" \ - " '*auto_density' \n" \ - " '*bit_unknown' " \ - " " CONF_BITFORMAT_RW "\n" \ - " " CONF_SHAPE_RW "\n" \ - " ]]\n" \ - \ - CONF_CAP_DENSITY_CLAUSE \ - \ - /* \ - * Device that uses specific densities \ - * for readonly \ - */ \ - \ - "cap ['readonly-" CONF_DMNAME "' caplist [ \n" \ - " 'mms' \n" \ - " '*nocompression' 'compression' \n" \ - " '*default_tm' 'mms_tm' 'st_bsd' 'st_nobsd' \n" \ - " 'variable' 'block' 'fixed' \n" \ - " '*load' 'noload'\n" \ - " '*auto_drive' " CONF_DRIVE_SPEC "'"CONF_DRIVE_TYPE "'\n" \ - " '*oflag' 'old' \n" \ - " '*default_lbl' 'al' 'sl' 'nl' 'blp' \n" \ - " '*rewind' 'norewind' \n" \ - " '*dflt_vldt_filename' 'validate_filename' " \ - " 'no_validate_filename' \n" \ - " '*dflt_vldt_vid' 'validate_vid' 'no_validate_vid' \n" \ - " '*dflt_vldt_xdate' 'validate_xdate' 'no_validate_xdate'\n" \ - " '*dflt_switch_lbl' 'switch_lbl' 'ask_switch_lbl' " \ - " 'no_switch_lbl'\n" \ - " '*dflt_writeover' 'writeover' 'ask_writeover' " \ - " 'no_writeover'\n" \ - " '*dflt_preempt_rsv' 'preempt_rsv' 'ask_preempt_rsv' " \ - " 'no_preempt_rsv'\n" \ - " 'readonly' \n" \ - " " CONF_DENSITY_RW CONF_DENSITY_RO "\n" \ - " '*bit_unknown' " \ - " " CONF_BITFORMAT_RW CONF_BITFORMAT_RO "\n" \ - " " CONF_SHAPE_RW CONF_SHAPE_RO "\n" \ - " ]] \n" \ - \ - " shapepriority [ " CONF_SHAPE " ]\n" \ - " densitypriority [ " \ - " " CONF_BITFORMAT_RW CONF_BITFORMAT_RO \ - " ]\n" \ - " ;" - -#ifdef DM_MEM_DEBUG - -#define malloc(size) dm_mem_malloc((size), __FILE__, __LINE__) -#define strdup(str) dm_mem_strdup((str), __FILE__, __LINE__) -#define free(ptr) dm_mem_free((ptr), __FILE__, __LINE__) - - -char * -dm_mem_malloc(size_t size, char *filename, int line); -char * -dm_mem_strdup(char *str, char *filename, int line); -void -dm_mem_free(void *ptr, char *filename, int line); - - -#endif - -#define DRV_TAPE_DIR "/dev/rmt" -#define DRV_DIR_TAB_SIZE 20 - -int dm_trace(mms_trace_sev_t severity, char *file, int line, char *fmt, ...); -#define TRACE(args) (void) (dm_silent() || dm_trace args) -int dm_silent(void); - -#define DRV_CALL(func, arg) \ - ((void) dm_trace(MMS_DEBUG, "Calling %s", #func), (*(jtab->func))arg) - -#define DRV_PRSV_KEY (drv->drv_prsv_key) -#define DRV_PRSV_KEY_PFX "_MMS" - -#ifdef __cplusplus -} -#endif - -#ifdef MMS_MEM_DEBUG - -#include <mms_mem_debug.h> - -#endif - -#endif /* __DM_DRIVE_H */ diff --git a/usr/src/cmd/mms/dm/common/dm_impl.h b/usr/src/cmd/mms/dm/common/dm_impl.h deleted file mode 100644 index 48f00c9600..0000000000 --- a/usr/src/cmd/mms/dm/common/dm_impl.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - -#ifndef __DM_IMPL_H -#define __DM_IMPL_H - - -#ifdef __cplusplus -extern "C" { -#endif - -#include <sys/types.h> -#include <sys/ksynch.h> -#include <netdb.h> -#include <mms_network.h> -#include <dmd_impl.h> -#include <mms_parser.h> -#include <dm_drive.h> -#include <mms_sock.h> - -typedef struct dm_wka { - uint64_t dm_flags; - int dm_counter; - pid_t dm_pid; /* drive manager's pid */ - pid_t dm_app_pid; /* targ opend by this app */ - int dm_drm_fd; /* drive manager dev fd */ - - /* - * dm_drm_path is the pseudo device the DM opens for its own use. - */ - char *dm_drm_path; /* drive manager path */ - /* /devices/pseudo/dmd0:1drm */ - major_t dm_drm_major; /* major of dm_drm_path */ - minor_t dm_drm_minor; /* minor of dm_drm_path */ - - /* - * dm_targ_base_major and dm_targ_base_minor are major and minor - * numbers of the target base device, i.e. /dev/rmt/x. - */ - char *dm_target_base; /* base device of target */ - major_t dm_targ_base_major; /* major of target base */ - minor_t dm_targ_base_minor; /* minor of target base */ - /* - * dm_targ_hdl is the pathname DM returns to the client. - */ - char *dm_targ_hdl; /* target handle for client */ - /* - * dm_hdl_major and dm_hdl_id are major and minor device numbers - * of dm_targ_hdl. - * dm_hdl_major is the same as dm_drm_major. - * dm_hdl_minor is a unique id which is used as the minor device number - * and is mapped to (dm_drm_minor + 1). - */ - major_t dm_hdl_major; /* handle major */ - minor_t dm_hdl_minor; /* handle minor == handle id */ - - char *dm_host; - char *dm_port; - char *dm_passwd; - char *dm_mm_passwd; - int dm_ssl_enabled; - char *dm_ssl_cert_file; - char *dm_ssl_pass; - char *dm_ssl_pass_file; - char *dm_ssl_crl_file; - char *dm_ssl_peer_file; - char *dm_ssl_cipher; - void *dm_ssl_data; - char *dm_hdl_prefix; - char dm_local_hostname[MAXHOSTNAMELEN + 1]; - /* local hostname */ - mms_t dm_mms_conn; /* mm connection */ - void *dm_default_lib_hdl; - void *dm_dev_lib_hdl; - int dm_msg_level; - int dm_cmd_dispatchable; - mms_list_t dm_cmd_queue; /* active cmd queue */ - mms_list_t dm_pend_ack_queue; /* cmds not accepted yet */ - pthread_cond_t dm_accept_cv; - char *dm_dev_lib; - pthread_mutex_t dm_io_mutex; /* lock for I/O */ - drm_request_t *dm_request; - drm_request_t dm_reqbuf; - char *dm_pwbuf; /* _SC_GETPW_R_SIZE_MAX */ - int dm_pwbuf_size; - - /* - * If both dm_queue_mutex and dm_worker_mutex must be held, - * lock dm_queue_mutex first before locking dm_worker_mutex. - */ - pthread_mutex_t dm_queue_mutex; /* lock for cmd queues */ - pthread_mutex_t dm_worker_mutex; /* lock for worker thread */ - pthread_cond_t dm_work_cv; - pthread_mutex_t dm_tdv_close_mutex; - pthread_cond_t dm_tdv_close_cv; - int dm_work_todo; /* work todo flag */ - struct timeval dm_mnt_start; /* mount start time */ - struct timeval dm_mnt_done; /* mount done time */ - struct timeval dm_mnt_time; /* mount time */ -} dm_wka_t; - -/* - * DM flags - */ -#define DM_SILENT (1LL << 0) /* Silent - no mms_trace */ -#define DM_OPENED (1LL << 1) /* File opened */ -#define DM_ENABLED (1LL << 2) /* DM is enabled */ -#define DM_SEND_CAPACITY (1LL << 3) /* Send capacity */ -#define DM_HAVE_SESSION (1LL << 4) /* Opened session with MM */ -#define DM_NOT_USED (1LL << 5) /* Not used */ -#define DM_SEND_EOF_POS (1LL << 6) -#define DM_PREEMPT_RSV (1LL << 7) -#define DM_ASK_PREEMPT_RSV (1LL << 8) /* ask if DM_PREEMPT_RSV */ -#define DM_RESERVE_DRIVE (1LL << 9) /* Issue reserve drive */ -#define DM_DEV_LIB_LOADED (1LL << 10) /* device lib loaded */ -#define DM_DFLT_LIB_LOADED (1LL << 11) /* default lib loaded */ -#define DM_EXIT_NORESTART (1LL << 12) /* DM is terminating */ - - -typedef struct dm_command { - mms_list_node_t cmd_next; - int cmd_flags; - int cmd_state; /* Continue from state */ - int cmd_rc; /* return code from send */ - mms_par_node_t *cmd_root; /* command root node */ - char *cmd_task; /* task string */ - int (*cmd_func)(struct dm_command *); - char *cmd_textcmd; - pthread_cond_t cmd_done_cv; - pthread_mutex_t cmd_done_mutex; -} dm_command_t; - -#define CMD_DISPATCHABLE 0x01 -#define CMD_INCOMING 0x02 -#define CMD_COMPLETE 0x04 - -#define DM_OPEN_RETRIES 30 -#define DM_OPEN_INTERVAL 3 /* number of seconds between attempts */ -#define DM_CONNECT_INTERVAL 3 /* number of seconds between attempts */ -#define DM_WRITE_ACCEPT 1 - -#define DM_DEV_LIB_DIR "/usr/lib/mms/dm" -#define DM_TRACE_DIR "/var/log/mms/dm" -#define MMS_AUTHNAME "solaris.mms.io.*" - -#define DM_COMPLETE 1 /* command completed */ -#define DM_CONTINUE 2 /* will continue */ -#define DM_NOT_COMPLETE 3 /* not complete yet */ -#define DM_ERROR (-1) -#define DM_PARTIAL_WRITE (-2) -#define DM_RESTART 2 -#define DM_NO_RESTART 1 - -extern dm_wka_t *wka; - -#define DM_REP_RESPONDED "1000" /* Response message id */ -#define DM_REP_UNATTNDED "1001" /* Unattended message id */ -#define DM_REP_ERROR (-1) -#define DM_REP_YES 0x01 -#define DM_REP_NO 0x02 -#define DM_REP_UNATTENDED 0x04 -#define DM_REP_STRING 0x08 -#define DM_REP_ABORT 0x10 -#define DM_REP_RETRY 0x20 -#define DM_FAILED 0x01 - -#define DM_EXIT(code) dm_exit(code, _SrcFile, __LINE__) - -#ifdef __cplusplus -} -#endif - -#endif /* __DM_IMPL_H */ diff --git a/usr/src/cmd/mms/dm/common/dm_mem_debug.c b/usr/src/cmd/mms/dm/common/dm_mem_debug.c deleted file mode 100644 index 1d7edc19f5..0000000000 --- a/usr/src/cmd/mms/dm/common/dm_mem_debug.c +++ /dev/null @@ -1,106 +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 <stdlib.h> -#include <strings.h> -#include <mms_trace.h> -#include <mms_list.h> - - -static char *_SrcFile = __FILE__; - - - -typedef struct dm_mem_ele { - mms_list_node_t dm_link; - char *dm_mem; - char *dm_file; - int dm_line; -} dm_mem_ele_t; - -static MMS_LIST_CREATE(dm_mem_list, dm_mem_ele_t, dm_link); - -char * -dm_malloc(size_t size, char *filename, int line) -{ - dm_mem_ele_t *ele; - - if ((ele = (dm_mem_ele_t *)malloc(sizeof (dm_mem_ele_t))) == NULL) { - return (NULL); - } - - if ((ele->dm_mem = malloc(size)) == NULL) { - free(ele); - return (NULL); - } - ele->dm_file = filename; - ele->dm_line = line; - mms_list_insert_tail(&dm_mem_list, ele); - mms_trace(MMS_DEBUG, "Allocated memory %p, %s, %d", - ele->dm_mem, ele->dm_file, ele->dm_line); - return (ele->dm_mem); -} - -char * -dm_strdup(char *str, char *filename, int line) -{ - dm_mem_ele_t *ele; - - if ((ele = malloc(sizeof (dm_mem_ele_t))) == NULL) { - return (NULL); - } - - if ((ele->dm_mem = strdup(str)) == NULL) { - free(ele); - return (NULL); - } - ele->dm_file = filename; - ele->dm_line = line; - mms_list_insert_tail(&dm_mem_list, ele); - mms_trace(MMS_DEBUG, "Allocated memory %p, %s, %d", - ele->dm_mem, ele->dm_file, ele->dm_line); - return (ele->dm_mem); -} - -void -dm_free(void *ptr, char *filename, int line) -{ - dm_mem_ele_t *ele; - dm_mem_ele_t *tmp; - - mms_list_foreach_safe(&dm_mem_list, ele, tmp) { - if (ele->dm_mem == ptr) { - mms_list_remove(&dm_mem_list, ele); - mms_trace(MMS_DEBUG, "Freed memory %p, %s, %d", - ele->dm_mem, ele->dm_file, ele->dm_line); - free(ele->dm_mem); - free(ele); - return; - } - } - mms_trace(MMS_DEBUG, "Can't free memory %p, %s, %d", - ptr, filename, line); - -} diff --git a/usr/src/cmd/mms/dm/common/dm_msg.c b/usr/src/cmd/mms/dm/common/dm_msg.c deleted file mode 100644 index 5fc6167c67..0000000000 --- a/usr/src/cmd/mms/dm/common/dm_msg.c +++ /dev/null @@ -1,219 +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. - */ - - -#include <pthread.h> -#include <strings.h> -#include <stdio.h> -#include <stdarg.h> -#include <stdlib.h> -#include <signal.h> -#include <sys/varargs.h> -#include <mms_sym.h> -#include <dm_impl.h> -#include <dm_msg.h> -#include <mms_trace.h> -#include <dm_proto.h> -#include <mms_strapp.h> - -static char *_SrcFile = __FILE__; - -void -dm_msg_create_hdr(void) -{ - dm_msg_hdr_t *mh; - - mh = (dm_msg_hdr_t *)malloc(sizeof (dm_msg_hdr_t)); - if (mh == NULL) { - TRACE((MMS_ERR, "Out of memory")); - DM_EXIT(DM_RESTART); - } - mms_list_create(&mh->msg_msglist, sizeof (dm_msg_t), - offsetof(dm_msg_t, msg_next)); - mh->msg_tid = pthread_self(); - mms_list_insert_tail(&dm_msg_hdr_list, mh); -} - -dm_msg_hdr_t * -dm_msg_get_hdr(void) -{ - pthread_t tid; - dm_msg_hdr_t *mh; - - tid = pthread_self(); - mms_list_foreach(&dm_msg_hdr_list, mh) { - if (pthread_equal(mh->msg_tid, tid)) { - return (mh); - } - } - assert(mh != NULL); - return (NULL); -} - -void -dm_msg_remove(dm_msg_t *msg) -{ - dm_msg_hdr_t *mh; - - mh = dm_msg_get_hdr(); - mms_list_remove(&mh->msg_msglist, &msg->msg_next); - if (msg->msg_text) { - free(msg->msg_text); - } - free(msg); -} - -void -dm_msg_destroy(void) -{ - dm_msg_hdr_t *mh; - dm_msg_t *msg; - dm_msg_t *tmp; - - mh = dm_msg_get_hdr(); - mms_list_foreach_safe(&mh->msg_msglist, msg, tmp) { - dm_msg_remove(msg); - } -} - -char * -dm_msg_add_aux(int tail, int class, int code, char *fmt, va_list args) -{ - va_list ap; - char *text; - dm_msg_t *msg; - dm_msg_hdr_t *mh; - - assert(fmt != NULL); - - ap = args; - text = mms_vstrapp(NULL, fmt, ap); - /* Allocate a message struct */ - msg = (dm_msg_t *)malloc(sizeof (dm_msg_t)); - if (msg == NULL) { - return (NULL); - } - memset(msg, 0, sizeof (dm_msg_t)); - - msg->msg_class = class; - msg->msg_code = code; - msg->msg_text = text; - mh = dm_msg_get_hdr(); - if (tail) { - mms_list_insert_tail(&mh->msg_msglist, msg); - } else { - mms_list_insert_head(&mh->msg_msglist, msg); - } - return (msg->msg_text); -} - -char * -dm_msg_add(int class, int code, char *fmt, ...) -{ - va_list args; - char *rc; - - va_start(args, fmt); - rc = dm_msg_add_aux(1, class, code, fmt, args); - va_end(args); - return (rc); -} - -char * -dm_msg_add_head(int class, int code, char *fmt, ...) -{ - va_list args; - char *rc; - - va_start(args, fmt); - rc = dm_msg_add_aux(0, class, code, fmt, args); - va_end(args); - return (rc); -} - -/* - * Get the first message - */ -char * -dm_msg_text(void) -{ - dm_msg_hdr_t *mh; - dm_msg_t *msg; - - mh = dm_msg_get_hdr(); - if (mms_list_empty(&mh->msg_msglist)) { - return (NULL); - } - msg = mms_list_head(&mh->msg_msglist); - return (msg->msg_text); -} - -int -dm_msg_class(void) -{ - dm_msg_hdr_t *mh; - dm_msg_t *msg; - - mh = dm_msg_get_hdr(); - if (mms_list_empty(&mh->msg_msglist)) { - return (MMS_INTERNAL); - } - msg = mms_list_head(&mh->msg_msglist); - return (msg->msg_class); -} - -int -dm_msg_code(void) -{ - dm_msg_hdr_t *mh; - dm_msg_t *msg; - - mh = dm_msg_get_hdr(); - if (mms_list_empty(&mh->msg_msglist)) { - return (MMS_DM_E_UNKNOWN); - } - msg = mms_list_head(&mh->msg_msglist); - return (msg->msg_code); -} - -char * -dm_msg_prepend(char *fmt, ...) -{ - dm_msg_hdr_t *mh; - dm_msg_t *msg; - char *newtext; - va_list args; - - va_start(args, fmt); - newtext = mms_vstrapp(NULL, fmt, args); - va_end(args); - mh = dm_msg_get_hdr(); - if (mms_list_empty(&mh->msg_msglist)) { - return (dm_msg_add(MMS_INTERNAL, MMS_DM_E_INTERNAL, newtext)); - } - msg = mms_list_head(&mh->msg_msglist); - - msg->msg_text = mms_strapp(newtext, "%s", msg->msg_text); - return (msg->msg_text); -} diff --git a/usr/src/cmd/mms/dm/common/dm_msg.h b/usr/src/cmd/mms/dm/common/dm_msg.h deleted file mode 100644 index 5fb06c061b..0000000000 --- a/usr/src/cmd/mms/dm/common/dm_msg.h +++ /dev/null @@ -1,69 +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 __DM_MSG_H -#define __DM_MSG_H - - -#ifdef __cplusplus -extern "C" { -#endif - -#include <mms_sym.h> -#include <mms_list.h> -#include <mms_dm_msg.h> - -extern mms_list_t dm_msg_hdr_list; - -#define DM_MSG_DM "dm" -#define DM_MSG_ERROR "error" - -/* - * There is a dm_msghdr_t for every pthread. - */ -typedef struct dm_msg_hdr { - mms_list_node_t msg_next; - mms_list_t msg_msglist; - pthread_t msg_tid; /* pthread id */ -} dm_msg_hdr_t; - -typedef struct dm_msg { - mms_list_node_t msg_next; - char *msg_text; /* could be NULL */ - int msg_class; /* error class */ - int msg_code; /* error code */ -} dm_msg_t; - -#define DM_MSG_ADD(x) TRACE((MMS_ERR, dm_msg_add x)) -#define DM_MSG_ADD_HEAD(x) TRACE((MMS_ERR, dm_msg_add_head x)) -#define DM_MSG_PREPEND(x) TRACE((MMS_ERR, dm_msg_prepend x)) -#define DM_ADM_ERR "administrator", "error" -#define DM_MSG_SEND(x) dm_send_message x -#define DM_MSG_REASON "dm", DMNAME, "error", dm_msg_text(), NULL - -#ifdef __cplusplus -} -#endif - -#endif /* __DM_MSG_H */ diff --git a/usr/src/cmd/mms/dm/common/dm_proto.h b/usr/src/cmd/mms/dm/common/dm_proto.h deleted file mode 100644 index 3cdca15f65..0000000000 --- a/usr/src/cmd/mms/dm/common/dm_proto.h +++ /dev/null @@ -1,311 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef __DM_PROTO_H -#define __DM_PROTO_H - - -#ifdef __cplusplus -extern "C" { -#endif - -char **dm_bld_dir_tab(void); -char *dm_bld_config_cmd(char *task); -char *dm_bld_task(char *cmd); -char *dm_char_to_hex(uchar_t *ibuf, int ilen, char *obuf, int olen); -char *dm_get_attr_value(mms_par_node_t *root, char *obj, char *attr); -char *dm_get_capabilities(char *tokens); -char *dm_get_task(mms_par_node_t *root); -char *dm_get_user(pid_t pid); -char *dm_malloc(size_t size, char *filename, int line); -char *dm_msg_add(int class, int code, char *fmt, ...); -char *dm_msg_add_aux(int tail, int class, int code, char *fmt, va_list args); -char *dm_msg_add_head(int class, int code, char *fmt, ...); -char *dm_msg_prepend(char *fmt, ...); -char *dm_msg_text(void); -char *dm_show_virt_cart_path(void); -char *dm_strdup(char *str, char *filename, int line); -char *dm_timestamp(void); -dm_command_t *dm_get_cmd_by_task(char *task); -dm_command_t *dm_send_cmd(char *cmdbuf, int (*cmd_func) (dm_command_t *), - char *task); -dm_msg_hdr_t *dm_msg_get_hdr(void); -drv_skaa_t *dm_skaa_lookup(uchar_t senkey, uchar_t asc, uchar_t ascq); -int dm_accept_cmd_aux(dm_command_t *cmd); -int dm_activate_cmd(dm_command_t *cmd); -int dm_activate_disable(dm_command_t *cmd); -int dm_activate_enable(dm_command_t *cmd); -int dm_activate_release(dm_command_t *cmd); -int dm_activate_reserve(dm_command_t *cmd); -int dm_ask_freserve(void); -int dm_ask_preempt(void); -int dm_ask_reply(char *reply); -int dm_ask_write_lbl(char *from, char *to, char *pcl); -int dm_attach_cmd(dm_command_t *cmd); -int dm_bind_raw_dev(int oflag); -int dm_bind_target(void); -int dm_bind_target_base(void); -int dm_cap_clause(char **pconf); -int dm_cap_clause_aux(char *fmt, char **pconf, drv_shape_density_t *sd); -int dm_chk_dev_auth(char *user); -int dm_chk_eof(void); -int dm_chk_uscsi_error(int ret, struct uscsi_cmd *us, int err); -int dm_close(); -int dm_cmd_response(dm_command_t *cmd); -int dm_create_eof1(void); -int dm_create_eof2(void); -int dm_create_hdr1(void); -int dm_create_hdr2(void); -int dm_create_trailor_lbls(void); -int dm_create_vol1(void); -int dm_detach_cmd(dm_command_t *cmd); -int dm_dmpm_private_cmd(dm_command_t *cmd); -int dm_drv_assigned(void); -int dm_duplicate_bit(drv_shape_density_t *sd); -int dm_duplicate_shape(drv_shape_density_t *sd, char *type); -int dm_force_release(void); -int dm_get_app_options(mms_par_node_t *); -int dm_get_bof_pos(void); -int dm_get_capacity(mms_par_node_t *); -int dm_get_default_lib_path(void); -int dm_get_dev_lib_name(void); -int dm_get_eof_pos(void); -int dm_get_hostpath(void); -int dm_get_log_sense_parm(uchar_t *page, int code, uint64_t *val); -int dm_get_mount_options(dm_command_t *cmd); -int dm_get_part_rwmode(mms_par_node_t *); -int dm_get_system_options(void); -int dm_get_target_base(void); -int dm_get_target_by_serial_num(void); -int dm_get_target_pathname(void); -int dm_goto_eof(void); -int dm_have_mms_rsv(void); -int dm_identify_cmd(dm_command_t *cmd); -int dm_init(int argc, char **argv); -int dm_init_session(int retries); -int dm_ioctl(int cmd, void *arg); -int dm_ioctl_bsb(int count); -int dm_ioctl_bsf(int count); -int dm_ioctl_clrerr(drm_reply_t *rep); -int dm_ioctl_fsb(int count); -int dm_ioctl_fsf(int count); -int dm_ioctl_get_capacity(drm_reply_t *rep); -int dm_ioctl_get_density(drm_reply_t *rep); -int dm_ioctl_getpos(drm_reply_t *rep); -int dm_ioctl_locate(drm_request_t *req); -int dm_ioctl_mtget(drm_request_t *req, drm_reply_t *rep); -int dm_ioctl_mtgetpos(drm_reply_t *rep); -int dm_ioctl_mtiocltop(drm_request_t *req, drm_reply_t *rep); -int dm_ioctl_mtrestpos(drm_request_t *req); -int dm_ioctl_rewind(void); -int dm_ioctl_seek(int count); -int dm_ioctl_set_blksize(uint64_t blksize); -int dm_ioctl_set_density(void); -int dm_ioctl_upt_capacity(void); -int dm_ioctl_wtm(int count); -int dm_load_cmd(dm_command_t *cmd); -int dm_load_default_lib(void); -int dm_load_devlib(void); -int dm_msg_class(void); -int dm_msg_code(void); -int dm_mtiocltop(drv_req_t *op); -int dm_open(drm_request_t *req, drm_reply_t *rep); -int dm_open_dm_device(void); -int dm_open_labeled(int *newfile); -int dm_open_nonlabeled(int *newfile); -int dm_open_pos(void); -int dm_pos_fseq(void); -int dm_preempt_rsv(void); -int dm_probe_dir(char *dirname); -int dm_read(drm_reply_t *rep); -int dm_read_cfg(char *cfgname); -int dm_read_err(drm_request_t *req, drm_reply_t *rep); -int dm_read_tm(drm_request_t *req); -int dm_reader(char **cmdbuf); -int dm_rebind_target(void); -int dm_release_target(void); -int dm_reserve_target(void); -int dm_reserve_target_prsv(void); -int dm_reserve_target_rsv(void); -int dm_responded_with(dm_command_t *cmd, char *keyword); -int dm_rewind_file(void); -int dm_rw_shape(char *shape); -int dm_send_capacity(mms_capacity_t *cap); -int dm_send_cartridge_media_error(void); -int dm_send_clean_request(void); -int dm_send_config(void); -int dm_send_drive_broken(void); -int dm_send_eof_pos(void); -int dm_send_error(void); -int dm_send_loaded(void); -int dm_send_ready(int msgid, ...); -int dm_send_ready_aux(char *spec, int msgid, va_list args); -int dm_send_ready_broken(int msgid, ...); -int dm_send_ready_disconnected(int msgid, ...); -int dm_send_ready_not(int msgid, ...); -int dm_send_statistics(void); -int dm_send_write_protect(int wp); -int dm_set_file_blksize(int blksize); -int dm_set_label_blksize(void); -int dm_setup_incoming_cmd(dm_command_t *cmd); -int dm_show_dca_info(mms_par_node_t **); -int dm_show_drive_dmname(char **dmname); -int dm_show_eof_pos(void); -int dm_show_mount_point(mms_par_node_t **typeroot); -int dm_show_system_options(mms_par_node_t **root); -int dm_silent(void); -int dm_stat_targ_base(void); -int dm_terminate_file(void); -int dm_trace(mms_trace_sev_t severity, char *file, int line, char *fmt, ...); -int dm_unload_cmd(dm_command_t *cmd); -int dm_update_bitformat(void); -int dm_update_capacity(void); -int dm_update_drivetype(void); -int dm_update_write_protect(void); -int dm_uscsi(struct uscsi_cmd *us); -int dm_validate_fname(void); -int dm_validate_xdate(void); -int dm_verify_target_dev(char *devname); -int dm_verify_trailor_label(char *buf); -int dm_write(drm_reply_t *rep); -int dm_write_0(drm_request_t *req, drm_reply_t *rep); -int dm_write_err(drm_request_t *req, drm_reply_t *rep); -int dm_writer(char *cmdbuf); -int dm_writer_accept(char *cmdbuf); -int dm_writer_aux(char *cmdbuf, int accept); -int drv_bind_raw_dev(int oflags); -int drv_blk_limit(mms_blk_limit_t *lmt); -int drv_bsb(uint64_t count, int cross); -int drv_bsf(uint64_t count); -int drv_clrerr(void); -int drv_eom(void); -int drv_fsb(uint64_t count, int cross); -int drv_fsf(uint64_t count); -int drv_get_blksize(uint64_t *size); -int drv_get_capacity(mms_capacity_t *cap); -int drv_get_density(int *den, int *comp); -int drv_get_drivetype(void); -int drv_get_mount_points(void); -int drv_get_pos(tapepos_t *pos); -int drv_get_serial_num(char *ser); -int drv_get_statistics(void); -int drv_get_write_protect(int *wp); -int drv_inquiry(void); -int drv_load(void); -int drv_locate(tapepos_t *pos); -int drv_log_sense(uchar_t *buf, int len, int page_control, int page_code); -int drv_mode_select(int pf, int len); -int drv_mode_sense(int page, int pc, int len); -int drv_prsv_clear(void); -int drv_prsv_preempt(char *curkey); -int drv_prsv_read_keys(char *buf, int bufsize); -int drv_prsv_read_rsv(char *buf, int bufsize); -int drv_prsv_register(void); -int drv_prsv_release(void); -int drv_prsv_reserve(void); -int drv_read(char *buf, int len); -int drv_read_tm(void); -int drv_read_attribute(uchar_t *buf, int32_t len, int servact, int32_t attr); -int drv_rebind_target(void); -int drv_release(void); -int drv_req_sense(int len); -int drv_reserve(void); -int drv_rewind(void); -int drv_seek(uint64_t count); -int drv_set_blksize(uint64_t size); -int drv_set_compression(int comp); -int drv_set_density(int den); -int drv_tell(uint64_t *count); -int drv_tur(void); -int drv_unload(void); -int drv_write(char *buf, int len); -int drv_wtm(uint64_t count); -int main(int argc, char **argv); -int64_t drv_get_avail_capacity(void); -minor_t dm_get_targ(minor_t minor); -minor_t dm_hdl_minor(void); -mms_sym_t *dm_sym_in(mms_sym_t *arr, char *token); -void *dm_worker(void *arg); -void char_to_int32(signed char *start, int len, int32_t *val); -void char_to_int64(signed char *start, int len, int64_t *val); -void char_to_uint32(uchar_t *start, int len, uint32_t *val); -void char_to_uint64(uchar_t *start, int len, uint64_t *val); -void dm_accept_cmds(void); -void dm_clear_dev(void); -void dm_destroy_cmd(dm_command_t *cmd); -void dm_destroy_dca(void); -void dm_destroy_mnt(void); -void dm_disallowed(void); -void dm_dispatch_cmds(void); -void dm_err_trace(void); -void dm_exit(int code, char *file, int line); -void dm_exit_cmd(dm_command_t *cmd); -void dm_free(void *ptr, char *filename, int line); -void dm_get_mt_error(int err); -void dm_get_mtstat(int save); -void dm_get_request(void); -void dm_init_dev_lib(void *hdl, int init); -void dm_init_log(void); -void dm_init_sense_buf(void); -void dm_init_wka(void); -void dm_mk_prsv_key(void); -void dm_mms_to_db_time(char *db); -void dm_msg_create_hdr(void); -void dm_msg_destroy(void); -void dm_msg_remove(dm_msg_t *msg); -void dm_parse_err(mms_par_node_t *root, mms_list_t *err_list); -void dm_proc_request(void); -void dm_read_input(void); -void dm_rem_old_handle(void); -void dm_reset_cmd(dm_command_t *cmd); -void dm_resp_error(char *task, int msgid, ...); -void dm_resp_success(char *task, char *text); -void dm_resp_unacceptable(int msgid, ...); -void dm_restart_session(void); -void dm_scsi_error(int err, int status, int cdblen, uchar_t *cdb, int senlen, - uchar_t *sense); -void dm_send_message(char *who, char *severity, int msgid, ...); -void dm_send_request(char **reply, int msgid, ...); -void dm_setup_sig_handler(void); -void dm_sighup(void); -void dm_sigint(void); -void dm_signal(int sig, void (*handler) ()); -void dm_sigterm(void); -void dm_sigusr1(void); -void dm_sigusr2(void); -void dm_to_upper(char *vp); -void dm_trace_drv_flags(void); -void dm_trace_mnt_flags(void); -void dm_trim_tail(char *str); -void drv_disallowed(void); -void drv_mk_prsv_key(void); -void drv_proc_error(void); -void int32_to_char(int32_t val, uchar_t *start, int len); -void int64_to_char(int64_t val, uchar_t *start, int len); - -#ifdef __cplusplus -} -#endif - -#endif /* __DM_PROTO_H */ diff --git a/usr/src/cmd/mms/dm/common/dm_request.c b/usr/src/cmd/mms/dm/common/dm_request.c deleted file mode 100644 index 61a7654e7c..0000000000 --- a/usr/src/cmd/mms/dm/common/dm_request.c +++ /dev/null @@ -1,2856 +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 <thread.h> -#include <ctype.h> -#include <sys/types.h> -#include <sys/mkdev.h> -#include <sys/file.h> -#include <synch.h> -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> -#include <time.h> -#include <stropts.h> -#include <errno.h> -#include <string.h> -#include <syslog.h> -#include <fcntl.h> -#include <sys/stat.h> -#include <pthread.h> -#include <sys/scsi/generic/sense.h> -#include <sys/scsi/impl/uscsi.h> -#include <mms_list.h> -#include <dmd_impl.h> -#include <dm_impl.h> -#include <dm_msg.h> -#include <mms_trace.h> -#include <mms_dmd.h> -#include <dm_proto.h> -#include <mms_strapp.h> - -static char *_SrcFile = __FILE__; - -void -dm_get_request(void) -{ - /* - * Get request from driver - */ - if (ioctl(wka->dm_drm_fd, DRM_REQUEST, &wka->dm_reqbuf)) { - /* - * No request, process error - */ - TRACE((MMS_DEBUG, "dm_get_request: " - "No request: %s", strerror(errno))); - return; - } - wka->dm_request = &wka->dm_reqbuf; -} - -void -dm_proc_request(void) -{ - int rc = 0; - drm_request_t *req; - drm_reply_t rep; - tapepos_t pos; - char dbuf[4096]; - - dm_msg_destroy(); /* cleanup any left over msg */ - - if (DRV_CALL(drv_get_pos, (&pos)) == 0) { - TRACE((MMS_DEBUG, "dm_proc_request: Entered at position %lld", - pos.lgclblkno)); - } - - memset(&rep, 0, sizeof (rep)); - req = wka->dm_request; - (void) mms_trace_dump((char *)req, sizeof (drm_request_t), dbuf, - sizeof (dbuf)); - TRACE((MMS_DEBUG, "dm_proc_request: Request:\n%s", dbuf)); - - /* - * Save I/O counts - */ - drv->drv_rdbytes += req->drm_req_rdbytes; - drv->drv_wrbytes += req->drm_req_wrbytes; - - if (req->drm_req_type != DRM_REQ_OPEN && - req->drm_req_type != DRM_REQ_CLOSE) { - /* - * If not an open or close request and not in user data, - * then allow only status requests. - */ - if ((drv->drv_flags & DRV_UDATA) == 0 && - req->drm_req_type != DRM_REQ_MTGET) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "file not positioned correctly")); - rc = EACCES; - goto done; - } - } - - if (req->drm_req_flags & DRM_REQ_MOVED) { - TRACE((MMS_DEBUG, "dm_get_request: Tape Moved")); - drv->drv_flags &= ~(DRV_VALID_STAT | DRV_MOVE_FLAGS); - } - - memset(&rep, 0, sizeof (drm_reply_t)); - switch (req->drm_req_type) { - case DRM_REQ_MTIOCTOP: - TRACE((MMS_INFO, "dm_get_request: " - "Got request DRM_REQ_MTIOCTOP")); - rc = dm_ioctl_mtiocltop(req, &rep); - break; - case DRM_REQ_MTIOCLTOP: - TRACE((MMS_INFO, "dm_get_request: " - "Got request DRM_REQ_MTIOCLTOP")); - rc = dm_ioctl_mtiocltop(req, &rep); - break; - case DRM_REQ_OPEN: - TRACE((MMS_INFO, "dm_get_request: " - "Got open request DRM_REQ_OPEN")); - rc = dm_open(req, &rep); - break; - case DRM_REQ_CLOSE: - TRACE((MMS_INFO, "dm_get_request: " - "Got close request DRM_REQ_CLOSE")); - rc = dm_close(); - break; - case DRM_REQ_READ: - TRACE((MMS_INFO, "dm_get_request: " - "Got read request DRM_REQ_READ")); - rc = dm_read(&rep); - break; - case DRM_REQ_READ_TM: - TRACE((MMS_INFO, "dm_get_request: " - "Got read FM request DRM_REQ_READ_TM")); - rc = dm_read_tm(req); - break; - case DRM_REQ_READ_ERR: - TRACE((MMS_INFO, "dm_get_request: " - "Got read ERR request DRM_REQ_READ_ERR")); - rc = dm_read_err(req, &rep); - break; - case DRM_REQ_WRITE: - TRACE((MMS_INFO, "dm_get_request: " - "Got write request DRM_REQ_WRITE")); - rc = dm_write(&rep); - break; - case DRM_REQ_WRITE0: - TRACE((MMS_INFO, "dm_get_request: " - "Got write0 request DRM_REQ_WRITE0")); - rc = dm_write_0(req, &rep); - break; - case DRM_REQ_WRITE_ERR: - TRACE((MMS_INFO, "dm_get_request: " - "Got write err request DRM_REQ_WRITE_ERR")); - rc = dm_write_err(req, &rep); - break; - case DRM_REQ_MTGET: - TRACE((MMS_INFO, "dm_get_request: " - "Got request DRM_REQ_MTGET")); - rc = dm_ioctl_mtget(req, &rep); - break; - case DRM_REQ_CLRERR: - TRACE((MMS_INFO, "dm_get_request: " - "Got request DRM_REQ_CLRERR")); - rc = dm_ioctl_clrerr(&rep); - break; - case DRM_REQ_BLK_LIMIT: - TRACE((MMS_INFO, "dm_get_request: " - "Got request MMS_REQ_BLK_LIMIT")); - if (drv->drv_flags & DRV_FATAL) { - rc = EIO; - break; - } - rc = DRV_CALL(drv_blk_limit, (&rep.drm_blk_limit_rep)); - break; - case DRM_REQ_GET_POS: - TRACE((MMS_INFO, "dm_get_request: " - "Got request MMS_REQ_GET_POS")); - rc = dm_ioctl_getpos(&rep); - break; - case DRM_REQ_MTGETPOS: - TRACE((MMS_INFO, "dm_get_request: " - "Got request MMS_REQ_GET_POS")); - rc = dm_ioctl_mtgetpos(&rep); - break; - case DRM_REQ_MTRESTPOS: - TRACE((MMS_INFO, "dm_get_request: " - "Got request MMS_REQ_GET_POS")); - rc = dm_ioctl_mtrestpos(req); - break; - case DRM_REQ_LOCATE: - TRACE((MMS_INFO, "dm_get_request: " - "Got request MMS_REQ_LOCATE")); - rc = dm_ioctl_locate(req); - break; - case DRM_REQ_GET_CAPACITY: - TRACE((MMS_INFO, "dm_get_request: " - "Got request MMS_REQ_GET_CAPACITY")); - rc = dm_ioctl_get_capacity(&rep); - break; - case DRM_REQ_UPT_CAPACITY: - TRACE((MMS_INFO, "dm_get_request: " - "Got request MMS_REQ_UPT_CAPACITY")); - rc = dm_ioctl_upt_capacity(); - break; - case DRM_REQ_SET_DENSITY: - TRACE((MMS_INFO, "dm_get_request: " - "Got request MMS_REQ_SET_DENSITY")); - rc = dm_ioctl_set_density(); - break; - case DRM_REQ_GET_DENSITY: - TRACE((MMS_INFO, "dm_get_request: " - "Got request MMS_REQ_GET_DENSITY")); - rc = dm_ioctl_get_density(&rep); - break; - - default: - rc = EINVAL; - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "invalid request from driver %lld", req->drm_req_type)); - rc = EINVAL; - break; - } - -done: - dm_msg_destroy(); /* clean up left over msg */ - /* - * If at EOF and don't have a valid EOF position, then get it. - */ - if (drv->drv_flags & DRV_EOF) { - (void) dm_get_eof_pos(); - } - - rep.drm_rep_rc = rc; - if (drv->drv_flags & DRV_EOF) { - TRACE((MMS_DEBUG, "dm_get_request: " - "At EOF")); - rep.drm_rep_flags |= DRM_REP_EOF; - } - - if (drv->drv_flags & DRV_FATAL) { - TRACE((MMS_DEBUG, "dm_get_request: " - "Fatal error occured")); - rep.drm_rep_flags |= DRM_REP_FATAL; - } - if (drv->drv_flags & DRV_TERM_FILE) { - TRACE((MMS_DEBUG, "dm_get_request: " - "Catch next read")); - rep.drm_rep_flags |= DRM_REP_NOTIFY_READ; - } else { - TRACE((MMS_DEBUG, "dm_get_request: " - "Catch next write")); - rep.drm_rep_flags |= DRM_REP_NOTIFY_WRITE; - } - if (req->drm_req_flags & DRM_REQ_NOTIFY_READ) { - TRACE((MMS_DEBUG, "dm_get_request: " - "Notify read in effect")); - rep.drm_rep_flags |= DRM_REP_NOTIFY_READ; - } - if (req->drm_req_flags & DRM_REQ_NOTIFY_WRITE) { - TRACE((MMS_DEBUG, "dm_get_request: " - "Notify write in effect")); - rep.drm_rep_flags |= DRM_REP_NOTIFY_WRITE; - } - - if (DRV_CALL(drv_get_pos, (&pos)) == 0) { - TRACE((MMS_DEBUG, "dm_proc_request: Resumed at position %lld", - pos.lgclblkno)); - } - - wka->dm_request = NULL; /* request done */ - ioctl(wka->dm_drm_fd, DRM_RESUME, &rep); - TRACE((MMS_DEBUG, "Resume with rc = %lld", rep.drm_rep_rc)); - - if (req->drm_req_type == DRM_REQ_OPEN) { - if (rep.drm_rep_rc == 0) { - /* Opened successfully */ - wka->dm_flags |= DM_OPENED; - } - - } - -} - -int -dm_ioctl_mtiocltop(drm_request_t *req, drm_reply_t *rep) -{ - drm_mtop_t *op = &req->drm_mtop_req; - int rc = 0; - - rep->drm_mtop_rep.drm_op = op->drm_op; - rep->drm_mtop_rep.drm_count = op->drm_count; - - switch (op->drm_op) { - case MTREW: - case MTRETEN: - TRACE((MMS_INFO, "dm_ioctl_mtiocltop: MTREW/MTRETEN")); - rc = dm_ioctl_rewind(); - break; - case MTSEEK: - TRACE((MMS_INFO, "dm_ioctl_mtiocltop: MTSEEK")); - rc = dm_ioctl_seek(op->drm_count); - break; - case MTTELL: - TRACE((MMS_INFO, "dm_ioctl_mtiocltop: MTTELL")); - drv->drv_flags &= ~DRV_VALID_STAT; - rc = DRV_CALL(drv_tell, - ((uint64_t *)&rep->drm_mtop_rep.drm_count)); - if (rc) { - DM_MSG_SEND((DM_ADM_ERR, DM_6523_MSG, DM_MSG_REASON)); - } - break; - case MTFSF: - TRACE((MMS_INFO, "dm_ioctl_mtiocltop: MTFSF")); - rc = dm_ioctl_fsf(op->drm_count); - break; - case MTFSR: - TRACE((MMS_INFO, "dm_ioctl_mtiocltop: MTFSR")); - rc = dm_ioctl_fsb(op->drm_count); - break; - case MTBSF: - TRACE((MMS_INFO, "dm_ioctl_mtiocltop: MTBSF")); - rc = dm_ioctl_bsf(op->drm_count); - break; - case MTBSR: - TRACE((MMS_INFO, "dm_ioctl_mtiocltop: MTBSR")); - rc = dm_ioctl_bsb(op->drm_count); - break; - case MTWEOF: - TRACE((MMS_INFO, "dm_ioctl_mtiocltop: MTWEOF")); - rc = dm_ioctl_wtm(op->drm_count); - break; - case MTEOM: - TRACE((MMS_INFO, "dm_ioctl_mtiocltop: MTEOM")); - rc = dm_goto_eof(); - break; - case MTSRSZ: - TRACE((MMS_INFO, "dm_ioctl_mtiocltop: MTSRSZ")); - /* - * You're allowed to set any record size any time. - */ - rc = dm_ioctl_set_blksize(op->drm_count); - break; - case MTGRSZ: - TRACE((MMS_INFO, "dm_ioctl_mtiocltop: MTGRSZ")); - if (drv->drv_flags & DRV_FATAL) { - rc = EIO; - break; - } - rc = DRV_CALL(drv_get_blksize, - ((uint64_t *)&rep->drm_mtop_rep.drm_count)); - if (rc) { - DM_MSG_SEND((DM_ADM_ERR, DM_6514_MSG, DM_MSG_REASON)); - } - rep->drm_mtop_rep.drm_op = MTGRSZ; - break; - - default: - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "0x%x", (int)op->drm_op)); - DM_MSG_SEND((DM_ADM_ERR, DM_6515_MSG, DM_MSG_REASON)); - rc = EINVAL; - break; - } - - return (rc); -} - - -int -dm_open(drm_request_t *req, drm_reply_t *rep) -{ - int newfile = 0; - drm_open_t *oreq = &req->drm_open_req; - tapepos_t pos; - int rc = 0; - char *user; - - TRACE((MMS_DEBUG, "dm_open: Enter dm_open")); - - /* - * Must be attached to open - */ - if ((drv->drv_flags & DRV_ATTACHED) == 0) { - /* Not attached */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Drive not attached")); - rc = ENODEV; - goto fatal; - } - - if (wka->dm_hdl_minor != oreq->drm_open_minor) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Target ID mismatch, requested %lld, have %d", - oreq->drm_open_minor, wka->dm_hdl_minor)); - rc = ENODEV; - goto fatal; - } - - /* Return EBUSY if already opened */ - if (wka->dm_app_pid) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Already opened by pid = %d", wka->dm_app_pid)); - rc = EBUSY; - goto fatal; - } - - /* - * Save application's pid and user name - */ - wka->dm_app_pid = req->drm_req_pid; - user = dm_get_user(req->drm_req_pid); - if (user == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Unable to get user from uid %lld", req->drm_req_uid)); - rc = EPERM; - goto fatal; - } - - /* - * Check user authentication - */ - if (dm_chk_dev_auth(user) != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "User %s is not authorized to use MMS", - user)); - rc = EPERM; - goto fatal; - } - - - if ((drv->drv_flags & DRV_LOADED) == 0) { - /* Cartridge is not loaded */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Cartridge %s, Volume %s not loaded", - mnt->mnt_pcl, mnt->mnt_volumename)); - rc = ENOTTY; - goto fatal; - } - - /* - * Check MMS mode - */ - if ((mnt->mnt_flags & MNT_MMS) == 0) { - /* In raw mode */ - TRACE((MMS_DEBUG, "dm_open: RAW mode")); - rc = ioctl(wka->dm_drm_fd, DRM_MMS_MODE, 0); - if (rc < 0) { - rc = errno; - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Cannot set raw mode: %s", strerror(rc))); - goto fatal; - } - - if (DRV_CALL(drv_bind_raw_dev, - (req->drm_open_req.drm_open_flags | FNDELAY)) != 0) { - rc = errno; - DM_MSG_PREPEND(("Cannot set raw mode: %s: ", - strerror(rc))); - goto fatal; - } - /* The entire tape is user data in non MMS mode */ - drv->drv_flags |= DRV_UDATA; - drv->drv_numopens++; /* 1 more open */ - drv->drv_flags |= DRV_OPENED; - /* - * Set the bit format - */ - if (dm_update_bitformat()) { - DM_MSG_PREPEND(("update bit format error: ")); - rc = EIO; - goto fatal; - } - - return (0); - } - - /* - * MMS mode - */ - - /* - * Save open flags - */ - drv->drv_oflags = oreq->drm_open_flags; - - /* - * Set readonly/readwrite flags - */ - if ((drv->drv_oflags & O_RDONLY) || - (mnt->mnt_flags & MNT_READONLY)) { - TRACE((MMS_DEBUG, "readonly open option")); - drv->drv_flags |= DRV_READONLY; - } - - if (mnt->mnt_flags & MNT_READWRITE) { - if (drv->drv_flags & DRV_READONLY) { - TRACE((MMS_DEBUG, "dm_open: explicit readwrite " - "on mount command overrides readonly option")); - drv->drv_flags &= ~DRV_READONLY; - } - } - - if (drv->drv_flags & DRV_WRITEPROTECTED) { - TRACE((MMS_DEBUG, "dm_open: cartridge writeprotected")); - drv->drv_flags |= DRV_READONLY; - } - - /* - * Set disposition of file - */ - if ((drv->drv_oflags & FCREAT) || (mnt->mnt_flags & MNT_CREAT)) { - drv->drv_flags |= DRV_CREAT; - } - - if (drv->drv_oflags & FAPPEND) { - drv->drv_flags |= DRV_APPEND; - } - - /* - * Save current tape position before validation. We may have to - * return to this position if the rest of open fails. - */ - if (DRV_CALL(drv_get_pos, (&pos)) != 0) { - DM_MSG_PREPEND(("unable to get current position: ")); - rc = EIO; - goto fatal; - } - drv->drv_cur_pos = pos; - - /* - * Determine if a new file should be created - */ - if (drv->drv_lbl_type != DRV_NL) { - rc = dm_open_labeled(&newfile); - } else { - rc = dm_open_nonlabeled(&newfile); - } - if (rc != 0) { - goto fatal; - } - - if (newfile && - (drv->drv_flags & DRV_READONLY)) { - /* Readonly is for old only */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "cannot write to readonly")); - rc = EACCES; - goto fatal; - } - - /* - * Set record format - */ - if (mnt->mnt_flags & MNT_FIXED) { - drv->drv_flags |= DRV_FIXED; - drv->drv_flags &= ~DRV_VARIABLE; - } else { - drv->drv_flags &= ~DRV_FIXED; - drv->drv_flags |= DRV_VARIABLE; - } - - TRACE((MMS_DEBUG, "dm_open: %s, %s, %s, %s", - drv->drv_flags & DRV_CREAT ? "CREAT" : "OLD", - drv->drv_flags & DRV_READONLY ? "READONLY" : "READWRITE", - drv->drv_flags & DRV_APPEND ? "APPEND" : "NOT_APPEND", - drv->drv_flags & DRV_FIXED ? "FIXED" : "VARIABLE")); - - if (newfile) { - /* Turn off append */ - drv->drv_flags &= ~DRV_APPEND; - - /* - * Check expiration date. - */ - if (drv->drv_lbl_type != DRV_NL) { - if (dm_validate_xdate() != 0) { - DM_MSG_PREPEND(("Existing file not expired: ")); - /* Existing file not expired */ - rc = EACCES; - goto fatal; - } - } - - if (dm_set_label_blksize() != 0) { - DM_MSG_PREPEND(("Set label blksize error: ")); - rc = EIO; - goto fatal; - } - if (mnt->mnt_fseq == 1) { - /* - * If mounted tape is NL, then decide whether to - * write new label to AL. - */ - if (drv->drv_lbl_type == DRV_NL) { - if (dm_ask_write_lbl("NL", "AL", - mnt->mnt_pcl) != 0) { - /* Don't write new label */ - rc = EACCES; - goto fatal; - } - } - /* - * If creating the first file, rewind - * to BOM and set density and create - * VOL1 again - */ - if (DRV_CALL(drv_rewind, ())) { - rc = EIO; - goto fatal; - } - if ((mnt->mnt_flags & MNT_AUTO_DEN) == 0) { - if (DRV_CALL(drv_set_density, (mnt-> - mnt_density->sym_code)) != 0) { - rc = EIO; - goto fatal; - } - } - if (dm_create_vol1() != 0) { - rc = EIO; - goto fatal; - } - } else { - /* fseq != 1 */ - if (DRV_CALL(drv_locate, (&pos)) != 0) { - rc = EIO; - goto fatal; - } - } - /* Create file, write hdr label */ - if (dm_create_hdr1() != 0) { - rc = EIO; - goto fatal; - } - if (dm_create_hdr2() != 0) { - rc = EIO; - goto fatal; - } - if (DRV_CALL(drv_wtm, (1)) != 0) { - rc = EIO; - goto fatal; - } - drv->drv_flags &= ~DRV_TM; - drv->drv_flags |= - (DRV_TERM_FILE | DRV_BOF | DRV_UDATA | - DRV_VALIDATED_FNAME); - if (dm_get_bof_pos() != 0) { - rc = EIO; - goto fatal; - } - } - - if ((drv->drv_flags & DRV_VALIDATED_FNAME) == 0) { - /* - * File must be validated by now - */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Unable to validate filename")); - rc = EACCES; - goto fatal; - } - - if ((drv->drv_flags & DRV_UDATA) == 0) { - /* - * Validated and not in user data, then - * position file to BOF - */ - if (DRV_CALL(drv_fsf, (1)) != 0) { - DM_MSG_PREPEND(("spacing to user data error: ")); - rc = EIO; - goto fatal; - } - drv->drv_flags &= ~DRV_TM; - drv->drv_flags |= (DRV_BOF | DRV_UDATA); - if (dm_get_bof_pos() != 0) { - DM_MSG_PREPEND(("cannot get bof position: ")); - rc = EIO; - goto fatal; - } - } - - if ((drv->drv_flags & DRV_UDATA) == 0) { - /* - * Must be in user data now - */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Unable to reach user data in file")); - rc = EACCES; - goto fatal; - } - - if ((drv->drv_flags & DRV_VALID_BOF_POS) == 0) { - /* - * Must have BOF position - */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Unable to get BOF position")); - rc = EACCES; - goto fatal; - } - - /* - * Get EOF position from MM - */ - if (newfile) { - drv->drv_flags &= ~DRV_VALID_EOF_POS; - drv->drv_flags |= DRV_UPDATE_EOF_POS; - /* ignore send error */ - (void) dm_send_eof_pos(); - } else if ((drv->drv_flags & DRV_VALID_EOF_POS) == 0) { - if (dm_show_eof_pos() != 0) { - drv->drv_flags &= ~DRV_VALID_EOF_POS; - } - } - - /* - * Position in the file - */ - if (newfile == 0) { - if (dm_open_pos() != 0) { - /* Error */ - DM_MSG_PREPEND(("unable to reposition file: ")); - rc = EIO; - goto fatal; - } - } - - /* - * Now that the file is positioned correctly, reset the disposition - * so that open flags will be used. - */ - mnt->mnt_flags &= ~(MNT_CREAT | MNT_OLD); - drv->drv_flags &= ~DRV_CREAT; /* and turn off create */ - - /* - * Switch to user's file - */ - if (DRV_CALL(drv_bind_raw_dev, - (req->drm_open_req.drm_open_flags | FNDELAY) != 0)) { - rc = errno; - DM_MSG_PREPEND(("Raw device open error: %s: ", strerror(rc))); - wka->dm_app_pid = 0; - goto fatal; - } - TRACE((MMS_DEBUG, "Opened by pid %d", (int)wka->dm_app_pid)); - - /* - * Set up file blksize, density and compression - */ - if (dm_set_file_blksize(-1) != 0) { - /* - * Rebind to target base - */ - DM_MSG_PREPEND(("set file blocksize error: ")); - if (DRV_CALL(drv_rebind_target, ()) != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Rebind base device error: %s", - strerror(errno))); - } - rc = EIO; - goto fatal; - } - - /* - * Set the bit format - */ - if (dm_update_bitformat() != 0) { - DM_MSG_PREPEND(("unable to update bit format: ")); - rc = EIO; - goto fatal; - } - rep->drm_rep_flags |= (DRM_REP_NOTIFY_WRITE | DRM_REP_NOTIFY_READ); - if (rc == 0) { - /* Successfully positioned, turn off append */ - drv->drv_flags &= ~DRV_APPEND; - drv->drv_flags |= DRV_OPENED; - } - free(user); - return (rc); - -fatal: - free(user); - wka->dm_app_pid = 0; - DRV_CALL(drv_locate, (&pos)); - DM_MSG_SEND((DM_ADM_ERR, DM_6516_MSG, DM_MSG_REASON)); - (void) dm_set_label_blksize(); - return (rc); - -} - -int -dm_open_labeled(int *newfile) -{ - /* - * Position to the file seq - */ - if (dm_pos_fseq() != 0) { - return (EIO); - } - - if (drv->drv_fseq != mnt->mnt_fseq) { - /* - * We must be at the file requested by the user - */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Unable to reach requested file")); - return (EIO); - } - - /* - * Determine if a new file will be created - */ - - *newfile = 0; - if (drv->drv_flags & DRV_CREAT) { - /* - * Create a new file - */ - *newfile = 1; - if (drv->drv_flags & DRV_UDATA) { - if (drv->drv_fseq == 1) { - if (DRV_CALL(drv_rewind, ()) != 0 || - DRV_CALL(drv_fsb, (1, - DRV_LOGICAL_CROSS_TM)) != 0) { - DM_MSG_PREPEND(("unable to " - "position cartridge: ")); - return (EIO); - } - } else { - if (dm_rewind_file() != 0 || - DRV_CALL(drv_bsf, (2)) != 0 || - DRV_CALL(drv_fsf, (1)) != 0) { - DM_MSG_PREPEND(("unable to " - "position cartridge: ")); - return (EIO); - } - } - drv->drv_flags &= ~DRV_UDATA; - } - if ((drv->drv_flags & DRV_VALIDATED_FNAME) != 0) { - if (dm_validate_fname() != 0) { - return (ENOENT); - } - } - drv->drv_flags |= DRV_VALIDATED_FNAME; - } else { - /* - * Writing over an existing file - */ - if ((drv->drv_flags & DRV_UDATA) == 0) { - /* Not in user data and validate filename */ - if ((drv->drv_flags & DRV_VALIDATED_FNAME) == 0) { - if (dm_validate_fname() != 0) { - return (EACCES); - } - } - } - } - - /* - * Set up blocksize - */ - if (drv->drv_flags & DRV_CREAT) { - drv->drv_file_blksize = mnt->mnt_blksize > 0 ? - mnt->mnt_blksize : drv->drv_dflt_blksize; - } else { - drv->drv_file_blksize = mnt->mnt_blksize > 0 ? - mnt->mnt_blksize : drv->drv_lbl_blksize; - } - return (0); -} - -int -dm_open_nonlabeled(int *newfile) -{ - /* - * Mounted cartridge is NL - * If mount option is AL, then create label if not done already - */ - if (mnt->mnt_lbl_type == DRV_AL && (drv->drv_flags & DRV_BOM)) { - /* Can only create fseq 1 */ - if (mnt->mnt_fseq > 1) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Do not support fseq = %d", mnt->mnt_fseq)); - return (ENOENT); - } - /* - * Must create a new file - */ - *newfile = 1; - - /* - * Set up blocksize - */ - drv->drv_file_blksize = mnt->mnt_blksize > 0 ? - mnt->mnt_blksize : drv->drv_dflt_blksize; - } - - return (0); -} - -int -dm_validate_xdate(void) -{ - time_t curtime; - int curdate; - int xdate; - int tmp; - int i; - char lxdate[7]; - struct tm tm; - - if (mnt->mnt_lbl_type == DRV_NL) { - /* nonlabeled */ - return (0); - } - - strncpy(lxdate, drv->drv_hdr1.hdr1_xdate, 6); - lxdate[6] = '\0'; - if (strncmp(lxdate + 1, "00000", 5) == 0) { - /* No expiration date used */ - return (0); - } - - /* - * If date is invalid, then ignore - */ - if (lxdate[0] != ' ' && lxdate[0] != '0') { - goto invalid_xdate; - } - for (i = 0; i < 5; i++) { - if (!isdigit(lxdate[1 + i])) { - goto invalid_xdate; - } - } - sscanf(lxdate + 3, "%d", &tmp); - if (tmp < 1 || tmp > 366) { - goto invalid_xdate; - } - - if ((drv->drv_flags & DRV_VALIDATE_XDATE) == 0) { - /* Don't validate expiration date */ - return (0); - } - - /* - * Get expiration date since 1900 - */ - sscanf(lxdate + 1, "%d", &xdate); - if (lxdate[0] == '0') { - /* years since 1900 */ - xdate += 100000; - } - - /* - * Get current date since 1900 - */ - curtime = time(NULL); - localtime_r(&curtime, &tm); - curdate = tm.tm_year * 1000 + tm.tm_yday + 1; - - if (xdate > curdate) { - /* file not expired */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Existing file not expired: " - "expiration date = %s", lxdate)); - return (-1); - } else { - /* File expired */ - return (0); - } - -invalid_xdate: - TRACE((MMS_DEBUG, "invalid expiration date: %s", lxdate)); - return (0); -} - -/* - * Currently, only one file is supported on each volume, so fseq can only be 1. - */ - -int -dm_pos_fseq(void) -{ - if (drv->drv_fseq == 0) { - /* Tape not positioned */ - if (DRV_CALL(drv_rewind, ()) != 0) { - return (EIO); - } - if (drv->drv_lbl_type != DRV_NL) { - if (DRV_CALL(drv_fsb, (1, DRV_LOGICAL_CROSS_TM))) { - return (EIO); - } - } - drv->drv_flags &= ~(DRV_UDATA | DRV_BOF | - DRV_EOF | DRV_TM | DRV_HDR1 | - DRV_HDR2 | DRV_EOF1 | DRV_EOF2); - drv->drv_fseq = 1; - } - - if (mnt->mnt_fseq == drv->drv_fseq) { - /* Already positioned to file */ - return (0); - } - - /* - * We don't support fseq > 1 for the time being - */ - if (mnt->mnt_fseq > 1) { - return (EINVAL); - } - - return (0); -} - -int -dm_get_bof_pos(void) -{ - if ((drv->drv_flags & DRV_BOF) == 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Not at BOF. Can't get BOF position")); - return (EACCES); - } - - if (DRV_CALL(drv_get_pos, (&drv->drv_bof_pos)) != 0) { - return (EIO); - } - drv->drv_flags |= DRV_VALID_BOF_POS; - return (0); -} - -int -dm_get_eof_pos(void) -{ - if ((drv->drv_flags & DRV_EOF) == 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "not at EOF. cannot get EOF position")); - return (EACCES); - } - - if (DRV_CALL(drv_get_pos, (&drv->drv_eof_pos)) != 0) { - return (EIO); - } - drv->drv_flags |= DRV_VALID_EOF_POS; - drv->drv_cur_pos = drv->drv_eof_pos; - return (0); -} - -int -dm_open_pos(void) -{ - if ((drv->drv_flags & DRV_UDATA) == 0) { - /* - * Must be in uset data to do positioning at open - */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Not in user data. Can't do open position")); - return (EACCES); - } - - if ((drv->drv_flags & DRV_VALID_BOF_POS) == 0) { - /* - * Must have BOF position - */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Don't have BOF position. " "Can't do open position")); - return (EACCES); - } - - if (drv->drv_flags & DRV_CREAT) { - if (DRV_CALL(drv_locate, (&drv->drv_bof_pos)) != 0) { - return (EIO); - } - drv->drv_cur_pos = drv->drv_bof_pos; - } else if (drv->drv_flags & DRV_APPEND) { - /* Go to eof */ - return (dm_goto_eof()); - } - return (0); -} - -int -dm_goto_eof(void) -{ - char buf[80] = ""; - int rc; - tapepos_t cur_pos = drv->drv_cur_pos; - - if (drv->drv_flags & DRV_FATAL) { - return (EIO); - } - - if ((drv->drv_flags & DRV_UDATA) == 0) { - /* - * Must be in user data to go to EOF - */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Not in user data. Can't go to EOF")); - return (EACCES); - } - - if (DRV_CALL(drv_get_pos, (&cur_pos)) != 0) { - return (EIO); - } - drv->drv_flags &= ~(DRV_TM | DRV_EOF); - - /* - * If eof position is valid, then locate to it - */ - if (dm_set_label_blksize()) { - return (EIO); - } - if (drv->drv_flags & DRV_VALID_EOF_POS) { - if (DRV_CALL(drv_locate, (&drv->drv_eof_pos)) != 0) { - goto repos; - } - drv->drv_cur_pos = drv->drv_eof_pos; - /* - * If this is really EOF, then the next block must be a - * tapemark followed by the trailor label. - */ - if (DRV_CALL(drv_fsb, (1, DRV_LOGICAL_CROSS_TM)) != 0) { - /* Could not space 1 block */ - /* We're at EOF if we hit EOM or blank check */ - drv->drv_flags &= ~DRV_VALID_STAT; - if (serr->se_senkey == SUN_KEY_EOT || - serr->se_senkey == KEY_BLANK_CHECK) { - TRACE((MMS_DEBUG, "Hit EOT/BLANK CHECK")); - goto done; - } - /* - * Hit a tapemark, read the next block to see if it is a - * trailor label. - */ - if ((drv->drv_flags & DRV_TM) != 0) { - if (DRV_CALL(drv_read, (buf, 80)) != 80) { - /* - * We're at EOF if we hit EOM or - * blank check - */ - if (serr->se_senkey == SUN_KEY_EOT || - serr->se_senkey == - KEY_BLANK_CHECK) { - TRACE((MMS_DEBUG, - "Hit EOT/BLANK CHECK")); - drv->drv_flags &= - ~DRV_VALID_EOF_POS; - goto done; - } else { - /* other error */ - goto repos; - } - } - /* - * Read an 80 byte record - */ - if (dm_verify_trailor_label(buf) == 0) { - TRACE((MMS_DEBUG, "Found EOF")); - if (DRV_CALL(drv_locate, - (&drv->drv_eof_pos)) != 0) { - /* - * Can't reposition - * to EOF - */ - goto repos; - } - drv->drv_cur_pos = drv->drv_eof_pos; - goto done; - } - } else { - /* All errors, do it the hard way */ - goto repos; - } - } else { - /* Skipped a block, this is not EOF for sure */ - goto repos; - } -repos: - /* - * Don't find trailor label. - * Return to where we started and try to locate EOF - * the hard way. - */ - if (dm_set_file_blksize(drv->drv_cur_blksize)) { - return (EIO); - } - drv->drv_flags &= ~DRV_VALID_EOF_POS; - buf[0] = '\0'; - if (DRV_CALL(drv_locate, (&cur_pos)) != 0) { - return (EIO); - } - drv->drv_cur_pos = cur_pos; - drv->drv_flags &= ~(DRV_TM | DRV_EOF); - } - - /* - * Eof position is not valid, find eof the hard way - */ - - if (dm_set_label_blksize()) { - return (EIO); - } - for (;;) { - if (DRV_CALL(drv_fsf, (1)) != 0) { - /* We're at EOF if we hit EOM or blank check */ - if (serr->se_senkey == SUN_KEY_EOT || - serr->se_senkey == KEY_BLANK_CHECK) { - TRACE((MMS_DEBUG, "Hit EOT/BLANK CHECK")); - goto done; - } - goto err; - } - /* - * Try to read the next block to see if it is a trailor label. - * Skip over any tapemark we encounter - */ - while ((rc = DRV_CALL(drv_read, (buf, 80))) != 80) { - /* We're at EOF if we hit EOM or blank check */ - if (serr->se_senkey == SUN_KEY_EOT || - serr->se_senkey == KEY_BLANK_CHECK) { - TRACE((MMS_DEBUG, "Hit EOT/BLANK CHECK")); - drv->drv_flags |= DRV_EOF; - DRV_CALL(drv_clrerr, ()); - goto done; - } else if (drv->drv_flags & DRV_TM) { - /* Hit a tapemark */ - continue; /* Check for eof label */ - } else if (rc > 0) { - /* Read a short block */ - continue; - } else { - /* other error */ - goto err; - } - } - if (rc != 80) { - /* Read a short block */ - continue; - } - /* - * Read an 80 byte record - */ - if (strncmp(buf, "EOF1", 4) == 0 || - strncmp(buf, "EOV1", 4) == 0) { - if (dm_verify_trailor_label(buf) != 0) { - /* Invalid label structure */ - TRACE((MMS_ERR, "Invalid trailor label")); - errno = EINVAL; - goto err; - } - /* Found the EOF/EOV label */ - TRACE((MMS_DEBUG, "Found EOF")); - break; - } - } - /* - * We've read a trailor label. Position to the end of user data. - */ - if (DRV_CALL(drv_bsf, (1)) != 0) { - goto err; - } - -done: - drv->drv_flags &= ~DRV_TM; - drv->drv_flags |= DRV_EOF; - if (dm_set_file_blksize(drv->drv_cur_blksize)) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Set file blksize error")); - goto err; - } - - if ((drv->drv_flags & DRV_VALID_EOF_POS) == 0) { - if (dm_get_eof_pos()) { - TRACE((MMS_DEBUG, "Can't get EOF pos")); - goto err; - } - drv->drv_flags |= DRV_UPDATE_EOF_POS; - } - return (0); - -err: - /* - * Error going to EOF, reposition to where we started and return error - */ - DRV_CALL(drv_clrerr, ()); - DRV_CALL(drv_locate, (&cur_pos)); - if (dm_set_file_blksize(drv->drv_cur_blksize)) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Set file blksize error")); - } - return (EIO); -} - -int -dm_verify_trailor_label(char *buf) -{ - drv_eof1_t *eof1 = (drv_eof1_t *)buf; - drv_eov1_t *eov1 = (drv_eov1_t *)buf; - drv_hdr1_t *hdr1 = &drv->drv_hdr1; - - if (strncmp(eof1->eof1_id, "EOF1", 4) == 0) { - if (strncmp(eof1->eof1_fseq, hdr1->hdr1_fseq, 4)) { - /* - * EOF1 does not match HDR1 - */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "EOF1 label does not match HDR1 label")); - return (-1); - } - } else if (strncmp(eov1->eov1_id, "EOV1", 4) == 0) { - if (strncmp(eov1->eov1_fseq, hdr1->hdr1_fseq, 4)) { - /* - * EOV1 does not match HDR1 - */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "EOV1 label does not match HDR1 label")); - return (-1); - } - } - - return (0); -} - -int -dm_chk_eof(void) -{ - int rc; - char buf[80] = ""; - tapepos_t pos; - - if (DRV_CALL(drv_get_pos, (&pos)) != 0) { - return (EIO); - } - - if ((rc = DRV_CALL(drv_read, (buf, 80))) <= 0) { - /* We're at EOF if we hit EOM or blank check */ - if (serr->se_senkey == SUN_KEY_EOT || - serr->se_senkey == KEY_BLANK_CHECK) { - TRACE((MMS_DEBUG, "Hit EOT/BLANK CHECK")); - drv->drv_flags |= DRV_EOF; - if (dm_get_eof_pos()) { - rc = EIO; - } else { - rc = 0; - } - } else { - /* Other error */ - DRV_CALL(drv_clrerr, ()); - rc = EIO; - } - } else if (rc >= 80 && - (strncmp(buf, "EOF1", 4) == 0 || strncmp(buf, "EOV1", 4) == 0)) { - TRACE((MMS_DEBUG, "Found EOF1/EOV1")); - rc = 0; - } - - DRV_CALL(drv_locate, (&pos)); - return (rc); -} - -int -dm_validate_fname(void) -{ - int rc; - drv_hdr1_t *hdr1 = &drv->drv_hdr1; - drv_hdr2_t *hdr2 = &drv->drv_hdr2; - char tmp[18]; - - drv->drv_flags &= ~DRV_FIXED; /* assume variable */ - drv->drv_flags |= DRV_VARIABLE; - drv->drv_file_blksize = drv->drv_dflt_blksize; /* default blksize */ - - if ((drv->drv_flags & DRV_HDR1) == 0) { - rc = DRV_CALL(drv_read, ((char *)&drv->drv_hdr1, 80)); - if (rc != 80 || - strncmp(drv->drv_hdr1.hdr1_id, "HDR1", 4) != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "invalid header label structure, no HDR1")); - return (EINVAL); - } - drv->drv_flags |= DRV_HDR1; - - strncpy(drv->drv_fid, drv->drv_hdr1.hdr1_fid, 17); - drv->drv_fid[17] = '\0'; - } - - /* - * Validate filename - */ - if (drv->drv_flags & DRV_VALIDATE_FNAME) { - /* validate filename */ - if (strncmp(drv->drv_hdr1.hdr1_fid, mnt->mnt_fname, 17) != 0) { - /* Mismatch filename */ - strncpy(tmp, drv->drv_hdr1.hdr1_fid, 17); - tmp[17] = '\0'; - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "filename mismatch: " - "label %s, specified %s", tmp, mnt->mnt_fname)); - } else { - /* File verified */ - drv->drv_flags |= DRV_VALIDATED_FNAME; - } - } else { - /* File verified */ - drv->drv_flags |= DRV_VALIDATED_FNAME; - } - - /* - * HDR2 is optional - */ - if ((drv->drv_flags & DRV_HDR2) == 0) { - rc = DRV_CALL(drv_read, ((char *)&drv->drv_hdr2, 80)); - - /* - * HDR2 optional. If no HDR2, then there must be a tapemark. - */ - if ((drv->drv_flags & DRV_TM) != 0) { - TRACE((MMS_DEBUG, "No HDR2")); - return (0); - } - - if (rc != 80 || - strncmp(drv->drv_hdr2.hdr2_id, "HDR2", 4) != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "invalid header label structure, " - "invalid HDR2")); - return (EIO); - } - - drv->drv_flags |= DRV_HDR2; - - if (hdr2->hdr2_rformat == 'F') { - drv->drv_flags |= DRV_FIXED; - drv->drv_flags &= ~DRV_VARIABLE; - } else { - drv->drv_flags &= ~DRV_FIXED; - drv->drv_flags |= DRV_VARIABLE; - } - - if (strncmp(hdr1->hdr1_impid, DRV_IMPID, DRV_IMPID_LEN) == 0 || - strncmp(hdr1->hdr1_impid, DRV_IMPID2, DRV_IMPID_LEN) == 0) { - /* Label created by MMS */ - strncpy(tmp, hdr2->hdr2_blksize, - sizeof (hdr2->hdr2_blksize)); - tmp[sizeof (hdr2->hdr2_blksize)] = '\0'; - sscanf(tmp, "%d", &drv->drv_lbl_blksize); - } else { - /* Label not created by MMS */ - strncpy(tmp, hdr2->hdr2_blklen, 5); - tmp[5] = '\0'; - sscanf(tmp, "%d", &drv->drv_lbl_blksize); - if (drv->drv_lbl_blksize >= 99999) { - drv->drv_lbl_blksize = drv->drv_dflt_blksize; - } - } - } - return (0); -} - - -int -dm_close(void) -{ - TRACE((MMS_DEBUG, "Closing file")); - - /* - * In MMS mode, terminate the tape if necessary - */ - if (mnt->mnt_flags & MNT_MMS) { - if (drv->drv_flags & DRV_UDATA) { - if (drv->drv_flags & DRV_TERM_FILE) { - drv->drv_flags |= DRV_EOF; - if (drv->drv_flags & DRV_UPDATE_EOF_POS) { - (void) dm_get_eof_pos(); - } - /* - * Ignore error since there isn't anything - * we can do except get it recorded. - */ - (void) dm_terminate_file(); - drv->drv_flags &= ~DRV_TERM_FILE; - } - if ((mnt->mnt_flags & MNT_NOREWIND) == 0) { - /* Rewind at close */ - TRACE((MMS_DEBUG, "Rewind on close")); - DRV_CALL(drv_locate, (&drv->drv_bof_pos)); - drv->drv_cur_pos = drv->drv_bof_pos; - } - } - } - - /* - * Rebind to target base - */ - if (DRV_CALL(drv_rebind_target, ()) != 0) { - TRACE((MMS_ERR, "Rebind base device error: %s", - strerror(errno))); - drv->drv_flags |= DRV_FATAL; - TRACE((MMS_DEBUG, "FATAL error")); - } - dm_clear_dev(); - - ioctl(wka->dm_drm_fd, DRM_MMS_MODE, 1); - if (drv->drv_flags & DRV_UPDATE_EOF_POS) { - wka->dm_flags |= DM_SEND_EOF_POS; - drv->drv_flags &= ~DRV_UPDATE_EOF_POS; - } - if (drv->drv_flags & DRV_UPDATE_CAPACITY) { - wka->dm_flags |= DM_SEND_CAPACITY; - drv->drv_flags &= ~DRV_UPDATE_CAPACITY; - } - wka->dm_app_pid = 0; - TRACE((MMS_DEBUG, "Closed by pid %d", (int)wka->dm_app_pid)); - drv->drv_flags &= ~DRV_OPENED; - pthread_mutex_lock(&wka->dm_worker_mutex); - wka->dm_work_todo = 1; - pthread_cond_broadcast(&wka->dm_work_cv); - pthread_mutex_unlock(&wka->dm_worker_mutex); - return (0); -} - -/* - * Terminate a acrtridge by writing either two tapemarks or trailor labels - */ -int -dm_terminate_file(void) -{ - tapepos_t pos; - int rc = 0; - int i; - - /* - * At EOF now - */ - drv->drv_flags |= DRV_EOF; - - if ((drv->drv_flags & DRV_UDATA) == 0) { - /* - * Must be in user data to terminate file - */ - TRACE((MMS_ERR, "Not in user data. Can't terminate file")); - return (EACCES); - } - - if ((drv->drv_flags & DRV_TERM_FILE) == 0) { - /* - * Must have set DRV_TERM_FILE to terminate a file - */ - TRACE((MMS_ERR, - "DRV_TERM_FILE not set. Can't terminate file")); - } - - /* - * Save EOF pos - */ - (void) dm_get_eof_pos(); - - /* - * Save capacity of cartridge - */ - drv->drv_avail = DRV_CALL(drv_get_avail_capacity, ()); - drv->drv_pc_avail = (drv->drv_avail * 100) / drv->drv_capacity; - drv->drv_flags |= DRV_UPDATE_CAPACITY; - - if (DRV_CALL(drv_get_pos, (&pos)) != 0) { - TRACE((MMS_ERR, "Can't read position")); - return (EIO); - } - - ioctl(drv->drv_fd, MTIOCLRERR, 0); /* clear outstanding error */ - if (drv->drv_lbl_type == DRV_NL) { - /* write 2 tapemarks to terminate a NL tape */ - for (i = 0; i < 2; i++) { - if (DRV_CALL(drv_wtm, (2)) != 0) { - DRV_CALL(drv_clrerr, ()); - continue; - } - break; - } - if (i == 2) { - TRACE((MMS_ERR, "Can't terminate cartridge")); - rc = EIO; - } - } else { - /* - * Write EOF/EOV labels - */ - rc = dm_create_trailor_lbls(); - } - - /* - * Reposition to the end of user data - */ - if (rc != 0) { - DRV_CALL(drv_clrerr, ()); - } - if (DRV_CALL(drv_locate, (&drv->drv_eof_pos)) != 0) { - TRACE((MMS_ERR, "Can't reposition to EOF")); - rc = EIO; - } - if (dm_set_file_blksize(drv->drv_cur_blksize)) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Set file blksize error")); - rc = EIO; - } - drv->drv_flags &= ~DRV_TM; - drv->drv_cur_pos = drv->drv_eof_pos; - if (rc == 0) { - /* - * Successfully wrote trailor labels and return to end of - * user data. We'er at EOF. - */ - drv->drv_flags |= DRV_EOF; - } - - return (rc); -} - -int -dm_create_trailor_lbls(void) -{ - int i; - - for (i = 0; i < 2; i++) { - if (DRV_CALL(drv_wtm, (1)) != 0) { - if (serr->se_status == SUN_KEY_EOT && - serr->se_resid == 1) { - DRV_CALL(drv_wtm, (1)); - } - continue; - } - break; - } - if (i == 2) { - TRACE((MMS_ERR, "Can't write terminating FM")); - return (EIO); - } - - if (dm_set_label_blksize() != 0) { - return (EIO); - } - - for (i = 0; i < 2; i++) { - if (dm_create_eof1() != 0) { - continue; - } - break; - } - if (i == 2) { - return (EIO); - } - - for (i = 0; i < 2; i++) { - if (dm_create_eof2() != 0) { - continue; - } - break; - } - if (i == 2) { - return (EIO); - } - - for (i = 0; i < 2; i++) { - if (DRV_CALL(drv_wtm, (2)) != 0) { - continue; - } - break; - } - if (i == 2) { - return (EIO); - } - - return (0); -} - -/* - * dm_read and dm_write are entered because we asked for it - */ -int -dm_read(drm_reply_t *rep) -{ - TRACE((MMS_DEBUG, "Starting to Read")); - if (drv->drv_flags & DRV_FATAL) { - return (EIO); - } - memset(rep, 0, sizeof (rep)); - - if (drv->drv_flags & DRV_TERM_FILE) { - /* - * The previous movement command was an output command. - * Let the driver fail this read. - */ - TRACE((MMS_ERR, "attempted read after write")); - return (0); - } - /* - * Notify when switching to output - */ - rep->drm_rep_flags |= DRM_REP_NOTIFY_WRITE; - return (0); -} - -int -dm_read_tm(drm_request_t *req) -{ - uint64_t flags; - char buf[4096]; - tapepos_t cur_pos = drv->drv_cur_pos; - - /* - * Hit a tapemark. - * Check to see if we reached EOF - */ - if (mnt->mnt_flags & MNT_NOBSD) { - /* - * Alway cross TM to check trailor labels - */ - DRV_CALL(drv_fsf, (1)); - } - - if (dm_set_label_blksize()) { - goto err; - } - if (drv->drv_flags & DRV_VALID_EOF_POS) { - if (DRV_CALL(drv_get_pos, (&cur_pos)) != 0) { - goto err; - } - if (cur_pos.lgclblkno > drv->drv_eof_pos.lgclblkno) { - if (DRV_CALL(drv_locate, (&drv->drv_eof_pos)) != 0) { - goto err; - } - drv->drv_cur_pos = drv->drv_eof_pos; - drv->drv_flags &= ~DRV_TM; - drv->drv_flags |= DRV_EOF; - } - } else if (dm_chk_eof() == 0) { - if (DRV_CALL(drv_bsf, (1)) != 0) { - goto err; - } - drv->drv_cur_pos = cur_pos; - drv->drv_flags &= ~DRV_TM; - drv->drv_flags |= DRV_EOF; - (void) dm_get_eof_pos(); - } - - if ((drv->drv_flags & DRV_EOF) == 0) { - /* Not at EOF */ - if (mnt->mnt_flags & MNT_NOBSD) { - DRV_CALL(drv_bsf, (1)); - read(drv->drv_fd, buf, sizeof (buf)); - } - drv->drv_flags |= DRV_TM; - drv->drv_flags &= ~DRV_EOF; - } - - flags = drv->drv_flags & (DRV_TM | DRV_EOF); - dm_get_mtstat(DRV_SAVE_STAT); - drv->drv_flags &= ~(DRV_TM | DRV_EOF); - drv->drv_flags |= flags; - - drv->drv_mtget.drm_resid = req->drm_err_req.drm_resid; - if (dm_set_file_blksize(drv->drv_cur_blksize)) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Set file blksize error")); - goto err; - } - return ((int)req->drm_err_req.drm_errno); - -err: - if (dm_set_file_blksize(drv->drv_cur_blksize)) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Set file blksize error")); - } - drv->drv_mtget.drm_resid = req->drm_err_req.drm_resid; - drv->drv_flags |= DRV_FATAL; - TRACE((MMS_DEBUG, "FATAL error")); - return (EIO); -} - -int -dm_read_err(drm_request_t *req, drm_reply_t *rep) -{ - TRACE((MMS_ERR, "Read error: resid = %lld, errno = %lld, %s", - req->drm_err_req.drm_resid, req->drm_err_req.drm_errno, - strerror(req->drm_err_req.drm_errno))); - drv->drv_flags &= ~DRV_VALID_STAT; - dm_get_mtstat(DRV_SAVE_STAT); - dm_get_mt_error(EIO); - DRV_CALL(drv_proc_error, ()); - if (serr->se_senkey == KEY_HARDWARE_ERROR) { - /* set DriveBroken to "yes" */ - (void) dm_send_drive_broken(); - } else if (serr->se_senkey == KEY_MEDIUM_ERROR) { - /* Set CartridgeMediaError to "yes" */ - (void) dm_send_cartridge_media_error(); - } - rep->drm_rep_flags |= DRM_REP_NOTIFY_WRITE; - drv->drv_mtget.drm_resid = req->drm_err_req.drm_resid; - return ((int)req->drm_err_req.drm_errno); - -} - -int -dm_write(drm_reply_t *rep) -{ - - TRACE((MMS_DEBUG, "In dm_write")); - - if (drv->drv_flags & DRV_FATAL) { - return (EIO); - } - - /* - * Readonly, can't write to it - */ - if (drv->drv_flags & DRV_READONLY) { - return (EACCES); - } - - memset(rep, 0, sizeof (rep)); - drv->drv_flags |= DRV_TERM_FILE; - drv->drv_flags &= ~DRV_VALID_EOF_POS; - /* - * DRV_UPDATE_EOF_POS is only set when valid eof flag is updated - */ - if ((drv->drv_flags & DRV_UPDATE_EOF_POS) == 0) { - drv->drv_flags |= DRV_UPDATE_EOF_POS; - (void) dm_send_eof_pos(); - } - /* - * Notify when switching to input - */ - if (mnt->mnt_flags & MNT_MMS) { - rep->drm_rep_flags |= DRM_REP_NOTIFY_READ; - } - drv->drv_flags &= ~DRV_MOVE_FLAGS; - return (0); -} - -int -dm_write_0(drm_request_t *req, drm_reply_t *rep) -{ - TRACE((MMS_DEBUG, "In dm_write_0")); - - memset(rep, 0, sizeof (rep)); - dm_get_mtstat(DRV_SAVE_STAT); - /* - * Notify when switching to input - */ - rep->drm_rep_flags |= DRM_REP_NOTIFY_READ; - drv->drv_mtget.drm_resid = req->drm_err_req.drm_resid; - return ((int)req->drm_err_req.drm_errno); -} - -int -dm_write_err(drm_request_t *req, drm_reply_t *rep) -{ - TRACE((MMS_ERR, "Write error: resid = %lld, errno = %lld, %s", - req->drm_err_req.drm_resid, req->drm_err_req.drm_errno, - strerror(req->drm_err_req.drm_errno))); - drv->drv_flags &= ~DRV_VALID_STAT; - dm_get_mtstat(DRV_SAVE_STAT); - dm_get_mt_error(EIO); - DRV_CALL(drv_proc_error, ()); - if (serr->se_senkey == KEY_HARDWARE_ERROR) { - /* set DriveBroken to "yes" */ - (void) dm_send_drive_broken(); - } else if (serr->se_senkey == KEY_MEDIUM_ERROR) { - /* Set CartridgeMediaError to "yes" */ - (void) dm_send_cartridge_media_error(); - } - rep->drm_rep_flags |= DRM_REP_NOTIFY_READ; - drv->drv_mtget.drm_resid = req->drm_err_req.drm_resid; - return ((int)req->drm_err_req.drm_errno); -} - -int -dm_create_vol1(void) -{ - drv_vol1_t *vol1 = &drv->drv_vol1; - char dumpbuf[MMS_DUMPBUF_SIZE(80)]; - char *vp; - char *buf; - - memset(vol1, ' ', sizeof (drv_vol1_t)); - strncpy(vol1->vol1_id, "VOL1", 4); - if (mnt->mnt_vid == NULL) { - vp = mnt->mnt_pcl; - } else { - vp = mnt->mnt_vid; - } - - buf = mms_strapp(NULL, - "%-6.6s", vp); - strncpy(vol1->vol1_vid, buf, 6); - free(buf); - vol1->vol1_acc = ' '; - strncpy(vol1->vol1_impid, DRV_IMPID, 13); - strncpy(vol1->vol1_owner, VOL1_OWNER, 14); - vol1->vol1_ver = '4'; - (void) mms_trace_dump((char *)vol1, 80, dumpbuf, sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "VOL1 label:\n%s", - mms_trace_dump((char *)vol1, 80, dumpbuf, sizeof (dumpbuf)))); - - if (DRV_CALL(drv_write, ((char *)vol1, 80)) != 80) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Unable to write VOL1 label")); - return (EIO); - } - drv->drv_lbl_type = DRV_AL; - TRACE((MMS_DEBUG, "Wrote VOL1")); - strncpy(drv->drv_vid, vol1->vol1_vid, 6); - drv->drv_flags |= (DRV_VOL1 | DRV_IDENTIFIED); - drv->drv_fseq = 1; - return (0); -} - -int -dm_create_hdr1(void) -{ - drv_hdr1_t *hdr1 = &drv->drv_hdr1; - char *buf; - char dumpbuf[MMS_DUMPBUF_SIZE(80)]; - time_t curtime; - struct tm tm; - char *tmp; - - memset(hdr1, ' ', sizeof (drv_hdr1_t)); - - /* - * Get creation date - */ - curtime = time(NULL); - localtime_r(&curtime, &tm); - if (tm.tm_year > 100) { - tm.tm_year -= 100; - hdr1->hdr1_cdate[0] = '0'; - } else { - hdr1->hdr1_cdate[0] = ' '; - } - tmp = mms_strapp(NULL, - "%2.2d", tm.tm_year); - strncpy(hdr1->hdr1_cdate + 1, tmp, 2); - free(tmp); - tmp = mms_strapp(NULL, - "%3.3d", tm.tm_yday + 1); - free(tmp); - strncpy(hdr1->hdr1_cdate + 3, tmp, 3); - - /* - * Get expiration date - */ - if (drv->drv_retention == 0) { - /* Don't use expiration date */ - strncpy(hdr1->hdr1_xdate, "000000", 6); - } else if (drv->drv_retention == 99999) { - /* Never expires */ - strncpy(hdr1->hdr1_xdate, "099366", 6); - } else { - /* expire time */ - curtime += ((drv->drv_retention + 1) * 24 * 60 * 60); - localtime_r(&curtime, &tm); - if (tm.tm_year > 100) { - tm.tm_year -= 100; - hdr1->hdr1_xdate[0] = '0'; - } else { - hdr1->hdr1_xdate[0] = ' '; - } - tmp = mms_strapp(NULL, - "%2.2d", tm.tm_year); - strncpy(hdr1->hdr1_xdate + 1, tmp, 2); - free(tmp); - tmp = mms_strapp(NULL, - "%3.3d", tm.tm_yday + 1); - strncpy(hdr1->hdr1_xdate + 3, tmp, 3); - free(tmp); - } - - strncpy(hdr1->hdr1_id, "HDR1", 4); - strncpy(hdr1->hdr1_fid, mnt->mnt_fname, 17); - strncpy(hdr1->hdr1_fsnum, "0001", 4); - buf = mms_strapp(NULL, - "%4.4d", mnt->mnt_fseq); - strncpy(hdr1->hdr1_fseq, buf, 4); - free(buf); - strncpy(hdr1->hdr1_gnum, "0001", 4); - strncpy(hdr1->hdr1_gver, "00", 2); - strncpy(hdr1->hdr1_bcount, "000000", 6); - strncpy(hdr1->hdr1_impid, DRV_IMPID, 13); - (void) mms_trace_dump((char *)hdr1, 80, dumpbuf, sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "HDR1 label:\n%s", dumpbuf)); - - - if (DRV_CALL(drv_write, ((char *)hdr1, 80)) != 80) { - TRACE((MMS_ERR, "Unable to write HDR1 label")); - return (EIO); - } - TRACE((MMS_DEBUG, "Wrote HDR1")); - strncpy(drv->drv_fid, mnt->mnt_fname, 17); - drv->drv_fid[17] = '\0'; - drv->drv_flags |= (DRV_HDR1 | DRV_VALIDATED_FNAME); - return (0); -} - -int -dm_create_hdr2(void) -{ - drv_hdr2_t *hdr2 = &drv->drv_hdr2; - char *buf; - char dumpbuf[MMS_DUMPBUF_SIZE(80)]; - - memset(hdr2, ' ', 80); - strncpy(hdr2->hdr2_id, "HDR2", 4); - if (drv->drv_flags & DRV_FIXED) { - hdr2->hdr2_rformat = 'F'; - } else { - hdr2->hdr2_rformat = 'D'; - } - - /* - * Put file blksize in label - */ - drv->drv_lbl_blksize = drv->drv_file_blksize; - if (mnt->mnt_blksize < 99999) { - buf = mms_strapp(NULL, - "%5.5d", drv->drv_lbl_blksize); - strncpy(hdr2->hdr2_blklen, buf, sizeof (hdr2->hdr2_blklen)); - strncpy(hdr2->hdr2_rcdlen, buf, sizeof (hdr2->hdr2_rcdlen)); - free(buf); - } else { - strncpy(hdr2->hdr2_blklen, "99999", sizeof (hdr2->hdr2_blklen)); - strncpy(hdr2->hdr2_rcdlen, "99999", sizeof (hdr2->hdr2_rcdlen)); - } - buf = mms_strapp(NULL, - "%10.10d", drv->drv_lbl_blksize); - strncpy(hdr2->hdr2_blksize, buf, sizeof (hdr2->hdr2_blksize)); - free(buf); - strncpy(hdr2->hdr2_off, "00", sizeof (hdr2->hdr2_off)); - (void) mms_trace_dump((char *)hdr2, 80, dumpbuf, sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "HDR2 label:\n%s", dumpbuf)); - - if (DRV_CALL(drv_write, ((char *)hdr2, 80)) != 80) { - TRACE((MMS_ERR, "Unable to write HDR2 label")); - return (EIO); - } - TRACE((MMS_DEBUG, "Wrote HDR2")); - drv->drv_flags |= DRV_HDR2; - return (0); -} - -int -dm_create_eof1(void) -{ - drv_eof1_t *eof1 = &drv->drv_eof1; - char *buf; - char dumpbuf[MMS_DUMPBUF_SIZE(80)]; - - memset(eof1, ' ', sizeof (drv_eof1_t)); - strncpy(eof1->eof1_id, "EOF1", 4); - strncpy(eof1->eof1_fid, mnt->mnt_fname, 17); - strncpy(eof1->eof1_fsnum, "0001", 4); - buf = mms_strapp(NULL, - "%4.4d", mnt->mnt_fseq); - strncpy(eof1->eof1_fseq, buf, sizeof (eof1->eof1_fseq)); - strncpy(eof1->eof1_gnum, "0001", sizeof (eof1->eof1_gnum)); - strncpy(eof1->eof1_gver, "00", sizeof (eof1->eof1_gver)); - strncpy(eof1->eof1_cdate, drv->drv_hdr1.hdr1_cdate, - sizeof (eof1->eof1_cdate)); - strncpy(eof1->eof1_xdate, drv->drv_hdr1.hdr1_xdate, - sizeof (eof1->eof1_xdate)); - strncpy(eof1->eof1_bcount, "000000", sizeof (eof1->eof1_bcount)); - strncpy(eof1->eof1_impid, DRV_IMPID, sizeof (eof1->eof1_impid)); - free(buf); - (void) mms_trace_dump((char *)eof1, 80, dumpbuf, sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "EOF1 label:\n%s", dumpbuf)); - - if (DRV_CALL(drv_write, ((char *)eof1, 80)) != 80) { - TRACE((MMS_ERR, "Unable to write EOF1 label")); - return (EIO); - } - TRACE((MMS_DEBUG, "Wrote EOF1")); - strncpy(drv->drv_fid, mnt->mnt_fname, sizeof (drv->drv_fid)); - drv->drv_fid[17] = '\0'; - drv->drv_flags |= DRV_EOF1; - return (0); -} - -int -dm_create_eof2(void) -{ - drv_eof2_t *eof2 = &drv->drv_eof2; - char *buf; - char dumpbuf[MMS_DUMPBUF_SIZE(80)]; - - memset(eof2, ' ', 80); - strncpy(eof2->eof2_id, "EOF2", 4); - if (drv->drv_flags & DRV_FIXED) { - eof2->eof2_rformat = 'F'; - } else { - eof2->eof2_rformat = 'D'; - } - if (mnt->mnt_blksize < 99999) { - buf = mms_strapp(NULL, - "%5.5d", drv->drv_lbl_blksize); - strncpy(eof2->eof2_blklen, buf, sizeof (eof2->eof2_blklen)); - strncpy(eof2->eof2_rcdlen, buf, sizeof (eof2->eof2_blklen)); - free(buf); - } else { - strncpy(eof2->eof2_blklen, "99999", sizeof (eof2->eof2_blklen)); - strncpy(eof2->eof2_rcdlen, "99999", sizeof (eof2->eof2_blklen)); - } - buf = mms_strapp(NULL, - "%10.10d", drv->drv_lbl_blksize); - strncpy(eof2->eof2_blksize, buf, sizeof (eof2->eof2_blksize)); - strncpy(eof2->eof2_off, "00", sizeof (eof2->eof2_off)); - free(buf); - (void) mms_trace_dump((char *)eof2, 80, dumpbuf, sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "EOF2 label:\n%s", dumpbuf)); - - if (DRV_CALL(drv_write, ((char *)eof2, 80)) != 80) { - TRACE((MMS_ERR, "Unable to write EOF2 label")); - return (EIO); - } - TRACE((MMS_DEBUG, "Wrote EOF2")); - drv->drv_flags |= DRV_EOF2; - return (0); -} - -int -dm_rewind_file(void) -{ - if ((drv->drv_flags & DRV_UDATA) == 0) { - /* - * Must be in user data to rewind - */ - TRACE((MMS_ERR, "Not in user data. Can't rewind file")); - return (EACCES); - } - - if ((drv->drv_flags & DRV_VALID_BOF_POS) == 0) { - /* - * Must have valid BOF position - */ - TRACE((MMS_ERR, - "Don't have BOF position. Can't rewind file")); - return (EACCES); - } - - if (drv->drv_flags & DRV_BOF) { - /* Already at BOF */ - return (0); - } - if (DRV_CALL(drv_locate, (&drv->drv_bof_pos))) { - TRACE((MMS_ERR, "Rewind file error")); - return (EIO); - } - if (DRV_CALL(drv_bsb, (1, DRV_LOGICAL_CROSS_TM)) != 0) { - if ((drv->drv_flags & DRV_TM)) { - /* Hit a TM */ - DRV_CALL(drv_fsf, (1)); - } else if ((drv->drv_flags & DRV_BOM) == 0) { - /* Did not hit BOM. Must be an error */ - return (EIO); - } - } else { - /* Not at BOF */ - return (EIO); - } - - drv->drv_mtget.drm_resid = 0; - drv->drv_flags &= ~(DRV_BOM | DRV_TM); - drv->drv_flags |= DRV_BOF; - - drv->drv_cur_pos = drv->drv_bof_pos; - - return (0); -} - -int -dm_ioctl_clrerr(drm_reply_t *rep) -{ - int rc = 0; - - memset(rep, 0, sizeof (drm_reply_t)); - rc = DRV_CALL(drv_clrerr, ()); - return (rc); -} - -int -dm_ioctl_mtget(drm_request_t *req, drm_reply_t *rep) -{ - if ((req->drm_req_flags & DRM_REQ_MOVED) || - (drv->drv_flags & DRV_VALID_STAT) == 0) { - /* If tape moved since last signal, get new status */ - drv->drv_flags &= ~DRV_VALID_STAT; - dm_get_mtstat(DRV_SAVE_STAT); - } - - memcpy(&rep->drm_mtget_rep, &drv->drv_mtget, sizeof (drm_mtget_t)); - - if (drv->drv_flags & DRV_BOF) { - rep->drm_mtget_rep.drm_erreg = SUN_KEY_BOT; - } else if (drv->drv_flags & DRV_EOF) { - rep->drm_mtget_rep.drm_erreg = SUN_KEY_EOT; - } else if (drv->drv_flags & DRV_TM) { - rep->drm_mtget_rep.drm_erreg = SUN_KEY_EOF; - } - - return (0); -} - -int -dm_ioctl_rewind(void) -{ - int rc = 0; - - if (drv->drv_flags & DRV_FATAL) { - return (EIO); - } - - drv->drv_flags &= ~(DRV_VALID_STAT | DRV_MOVE_FLAGS); - if (drv->drv_flags & DRV_TERM_FILE) { - if (dm_terminate_file() != 0) { - TRACE((MMS_ERR, "Unable to terminate file")); - rc = EIO; - } - drv->drv_flags &= ~DRV_TERM_FILE; - } - - rc = dm_rewind_file(); - - return (rc); -} - -int -dm_ioctl_fsf(int count) -{ - int rc = 0; - char buf[80]; - int bytes; - int i; - - drv->drv_mtget.drm_resid = count; - if (drv->drv_flags & DRV_FATAL) { - return (EIO); - } - - drv->drv_flags &= ~(DRV_VALID_STAT | DRV_MOVE_FLAGS); - drv->drv_flags &= ~DRV_EOF; - if (dm_set_label_blksize()) { - return (EIO); - } - for (i = 0; i < count; i++) { - if (DRV_CALL(drv_fsf, (1)) != 0) { - rc = EIO; - break; - } - /* - * Try to read the next block to see if it is a trailor label. - */ - while ((drv->drv_flags & DRV_EOF) == 0) { - if ((bytes = DRV_CALL(drv_read, (buf, 80))) == 80) { - if (strncmp(buf, "EOF1", 4) == 0 || - strncmp(buf, "EOV1", 4) == 0) { - /* Read trailor label */ - /* Reposition to EOF */ - TRACE((MMS_DEBUG, "Found EOF1/EOV1")); - DRV_CALL(drv_bsf, (1)); - drv->drv_flags &= ~DRV_TM; - drv->drv_flags |= DRV_EOF; - (void) dm_get_eof_pos(); - rc = EIO; - break; - } - } - - if (bytes > 0) { - /* - * Read something other than a label - */ - if (i == (count - 1)) { - /* - * Spaced requested TM - */ - DRV_CALL(drv_bsb, - (1, DRV_LOGICAL_CROSS_TM)); - } - break; - } else if (drv->drv_flags & DRV_TM) { - /* Read another tapemark */ - drv->drv_flags &= ~DRV_TM; - if (i == (count - 1)) { - /* - * Spaced requested TM - */ - DRV_CALL(drv_bsf, (1)); - drv->drv_flags |= DRV_TM; - break; - } else { - i++; /* skipped another TM */ - } - continue; /* try to read label again */ - } else if (rc < 0) { - if (serr->se_senkey == SUN_KEY_EOT || - serr->se_senkey == KEY_BLANK_CHECK) { - /* Hit EOM or blank check */ - TRACE((MMS_DEBUG, - "Hit EOT/BLANK CHECK")); - drv->drv_flags |= DRV_EOF; - if (dm_get_eof_pos()) { - rc = EIO; - goto done; - } - break; - } else { - /* Other error */ - rc = EIO; - goto done; - } - } else { - /* - * Some unknown error - */ - rc = EIO; - break; - } - } - - /* - * Done if we are at EOF - */ - if (drv->drv_flags & DRV_EOF) { - break; - } - } - - -done: - dm_get_mtstat(DRV_SAVE_STAT); - if (dm_set_file_blksize(drv->drv_cur_blksize)) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Set file blksize error")); - rc = EIO; - } - drv->drv_mtget.drm_resid = count - i; - - return (rc); -} - -int -dm_ioctl_fsb(int count) -{ - uint64_t flags; - uint64_t resid = 0; - int rc = 0; - tapepos_t pos; - - if (drv->drv_flags & DRV_FATAL) { - return (EIO); - } - - drv->drv_flags &= ~DRV_VALID_STAT; - drv->drv_flags &= ~DRV_MOVE_FLAGS; - - if (dm_set_label_blksize()) { - return (EIO); - } - if (DRV_CALL(drv_fsb, (count, DRV_LOGICAL_CROSS_TM)) != 0) { - resid = serr->se_resid; - if (drv->drv_flags & DRV_TM) { - /* - * Hit a tapemark. - * Check to see if we reached EOF - */ - DRV_CALL(drv_get_pos, (&pos)); - if (drv->drv_flags & DRV_VALID_EOF_POS) { - if (pos.lgclblkno >= - drv->drv_eof_pos.lgclblkno) { - /* passed EOF position */ - DRV_CALL(drv_bsf, (1)); - drv->drv_flags &= ~DRV_TM; - drv->drv_flags |= DRV_EOF; - drv->drv_cur_pos = drv->drv_eof_pos; - } - } else if (dm_chk_eof() == 0) { - /* Not at EOF, check if at EOF */ - DRV_CALL(drv_bsf, (1)); - drv->drv_flags &= ~DRV_TM; - drv->drv_flags |= DRV_EOF; - } - /* - * If at EOF, and don't have EOF position, get it - */ - if (drv->drv_flags & DRV_EOF) { - if ((drv->drv_flags & DRV_VALID_EOF_POS) == 0) { - (void) dm_get_eof_pos(); - drv->drv_cur_pos = drv->drv_eof_pos; - } - } else { - /* - * If not at EOF, must have hit a TM - */ - drv->drv_flags |= DRV_TM; - /* - * Deal with Solaris BSB/NOBSD behavior - */ - if ((mnt->mnt_flags & MNT_MMS_TM) == 0) { - /* Not MMS TM, then do not cross TM */ - DRV_CALL(drv_bsf, (1)); - DRV_CALL(drv_fsb, - (1, ~DRV_LOGICAL_CROSS_TM)); - } - } - } - rc = EIO; - } - - if (dm_set_file_blksize(drv->drv_cur_blksize)) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Set file blksize error")); - rc = EIO; - } - flags = drv->drv_flags & (DRV_EOF | DRV_TM); - dm_get_mtstat(DRV_SAVE_STAT); - drv->drv_flags &= ~(DRV_EOF | DRV_TM); - drv->drv_flags |= flags; - drv->drv_mtget.drm_resid = resid; - - return (rc); -} - -int -dm_ioctl_bsf(int count) -{ - int rc = 0; - int i; - tapepos_t pos; - - if (drv->drv_flags & DRV_FATAL) { - return (EIO); - } - if (drv->drv_flags & DRV_TERM_FILE) { - if (dm_terminate_file() != 0) { - TRACE((MMS_ERR, "Write trailor label error")); - rc = EIO; - } - drv->drv_flags &= ~DRV_TERM_FILE; - } - - drv->drv_flags &= ~DRV_VALID_STAT; - drv->drv_flags &= ~DRV_MOVE_FLAGS; - for (i = 0; i < count; i++) { - DRV_CALL(drv_bsf, (1)); - DRV_CALL(drv_get_pos, (&pos)); - if (pos.lgclblkno < drv->drv_bof_pos.lgclblkno) { - DRV_CALL(drv_locate, (&drv->drv_bof_pos)); - drv->drv_flags |= DRV_BOF; - drv->drv_cur_pos = drv->drv_bof_pos; - rc = EIO; - break; - } - } - - dm_get_mtstat(DRV_SAVE_STAT); - drv->drv_mtget.drm_resid = count - i; - if (serr->se_resid == 0) { - drv->drv_flags |= DRV_TM; - } - - return (rc); -} - -int -dm_ioctl_bsb(int count) -{ - tapepos_t pos; - int cross; - int resid = 0; - int flags; - int rc = 0; - int err = 0; - - if (drv->drv_flags & DRV_FATAL) { - return (EIO); - } - - if (drv->drv_flags & DRV_TERM_FILE) { - if (dm_terminate_file() != 0) { - TRACE((MMS_ERR, "Write trailor label error")); - return (EIO); - } - drv->drv_flags &= ~DRV_TERM_FILE; - } - - drv->drv_flags &= ~DRV_VALID_STAT; - drv->drv_flags &= ~DRV_MOVE_FLAGS; - if (mnt->mnt_flags & MNT_MMS_TM) { - cross = DRV_LOGICAL_CROSS_TM; - } else { - cross = ~DRV_LOGICAL_CROSS_TM; - } - if (DRV_CALL(drv_bsb, (count, cross)) != 0) { - err = errno; - resid = serr->se_resid; - if (drv->drv_flags & DRV_TM) { - /* Hit a tapemark */ - DRV_CALL(drv_get_pos, (&pos)); - if (pos.lgclblkno <= drv->drv_bof_pos.lgclblkno) { - if (DRV_CALL(drv_locate, (&drv->drv_bof_pos))) { - /* Failed to reposition */ - rc = EIO; - } else { - drv->drv_flags &= ~DRV_TM; - drv->drv_flags |= DRV_BOF; - drv->drv_cur_pos = drv->drv_bof_pos; - } - } - } - rc = EIO; - errno = err; - } - - flags = drv->drv_flags & (DRV_TM | DRV_BOF); - dm_get_mtstat(DRV_SAVE_STAT); - drv->drv_flags &= ~(DRV_TM | DRV_BOF); - drv->drv_flags |= flags; - drv->drv_mtget.drm_resid = resid; - - return (rc); -} - -int -dm_ioctl_seek(int count) -{ - int rc = 0; - uint64_t flags; - - if (drv->drv_flags & DRV_FATAL) { - return (EIO); - } - - if (drv->drv_flags & DRV_TERM_FILE) { - if (dm_terminate_file() != 0) { - TRACE((MMS_ERR, "Write trailor label error")); - return (EIO); - } - drv->drv_flags &= ~DRV_TERM_FILE; - } - - drv->drv_flags &= ~DRV_VALID_STAT; - drv->drv_flags &= ~DRV_MOVE_FLAGS; - - rc = DRV_CALL(drv_seek, ((uint64_t)count)); - if (rc) { - DM_MSG_SEND((DM_ADM_ERR, DM_6522_MSG, DM_MSG_REASON)); - rc = EIO; - } - - flags = drv->drv_flags & (DRV_TM | DRV_BOF); - dm_get_mtstat(DRV_SAVE_STAT); - drv->drv_flags &= ~(DRV_TM | DRV_BOF); - drv->drv_flags |= flags; - - return (rc); -} - -int -dm_ioctl_wtm(int count) -{ - int rc = 0; - int resid = 0; - - if (drv->drv_flags & DRV_FATAL) { - return (EIO); - } - - /* - * Readonly, can't write to it - */ - if (drv->drv_flags & DRV_READONLY) { - if (count > 0) { - return (EACCES); - } - } - - drv->drv_flags &= ~DRV_MOVE_FLAGS; - drv->drv_flags &= ~DRV_VALID_EOF_POS; - drv->drv_flags &= ~DRV_VALID_STAT; - if (count > 0) { - /* Terminate file if writing TM to tape */ - drv->drv_flags |= DRV_TERM_FILE; - } - - if (DRV_CALL(drv_wtm, (count)) != 0) { - resid = serr->se_resid; - rc = EIO; - } - dm_get_mtstat(DRV_SAVE_STAT); - if (resid != count) { - /* Wrote some TM */ - drv->drv_flags |= DRV_TM; - } - drv->drv_mtget.drm_resid = resid; - - return (rc); -} - -int -dm_ioctl_set_blksize(uint64_t blksize) -{ - int rc; - - rc = DRV_CALL(drv_set_blksize, (blksize)); - - if (rc) { - DM_MSG_SEND((DM_ADM_ERR, DM_6513_MSG, DM_MSG_REASON)); - return (rc); - } - if ((drv->drv_cur_blksize = blksize) == 0) { - drv->drv_flags &= ~DRV_FIXED; - } else { - drv->drv_flags |= DRV_FIXED; - } - return (0); -} - -int -dm_ioctl_getpos(drm_reply_t *rep) -{ - tapepos_t pos; - - if (drv->drv_flags & DRV_FATAL) { - return (EIO); - } - - if (DRV_CALL(drv_get_pos, (&pos)) != 0) { - return (EIO); - } - rep->drm_pos_rep.mms_pos = pos.lgclblkno; - - return (0); -} - -int -dm_ioctl_mtgetpos(drm_reply_t *rep) -{ - if (drv->drv_flags & DRV_FATAL) { - return (EIO); - } - - if (DRV_CALL(drv_get_pos, (&rep->drm_mtpos_rep)) != 0) { - return (EIO); - } - - return (0); -} - -int -dm_ioctl_mtrestpos(drm_request_t *req) -{ - if (drv->drv_flags & DRV_FATAL) { - return (EIO); - } - - if (DRV_CALL(drv_locate, (&req->drm_mtpos_req)) != 0) { - return (EIO); - } - - return (0); -} - -int -dm_ioctl_locate(drm_request_t *req) -{ - int rc = 0; - uint64_t blkno = req->drm_pos_req.mms_pos; - tapepos_t pos; - - if (drv->drv_flags & DRV_FATAL) { - return (EIO); - } - - if ((drv->drv_flags & DRV_VALID_EOF_POS) && - drv->drv_eof_pos.lgclblkno < blkno) { - TRACE((MMS_ERR, "Invalid locate to position: %lld", - blkno)); - return (EINVAL); - } - if (drv->drv_flags & DRV_TERM_FILE) { - if (dm_terminate_file() != 0) { - TRACE((MMS_ERR, "Unable to terminate file")); - rc = EIO; - } - drv->drv_flags &= ~DRV_TERM_FILE; - } - - memset(&pos, 0, sizeof (tapepos_t)); - pos.lgclblkno = blkno; - pos.eof = ST_NO_EOF; - pos.pmode = logical; - if (DRV_CALL(drv_locate, (&pos)) != 0) { - rc = EIO; - } - return (rc); -} - -int -dm_ioctl_get_capacity(drm_reply_t *rep) -{ - int rc = 0; - mms_capacity_t *cap = &rep->drm_cap_rep; - - if (DRV_CALL(drv_get_capacity, (cap)) != 0) { - rc = EIO; - } - return (rc); -} - -int -dm_ioctl_upt_capacity(void) -{ - int rc = 0; - - if (dm_update_capacity() != 0) { - rc = EIO; - } - return (rc); -} - -int -dm_ioctl_set_density(void) -{ - int rc = 0; - - if (drv->drv_flags & DRV_FATAL) { - return (EIO); - } - - if ((mnt->mnt_flags & MNT_AUTO_DEN) == 0) { - if (DRV_CALL(drv_set_density, - (mnt->mnt_density->sym_code)) != 0) { - drv->drv_flags |= DRV_FATAL; - TRACE((MMS_DEBUG, "FATAL error")); - rc = EIO; - } - } - return (rc); -} - -int -dm_ioctl_get_density(drm_reply_t *rep) -{ - int rc = 0; - int den; - - if (DRV_CALL(drv_get_density, (&den, NULL)) != 0) { - rc = EIO; - } else { - rep->drm_den_rep = den; - } - return (rc); -} - -void -dm_clear_dev(void) -{ - int i; - - /* - * Get rid of all attentions - */ - for (i = 0; i < 10; i++) { - DRV_CALL(drv_tur, ()); - } -} - -int -dm_set_label_blksize(void) -{ - if (DRV_CALL(drv_set_blksize, (0)) != 0) { - return (EIO); - } - if (DRV_CALL(drv_set_compression, (0)) != 0) { - return (EIO); - } - return (0); -} - -int -dm_set_file_blksize(int blksize) -{ - int rc; - int comp; - int bz; - drm_blksize_t blk; - - if (drv->drv_flags & DRV_FATAL) { - return (EIO); - } - - /* - * If blksize == -1, determine the blocksize. - * If blksize >= 0, use blksize - */ - if (blksize == -1) { - if (drv->drv_file_blksize <= 0) { - drv->drv_file_blksize = drv->drv_dflt_blksize; - } - - if (drv->drv_flags & DRV_FIXED) { - bz = drv->drv_file_blksize; - } else { - bz = 0; - } - } else { - bz = blksize; - } - - /* - * Set tape compression - */ - comp = (mnt->mnt_flags & MNT_COMPRESSION) ? 1 : 0; - - if (DRV_CALL(drv_set_blksize, (bz)) != 0) { - TRACE((MMS_ERR, "Unable to set tape blksize")); - return (EIO); - } else if (DRV_CALL(drv_set_compression, (comp)) != 0) { - TRACE((MMS_ERR, "Unable to set tape compression: %d", - comp)); - return (EIO); - } else { - drv->drv_cur_blksize = bz; - blk.drm_fixed = (drv->drv_flags & DRV_FIXED) ? 1 : 0; - blk.drm_blksize = drv->drv_file_blksize; - rc = ioctl(drv->drv_fd, DRM_BLKSIZE, &blk); - TRACE((MMS_DEBUG, "Max blksize %lld", blk.drm_blksize)); - } - - return (rc == 0 ? 0 : EIO); -} diff --git a/usr/src/cmd/mms/dm/common/dm_target.c b/usr/src/cmd/mms/dm/common/dm_target.c deleted file mode 100644 index b9a2b6835b..0000000000 --- a/usr/src/cmd/mms/dm/common/dm_target.c +++ /dev/null @@ -1,1125 +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. - */ - - -#include <limits.h> -#include <sys/types.h> -#include <sys/mkdev.h> -#include <sys/file.h> -#include <pthread.h> -#include <synch.h> -#include <ctype.h> -#include <signal.h> -#include <pwd.h> -#include <auth_attr.h> -#include <secdb.h> -#include <ucred.h> -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <dlfcn.h> -#include <link.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <strings.h> -#include <dirent.h> -#include <errno.h> -#include <sys/scsi/impl/uscsi.h> -#include <sys/scsi/generic/sense.h> -#include <sys/scsi/generic/status.h> -#include <dmd_impl.h> -#include <dm_impl.h> -#include <dm_drive.h> -#include <mms_sym.h> -#include <dm_msg.h> -#include <mms_trace.h> -#include <mms_dmd.h> -#include <dm_proto.h> -#include <mms_strapp.h> - - - -static char *_SrcFile = __FILE__; - - -/* - * Minor device number of the ST driver. - * - * Change device to bn device - turn BSD and norewind bits - * - * The minor device byte structure is (from mtio(7I)): - * - * 15-7 6 5 4 3 2 1 0 - * ___________________________________________________________________ - * Unit # BSD Reserved Density Density No rewind Unit # - * behavior Select Select on Close Bits 0-1 - * - */ - -minor_t -dm_get_targ(minor_t minor) -{ - minor &= ~0x18; /* turn off density select */ - minor |= 0x44; /* BSD, norewind */ - - return (minor); -} - -minor_t -dm_hdl_minor(void) -{ - minor_t minor = 0; - - minor = (((wka->dm_counter % 255) + 1) << 8) | wka->dm_drm_minor; - return (minor); -} - -int -dm_get_target_base(void) -{ - if (drv->drv_serial_num[0] == '\0') { - /* - * Serial number unknown. Have to use specified path - */ - return (dm_get_target_pathname()); - } else { - /* - * Have serial number, look in /dev/rmt (tape devices) - * for device matching serial number. - */ - return (dm_get_target_by_serial_num()); - } -} - -int -dm_get_target_pathname(void) -{ - char *show_cmd; - char *task; - mms_par_node_t *root; - dm_command_t *cmd; - char *val; - - TRACE((MMS_DEVP, "Getting target base")); - task = dm_bld_task("show-target-base"); - show_cmd = mms_strapp(NULL, - "show task['%s'] reportmode[namevalue] " - "match[streq(DM.'DMName' '%s')] " - "report[ DM.'DMTargetPath']" ";", task, DMNAME); - cmd = dm_send_cmd(show_cmd, dm_cmd_response, task); - free(show_cmd); - free(task); - if (cmd == NULL || cmd->cmd_rc != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to get DM.'DMTargetPath'")); - if (cmd) { - dm_destroy_cmd(cmd); - } - return (-1); - } - root = cmd->cmd_root; - /* - * Save tape path - */ - val = dm_get_attr_value(root, "DM", "DMTargetPath"); - if (val == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "No TargetPath")); - dm_destroy_cmd(cmd); - return (-1); - } - if (dm_verify_target_dev(val) != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "invalid device pathname %s", val)); - dm_destroy_cmd(cmd); - return (-1); - } - wka->dm_target_base = strdup(val); - TRACE((MMS_OPER, "dm_get_target_base: Target base is %s", - wka->dm_target_base)); - dm_destroy_cmd(cmd); - return (0); -} - -int -dm_get_target_by_serial_num(void) -{ - char **dirtab; - int i; - int rc = -1; - - /* - * Search in the default dir - */ - if (dm_probe_dir(drv->drv_dev_dir) == 0) { - /* Found it */ - return (0); - } - - /* - * Build a dir table from *.so - */ - dirtab = dm_bld_dir_tab(); - if (dirtab == NULL) { - return (-1); - } - - /* - * Search each entry in dir table - */ - rc = -1; /* assume not found */ - for (i = 0; dirtab[i] != NULL; i++) { - if (dm_probe_dir(dirtab[i]) == 0) { - /* Found it */ - rc = 0; - break; - } - } - - /* - * Can't find a device that matches the serial number - */ - for (i = 0; dirtab[i] != NULL; i++) { - free(dirtab[i]); - } - free(dirtab); - - return (rc); -} - -int -dm_probe_dir(char *dirname) -{ - DIR *dir; - struct dirent *dirent; - int len; - char sernum[MMS_SER_NUM_LEN + 1]; - int fd; - int rc = -1; - struct ent { - ino_t ino; - char *name; - }; - struct ent ptab[64]; - int nument = 0; - int probe = 1; - drm_probe_dev_t dev; - int i; - int err; - int zero = 0; - - - if ((dir = opendir(dirname)) == NULL) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to open directory %s: %s", - dirname, strerror(errno))); - return (-1); - } - - while ((dirent = readdir(dir)) != NULL) { - /* - * Read the serial number of this device - */ - len = strlen(dirent->d_name); - if (strcmp(dirname, DRV_TAPE_DIR) == 0) { - if (len < 2) { - /* Device name must be >= 2 chars */ - continue; - } - /* If tape device, look at only norewind devices */ - if (dirent->d_name[len - 1] != 'n' || - !isdigit(dirent->d_name[len - 2])) { - continue; - } - } - ptab[nument].name = mms_strapp(NULL, - "%s/%s", dirname, dirent->d_name); - ptab[nument].ino = dirent->d_ino; - nument++; - } - closedir(dir); - - while (probe) { - /* - * Continue to probe until all devices are probed. - */ - probe = 0; - for (i = 0; i < nument; i++) { - /* - * Set the ino in dmd. If EBUSY, then skip for now - */ - if (ptab[i].name == NULL) { - /* Already checked */ - continue; - } - - /* - * Tell DMD probing this device - */ - dev.drm_dev = 0; - ioctl(drv->drv_fd, DRM_PROBE_DEV, &dev); - dev.drm_dev = ptab[i].ino; - if (ioctl(drv->drv_fd, DRM_PROBE_DEV, &dev) < 0) { - err = errno; - if (err == EBUSY) { - TRACE((MMS_DEBUG, "Busy: %s", - ptab[i].name)); - continue; - } - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to probe device: %s", - strerror(err))); - errno = err; - rc = -1; - goto done; - } - - /* - * Check serial number of this device - */ - probe = 1; - do { - TRACE((MMS_DEBUG, "Looking at: %s", - ptab[i].name)); - fd = open(ptab[i].name, O_NDELAY | O_RDWR); - if (fd < 0) { - /* - * If can't open this device, - * then skip it - */ - TRACE((MMS_DEBUG, "probe open error: " - "%s: %s", - ptab[i].name, strerror(errno))); - break; - } - - /* Read the serial number */ - drv->drv_fd = fd; - /* drv_*() uses drv->drv_fd */ - if (DRV_CALL(drv_get_serial_num, - (sernum)) != 0) { - TRACE((MMS_DEBUG, "probe get " - "serial num error: %s: %s", - ptab[i].name, strerror(errno))); - close(fd); - drv->drv_fd = wka->dm_drm_fd; - /* restoredrv->drv_fd */ - break; - } - close(fd); - drv->drv_fd = wka->dm_drm_fd; - /* restoredrv->drv_fd */ - - TRACE((MMS_DEBUG, "path %s, serial num %s", - ptab[i].name, sernum)); - - /* - * Compare serial numbers - */ - if (strcmp(sernum, drv->drv_serial_num) == 0) { - /* Found device matching serial num */ - wka->dm_target_base = - strdup(ptab[i].name); - /* Drop the "n" from pathname */ - wka->dm_target_base[ - strlen(wka->dm_target_base) - 1] = - '\0'; - TRACE((MMS_OPER, "dm_probe_dir: " - "Target base is %s", - wka->dm_target_base)); - rc = 0; - probe = 0; /* probe done */ - } - } while (zero); - - free(ptab[i].name); - ptab[i].name = NULL; - /* - * Unlock this dev - */ - dev.drm_dev = 0; - ioctl(drv->drv_fd, DRM_PROBE_DEV, &dev); - - if (probe == 0) { - break; - } - } - if (nument == i) { - DM_MSG_PREPEND(("dm_probe_dir: " - "cannot find a matching drive " - "with serial num %s in %s: ", - drv->drv_serial_num, dirname)); - } - } - -done: - for (i = 0; i < nument; i++) { - if (ptab[i].name != NULL) { - free(ptab[i].name); - } - } - - return (rc); -} - -char ** -dm_bld_dir_tab(void) -{ - char **dirtab; - char **newtab; - int taboff = 0; - int size = DRV_DIR_TAB_SIZE; - char *libpath; - char *libname; - int len; - void *dlhdl; - char *devdir; - DIR *dir; - dirent_t *dirent; - int i; - - dirtab = (char **)malloc(size * sizeof (char *)); - if (dirtab == NULL) { - DM_MSG_ADD((MMS_EXIST, MMS_DM_E_INTERNAL, - "out of memory")); - return (NULL); - } - memset(dirtab, 0, size); - - dir = opendir(DM_DEV_LIB_DIR); - if (dir == NULL) { - DM_MSG_ADD((MMS_EXIST, MMS_DM_E_INTERNAL, - "unable to open %s", DM_DEV_LIB_DIR)); - free(dirtab); - return (NULL); - } - - while (dirent = readdir(dir)) { - libname = dirent->d_name; - len = strlen(libname); - if (strncmp(libname, "lib", 3) || - strncmp(libname + len - 3, ".so", 3)) { - /* Not lib*.so */ - continue; - } - - TRACE((MMS_DEBUG, "looking at lib %s", libname)); - libpath = mms_strapp(NULL, - "%s/%s", DM_DEV_LIB_DIR, libname); - dlhdl = dlopen(libpath, RTLD_LAZY); - if (dlhdl == NULL) { - DM_MSG_ADD((MMS_EXIST, MMS_DM_E_INTERNAL, - "unable to open %s", libpath)); - free(libpath); - continue; - } - free(libpath); - - devdir = dlsym(dlhdl, "drv_dev_dir"); - if (devdir != NULL) { - if (devdir[0] == '\0') { - /* dev dir not specified */ - dlclose(dlhdl); - continue; - } - - if (strcmp(devdir, DRV_TAPE_DIR) == 0) { - /* Already probed DRV_TAPE_DIR */ - dlclose(dlhdl); - continue; - } - - /* - * Add to dirtab if not in it already - */ - for (i = 0; i < taboff && dirtab[i] != NULL; i++) { - if (strcmp(devdir, dirtab[i]) == 0) { - /* dir name already in dirtab */ - dlclose(dlhdl); - continue; - } - } - /* Not in table yet */ - TRACE((MMS_DEBUG, "adding to dirtab: %s", devdir)); - dirtab[taboff] = strdup(devdir); - taboff++; - if (taboff == size) { - size += DRV_DIR_TAB_SIZE; - newtab = (char **) - realloc(dirtab, size * sizeof (char *)); - if (newtab == NULL) { - DM_MSG_ADD((MMS_EXIST, - MMS_DM_E_INTERNAL, - "out of memory")); - return (NULL); - } - dirtab = newtab; - } - - } - } - - /* - * Done - */ - return (dirtab); -} - -/* - * Verify target device name - */ -int -dm_verify_target_dev(char *devname) -{ - int i; - - if (devname[0] == '\0') { - return (-1); - } - - if (strncmp(devname, DRV_TAPE_DIR "/", 9) != 0) { - /* If not a tape dev, ignore */ - return (0); - } - - if (!isdigit(devname[9])) { - return (-1); - } - - /* - * strip device attribute from devname - */ - - for (i = 9; devname[i] != '\0'; i++) { - if (!isdigit(devname[i])) { - devname[i] = '\0'; - return (0); - } - } - return (0); -} - -int -dm_stat_targ_base(void) -{ - struct stat buf; - int fd; - - if (wka->dm_target_base == NULL || wka->dm_target_base[0] == '\0') { - DM_MSG_ADD((MMS_EXIST, MMS_DM_E_INTERNAL, - "target base device not available")); - return (-1); - } - - if ((fd = open(wka->dm_target_base, O_RDWR | O_NDELAY)) < 0 || - fstat(fd, &buf)) { - DM_MSG_ADD((MMS_EXIST, MMS_DM_E_INTERNAL, - "stat '%s' error: %s", - wka->dm_target_base, strerror(errno))); - if (fd >= 0) { - close(fd); - } - return (-1); - } - - wka->dm_targ_base_major = major(buf.st_rdev); - wka->dm_targ_base_minor = minor(buf.st_rdev); - TRACE((MMS_DEVP, "dm_stat_targ_base: %s - (%d:%d)", - wka->dm_target_base, wka->dm_targ_base_major, - wka->dm_targ_base_minor)); - close(fd); - return (0); -} - -int -dm_reserve_target(void) -{ - int rc = 0; - - if (drv->drv_flags & DRV_USE_PRSV) { - for (;;) { - rc = dm_reserve_target_prsv(); - if (rc == 0) { /* drive reserved */ - break; - } else if (rc > 0) { - /* error other than reservation conflict */ - DM_MSG_ADD_HEAD((MMS_INTERNAL, - MMS_DM_E_INTERNAL, - "unable to reserve drive: " - "I/O error")); - return (-1); - } - /* - * If already have MMS reservation, just preempt it. - * Otherwise see if we have to ask. - */ - rc = DM_REP_YES; /* assume preempt */ - if (!dm_have_mms_rsv()) { /* no mms rsv */ - if (wka->dm_flags & DM_ASK_PREEMPT_RSV) { - rc = dm_ask_preempt(); - } - if (rc == DM_REP_ERROR) { - /* Ask got an error, assume "no" */ - rc = DM_REP_NO; - } - if (rc == DM_REP_NO) { - DM_MSG_ADD_HEAD((MMS_INTERNAL, - MMS_DM_E_INTERNAL, - "drive reservation " - "denied by operator")); - return (-1); - } else if (rc == DM_REP_RETRY) { - sleep(1); - continue; - } - } - if (rc == DM_REP_YES) { - TRACE((MMS_DEBUG, "Preempting reservation")); - if (dm_preempt_rsv()) { - return (-1); - } - rc = 0; - break; - } - - - } - } else { - rc = dm_reserve_target_rsv(); - } - - TRACE((MMS_DEBUG, "Drive reserved successfully")); - - return (rc); -} - - -int -dm_reserve_target_prsv(void) -{ - int status = 0; - uint64_t key; - - TRACE((MMS_DEVP, "dm_reserve_target_prsv: Using PRSV")); - - /* - * Register key - */ - - if (DRV_CALL(drv_prsv_register, ())) { - status = serr->se_dsreg; - char_to_uint64((uchar_t *)DRV_PRSV_KEY, 8, &key); - TRACE((MMS_DEVP, "Can't register PRSV " - "reservation key: %16.16llx: %s", - key, mms_scsi_status(status))); - if (status == STATUS_RESERVATION_CONFLICT) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to register key, " - "reservation conflict")); - return (-1); - } else { - /* other error */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "registration error: %s", strerror(errno))); - return (EIO); - } - } - - /* - * Do an exclusive persistent reservation - */ - if (DRV_CALL(drv_prsv_reserve, ()) != 0) { - status = serr->se_dsreg; - TRACE((MMS_ERR, "Unable to reserve drive")); - if (status == STATUS_RESERVATION_CONFLICT) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to reserve drive: " - "reservation conflict")); - return (-1); - } else { - /* other error */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "reservation error: %s", strerror(errno))); - return (EIO); - } - } - - /* - * Now, get rid of all the attentions - */ - TRACE((MMS_DEVP, "dm_reserve_target_prsv: Clear attentions")); - while (DRV_CALL(drv_tur, ()) != 0 && - serr->se_senkey == KEY_UNIT_ATTENTION) { - ; - } - - TRACE((MMS_DEVP, "dm_reserve_target_prsv: Drive %s reserved", - DRVNAME)); - - return (0); -} - -int -dm_reserve_target_rsv(void) -{ - int rc = 0; - - /* - * Since the target is opened (via ldi_open()) with O_NDELAY, - * the st drive will not do reserve/release on open/close. - * until an I/O is done. A TUR will be done after binding - * the target. This causes the st driver to reserve the drive. - */ - while (DRV_CALL(drv_tur, ()) != 0 && errno == EACCES) { - TRACE((MMS_INFO, "TUR error: %s", strerror(errno))); - /* - * Drive is reserved, find out if it is assigned to - * another DM - */ - if (dm_drv_assigned() != 0) { - /* - * No, not assigned. This means that the drive - * is being used by a non MMS client. - */ - if ((wka->dm_flags & DM_PREEMPT_RSV) == 0) { - /* Do not preempt */ - return (-1); - } - - rc = DM_REP_YES; /* assume freserve */ - if (wka->dm_flags & DM_ASK_PREEMPT_RSV) { - rc = dm_ask_freserve(); - } - if (rc == DM_REP_ERROR) { - /* Ask got an error, assume "no" */ - rc = DM_REP_NO; - } - if (rc == DM_REP_YES) { - TRACE((MMS_DEBUG, "Doing forcereserve")); - if (ioctl(wka->dm_drm_fd, MTIOCFORCERESERVE)) { - return (-1); - } - } else if (rc == DM_REP_NO) { - return (-1); - } else if (rc == DM_REP_RETRY) { - continue; - } - } else { - /* - * If drive is assigned to another DM, then - * silently wait for it to be unassigned. - */ - TRACE((MMS_ERR, "Drive %s is reserved by " - "another DM. " - "Will keep trying reserve until " - "successful", wka->dm_target_base)); - } - } - - /* - * Release the reservation made by the ST driver and tell it - * not to do reserve/release at open/close. - * Then do my own reservations - */ - ioctl(drv->drv_fd, MTIOCRESERVE); - DRV_CALL(drv_release, ()); - if (DRV_CALL(drv_reserve, ()) != 0) { - ioctl(drv->drv_fd, MTIOCRELEASE); - return (-1); - } - drv->drv_flags |= DRV_RESERVED; - return (0); -} - -int -dm_release_target(void) -{ - if ((drv->drv_flags & DRV_USE_PRSV) == 0) { - /* Using reserve/release */ - DRV_CALL(drv_release, ()); - return (0); - } - - /* - * Using persistent reserve out - */ - DRV_CALL(drv_prsv_register, ()); - DRV_CALL(drv_prsv_release, ()); - return (0); -} - -int -dm_force_release(void) -{ - if (ioctl(wka->dm_drm_fd, MTIOCFORCERESERVE)) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Can't do FORCERESERVE: %s", strerror(errno))); - return (-1); - } - TRACE((MMS_DEBUG, "FORCERESERVE successful")); - - if (DRV_CALL(drv_release, ()) != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "release error: %s", strerror(errno))); - return (-1); - } - TRACE((MMS_DEBUG, "RELEASE successful")); - - return (0); -} - -int -dm_preempt_rsv(void) -{ - char buf[24]; - uint32_t num; - - if (DRV_CALL(drv_prsv_register, ()) != 0 || - DRV_CALL(drv_prsv_read_rsv, (buf, sizeof (buf))) != 0) { - if (serr->se_dsreg == STATUS_RESERVATION_CONFLICT) { - /* Try force reserve and release */ - if (dm_force_release() != 0) { - /* Can't force release */ - return (-1); - } - if (DRV_CALL(drv_prsv_register, ()) != 0 || - DRV_CALL(drv_prsv_reserve, ())) { - DM_MSG_ADD_HEAD((MMS_INTERNAL, - MMS_DM_E_INTERNAL, - "persistent reservation " "error")); - return (-1); - } - return (0); - } else { - /* Other error */ - DM_MSG_ADD_HEAD((MMS_INTERNAL, - MMS_DM_E_INTERNAL, - "reservation error", strerror(errno))); - return (-1); - } - } - - char_to_uint32((uchar_t *)buf + 4, 4, &num); - if (num == 0) { /* no reservation */ - if (DRV_CALL(drv_prsv_register, ()) != 0 || - DRV_CALL(drv_prsv_reserve, ()) != 0) { - DM_MSG_ADD_HEAD((MMS_INTERNAL, - MMS_DM_E_INTERNAL, - "persistent reservation " "error")); - return (-1); - } - } else { - /* Preempt the current reservation */ - if (DRV_CALL(drv_prsv_preempt, (buf + 8)) != 0) { - DM_MSG_ADD_HEAD((MMS_INTERNAL, - MMS_DM_E_INTERNAL, - "persistent reservation preempt" "error")); - return (-1); - } - } - - return (0); -} - -int -dm_have_mms_rsv(void) -{ - char buf[24]; - uint32_t num; - - if (DRV_CALL(drv_prsv_register, ()) != 0 || - DRV_CALL(drv_prsv_read_rsv, (buf, sizeof (buf))) != 0) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to read reservation")); - /* Can't read reservation */ - return (0); - } - - char_to_uint32((uchar_t *)buf + 4, 4, &num); - if (num == 0) { /* no reservation */ - return (0); - } - - if (memcmp(buf + 8, DRV_PRSV_KEY_PFX, 4) != 0) { - return (0); - } - - /* - * Have MMS reservation - */ - return (1); -} - -int -dm_rebind_target(void) -{ - drm_target_t targ; - - wka->dm_targ_base_minor = dm_get_targ(wka->dm_targ_base_minor); - memset(&targ, 0, sizeof (targ)); - targ.drm_targ_oflags |= FREAD | FWRITE | FNDELAY; - targ.drm_targ_major = wka->dm_targ_base_major; - targ.drm_targ_minor = wka->dm_targ_base_minor; - if (ioctl(wka->dm_drm_fd, DRM_REBIND_DEV, &targ)) { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "Rebind base device error: %s", - strerror(errno))); - return (-1); - } - TRACE((MMS_DEBUG, "Target rebound to (%d:%d)", - wka->dm_targ_base_major, wka->dm_targ_base_minor)); - return (0); -} - -int -dm_open_dm_device(void) -{ - int fd; - - /* - * close the device if it has been opened to unbind it - * from the target (most likely, the ST) driver. - */ - if (wka->dm_drm_fd != -1) { - close(wka->dm_drm_fd); - wka->dm_drm_fd = -1; - } - /* - * Open the drive manager device - */ - fd = open(wka->dm_drm_path, O_RDWR | O_NDELAY); - if (fd < 0) { - DM_MSG_ADD((MMS_EXIST, MMS_DM_E_INTERNAL, - "open '%s' error: %s", - wka->dm_drm_path, strerror(errno))); - wka->dm_drm_fd = -1; - return (-1); - } - wka->dm_drm_fd = fd; - drv->drv_fd = fd; - - return (0); -} - -int -dm_bind_target(void) -{ - struct stat statbuf; - - /* - * Get the major and minor of the DRM device - */ - fstat(wka->dm_drm_fd, &statbuf); - wka->dm_drm_major = major(statbuf.st_rdev); - wka->dm_drm_minor = minor(statbuf.st_rdev); - - /* - * Bind the drive manager to the target device. - * Since the target is opened (via ldi_open()) with O_NDELAY, - * the st drive will not do reserve/release on open/close. - * until an I/O is done. A TUR will be done after binding - * the target. This causes the st driver to reserve the drive. - */ - if (dm_bind_target_base() != 0) { - return (-1); - } - - return (0); -} - -/* - * Bind manager drive to target - */ -int -dm_bind_target_base(void) -{ - drm_target_t targ; - int err; - uint32_t buf; - char pid[20]; - - targ.drm_targ_major = wka->dm_targ_base_major; - targ.drm_targ_minor = wka->dm_targ_base_minor; - - targ.drm_targ_oflags = FWRITE | FNDELAY; - - pthread_mutex_lock(&wka->dm_tdv_close_mutex); - while (ioctl(wka->dm_drm_fd, DRM_BIND_DEV, &targ)) { - err = errno; - if (err == EMFILE) { - /* drive is still opened. wait for close */ - ioctl(wka->dm_drm_fd, DRM_TDV_PID, &buf); - snprintf(pid, sizeof (pid), "%d", buf); - TRACE((MMS_DEBUG, - "Waiting for App to close target device, pid %s", - pid)); - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "waiting for close")); - DM_MSG_SEND((DM_ADM_ERR, DM_6521_MSG, - "drive", drv->drv_drvname, "pid", pid, - DM_MSG_REASON)); - pthread_cond_wait(&wka->dm_tdv_close_cv, - &wka->dm_tdv_close_mutex); - TRACE((MMS_DEBUG, "Waken up by tdv close")); - } else { - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "unable to bind target device: %s", strerror(err))); - pthread_mutex_unlock(&wka->dm_tdv_close_mutex); - return (-1); - } - } - pthread_mutex_unlock(&wka->dm_tdv_close_mutex); - TRACE((MMS_OPER, "Device %s (%lld, %lld) bound to %s", - wka->dm_target_base, targ.drm_targ_major, targ.drm_targ_minor, - wka->dm_drm_path)); - - return (0); -} - -int -dm_bind_raw_dev(int oflag) -{ - int err; - char *path; - char *den = ""; - char *bsd = ""; - char *rew = ""; - struct stat statbuf; - drm_target_t targ; - - if (mnt->mnt_flags & MNT_LOW) { - den = "l"; - } else if (mnt->mnt_flags & MNT_MEDIUM) { - den = "m"; - } else if (mnt->mnt_flags & MNT_HIGH) { - den = "h"; - } else if (mnt->mnt_flags & (MNT_ULTRA | MNT_COMPRESSION)) { - den = "c"; - } - if (mnt->mnt_flags & (MNT_MMS | MNT_MMS_TM | MNT_BSD)) { - /* MMS mode always use "b" */ - bsd = "b"; - } - if (mnt->mnt_flags & (MNT_MMS | MNT_NOREWIND)) { - /* MMS mode always use "n" */ - rew = "n"; - } - - path = mms_strapp(NULL, - "%s%s%s%s", wka->dm_target_base, den, bsd, rew); - TRACE((MMS_DEBUG, "Device path chosen = %s", path)); - - if (stat(path, &statbuf) != 0) { - err = errno; - TRACE((MMS_ERR, "Can't stat %s: %s", path, strerror(err))); - return (err); - } - free(path); - targ.drm_targ_oflags = oflag; - targ.drm_targ_major = major(statbuf.st_rdev); - targ.drm_targ_minor = minor(statbuf.st_rdev); - if (ioctl(wka->dm_drm_fd, DRM_REBIND_DEV, &targ)) { - err = errno; - TRACE((MMS_ERR, "Rebind raw device error: %s", - strerror(err))); - return (err); - } - - dm_clear_dev(); - - return (0); -} - -void -dm_init_sense_buf(void) -{ - struct scsi_extended_sense *es; - - if (DRV_CALL(drv_req_sense, (sizeof (struct scsi_extended_sense)))) { - /* Can't read sense data */ - drv->drv_mtee_stat_len = sizeof (struct scsi_extended_sense); - TRACE((MMS_DEBUG, "drv_req_sense error: Sense buf size set " - "to %d", sizeof (struct scsi_extended_sense))); - return; - } - es = (struct scsi_extended_sense *)drv->drv_iobuf; - drv->drv_num_sen_bytes = - es->es_add_len + ((char *)&es->es_add_len - (char *)es) + 1; - drv->drv_mtee_stat_len = - sizeof (struct scsi_arq_status) - - sizeof (struct scsi_extended_sense) + drv->drv_num_sen_bytes; - if (drv->drv_mtee_stat_len < sizeof (struct scsi_arq_status)) { - drv->drv_mtee_stat_len = sizeof (struct scsi_arq_status); - } - if (drv->drv_mtee_stat_len > DRV_SENSE_LEN) { - drv->drv_mtee_stat_len = DRV_SENSE_LEN; - } - TRACE((MMS_DEBUG, "add sense length = %d, num of sen bytes = %d", - es->es_add_len, drv->drv_num_sen_bytes)); - TRACE((MMS_DEBUG, "Sense buf size set = %d", drv->drv_mtee_stat_len)); -} - -char * -dm_get_user(pid_t pid) -{ - /* - * Given the pid, return the user login name - */ - struct passwd pwd; - struct passwd *pwent; - ucred_t *ucred; - uid_t uid; - - ucred = ucred_get(pid); - uid = ucred_getruid(ucred); - - setpwent(); - pwent = getpwuid_r(uid, &pwd, wka->dm_pwbuf, wka->dm_pwbuf_size); - if (pwent == NULL) { - endpwent(); - ucred_free(ucred); - return (NULL); - } - TRACE((MMS_DEBUG, "pid %ld, uid %ld, user %s", - (long)pid, (long)uid, pwent->pw_name)); - endpwent(); - ucred_free(ucred); - return (strdup(pwent->pw_name)); -} - -int -dm_chk_dev_auth(char *user) -{ - /* - * Check to see if the user is authorized to use MMS - */ - setauthattr(); - if (!chkauthattr(MMS_AUTHNAME, user)) { - endauthattr(); - return (-1); - } - endauthattr(); - return (0); -} diff --git a/usr/src/cmd/mms/dm/common/dm_uscsi.c b/usr/src/cmd/mms/dm/common/dm_uscsi.c deleted file mode 100644 index f6ba9fc891..0000000000 --- a/usr/src/cmd/mms/dm/common/dm_uscsi.c +++ /dev/null @@ -1,462 +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/scsi/impl/uscsi.h> -#include <sys/scsi/generic/sense.h> -#include <sys/scsi/generic/status.h> -#include <unistd.h> -#include <stropts.h> -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <signal.h> -#include <errno.h> -#include <mms_trace.h> -#include <dmd_impl.h> -#include <dm_impl.h> -#include <dm_drive.h> -#include <dm_msg.h> -#include <mms_sym.h> -#include <mms_list.h> -#include <mms_scsi.h> -#include <dm_proto.h> -#include <mms_strapp.h> - -static char *_SrcFile = __FILE__; - -/* - * Process scsi error - */ -void -dm_scsi_error(int err, int status, - int cdblen, uchar_t *cdb, int senlen, uchar_t *sense) -{ - char dumpbuf[MMS_DUMPBUF_SIZE(DRV_SENSE_LEN)]; - char *error; - char *scsi_err; - drv_skaa_t *skaa; - char *buf; - - serr->se_errno = err; - serr->se_status = status; - /* Save cdb */ - memcpy((char *)serr->se_cdb, cdb, cdblen); - serr->se_cdblen = cdblen; - serr->se_senlen = senlen; - if (senlen > 0) { - /* Save sense */ - memcpy((char *)serr->se_sense, sense, senlen); - serr->se_flags |= DRV_SE_SEN_VALID; - if (serr->se_flags & DRV_SE_USCSI) { - /* - * If uscsi, save sense key in erreg - */ - serr->se_senkey = serr->se_sense[2] & 0x0f; - } - if (serr->se_resid == -1) { - /* get resid from sense bytes if not already have it */ - char_to_int64((signed char *)serr->se_sense + 3, 4, - (int64_t *)&serr->se_resid); - } - serr->se_flags |= serr->se_sense[0] & 0x80 ? - DRV_SE_SEN_VALID : 0; - serr->se_flags |= serr->se_sense[2] & 0x20 ? - DRV_SE_ILI : 0; - drv->drv_flags |= serr->se_sense[2] & 0x80 ? - DRV_TM : 0; - drv->drv_flags |= serr->se_sense[2] & 0x40 ? - DRV_EOM : 0; - } - - /* - * Trace the error - */ - (void) mms_trace_dump((char *)serr->se_cdb, serr->se_cdblen, dumpbuf, - sizeof (dumpbuf)); - TRACE((MMS_ERR, "SCSI command error: %s, cdb %s", - mms_scsi_status(serr->se_status), dumpbuf)); - error = mms_strnew("%s", strerror(serr->se_errno)); - - if (serr->se_status == STATUS_CHECK) { - if (serr->se_senlen) { - skaa = dm_skaa_lookup(serr->se_senkey, serr->se_asc, - serr->se_ascq); - serr->se_errcl = skaa->drv_ec; - (void) mms_trace_dump((char *)serr->se_sense, - serr->se_senlen, dumpbuf, sizeof (dumpbuf)); - TRACE((MMS_ERR, "Sense bytes: %s", dumpbuf)); - buf = mms_format_sense((struct scsi_extended_sense *) - &serr->se_sense); - if (buf) { - TRACE((MMS_ERR, "Sense Data: %s", buf)); - free(buf); - } - scsi_err = mms_strnew("key %s, acs %2.2x, " - "acsq %2.2x, resid %lld: %s", - mms_scsi_sensekey(serr->se_senkey), - serr->se_asc, serr->se_ascq, serr->se_resid, - skaa->drv_text); - serr->se_err_text = skaa->drv_text; - } - } else { - scsi_err = mms_strnew("%s", "no sense bytes"); - } - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "%s, status %s, %s", - error, mms_scsi_status(serr->se_status), scsi_err)); - free(error); - free(scsi_err); - mms_trace_flush(); -} - -int -dm_uscsi(struct uscsi_cmd *us) -{ - int rc; - uchar_t senbuf[DRV_SENSE_LEN]; - - if (us->uscsi_buflen > DRV_IOBUF_LEN) { - /* Reduce io size to size of io buf */ - us->uscsi_buflen = DRV_IOBUF_LEN; - } - us->uscsi_rqlen = DRV_SENSE_LEN; - us->uscsi_rqbuf = (char *)senbuf; - /* must set USCSI_RQENABLE to get sense */ - us->uscsi_flags |= (USCSI_SILENT | USCSI_RQENABLE); - - memset(serr, 0, sizeof (drv_scsi_err_t)); - rc = dm_ioctl(USCSICMD, us); - return (rc); -} - -void -dm_err_trace(void) -{ - TRACE((MMS_ERR, "type %d, status %s, sense key %s, resid %lld, " - "fileno %lld, blkno %lld, flags %16.16x", - serr->se_type, mms_scsi_status(serr->se_status), - mms_scsi_sensekey(serr->se_senkey), serr->se_resid, - serr->se_fileno, serr->se_blkno, serr->se_flags)); - -} - -void -dm_get_mtstat(int save) -{ - struct mtget mtstat; - int err = errno; - - if (ioctl(drv->drv_fd, MTIOCGET, &mtstat)) { - TRACE((MMS_ERR, "Unable to get error status")); - return; - } - - memset(serr, 0, sizeof (drv_scsi_err_t)); - serr->se_errno = err; - serr->se_type = mtstat.mt_type; - serr->se_status = mtstat.mt_dsreg; - serr->se_senkey = mtstat.mt_erreg; - serr->se_resid = mtstat.mt_resid; - serr->se_fileno = mtstat.mt_fileno; - serr->se_blkno = mtstat.mt_blkno; - serr->se_mt_flags = mtstat.mt_flags; - serr->se_mt_bf = mtstat.mt_bf; - - TRACE((MMS_DEBUG, "mtget: type=%lld, dsreg=%s, erreg=%s, resid=%lld, " - "fileno=%lld, blkno=%lld, flags=0x%llx, bf=%lld", - serr->se_type, mms_scsi_status(serr->se_status), - mms_scsi_sensekey(serr->se_senkey), serr->se_resid, - serr->se_fileno, serr->se_blkno, serr->se_mt_flags, - serr->se_mt_bf)); - - if (save == DRV_SAVE_STAT && (drv->drv_flags & DRV_VALID_STAT) == 0) { - drv->drv_mtget = serr->se_mtget; - drv->drv_flags |= DRV_VALID_STAT; - } -} - -int -dm_mtiocltop(drv_req_t *op) -{ - int err = 0; - struct mtlop mtlop; - struct mtop mtop; - int cmd; - void *arg; - int rc; - - /* - * If this is an MTIOCLTOP request, then arg points to a - * struct mtlop. - * We'll only use MTIOCLTOP if it is request by the application. - * Otherwise we use MTIOCTOP. - */ - if (wka->dm_request != NULL && - wka->dm_request->drm_req_type == DRM_REQ_MTIOCLTOP) { - mtlop.mt_op = op->drv_op; - mtlop.mt_count = op->drv_count; - cmd = MTIOCLTOP; - arg = &mtlop; - } else { - mtop.mt_op = op->drv_op; - mtop.mt_count = op->drv_count; - cmd = MTIOCTOP; - arg = &mtop; - } - - memset(serr, 0, sizeof (drv_scsi_err_t)); - rc = dm_ioctl(cmd, arg); - err = errno; - if (wka->dm_request != NULL && - wka->dm_request->drm_req_type == DRM_REQ_MTIOCLTOP) { - op->drv_op = mtlop.mt_op; - op->drv_count = mtlop.mt_count; - } else { - op->drv_op = mtop.mt_op; - op->drv_count = mtop.mt_count; - } - - if (rc != 0) { - TRACE((MMS_ERR, "MTIOCLTOP error: %s", strerror(err))); - } - errno = err; /* original errno */ - return (rc); -} - -void -dm_disallowed(void) -{ - uchar_t mask[DMD_DISALLOWED_MASK_SIZE]; - int *ac; - int num_ac; - int i; - char dumpbuf[1024]; - - /* - * Set up disallowed USCSI cmds - */ - ac = drv->drv_disallowed_cmds; - if (ac != NULL) { - num_ac = *(drv->drv_num_disallowed_cmds); - memset(mask, 0, sizeof (mask)); - for (i = 0; i < num_ac; i++) { - DMD_SET_MASK(mask, ac[i]); - } - (void) dm_ioctl(DRM_DISALLOWED_CMDS, mask); - } - (void) mms_trace_dump((char *)mask, DMD_DISALLOWED_MASK_SIZE, dumpbuf, - sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "disallowed_cmd mask: %s", dumpbuf)); - /* - * Set up disallowed ioctls - */ - ac = drv->drv_disallowed_ioctls; - if (ac != NULL) { - num_ac = *(drv->drv_num_disallowed_ioctls); - memset(mask, 0, sizeof (mask)); - for (i = 0; i < num_ac; i++) { - DMD_SET_MASK(mask, ac[i] - MTIOC); - } - (void) dm_ioctl(DRM_DISALLOWED_IOCTLS, mask); - } - (void) mms_trace_dump((char *)mask, DMD_DISALLOWED_MASK_SIZE, dumpbuf, - sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "disallowed_ioctl mask: %s", dumpbuf)); -} - -int -dm_chk_uscsi_error(int ret, struct uscsi_cmd *us, int err) -{ - int senlen; - - if (ret == 0 && us->uscsi_status == STATUS_GOOD) { - /* No error */ - return (0); - } - - if (ret < 0) { - /* An error occured */ - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_INTERNAL, - "USCSICMD error: %s", strerror(err))); - } - - if (err != EIO) { - /* Not an I/O error */ - return (-1); - } - - /* - * An I/O error - */ - dm_get_mtstat(~DRV_SAVE_STAT); - senlen = us->uscsi_rqlen - us->uscsi_rqresid; - serr->se_flags |= DRV_SE_USCSI; - dm_scsi_error(err, us->uscsi_status, - us->uscsi_cdblen, (uchar_t *)us->uscsi_cdb, - senlen, (uchar_t *)us->uscsi_rqbuf); - - drv->drv_mtget.drm_dsreg = serr->se_status; - drv->drv_mtget.drm_erreg = serr->se_senkey; - - return (-1); -} - -int -dm_ioctl(int cmd, void *arg) -{ - int rc; - int err; - - memset(serr, 0, sizeof (drv_scsi_err_t)); - rc = ioctl(drv->drv_fd, cmd, arg); - err = errno; - if (rc == -1) { - TRACE((MMS_ERR, "ioctl error: errno = %d", err)); - errno = err; - } - if (cmd == USCSICMD) { - rc = dm_chk_uscsi_error(rc, arg, err); - } else if (rc != 0) { - serr->se_resid = -1; - dm_get_mtstat(~DRV_SAVE_STAT); - dm_get_mt_error(err); - } - - if (rc != 0) { - if (serr->se_flags & DRV_SE_SEN_VALID) { - TRACE((MMS_DEBUG, "Calling drv_proc_error")); - DRV_CALL(drv_proc_error, ()); - /* - * Record error if drive is loaded. - * Hitting a tapemark is not an error - */ - if ((drv->drv_flags & DRV_TM) == 0) { - if (serr->se_senkey != KEY_NOT_READY || - (drv->drv_flags & DRV_LOADED) || - (serr->se_cmd != SCMD_TEST_UNIT_READY)) { - (void) dm_send_error(); - } - } - } - if (serr->se_senkey == KEY_HARDWARE_ERROR) { - /* set DriveBroken to "yes" */ - (void) dm_send_drive_broken(); - } else if (serr->se_senkey == KEY_MEDIUM_ERROR) { - /* Set CartridgeMediaError to "yes" */ - (void) dm_send_cartridge_media_error(); - } - } - - /* If error and no saved stat, save it */ - if (rc != 0 && (drv->drv_flags & DRV_VALID_STAT) == 0) { - memcpy(&drv->drv_mtget, &serr->se_mtget, sizeof (drm_mtget_t)); - drv->drv_flags |= DRV_VALID_STAT; - } - - errno = err; - return (rc); -} - -void -dm_get_mt_error(int err) -{ - uchar_t cdb[MMS_MAX_CDB_LEN]; - struct mterror_entry mtee = { 0, cdb }; - struct mterror_entry *mte = &mtee; - uchar_t arqbuf[DRV_SENSE_LEN]; - int have_sense = 0; - - mtee.mtee_cdb_len = sizeof (cdb); - mte->mtee_arq_status_len = drv->drv_mtee_stat_len; - mte->mtee_arq_status = (struct scsi_arq_status *)(void *)arqbuf; - serr->se_flags &= ~DRV_SE_SEN_VALID; - while (ioctl(drv->drv_fd, MTIOCGETERROR, mte) == 0) { - dm_scsi_error(err, - *(uchar_t *)&mte->mtee_arq_status->sts_status, - mte->mtee_cdb_len, cdb, - drv->drv_num_sen_bytes, - (uchar_t *)&mte->mtee_arq_status->sts_sensedata); - mte->mtee_cdb_len = sizeof (cdb); - serr->se_flags |= DRV_SE_SEN_VALID; - have_sense = 1; - } - if (have_sense == 0) { - TRACE((MMS_DEBUG, "No sense info available")); - } - if ((serr->se_flags & DRV_SE_SEN_VALID) == 0) { - /* No valid sense bytes, then use what we already know */ - TRACE((MMS_DEBUG, "Sense not valid")); - if (serr->se_erreg == SUN_KEY_EOF) { - drv->drv_flags |= DRV_TM; - } else if (serr->se_erreg == SUN_KEY_EOT) { - drv->drv_flags |= DRV_EOM; - } - } -} - -int -dm_get_log_sense_parm(uchar_t *page, int code, uint64_t *val) -{ - uint32_t len; - uchar_t *pp; - uint32_t pcode; - uint32_t psize; - uchar_t *limit; - - char_to_uint32(page + 2, 2, &len); /* page length */ - pp = page + 4; - limit = page + len; - - while (pp < limit) { - char_to_uint32(pp, 2, &pcode); - pp += 3; - psize = pp[0]; - pp++; - if (pcode == code) { /* found matching code */ - char_to_uint64(pp, psize, val); - return (0); - } - pp += psize; - } - return (-1); /* no matching code */ -} - -drv_skaa_t * -dm_skaa_lookup(uchar_t senkey, uchar_t asc, uchar_t ascq) -{ - drv_skaa_t *ele; - - for (ele = drv->drv_skaa_tab; - ele->drv_ec != DRV_EC_UNKNOWN_ERR; - ele++) { - if ((ele->drv_senkey == senkey || ele->drv_senkey == 0xff) && - (ele->drv_asc == asc || ele->drv_asc == 0xff) && - (ele->drv_ascq == ascq || ele->drv_ascq == 0xff)) { - return (ele); - } - } - return (ele); -} diff --git a/usr/src/cmd/mms/dm/common/dm_util.c b/usr/src/cmd/mms/dm/common/dm_util.c deleted file mode 100644 index 8b503fbaf5..0000000000 --- a/usr/src/cmd/mms/dm/common/dm_util.c +++ /dev/null @@ -1,163 +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 <ctype.h> -#include <time.h> -#include <unistd.h> -#include <strings.h> -#include <stdio.h> -#include <sys/varargs.h> -#include <mms_trace.h> - -void -int32_to_char(int32_t val, uchar_t *start, int len) -{ - int i; - int shift; - - for (i = 0, shift = (len - 1) * 8; i < len; i++, shift -= 8) { - start[i] = (val >> shift); - } -} - -void -int64_to_char(int64_t val, uchar_t *start, int len) -{ - int i; - int shift; - - for (i = 0, shift = (len - 1) * 8; i < len; i++, shift -= 8) { - start[i] = (val >> shift); - } -} - -void -char_to_int32(signed char *start, int len, int32_t *val) -{ - int i; - /* LINTED: to satisfy lint */ - int shift; - - *val = start[0]; - for (i = 1, shift = (len - 1) * 8; i < len; i++) { - *val = (*val << 8) | (start[i] & 0xff); - } -} - -void -char_to_uint32(uchar_t *start, int len, uint32_t *val) -{ - int i; - /* LINTED: to satisfy lint */ - int shift; - - *val = 0; - for (i = 0, shift = (len - 1) * 8; i < len; i++) { - *val = (*val << 8) | (start[i] & 0xff); - } -} - -void -char_to_int64(signed char *start, int len, int64_t *val) -{ - int i; - /* LINTED: to satisfy lint */ - int shift; - - *val = start[0]; - for (i = 1, shift = (len - 1) * 8; i < len; i++) { - *val = (*val << 8) | (start[i] & 0xff); - } -} - -void -char_to_uint64(uchar_t *start, int len, uint64_t *val) -{ - int i; - /* LINTED: to satisfy lint */ - int shift; - - *val = 0; - for (i = 0, shift = (len - 1) * 8; i < len; i++) { - *val = (*val << 8) | (start[i] & 0xff); - } -} - -void -dm_trim_tail(char *str) -{ - int len; - int i; - - len = strlen(str); - - for (i = len - 1; i >= 0; i--) { - if (str[i] == ' ') { - str[i] = '\0'; - } else { - return; - } - } -} - -void -dm_to_upper(char *vp) -{ - int i; - - for (i = 0; vp[i] != '\0'; i++) { - vp[i] = toupper(vp[i]); - } -} - -char * -dm_char_to_hex(uchar_t *ibuf, int ilen, char *obuf, int olen) -{ - int ioff; - int ooff; - int olmt = olen - 1; - int i; - - for (ioff = 0, ooff = 0; ioff < ilen; ) { - for (i = 0; (i < 4) && (ioff < ilen); i++) { - if (ooff > (olmt - 2)) { - /* Need 2 output chars for a sense byte */ - break; - } - snprintf(obuf + ooff, olmt - ooff, "%2.2x", ibuf[ioff]); - ioff++; - ooff += 2; - } - if (ooff > (olmt - 3)) { - /* Need 3 output chars for a blank and a sense byte */ - break; - } - obuf[ooff] = ' '; - ooff++; - } - obuf[ooff] = '\0'; - return (obuf); -} diff --git a/usr/src/cmd/mms/dm/i386/Makefile b/usr/src/cmd/mms/dm/i386/Makefile deleted file mode 100644 index 7e02307f11..0000000000 --- a/usr/src/cmd/mms/dm/i386/Makefile +++ /dev/null @@ -1,27 +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.cmd -include ../Makefile.com diff --git a/usr/src/cmd/mms/dm/sparc/Makefile b/usr/src/cmd/mms/dm/sparc/Makefile deleted file mode 100644 index 7e02307f11..0000000000 --- a/usr/src/cmd/mms/dm/sparc/Makefile +++ /dev/null @@ -1,27 +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.cmd -include ../Makefile.com diff --git a/usr/src/cmd/mms/lm/Makefile b/usr/src/cmd/mms/lm/Makefile deleted file mode 100644 index 9912e2b4e7..0000000000 --- a/usr/src/cmd/mms/lm/Makefile +++ /dev/null @@ -1,28 +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. -# - -SUBDIRS = $(MACH) - -include ../Makefile.subdirs diff --git a/usr/src/cmd/mms/lm/Makefile.com b/usr/src/cmd/mms/lm/Makefile.com deleted file mode 100644 index e6a965d6a8..0000000000 --- a/usr/src/cmd/mms/lm/Makefile.com +++ /dev/null @@ -1,78 +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. -# - -.KEEP_STATE: -.SUFFIXES: - -SRCS = lm.c lm_common_cmds.c lm_io.c lm_lib.c lm_queue.c - -PROG = mmslm - -OBJS = $(SRCS:%.c=%.o) -lint_SRCS = $(SRCS:%.c=%.ln) - -include ../../../Makefile.cmd - -ROOTCMDDIR= $(ROOT)/usr/lib - -$(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG -CPPFLAGS += -DMMS_OPENSSL -D_REENTRANT -CPPFLAGS += -I. -I../common -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/lib/mms/mms/common -CPPFLAGS += -I$(SRC)/lib/mms/lm/libcommon - -CFLAGS += $(CTF_FLAGS) $(CC_VERBOSE) - -LDLIBS += -lc -LDLIBS += -L$(SRC)/lib/mms/mms/$(MACH) -lmms - -.NO_PARALLEL: -.PARALLEL: $(OBJS) $(lint_SRCS) - -C99MODE = $(C99_ENABLE) - -all: $(PROG) - -$(PROG): $(OBJS) - $(LINK.c) $(OBJS) -o $@ $(LDLIBS) - $(CTFMERGE) -L VERSION -o $@ $(OBJS) - $(POST_PROCESS) - -%.o: ../common/%.c - $(COMPILE.c) $< - $(CTFCONVERT_O) - -clean: - $(RM) $(OBJS) $(lint_SRCS) - -lint: $(lint_SRCS) - -%.ln: ../common/%.c - $(LINT.c) -c $< - -install: all $(ROOTCMD) - -include ../../../Makefile.targ diff --git a/usr/src/cmd/mms/lm/common/lm.c b/usr/src/cmd/mms/lm/common/lm.c deleted file mode 100644 index 64b01e898b..0000000000 --- a/usr/src/cmd/mms/lm/common/lm.c +++ /dev/null @@ -1,1179 +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 <lm.h> -#include <lm_proto.h> -#include <net_cfg_service.h> - -/* Globals */ -static char *_SrcFile = __FILE__; -lm_t lm; /* The global library management structure. Only one */ - /* exists per library manager. */ -lm_queue_t lm_cmdq; /* The global work queue for processing LMPM cmds */ -lmpl_rsp_t lm_rspq; /* The global response structure. This keeps track */ - /* of which cmds are waiting on responses from MM */ - -pthread_mutex_t lm_acc_mutex; /* Mutex to protect cmd waiting on a accept */ - /* This mutex allows only one cmd to be sent */ - /* to MM at a time until MM responses with */ - /* a accept or unaccept response */ -pthread_mutex_t lm_write_mutex; /* Mutex to protect from multiple writes */ - /* occuring at one time from different */ - /* threads */ -int lm_daemon_mode = 1; /* Indicates if running in daemon mode */ -int lm_message_level = MMS_MSG_SEV_WARN; /* LM's message level from MM */ -int lm_state = LM_NOT_ACTIVE; /* Global indicator of LM's state */ -int exit_code = LM_NORMAL; /* Global to tell what exit code should */ - /* be used when LM exits */ -int lm_internal_error = LM_OK; /* Indicates that a fatal internal LM system */ - /* error was detected. LM will shutdown */ - /* processing and exit */ - - /* Structure that is updated to contain the */ - /* dynamic entry points to the commands that */ - /* interface with a specific library */ -lm_cmdData_t lm_cmdData[] = { - "mount", "lm_mount", NULL, - "unmount", "lm_unmount", NULL, - "move", "lm_move", NULL, - "inject", "lm_inject", NULL, - "scan", "lm_scan", NULL, - "activate", "lm_activate", NULL, - "reset", "lm_reset", NULL, - "eject", "lm_eject", NULL, - "barrier", "lm_barrier", NULL, - "private", "lm_private", NULL, - "cancel", "lm_cancel", NULL, - "exit", "lm_exit", NULL, - "event", "lm_event", NULL, - NULL, NULL, NULL, - /* Commands that also need a general */ - /* part as well as a library specific part */ - /* This general part will get called frist */ - /* and then the library specific part will be called */ - "activate", "lm_common_activate", lm_common_activate, - "private", "lm_common_private", lm_common_private, - "exit", "lm_common_exit", lm_common_exit, - "reset", "lm_common_reset", lm_common_reset, - "event", "lm_common_event", lm_common_event, - "internal", "lm_common_internal", lm_common_internal, - NULL, NULL, NULL }; - -static sigset_t signalSet; - -static void lm_cmd_handler(lm_queue_ele_t *); - -/* - * signal_waiter - * - * Parameters: - * None - arg exists only to match argument in pthread_create - * - * This routine is spawned as a separate thread created to wait for masked - * signals. Any masked signaled will be delivered to this thread. - * - * Return Values: - * None - Return value exists only to match return value in pthread_create - */ - -static void* -/* LINTED arg in signal_waiter (E_FUNC_ARG_UNUSED) */ -signal_waiter(void *arg) -{ - int signum; - - mms_trace(MMS_DEVP, "Entering signal_waiter"); - - /* LINTED constant in conditional context */ - while (1) { - signum = sigwait(&signalSet); - - switch (signum) { - - case SIGHUP: - mms_trace(MMS_OPER, "signal_waiter: Received SIGHUP " - "signal, ignoring signal"); - break; - case SIGINT: - mms_trace(MMS_OPER, "signal_waiter: Received SIGINT " - "signal, restarting LM"); - mms_trace_flush(); - lm_state = LM_STOP; - exit_code = LM_SIG_RESTART; - break; - case SIGPIPE: - mms_trace(MMS_OPER, "signal_waiter: Received SIGPIPE " - "signal, shutting down LM"); - mms_trace_flush(); - lm_internal_error = LM_NO_MM; - exit_code = LM_SIG_RESTART; - break; - case SIGTERM: - mms_trace(MMS_OPER, "signal_waiter: Received SIGTERM " - "signal, shutting down LM"); - mms_trace_flush(); - lm_state = LM_STOP; - exit_code = LM_SIG_NRESTART; - break; - default: - mms_trace(MMS_ERR, - "signal_waiter: Received a signal that " - "lm does not handle - %d", signum); - break; - } - } - /* LINTED Function has no return statement */ -} - -/* - * set_signal_handling() - * - * Paramters: - * None - * - * Mask signals to catch. All threads inherit the signal mask - * from their creator (this thread). The semantics of sigwait - * (see signal_waiter function) requires that all threads have - * the signal masked. Otherwise a signal that arrives while the - * signal_waiter is not blocked in sigwait might be delivered to - * another thread. - * - * Return Values: - * None - * - */ -static void -set_signal_handling() -{ - int rc; - pthread_t signal_thread_id; - - (void) sigemptyset(&signalSet); - (void) sigaddset(&signalSet, SIGHUP); - (void) sigaddset(&signalSet, SIGPIPE); - (void) sigaddset(&signalSet, SIGTERM); - (void) sigaddset(&signalSet, SIGINT); - - if ((rc = pthread_sigmask(SIG_BLOCK, &signalSet, NULL)) != 0) { - lm_log(LOG_ERR, "%s:%d set_signal_handling: pthread_sigmask " - "failed, rc - %d\n", MMS_HERE, rc); - exit(LM_RESTART); - } - - /* - * Create signal waiter thread. - */ - if ((rc = pthread_create(&signal_thread_id, NULL, signal_waiter, - NULL)) != 0) { - lm_log(LOG_ERR, "%s:%d set_signal_handling: pthread_create " - "failed to create signal_waiter thread, rc - %d\n", - MMS_HERE, rc); - exit(LM_RESTART); - } -} - - -/* - * lm_initialize() - * - * Parameters: - * - cfg_name: Name of network configuration file. This file contains - * necessary configuration information to connect to the MM - * - lm_daemon_mode: Indicates if LM should be started in daemon - * mode or in a standalone execution mode. - * Default is daemon mode. - * - * Globals: - * - lm: The global library management structure. Only one exists - * per library manager. Using a global verses passing it - * into all the different routines that need it. - * - * This function will initialize LM. - * - Sets up for signal processing. - * - Sets up the work queue for processing LMPM cmds. - * - Initializes mutexes. - * - Establishes the initial connection to MM. - * - Sets up the correct set of commands to support the library type. - * - * Return Values: - * MMS_OK: Function completed sucessfully. - * LM_ERROR: Function had a non recoverable error. - * - * Errors are logged in the LM's mms_trace log or - * syslog file. - */ -static int -lm_initialize(char *cfg_name, int lm_daemon_mode) -{ - int err; - int rc; /* return code */ - int i; - char *tag = NULL; - char ebuf[MMS_EBUF_LEN]; - char *hello; - char *welcome; - char *corename; - - lm_log(LOG_INFO, "%s:%d lm_init: Entering " - "lm_initialize, config file - %s\n", MMS_HERE, cfg_name); - - /* Set up signal handling */ - set_signal_handling(); - - /* Open message catalog */ - mms_cat_open(); - - /* Obtain information from config file in order */ - /* be able to connect to MM */ - if (rc = mms_net_cfg_read(&lm.lm_net_cfg, cfg_name)) { - lm_log(LOG_ERR, "%s:%d lm_init: Reading LM's config file %s " - "failed.\n", MMS_HERE, cfg_name); - exit(LM_NON_RESTART); - } - if (lm.lm_net_cfg.cli_vers) { - free(lm.lm_net_cfg.cli_vers); - } - if (lm.lm_net_cfg.cli_pass) { - hello = mms_obfpassword(lm.lm_net_cfg.cli_pass, 1); - free(lm.lm_net_cfg.cli_pass); - lm.lm_net_cfg.cli_pass = hello; - } - if (lm.lm_net_cfg.mm_pass) { - welcome = mms_obfpassword(lm.lm_net_cfg.mm_pass, 1); - free(lm.lm_net_cfg.mm_pass); - lm.lm_net_cfg.mm_pass = welcome; - } - if ((lm.lm_net_cfg.cli_vers = strdup(SUPPORT_LMP_VERSION)) == NULL) { - lm_log(LOG_ERR, "%s:%d lm_init: Setting version", MMS_HERE); - exit(LM_NON_RESTART); - } - - lm_log(LOG_INFO, "%s:%d lm_init: Reading LM's config file %s " - "completed successfully\n", MMS_HERE, cfg_name); - - if (lm_daemon_mode) { - lm_log(LOG_INFO, "%s:%d lm_init: Start LM as a daemon.\n", - MMS_HERE); - - if (getuid() != 0) { - lm_log(LOG_ERR, "%s:%d lm_init: LM was started in " - "daemon by a process that is not root\n"); - exit(LM_NON_RESTART); - } - - /* Close all open file descriptors and redirect stdin, */ - /* stdout, and stderr to /dev/null in prepration to */ - /* becoming a standalone daemon */ - for (i = 0; i < OPEN_MAX; i++) - (void) close(i); - - (void) fopen("/dev/null", "r"); - (void) fopen("/dev/null", "w"); - (void) fopen("/dev/null", "w"); - - if (setsid() < 0) { - lm_log(LOG_ERR, "%s:%d lm_init: LM's setsid failed - " - "%s, make sure LM is started by root\n", - MMS_HERE, strerror(errno)); - exit(LM_NON_RESTART); - } - - (void) umask(0); - - /* Move to where core files will be placed */ - if (mms_set_core(MMS_CORES_DIR, lm.lm_net_cfg.cli_inst)) { - lm_log(LOG_ERR, "%s:%d lm_init: LM's core setup failed " - "- %s", MMS_HERE, strerror(errno)); - } - - corename = mms_strapp(NULL, "core.mmslm.%s", - lm.lm_net_cfg.cli_inst); - /* Check to see how many core files exist */ - if (mms_man_cores(MMS_CORES_DIR, corename)) { - lm_log(LOG_ERR, "%s:%d lm_init: LM's core man failed " - "- %s", MMS_HERE, strerror(errno)); - } - free(corename); - - /* Trace filename should indicate which library */ - /* the mms_trace file is for */ - (void) snprintf(lm.lm_tracefn, sizeof (lm.lm_tracefn), - "%s/%s.debug", LM_TRACE_DIR, - lm.lm_net_cfg.cli_inst); - lm_log(LOG_INFO, "%s:%d lm_init: LM's mms_trace file - %s\n", - MMS_HERE, lm.lm_tracefn); - if (mms_trace_open(lm.lm_tracefn, MMS_ID_LM, -1, -1, 1, 1)) { - lm_log(LOG_ERR, "%s:%d lm_init: Unable to open LM's " - "mms_trace file %s, LM is unable to mms_trace " - "messages.\n", - MMS_HERE, lm.lm_tracefn); - } - } else { - if (mms_trace_open("/dev/null", MMS_ID_ND, -1, -1, 1, 1)) { - (void) printf("%s:%d lm_init: " - "Unable to set mms_trace file to " - "stderr for non daemon mode\n", MMS_HERE); - exit(LM_NON_RESTART); - } - } - -#ifdef MMS_OPENSSL - if (mms_ssl_client(&lm.lm_net_cfg, &lm.lm_ssl_data, &lm.lm_mms_err)) { - mms_get_error_string(&lm.lm_mms_err, ebuf, MMS_EBUF_LEN); - mms_trace(MMS_ERR, "ssl init - %s", ebuf); - exit(LM_NON_RESTART); - } -#endif /* MMS_OPENSSL */ - - /* set tracing level */ -#ifdef MMSDEBUG -#ifdef JDP - (void) mms_trace_filter(MMS_SEV_DEVP); -#else - (void) mms_trace_filter(MMS_SEV_DEBUG); -#endif /* JDP */ -#else - (void) mms_trace_filter(MMS_SEV_WARN); -#endif - mms_trace(MMS_DEVP, "lm_init: through daemon/non-daemon startup"); - - /* Initialize work queue */ - if ((rc = lm_queue_init(&lm_cmdq, LM_NUM_WRK_THRDS, lm_cmd_handler)) - != 0) { - mms_trace(MMS_DEBUG, "lm_init: queue_init failed, rc - %d", rc); - return (LM_ERROR); - } - - /* Initialize mutex for cmd waiting on an accept response */ - if ((rc = pthread_mutex_init(&lm_acc_mutex, NULL)) != 0) { - lm_serr(MMS_CRIT, "lm_init: acc_mutex_init failed, errno - %s", - strerror(errno)); - return (LM_ERROR); - } - - /* Initialize mutex for controling writes over MM socket */ - if ((rc = pthread_mutex_init(&lm_write_mutex, NULL)) != 0) { - lm_serr(MMS_CRIT, - "lm_init: write_mutex_init failed, errno - %s", - strerror(errno)); - return (LM_ERROR); - } - - /* Initialize mutex for accessing response queue structure */ - if ((rc = pthread_mutex_init(&lm_rspq.rspq_mutex, NULL)) != 0) { - lm_serr(MMS_CRIT, "lm_init: rsp_mutex_init failed, errno - %s", - strerror(errno)); - return (LM_ERROR); - } - - if (mms_mmconnect(&lm.lm_net_cfg, lm.lm_ssl_data, - &lm.lm_mms_conn, &err, tag) < 0) { - /* XXX STILL NEED RESPONSE TO MMS_ERROR RETURNS AS TO WHICH */ - /* ONES SHOULD CAUSE AN EXIT WITH A RESTART AND WHICH */ - /* ONES SHOULD CAUSE A NON RESTART */ - lm_serr(MMS_CRIT, - "lm_init: LM's mms_mmconnect failed, code - %s", - mms_sym_code_to_str(err)); - return (LM_ERROR); - } - - mms_trace(MMS_DEVP, "LM's mms_mmconnect succeeded"); - - return (LM_OK); -} - -/* - * - * lm_cmd_intrp() - * - * Parameters: - * - cmd Parse tree of LMPM command sent to LM by MM - * - tid A return ptr to string containing task id from cmd - * - * Globals: - * - None. - * - * This function will determine which LMPM command to process. It pulls - * the command string from the cmd node of the parse tree. - * - * Return Values: - * - Enumeration of the command to process. - * - MMS_LM_E_DEVCMDILLEGAL If the cmd string was not a valid - * command. This should never occur - * unless lmpm_parse_buf() has a - * logic error. - * - */ -static int -lm_cmd_intrp(mms_par_node_t *cmd, char **tid) -{ - int rc; /* Return code */ - - char *cmd_str; /* cmd to be processed */ - - mms_par_node_t *clause; /* Ptr to clause node of parse tree */ - mms_par_node_t *value; /* Ptr to value node of parse tree */ - - /* We know at this point we have a syntaically correct cmd, and */ - /* the cmd points to the cmd portion of the parse tree */ - - mms_trace(MMS_DEVP, "Entering lm_cmd_intrp"); - - cmd_str = mms_pn_token(cmd); - - if (strcmp("mount", cmd_str) == 0) { - mms_trace(MMS_DEBUG, "lm_cmd_intrp: Input is mount"); - rc = LM_MOUNT; - } - - else if (strcmp("unmount", cmd_str) == 0) { - mms_trace(MMS_DEBUG, "lm_cmd_intrp: Input is unmount"); - rc = LM_UNMOUNT; - } - - else if (strcmp("move", cmd_str) == 0) { - mms_trace(MMS_DEBUG, "lm_cmd_intrp: Input is move"); - rc = LM_MOVE; - } - - else if (strcmp("inject", cmd_str) == 0) { - mms_trace(MMS_DEBUG, "lm_cmd_intrp: Input is inject"); - rc = LM_INJECT; - } - - else if (strcmp("eject", cmd_str) == 0) { - mms_trace(MMS_DEBUG, "lm_cmd_intrp: Input is eject"); - rc = LM_EJECT; - } - - else if (strcmp("scan", cmd_str) == 0) { - mms_trace(MMS_DEBUG, "lm_cmd_intrp: Input is scan"); - rc = LM_SCAN; - } - - else if (strcmp("activate", cmd_str) == 0) { - mms_trace(MMS_DEBUG, "lm_cmd_intrp: Input is activate"); - rc = LM_C_ACTIVATE; - } - - else if (strcmp("reset", cmd_str) == 0) { - mms_trace(MMS_DEBUG, "lm_cmd_intrp: Input is reset"); - rc = LM_C_RESET; - } - - else if (strcmp("exit", cmd_str) == 0) { - mms_trace(MMS_DEBUG, "lm_cmd_intrp: Input is exit"); - rc = LM_C_EXIT; - } - - else if (strcmp("barrier", cmd_str) == 0) { - mms_trace(MMS_DEBUG, "lm_cmd_intrp: Input is barrier"); - rc = LM_BARRIER; - } - - else if (strcmp("private", cmd_str) == 0) { - mms_trace(MMS_DEBUG, "lm_cmd_intrp: Input is private"); - rc = LM_C_PRIVATE; - } - - else if (strcmp("cancel", cmd_str) == 0) { - mms_trace(MMS_DEBUG, "lm_cmd_intrp: Input is cancel"); - rc = LM_CANCEL; - } - - else if (strcmp("event", cmd_str) == 0) { - mms_trace(MMS_DEBUG, "lm_cmd_intrp: Input is event"); - rc = LM_C_EVENT; - /* Return here for events, there is no taskid */ - /* in an event */ - return (rc); - } - - else { - mms_trace(MMS_ERR, - "lm_cmd_intrp: Command %s is not a supported " - "LMPM command", cmd_str); - /* Return unsupported command error response to MM */ - rc = MMS_LM_E_DEVCMDILLEGAL; - } - - clause = mms_pn_lookup(cmd, "task", MMS_PN_CLAUSE, NULL); - if (clause == NULL) { - mms_trace(MMS_ERR, "lm_cmd_intrp: No task id clause found in " - "LMPM %s command", cmd_str); - /* Return an unacceptable to MM for the command */ - return (rc); - } - value = mms_pn_lookup(clause, NULL, MMS_PN_STRING, NULL); - if (value == NULL) { - mms_trace(MMS_ERR, "lm_cmd_intrp: No task id value found in " - "LMPM %s command", cmd_str); - /* Return an unacceptable to MM for this command */ - return (rc); - } - *tid = mms_pn_token(value); - - return (rc); -} - -/* - * lm_input_handler() - * - * Parameters: - * - None - * - * Globals: - * lm The global library management structure. Only one exists - * per library manager. Using a global verses passing it - * into all the different routines that need it. - * - * This function will handle all input for LM from MM. - * - Read input from MM. - * - Parse input. - * - Send accept/unaccept response for command - * - Determine if a response cmd. If so give response to the thread that - * is waiting on the response. Response can be a accept or finial. - * - If new command place command on work queue for processing threads. - * - * Return Values: - * NONE: This routine does not exit unless LM is told to shutdown or - * an internal error is detected. The lm_internal_error and - * lm_state variables control when this routine will return. - */ -static void -lm_input_handler() -{ - - int rc; /* return code */ - int class; - int code; - - char *input = NULL; /* ptr to xml input string from MM */ - char *tid; /* new cmd's task id */ - char msg_str[256]; - char rsp_str[512]; - - mms_list_t err_list; /* error list structure for parser */ - mms_par_node_t *cmd; /* ptr to parsed xml input string */ - mms_par_node_t *node; /* ptr to cmd node of parsed xml str */ - - fd_set fdset; - struct timeval tv; - struct timeval *tvp; - - mms_trace(MMS_DEVP, "Entering lm_input_handler"); - - /* Continue processing input until we are told by MM through */ - /* an exit command to shutdown. Signals may also shut us down */ - /* but at this point, we don't know which signals we are to */ - /* accept and which ones we are to ignore */ - /* LINTED constant in conditional context */ - while (1) { - if (getppid() == 1) { - lm_serr(MMS_CRIT, "lm_input_handler: LM has detected " - "that it's parnet process mmswcr has gone away"); - lm_internal_error = LM_NO_WCR; - return; - } - /* Setup a timer on the select so that */ - /* we will kick out periodically to see if */ - /* a signal from the watcher occurred */ - - FD_ZERO(&fdset); - FD_SET(lm.lm_mms_conn.mms_fd, &fdset); - - tv.tv_sec = LM_SELECT_WAIT; - tv.tv_usec = 0; - tvp = &tv; - - mms_trace_flush(); - rc = select(lm.lm_mms_conn.mms_fd + 1, &fdset, NULL, NULL, - tvp); - if (rc < 0) { - if (errno == EINTR) - continue; - else if (errno == EBADF) { - lm_serr(MMS_CRIT, "lm_input_handler: select() " - "has determined that the MM socket is no " - "longer open - %s", strerror(errno)); - lm_internal_error = LM_NO_MM; - return; - } else { - lm_serr(MMS_CRIT, "lm_input_handler: select() " - "on socket to MM has failed with a " - "errno of %s", strerror(errno)); - return; - } - - /* Timer expired see if a something occurred */ - /* to cause LM to shutdown */ - } else if (rc == 0) { - /* Check to see if LM was told to stop */ - if (lm_state == LM_STOP) { - /* See if LM can exit */ - if (lm_cmdq.lmq_first == NULL && - lm_cmdq.lmq_counter == 0) { - mms_trace(MMS_DEBUG, - "lm_input_handler: " - "LM told to exit and there are no " - "outstanding LMPM commands left to " - "process, shutting down LM"); - return; - } - } - /* Check to see if one of the command */ - /* processing threads encountered an internal */ - /* error */ - if (lm_internal_error) { - mms_trace(MMS_DEBUG, "lm_input_handler: LM has " - "encountered an unrecoverable internal " - "error, shutting down LM"); - return; - } - continue; - } - - /* Check to see if one of the command processing */ - /* threads encountered an internal error */ - if (lm_internal_error) { - mms_trace(MMS_DEBUG, - "lm_input_handler: LM has encountered " - "an unrecoverable internal error, shutting " - "down LM"); - return; - } - - /* Obtain input from MM */ - if (! FD_ISSET(lm.lm_mms_conn.mms_fd, &fdset)) { - mms_trace(MMS_ERR, "lm_input_handler: select() " - "tripped on a file descriptor, but not the one " - "LM has opened with MM"); - continue; - } - - if ((rc = mms_reader(&lm.lm_mms_conn, &input)) <= 0) { - if (rc == 0) { - lm_serr(MMS_CRIT, "lm_input_handler: Reading " - "routine mms_reader() has indicated that " - "the MM has disconnected"); - lm_internal_error = LM_NO_MM; - } else - lm_serr(MMS_CRIT, "lm_input_handler: Reading " - "routine mms_reader() failed with a " - "return code of %d", rc); - return; - } - - if (rc = mms_lmpm_parse(&cmd, &err_list, input)) { - mms_trace(MMS_ERR, "lm_input_handler: lmpm_parse_buf() " - "failed on MM input:\n%s", input); - if ((rc = lm_handle_parser_error(cmd, &err_list)) - == LM_NOMEM) { - /* NOMEM error, retry parsing again */ - mms_pe_destroy(&err_list); - mms_pn_destroy(cmd); - if (mms_lmpm_parse(&cmd, &err_list, input)) { - /* Second attempt at parsing had an */ - /* error, return error */ - lm_serr(MMS_CRIT, "lm_input_handler: " - "lmpm_parser() failed on second " - "attempt to parse input after a " - "first attempt failed due to lack " - "of memory"); - } else { - mms_trace(MMS_OPER, "lm_input_handler: " - "Able to obtain memory to parse " - "new input on second attempt of " - "parse"); - goto parse_ok; - } - } - - switch (rc) { - case LM_NOMEM: - (void) mms_buf_msgcl(msg_str, - sizeof (msg_str), LM_7025_MSG, - NULL); - (void) snprintf(rsp_str, - sizeof (rsp_str), LM_MSG_PARSE, - msg_str); - break; - case LM_SYNTAX_ERR: - (void) mms_buf_msgcl(msg_str, - sizeof (msg_str), LM_7024_MSG, - NULL); - (void) snprintf(rsp_str, - sizeof (rsp_str), LM_MSG_PARSE, - msg_str); - break; - case LM_SYNTAX_RSP: - (void) mms_buf_msgcl(msg_str, - sizeof (msg_str), - LM_7023_MSG, NULL); - (void) snprintf(rsp_str, - sizeof (rsp_str), LM_MSG_PARSE, - msg_str); - break; - case LM_SYNTAX_CMD: - node = mms_pn_lookup(cmd, NULL, - MMS_PN_CMD, NULL); - (void) mms_buf_msgcl(msg_str, - sizeof (msg_str), LM_7005_MSG, - "cmd", mms_pn_token(node), NULL); - (void) snprintf(rsp_str, - sizeof (rsp_str), LM_MSG_PARSE, - msg_str); - break; - default: - (void) mms_buf_msgcl(msg_str, - sizeof (msg_str), LM_7026_MSG, - NULL); - (void) snprintf(rsp_str, - sizeof (rsp_str), LM_MSG_PARSE, - msg_str); - break; - } - /* Send message to MM indicating the type */ - /* of parse error detected. Do no wait for */ - /* a response to the message */ - if (lm_write_msg(rsp_str, &lm.lm_mms_conn, - lm_write_mutex)) - lm_serr(MMS_CRIT, "lm_input_handler: Sending " - "parser error message failed"); - mms_pe_destroy(&err_list); - mms_pn_destroy(cmd); - free(input); - return; - } -parse_ok: - mms_pe_destroy(&err_list); - node = mms_pn_lookup(cmd, NULL, MMS_PN_CMD, NULL); - /* This should never occur unless parser generated */ - /* a invalid parse tree or memory corruption */ - if (node == NULL) { - lm_serr(MMS_CRIT, "lm_input_handler: No command node " - "found in MM input:\n%s", input); - mms_pn_destroy(cmd); - free(input); - return; - } - - if (strcmp("response", node->pn_string) == 0) { - /* Have received a response for a LMPL command */ - /* that the LM sent to the MM, update the response */ - /* command structure with the necessary response */ - /* and wake up command processing thread waiting on */ - /* the response */ - /* NOTE: We do not destory the node "cmd" here. It is */ - /* the job of function that issued the LMPL command */ - /* to free the cmd memory when it is done processing */ - /* the response */ - mms_trace(MMS_OPER, "lm_input_handler: Received a LMPL " - "response:\n%s", input); - if (lm_handle_response(cmd)) { - mms_trace(MMS_DEBUG, "lm_input_handler: " - "lm_handle_response was not able to " - "handle response cleanly"); - mms_pn_destroy(cmd); - free(input); - return; - } - free(input); - continue; - } - /* At this point we can assume that we have a new LMPM */ - /* command Determine the command to process send an */ - /* accept/unacceptable response and place command onto work */ - /* queue for worker threads */ - /* NOTE: We do not destory the node "cmd" here. It is the job */ - /* of lm_cmd_handler() function to free the cmd memory when */ - /* it is done processing the cmd */ - - mms_trace(MMS_OPER, - "lm_input_handler: Process LMPM command:\n%s", - input); - tid = NULL; - rc = lm_cmd_intrp(cmd, &tid); - /* Check to see if LMPM command is an event */ - if (rc == LM_C_EVENT) { - if (lm_handle_event(cmd)) { - mms_trace(MMS_DEBUG, "lm_input_handler: " - "handle_event failed with internal " - "error"); - return; - } - continue; - } - /* If lm_cmd_intrp was unable to obtain a valid */ - /* task id for the command we need to send an */ - /* unaccept response for the command. There is */ - /* an issue with lmpm_parse_buf since it did not */ - /* issue an error for the command and yet we could */ - /* not find the task id for the command */ - if (tid == NULL || *tid == '\0') { - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7000_MSG, "cmd", mms_pn_token(cmd), NULL); - (void) snprintf(rsp_str, sizeof (rsp_str), - LM_UNACC_RESP, msg_str); - mms_trace(MMS_OPER, - "lm_input_handler: Sending unacceptable " - "response for LMPM %s command:\n%s", - mms_pn_token(cmd), rsp_str); - if (lm_write_msg(rsp_str, &lm.lm_mms_conn, - lm_write_mutex)) { - lm_serr(MMS_CRIT, "lm_input_handler: Sending " - "unacceptable response failed"); - mms_pn_destroy(cmd); - free(input); - return; - } - /* Obtain next command */ - continue; - } - - /* Send accept response for command */ - (void) snprintf(rsp_str, sizeof (rsp_str), LM_ACC_RESP, tid); - mms_trace(MMS_OPER, - "lm_input_handler: Sending accept response:\n%s", - rsp_str); - if (lm_write_msg(rsp_str, &lm.lm_mms_conn, lm_write_mutex)) { - lm_serr(MMS_CRIT, "lm_input_handler: Sending accept " - "response failed"); - mms_pn_destroy(cmd); - free(input); - return; - } - - /* If processing an exit cmd, */ - /* SIGTERM, or SIGINT, the state of lm gets set */ - /* to LM_STOP. Any commands that are received */ - /* after one of the above, will be aborted with an */ - /* error response */ - if (lm_state == LM_STOP) { - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7003_MSG, "cmd", mms_pn_token(cmd), NULL); - mms_pn_destroy(cmd); - (void) snprintf(rsp_str, - sizeof (rsp_str), LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_DEVCMDABORT), - msg_str); - mms_trace(MMS_OPER, - "lm_input_handler: LM in stop state " - "sending error final response for new command:" - "\n%s", rsp_str); - if (lm_write_msg(rsp_str, &lm.lm_mms_conn, - lm_write_mutex)) { - lm_serr(MMS_CRIT, "lm_input_handler: Sending " - "error response failed"); - return; - } - mms_pn_destroy(cmd); - free(input); - continue; - } - - code = 0; - class = 0; - switch (rc) { - /* Commands that can be executed with LM */ - /* in any state execpt stop. Stop state */ - /* is detected above, thus not in stop state */ - case LM_C_RESET: - case LM_C_EXIT: - case LM_C_PRIVATE: - break; - /* Commands that can be executed with LM */ - /* in not-ready, broken, or disconnected */ - case LM_BARRIER: - case LM_CANCEL: - if (!(lm_state & LM_MASK0)) { - mms_trace(MMS_ERR, - "lm_input_handler: LM " - "is not in a valid state to " - "process %s command, state " - "- 0x%x", - lm_cmdData[rc].cmd, lm_state); - code = MMS_LM_E_READY; - class = MMS_STATE; - (void) mms_buf_msgcl(msg_str, - sizeof (msg_str), LM_7001_MSG, - "cmd", lm_cmdData[rc].cmd, NULL); - } - break; - - /* Commands that can be executed with LM */ - /* only in not-active, disconnected, or */ - /* active states */ - case LM_C_ACTIVATE: - if (!(lm_state & LM_MASK1)) { - mms_trace(MMS_ERR, - "lm_input_handler: LM " - "is not in a valid state to " - "process %s command, state " - "- 0x%x", - lm_cmdData[rc].cmd, lm_state); - code = MMS_LM_E_READY; - class = MMS_STATE; - (void) mms_buf_msgcl(msg_str, - sizeof (msg_str), LM_7001_MSG, - "cmd", lm_cmdData[rc].cmd, NULL); - } - break; - /* Commands that can only be executed with */ - /* LM in the active state */ - case LM_MOUNT: - case LM_UNMOUNT: - case LM_MOVE: - case LM_INJECT: - case LM_SCAN: - case LM_EJECT: - /* Make sure LM is active */ - if (!(lm_state & LM_MASK2)) { - mms_trace(MMS_ERR, - "lm_input_handler: LM " - "is not in a valid state to " - "process %s command, state " - "- 0x%x", - lm_cmdData[rc].cmd, lm_state); - code = MMS_LM_E_READY; - class = MMS_STATE; - (void) mms_buf_msgcl(msg_str, - sizeof (msg_str), LM_7001_MSG, - "cmd", lm_cmdData[rc].cmd, NULL); - } - break; - case MMS_LM_E_DEVCMDILLEGAL: - mms_trace(MMS_DEBUG, - "lm_input_handler: cmd_intrp " - "returned invalid command found, send " - "error final response"); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7002_MSG, - "cmd", mms_pn_token(cmd), NULL); - code = rc; - class = MMS_INTERNAL; - break; - } - if (code) { - (void) snprintf(rsp_str, sizeof (rsp_str), - LM_ERR_FINAL, tid, - mms_sym_code_to_str(class), - mms_sym_code_to_str(code), msg_str); - mms_trace(MMS_OPER, "lm_input_handler: Sending error " - "final response to LMPM %s command:\n%s", - mms_pn_token(cmd), rsp_str); - if (lm_write_msg(rsp_str, &lm.lm_mms_conn, - lm_write_mutex)) { - lm_serr(MMS_CRIT, "lm_input_handler: Sending " - "error final response failed"); - return; - } - mms_pn_destroy(cmd); - free(input); - continue; - } - /* Free command memory */ - free(input); - - mms_trace(MMS_DEBUG, "lm_input_handler: Adding %s command to " - "work queue", mms_pn_token(cmd)); - if ((rc = lm_queue_add(&lm_cmdq, (void *)cmd, &tid, rc)) - != LM_OK) { - mms_trace(MMS_DEBUG, "lm_input_handler adding %s " - "command to LM's work queue failed", - mms_pn_token(cmd)); - mms_pn_destroy(cmd); - return; - } - } -} - -/* - * - * lm_cmd_handler() - * - * Parameters: - * - ce Structure to a work queue element. The structure - * contains the necessary elements to process a command, - * one being the parse tree of the command itself. See - * lm.h for a complete description of the elements of - * the structure. - * - * This function is what process each of the commands issued to LM by - * MM. This function is actually executed as a spearate thread within LM. - * The queue_add function called by lm_input_handler() is what starts this - * function as a thread. The queue_add() function will start up to a - * max number of these threads to process individual commands. See the - * the queue functions for a better description of how the work queue is - * used. - * - * The final response is written out when the command processing returns. - * - * Return Values: - * - None. All error encountered need to be handled at a global - * level. Errors found in this routine are issues with - * system problems and most likely cause the LM to abort - * since recovery in most cases cannot be done correctly. - * The cmd was successfully parsed and thus should - * represent a valid command. - * - */ - -static void -lm_cmd_handler(lm_queue_ele_t *ce) -{ - /* Parse tree of cmd being processed */ - mms_par_node_t *cmd = ce->lmqe_cmd_tree; - char ret_msg[RMBUFSIZE]; - int rc; - - mms_trace(MMS_DEVP, "Entering lm_cmd_handler"); - - mms_trace(MMS_DEBUG, "lm_cmd_handler: Processing LMPM command %s", - lm_cmdData[ce->lmqe_cindex].cmd); - - /* Call cmd processing routine */ - rc = (*lm_cmdData[ce->lmqe_cindex].cd_cmdptr)(cmd, ce->lmqe_tid, - &ret_msg[0]); - - /* Each command will return either a successful finial */ - /* response or an error finial response message */ - if (rc == LM_ERROR) - mms_trace(MMS_DEBUG, - "lm_cmd_handler: Processing of LMPM %s command " - "failed:\n%s", lm_cmdData[ce->lmqe_cindex].cmd, - mms_pn_build_cmd_text(cmd)); - else - mms_trace(MMS_DEVP, - "lm_cmd_handler: Processing of LMPM %s command " - "succeded", lm_cmdData[ce->lmqe_cindex].cmd); - - /* Free memory of parse tree of LMPM cmd */ - mms_pn_destroy(cmd); - - /* Event or internal commands do not get a acknowledge or */ - /* final response */ - if (ce->lmqe_cindex == LM_C_EVENT || ce->lmqe_cindex == LM_C_INTERNAL) - return; - - /* write out final response message for LMPM command */ - mms_trace(MMS_OPER, "lm_cmd_handler: %s command's final response - %s", - lm_cmdData[ce->lmqe_cindex].cmd, ret_msg); - if (lm_write_msg(ret_msg, &lm.lm_mms_conn, lm_write_mutex)) { - lm_serr(MMS_CRIT, "lm_cmd_handler: Sending finial response for " - "%s command to MM failed", - lm_cmdData[ce->lmqe_cindex].cmd); - } -} - -/* - * - * Main routine for Library Manager. - * - * Arguments: - * Arg 1: Path to configuration file which this instance of LM is to - * use to obtain its configuration information from. - * Arg 2: Indicates if LM should be run in a non daemon mode. If set - * then LM can run as a standalone process. If run in daemon - * mode (default) LM must be run as root. - * - * Description: - * Each instance of an LM is used to control an actual physical instance - * of a library. Multiple LM instances for a library can exist at the - * same time, but only one can be active at a given time. - */ -int -main(int argc, char **argv) -{ - char msg_str[256]; - char msg_cmd[512]; - char nbuf[20]; - - /* If a second parameter is passed then this */ - /* indicates that LM is being run in standalone mode */ - if (argc == 3) - lm_daemon_mode = 0; - - if (argc == 1) { - lm_log(LOG_ERR, "%s:%d LM was not given a configuration file. " - "Unable to start LM\n.", MMS_HERE); - exit(LM_RESTART); - } - - if (lm_initialize(argv[1], lm_daemon_mode) == LM_ERROR) { - mms_trace(MMS_CRIT, - "LM initialization failed, Unable to start LM."); - mms_trace_flush(); - mms_trace_close(); - exit(LM_RESTART); - } else - lm_input_handler(); - - - if (lm_internal_error == LM_NO_MM) { - mms_trace(MMS_OPER, - "Exiting LM because connection to MM is gone"); - mms_trace_flush(); - mms_trace_close(); - exit(exit_code); - } - /* send a message to MM indicating LM is shutting down */ - if (lm_internal_error) { - if (lm_internal_error == LM_NO_WCR) - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7021_MSG, NULL); - else - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7007_MSG, NULL); - (void) snprintf(msg_cmd, sizeof (msg_cmd), - LM_MSG_EXIT, msg_str); - (void) mms_writer(&lm.lm_mms_conn, msg_cmd); - } else if (exit_code == LM_SIG_NRESTART || exit_code == - LM_SIG_RESTART) { - (void) snprintf(nbuf, sizeof (nbuf), "%d", exit_code); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7006_MSG, "ecode", nbuf, NULL); - (void) snprintf(msg_cmd, sizeof (msg_cmd), - LM_MSG_EXIT, msg_str); - if (lm_write_msg(msg_cmd, &lm.lm_mms_conn, lm_write_mutex)) - mms_trace(MMS_ERR, "Sending exit message failed"); - if (exit_code == LM_SIG_NRESTART) - exit_code = LM_NON_RESTART; - else - exit_code = LM_RESTART; - } - - mms_trace(MMS_OPER, "Exiting LM with exit code - %d", exit_code); - mms_trace_flush(); - mms_trace_close(); - - /* Need sleep in order for MM to complete processing of */ - /* the LMPL message */ - (void) sleep(5); - mms_close(&lm.lm_mms_conn); - - return (exit_code); -} diff --git a/usr/src/cmd/mms/lm/common/lm.h b/usr/src/cmd/mms/lm/common/lm.h deleted file mode 100644 index bbb09ed3b2..0000000000 --- a/usr/src/cmd/mms/lm/common/lm.h +++ /dev/null @@ -1,327 +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 __LM_H -#define __LM_H - - -#include <stdio.h> -#include <errno.h> -#include <string.h> -#include <syslog.h> -#include <stdlib.h> -#include <signal.h> -#include <unistd.h> -#include <sys/stat.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/uuid.h> -#include <limits.h> -#include <pthread.h> -#include <libintl.h> -#include <mms_list.h> -#include <mms_parser.h> -#include <mms_cores.h> -#include <mms_sym.h> -#include <mms_network.h> -#include <mms_trace.h> -#include <mms_strapp.h> -#include <mms_cfg.h> -#include <mms_cat.h> -#include <mms_lm_msg.h> -#include <lm_cmd_fmt.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define JDP 1 - -#define CMDPATH_DIRECTORY "/usr/lib/mms/lm/lib" -#define LM_TRACE_DIR "/var/log/mms/lm" - -#define TRACEFN_LEN PATH_MAX -#define CFGFN_LEN PATH_MAX -#define MSGCATFN_LEN PATH_MAX - -#define SUPPORT_LMP_VERSION "1.0" - -#define SPM_CONN_MIN 1 -#define SPM_CONN_MAX 100 -#define SPM_CONN_DEFAULT 30 - -#define SPM_IDLE_TIME_MIN 1 -#define SPM_IDLE_TIME_MAX 600 -#define SPM_IDLE_TIME_DEFAULT 60 - -#define DB_IDLE_TIME_MIN 1 -#define DB_IDLE_TIME_MAX 60 -#define DB_IDLE_TIME_DEFAULT 5 - -#define MAX_NUM_BAYS 4 /* Max number of bays in any supported */ - /* library, Needs to be updated if a new */ - /* library is added with a greater number */ - -typedef void *lm_cmdHandle_t; - -typedef struct lm { - mms_network_cfg_t lm_net_cfg; /* lm network config */ - char lm_tracefn[TRACEFN_LEN]; /* mms_trace filename */ - char lm_msgcatfn[MSGCATFN_LEN]; /* message catalog */ - char lm_manf[20]; /* Manufacturer of library */ - char *lm_name; /* Device path if direct att */ - char *lm_type; /* Type of library */ - char *lm_conn; /* Type of library connection */ - char lm_ip[20]; /* IP mms_address if network att */ - char lm_path[256]; /* Device path if direct att */ - int lm_acs; /* ACS for STK library */ - int lm_lsm; /* LSM for STK library */ - int lm_ssiport; /* Port Number for SSI */ - int lm_lsms; /* Number of lsms in library */ - int lm_panels; /* Num of panels in library */ - int lm_caps; /* Number of caps in library */ - int lm_disk_timeout; /* Disk library timeout for */ - /* stat of files on nfs */ - void *lm_port; /* Ptr to struct containing */ - /* port information */ - void *lm_drive; /* Ptr to struct containing */ - /* drive information */ - lm_cmdHandle_t lm_cmdHandle; /* Handle for cmd file */ - mms_t lm_mms_conn; /* Used for connection */ - mms_err_t lm_mms_err; - void *lm_ssl_data; /* SSL data */ -} lm_t; - -/* - * Thread structure for LM's threads - * Structure representing basic threads within LM - */ - -typedef struct lm_queue_ele { - struct lm_queue_ele *lmqe_next; - pthread_mutex_t lmqe_mutex; - pthread_cond_t lmqe_rv; - int lmqe_cindex; /* cmdData index for LMPM cmd */ - char *lmqe_tid; /* tid of cmd being prcessed */ - void *lmqe_cmd_tree; -} lm_queue_ele_t; - - -typedef struct lm_queue { - pthread_mutex_t lmq_mutex; /* protect access to queues */ - pthread_cond_t lmq_cv; /* queue control */ - pthread_attr_t lmq_attr; /* create detached threads */ - lm_queue_ele_t *lmq_first; /* queue */ - lm_queue_ele_t *lmq_last; /* queue */ - int lmq_valid; - int lmq_quit; /* queue should quit */ - int lmq_parallel; /* maximum number of worker threads */ - int lmq_counter; /* current number of worker threads */ - int lmq_idle; /* number of idle threads */ - void (*lmq_worker)(void *arg); /* worker code */ -} lm_queue_t; - -/* - * Structure to keep track of work and response queues - */ -#define SIZE_RSP_ARRAY 8 /* Number of possible outstanding */ - /* LMPL commands. This should be */ - /* kept the same size as */ - /* LM_NUM_WRK_THRDS */ - -typedef struct lmpl_rsp_node { - mms_list_node_t lmpl_rsp_next; /* ptr to the next response */ - /* used for intermediate and */ - /* final responses */ - int lmpl_rsp_type; /* indicates type of response */ - /* intermediate or final */ - mms_par_node_t *lmpl_rsp_tree; /* the parse tree of the rsp */ -} lmpl_rsp_node_t; - -typedef struct lmpl_rsp_ele { - - mms_list_t lmpl_rsp_list; /* list of final responses */ - /* since there can be */ - /* intermediate and final */ - /* responses for a lmpl cmd */ - - - pthread_mutex_t lmpl_rsp_mutex; /* used to tell command */ - /* processing thread a */ - /* response is available */ - pthread_cond_t lmpl_rsp_cv; - int lmpl_rsp_final; /* Indicates a final response */ - /* was received for lmpl cmd */ - void *lmpl_acc_tree; /* the accept response parse */ - /* tree for the lmpl command */ -} lmpl_rsp_ele_t; - -typedef struct lmpl_rsp { - pthread_mutex_t rspq_mutex; /* Controls access to response array */ - /* as a new LMPL cmd is being added */ - /* or one is being deleted */ - lmpl_rsp_ele_t *rspq_cmd[SIZE_RSP_ARRAY]; - int rspq_tid; /* Task ID of LMPL cmd waiting on */ - /* an accept unaccept response from */ - /* MM. This also represents the */ - /* index into the response arrary of */ - /* the cmd being processed by MM */ -} lmpl_rsp_t; - -typedef struct lm_cmdData { - char *cmd; /* Name of command */ - char *cd_symName; /* Symbol name of object */ - int (*cd_cmdptr)(); /* Ptr to cmd entry point from shared lib */ -} lm_cmdData_t; - - -/* Global definitions */ - -extern lm_t lm; -extern int lm_daemon_mode; -extern int lm_message_level; -extern int lm_state; -extern int exit_code; -extern int lm_internal_error; -extern lm_queue_t lm_cmdq; -extern lmpl_rsp_t lm_rspq; -extern pthread_mutex_t lm_acc_mutex; -extern pthread_mutex_t lm_write_mutex; -extern lm_cmdData_t lm_cmdData[]; - - -/* Indexs for the different possible LMPM commands */ - -#define LM_MOUNT 0 -#define LM_UNMOUNT 1 -#define LM_MOVE 2 -#define LM_INJECT 3 -#define LM_SCAN 4 -#define LM_ACTIVATE 5 -#define LM_RESET 6 -#define LM_EJECT 7 -#define LM_BARRIER 8 -#define LM_PRIVATE 9 -#define LM_CANCEL 10 -#define LM_EXIT 11 -#define LM_EVENT 12 -#define LM_NULL_CMD 13 -#define LM_C_ACTIVATE 14 -#define LM_C_PRIVATE 15 -#define LM_C_EXIT 16 -#define LM_C_RESET 17 -#define LM_C_EVENT 18 -#define LM_C_INTERNAL 19 - -/* Possible states of LM */ - -#define LM_STOP 0x0 -#define LM_NOT_ACTIVE 0x1 -#define LM_NOT_READY 0x2 -#define LM_BROKEN 0x4 -#define LM_DISCONNECTED 0x8 -#define LM_ACTIVE 0x10 - -/* Possible state for ready command */ - -#define LM_READY 0 -#define LM_NOT 1 -#define LM_DISCONN 2 -#define LM_BROKE 3 -#define LM_PRESENT 4 - -/* Masks that show which commands can execute in above states */ - -#define LM_MASK0 0x1E /* Cmds which can execute in not-ready */ - /* broken, disconnected, and active states */ - /* barrier, cancel */ -#define LM_MASK1 0x19 /* Cmds which can execute in not-active */ - /* disconnected, and active states only */ - /* activate */ -#define LM_MASK2 0x10 /* Cmds which can execute in active state */ - /* only. mount, unmount, move, inject, */ - /* eject, scan */ - -/* Exit codes for when LM exits */ - -#define LM_NORMAL 0 /* Means LM exited by an exit command */ -#define LM_NON_RESTART 1 /* Means LM exited due to exit command */ -#define LM_RESTART 2 /* Means LM exited due to reset command */ -#define LM_SIG_NRESTART 3 /* Means LM exited due to a sigterm */ -#define LM_SIG_RESTART 4 /* Means LM exited due to a sighup */ - -#define LM_OK 0 -#define LM_ERROR -1 -#define LM_NOMEM 1 -#define LM_NO_WCR 2 -#define LM_NO_MM 3 -#define LM_SYNTAX_ERR 4 -#define LM_SYNTAX_RSP 5 -#define LM_SYNTAX_CMD 6 - -#define LM_NO 0 -#define LM_YES 1 - -#define LMPL_FINAL_OK 0 -#define LMPL_FINAL_INTER 1 -#define LMPL_FINAL_ERROR 2 -#define LMPL_FINAL_CANCEL 3 -#define LMPL_FINAL_INVALID 4 -#define LMPL_UNACCEPTABLE 5 -#define LMPL_ACCEPT 6 -#define LMPL_WAITING 7 - -#define LM_NUM_WRK_THRDS 8 /* Number of cmd processing threads that can */ - /* be started at one time. There can never be */ - /* more than this num of threads started to */ - /* process LMPM cmds. The current number 8 is */ - /* just an arbitray num picked. After testing */ - /* a different num may be choosen to better */ - /* fit what is needed by LM to process cmds. */ - /* Keep SIZE_RSP_ARRAY the same size as this */ - -#define LM_SELECT_WAIT 5 /* Number of seconds to wait on pselect */ - /* before breaking out */ -#define LM_THREAD_WAIT LM_SELECT_WAIT - - /* The default number of seconds to wait */ - /* on stats of disk cartridges */ -#define LM_DISK_TIMEOUT 5 - -/* Types of connections supported */ - -#define LM_GENERIC 0 -#define LM_DIRECT_ATTACHED 1 -#define LM_NETWORK_ATTACHED 2 - -/* Buffer sizes */ - -#define RMBUFSIZE 2048 -#define FSBUFSIZE 2056 - -#ifdef __cplusplus -} -#endif - -#endif /* __LM_H */ diff --git a/usr/src/cmd/mms/lm/common/lm_cmd_fmt.h b/usr/src/cmd/mms/lm/common/lm_cmd_fmt.h deleted file mode 100644 index b12c0d9600..0000000000 --- a/usr/src/cmd/mms/lm/common/lm_cmd_fmt.h +++ /dev/null @@ -1,80 +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 __LM_CMD_FMT_H -#define __LM_CMD_FMT_H - - -#ifdef __cplusplus -extern "C" { -#endif - -#define LM_UNACC_RESP "response unacceptable %s;" -#define LM_ACC_RESP "response task [\"%s\"] accepted;" - -#define LM_TEXT_MNT "text [\"%s\" \"%s\" \"%s\" \"%s\"]" -#define LM_TEXT_CLS "text [%s]" - -#define LM_SUC_FINAL "response task [\"%s\"] success %s %s;" -#define LM_CANCEL_FINAL "response task [\"%s\"] cancelled %s;" -#define LM_ERR_FINAL "response task [\"%s\"] error [%s %s] %s;" - -#define LM_MSG_PARSE "message task [\"7998\"] who [operator] \ -severity [error] %s; " -#define LM_MSG_EXIT "message task [\"7999\"] who [operator] \ -severity [error] %s; " -#define LM_MSG_CMD "message task [\"%d\"] who [\"%s\"] severity [\"%s\"] %s; " -#define LM_DRIVEDISABLED_CMD "attribute task[\"%d\"] \ -match[streq(DRIVE.\"DriveName\" \"%s\")]set[DRIVE.\"DriveDisabled\" \"%s\"]; " - -#define PRIVATE_CMD "private task [\"%d\"] %s;" -#define PRI_GET_LIB "get [LIBRARY \"LibraryName\" LIBRARY \"LibraryType\" \ -LIBRARY \"LibraryConnection\"]" -#define PRI_GET_ACSLS "get [LIBRARY \"LibraryACS\" LIBRARY \"LibraryLSM\""\ -" LM \"LMSSIPort\"]" - -#define LM_READY_R "ready task [\"%d\"];" -#define LM_READY_N "ready task [\"%d\"] not %s;" -#define LM_READY_D "ready task [\"%d\"] disconnected %s;" -#define LM_READY_B "ready task [\"%d\"] broken %s;" -#define LM_READY_P "ready task [\"%d\"] present;" - -#define LM_EVENT_CMD "notify task[\"%d\"] \ -receive[\"NotifyNewDrive\" \"NotifyNewCartridge\"] \ -scope[global]; " - -#define LM_SEND_CANCEL "internal \"cancel\" \"%d\";" - -#define LM_DRIVE_SERIAL "attribute task[\"%d\"] \ -match[and(streq(LIBRARY.\"LibraryName\" \"%s\") \ -streq(DRIVE.\"DriveGeometry\" \"%d,%d,%d,%d\"))] \ -set[DRIVE.\"DriveSerialNum\" \"%s\"]; " - -#define LM_CANCEL_CMD "cancel task[\"%d\"] whichtask[\"%s\"]; " - -#ifdef __cplusplus -} -#endif - -#endif /* __LM_CMD_FMT_H */ diff --git a/usr/src/cmd/mms/lm/common/lm_common_cmds.c b/usr/src/cmd/mms/lm/common/lm_common_cmds.c deleted file mode 100644 index 55b5f66d65..0000000000 --- a/usr/src/cmd/mms/lm/common/lm_common_cmds.c +++ /dev/null @@ -1,1524 +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 "lm.h" -#include <lm_proto.h> - -static char *_SrcFile = __FILE__; - -static char *lm_c_priv_set[] = { - "LMMessageLevel", - "TraceLevel", - "TraceFileSize", - "SystemDiskMountTimeout", - NULL }; - -static char *lm_c_priv_unset[] = { - "LMMessageLevel", - "Tracelevel", - "TraceFileSize", - "SystemDiskMountTimeout", - NULL }; - -static char *lm_c_priv_get[] = { - NULL }; - -/* - * lm_common_ready - * - * Parameters: - * level The level that the LMPL command is to issue to MM - * tid The task id of the LMPM command that is responsible for - * the ready command to be issued. - * ret_msg If an error is detected while processing the ready command - * the error response is create here. - * - * This function sends the different forms of the LMPL ready command to MM - * based on the level sent to it. - * - * Return Values: - * LM_OK If LM was able to successfully complete the ready command. - * - * LM_ERROR If LM encountered an error while processing the ready - * command. This could mean either an internal processing error - * or just a command processing error. In either case an - * final error response is created in ret_msg with the error. - * This message would be used in the case where the ready is - * part of a LMPM command sequence. Currently only the LMPM - * activate command calls this function. - * NOTE: May not return a ret_msg here when more levels are - * called from other parts of the code. The caller would be - * responsible to generate a error message if required for a - * final response to a LMPM command. - * - */ -int -lm_common_ready(int level, char *tid, char *ret_msg) -{ - - int rc; - int lmpl_tid; - - char cmd_str[512]; - const char *cfg_str; - char msg_str[256]; - - lmpl_rsp_ele_t *ele; - - mms_trace(MMS_DEVP, "Entering lm_common_ready, set level to %d", level); - - switch (level) { - case LM_READY: - cfg_str = LM_READY_R; - break; - case LM_NOT: - cfg_str = LM_READY_N; - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7013_MSG, "state", "Not Ready", NULL); - break; - case LM_DISCONN: - cfg_str = LM_READY_D; - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7013_MSG, "state", "Disconnected", NULL); - break; - case LM_BROKE: - cfg_str = LM_READY_B; - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7013_MSG, "state", "Broke", NULL); - break; - case LM_PRESENT: - cfg_str = LM_READY_P; - break; - default: - mms_trace(MMS_ERR, "lm_c_ready: Invalid level sent " - "- %d", level); - return (LM_ERROR); - } - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_ERR, "lm_c_ready: lm_obtain_task_id was unable " - "to get a taskid for LMPL ready command"); - return (LM_ERROR); - } - - if (level == LM_PRESENT || level == LM_READY) { - (void) snprintf(cmd_str, sizeof (cmd_str), - cfg_str, lmpl_tid); - } else { - (void) snprintf(cmd_str, sizeof (cmd_str), - cfg_str, lmpl_tid, msg_str); - } - - mms_trace(MMS_DEVP, "lm_c_ready: Send ready command:\n%s", cmd_str); - - if ((rc = lm_gen_lmpl_cmd(cmd_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_CRIT, "lm_c_ready: Internal processing error " - "encountered while processing LMPL ready command:\n%s", - cmd_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, "lm_c_ready: Non success response " - "received from MM for LMPL ready command:\n%s, cmd_str"); - handle_lmpl_cmd_error(rc, "activate", "ready", tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - mms_trace(MMS_OPER, - "lm_c_ready: LMPL ready command was successfull:\n%s", - cmd_str); - - lm_remove_lmpl_cmd(lmpl_tid, ele); - mms_trace(MMS_DEVP, "Exiting lm_common_ready"); - return (LM_OK); -} - -/* - * lm_common_activate - * - * Parameters: - * cmd Pointer to the parse tree of the activate command. - * tid The task id of the activate command. - * ret_msg The final response message that is to be sent back to MM. - * This could be either a success or error final response. - * - * This function executes the necessary steps that are common between - * all libraries when the LM receives an activate command. This routine - * is responsible for dynamically loading and unloading the library specific - * command modules when the LM is activated and deactivated. - * - * Return Values: - * LM_OK If LM was able to successfully complete the activate command. - * A final success response is created in ret_msg that will be - * sent to MM. - * LM_ERROR If LM encountered an error while processing the activate - * command. This could mean either an internal processing error - * or just a command processing error. In either case an - * final error response is created in ret_msg with the - * error information that will be sent to MM. - * - */ -int -lm_common_activate(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - int rc; - int lmpl_tid; - int connection = LM_GENERIC; - - char cmd_str[512]; - char msg_str[1024]; - - mms_par_node_t *cmd_spec; - mms_par_node_t *attribute; - mms_par_node_t *clause; - mms_par_node_t *loc = NULL; - lmpl_rsp_ele_t *ele; - lmpl_rsp_node_t *node; - - mms_trace(MMS_DEVP, "Entering lm_common_activate()"); - - /* Create default final error response for MM */ - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7004_MSG, "cmd", "activate", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_INTERNAL), msg_str); - - if ((cmd_spec = mms_pn_lookup(cmd, "enable", MMS_PN_KEYWORD, NULL)) - != NULL) { - mms_trace(MMS_DEBUG, - "lm_c_activate: Processing activate enable"); - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_ERR, "lm_c_activate: lm_obtain_task_id " - "was unable to get a taskid for LMPL private " - "command to obtain library type and connection " - "information"); - return (LM_ERROR); - } - - (void) snprintf(cmd_str, sizeof (cmd_str), - PRIVATE_CMD, lmpl_tid, PRI_GET_LIB); - - mms_trace(MMS_DEVP, "lm_c_activate: Obtain library info:\n%s", - cmd_str); - - if ((rc = lm_gen_lmpl_cmd(cmd_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_CRIT, - "lm_c_activate: Internal processing " - "error encountered while processing private " - "command to obtain library type:\n%s", cmd_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, - "lm_c_activate: Non success response " - "received from MM for LMPL private command to " - "obtain library and connection type:\n%s", cmd_str); - handle_lmpl_cmd_error(rc, "activate", "private", - tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - node = mms_list_head(&ele->lmpl_rsp_list); - cmd_spec = node->lmpl_rsp_tree; - mms_trace(MMS_DEVP, "lm_c_activate: Private command to obtain " - "LibraryType and LibraryConnection received a success " - "response"); - - if ((clause = mms_pn_lookup(cmd_spec, "text", - MMS_PN_CLAUSE, NULL)) == NULL) { - mms_trace(MMS_ERR, - "lm_c_activate: No text clause found " - "in final success response of private command to " - "obtain library type, response:\n%s", - mms_pn_build_cmd_text(cmd_spec)); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - if ((attribute = mms_pn_lookup(clause, "LibraryName", - MMS_PN_STRING, &loc)) == NULL) { - mms_trace(MMS_ERR, "lm_c_activate: No LibraryName " - "attribute found in final success response of " - "private command to obtain library name, " - "response:\n%s", mms_pn_build_cmd_text(cmd_spec)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7018_MSG, "object", "LibraryName", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_SUBCMDFAILED), - msg_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - if ((attribute = mms_pn_lookup(clause, NULL, MMS_PN_STRING, - &loc)) == NULL) { - mms_trace(MMS_ERR, "lm_c_activate: No value associated " - "with LibraryName attribute found in final success " - "response of private command to obtain library " - "name, response:\n%s", - mms_pn_build_cmd_text(cmd_spec)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7018_MSG, "object", "LibraryName", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_SUBCMDFAILED), - msg_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_c_activate: Library Name - %s", - mms_pn_token(attribute)); - - lm.lm_name = strdup(mms_pn_token(attribute)); - - loc = NULL; - if ((attribute = mms_pn_lookup(clause, "LibraryType", - MMS_PN_STRING, &loc)) == NULL) { - mms_trace(MMS_ERR, "lm_c_activate: No LibraryType " - "attribute found in final success response of " - "private command to obtain library type, " - "response:\n%s", mms_pn_build_cmd_text(cmd_spec)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7018_MSG, "object", "LibraryType", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_SUBCMDFAILED), - msg_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - if ((attribute = mms_pn_lookup(clause, NULL, MMS_PN_STRING, - &loc)) == NULL) { - mms_trace(MMS_ERR, "lm_c_activate: No value associated " - "with LibraryType attribute found in final success " - "response of private command to obtain library " - "type, response:\n%s", - mms_pn_build_cmd_text(cmd_spec)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7018_MSG, "object", "LibraryType", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_SUBCMDFAILED), - msg_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_c_activate: Library Type - %s", - mms_pn_token(attribute)); - - lm.lm_type = strdup(mms_pn_token(attribute)); - - loc = NULL; - if ((attribute = mms_pn_lookup(clause, "LibraryConnection", - MMS_PN_STRING, &loc)) == NULL) { - mms_trace(MMS_ERR, - "lm_c_activate: No LibraryConnection " - "attribute found in finial success response of " - "private command to obtain library connection " - "type, response:\n%s", - mms_pn_build_cmd_text(cmd_spec)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7018_MSG, "object", "LibraryConnection", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_SUBCMDFAILED), - msg_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - if ((attribute = mms_pn_lookup(clause, NULL, MMS_PN_STRING, - &loc)) == NULL) { - mms_trace(MMS_ERR, "lm_c_activate: No value associated " - "with LibraryConnection attribute found in final " - "success response of private command to obtain " - "library connection type, response:\n%s", - mms_pn_build_cmd_text(cmd_spec)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7018_MSG, "object", "LibraryConnection", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_SUBCMDFAILED), - msg_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_c_activate: Library Connection - %s", - mms_pn_token(attribute)); - - if (strcmp("network", mms_pn_token(attribute)) == 0) { - connection = LM_NETWORK_ATTACHED; - } else if (strcmp("direct", mms_pn_token(attribute)) == 0) { - connection = LM_DIRECT_ATTACHED; - } - lm.lm_conn = strdup(mms_pn_token(attribute)); - - /* Private command to obtain library type completed */ - /* Free up element components and response array */ - lm_remove_lmpl_cmd(lmpl_tid, ele); - - mms_trace(MMS_DEBUG, - "lm_c_activate: Load correct command handling " - "routines for library type %s, %s", lm.lm_type, lm.lm_conn); - - /* Import in the correct cmd handling routines */ - if ((lm.lm_cmdHandle = lm_load_cmds(lm.lm_type, connection, - lm_cmdData)) == NULL) { - mms_trace(MMS_ERR, "lm_c_activate: unable to load " - "command handling routines for library type - " - "%s, %s", lm.lm_type, lm.lm_conn); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7020_MSG, "type", lm.lm_type, - "conn", lm.lm_conn, NULL); - lm_message("operator", "alert", msg_str); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_CONFIG), msg_str); - return (LM_ERROR); - } - /* Call library specific activate to finish */ - /* the activation of the library */ - if ((rc = (*lm_cmdData[LM_ACTIVATE].cd_cmdptr)(cmd, tid, - ret_msg)) != LM_OK) { - mms_trace(MMS_ERR, "lm_c_activate: library specific " - "activate command failed, unable to activate LM"); - lm_unload_cmds(lm.lm_cmdHandle); - return (LM_ERROR); - } - -/* - * LM does not need to register for any events at this time - * This code is being left in in case it is required in the - * future - * - * if ((rc = lm_register_events(tid, ret_msg)) != LM_OK) { - * mms_trace(MMS_DEBUG, "c_activate: Failure while issueing " - * "event register command to MM. Unable to " - * "activate LM - %s", lm.lm_net_cfg.cli_inst); - * return (LM_ERROR); - * } - * - * LM is not going to send the LMPL ready command on the - * activate. MM will set LM state to ready when it receives - * the final success response to the activate command - * - * if ((rc = lm_common_ready(LM_READY, tid, ret_msg)) != LM_OK) { - * mms_trace(MMS_DEBUG, "lm_c_activate: Failure while issueing " - * "ready command to MM. Unable to enable LM"); - * lm_unload_cmds(lm.lm_cmdHandle); - * return (LM_ERROR); - * } - */ - lm_state = LM_ACTIVE; - - mms_trace(MMS_DEBUG, "lm_c_activate: LM is active"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7014_MSG, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_SUC_FINAL, tid, msg_str, ""); - - } else if ((cmd_spec = mms_pn_lookup(cmd, "disable", MMS_PN_KEYWORD, - NULL)) != NULL) { - mms_trace(MMS_DEBUG, - "lm_c_activate: Processing activate disable"); - - lm_state = LM_NOT_ACTIVE; - - /* Abort any abortable LMPM cmds on work queue */ - lm_queue_clean(); - - /* Wait for all non abortable LMPM cmds to complete */ - while (lm_cmdq.lmq_first != NULL || lm_cmdq.lmq_counter != 1) { - mms_trace(MMS_DEBUG, "lm_c_activate: Waiting for all " - "outstanding LMPM commands to complete " - "before disable is complete"); - (void) sleep(5); - } - - mms_trace(MMS_DEBUG, "lm_c_activate: all LMPM commands have " - "completed, ready to disable LM"); - - if ((rc = lm_common_ready(LM_PRESENT, tid, ret_msg)) != LM_OK) { - mms_trace(MMS_ERR, - "lm_c_activate: Failure while issueing " - "ready command to MM. Unable to disable LM"); - /* Reset state to ACTIVE */ - lm_state = LM_ACTIVE; - return (LM_ERROR); - } - - free(lm.lm_name); - free(lm.lm_type); - free(lm.lm_conn); - lm_unload_cmds(lm.lm_cmdHandle); - - mms_trace(MMS_DEBUG, "lm_c_activate: LM is inactive"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7015_MSG, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_SUC_FINAL, tid, msg_str, ""); - - } else { - mms_trace(MMS_ERR, "lm_c_activate: Invalid activate command"); - return (LM_ERROR); - } - mms_trace(MMS_DEVP, "Exiting lm_common_activate with LM_OK"); - return (LM_OK); -} - -/* - * lm_c_validate_private() - * - * Parameters: - * - cmd LMPM private command being processed. - * - tid Task id of private command being processed. - * - ret_msg Ptr to final response string. If an error message is - * to be sent to MM for the private command because of - * a failure, the response is copied here. - * - * Globals: - * - lm_c_priv_set The set-name values allowed in a LMPM private cmd. - * - lm_c_priv_get The get-name values allowed in a LMPM private cmd. - * - lm_c_priv_unset The unset-name values allowed in a LMPM private cmd. - * - * This function validates that all the set-name, get-name, and unset-name - * are valid. If the private command contains a name that is not known by - * LM, a error final response is sent in response the the LMPM private cmd. - * This function does not validate that the set-value is valid, while the - * set-name is being processed, the value needs to be validated. This function - * is only invoked if the LM has not yet activated. In the case of an - * activated LM where a library specific private command is available, the - * validation needs to be done by the library specific private command. - * - * Return Values: - * - LM_OK If all names are valid LM_OK is returned. - * - LM_ERROR If a name is encountered that is not know, LM_ERROR - * is returned and ret_msg is updated to reflect the - * error final response for the LMPM private cmd. - */ -static int -lm_c_validate_private(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - int i; - - char *kw; - char msg_str[256]; - - mms_par_node_t *loc = NULL; - mms_par_node_t *loc1; - mms_par_node_t *clause; - mms_par_node_t *name; - mms_par_node_t *value; - - for (clause = mms_pn_lookup(cmd, kw = "get", MMS_PN_CLAUSE, &loc); - clause != NULL; clause = mms_pn_lookup(cmd, "get", - MMS_PN_CLAUSE, &loc)) { - - mms_trace(MMS_DEBUG, - "lm_c_v_private:, Validating a get clause"); - - loc1 = NULL; - for (name = mms_pn_lookup(clause, NULL, MMS_PN_STRING, - &loc1); name != NULL; name = mms_pn_lookup(clause, NULL, - MMS_PN_STRING, &loc1)) { - - for (i = 0; lm_c_priv_get[i] != NULL; i++) { - if (strcmp(mms_pn_token(name), - lm_c_priv_get[i]) == 0) { - mms_trace(MMS_DEBUG, "lm_c_v_private: " - "private get contains %s get-name", - mms_pn_token(name)); - break; - } - } - - if (lm_c_priv_get[i] == NULL) { - mms_trace(MMS_ERR, "lm_c_v_private: private " - "command contains a unsupport get-name - " - "%s", mms_pn_token(name)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7010_MSG, "type", "get", - "name", mms_pn_token(name), NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_EXIST), - mms_sym_code_to_str(MMS_LM_E_NOELT), - msg_str); - return (LM_ERROR); - } - - } - } - - loc = NULL; - for (clause = mms_pn_lookup(cmd, kw = "set", MMS_PN_CLAUSE, &loc); - clause != NULL; clause = mms_pn_lookup(cmd, "set", - MMS_PN_CLAUSE, &loc)) { - - mms_trace(MMS_DEBUG, - "lm_c_v_private:, Validating a set clause"); - - loc1 = NULL; - for (name = mms_pn_lookup(clause, NULL, MMS_PN_STRING, - &loc1); name != NULL; name = mms_pn_lookup(clause, NULL, - MMS_PN_STRING, &loc1)) { - - for (i = 0; lm_c_priv_set[i] != NULL; i++) { - if (strcmp(mms_pn_token(name), - lm_c_priv_set[i]) == 0) { - mms_trace(MMS_DEBUG, "lm_c_v_private: " - "private set contains %s set-name", - mms_pn_token(name)); - break; - } - } - - if (lm_c_priv_set[i] == NULL) { - mms_trace(MMS_ERR, "lm_c_v_private: private " - "command contains a unsupport set-name - " - "%s", mms_pn_token(name)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7010_MSG, "type", "set", - "name", mms_pn_token(name), NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_EXIST), - mms_sym_code_to_str(MMS_LM_E_NOELT), - msg_str); - return (LM_ERROR); - } - - /* For set clauses, the values asssociated */ - /* with the set-name are validated when */ - /* the set is acutally being processed, */ - /* here just skip them to get next set-name */ - MMS_PN_LOOKUP(value, clause, NULL, MMS_PN_STRING, - &loc1); - } - } - - loc = NULL; - for (clause = mms_pn_lookup(cmd, kw = "unset", MMS_PN_CLAUSE, &loc); - clause != NULL; clause = mms_pn_lookup(cmd, "unset", - MMS_PN_CLAUSE, &loc)) { - - mms_trace(MMS_DEBUG, - "lm_c_v_private:, Validating a unset clause"); - - loc1 = NULL; - for (name = mms_pn_lookup(clause, NULL, MMS_PN_STRING, - &loc1); name != NULL; name = mms_pn_lookup(clause, NULL, - MMS_PN_STRING, &loc1)) { - - for (i = 0; lm_c_priv_unset[i] != NULL; i++) { - if (strcmp(mms_pn_token(name), - lm_c_priv_unset[i]) == 0) { - mms_trace(MMS_DEBUG, "lm_c_v_private: " - "private unset contains %s " - "unset-name", mms_pn_token(name)); - break; - } - } - - if (lm_c_priv_unset[i] == NULL) { - mms_trace(MMS_ERR, "lm_c_v_private: private " - "command contains a unsupport unset-name - " - "%s", mms_pn_token(name)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7010_MSG, "type", "unset", - "name", mms_pn_token(name), NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_EXIST), - mms_sym_code_to_str(MMS_LM_E_NOELT), - msg_str); - return (LM_ERROR); - } - - } - } - - return (LM_OK); - -not_found: - mms_trace(MMS_ERR, "lm_c_v_private: LMPM private command has a " - "missing value for a %s set-name", mms_pn_token(name)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7009_MSG, "cmd", "private", "part", kw, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INVALID), - mms_sym_code_to_str(MMS_LM_E_CMDARGS), msg_str); - return (LM_ERROR); -} - -/* - * lm_common_private - * - * Parameters: - * cmd Pointer to the parse tree of the private command. - * tid The task id of the private command. - * ret_msg The final response message that is to be sent back to MM. - * This could be either a success or error final response. - * - * This function executes the necessary steps that are common between - * all libraries when the LM receives an private command. This routine - * is responsible for parsing through the parse tree to determine what - * attributes are to be updated based on the private command. This - * routine only handles what is common to all types of LMs. Once it has - * gone through the parse tree, it call the library specific private command - * handler. - * - * Return Values: - * LM_OK If LM was able to successfully complete the private command. - * A final success response is created in ret_msg that will be - * sent to MM. - * LM_ERROR If LM encountered an error while processing the private - * command. This could mean either an internal processing error - * or just a command processing error. In either case a - * final error response is created in ret_msg with the - * error information that will be sent to MM. - */ -int -lm_common_private(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - char *kw; - char msg_str[256]; - char get_str[256]; /* This may need to be changed */ - /* to accommodate larger get */ - /* return text clauses, currently */ - /* LM does not have any get-name */ - /* that it supports */ - - mms_msg_sev_t m_level; - - mms_par_node_t *loc = NULL; - mms_par_node_t *loc1; - mms_par_node_t *clause; - mms_par_node_t *name; - mms_par_node_t *value; - - mms_trace(MMS_DEVP, "Entering lm_common_private"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7004_MSG, "cmd", "private", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_INTERNAL), msg_str); - - /* Call library specific private to handle parts that */ - /* are specific for library only */ - if (lm_cmdData[LM_PRIVATE].cd_cmdptr != NULL) { - if ((*lm_cmdData[LM_PRIVATE].cd_cmdptr)(cmd, tid, - ret_msg) != LM_OK) { - mms_trace(MMS_DEBUG, "lm_c_private: library specific " - "private command failed, unable to complete " - "private command"); - return (LM_ERROR); - } - - /* If the library specific private command processes */ - /* cleanly any get library specific operations will */ - /* return their text clauses in the ret_msg, copy them */ - /* to the get_str to retain their values and add any */ - /* common library get operations to them */ - (void) strcpy(get_str, ret_msg); - } else { - if (lm_c_validate_private(cmd, tid, ret_msg) == LM_ERROR) { - mms_trace(MMS_DEBUG, - "lm_c_private: lm_c_validate_private() " - "failed"); - return (LM_ERROR); - } - - (void) strcpy(get_str, ""); - } - - for (clause = mms_pn_lookup(cmd, kw = "get", MMS_PN_CLAUSE, &loc); - clause != NULL; clause = mms_pn_lookup(cmd, "get", - MMS_PN_CLAUSE, &loc)) { - - /* Currently LM does not support any common get */ - /* operations, just a place holder for when it */ - /* does */ - mms_trace(MMS_DEBUG, "lm_c_private: Skipping get clause"); - - } - - loc = NULL; - for (clause = mms_pn_lookup(cmd, kw = "set", MMS_PN_CLAUSE, &loc); - clause != NULL; clause = mms_pn_lookup(cmd, "set", - MMS_PN_CLAUSE, &loc)) { - - mms_trace(MMS_DEBUG, "lm_c_private: Handle set clause"); - - loc1 = NULL; - for (name = mms_pn_lookup(clause, NULL, MMS_PN_STRING, - &loc1); name != NULL; name = mms_pn_lookup(clause, NULL, - MMS_PN_STRING, &loc1)) { - - MMS_PN_LOOKUP(value, clause, NULL, MMS_PN_STRING, - &loc1); - if (strcmp(mms_pn_token(name), "TraceLevel") == 0) { - if (mms_trace_str_filter(mms_pn_token(value))) { - mms_trace(MMS_DEBUG, "lm_c_private: " - "mms_trace_str_filter failed"); - (void) mms_buf_msgcl(msg_str, - sizeof (msg_str), - LM_7011_MSG, - "name", mms_pn_token(name), - "value", mms_pn_token(value), - NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, - tid, - mms_sym_code_to_str( - MMS_INTERNAL), - mms_sym_code_to_str( - MMS_LM_E_BADVAL), - msg_str); - return (LM_ERROR); - } - mms_trace(MMS_OPER, - "lm_c_private: changing mms_trace " - "level to %s", mms_pn_token(value)); - } - if (strcmp(mms_pn_token(name), "TraceFileSize") - == 0) { - if (mms_trace_set_fsize(mms_pn_token(value))) { - mms_trace(MMS_DEBUG, "lm_c_private: " - "mms_trace_set_fsize failed"); - (void) mms_buf_msgcl(msg_str, - sizeof (msg_str), - LM_7011_MSG, - "name", mms_pn_token(name), - "value", mms_pn_token(value), - NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, - tid, - mms_sym_code_to_str( - MMS_INTERNAL), - mms_sym_code_to_str( - MMS_LM_E_BADVAL), - msg_str); - return (LM_ERROR); - } - mms_trace(MMS_OPER, - "lm_c_private: changing mms_trace " - "file rotation size to %s", - mms_pn_token(value)); - } - if (strcmp(mms_pn_token(name), "LMMessageLevel") - == 0) { - m_level = - mms_msg_get_severity(mms_pn_token(value)); - if (m_level < MMS_MSG_SEV_EMERG || m_level > - MMS_MSG_SEV_DEVP) { - mms_trace(MMS_ERR, "lm_c_private " - "invalid message level - %s", - mms_pn_token(value)); - (void) mms_buf_msgcl(msg_str, - sizeof (msg_str), - LM_7011_MSG, - "name", mms_pn_token(name), - "value", mms_pn_token(value), - NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, - tid, - mms_sym_code_to_str( - MMS_INTERNAL), - mms_sym_code_to_str( - MMS_LM_E_BADVAL), - msg_str); - return (LM_ERROR); - } - lm_message_level = m_level; - mms_trace(MMS_OPER, "lm_c_private: changing " - "message level to %s", - mms_pn_token(value)); - } - if (strcmp(mms_pn_token(name), - "SystemDiskMountTimeout") == 0) { - lm.lm_disk_timeout = - atoi(mms_pn_token(value)); - mms_trace(MMS_OPER, "lm_c_private: changing " - "disk stat timeout to %s", - mms_pn_token(value)); - } - } - } - - loc = NULL; - for (clause = mms_pn_lookup(cmd, kw = "unset", MMS_PN_CLAUSE, &loc); - clause != NULL; clause = mms_pn_lookup(cmd, "unset", - MMS_PN_CLAUSE, &loc)) { - - mms_trace(MMS_DEBUG, "lm_c_private: Handle unset clause"); - - loc1 = NULL; - for (name = mms_pn_lookup(clause, NULL, MMS_PN_STRING, - &loc1); name != NULL; name = mms_pn_lookup(clause, NULL, - MMS_PN_STRING, &loc1)) { - - if (strcmp(mms_pn_token(name), "TraceLevel") == 0) { - mms_trace(MMS_OPER, - "lm_c_private: changing mms_trace " - "level to default of error"); - (void) mms_trace_filter(MMS_SEV_ERROR); - } - if (strcmp(mms_pn_token(name), "TraceFileSize") - == 0) { - mms_trace(MMS_OPER, - "lm_c_private: changing mms_trace " - "file rotation size to 10M"); - (void) mms_trace_set_fsize("10M"); - } - - if (strcmp(mms_pn_token(name), "LMMessageLevel") - == 0) { - mms_trace(MMS_OPER, "lm_c_private: changing " - "message level to warning"); - lm_message_level = MMS_MSG_SEV_WARN; - } - if (strcmp(mms_pn_token(name), - "SystemDiskMountTimeout") == 0) { - lm.lm_disk_timeout = LM_DISK_TIMEOUT; - mms_trace(MMS_OPER, "lm_c_private: changing " - "disk stat timeout to %d", - LM_DISK_TIMEOUT); - } - } - } - - mms_trace(MMS_DEBUG, - "lm_c_private: completed private command successfully"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7101_MSG, "cmd", "private", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_SUC_FINAL, tid, get_str, msg_str); - mms_trace(MMS_DEVP, "Exiting lm_common_private"); - return (LM_OK); - -not_found: - mms_trace(MMS_ERR, "lm_c_private: LMPM private command has a " - "missing value for a %s set-name", mms_pn_token(name)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7009_MSG, "cmd", "private", "part", kw, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INVALID), - mms_sym_code_to_str(MMS_LM_E_CMDARGS), msg_str); - return (LM_ERROR); -} - -/* - * lm_common_event - * - * Parameters: - * cmd Pointer to the parse tree of the event command. - * tid The task id of the event command. - * ret_msg Just a place holder, events do not get a response. The - * lm_cmd_handler() routine that calls this routine will - * skip the sending of the response. - * - * This function executes the necessary steps that are common between - * all libraries when the LM receives an event. The routine will first - * call the library specific lm_event() routine. - * - * Currently there are no events that LM registers for, so LM should - * never receive an event. If one is received, it is just ignored at this - * time. In the future if LM can receive events, this code will need to - * be updated to handle those events. - * - * Return Values: - * LM_OK If LM was able to successfully complete the event. - * LM_ERROR If LM encountered an error while processing the event - * This could mean either an internal processing error - * or just a command processing error. - */ -int -lm_common_event(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - - mms_trace(MMS_DEVP, "Entering lm_common_event"); - - mms_trace(MMS_OPER, - "Processing event:\n%s", mms_pn_build_cmd_text(cmd)); - - if (lm_cmdData[LM_EVENT].cd_cmdptr == NULL) { - mms_trace(MMS_DEBUG, - "lm_c_event: no library specific lm_event() " - "defined"); - } else if ((*lm_cmdData[LM_EVENT].cd_cmdptr)(cmd, tid, ret_msg) - != LM_OK) { - mms_trace(MMS_ERR, "lm_c_event: Library specific event command " - "failed"); - return (LM_ERROR); - } - - mms_trace(MMS_DEVP, "Exiting lm_common_event"); - return (LM_OK); -} - -/* - * lm_common_internal - * - * Parameters: - * cmd Pointer to the parse tree of the internal command. - * tid The task id of the internal command. - * ret_msg Just a place holder, internal commands do not get a - * response. The lm_cmd_handler() routine that calls this - * routine will skip the sending of the response. - * - * This function is used by the LM to be able to process another command - * on behalf of a different LMPM command. - * - * Currently, when lm_gen_lmpl_cmd() sends a LMPL command as part of - * processing a LMPM command, the routine processing the LMPM command - * can specifiy a timeout for how long it will wait for a response to - * the LMPL command. If the timeout is hit, the LM will need to send a - * cancel command for the LMPL command. This is done by adding an - * internal cancel command to the work queue, which will cause this - * routine to be invoked by the lm_cmd_handler(). - * - * Note: No commands currently send a LMPL command with a timeout, thus - * nothing within LM currently will generate the internal command. - * - * Return Values: - * LM_OK If LM was able to successfully complete the internal command. - * LM_ERROR If LM encountered an error while processing the internal - * command. This could mean either an internal processing error - * or just a command processing error. - */ -int -lm_common_internal(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - - int rc; - int lmpl_tid; - - char cmd_str[256]; - - mms_par_node_t *loc = NULL; - mms_par_node_t *icmd; - mms_par_node_t *taskid; - lmpl_rsp_ele_t *ele; - - mms_trace(MMS_DEVP, "Entering lm_common_internal"); - - if ((icmd = mms_pn_lookup(cmd, NULL, MMS_PN_STRING, &loc)) - == NULL) { - mms_trace(MMS_ERR, "lm_c_internal: No internal command found " - "in command:\n%s", mms_pn_build_cmd_text(cmd)); - return (LM_ERROR); - } - - if (strcmp("cancel", mms_pn_token(icmd)) == 0) { - mms_trace(MMS_DEBUG, "lm_c_internal: Processing an internal " - "cancel command"); - - if ((taskid = mms_pn_lookup(cmd, NULL, MMS_PN_STRING, &loc)) - == NULL) { - mms_trace(MMS_ERR, "lm_c_internal: No taskid found in " - "the internal cancel command:\n%s", - mms_pn_build_cmd_text(cmd)); - return (LM_ERROR); - } - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_ERR, "lm_obtain_task_id failed trying to " - "generate cancel command for LMPL command " - "with taskid - %s", mms_pn_token(taskid)); - return (LM_ERROR); - } - - (void) snprintf(cmd_str, sizeof (cmd_str), - LM_CANCEL_CMD, lmpl_tid, - mms_pn_token(taskid)); - - mms_trace(MMS_DEBUG, "lm_c_internal: Cancel cmd:\n%s", cmd_str); - - if ((rc = lm_gen_lmpl_cmd(cmd_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_CRIT, "lm_common_internal: Internal " - "processing error encountered while processing " - "internal cancel command to cancel LMPL " - "command with taskid - %s", mms_pn_token(taskid)); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else if (rc == LMPL_FINAL_ERROR) { - mms_trace(MMS_ERR, - "lm_common_internal: Internal cancel " - "command received error response, unable to " - "cancel LMPL commmand with task id - %s", - mms_pn_token(taskid)); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_CRIT, - "lm_common_internal: Internal cancel " - "command received a non success response, unable " - "to cancel LMPL command with taskid - %s", - mms_pn_token(taskid)); - handle_lmpl_cmd_error(rc, "internal", "cancel", tid, - ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else { - mms_trace(MMS_DEBUG, - "lm_common_internal: Internal cancel " - "command received a success final response"); - } - lm_remove_lmpl_cmd(lmpl_tid, ele); - - } else { - mms_trace(MMS_ERR, - "lm_c_internal: Unsupported internal command " - "received:\n", mms_pn_build_cmd_text(cmd)); - return (LM_ERROR); - } - - return (LM_OK); -} - -/* - * lm_message - * - * Parameters: - * who Specifies the who in the LMPL message - * severity Specifies the severity of the LMPL message - * msg The message to be sent out - * - * This function is used to send a message of some severity level to - * the destination defined by the argument "who". - * - * Return Values: - * None Since this is just a message going out, if it fails to - * be sent, it should not affect the running of the LM. - * - * Currently the messages are being sent out only to tell - * the operator of some other type of error that has - * occurred on a LMPM command; therefore, the error will be - * returned to the client in the error response. - */ -void -lm_message(char *who, char *severity, char *msg) -{ - int rc; - int lmpl_tid; - - char cmd_str[1024]; - - lmpl_rsp_ele_t *ele; - - mms_trace(MMS_DEVP, "Entering lm_message"); - - if (mms_msg_get_severity(severity) > lm_message_level) { - mms_trace(MMS_INFO, "lm_message: Unable to send message, the " - "severity of the message is less than what is currently " - "allowed. message ignored:\n%s", msg); - return; - } - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_ERR, "lm_message: lm_obtain_task_id was unable " - "to get a taskid for LMPL message command"); - return; - } - - (void) snprintf(cmd_str, sizeof (cmd_str), - LM_MSG_CMD, lmpl_tid, who, severity, msg); - - mms_trace(MMS_DEVP, "lm_message: message command:\n%s", cmd_str); - - if ((rc = lm_gen_lmpl_cmd(cmd_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_CRIT, "lm_message: Internal processing error " - "encountered while processing LMPL message command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return; - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, "lm_message: Non success response " - "received from MM for LMPL message command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return; - } - - lm_remove_lmpl_cmd(lmpl_tid, ele); - mms_trace(MMS_DEVP, "Message sent successfully, exiting lm_message"); -} - -/* - * lm_common_exit - * - * Parameters: - * cmd Pointer to the parse tree of the exit command. - * tid The task id of the exit command. - * ret_msg The final response message that is to be sent back to MM. - * This could be either a success or error final response. - * - * This function executes the necessary steps that are common between - * all libraries when the LM receives a exit command. This routine - * is responsible for shutting down the LM gracefully and then exiting. - * Even if something does not shutdown cleanly, the LM will still exit. - * - * Return Values: - * LM_OK If LM was able to successfully complete the exit command. - * A final success response is created in ret_msg that will be - * sent to MM. - * LM_ERROR If LM encountered an error while processing the exit - * command. This could mean either an internal processing error - * or just a command processing error. In either case a - * final error response is created in ret_msg with the - * error information that will be sent to MM. - */ -int -lm_common_exit(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - int rc; - - char msg_str[1024]; - - mms_trace(MMS_DEVP, "Entering CommonExit"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7004_MSG, "cmd", "exit", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_INTERNAL), msg_str); - - /* Set state of lm to stop to abort any new commands */ - lm_state = LM_STOP; - /* Set LM state in MM to not ready */ - if ((rc = lm_common_ready(LM_NOT, tid, ret_msg)) != LM_OK) { - mms_trace(MMS_ERR, "lm_c_exit: Failure of ready command to MM. " - "Unable to set LM's state to not ready"); - } - - /* Abort any abortable LMPM cmds on work queue */ - lm_queue_clean(); - - /* Wait for all non abortable LMPM cmds to complete */ - while (lm_cmdq.lmq_first != NULL || lm_cmdq.lmq_counter != 1) { - mms_trace(MMS_DEBUG, - "lm_c_exit: Waiting for all outstanding LMPM " - "commands to complete before exit is complete"); - (void) sleep(5); - } - /* Call library specific lm_exit() to handle any parts */ - /* are specific for the library only */ - if (lm_cmdData[LM_EXIT].cd_cmdptr != NULL) { - if ((*lm_cmdData[LM_EXIT].cd_cmdptr)(cmd, tid, - ret_msg) != LM_OK) { - mms_trace(MMS_ERR, "lm_c_exit: library specific " - "exit command failed to do pre exit cleanly"); - } else { - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7016_MSG, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_SUC_FINAL, tid, msg_str, ""); - } - } else { - if (rc == LM_OK) { - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7016_MSG, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_SUC_FINAL, tid, msg_str, ""); - } - } - - mms_trace(MMS_DEVP, "lm_c_exit: exit command's final response:\n%s", - ret_msg); - mms_trace(MMS_OPER, "lm_c_exit: All outstanding LMPM commands have " - "completed, ready to exit LM"); - - exit_code = LM_NON_RESTART; - - return (LM_OK); -} - -/* - * lm_common_reset - * - * Parameters: - * cmd Pointer to the parse tree of the reset command. - * tid The task id of the reset command. - * ret_msg The final response message that is to be sent back to MM. - * This could be either a success or error final response. - * - * This function executes the necessary steps that are common between - * all libraries when the LM receives a reset command. This routine - * is responsible for shutting down the LM gracefully and then restarting. - * - * Return Values: - * LM_OK If LM was able to successfully complete the reset command. - * A final success response is created in ret_msg that will be - * sent to MM. - * LM_ERROR If LM encountered an error while processing the reset - * command. This could mean either an internal processing error - * or just a command processing error. In either case a - * final error response is created in ret_msg with the - * error information that will be sent to MM. - */ - -int -lm_common_reset(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - int rc; - int partial = LM_NO; - - char msg_str[1024]; - char lret_msg[2048]; - - mms_trace(MMS_DEVP, "Entering CommonReset"); - - lret_msg[0] = '\0'; - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7004_MSG, "cmd", "reset", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, - tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_INTERNAL), - msg_str); - - if (mms_pn_lookup(cmd, "partial", MMS_PN_KEYWORD, NULL) - != NULL) { - partial = LM_YES; - - /* Set LM state in MM to not ready */ - if ((rc = lm_common_ready(LM_NOT, tid, ret_msg)) != LM_OK) { - mms_trace(MMS_ERR, "lm_c_reset: LMPL ready not failed, " - "unable to set LM's state to ready not prior to " - "reset"); - return (LM_ERROR); - } - } else { - /* Set LM state in MM to not ready, ignore return */ - /* value since the LM will reset itself */ - if ((rc = lm_common_ready(LM_NOT, tid, lret_msg)) != LM_OK) { - mms_trace(MMS_ERR, "lm_c_reset: LMPL ready not failed, " - "unable to set LM's state to ready not prior to " - "reset"); - } - /* Set state of lm to stop to abort any new commands */ - lm_state = LM_STOP; - - /* Abort any abortable LMPM cmds on work queue */ - lm_queue_clean(); - - /* Wait for all non abortable LMPM cmds to complete */ - while (lm_cmdq.lmq_first != NULL || lm_cmdq.lmq_counter != 1) { - mms_trace(MMS_DEBUG, "lm_c_reset: Waiting for all " - "outstanding LMPM commands to complete before " - "reset is complete"); - (void) sleep(5); - } - } - - /* Call library specific lm_reset() to handle any parts */ - /* are specific for the library only */ - if (lm_cmdData[LM_RESET].cd_cmdptr != NULL) { - if ((*lm_cmdData[LM_RESET].cd_cmdptr)(cmd, tid, - ret_msg) != LM_OK) { - /* Use retmsg for resturn message */ - mms_trace(MMS_DEVP, "lm_c_reset: library specific " - "reset command failed to do reset cleanly"); - if (partial) { - if (lm_common_ready(LM_READY, tid, lret_msg) - != LM_OK) { - lm_serr(MMS_CRIT, "lm_c_reset: During " - "a partial reset, LMPL ready " - "command failed to set LM's state " - "back to ready"); - } - return (LM_ERROR); - } else { - mms_trace(MMS_ERR, - "lm_c_reset: library specific " - "full reset failed"); - } - } else { - if (partial) { - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7022_MSG, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_SUC_FINAL, - tid, msg_str, ""); - } else { - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7017_MSG, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_SUC_FINAL, - tid, msg_str, ""); - } - } - } else { - mms_trace(MMS_DEBUG, "No library specific reset function " - "exists"); - if (partial) { - if (lm_common_ready(LM_READY, tid, ret_msg) != LM_OK) { - lm_serr(MMS_CRIT, - "lm_c_reset: During a partial " - "reset, LMPL ready command failed to set " - "LM's state back to ready"); - return (LM_ERROR); - } - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7022_MSG, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_SUC_FINAL, tid, msg_str, ""); - return (LM_OK); - } else { - if (rc == LM_OK) { - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7017_MSG, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_SUC_FINAL, - tid, msg_str, ""); - } - } - } - if (partial) { - if (lm_common_ready(LM_READY, tid, ret_msg) != LM_OK) { - lm_serr(MMS_CRIT, "lm_c_reset: During a partial " - "reset, LMPL ready command failed to set " - "LM's state back to ready"); - return (LM_ERROR); - } - } else { - mms_trace(MMS_OPER, - "lm_c_reset: All outstanding LMPM commands have " - "completed, ready to reset LM"); - - exit_code = LM_RESTART; - } - mms_trace(MMS_DEVP, "lm_c_reset: reset command's final response:\n%s", - ret_msg); - - return (LM_OK); -} -/* - * lm_set_drive_disabled - * - * Parameters: - * - drive_name : ptr to string of drive name - * - drive_state : ptr to string of DriveDisabled state to set to - * - * Sends an attribute command to MM to set the DriveDisabled state to - * the drive_state string for a drive who's name is drive_name - * - * Return Values: - * None - * - */ -void -lm_set_drive_disabled(char *drive_name, char *drive_state) -{ - int rc; - int lmpl_tid; - - char *cmd_str = NULL; - - lmpl_rsp_ele_t *ele; - - mms_trace(MMS_DEVP, "Entering lm_set_drive_disabled"); - - if (drive_name == NULL) { - mms_trace(MMS_ERR, - "lm_set_drive_disabled: " - "passed null drive_name"); - return; - } - if (drive_state == NULL) { - mms_trace(MMS_ERR, - "lm_set_drive_disabled: " - "passed null drive_state"); - return; - } - mms_trace(MMS_DEBUG, - "lm_set_drive_disabled: " - "set DriveDisabled = %s for %s", - drive_state, drive_name); - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_ERR, - "lm_set_drive_disabled: " - "lm_obtain_task_id was unable " - "to get a taskid for LMPL attribute command"); - return; - } - - cmd_str = mms_strapp(cmd_str, - LM_DRIVEDISABLED_CMD, lmpl_tid, - drive_name, drive_state); - - mms_trace(MMS_DEVP, - "lm_set_drive_disabled: " - "attribute command:\n%s", cmd_str); - - if ((rc = lm_gen_lmpl_cmd(cmd_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_CRIT, - "lm_set_drive_disabled: " - "Internal processing error " - "encountered while processing LMPL attribute command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(cmd_str); - return; - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, - "lm_set_drive_disabled: " - "Non success response " - "received from MM for LMPL attribute command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(cmd_str); - return; - } - - lm_remove_lmpl_cmd(lmpl_tid, ele); - mms_trace(MMS_DEBUG, - "lm_set_drive_disabled: " - "Attribute sent successfully"); - free(cmd_str); - -} diff --git a/usr/src/cmd/mms/lm/common/lm_io.c b/usr/src/cmd/mms/lm/common/lm_io.c deleted file mode 100644 index 4a35fc173c..0000000000 --- a/usr/src/cmd/mms/lm/common/lm_io.c +++ /dev/null @@ -1,815 +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. - */ - - -#include "lm.h" -#include <lm_proto.h> - -static char *_SrcFile = __FILE__; - -/* - * lm_remove_lmpl_cmd - * - * Parameters: - * tid The index into the response queue for the command being - * removed. A -1 value means that only the memory of ele is - * to be freed. - * ele The structure which contains the information about the lmpl - * command being removed. - * - * Gloabals: - * None - * - * This functions cleans up the response queue which handles responses for - * lmpl commands. Once the lmpl command has received its finial response - * this functions is called to free up the memory associated with ele and - * to open the index in the response queue associated with the task id of - * the lmpl command. There is no lock around the updates, since we are - * only removing an elements memory and setting the lm_rspq.rspq_cmd[tid] - * to NULL. - * - * Return Values: - * None - */ -void -/* LINTED tid in lm_remove_lmpl_cmd (E_FUNC_ARG_UNUSED) */ -lm_remove_lmpl_cmd(int tid, lmpl_rsp_ele_t *ele) -{ - lmpl_rsp_node_t *node; - lmpl_rsp_node_t *next; - - if (ele == NULL) { - return; - } - - if (pthread_cond_destroy(&ele->lmpl_rsp_cv) != 0) { - lm_serr(MMS_CRIT, "lm_remove_lmpl_cmd: Unable to free lmpl " - "command element's condition variable"); - } - - if (pthread_mutex_destroy(&ele->lmpl_rsp_mutex) != 0) { - lm_serr(MMS_CRIT, "lm_remove_lmpl_cmd: Unable to free lmpl " - "command element's mutex"); - } - - if (ele->lmpl_acc_tree != NULL) - mms_pn_destroy(ele->lmpl_acc_tree); - - mms_list_foreach_safe(&ele->lmpl_rsp_list, node, next) { - mms_list_remove(&ele->lmpl_rsp_list, node); - - if (node->lmpl_rsp_tree != NULL) - mms_pn_destroy(node->lmpl_rsp_tree); - free(node); - } - free(ele); -} - -/* - * lm_obtain_task_id() - * - * Parameters: - * tid Next available task id for a LMPL command. - * rele Will be updated with the location of new element created for - * the lmpl command. - * - * This function obtains the necessary taskid for the cmd that is to - * be generated. It sets up a ptr to the lm_queue_ele in the lm_rspq - * based on the taskid as an index into lm_rspq.rspq_cmd array. - * - * Return Values: - * LM_OK If it was able to obtain a taskid and lock the necessary - * mutexes. - * LM_ERROR If it encountered an error while processing. All errors - * generate an internal processing error that are not - * currently recoverable from. Thus, any error encountered will - * set the global lm_internal_error indicating to LM that - * it should abort processing as quick as possible. - * - */ -int -lm_obtain_task_id(int *tid, lmpl_rsp_ele_t **rele) -{ - - lmpl_rsp_ele_t *ele; - - if ((ele = (lmpl_rsp_ele_t *)malloc(sizeof (lmpl_rsp_ele_t))) - == NULL) { - lm_serr(MMS_CRIT, "lm_obtain_task_id: Unable to malloc space " - "for a new lmpl command element, errno - %s", - strerror(errno)); - *rele = NULL; - return (LM_ERROR); - } - - if (pthread_mutex_init(&ele->lmpl_rsp_mutex, NULL) != 0) { - lm_serr(MMS_CRIT, "lm_obtain_task_id: Unable to initialize new " - "lmpl command element's mutex, errno - %s", - strerror(errno)); - free(ele); - *rele = NULL; - return (LM_ERROR); - } - - if (pthread_cond_init(&ele->lmpl_rsp_cv, NULL) != 0) { - lm_serr(MMS_CRIT, "lm_obtain_task_id: Unable to initialize new " - "lmpl command element's condition variable, " - "errno - %s", strerror(errno)); - free(ele); - *rele = NULL; - if (pthread_mutex_destroy(&ele->lmpl_rsp_mutex) != 0) { - mms_trace(MMS_CRIT, - "lm_obtain_task_id: Unable to free lmpl " - "command element's mutex, errno - %s", - strerror(errno)); - } - return (LM_ERROR); - } - - mms_list_create(&ele->lmpl_rsp_list, sizeof (lmpl_rsp_node_t), - offsetof(lmpl_rsp_node_t, lmpl_rsp_next)); - - ele->lmpl_acc_tree = NULL; - ele->lmpl_rsp_final = LMPL_WAITING; - - /* Lock the accept/unaccept mutex so that if any */ - /* any other cmd processing threads want to send */ - /* a cmd to MM they will block here until the last */ - /* thread that generated a cmd gets it's accept */ - /* unaccept response. */ - if (pthread_mutex_lock(&lm_acc_mutex) != 0) { - lm_serr(MMS_CRIT, "lm_obtain_task_id: Lock of accept/unaccept " - "mutex failed with errno - %s", strerror(errno)); - lm_remove_lmpl_cmd(-1, ele); - *rele = NULL; - return (LM_ERROR); - } - - /* Lock the response queue so that there is not */ - /* more than one thread updating information in the */ - /* queue at one time */ - - if (pthread_mutex_lock(&lm_rspq.rspq_mutex) != 0) { - lm_serr(MMS_CRIT, "lm_obtain_task_id: Lock of response queue's " - "mutex failed with errno - %s", strerror(errno)); - if (pthread_mutex_unlock(&lm_acc_mutex) != 0) - mms_trace(MMS_CRIT, "lm_obtain_task_id: Unlock of " - "accept/unaccept mutex failed with errno - " - "%s", strerror(errno)); - lm_remove_lmpl_cmd(-1, ele); - *rele = NULL; - return (LM_ERROR); - } - - /* Update the response queue task id to the next */ - /* available one */ - if (++lm_rspq.rspq_tid == SIZE_RSP_ARRAY) - lm_rspq.rspq_tid = 0; - - /* This is not an infinite loop because the */ - /* lm_remove_lmpl_cmd does not need the resp queue */ - /* mutex to free an element. Also, the number */ - /* of outstanding LMPL commands is equal to the */ - /* number of command processing threads, thus the */ - /* most outstanding is equal to the number of */ - /* processing threads and therefore there should */ - /* always be an available taskid */ - while (lm_rspq.rspq_cmd[lm_rspq.rspq_tid] != NULL) { - if (lm_rspq.rspq_tid == SIZE_RSP_ARRAY) - lm_rspq.rspq_tid = 0; - else - lm_rspq.rspq_tid++; - } - - *tid = lm_rspq.rspq_tid; - lm_rspq.rspq_cmd[lm_rspq.rspq_tid] = ele; - - *rele = ele; - - if (pthread_mutex_unlock(&lm_rspq.rspq_mutex) != 0) { - lm_serr(MMS_CRIT, "lm_obtain_task_id: Unlock of response " - "queue's mutex failed with errno - %s", - strerror(errno)); - if (pthread_mutex_unlock(&lm_acc_mutex) != 0) - mms_trace(MMS_CRIT, "lm_obtain_task_id: Unlock of " - "accept/unaccept mutex failed with errno - " - "%s", strerror(errno)); - lm_remove_lmpl_cmd(lm_rspq.rspq_tid, ele); - *rele = NULL; - return (LM_ERROR); - } - - return (LM_OK); -} - -/* - * lm_gen_lmpl_cmd - * - * Parameters: - * cmd_str The LMPL command to send to MM. - * ele The structure which contains the information about the lmpl - * command being being sent to MM. - * wait Indicates if the LMPL command should only take this many - * seconds to process. If it takes longer than this many - * seconds, LM will send a LMPL cancel command to MM to - * try to cancel the original LMPL command. - * - * Gloabals: - * None - * - * This functions sends the LMPL command to MM and waits for an accept - * response, and the final response to the command. Once the final - * response is received, it returns the lmpl response in ele. - * - * Return Values: - * MMS_OK If command was sent successfully and a valid response - * was received. - * MMS_ERROR If an error was encountered while sending the command - * or receiving the response. - */ -int -lm_gen_lmpl_cmd(char *cmd_str, lmpl_rsp_ele_t *ele, int wait) -{ - int rc; - int len; - int taskid; - - timespec_t tv; - timespec_t *tvp; - mms_par_node_t *acc; - - taskid = lm_rspq.rspq_tid; - len = strlen(cmd_str); - - /* Lock mutex to protect that only one thread is */ - /* sending information over the socket to MM at */ - /* one time */ - if ((rc = pthread_mutex_lock(&lm_write_mutex)) != 0) { - lm_serr(MMS_CRIT, - "lm_gen_lmpl_cmd: Lock on write mutex failed, " - "errno - %s", strerror(errno)); - return (LM_ERROR); - } - /* Write out cmd to MM */ - mms_trace(MMS_DEVP, - "send to MM: \n%s", - cmd_str); - if ((rc = mms_writer(&lm.lm_mms_conn, cmd_str)) != len) { - lm_serr(MMS_CRIT, "lm_gen_lmpl_cmd: mms_writer failed, " - "errno - %s", strerror(errno)); - (void) pthread_mutex_unlock(&lm_write_mutex); - return (LM_ERROR); - } - /* Unlock write mutex */ - if ((rc = pthread_mutex_unlock(&lm_write_mutex)) != 0) { - lm_serr(MMS_CRIT, "lm_gen_lmpl_cmd: Unlock write mutex failed, " - "errno - %s", strerror(errno)); - return (LM_ERROR); - } - - /* Go to sleep until accept or unaccept is returned */ - if ((rc = pthread_mutex_lock(&ele->lmpl_rsp_mutex)) != 0) { - lm_serr(MMS_CRIT, "lm_gen_lmpl_cmd: Unable to lock element " - "mutex, errno - %s", strerror(errno)); - return (LM_ERROR); - } - - while (ele->lmpl_acc_tree == NULL) { - timespec_t tv; - timespec_t *tvp; - - mms_trace_flush(); /* flush mms_trace buffer */ - tv.tv_sec = time(NULL) + LM_THREAD_WAIT; - tv.tv_nsec = 0; - tvp = &tv; - - rc = pthread_cond_timedwait(&ele->lmpl_rsp_cv, - &ele->lmpl_rsp_mutex, tvp); - if (rc == ETIMEDOUT) { - if (!lm_internal_error) - continue; - else { - mms_trace(MMS_ERR, "lm_gen_lmpl_cmd: While " - "waiting on an accept response, LM " - "encountered an internal processing error"); - (void) pthread_mutex_unlock(&ele-> - lmpl_rsp_mutex); - return (LM_ERROR); - } - } else if (rc != 0) { - lm_serr(MMS_CRIT, "lm_gen_lmpl_cmd: Unable to wait on " - "element cond var, errno - %s", - strerror(errno)); - (void) pthread_mutex_unlock(&ele->lmpl_rsp_mutex); - return (LM_ERROR); - } - mms_trace(MMS_DEBUG, - "lm_gen_lmpl_cmd: Went to sleep waiting for " - "accept"); - } - - mms_trace(MMS_DEBUG, "lm_gen_lmpl_cmd: Handling accept response"); - - if ((acc = ele->lmpl_acc_tree) == NULL) { - lm_serr(MMS_ERR, "lm_gen_lmpl_cmd: Woken up while waiting on " - "an accept response, but accept response is still set " - "to NULL"); - (void) pthread_mutex_unlock(&ele->lmpl_rsp_mutex); - return (LM_ERROR); - } - - if (mms_pn_lookup(acc, "unacceptable", MMS_PN_KEYWORD, - NULL) != NULL) { - mms_trace(MMS_ERR, "lm_gen_lmpl_cmd: Received an unacceptable " - "response for LMPL command:\n%s", cmd_str); - (void) pthread_mutex_unlock(&ele->lmpl_rsp_mutex); - (void) pthread_mutex_unlock(&lm_acc_mutex); - ele->lmpl_rsp_final = LMPL_UNACCEPTABLE; - return (LMPL_UNACCEPTABLE); - } - - mms_trace(MMS_DEBUG, "Free up accept mutex"); - if ((rc = pthread_mutex_unlock(&lm_acc_mutex)) != 0) { - lm_serr(MMS_CRIT, "lm_gen_lmpl_cmd: Unable to unlock acc/unacc " - "mutex, errno - %s", strerror(errno)); - (void) pthread_mutex_unlock(&ele->lmpl_rsp_mutex); - return (LM_ERROR); - } - - while (ele->lmpl_rsp_final == LMPL_WAITING) { - mms_trace(MMS_DEBUG, - "lm_gen_lmpl_cmd: Going to sleep waiting for " - "final response"); - /* If the LMPL command that is being sent does not */ - /* complete in the alotted time, then LM will */ - /* send a LMPL cancel command to MM to cancel the */ - /* original LMPL command */ - if (wait) { - tv.tv_sec = time(NULL) + wait; - tv.tv_nsec = 0; - tvp = &tv; - if ((rc = pthread_cond_timedwait(&ele->lmpl_rsp_cv, - &ele->lmpl_rsp_mutex, tvp)) == ETIMEDOUT) { - mms_trace(MMS_DEBUG, - "lm_gen_lmpl_cmd: 2 Timeout " - "hit, send LMPL cancel command for command" - ":\n%s", cmd_str); - lm_send_cancel(taskid); - wait = 0; - continue; - } else if (rc != 0) { - lm_serr(MMS_CRIT, - "lm_gen_lmpl_cmd: 2 Unable to " - "wait on element cond var, errno - %s", - strerror(errno)); - (void) pthread_mutex_unlock(&ele-> - lmpl_rsp_mutex); - return (LM_ERROR); - } - } else { - tv.tv_sec = time(NULL) + LM_THREAD_WAIT; - tv.tv_nsec = 0; - tvp = &tv; - if ((rc = pthread_cond_timedwait(&ele->lmpl_rsp_cv, - &ele->lmpl_rsp_mutex, tvp)) == ETIMEDOUT) { - if (!lm_internal_error) - continue; - mms_trace(MMS_ERR, - "lm_gen_lmpl_cmd: 2 Detected " - "an internal processing error"); - (void) pthread_mutex_unlock(&ele-> - lmpl_rsp_mutex); - return (LM_ERROR); - } else if (rc != 0) { - lm_serr(MMS_CRIT, - "lm_gen_lmpl_cmd: 2 Unable to " - "wait on element cond var, errno - %s", - strerror(errno)); - (void) pthread_mutex_unlock(&ele-> - lmpl_rsp_mutex); - return (LM_ERROR); - } - } - mms_trace(MMS_DEBUG, - "lm_gen_lmpl_cmd: Woke up while waiting for " - "final reponse"); - } - - (void) pthread_mutex_unlock(&ele->lmpl_rsp_mutex); - - mms_trace(MMS_DEVP, "lm_gen_lmpl_cmd: return to command routine"); - - return (ele->lmpl_rsp_final); -} - -/* - * - * lm_handle_event() - * - * Parameters: - * - cmd Ptr to parse tree of event command. - * - * This function will do any preprocessing of an event notification - * command. It currently only checks to see if the state of the LM is - * valid to process an event. - * NOTE: Currently LM does not register for any events. - * - * Return Values: - * LM_OK If it was able to process the event correctly - * LM_ERROR If routine encountered an internal error while - * processing event - * - */ -int -lm_handle_event(mms_par_node_t *cmd) -{ - char *tid = NULL; - - /* If LM is not active ignore event commands */ - if (!(lm_state & LM_MASK2)) { - mms_trace(MMS_OPER, - "lm_handle_event: LM is not in a valid state " - "to process event command, state - 0x%x", lm_state); - mms_pn_destroy(cmd); - return (LM_OK); - } - - if (lm_queue_add(&lm_cmdq, (void *)cmd, &tid, LM_C_EVENT) != 0) { - lm_serr(MMS_ERR, "lm_handle_event: adding %s command " - "to work queue failed", mms_pn_token(cmd)); - mms_pn_destroy(cmd); - return (LM_ERROR); - } - return (LM_OK); -} - -/* - * - * lm_handle_response() - * - * Parameters: - * - cmd Ptr to parse tree of response cmd. - * - * This function will indicate to the correct thread waiting for a response - * from the MM that it has received it and wake it up. It is the cmd - * processing thread that will interrept the response based on its expectations - * This function's job is only to save the parsed cmd in the queue's element - * location and wake the cmd thread up. - * - * Return Values: - * LM_OK If it was able to process the response correctly - * LM_ERROR If routine encountered an internal error while - * processing response - * - */ - -int -lm_handle_response(mms_par_node_t *cmd) -{ - int found = LMPL_FINAL_INVALID; - int task_id; - - lmpl_rsp_ele_t *ele; - lmpl_rsp_node_t *node; - - mms_par_node_t *clause; - mms_par_node_t *tid; - - if (pthread_mutex_lock(&lm_rspq.rspq_mutex) != 0) { - lm_serr(MMS_CRIT, "lm_handle_response: unable to lock " - "response queue mutex, errno - %s", - strerror(errno)); - return (LM_ERROR); - } - - if (mms_pn_lookup(cmd, "accepted", MMS_PN_KEYWORD, NULL) - != NULL) { - mms_trace(MMS_DEBUG, - "lm_handle_response: handle accept response " - "for tid - %d", lm_rspq.rspq_tid); - found = LMPL_ACCEPT; - - } else if (mms_pn_lookup(cmd, "unacceptable", MMS_PN_KEYWORD, - NULL) != NULL) { - mms_trace(MMS_DEBUG, - "lm_handle_response: handle unaccept response " - "for tid - %d", lm_rspq.rspq_tid); - found = LMPL_UNACCEPTABLE; - - } else if (mms_pn_lookup(cmd, "success", MMS_PN_KEYWORD, - NULL) != NULL) { - mms_trace(MMS_DEBUG, "lm_handle_response: Found a success " - "response"); - found = LMPL_FINAL_OK; - - } else if (mms_pn_lookup(cmd, "intermediate", MMS_PN_KEYWORD, - NULL) != NULL) { - mms_trace(MMS_DEBUG, "lm_handle_response: Found a intermediate " - "response"); - found = LMPL_FINAL_INTER; - - } else if (mms_pn_lookup(cmd, "error", MMS_PN_CLAUSE, - NULL) != NULL) { - mms_trace(MMS_DEBUG, "lm_handle_response: Found a error " - "response"); - found = LMPL_FINAL_ERROR; - - } else if (mms_pn_lookup(cmd, "cancelled", MMS_PN_KEYWORD, - NULL) != NULL) { - mms_trace(MMS_DEBUG, "lm_handle_response: Found a cancelled " - "response"); - found = LMPL_FINAL_CANCEL; - - } else { - lm_serr(MMS_CRIT, "lm_handle_response: Did not find " - "accept, unacceptable, success, error, or cancelled in " - "response:\n%s", mms_pn_build_cmd_text(cmd)); - (void) pthread_mutex_unlock(&lm_rspq.rspq_mutex); - return (LM_ERROR); - } - - if (found == LMPL_ACCEPT || found == LMPL_UNACCEPTABLE) { - ele = lm_rspq.rspq_cmd[lm_rspq.rspq_tid]; - task_id = lm_rspq.rspq_tid; - if (ele == NULL) { - lm_serr(MMS_CRIT, "lm_handle_response: Trying to " - "handle a accept/unaccept response for tid - %d, " - "but element is null", lm_rspq.rspq_tid); - (void) pthread_mutex_unlock(&lm_rspq.rspq_mutex); - return (LM_ERROR); - } - ele->lmpl_acc_tree = cmd; - } else { - if ((clause = mms_pn_lookup(cmd, "task", MMS_PN_CLAUSE, - NULL)) == NULL) { - lm_serr(MMS_CRIT, "lm_handle_response: Did not find " - "task clause in response:\n%s", - mms_pn_build_cmd_text(cmd)); - (void) pthread_mutex_unlock(&lm_rspq.rspq_mutex); - return (LM_ERROR); - } - - if ((tid = mms_pn_lookup(clause, NULL, MMS_PN_STRING, NULL)) - == NULL) { - lm_serr(MMS_CRIT, "lm_handle_response: Did not find " - "task value in response:\n%s", - mms_pn_build_cmd_text(cmd)); - (void) pthread_mutex_unlock(&lm_rspq.rspq_mutex); - return (LM_ERROR); - } - mms_trace(MMS_DEVP, "lm_handle_response: Response task id " - "- %s", mms_pn_token(tid)); - - task_id = atoi(mms_pn_token(tid)); - mms_trace(MMS_DEBUG, "lm_handle_response: Response task id " - "- %d", task_id); - - if (task_id < 0 || task_id > SIZE_RSP_ARRAY) { - lm_serr(MMS_CRIT, "lm_handle_response: Task id %d in " - "response is not in the range of possible " - "LMPL task ids, range: %d - %d", task_id, 0, - SIZE_RSP_ARRAY); - (void) pthread_mutex_unlock(&lm_rspq.rspq_mutex); - return (LM_ERROR); - } - - ele = lm_rspq.rspq_cmd[task_id]; - if (ele == NULL) { - lm_serr(MMS_CRIT, "lm_handle_response: Trying to " - "handle a response for tid - %d, but response " - "element is NULL", task_id); - (void) pthread_mutex_unlock(&lm_rspq.rspq_mutex); - return (LM_ERROR); - } - if ((node = (lmpl_rsp_node_t *)malloc(sizeof (lmpl_rsp_node_t))) - == NULL) { - lm_serr(MMS_CRIT, "lm_obtain_task_id: Unable to malloc " - "space for a new lmpl node element, errno - %s", - strerror(errno)); - return (LM_ERROR); - } - node->lmpl_rsp_tree = cmd; - node->lmpl_rsp_type = found; - - mms_list_insert_tail(&ele->lmpl_rsp_list, node); - - if (found == LMPL_FINAL_INTER) { - mms_trace(MMS_DEBUG, "lm_handle_response: Recevied a " - "intermediate response for task id - %d", task_id); - return (LM_OK); - } - ele->lmpl_rsp_final = found; - - /* clear entry in response array so that another */ - /* LMPL command can use it */ - lm_rspq.rspq_cmd[task_id] = NULL; - } - - if (pthread_cond_signal(&ele->lmpl_rsp_cv) != 0) { - lm_serr(MMS_CRIT, "lm_handle_response: Cond_signal failed " - "trying to signal thread waiting on wakeup call, " - "errno - %s", strerror(errno)); - (void) pthread_mutex_unlock(&ele->lmpl_rsp_mutex); - return (LM_ERROR); - } - mms_trace(MMS_DEBUG, "lm_handle_response: Signaled thread waiting on " - "condition mutex - %d", task_id); - - if (pthread_mutex_unlock(&lm_rspq.rspq_mutex) != 0) { - lm_serr(MMS_CRIT, "lm_handle_response: Failure trying to " - "unlock lm_rspq.rspq_mutex mutex, errno - %s", - strerror(errno)); - return (LM_ERROR); - } - - return (LM_OK); -} - -/* - * lm_handle_parser_error() - * - * Parameters: - * - cmd Parse tree of input generated by mms_lmpm_parse - * - err_list List of errors found by mms_lmpm_parse - * - * Globals: - * - * This function handle the case where mms_lmpm_parse detected a error. This - * routine tries to look at the errors that were detected and decide - * what should be done. - * - * NOTE: The input could be one of the following. This routine tries to - * look at the output from the parser and handle each case: - * - A new LMPM cmd sent to LM by MM. - * - A final response to a LMPL cmd that LM sent to MM. - * - A accept/unaccept response to a LMPL cmd that LM sent to MM. - * - * Return Values: - * MMS_OK: If error was a syntax error on a new command from MM. We send - * a unaccept response back to MM in this case. - * NOMEM: Have the parser retry parsing the cmd since memory may be freed - * since the first try. - * MMS_ERROR: This routine encountered an error that should not of occured - * and it could not recover. - * - */ - -int -lm_handle_parser_error(mms_par_node_t *cmd, mms_list_t *err_list) -{ - char rsp_str[256]; /* Contains negative resp BNF string */ - /* msg part of rsp_str */ - char msg_str[256]; - - mms_par_err_t *err; /* Used to step through error list */ - mms_par_node_t *root; /* Ptr to cmd node of parse tree */ - - /* Determine type of errors detected */ - mms_list_foreach(err_list, err) { - mms_trace(MMS_ERR, "lm_handle_parser_error: lmp_parse error, \ - line %d, col %d, near token %s, err code %d, %s", - err->pe_line, - err->pe_col, - err->pe_token, - err->pe_code, - err->pe_msg); - - switch (err->pe_code) { - case MMS_PE_NOMEM: - mms_trace(MMS_ERR, "lm_handle_parser_error: " - "Parser error indicates that no memory " - "is available to create parse tree, try " - "parsing again"); - return (LM_NOMEM); - case MMS_PE_SYNTAX: - break; - case MMS_PE_MAX_LEVEL: - lm_serr(MMS_CRIT, "lm_handle_parser_error: " - "Parser error indicates that the max level " - "was reached"); - return (LM_ERROR); - default: - /* Only above three possible error */ - /* conditions exist, thus if this */ - /* condition is ever hit, things */ - /* are really messed up, system error */ - lm_serr(MMS_CRIT, "lm_handle_parser_error: " - "Encountered a unknown parser error - %d", - err->pe_code); - return (LM_ERROR); - } - } - - root = mms_pn_lookup(cmd, NULL, MMS_PN_CMD, NULL); - if (root == NULL) { - /* Unable to tell what the input was at all, in this */ - /* case we generate a system error and will exit */ - lm_serr(MMS_CRIT, "lm_handle_parser_error: Parser error is a " - "syntax error, but unable to determine if error is on a " - "new LMPM command or a LMPL response"); - return (LM_SYNTAX_ERR); - } - - if (strcmp("response", mms_pn_token(root)) == 0) { - lm_serr(MMS_CRIT, "lm_handle_parser_error: Parser syntax error " - "on LMPL response from MM"); - return (LM_SYNTAX_RSP); - } - - /* ASSUME THAT THE MM SENT US A CMD. NEED TO SEND AN UNACCEPT, SINCE */ - /* WE ARE USING LMPM_PARSE, WE KNOW IT IS A LMPM COMMAND, JUST NOT */ - /* VALID LMPM COMMAND */ - - lm_serr(MMS_CRIT, "lm_handle_parser_error: Parser syntax error " - "on LMPM %s command from MM", mms_pn_token(root)); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7005_MSG, "cmd", mms_pn_token(root), NULL); - (void) snprintf(rsp_str, sizeof (rsp_str), - LM_UNACC_RESP, msg_str); - if (lm_write_msg(rsp_str, &lm.lm_mms_conn, lm_write_mutex)) { - lm_serr(MMS_CRIT, - "lm_handle_parser_error: Sending unacceptable " - "response on invalid LMPM command failed"); - } - return (LM_SYNTAX_CMD); -} - -/* - * - * lm_write_msg() - * - * Parameters: - * - msg The message that is to be sent to the MM. It is in BNF - * form defined in the IEEE spec for MMS. - * - conn The connection structure - * - mutex The mutex which allows only one thread of the LM to - * write to the MM at a time. - * - * This function sends a message from the LM to the MM over the socket that - * connects the LM and MM. Locks the mutex around output, and sends the message. - * This routine is not to be used to send a LMPL command to MM. Use - * lm_gen_lmpl_cmd() to do this. This routine is used to send messages where - * no response is expected. - * - * Return Values: - * - MMS_OK If the message was sent without errors. - * - MMS_ERROR If a error occurred while sending the message. - * - * NOTE: The calling routine should call lm_serr if LM_ERROR is returned. - * This routine only sends a mms_trace message indicating the write error. - * - */ - -int -lm_write_msg(char *msg, mms_t *conn, pthread_mutex_t mutex) -{ - - int len; /* length of xmlcmd string */ - int rc; /* return code */ - - len = strlen(msg); - - if ((rc = pthread_mutex_lock(&mutex)) != 0) { - lm_serr(MMS_CRIT, "lm_write_msg: Unable to lock mutex for " - "writing command to MM, errno - %s", strerror(errno)); - return (LM_ERROR); - } - - if ((rc = mms_writer(conn, msg)) != len) { - mms_trace(MMS_CRIT, "lm_write_msg: mms_writer failed to write " - "to MM, error - %d", rc); - mms_trace(MMS_CRIT, "lm_write_msg: Command/Response:\n%s", msg); - (void) pthread_mutex_unlock(&mutex); - return (LM_ERROR); - } - - if ((rc = pthread_mutex_unlock(&mutex)) != 0) { - lm_serr(MMS_CRIT, "lm_write_msg: Unable to unlock mutex " - "for writing to MM, errno - %s", strerror(errno)); - return (LM_ERROR); - } - - return (LM_OK); -} diff --git a/usr/src/cmd/mms/lm/common/lm_lib.c b/usr/src/cmd/mms/lm/common/lm_lib.c deleted file mode 100644 index da62e75580..0000000000 --- a/usr/src/cmd/mms/lm/common/lm_lib.c +++ /dev/null @@ -1,419 +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. - */ - - -#include <dlfcn.h> -#include <alloca.h> -#include "lm.h" -#include <lm_proto.h> -#include "mms_strapp.h" - -static char *_SrcFile = __FILE__; - -/* - * lm_need_libapi - * - type: Type of library that LM is controlling - * The function will return 1 if the library type requires - * LM to set LD_LIBRARY_PATH to include the path stored in SMF - * (libapi_path) - * If libapi is not needed for this library type return 0 - * - */ -int -lm_need_libapi(char *type) { - - /* need libapi for all acsls supported libraries */ - /* L180 L500 L700 SL500 */ - if (strcmp(type, "L180") == 0) { - return (1); - } - if (strcmp(type, "L500") == 0) { - return (1); - } - if (strcmp(type, "L700") == 0) { - return (1); - } - if (strcmp(type, "SL500") == 0) { - return (1); - } - if (strcmp(type, "SL3000") == 0) { - return (1); - } - if (strcmp(type, "SL8500") == 0) { - return (1); - } - return (0); -} - - - - -/* - * lm_load_cmds() - * - * Parameters: - * - libName: Type of library that LM is controlling. Ex: L700 - * - connection: The type of connection, network or direct - * - cmdData: An array of strutures which contains the name of - * the LM commands and a pointer location which will - * contain the entry mms_address to the command processing - * functions which support the library type. - * - * Globals: - * None - * - * This functions dynamically opens a shared library that contains the - * set of LM command processing functions that support the type of library - * the LM is configured to control. Once opened, it searches for the - * entry points to each of the LM commands and stores those in the cmdData - * array. - * - * Return Values: - * NULL: If an error was encountered. - * handle: The handle to the open shared library. - * - */ - -lm_cmdHandle_t -lm_load_cmds(char *libName, int connection, lm_cmdData_t *cmdData) -{ - lm_cmdHandle_t handle; - lm_cmdData_t *cd; - char *cmdPathname; - void *symAddr; - char symName[64]; - - char *libapi_path = NULL; - - mms_trace(MMS_DEVP, - "lm_load_cmds : " - "libName == %s", libName); - - if (lm_need_libapi(libName)) { - mms_trace(MMS_DEBUG, - "lm_load_cmds :" - "libapi needed"); - /* get libapi_path from SMF */ - if ((libapi_path = - mms_cfg_alloc_getvar(MMS_CFG_LIBAPI_PATH, NULL)) - == NULL) { - /* report service configuration */ - /* repoistory scf_error() */ - mms_trace(MMS_ERR, - "using default-path, libapi path cfg error"); - libapi_path = strdup("/opt/mms/lib/acsls"); - } - mms_trace(MMS_DEBUG, - "lm_load_cmds :" - "path to libapi.so == %s", - libapi_path); - - libapi_path = mms_strapp(libapi_path, "/libapi.so"); - - if (dlopen(libapi_path, RTLD_NOW | RTLD_GLOBAL) == NULL) { - mms_trace(MMS_CRIT, - "lm_load_cmds: dlopen " - "failed for libapi.so, dlerror - %s", - dlerror()); - free(libapi_path); - return (NULL); - } - free(libapi_path); - mms_trace(MMS_DEBUG, - "lm_load_cmds : " - "libapi.so loaded successfully"); - } else { - mms_trace(MMS_DEBUG, - "lm_load_cmds : " - "%s does not need libapi", libName); - } - - - - - cmdPathname = (char *)alloca(strlen(libName) + - strlen(CMDPATH_DIRECTORY) + 4); - (void) strcpy(cmdPathname, CMDPATH_DIRECTORY); - (void) strcat(cmdPathname, libName); - if (connection == LM_DIRECT_ATTACHED) - (void) strcat(cmdPathname, "_direct"); - else if (connection == LM_NETWORK_ATTACHED) - (void) strcat(cmdPathname, "_net"); - (void) strcat(cmdPathname, ".so"); - mms_trace(MMS_DEBUG, "lm_load_cmds: libname - %s", cmdPathname); - if ((handle = dlopen(cmdPathname, RTLD_NOW)) == NULL) { - mms_trace(MMS_CRIT, "lm_load_cmds: dlopen failed, dlerror - %s", - dlerror()); - return (NULL); - } - - for (cd = cmdData; cd->cd_symName != NULL; cd++) { - (void) strcpy(&symName[0], cd->cd_symName); - symAddr = dlsym(handle, symName); - if (symAddr != NULL) { - cd->cd_cmdptr = (int (*)())symAddr; - } else { - mms_trace(MMS_CRIT, - "lm_load_cmds: Cmds lib %s does not " - "contain cmd %s", libName, symName); - lm_unload_cmds(handle); - return (NULL); - } - } - return (handle); -} - -/* - * lm_unload_cmds() - * - * Parameters: - * - cmdHandle The handle that was returned from the dlopen in - * lm_load_cmds(). - * - * Globals: - * None - * - * This functions closes the shared library that was dynamically opened - * in the lm_load_cmds() routine. - * - * Return Values: - * None - * - */ - -void -lm_unload_cmds(lm_cmdHandle_t cmdHandle) -{ - (void) dlclose(cmdHandle); -} - -/* - * lm_serr() - * - * Parameters: - * - severity The severity of the internal error encountered - * - file The name of the file in which the error occurred - * - line The line number in the file where the error occurred - * - fmt The format of the message to be mms_printed. - * - ... The variable number of arguments for the message. - * - * Globals: - * lm_internal_error Set to indicate an internal error occured - * exit_code Set so exit indicates LM can be restarted - * - * This function is used within LM to handle internal processing errors. - * The function will handle what needs to be done when an internal - * processing error occurs and then will output the message to the mms_trace - * file. - * - * Return Values: - * None - * - */ -void -lm_serr(mms_trace_sev_t severity, char *file, int line, char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - - mms_trace_va(severity, file, line, fmt, args); - - va_end(args); - - exit_code = LM_RESTART; - lm_internal_error = LM_ERROR; -} - -/* - * lm_log() - * - * Parameters: - * - priority The syslog priority of the error - * - fmt The format of the log message to be mms_printed - * - ... The variable number of arguments for the message. - * - * Globals: - * lm_daemon_mode Uses this to know if it should print message to - * syslog or stderr. - * - * This function is used to print messages that should go to syslog - * if LM is in daemon mode or to stderr if it is running in standalone mode. - * - * Return Values: - * None - * - */ -void -lm_log(int priority, char *fmt, ...) -{ - int count; - char tmp[10]; - char *ptr; - va_list args; - - if (lm_daemon_mode) - openlog("MMS_LM", LOG_PID | LOG_NOWAIT, LOG_LOCAL7); - - va_start(args, fmt); - - /* LINTED [E_SEC_PRINTF_VAR_FMT] */ - if ((count = vsnprintf(tmp, 10, fmt, args)) == -1) { - va_end(args); - return; - } - - if ((ptr = (char *)malloc(count + 1)) == NULL) { - va_end(args); - return; - } - - /* LINTED [E_SEC_PRINTF_VAR_FMT] */ - if (vsprintf(ptr, fmt, args) < 0) { - va_end(args); - free(ptr); - return; - } - - va_end(args); - - if (lm_daemon_mode) { - /* LINTED [E_SEC_PRINTF_VAR_FMT] */ - syslog(priority, ptr); - closelog(); - } else - /* LINTED [E_SEC_PRINTF_VAR_FMT] */ - (void) fprintf(stderr, ptr); - - - free(ptr); -} - -void -handle_lmpl_cmd_error(int rc, char *cmd, char *lmpl, char *tid, char *msg) -{ - - char msg_str[1024]; - - if (rc == LMPL_UNACCEPTABLE) - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7030_MSG, "cmd", cmd, "lmpl", lmpl, - "rsp", "unacceptable", NULL); - else if (rc == LMPL_FINAL_ERROR) - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7030_MSG, "cmd", cmd, "lmpl", lmpl, - "rsp", "final error", NULL); - else if (rc == LMPL_FINAL_CANCEL) - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7030_MSG, "cmd", cmd, "lmpl", lmpl, - "rsp", "final cancel", NULL); - else - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7030_MSG, "cmd", cmd, "lmpl", lmpl, - "rsp", "invalid final", NULL); - - mms_trace(MMS_ERR, "handle_lmpl_cmd_error: %s", msg_str); - - (void) snprintf(msg, RMBUFSIZE, LM_ERR_FINAL, - tid, mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_SUBCMDFAILED), msg_str); -} - -void -lm_connect_failure(mms_t *conn) -{ - - char ebuf[MMS_EBUF_LEN]; - - mms_get_error_string(&conn->mms_err, ebuf, MMS_EBUF_LEN); - switch (conn->mms_err.mms_id) { - case MMS_ERR_SERVICE_NOT_FOUND: - lm_serr(MMS_CRIT, "connect_failure: mm is not " - "running, - %s", ebuf); - break; - default: - lm_serr(MMS_CRIT, "connect_failure: mm connect " - "failure, - %s", ebuf); - break; - } -} - -/* - * lm_send_cancel - * - * Parameters: - * taskid The task id of the LMPL command to be cancelled. - * - * This function is used by the LM to be able to cancel a LMPL command - * that it has sent to MM but the timeout for how long to wait for - * a response has expired. - * - * Currently, when lm_gen_lmpl_cmd() sends a LMPL command as part of - * processing a LMPM command, the routine processing the LMPM command - * can specifiy a timeout for how long it will wait for a response to - * the LMPL command. If the timeout is hit, the LM will then send a - * cancel command for the LMPL command. This is done by adding an - * internal cancel command to the work queue, which will cause this - * routine to be invoked by the lm_cmd_handler(). - * - * Note: No commands currently send a LMPL command with a timeout, thus - * nothing within LM currently will generate the lm_send_cancel. - * - * Return Values: - * None Since the command just adds an internal cancel command - * to the LM's work queue, no response is required. If - * lm_queue_add() fails, it will cause LM to eventually - * exit. - */ -void -lm_send_cancel(int taskid) -{ - char input[1024]; - char *tid; - - mms_par_node_t *cmd; - mms_list_t err_list; - - mms_trace(MMS_DEVP, "Entering lm_send_cancel for LMPL cmd taskid - %d", - taskid); - - (void) sprintf(input, LM_SEND_CANCEL, taskid); - - if (mms_lmpm_parse(&cmd, &err_list, input)) { - mms_trace(MMS_ERR, "lmpm parser failure, unable to send cancel " - "of LMPL command with task id of %d", taskid); - mms_pe_destroy(&err_list); - return; - } - mms_pe_destroy(&err_list); - - /* No real LMPM command, just a place holder */ - tid = NULL; - - if (lm_queue_add(&lm_cmdq, (void *)cmd, &tid, LM_C_INTERNAL) != 0) { - mms_trace(MMS_CRIT, "lm_send_cancel: adding internal cancel " - "command to work queue failed"); - return; - } -} diff --git a/usr/src/cmd/mms/lm/common/lm_proto.h b/usr/src/cmd/mms/lm/common/lm_proto.h deleted file mode 100644 index b5170b2375..0000000000 --- a/usr/src/cmd/mms/lm/common/lm_proto.h +++ /dev/null @@ -1,66 +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 __LM_PROTO_H -#define __LM_PROTO_H - - -#ifdef __cplusplus -extern "C" { -#endif - -int lm_queue_init(lm_queue_t *, int, void (*)()); -int lm_queue_add(lm_queue_t *, void *, char **, int); -void lm_queue_clean(); - -void lm_remove_lmpl_cmd(int, lmpl_rsp_ele_t *); -int lm_obtain_task_id(int *, lmpl_rsp_ele_t **); -int lm_gen_lmpl_cmd(char *, lmpl_rsp_ele_t *, int); -int lm_handle_event(mms_par_node_t *); -int lm_handle_response(mms_par_node_t *); -int lm_handle_parser_error(mms_par_node_t *, mms_list_t *); -int lm_write_msg(char *, mms_t *, pthread_mutex_t); -void lm_connect_failure(mms_t *); - -int lm_common_ready(int, char *, char *); -int lm_common_activate(mms_par_node_t *, char *, char *); -int lm_common_private(mms_par_node_t *, char *, char *); -int lm_common_event(mms_par_node_t *, char *, char *); -int lm_common_internal(mms_par_node_t *, char *, char *); -int lm_common_exit(mms_par_node_t *, char *, char *); -int lm_common_reset(mms_par_node_t *, char *, char *); -extern void lm_message(char *, char *, char *); - -lm_cmdHandle_t lm_load_cmds(char *, int, lm_cmdData_t *); -void lm_unload_cmds(lm_cmdHandle_t); -void lm_serr(mms_trace_sev_t, char *, int, char *, ...); -void lm_log(int, char *, ...); -void handle_lmpl_cmd_error(int, char *, char *, char *, char *); -void lm_send_cancel(int); - -#ifdef __cplusplus -} -#endif - -#endif /* __LM_PROTO_H */ diff --git a/usr/src/cmd/mms/lm/common/lm_queue.c b/usr/src/cmd/mms/lm/common/lm_queue.c deleted file mode 100644 index d231ae5378..0000000000 --- a/usr/src/cmd/mms/lm/common/lm_queue.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 <pthread.h> -#include <time.h> -#include "lm.h" -#include <lm_proto.h> - -static void *lm_q_worker(void *arg); - -static char *_SrcFile = __FILE__; - -/* - * - * lm_queue_init() - * - * Parameters: - * - cq Ptr to main work queue structure used for processing - * the LMPM commands. - * - threads: The number of worker threads that can be started - * - worker: The routine that is to be used to process items - * on the work queue. In LM that is lm_cmd_handler - * - * Globals: - * None - * - * Initialize a work queue objects that are going to be used by LM to process - * commands sent to it by the MM. - * - * Return Values: - * LM_OK: If function compelete cleanly - * LM_ERROR: If an error was encountered during the queue init. - * - */ - -int -lm_queue_init(lm_queue_t *cq, int threads, void (*worker)(void *arg)) -{ - - if (pthread_attr_init(&cq->lmq_attr) != 0) { - lm_serr(MMS_CRIT, "lm_queue_init: attr_init failed, errno - " - "%s", strerror(errno)); - return (LM_ERROR); - } - if (pthread_attr_setdetachstate(&cq->lmq_attr, - PTHREAD_CREATE_DETACHED) != 0) { - lm_serr(MMS_CRIT, "lm_queue_init: setdetachstate failed, " - "errno - %s", strerror(errno)); - (void) pthread_attr_destroy(&cq->lmq_attr); - return (LM_ERROR); - } - - if (pthread_mutex_init(&cq->lmq_mutex, NULL) != 0) { - lm_serr(MMS_CRIT, "lm_queue_init: mutex_init failed, errno - " - "%s", strerror(errno)); - (void) pthread_attr_destroy(&cq->lmq_attr); - return (LM_ERROR); - } - - if (pthread_cond_init(&cq->lmq_cv, NULL) != 0) { - lm_serr(MMS_CRIT, "lm_queue_init: cond_init failed, errno - " - "%s", strerror(errno)); - (void) pthread_mutex_destroy(&cq->lmq_mutex); - (void) pthread_attr_destroy(&cq->lmq_attr); - return (LM_ERROR); - } - - cq->lmq_quit = 0; - cq->lmq_first = cq->lmq_last = NULL; - cq->lmq_parallel = threads; - cq->lmq_counter = cq->lmq_idle = 0; - cq->lmq_worker = worker; - return (LM_OK); -} - -/* - * - * lm_queue_clean() - * - * Parameters: - * - * Globals: - * - * This function will go through the work queue and delete all commands - * that are pending. It will send a error final response for the commands - * with an error code of abort. This function is used when LM is told to - * disable, reset, or exit. - * - * Return Values: - * - */ -void -lm_queue_clean() -{ - char msg_str[256]; - char rsp_str[512]; - - lm_queue_ele_t *ce; - lm_queue_t *cq = &lm_cmdq; - - mms_trace(MMS_DEVP, "Entering lm_queue_clean"); - - if (pthread_mutex_lock(&cq->lmq_mutex) != 0) { - lm_serr(MMS_CRIT, "lm_queue_clean: mutex_lock failed, errno - " - "%s", strerror(errno)); - return; - } - - while (cq->lmq_first != NULL) { - ce = cq->lmq_first; - cq->lmq_first = ce->lmqe_next; - if (cq->lmq_last == ce) - cq->lmq_last = NULL; - /* Events and internal commands do not get final */ - /* response sent to MM, just skip and ignore */ - if (ce->lmqe_cindex == LM_C_EVENT || - ce->lmqe_cindex == LM_C_INTERNAL) { - mms_trace(MMS_DEBUG, - "lm_queue_clean: %s command does not " - "need to be aborted", - lm_cmdData[ce->lmqe_cindex].cmd); - mms_pn_destroy(ce->lmqe_cmd_tree); - free(ce); - continue; - } - mms_trace(MMS_DEBUG, "lm_queue_clean: Aborting %s command", - lm_cmdData[ce->lmqe_cindex].cmd); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7027_MSG, "cmd", lm_cmdData[ce->lmqe_cindex].cmd, NULL); - (void) snprintf(rsp_str, sizeof (rsp_str), - LM_ERR_FINAL, ce->lmqe_tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_DEVCMDABORT), msg_str); - mms_trace(MMS_OPER, - "lm_queue_clean: %s command was aborted, final " - "response:\n%s", lm_cmdData[ce->lmqe_cindex].cmd, rsp_str); - if (lm_write_msg(rsp_str, &lm.lm_mms_conn, lm_write_mutex)) { - lm_serr(MMS_CRIT, "lm_queue_clean: Sending final " - "response for %s command failed", - lm_cmdData[ce->lmqe_cindex].cmd); - return; - } - mms_pn_destroy(ce->lmqe_cmd_tree); - free(ce); - } - - if (pthread_mutex_unlock(&cq->lmq_mutex) != 0) { - lm_serr(MMS_CRIT, "lm_queue_clean: mutex_unlock " - "failed, errno - %s", strerror(errno)); - } - - mms_trace(MMS_DEVP, "Exiting lm_queue_clean"); -} - -/* - * - * lm_queue_add() - * - * Parameters: - * cq Ptr to main work queue structure used for processing the - * LMPM commands. - * cmd Pointer to parse tree of the LMPM command that is to be - * processed by one of the worker threads. - * tid The task id of the LMPM command being added to work queue. - * index The index into the lm_cmdData[] of the LMPM command - * - * Globals: - * None - * - * This functions adds the cmd to the work queue. It also determines if - * a worker thread is available to processes the cmd. If no worker threads - * can process the cmd and another worker thread can be started, the - * function will start another worker thread. - * - * Return Values: - * LM_OK: If function compelete cleanly - * LM_ERROR: If an error was encountered during adding the cmd - * to the work queue. - * - */ - -int -lm_queue_add(lm_queue_t *cq, void *cmd, char **tid, int index) -{ - - lm_queue_ele_t *item; - pthread_t id; - - if ((item = (lm_queue_ele_t *)malloc(sizeof (lm_queue_ele_t))) - == NULL) { - lm_serr(MMS_CRIT, "lm_queue_add: malloc failed, errno - %s", - strerror(errno)); - return (LM_ERROR); - } - - item->lmqe_cindex = index; - if (*tid == NULL) - item->lmqe_tid = NULL; - else - item->lmqe_tid = *tid; - item->lmqe_cmd_tree = cmd; - item->lmqe_next = NULL; - if (pthread_mutex_init(&item->lmqe_mutex, NULL) != 0) { - lm_serr(MMS_CRIT, "lm_queue_add: mutex_init failed, errno - %s", - strerror(errno)); - return (LM_ERROR); - } - if (pthread_cond_init(&item->lmqe_rv, NULL) != 0) { - lm_serr(MMS_CRIT, "lm_queue_add: cond_init failed, errno - %s", - strerror(errno)); - return (LM_ERROR); - } - if (pthread_mutex_lock(&cq->lmq_mutex) != 0) { - lm_serr(MMS_CRIT, "lm_queue_add: mutex_lock failed, errno - %s", - strerror(errno)); - return (LM_ERROR); - } - - /* - * Add the command to the end of the queue - */ - if (cq->lmq_first == NULL) - cq->lmq_first = item; - else - cq->lmq_last->lmqe_next = item; - cq->lmq_last = item; - - /* If any threads are idle, wake them up, or if allowed start a */ - /* new worker thread */ - - if (cq->lmq_idle > 0) { - /* A thread is idle, wake it up to handle cmd */ - mms_trace(MMS_DEBUG, "lm_queue_add: Waking up idle thread to " - "handle new command"); - if (pthread_cond_signal(&cq->lmq_cv) != 0) { - lm_serr(MMS_CRIT, "lm_queue_add: cond_signal failed " - "errno - %s", strerror(errno)); - (void) pthread_mutex_unlock(&cq->lmq_mutex); - return (LM_ERROR); - } - } else if (cq->lmq_counter < cq->lmq_parallel) { - /* Create new thread to handle cmd */ - mms_trace(MMS_DEBUG, - "lm_queue_add: Creating new command processing " - "thread"); - if (pthread_create(&id, &cq->lmq_attr, lm_q_worker, - (void *)cq) != 0) { - lm_serr(MMS_CRIT, "lm_queue_add: thread_create failed, " - "errno - %s", strerror(errno)); - (void) pthread_mutex_unlock(&cq->lmq_mutex); - return (LM_ERROR); - } - cq->lmq_counter++; - } - if (pthread_mutex_unlock(&cq->lmq_mutex) != 0) { - lm_serr(MMS_CRIT, "lm_queue_add: mutex_unlock failed, errno - " - "%s", strerror(errno)); - return (LM_ERROR); - } - - return (LM_OK); -} - -/* - * - * lm_q_worker() - * - * Parameters: - * - arg Ptr to main work queue structure used for processing - * the LMPM commands. - * - * Globals: - * None - * - * This function is the wrapper that pulls the command off the work queue - * and then calls the actual function lm_cmd_handler() to process the command. - * This routine takes care of the thread processing part of the command - * processing so that the actual command processor does not need to worry - * about how it got the command. - * - * Return Values: - * NULL: If function compelete cleanly - * NULL: If an error was encountered during processing. - * - */ - -static void * -lm_q_worker(void *arg) -{ - - int rc; - int timedout; - - struct timespec timeout; - - lm_queue_t *cq = (lm_queue_t *)arg; - lm_queue_ele_t *ce; - - mms_trace(MMS_DEVP, "lm_q_worker: New worker thread starting"); - - if (pthread_mutex_lock(&cq->lmq_mutex) != 0) { - lm_serr(MMS_CRIT, "lm_q_worker: mutex_lock failed, errno - " - "%s", strerror(errno)); - return ((void *)NULL); - } - - /* LINTED constant in conditional context */ - while (1) { - timedout = 0; - mms_trace(MMS_DEBUG, - "lm_q_worker: Worker thread looking for work"); - (void) clock_gettime(CLOCK_REALTIME, &timeout); - timeout.tv_sec += 5; - - while (cq->lmq_first == NULL && !cq->lmq_quit) { - mms_trace(MMS_DEBUG, - "lm_q_worker: Worker thread waiting on " - "work"); - cq->lmq_idle++; - rc = pthread_cond_timedwait(&cq->lmq_cv, - &cq->lmq_mutex, &timeout); - cq->lmq_idle--; - if (rc == ETIMEDOUT) { - mms_trace(MMS_DEBUG, - "lm_q_worker: Worker thread " - "waiting for work timed out"); - timedout = 1; - break; - } else if (rc != 0) { - mms_trace(MMS_ERR, "lm_q_worker: Worker thread " - "failed, %d", rc); - cq->lmq_counter--; - if ((pthread_mutex_unlock(&cq->lmq_mutex)) - != 0) - lm_serr(MMS_CRIT, "lm_q_worker: " - "unlock failed, errno - %s", - strerror(errno)); - return ((void *)NULL); - } else { - mms_trace(MMS_DEBUG, - "lm_q_worker: Worker thread " - "woke up to handle work"); - } - } - - mms_trace(MMS_DEBUG, "lm_q_worker: Queue: %#lx, quit: %d", - cq->lmq_first, cq->lmq_quit); - ce = cq->lmq_first; - if (ce != NULL) { - cq->lmq_first = ce->lmqe_next; - if (cq->lmq_last == ce) - cq->lmq_last = NULL; - if (pthread_mutex_unlock(&cq->lmq_mutex) != 0) { - lm_serr(MMS_CRIT, "lm_q_worker: mutex_unlock " - "failed, errno - %s", strerror(errno)); - return ((void *)NULL); - } - mms_trace(MMS_DEBUG, - "lm_q_worker: Worker thread calling " - "cmd processing routine"); - cq->lmq_worker(ce); - free(ce); - if (pthread_mutex_lock(&cq->lmq_mutex) != 0) { - lm_serr(MMS_CRIT, "lm_q_worker: mutex_lock " - "failed, errno - %s", - strerror(errno)); - return ((void *)NULL); - } - } - - if (cq->lmq_first == NULL && cq->lmq_quit) { - mms_trace(MMS_DEBUG, - "lm_q_worker: Worker thread shutting " - "down"); - cq->lmq_counter--; - if (cq->lmq_counter == 0) - if (pthread_cond_broadcast(&cq->lmq_cv) - != 0) - lm_serr(MMS_CRIT, "lm_q_worker: " - "cond_broadcast failed, " - "errno - %s", strerror(errno)); - if (pthread_mutex_unlock(&cq->lmq_mutex) != 0) - lm_serr(MMS_CRIT, "lm_q_worker: mutex_unlock " - "failed, errno - %s", strerror(errno)); - return ((void *)NULL); - } - - if (cq->lmq_first == NULL && timedout) { - mms_trace(MMS_DEBUG, "lm_q_worker: Worker thread " - "terminating due to timeout being reached"); - cq->lmq_counter--; - break; - } - } - - if (pthread_mutex_unlock(&cq->lmq_mutex) != 0) - lm_serr(MMS_CRIT, - "lm_q_worker: mutex_unlock failed, errno - %s", - strerror(errno)); - - mms_trace(MMS_DEVP, "lm_q_worker: Worker thread exiting"); - return ((void *)NULL); -} diff --git a/usr/src/cmd/mms/lm/i386/Makefile b/usr/src/cmd/mms/lm/i386/Makefile deleted file mode 100644 index 7e02307f11..0000000000 --- a/usr/src/cmd/mms/lm/i386/Makefile +++ /dev/null @@ -1,27 +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.cmd -include ../Makefile.com diff --git a/usr/src/cmd/mms/lm/sparc/Makefile b/usr/src/cmd/mms/lm/sparc/Makefile deleted file mode 100644 index 7e02307f11..0000000000 --- a/usr/src/cmd/mms/lm/sparc/Makefile +++ /dev/null @@ -1,27 +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.cmd -include ../Makefile.com diff --git a/usr/src/cmd/mms/mgmt/Makefile b/usr/src/cmd/mms/mgmt/Makefile deleted file mode 100644 index 049ddf7518..0000000000 --- a/usr/src/cmd/mms/mgmt/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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -SUBDIRS = \ - adm \ - init \ - mnt - -include ../Makefile.subdirs diff --git a/usr/src/cmd/mms/mgmt/adm/Makefile b/usr/src/cmd/mms/mgmt/adm/Makefile deleted file mode 100644 index 3a3c393869..0000000000 --- a/usr/src/cmd/mms/mgmt/adm/Makefile +++ /dev/null @@ -1,28 +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. -# - -SUBDIRS = $(MACH) - -include ../../Makefile.subdirs diff --git a/usr/src/cmd/mms/mgmt/adm/Makefile.com b/usr/src/cmd/mms/mgmt/adm/Makefile.com deleted file mode 100644 index 6bba76cba1..0000000000 --- a/usr/src/cmd/mms/mgmt/adm/Makefile.com +++ /dev/null @@ -1,78 +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. -# - -SRCS = mmsadm.c - -.KEEP_STATE: -.SUFFIXES: - -PROG = mmsadm - -OBJS = $(SRCS:%.c=%.o) -lint_SRCS = $(SRCS:%.c=%.ln) - -include $(SRC)/cmd/Makefile.cmd - -ACSLSH = $(SRC)/common/mms/h - -CFLAGS += $(CTF_FLAGS) $(CC_VERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -D_REENTRANT -CPPFLAGS += -I. -I../common -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/lib/mms/mms/common -I$(SRC)/lib/mms/mgmt/common -CPPFLAGS += -I$(ACSLSH) - -LDLIBS += -lc -lnvpair -LDLIBS += -L$(SRC)/lib/mms/mms/$(MACH) -lmms -LDLIBS += -L$(SRC)/lib/mms/mgmt/$(MACH) -lmmsadm -R/usr/lib/mms - -.NO_PARALLEL: -.PARALLEL: $(OBJS) $(lint_SRCS) - -C99MODE= $(C99_ENABLE) - -all: $(PROG) - -$(PROG): $(OBJS) - $(LINK.c) $(OBJS) -o $@ $(LDLIBS) - $(CTFMERGE) -L VERSION -o $@ $(OBJS) - $(POST_PROCESS) - -%.o: ../common/%.c - $(COMPILE.c) $< - $(CTFCONVERT_O) - -clean: - $(RM) $(OBJS) $(lint_SRCS) - -lint: $(lint_SRCS) - -%.ln: ../common/%.c - $(LINT.c) -c $< - -install: all $(ROOTBIN)/$(PROG) - -include $(SRC)/cmd/Makefile.targ diff --git a/usr/src/cmd/mms/mgmt/adm/common/mmsadm.c b/usr/src/cmd/mms/mgmt/adm/common/mmsadm.c deleted file mode 100644 index 0167e6162e..0000000000 --- a/usr/src/cmd/mms/mgmt/adm/common/mmsadm.c +++ /dev/null @@ -1,1674 +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. - */ - -#include <stdlib.h> -#include <stdio.h> -#include <strings.h> -#include <ctype.h> -#include <errno.h> -#include <libnvpair.h> - -#include "mms_trace.h" -#include "mms_mgmt.h" -#include "mgmt_acsls.h" -#include "mgmt_library.h" -#include "mgmt_media.h" -#include "mms_cfg.h" - -static char *_SrcFile = __FILE__; -extern char *optarg; -extern int optind, opterr, optopt; - -static char *usemsg = -"Usage: mmsadm [-h] <subcommand>\n\ -Subcommands:\n\ -\tdiscover\n\ -\tcreate\n\ -\tdelete\n\ -\tset\n\ -\tlist\n\ -\tpasswd\n\ -\tonline\n\ -\toffline\n\ -\tadd-volume\n\ -\tremove-volume\n\ -\tlabel\n\ -\tshowreq\n\ -\taccept\n\ -\treject\n\ -\tmount\n\ -\tunmount\n\ -\tdbbackup\n\ -\tdbrestore\n\ -Use 'mmsadm <subcommand> -h' to list subcommand options and/or refer to\n\ -the mmsadm man page.\n"; - -static int mmsadm_discover(nvlist_t *nvl, nvlist_t *errs); -static int mmsadm_create(nvlist_t *nvl, nvlist_t *errs); -static int mmsadm_delete(nvlist_t *nvl, nvlist_t *errs); -static int mmsadm_set(nvlist_t *nvl, nvlist_t *errs); -static int mmsadm_list(nvlist_t *nvl, nvlist_t *errs); -static int mmsadm_online(nvlist_t *nvl, nvlist_t *errs); -static int mmsadm_offline(nvlist_t *nvl, nvlist_t *errs); -static int mmsadm_add_vol(nvlist_t *nvl, nvlist_t *errs); -static int mmsadm_rm_vol(nvlist_t *nvl, nvlist_t *errs); -static int mmsadm_showreq(nvlist_t *nvl, nvlist_t *errs); -static int mmsadm_accept(nvlist_t *nvl, nvlist_t *errs); -static int mmsadm_reject(nvlist_t *nvl, nvlist_t *errs); -static int mmsadm_dbbackup(nvlist_t *nvl, nvlist_t *errs); -static int mmsadm_dbrestore(nvlist_t *nvl, nvlist_t *errs); -static int mmsadm_mount(nvlist_t *nvl, nvlist_t *errs); -static int mmsadm_unmount(nvlist_t *nvl, nvlist_t *errs); -static int mmsadm_discover_vols(nvlist_t *nvl, nvlist_t *errs); -static int mmsadm_passwd(nvlist_t *nvl, nvlist_t *errs); -static int mmsadm_label(nvlist_t *nvl, nvlist_t *errs); -static int mmsadm_discover_local(nvlist_t *nvl, nvlist_t *errs); - -static void usage(int idx); - -static int print_list_values(char *objtype, nvlist_t *nvl, char **printopts, - int pcount, boolean_t doscript); -static int confirm_delete(char *objname, boolean_t force); - -static char discover_usemsg[] = -"\nUsage: mmsadm discover [-a] [-H] [-S ACSLS-server:port] \ -[-t library|drive|vol]\n\ -\t-a\tShow all, including already-configured resources\n\ -\t-H\tScripting mode\n\ -\t-S\tACSLS server name and optional port number\n\ -\t\tIf not specified, displays locally connected tape drives\n\ -\t-t\tResource type\n"; - -static char create_usemsg[] = -"\nUsage: mmsadm create -t <type> -o option=x [-o option2=y ...] name\n" -"\t-t\tResource type - library, drive, dpool, mpool, app " -"or voltype\n"; - -static char delete_usemsg[] = -"\nUsage: mmsadm delete -t <type> [-f] name\n" -"\t-t\tResource type - library, drive, dpool, mpool, app or " -"voltype\n " -"\t-f\tForce\n"; - -static char set_usemsg[] = -"\nUsage: mmsadm set -t <type> -o option=x [-o option2=y ...] name\n" -"\t-t\tResource type - system, library, drive, dpool, mpool, app " -"or voltype\n"; - -static char passwd_usemsg[] = -"\nUsage: mmsadm passwd [-P passwdfile] name\n\ -\t-P\tPath to a temporary file containing the password\n\ -\tname\tApplication name. Use 'admin' to change the MMS Administrative \ -password\n"; - -static char online_usemsg[] = -"\nUsage: mmsadm online -t library|drive name\n\ -\t-t\t Resource type\n"; - -static char offline_usemsg[] = -"\nUsage: mmsadm offline -t library|drive name\n\ -\t-t\t Resource type\n"; - -static char label_usemsg[] = -"\nUsage: mmsadm label -l library -A application [-f] [-n] volume[,volume]\n\ -\t-l\tLibrary holding the volume\n\ -\t-A\tApplication to which this volume will be assigned after labeling\n\ -\t-f\tForce label. Use this option to relabel a tape that has previously \ -been labeled.\n\ -\t-n\tDo not mount tape\n"; - -static char add_usemsg[] = -"\nUsage: mmsadm add-volume -l library -x vol[,vol2...] mpool\n\ -\t-l\tLibrary from which the volume will be selected\n\ -\t-x\tComma separated list of volumes to be added\n\ -\tmpool\tName of media pool to which the volumes will be added\n"; - -static char remove_usemsg[] = -"\nUsage: mmsadm remove-volume -l library [-f] -x vol[,vol2...] mpool\n\ -\t-l\tLibrary from which the volume will be selected\n\ -\t-x\tComma separated list of volumes to be added\n\ -\t-f\tForce. Use this option to remove a volume which has previously \ -been used\n\ -\tmpool\tName of media pool to which the volumes will be added\n"; - -static char show_usemsg[] = -"\nUsage: mmsadm showreq [-H]\n\ -\t-H\tScripting mode.\n"; - -static char accept_usemsg[] = -"\nUsage: mmsadm accept [-r \"response text\"] requestid\n\ -\t-r\tOptional text message\n\ -\trequestid\tRequest ID as displayed by the 'mmsadm showreq' command\n"; - -static char reject_usemsg[] = -"\nUsage: mmsadm reject [-r \"response text\"] requestid\n\ -\t-r\tOptional text message\n\ -\trequestid\tRequest ID as displayed by the 'mmsadm showreq' command\n"; - -static char back_usemsg[] = -"\nUsage: mmsadm dbbackup <directory>\n\ -\tdirectory\tDirectory where the database backup file will be stored\n"; - -static char rest_usemsg[] = -"\nUsage: mmsadm dbrestore <filename>\n\ -\tfilename\tComplete path to the file containing the backup to be restored\n"; - -static char mount_usemsg[] = -"\nUsage: mmsadm mount [-n] [-N] [-d drive] [-D density] [-A application] \ --l library [-P passwdfile] [-u username] [-b blocksize] [-R] \ -[-M mode[,mode...]] volume\n\ -\t-n\tnorewind\n\ -\t-N\tnowait\n\ -\t-d\tdrive on which to mount the volume\n\ -\t-D\tdensity\n\ -\t-A\tapplication name\n\ -\t-l\tlibrary containing the volume to be mounted\n\ -\t-P\tPath to a temporary file containing the password\n\ -\t-u\tThe username who will have ownership of pseudodevice created by mount\n\ -\t-b\tblocksize\n\ -\t-R\treadonly\n\ -\t-M\tmode. One or more of creat, trunc, append. old, st_nobsd, st_tm, raw, \n\ -\t\tmms, compression, nocompression, variable, block\n"; - -static char unmount_usemsg[] = -"\nUsage: mmsadm unmount [-U] [-l library] [-A application] [-P passwdfile] \ -volume|pseudodevice\n\ -\t-U\tPhysically unload the tape from the drive\n\ -\t-l\tLibrary containing the volume to be unmounted\n\ -\t-A\tapplication name\n\ -\t-P\tPath to a temporary file containing the password\n\ -\tvolume\tVolume to be unmounted \n\ -\tpseudodevice\tName of pseudodevice as returned from the \ -'mmsadm mount' command\n"; - -static char *setphrases[2] = { - "Enter password: ", - "Re-enter password: " -}; - -static char *getphrases[2] = { - "Enter application password: ", - NULL -}; - -typedef struct { - char *subopt; - int (*func)(nvlist_t *nvl, nvlist_t *errs); - char *usemsg; - boolean_t hasobj; -} adminfuncs_t; - -static adminfuncs_t mmsadmfuncs[] = { - {"discover", mmsadm_discover, discover_usemsg, B_FALSE}, - {"create", mmsadm_create, create_usemsg, B_TRUE}, - {"delete", mmsadm_delete, delete_usemsg, B_TRUE}, - {"set", mmsadm_set, set_usemsg, B_TRUE}, - {"list", mmsadm_list, NULL, B_FALSE}, - {"online", mmsadm_online, online_usemsg, B_TRUE}, - {"offline", mmsadm_offline, offline_usemsg, B_TRUE}, - {"add-volume", mmsadm_add_vol, add_usemsg, B_TRUE}, - {"remove-volume", mmsadm_rm_vol, remove_usemsg, B_TRUE}, - {"showreq", mmsadm_showreq, show_usemsg, B_FALSE}, - {"accept", mmsadm_accept, accept_usemsg, B_TRUE}, - {"reject", mmsadm_reject, reject_usemsg, B_TRUE}, - {"dbbackup", mmsadm_dbbackup, back_usemsg, B_TRUE}, - {"dbrestore", mmsadm_dbrestore, rest_usemsg, B_TRUE}, - {"mount", mmsadm_mount, mount_usemsg, B_TRUE}, - {"unmount", mmsadm_unmount, unmount_usemsg, B_TRUE}, - {"passwd", mmsadm_passwd, passwd_usemsg, B_TRUE}, - {"label", mmsadm_label, label_usemsg, B_TRUE}, - {NULL, NULL, NULL, B_FALSE} -}; - -static char *cmdopts = ":aA:b:d:D:fF:hHl:L:m:M:nNo:P:r:Rs:S:t:u:Uv?x:V:"; - -int -main(int argc, char **argv) -{ - int st = 0; - int i; - int cmdidx = -1; - char *subcmd = NULL; - nvlist_t *nvl = NULL; - char c; - int newargc = argc; - char **newargv = argv; - char buf[2048]; - char *bufp; - int hflag = 0; - nvlist_t *errs = NULL; - char *tmpstr; - boolean_t allow_empty_val = B_FALSE; - boolean_t req_name = B_FALSE; - boolean_t listing = B_FALSE; - - if (argc < 2) { - hflag++; - st = 1; - goto done; - } - - (void) mms_trace_open("/var/log/mms/mmsadm.log", MMS_ID_CLI, - MMS_SEV_INFO, 5 * MEGA, 0, 0); - - mms_trace(MMS_INFO, "mmsadm start ***********************************"); - /* see if this host has been initialized. If not, fail. */ - st = mms_cfg_getvar(MMS_CFG_CONFIG_TYPE, buf); - if (st != 0) { - fprintf(stderr, "\nError: MMS has not been initialized for" - " use on this system. Please run the mmsinit command.\n"); - st = MMS_MGMT_MMS_NOT_INIT; - goto done; - } - - /* - * see if we've got a subcommand. If we don't, fall through - * to getopt() anyway. - */ - for (i = 0; mmsadmfuncs[i].subopt != NULL; i++) { - if (strcmp(mmsadmfuncs[i].subopt, argv[1]) == 0) { - /* reset options for getopt */ - newargc--; - newargv = &(argv[1]); - subcmd = argv[1]; - req_name = mmsadmfuncs[i].hasobj; - cmdidx = i; - if (strcmp(subcmd, "list") == 0) { - listing = B_TRUE; - } - break; - } - } - - if (subcmd == NULL) { - hflag++; - st = 1; - goto done; - } - - if (mmsadmfuncs[cmdidx].func == NULL) { - fprintf(stderr, "mmsadm %s not yet implemented\n", - mmsadmfuncs[cmdidx].subopt); - st = 1; - goto done; - } - - st = nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0); - if (st != 0) { - goto done; - } - - st = nvlist_alloc(&errs, NV_UNIQUE_NAME, 0); - if (st != 0) { - goto done; - } - - if (listing) { - allow_empty_val = B_TRUE; - } - - while (st == 0) { - c = getopt(newargc, newargv, cmdopts); - - if (c == -1) { - break; - } - - switch (c) { - case 'a': - st = nvlist_add_boolean_value(nvl, "all", - B_TRUE); - break; - case 'A': - st = nvlist_add_string(nvl, O_APPS, optarg); - break; - case 'b': - st = nvlist_add_string(nvl, "blocksize", - optarg); - break; - case 'd': - st = nvlist_add_string(nvl, O_MMSDRV, optarg); - break; - case 'D': - st = nvlist_add_string(nvl, O_DENSITY, optarg); - break; - case 'f': - st = nvlist_add_boolean_value(nvl, O_FORCE, - B_TRUE); - break; - case 'F': - if (!listing) { - st = nvlist_add_string(nvl, "filename", - optarg); - } else { - /* list filter */ - nvlist_add_boolean_value(nvl, "filter", - B_TRUE); - st = mgmt_opt_to_var(optarg, - allow_empty_val, nvl); - } - break; - case 'H': - st = nvlist_add_boolean_value(nvl, "script", - B_TRUE); - break; - case 'l': - case 'L': - st = nvlist_add_string(nvl, O_MMSLIB, optarg); - break; - case 'm': - st = nvlist_add_string(nvl, O_MPOOL, optarg); - break; - case 'M': - /* possibly multi-value */ - tmpstr = strdup(optarg); - if (tmpstr == NULL) { - st = ENOMEM; - break; - } - st = mgmt_set_str_or_arr(tmpstr, "mode", nvl); - - free(tmpstr); - tmpstr = NULL; - - break; - case 'n': - st = nvlist_add_boolean_value(nvl, O_NOREWIND, - B_TRUE); - break; - case 'N': - st = nvlist_add_boolean_value(nvl, O_NOWAIT, - B_TRUE); - break; - case 'o': - if (!listing) { - st = mgmt_opt_to_var(optarg, - allow_empty_val, nvl); - } else { - /* possibly multi-value */ - tmpstr = strdup(optarg); - if (tmpstr == NULL) { - st = ENOMEM; - break; - } - st = mgmt_set_str_or_arr(tmpstr, - "printopts", nvl); - - free(tmpstr); - tmpstr = NULL; - } - break; - case 'P': - /* read password from file */ - st = nvlist_add_string(nvl, "passwordfile", - optarg); - break; - case 'r': - st = nvlist_add_string(nvl, O_RESPTXT, optarg); - break; - case 'R': - st = nvlist_add_string(nvl, "readonly", "true"); - break; - case 's': - /* possibly multi-value */ - tmpstr = strdup(optarg); - if (tmpstr == NULL) { - st = ENOMEM; - break; - } - st = mgmt_set_str_or_arr(tmpstr, O_DEVCONN, - nvl); - - free(tmpstr); - tmpstr = NULL; - - break; - case 'S': - strlcpy(buf, optarg, sizeof (buf)); - bufp = strchr(buf, ':'); - if (bufp != NULL) { - *bufp++ = '\0'; - st = nvlist_add_string(nvl, O_ACSPORT, - bufp); - } - if (st == 0) { - st = nvlist_add_string(nvl, O_ACSHOST, - buf); - } - - break; - case 't': - st = nvlist_add_string(nvl, O_OBJTYPE, optarg); - if (strcmp(optarg, "system") == 0) { - req_name = B_FALSE; - } - break; - case 'u': - st = nvlist_add_string(nvl, "user", optarg); - break; - case 'U': - st = nvlist_add_boolean_value(nvl, "unload", - B_TRUE); - break; - case 'v': - st = nvlist_add_boolean_value(nvl, "verbose", - B_TRUE); - break; - case 'V': - st = nvlist_add_string(nvl, O_VOLTYPE, optarg); - break; - case 'x': - /* process list of volumes */ - /* possibly multi-value */ - tmpstr = strdup(optarg); - if (tmpstr == NULL) { - st = ENOMEM; - break; - } - st = mgmt_set_str_or_arr(tmpstr, O_VOLUMES, - nvl); - - free(tmpstr); - tmpstr = NULL; - - break; - case '?': - case 'h': - hflag++; - break; - case ':': - fprintf(stderr, - "Option %s requires an operand\n", - argv[optind-1]); - st = 1; - break; - default: - break; - } - } - - if ((st != 0) || (subcmd == NULL) || hflag) { - goto done; - } - - /* get object name[s] we're to act on, if any */ - if (optind < newargc) { - /* possibly multi-value */ - tmpstr = strdup(newargv[optind++]); - if (tmpstr == NULL) { - st = ENOMEM; - goto done; - } - st = mgmt_set_str_or_arr(tmpstr, O_NAME, nvl); - - free(tmpstr); - tmpstr = NULL; - - if (st != 0) { - goto done; - } - } else { - /* see if this subcommand requires one or more objects */ - if (subcmd && req_name) { - fprintf(stderr, - "Error, command requires an object name\n"); - st = ENOENT; - goto done; - } - } - - if (optind < newargc) { - /* hmm, leftover cmd args? */ - fprintf(stderr, - "Error: extra arguments after command line processing.\n"); - hflag++; - st = 1; - goto done; - } - - st = mmsadmfuncs[cmdidx].func(nvl, errs); - -done: - mms_trace_close(); - - if (hflag) { - usage(cmdidx); - } - - if (nvl != NULL) { - nvlist_free(nvl); - } - - if (st != 0) { - nvpair_t *nv; - char *nvo = NULL; - int nvi = 0; - const char *nve; - - nve = mms_mgmt_get_errstr(st); - if (nve) { - fprintf(stderr, "%s\n", nve); - } - fprintf(stderr, "mmsadm exiting with error %d\n", st); - - if (errs) { - nv = nvlist_next_nvpair(errs, NULL); - while (nv != NULL) { - nvo = nvpair_name(nv); - (void) nvpair_value_int32(nv, &nvi); - nve = mms_mgmt_get_errstr(nvi); - - if (nve != NULL) { - fprintf(stderr, "\t%-15s%s\n", - nvo, nve); - } else { - fprintf(stderr, "\t%-15serror = %d\n", - nvo, nvi); - } - nv = nvlist_next_nvpair(errs, nv); - } - } - } - - if (errs != NULL) { - nvlist_free(errs); - } - - return (st); -} - -static void -usage(int idx) -{ - if ((idx == -1) || (mmsadmfuncs[idx].usemsg == NULL)) { - printf("%s\n", usemsg); - } else { - printf("%s\n", mmsadmfuncs[idx].usemsg); - } -} - -static int -mmsadm_discover(nvlist_t *nvl, nvlist_t *errs) -{ - int st = 0; - char *host = NULL; - char *bufp; - boolean_t drv = B_FALSE; - boolean_t lib = B_FALSE; - boolean_t dolocal = B_FALSE; - boolean_t showall = B_FALSE; - boolean_t doscript = B_FALSE; - mms_list_t lib_list; - mms_list_t drv_list; - mms_acslib_t *lsm; - mms_drive_t *drive; - char *fmt = "%-8s%-10s%-20s%-20s%-20s\n"; - char *sfmt = "%s\t%s\t%s\t%s\t%s\n"; - char buf[128]; - char *fmtp; - - if (nvl == NULL) { - return (EINVAL); - } - - memset(&lib_list, 0, sizeof (mms_list_t)); - memset(&drv_list, 0, sizeof (mms_list_t)); - - st = nvlist_lookup_string(nvl, O_OBJTYPE, &bufp); - if (st == ENOENT) { - /* not set, report on both libraries and drives */ - drv = B_TRUE; - lib = B_TRUE; - } else if (st == 0) { - if (*bufp == 'l') { - lib = B_TRUE; - } else if (*bufp == 'd') { - drv = B_TRUE; - } else if (*bufp == 'v') { - /* volumes */ - st = mmsadm_discover_vols(nvl, errs); - return (st); - } else { - st = EINVAL; - if (errs) { - nvlist_add_int32(errs, O_TYPE, st); - } - return (st); - } - } else { - return (st); - } - - st = nvlist_lookup_string(nvl, O_ACSHOST, &bufp); - if (st == 0) { - host = bufp; - } else if (st == ENOENT) { - dolocal = B_TRUE; - st = nvlist_lookup_string(nvl, O_HOST, &bufp); - if (st == ENOENT) { - host = "localhost"; - st = 0; - } else if (st == 0) { - host = bufp; - if (strcmp(host, "localhost") != 0) { - fprintf(stderr, - "Remote discovery not yet supported\n"); - st = EOPNOTSUPP; - } - } - } - - if (st != 0) { - return (st); - } - - nvlist_lookup_boolean_value(nvl, "all", &showall); - nvlist_lookup_boolean_value(nvl, "script", &doscript); - - if (!dolocal) { - /* get ACSLS information */ - st = mms_mgmt_discover_libraries(host, drv, &lib_list); - } else { - /* Local drives only */ - st = mmsadm_discover_local(nvl, errs); - goto done; - } - - if ((st != 0) || (lib_list.list_size == 0)) { - goto done; - } - - /* print header */ - if (!doscript) { - fmtp = fmt; - /* LINTED [E_SEC_PRINTF_VAR_FMT] */ - printf(fmtp, "TYPE", "HWTYPE", "SERIALNUM", "ACS,LSM", "MMSID"); - /* LINTED [E_SEC_PRINTF_VAR_FMT] */ - printf(fmtp, "====", "======", "=========", "=======", "====="); - } else { - fmtp = sfmt; - } - - /* print out what we found */ - mms_list_foreach(&lib_list, lsm) { - if (lib) { - if (showall || (lsm->name[0] == '\0')) { - snprintf(buf, sizeof (buf), "[%d,%d]", - lsm->acs, lsm->lsm); - /* LINTED [E_SEC_PRINTF_VAR_FMT] */ - printf(fmtp, "L", lsm->type, lsm->serialnum, - buf, lsm->name); - } - } - - if (drv && (lsm->drive_list.list_size != 0)) { - mms_list_foreach(&lsm->drive_list, drive) { - if (!showall && (drive->name[0] != '\0')) { - continue; - } - - snprintf(buf, sizeof (buf), "[%d,%d,%d,%d]", - drive->acs, - drive->lsm, - drive->panel, - drive->drive); - - /* LINTED [E_SEC_PRINTF_VAR_FMT] */ - printf(fmtp, "D", drive->type, drive->serialnum, - buf, drive->name); - } - } - fflush(stdout); - } - -done: - free_acslib_list(&lib_list); - - return (st); -} - -static int -mmsadm_create(nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char *objtype = NULL; - char *pwfile = NULL; - - if (!nvl) { - return (EFAULT); - } - - st = nvlist_lookup_string(nvl, O_OBJTYPE, &objtype); - if (st != 0) { - return (st); - } - - if (strcmp(objtype, "library") == 0) { - st = mms_add_library(NULL, nvl, errs); - } else if (strcmp(objtype, "drive") == 0) { - st = mms_add_drive(NULL, nvl, errs); - } else if (strcmp(objtype, "app") == 0) { - nvlist_lookup_string(nvl, "passwordfile", &pwfile); - st = mms_mgmt_get_pwd(pwfile, O_MMPASS, setphrases, nvl, errs); - if (st == 0) { - st = mms_mgmt_add_application(NULL, nvl, errs); - } - } else if (strcmp(objtype, "mpool") == 0) { - st = mms_mgmt_add_mpool(NULL, nvl, errs); - } else if (strcmp(objtype, "dpool") == 0) { - st = mms_mgmt_add_dpool(NULL, nvl, errs); - } else if (strcmp(objtype, "voltype") == 0) { - st = mms_mgmt_add_voltype(NULL, nvl, errs); - } else { - return (EINVAL); - } - - return (st); -} - -static int -mmsadm_delete(nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char *objtype = NULL; - char *objname = NULL; - boolean_t force; - - if (!nvl) { - return (EFAULT); - } - - st = nvlist_lookup_string(nvl, O_OBJTYPE, &objtype); - if (st == 0) { - st = val_objtype(objtype); - } - if (st != 0) { - nvlist_add_int32(errs, O_OBJTYPE, st); - return (st); - } - - st = nvlist_lookup_string(nvl, O_NAME, &objname); - if (st != 0) { - nvlist_add_int32(errs, O_NAME, st); - return (st); - } - - if ((nvlist_lookup_boolean_value(nvl, O_FORCE, &force)) != 0) { - force = B_FALSE; - } - - if (strcmp(objtype, "library") == 0) { - if ((st = confirm_delete(objname, force)) != 0) { - return (st); - } - st = mms_remove_library(NULL, nvl, errs); - } else if (strcmp(objtype, "drive") == 0) { - if ((st = confirm_delete(objname, force)) != 0) { - return (st); - } - st = mms_remove_drive(NULL, nvl, errs); - } else if (strcmp(objtype, "app") == 0) { - if ((st = confirm_delete(objname, force)) != 0) { - return (st); - } - st = mms_mgmt_remove_application(NULL, nvl, errs); - } else if (strcmp(objtype, "mpool") == 0) { - if ((st = confirm_delete(objname, force)) != 0) { - return (st); - } - st = mms_mgmt_remove_mpool(NULL, objname, force, errs); - } else if (strcmp(objtype, "dpool") == 0) { - if ((st = confirm_delete(objname, force)) != 0) { - return (st); - } - st = mms_mgmt_remove_dpool(NULL, objname, force, errs); - } else if (strcmp(objtype, "voltype") == 0) { - if ((st = confirm_delete(objname, force)) != 0) { - return (st); - } - st = mms_mgmt_remove_voltype(NULL, objname); - } else { - return (EINVAL); - } - - return (st); -} - -static int -mmsadm_set(nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char *objtype = NULL; - - if (!nvl) { - return (EFAULT); - } - - st = nvlist_lookup_string(nvl, O_OBJTYPE, &objtype); - if (st != 0) { - return (st); - } - - if (strcmp(objtype, "library") == 0) { - st = mms_modify_library(NULL, nvl, errs); - } else if (strcmp(objtype, "drive") == 0) { - st = mms_modify_drive(NULL, nvl, errs); - } else if (strcmp(objtype, "system") == 0) { - st = mms_mgmt_set_opts(nvl, errs); - } else if (strcmp(objtype, "app") == 0) { - st = mms_mgmt_modify_application(NULL, nvl, errs); - } else if (strcmp(objtype, "mpool") == 0) { - st = mms_mgmt_modify_mpool(NULL, nvl, errs); - } else if (strcmp(objtype, "dpool") == 0) { - st = mms_mgmt_modify_dpool(NULL, nvl, errs); - } else if (strcmp(objtype, "voltype") == 0) { - st = mms_mgmt_modify_voltype(NULL, nvl, errs); - } else if (strcmp(objtype, "vol") == 0) { - st = mms_mgmt_set_vol_mode(NULL, nvl, errs); - } else { - return (EINVAL); - } - - return (st); -} - -static int -mmsadm_list(nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char *objtype = NULL; - char *objname = NULL; - nvlist_t *outlist = NULL; - boolean_t do_all = B_FALSE; - boolean_t found = B_FALSE; - char **printopts; - int pcount = 0; - boolean_t doscript = B_FALSE; - - st = nvlist_lookup_string(nvl, O_OBJTYPE, &objtype); - if (st != 0) { - if (st == ENOENT) { - do_all = B_TRUE; - st = 0; - } else { - nvlist_add_int32(errs, O_OBJTYPE, st); - return (st); - } - } - - nvlist_lookup_string(nvl, O_NAME, &objname); - nvlist_lookup_boolean_value(nvl, "script", &doscript); - - printopts = mgmt_var_to_array(nvl, "printopts", &pcount); - - if (do_all || (strcmp(objtype, "system") == 0)) { - found = B_TRUE; - st = mms_mgmt_get_opts("server", &outlist); - if (st == 0) { - st = print_list_values("system", outlist, printopts, - pcount, doscript); - nvlist_free(outlist); - outlist = NULL; - } - } - if (do_all || (strcmp(objtype, "library") == 0)) { - found = B_TRUE; - st = mms_mgmt_list_libraries(NULL, nvl, errs, &outlist); - if (st == 0) { - st = print_list_values("library", outlist, printopts, - pcount, doscript); - nvlist_free(outlist); - outlist = NULL; - } - } - if (do_all || (strcmp(objtype, "drive") == 0)) { - found = B_TRUE; - st = mms_mgmt_list_drives(NULL, nvl, errs, &outlist); - if (st == 0) { - st = print_list_values("drive", outlist, printopts, - pcount, doscript); - nvlist_free(outlist); - outlist = NULL; - } - } - if (do_all || (strcmp(objtype, "voltype") == 0)) { - found = B_TRUE; - st = mms_mgmt_show_cartridge_type(NULL, objname, &outlist); - if (st == 0) { - st = print_list_values("voltype", outlist, printopts, - pcount, doscript); - nvlist_free(outlist); - outlist = NULL; - } - } - if (do_all || ((strcmp(objtype, "vol") == 0)) || - (strcmp(objtype, "dkvol") == 0)) { - found = B_TRUE; - st = mms_mgmt_list_vols(NULL, nvl, &outlist); - if (st == 0) { - st = print_list_values("vol", outlist, printopts, - pcount, doscript); - nvlist_free(outlist); - outlist = NULL; - } - } - if (do_all || (strcmp(objtype, "dpool") == 0)) { - found = B_TRUE; - st = mms_mgmt_show_dpool(NULL, nvl, &outlist); - if (st == 0) { - st = print_list_values("dpool", outlist, printopts, - pcount, doscript); - nvlist_free(outlist); - outlist = NULL; - } - } - - if (do_all || (strcmp(objtype, "mpool") == 0)) { - found = B_TRUE; - st = mms_mgmt_show_mpool(NULL, nvl, &outlist); - if (st == 0) { - st = print_list_values("mpool", outlist, printopts, - pcount, doscript); - nvlist_free(outlist); - outlist = NULL; - } - } - - if (do_all || (strcmp(objtype, "app") == 0)) { - found = B_TRUE; - st = mms_mgmt_show_apps(NULL, nvl, &outlist); - if (st == 0) { - st = print_list_values("app", outlist, printopts, - pcount, doscript); - nvlist_free(outlist); - outlist = NULL; - } - } - - if (!do_all && !found) { - st = EOPNOTSUPP; - } - - if (outlist) { - nvlist_free(outlist); - } - - return (st); -} - -static int -print_list_values(char *objtype, nvlist_t *nvl, char **printopts, int pcount, - boolean_t doscript) -{ - nvlist_t *nva = NULL; - nvpair_t *nvp; - nvpair_t *nvpb; - char *key; - char *val; - boolean_t first = B_TRUE; - int i; - boolean_t printme; - data_type_t nvt; - char **arr; - uint_t count = 0; - - if (!objtype || !nvl) { - return (EFAULT); - } - - nvp = NULL; - while ((nvp = nvlist_next_nvpair(nvl, nvp)) != NULL) { - nvpair_value_nvlist(nvp, &nva); - key = nvpair_name(nvp); - - if (!doscript) { - printf("%s %s\n", objtype, key); - } - nvpb = NULL; - while ((nvpb = nvlist_next_nvpair(nva, nvpb)) != NULL) { - key = nvpair_name(nvpb); - if (printopts) { - printme = B_FALSE; - for (i = 0; i < pcount; i++) { - if (!printopts[i]) { - continue; - } - if (strcmp(printopts[i], key) == 0) { - printme = B_TRUE; - break; - } - } - if (!printme) { - continue; - } - } - nvt = nvpair_type(nvpb); - if (nvt == DATA_TYPE_STRING) { - nvpair_value_string(nvpb, &val); - if (!doscript) { - printf("\t%-30s\t%-30s\n", key, val); - } else { - if (first) { - printf("%s", val); - first = B_FALSE; - } else { - printf("\t%s", val); - } - } - } else if (nvt == DATA_TYPE_STRING_ARRAY) { - count = 0; - nvpair_value_string_array(nvpb, &arr, &count); - if (!doscript) { - for (i = 0; - (i < count) && !doscript; - i++) { - if (i > 0) { - key = " "; - } - printf("\t%-30s\t%-30s\n", - key, arr[i]); - } - } else { - for (i = 0; - (i < count) && !doscript; - i++) { - if (first) { - printf("%s", arr[i]); - first = B_FALSE; - } else { - printf("\t%s", arr[i]); - } - } - } - } - } - - if (doscript && !first) { - printf("\n"); - } - first = B_TRUE; - } - - return (0); -} - -static int -mmsadm_online(nvlist_t *nvl, nvlist_t *errs) -{ - int st; - - if (!nvl) { - return (EFAULT); - } - - nvlist_add_string(nvl, O_OBJSTATE, "online"); - - st = mms_mgmt_set_state(NULL, nvl, errs); - - return (st); -} - -static int -mmsadm_offline(nvlist_t *nvl, nvlist_t *errs) -{ - int st; - - if (!nvl) { - return (EFAULT); - } - - nvlist_add_string(nvl, O_OBJSTATE, "offline"); - - st = mms_mgmt_set_state(NULL, nvl, errs); - - return (st); -} - -static int -mmsadm_dbbackup(nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char *fname; - char outnm[MAXPATHLEN+1]; - - if (!nvl) { - return (EFAULT); - } - - st = nvlist_lookup_string(nvl, O_NAME, &fname); - if (st == 0) { - st = mgmt_db_dump(fname, outnm, sizeof (outnm)); - } else { - if (errs) { - nvlist_add_int32(errs, O_NAME, st); - } - } - - if (st == 0) { - printf("MMS database successfully backed up to %s\n", outnm); - } - - return (st); -} - -static int -mmsadm_dbrestore(nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char *fname; - - if (!nvl) { - return (EFAULT); - } - - st = nvlist_lookup_string(nvl, O_NAME, &fname); - if (st == 0) { - st = mgmt_db_restore(fname); - if ((st != 0) && (errs)) { - if (st == MMS_MGMT_DBDUMP_MISSING) { - nvlist_add_int32(errs, fname, ENOENT); - } - } - } else { - if (errs) { - nvlist_add_int32(errs, O_NAME, st); - } - } - - - return (st); -} - -static int -mmsadm_discover_vols(nvlist_t *nvl, nvlist_t *errs) -{ - int st; - boolean_t showall = B_FALSE; - boolean_t doscript = B_FALSE; - mms_list_t vol_list; - mms_acscart_t *vol; - char *fmt = "%-10s%-10s%-30s%-20s\n"; - char *sfmt = "%s\t%s\t%s\t%s\n"; - char *fmtp; - - if (!nvl) { - return (EFAULT); - } - - nvlist_lookup_boolean_value(nvl, "all", &showall); - nvlist_lookup_boolean_value(nvl, "script", &doscript); - - st = mms_mgmt_discover_media(NULL, showall, nvl, &vol_list, errs); - if (st != 0) { - return (st); - } - - /* print header */ - if (!doscript) { - fmtp = fmt; - /* LINTED [E_SEC_PRINTF_VAR_FMT] */ - printf(fmtp, "LABEL", "TYPE", "LIBRARY", "MPOOL"); - /* LINTED [E_SEC_PRINTF_VAR_FMT] */ - printf(fmtp, "=====", "====", "=======", "====="); - } else { - fmtp = sfmt; - } - - mms_list_foreach(&vol_list, vol) { - /* LINTED [E_SEC_PRINTF_VAR_FMT] */ - printf(fmtp, vol->label, vol->mtype, vol->libname, - vol->groupname); - } - - mms_list_free_and_destroy(&vol_list, free); - - return (st); -} - -static int -mmsadm_add_vol(nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char *typename = NULL; - char *shapename = NULL; - nvlist_t *type = NULL; - nvlist_t *tp = NULL; - - if (!nvl) { - return (EFAULT); - } - - st = nvlist_lookup_string(nvl, "voltype", &typename); - if (st != 0) { - st = MMS_MGMT_NO_VOLTYPE; - MGMT_ADD_OPTERR(errs, "voltype", st); - return (st); - } - - /* - * Get shapename from CARTRIDGETYPE - */ - /* see if we've already got this type */ - st = mms_mgmt_show_cartridge_type(NULL, typename, &type); - if (st != 0) { - st = MMS_MGMT_SHOW_CT_ERR; - return (st); - } - - st = nvlist_lookup_nvlist(type, typename, &tp); - if (st != 0) { - st = MMS_MGMT_CT_NOT_EXIST; - return (st); - } - - /* CartridgeShapeName is converted to O_MTYPE */ - st = nvlist_lookup_string(tp, O_MTYPE, &shapename); - if (st != 0) { - st = MMS_MGMT_SN_ERR; - return (st); - } - - /* - * If CartridgeShape of CARTRIDGETYPE is DISK, then create disk volume - */ - if (strcmp(shapename, "DISK") == 0) { - st = mms_mgmt_add_dkvol(NULL, nvl, errs); - } else { - st = mms_mgmt_add_cartridges(NULL, nvl, errs); - } - - return (st); -} - -static int -mmsadm_rm_vol(nvlist_t *nvl, nvlist_t *errs) -{ - int st; - - if (!nvl) { - return (EFAULT); - } - - st = mms_mgmt_remove_cartridges(NULL, nvl, errs); - - return (st); -} - -static int -mmsadm_discover_local(nvlist_t *nvl, nvlist_t *errs) -{ - int st; - nvlist_t *drv_list = NULL; - nvlist_t *drv = NULL; - nvlist_t *mmdrvs = NULL; - nvlist_t *mm_drv = NULL; - char *val; - nvpair_t *nvp = NULL; - nvpair_t *mnvp = NULL; - char *fmt = "%-20s%-20s%-20s%-20s\n"; - char *sfmt = "%s\t%s\t%s\t%s\n"; - char *fmtp; - boolean_t all = B_FALSE; - boolean_t doscript = B_FALSE; - char *sn; - char *ty; - char *dv; - char *id; - - if (!nvl) { - return (EFAULT); - } - - nvlist_lookup_boolean_value(nvl, "all", &all); - nvlist_lookup_boolean_value(nvl, "script", &doscript); - - /* probe /dev/rmt */ - st = mgmt_find_local_drives(&drv_list); - if (st != 0) { - return (st); - } - - nvp = nvlist_next_nvpair(drv_list, nvp); - if (nvp == NULL) { - printf("No drives attached to this system.\n"); - nvlist_free(drv_list); - return (0); - } - - /* print header */ - if (!doscript) { - fmtp = fmt; - /* LINTED [E_SEC_PRINTF_VAR_FMT] */ - printf(fmtp, "DEVICE", "TYPE", "SERIALNO", "MMSID"); - /* LINTED [E_SEC_PRINTF_VAR_FMT] */ - printf(fmtp, "======", "====", "========", "====="); - } else { - fmtp = sfmt; - } - - /* get list of drives from MM, if any */ - mms_mgmt_list_drives(NULL, nvl, errs, &mmdrvs); - - do { - sn = ""; - id = ""; - dv = ""; - ty = ""; - - st = nvpair_value_nvlist(nvp, &drv); - if (st != 0) { - break; - } - - /* - * while serial number is the best way to look up - * devices, need an alternate if device is busy when - * we ran the probe. When filtering is enabled for - * listing drives, list only those attached to this - * system. Then we can do device name lookups. - */ - st = nvlist_lookup_string(drv, O_SERIALNO, &sn); - if (st == 0) { - while ((mnvp = nvlist_next_nvpair(mmdrvs, mnvp)) - != NULL) { - st = nvpair_value_nvlist(mnvp, &mm_drv); - if (st != 0) { - continue; - } - - st = nvlist_lookup_string(mm_drv, - "DriveSerialNum", &val); - if (st != 0) { - continue; - } - if (strcmp(sn, val) == 0) { - st = nvlist_lookup_string(mm_drv, - "DriveName", &val); - if (st == 0) { - id = val; - } - } - } - } - /* reset, lookup failures shouldn't be reported to user */ - st = 0; - - if (!all && (id[0] != '\0')) { - continue; - } - - nvlist_lookup_string(drv, O_TYPE, &ty); - nvlist_lookup_string(drv, O_DEVPATH, &dv); - - /* LINTED [E_SEC_PRINTF_VAR_FMT] */ - printf(fmtp, dv, ty, sn, id); - - } while ((nvp = nvlist_next_nvpair(drv_list, nvp)) != NULL); - - return (0); -} - -static int -mmsadm_passwd(nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char *namep = NULL; - char *pathp = NULL; - - if (!nvl) { - return (EFAULT); - } - - st = nvlist_lookup_string(nvl, O_NAME, &namep); - if (st != 0) { - if (errs) { - nvlist_add_int32(errs, "application name", st); - } - return (st); - } - - nvlist_lookup_string(nvl, "passwordfile", &pathp); - - st = mms_mgmt_get_pwd(pathp, O_MMPASS, setphrases, nvl, errs); - if (st != 0) { - if (errs) { - nvlist_add_int32(errs, O_MMPASS, st); - } - return (st); - } - - st = mms_mgmt_set_pass(NULL, nvl, errs); - - return (st); -} - -static int -mmsadm_showreq(nvlist_t *nvl, nvlist_t *errs) /* ARGSUSED */ -{ - int st; - nvlist_t *reqs = NULL; - - st = mms_mgmt_show_requests(NULL, nvl, &reqs); - if (st != 0) { - return (st); - } - - st = print_list_values("operator request", reqs, NULL, 0, B_FALSE); - - return (st); -} - -static int -mmsadm_accept(nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char *reqID = NULL; - char *resp = NULL; - - if (!nvl) { - return (EFAULT); - } - - st = nvlist_lookup_string(nvl, O_NAME, &reqID); - if (!reqID) { - nvlist_add_int32(errs, O_NAME, st); - return (st); - } - - nvlist_lookup_string(nvl, O_RESPTXT, &resp); - - st = mms_mgmt_accept_request(NULL, reqID, resp); - - return (st); -} - -static int -mmsadm_reject(nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char *reqID = NULL; - char *resp = NULL; - - if (!nvl) { - return (EFAULT); - } - - st = nvlist_lookup_string(nvl, O_NAME, &reqID); - if (!reqID) { - nvlist_add_int32(errs, O_NAME, st); - return (st); - } - - nvlist_lookup_string(nvl, O_RESPTXT, &resp); - - st = mms_mgmt_reject_request(NULL, reqID, resp); - - return (st); -} - -static int -confirm_delete(char *objname, boolean_t force) -{ - char yesno = 'n'; - - if (!objname) { - return (MMS_MGMT_NOARG); - } - - if ((!isatty(STDIN_FILENO)) && !force) { - fprintf(stderr, - "To delete %s from a script, please use the -f option.\n", - objname); - return (1); - } - - fprintf(stdout, - "Do you really want to delete %s? ([y]|n)", - objname); - - yesno = fgetc(stdin); - if ((yesno == 'y') || (yesno == 'Y') || (yesno == '\n')) { - return (0); - } - - fprintf(stdout, "\n%s will not be deleted.\n", objname); - - return (1); -} - -static int -mmsadm_label(nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char *app = NULL; - char *pathp = NULL; - - if (!nvl) { - return (EINVAL); - } - - nvlist_lookup_string(nvl, "passwordfile", &pathp); - st = nvlist_lookup_string(nvl, O_APPS, &app); - if (st != 0) { - if (st == ENOENT) { - st = MMS_MGMT_ERR_REQUIRED; - } - MGMT_ADD_ERR(errs, O_APPS, st); - - return (st); - } - - if ((pathp) || (strcasecmp(app, "MMS") != 0)) { - st = mms_mgmt_get_pwd(pathp, O_MMPASS, getphrases, - nvl, errs); - if (st != 0) { - return (st); - } - } - - st = mms_mgmt_label_multi(NULL, nvl, errs); - - return (st); -} - -static int -mmsadm_mount(nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char *val = NULL; - char *app = NULL; - char *pathp = NULL; - - if (!nvl) { - return (EINVAL); - } - - nvlist_lookup_string(nvl, "passwordfile", &pathp); - st = nvlist_lookup_string(nvl, O_APPS, &app); - if (st != 0) { - if (st == ENOENT) { - st = MMS_MGMT_ERR_REQUIRED; - } - MGMT_ADD_ERR(errs, O_APPS, st); - - return (st); - } - - if ((pathp) || (strcasecmp(app, "MMS") != 0)) { - st = mms_mgmt_get_pwd(pathp, O_MMPASS, getphrases, - nvl, errs); - if (st != 0) { - return (st); - } - } - - st = mms_mgmt_mount_vol(NULL, nvl, errs); - - if (st == 0) { - st = nvlist_lookup_string(nvl, "mountdev", &val); - } - - if (st == 0) { - printf("Mount successful on device %s\n", val); - fflush(stdout); - } - - return (st); -} - -static int -mmsadm_unmount(nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char *app = NULL; - char *pathp = NULL; - - if (!nvl) { - return (EINVAL); - } - - nvlist_lookup_string(nvl, "passwordfile", &pathp); - st = nvlist_lookup_string(nvl, O_APPS, &app); - if (st != 0) { - if (st == ENOENT) { - st = MMS_MGMT_ERR_REQUIRED; - } - MGMT_ADD_ERR(errs, O_APPS, st); - - return (st); - } - - if ((pathp) || (strcasecmp(app, "MMS") != 0)) { - st = mms_mgmt_get_pwd(pathp, O_MMPASS, getphrases, - nvl, errs); - if (st != 0) { - return (st); - } - } - - st = mms_mgmt_unmount_vol(nvl, errs); - - return (st); -} diff --git a/usr/src/cmd/mms/mgmt/adm/i386/Makefile b/usr/src/cmd/mms/mgmt/adm/i386/Makefile deleted file mode 100644 index 732f299da3..0000000000 --- a/usr/src/cmd/mms/mgmt/adm/i386/Makefile +++ /dev/null @@ -1,27 +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 $(SRC)/cmd/Makefile.cmd -include ../Makefile.com diff --git a/usr/src/cmd/mms/mgmt/adm/sparc/Makefile b/usr/src/cmd/mms/mgmt/adm/sparc/Makefile deleted file mode 100644 index 732f299da3..0000000000 --- a/usr/src/cmd/mms/mgmt/adm/sparc/Makefile +++ /dev/null @@ -1,27 +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 $(SRC)/cmd/Makefile.cmd -include ../Makefile.com diff --git a/usr/src/cmd/mms/mgmt/init/Makefile b/usr/src/cmd/mms/mgmt/init/Makefile deleted file mode 100644 index 3a3c393869..0000000000 --- a/usr/src/cmd/mms/mgmt/init/Makefile +++ /dev/null @@ -1,28 +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. -# - -SUBDIRS = $(MACH) - -include ../../Makefile.subdirs diff --git a/usr/src/cmd/mms/mgmt/init/Makefile.com b/usr/src/cmd/mms/mgmt/init/Makefile.com deleted file mode 100644 index 45e545a8d3..0000000000 --- a/usr/src/cmd/mms/mgmt/init/Makefile.com +++ /dev/null @@ -1,78 +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. -# - -SRCS = mmsinit.c - -.KEEP_STATE: -.SUFFIXES: - -PROG = mmsinit - -OBJS = $(SRCS:%.c=%.o) -lint_SRCS = $(SRCS:%.c=%.ln) - -include $(SRC)/cmd/Makefile.cmd - -ACSLSH = $(CLOSED)/lib/mms/h - -CFLAGS += $(CTF_FLAGS) $(CC_VERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -D_REENTRANT -CPPFLAGS += -I. -I../common -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/lib/mms/mms/common -I$(SRC)/lib/mms/mgmt/common -CPPFLAGS += -I$(ACSLSH) - -LDLIBS += -lc -lnvpair -LDLIBS += -L$(SRC)/lib/mms/mms/$(MACH) -lmms -R/usr/lib -LDLIBS += -L$(SRC)/lib/mms/mgmt/$(MACH) -lmmsadm -R/usr/lib/mms - -.NO_PARALLEL: -.PARALLEL: $(OBJS) $(lint_SRCS) - -C99MODE= $(C99_ENABLE) - -all: $(PROG) - -$(PROG): $(OBJS) - $(LINK.c) $(OBJS) -o $@ $(LDLIBS) - $(CTFMERGE) -L VERSION -o $@ $(OBJS) - $(POST_PROCESS) - -%.o: ../common/%.c - $(COMPILE.c) $< - $(CTFCONVERT_O) - -clean: - $(RM) $(OBJS) $(lint_SRCS) - -lint: $(lint_SRCS) - -%.ln: ../common/%.c - $(LINT.c) -c $< - -install: all $(ROOTBIN)/$(PROG) - -include $(SRC)/cmd/Makefile.targ diff --git a/usr/src/cmd/mms/mgmt/init/common/mmsinit.c b/usr/src/cmd/mms/mgmt/init/common/mmsinit.c deleted file mode 100644 index 08093a9fc7..0000000000 --- a/usr/src/cmd/mms/mgmt/init/common/mmsinit.c +++ /dev/null @@ -1,339 +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. - */ - -#include <stdlib.h> -#include <getopt.h> -#include <stdio.h> -#include <strings.h> -#include <ctype.h> -#include <errno.h> -#include <libnvpair.h> -#include <fcntl.h> - -#include "mms_trace.h" -#include "mms_mgmt.h" -#include "mgmt_util.h" -#include "mms_cfg.h" - -extern char *optarg; -extern int optind, opterr, optopt; - -static char *_SrcFile = __FILE__; - -#ifdef MMS_VAR_CFG -static char *usemsg = \ -"Usage: \n\ -\tmmsinit [-?|-h]\n\ -\tmmsinit -t server -o options [-P passwordfile]\n\ -\tmmsinit -t client -M serverhost[:port] [-P passwordfile]\n\ -\tmmsinit -u\n"; -#else -static char *usemsg = \ -"Usage: \n\ -\tmmsinit [-h|-?]\n\ -\tmmsinit -t server -o options [-P passwordfile]\n"; -#endif /* MMS_VAR_CFG */ - -#ifdef MMS_VAR_CFG -static int uflag = 0; -#endif /* MMS_VAR_CFG */ -static int hflag = 0; - -static char *mmsinit_opts = ":M:P:t:o:fuv?"; - -static char *passphrases[2] = { - "Enter MMS Administrative password: ", - "Re-enter password: " -}; - - -static struct option mmsinit_long[] = { - {"mmhost", required_argument, NULL, 'M'}, - {"passfile", required_argument, NULL, 'P'}, - {"type", required_argument, NULL, 't'}, - {"force", no_argument, NULL, 'f'}, - {"options", required_argument, NULL, 'o'}, - {"uninit", no_argument, NULL, 'u'}, - {"verbose", no_argument, NULL, 'v'}, - {"help", no_argument, NULL, '?'}, - {NULL, 0, NULL, 0} -}; - -static void usage(void); - -int -main(int argc, char **argv) -{ - int st = 0; - int mmsind = 0; - char c; - char *mmtype = "server"; -#ifdef MMS_VAR_CFG - char *mmhost = "localhost"; - char *mmport = "7151"; - char *bufp; - boolean_t force = B_FALSE; -#endif - char *pwfile = NULL; - nvlist_t *mmnv = NULL; - nvlist_t *errlist = NULL; - char buf[2048]; - - (void) mms_trace_open("/var/log/mms/mmsinit.log", MMS_ID_CLI, - MMS_SEV_INFO, 5 * MEGA, 0, 0); - (void) mms_trace_filter(MMS_SEV_DEVP); - mms_trace(MMS_DEBUG, "mmsinit started ###############################"); - if (argc < 2) { - st = 1; - } - - memset(buf, 0, sizeof (buf)); - - st = nvlist_alloc(&mmnv, NV_UNIQUE_NAME, 0); - if (st != 0) { - return (st); - } - - while (st == 0) { - c = getopt_clip(argc, argv, mmsinit_opts, mmsinit_long, - &mmsind); - - /* catch end-of-args */ - if (c == -1) { - break; - } - - switch (c) { - case 0: - /* flag set by getopt */ - break; - case 't': - mmtype = optarg; -#ifdef MMS_VAR_CFG - if (*mmtype == 'c') { - st = nvlist_add_string(mmnv, O_OBJTYPE, - "client"); - } else if (*mmtype == 's') { - st = nvlist_add_string(mmnv, O_OBJTYPE, - "server"); - } else { - st = 1; - fprintf(stderr, "Invalid type: %s\n", - mmtype); - } -#else - if (*mmtype != 's') { - fprintf(stderr, - "Type must be 'server'\n"); - st = 1; - } -#endif /* MMS_VAR_CFG */ - break; -#ifdef MMS_VAR_CFG - case 'f': - force = B_TRUE; - break; - case 'M': - mmhost = optarg; - bufp = strchr(mmhost, ':'); - if (bufp == NULL) { - mmport = MMS_DEF_MMPORT; - } else { - *bufp = '\0'; - mmport = ++bufp; - } - - if (strcmp(mmhost, "localhost") == 0) { - gethostname(buf, sizeof (buf)); - - st = nvlist_add_string(mmnv, O_MMHOST, - buf); - } else { - st = nvlist_add_string(mmnv, O_MMHOST, - mmhost); - } - if (st != 0) { - break; - } - - st = nvlist_add_string(mmnv, O_MMPORT, mmport); - - break; -#endif /* MMS_VAR_CFG */ - case 'P': - pwfile = optarg; - break; - case 'o': - st = mgmt_opt_to_var(optarg, B_FALSE, mmnv); - - break; -#ifdef MMS_VAR_CFG - case 'u': - uflag++; - break; -#endif /* MMS_VAR_CFG */ - case '?': - hflag++; - break; - case ':': - fprintf(stderr, - "Option %s requires an operand\n", - argv[optind-1]); - st = 1; - break; - default: - st = 1; - break; - } - } - - if ((st != 0) || hflag) { - usage(); - goto done; - } - -#ifdef MMS_VAR_CFG - if (uflag) { - char yesno = 'n'; - - /* remove everything except the DB */ - if ((!isatty(STDIN_FILENO)) && !force) { - fprintf(stderr, - "To uninitialize from a script, " - "please use the -f option.\n"); - st = 1; - goto done; - } - fprintf(stdout, - "Do you really want to stop using MMS services on " - "this system? [y|n] "); - - yesno = fgetc(stdin); - if ((yesno == 'y') || (yesno == 'Y')) { - st = mms_mgmt_uninitialize(); - } else { - fprintf(stdout, - "Uninitialize will not be performed.\n"); - } - goto done; - } - - /* check to see if this host has already been initialized first */ - st = mms_cfg_getvar(MMS_CFG_CONFIG_TYPE, buf); - if ((st == 0) && (buf[0] != '\0')) { - st = EALREADY; - goto done; - } else { - st = 0; - } - - if (!mmtype) { - fprintf(stdout, - "Either -t client or -t server must be specified.\n"); - st = 1; - goto done; - } -#endif /* MMS_VAR_CFG */ - - st = nvlist_add_string(mmnv, O_OBJTYPE, mmtype); - - /* Prompt the user for the MM password or read it from a file */ - st = mms_mgmt_get_pwd(pwfile, O_MMPASS, passphrases, mmnv, errlist); - if (st != 0) { - fprintf(stderr, "%s\n", mms_mgmt_get_errstr(st)); - goto done; - } - -#ifdef MMS_VAR_CFG - if (*mmtype == 's') { - /* set mmhost to localhost */ - gethostname(buf, sizeof (buf)); - nvlist_add_string(mmnv, O_MMHOST, buf); - } -#endif /* MMS_VAR_CFG */ - - if (st != 0) { - goto done; - } - - st = mms_mgmt_init_host(mmnv, &errlist); - -done: - if (st != 0) { - if (st == EOPNOTSUPP) { - fprintf(stderr, - "Cannot change MMS host type. To change "); - fprintf(stderr, - "this value, first run 'mmsinit -u'.\n"); - } else if (st == EALREADY) { - fprintf(stderr, - "\nMMS already initialized on this system.\nTo "); - fprintf(stderr, - "change options, use the 'mmsadm set' command.\n"); - } else if (errlist) { - nvpair_t *nv = nvlist_next_nvpair(errlist, NULL); - char *nvo = NULL; - int nvl = 0; - const char *errmsg = NULL; - - while (nv != NULL) { - nvo = nvpair_name(nv); - (void) nvpair_value_int32(nv, &nvl); - errmsg = mms_mgmt_get_errstr(nvl); - if (errmsg != NULL) { - fprintf(stderr, "\t%s\t%s\n", nvo, - errmsg); - } else { - fprintf(stderr, "\t%s\terrno = %d\n", - nvo, nvl); - } - - nv = nvlist_next_nvpair(errlist, nv); - } - } - } - - if (errlist) { - nvlist_free(errlist); - } - - if (mmnv) { - nvlist_free(mmnv); - } - - if (st != 0) { - fprintf(stderr, "mmsinit exiting with error %d\n", st); - } - - mms_trace_close(); - - return (st); -} - -static void -usage(void) -{ - printf("%s\n", usemsg); -} diff --git a/usr/src/cmd/mms/mgmt/init/i386/Makefile b/usr/src/cmd/mms/mgmt/init/i386/Makefile deleted file mode 100644 index 732f299da3..0000000000 --- a/usr/src/cmd/mms/mgmt/init/i386/Makefile +++ /dev/null @@ -1,27 +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 $(SRC)/cmd/Makefile.cmd -include ../Makefile.com diff --git a/usr/src/cmd/mms/mgmt/init/sparc/Makefile b/usr/src/cmd/mms/mgmt/init/sparc/Makefile deleted file mode 100644 index 732f299da3..0000000000 --- a/usr/src/cmd/mms/mgmt/init/sparc/Makefile +++ /dev/null @@ -1,27 +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 $(SRC)/cmd/Makefile.cmd -include ../Makefile.com diff --git a/usr/src/cmd/mms/mgmt/mnt/Makefile b/usr/src/cmd/mms/mgmt/mnt/Makefile deleted file mode 100644 index 3a3c393869..0000000000 --- a/usr/src/cmd/mms/mgmt/mnt/Makefile +++ /dev/null @@ -1,28 +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. -# - -SUBDIRS = $(MACH) - -include ../../Makefile.subdirs diff --git a/usr/src/cmd/mms/mgmt/mnt/Makefile.com b/usr/src/cmd/mms/mgmt/mnt/Makefile.com deleted file mode 100644 index 8c79068090..0000000000 --- a/usr/src/cmd/mms/mgmt/mnt/Makefile.com +++ /dev/null @@ -1,81 +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. -# - -SRCS = mmsmnt.c - -.KEEP_STATE: -.SUFFIXES: - -PROG = mmsmnt - -OBJS = $(SRCS:%.c=%.o) -lint_SRCS = $(SRCS:%.c=%.ln) - -include $(SRC)/cmd/Makefile.cmd - -ACSLSH = $(CLOSED)/lib/mms/h - -FILEMODE = 4755 - -CFLAGS += $(CTF_FLAGS) $(CC_VERBOSE) -CFLAGS += -D_POSIX_PTHREAD_SEMANTICS - -CPPFLAGS += -DMMS_OPENSSL -D_REENTRANT -CPPFLAGS += -I. -I../common -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/lib/mms/mms/common -I$(SRC)/lib/mms/mgmt/common -CPPFLAGS += -I$(ACSLSH) - -LDLIBS += -lc -lnvpair -LDLIBS += -L$(SRC)/lib/mms/mms/$(MACH) -lmms -LDLIBS += -L$(SRC)/lib/mms/mgmt/$(MACH) -lmmsadm -R/usr/lib/mms - -.NO_PARALLEL: -.PARALLEL: $(OBJS) $(lint_SRCS) - -C99MODE= $(C99_ENABLE) - -all: $(PROG) - -$(PROG): $(OBJS) - $(LINK.c) $(OBJS) -o $@ $(LDLIBS) - $(CTFMERGE) -L VERSION -o $@ $(OBJS) - $(POST_PROCESS) - -%.o: ../common/%.c - $(COMPILE.c) $< - $(CTFCONVERT_O) - -clean: - $(RM) $(OBJS) $(lint_SRCS) - -lint: $(lint_SRCS) - -%.ln: ../common/%.c - $(LINT.c) -c $< - -install: all $(ROOTBIN)/$(PROG) - -include $(SRC)/cmd/Makefile.targ diff --git a/usr/src/cmd/mms/mgmt/mnt/common/mmsmnt.c b/usr/src/cmd/mms/mgmt/mnt/common/mmsmnt.c deleted file mode 100644 index 14471ebccf..0000000000 --- a/usr/src/cmd/mms/mgmt/mnt/common/mmsmnt.c +++ /dev/null @@ -1,683 +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 <unistd.h> -#include <stdlib.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <libgen.h> -#include <errno.h> -#include <door.h> -#include <pthread.h> -#include <signal.h> -#include <dirent.h> -#include <string.h> -#include <rpc/xdr.h> -#include <stdarg.h> - -#include <libnvpair.h> -#include "mms.h" -#include "mms_mgmt.h" -#include "mgmt_util.h" - -/* - * MMS Mount service daemon. - * - * Uses the "door" interface for inter-process communication. - */ - -/* structure for session list */ -typedef struct mnt_sess { - void *session; - char *volname; - char *library; - char *cartridge; - char *app; - char *localdev; - struct mnt_sess *next; -} mnt_sess_t; - -/* Function declarations */ -static void *handle_signal(void *arg); -static void mntsvr(void *cookie, char *argp, size_t arg_size, door_desc_t *dp, - uint_t n_desc); -static void log_err(const char *errpfx, const char *msg); -static void do_log_err(char *errpfx, char *fmt, ...); -static void * exit_idle(void *arg); -static int mount_vol(mmsmnt_arg_t *in); -static void incr_active(void); -static void decr_active(void); -static void add_session(mnt_sess_t *in); -static void remove_session(mmsmnt_arg_t *in, mnt_sess_t **sess); -static int unmount_vol(mmsmnt_arg_t *in); -static void free_sess(mnt_sess_t *in); - -/* Globals */ -boolean_t do_daemon = B_TRUE; -pthread_attr_t pattr; -pthread_mutex_t glock = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t quitcond = PTHREAD_COND_INITIALIZER; -boolean_t stopserver = B_FALSE; -char *ourdoor = "/var/run/mmsmnt_door"; -char *ourlock = "/var/run/mmsmnt_door_lk"; -mnt_sess_t *sess_list = NULL; - -/* session list lock */ -pthread_rwlock_t sesslk = PTHREAD_RWLOCK_INITIALIZER; - -/* mutex and condition for activity */ -pthread_mutex_t mntmutex = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t mntcond = PTHREAD_COND_INITIALIZER; -int active = 0; - -/* error log file */ -static char *errLog = "/var/log/mms/mmsmnt.log"; -FILE *errFilep = stderr; -pid_t mntd_pid = -1; -static char *timefmt = "%e %b %Y %T %Z"; - -/* - * This mount server process typically runs as an independent - * daemon. For debugging purposes, use the "-d" option to run - * the server in the foreground. "-d" is only available if the - * server has been compiled with -DDEBUG. - * - */ -int -main(int argc, char *argv[]) -{ - int st; - char c; - pid_t pid; - int nullfd; - sigset_t mask; - int doorfd = -1; - int lockfd = -1; - flock64_t flk; - pthread_t tid; - int logfd = -1; - char *errpfx = "main"; - - while ((c = getopt(argc, argv, "d")) != -1) { - switch (c) { - case 'd': - do_daemon = B_FALSE; - break; - default: - /* ignore invalid args */ - break; - } - } - - /* make sure we didn't inherit a weird creation mask */ - (void) umask(0); - - /* close any inherited file descriptors */ - closefrom(STDERR_FILENO + 1); - - nullfd = open("/dev/null", O_RDWR); - - /* and disassociate from our parent */ - if (do_daemon) { - pid = fork(); - if (pid < 0) { - (void) printf("Cannot fork process, exiting\n"); - exit(1); - } else if (pid > 0) { - /* parent exits now */ - exit(0); - } - /* become session leader */ - (void) setsid(); - - /* set out working directory to something rational */ - (void) chdir("/var/mms/cores"); - } - - /* block most signals. We only care about the die now ones */ - (void) sigfillset(&mask); - - /* - * if we're in debug mode, most likely in the debugger so - * allow SIGINT - */ - if (!do_daemon) { - (void) sigdelset(&mask, SIGINT); - } - - (void) pthread_sigmask(SIG_BLOCK, &mask, NULL); - - if (do_daemon) { - /* - * One last fork to make sure we're really really - * not going to inherit a controlling terminal... - */ - pid = fork(); - if (pid != 0) { - exit(0); - }; - - /* we're not using stdin/out/err */ - dup2(nullfd, STDIN_FILENO); - dup2(nullfd, STDOUT_FILENO); - dup2(nullfd, STDERR_FILENO); - } else { - /* assign stderr to stdout */ - dup2(STDOUT_FILENO, STDERR_FILENO); - } - - /* initialize log - defaults to stderr if log can't be opened */ - mntd_pid = getpid(); - logfd = open64(errLog, O_RDWR|O_CREAT, 0744); - if (logfd != -1) { - errFilep = fdopen(logfd, "a+"); - } - - do_log_err(errpfx, "mmsmntd starting"); - - mms_trace_open(errLog, MMS_ID_CLI, MMS_SEV_NOTICE, 5 * MEGA, 0, 0); - - /* all threads we create should be detached */ - (void) pthread_attr_init(&pattr); - (void) pthread_attr_setdetachstate(&pattr, PTHREAD_CREATE_DETACHED); - - /* Set up a signal handling thread */ - (void) pthread_create(&tid, &pattr, handle_signal, NULL); - - /* start the activity thread */ - pthread_create(&tid, &pattr, exit_idle, NULL); - - /* lock so multiple processes don't start */ - lockfd = open(ourlock, O_WRONLY|O_CREAT, 0655); - if (lockfd == -1) { - do_log_err(errpfx, "Could not lock %s", ourdoor); - return (errno); - } - - memset(&flk, 0, sizeof (flock64_t)); - flk.l_type = F_WRLCK; - flk.l_whence = SEEK_SET; - - st = fcntl(lockfd, F_SETLK64, &flk); - if (st == -1) { - if (errno == EAGAIN) { - /* already locked */ - do_log_err(errpfx, "mmsmnt process already running"); - st = 0; - } - goto done; - } - - /* open the doors! */ - doorfd = door_create(mntsvr, NULL, 0); - if (doorfd == -1) { - st = -1; - goto done; - } - - /* - * recreate the door itself. If a previous process exited - * abnormally (core dump, whatever), the door won't be revoked - * and we won't be able to start a new process. Yet another - * weird door-ism. The locking above should prevent a door - * from being removed out from under a running process. - */ - unlink(ourdoor); - st = mknod(ourdoor, 0655, 0); - if (st == -1) { - st = errno; - do_log_err(errpfx, "Could not create door."); - goto done; - } - - st = fattach(doorfd, ourdoor); - if (st == -1) { - st = errno; - if (st == EBUSY) { - /* shouldn't happen - another process got here first */ - st = 0; - } else { - do_log_err(errpfx, "Could not attach to door %d", st); - } - goto done; - } - - /* the mntsvr function now does all the work. Sit and wait to exit */ - (void) pthread_mutex_lock(&glock); - while (!stopserver) { - (void) pthread_cond_wait(&quitcond, &glock); - } - (void) pthread_mutex_unlock(&glock); - -done: - do_log_err(errpfx, "mmsmnt exiting with status %d", st); - - /* don't let any more calls in */ - door_revoke(doorfd); - - if (lockfd != -1) { - close(lockfd); - } - - /* all done */ - return (st); -} - -/* exit cleanly if we're told to stop */ -static void * -handle_signal(void *arg) /* ARGSUSED */ -{ - int count; - int st = 0; -#ifndef __lint - int signum; -#endif /* __lint */ - sigset_t mask; - - (void) sigemptyset(&mask); - (void) sigaddset(&mask, SIGINT); - (void) sigaddset(&mask, SIGQUIT); - (void) sigaddset(&mask, SIGTERM); - - (void) pthread_sigmask(SIG_UNBLOCK, &mask, NULL); - - /* - * wait forever, or until sigwait fails 10 times. sigwait() - * shouldn't fail, but we don't want to be looping frantically - * if it does. - */ - for (count = 0; count < 10; count++) { - /* - * for reasons I don't understand, lint is unhappy with - * the sigwait() function declaration in signal.h. - */ -#ifndef __lint - st = sigwait(&mask, &signum); -#endif - if (st == 0) { - break; - } - } - - if (st == 0) { - /* we've been asked to exit */ - (void) pthread_mutex_lock(&glock); - stopserver = B_TRUE; - (void) pthread_mutex_unlock(&glock); - (void) pthread_cond_broadcast(&quitcond); - } - - return (NULL); -} - -/* main dispatch function */ -static void -mntsvr( - void *cookie, /* ARGSUSED */ - char *argp, - size_t arg_size, /* ARGSUSED */ - door_desc_t *dp, - uint_t n_desc) -{ - - int st; - char *errpfx = "mntsvr"; - /* LINTED [E_BAD_PTR_CAST_ALIGN] */ - mmsmnt_arg_t *inarg = (mmsmnt_arg_t *)argp; - - incr_active(); - - if (argp == NULL) { - st = EINVAL; - do_log_err(errpfx, "No arguments received"); - goto done; - } - - if (inarg->op == 1) { - st = mount_vol(inarg); - } else if (inarg->op == 2) { - st = unmount_vol(inarg); - } else { - st = EINVAL; - } - -done: - if (st != 0) { - do_log_err(errpfx, "Completed task type = %d, status = %d", - inarg->op, st); - } - - inarg->st = st; - - decr_active(); - - door_return((char *)inarg, arg_size, NULL, 0); -} - -static int -unmount_vol(mmsmnt_arg_t *in) -{ - int st; - mnt_sess_t *old = NULL; - void *response = NULL; - char tid[64]; - char cmd[8192]; - - if (!in) { - return (EINVAL); - } - - remove_session(in, &old); - if (!old) { - /* nothing to do, just return */ - return (0); - } - - mms_gen_taskid(tid); - snprintf(cmd, sizeof (cmd), - "unmount task['%s'] type[VOLUME] " - "match[and (streq(LIBRARY.'LibraryName' '%s') " - "streq(CARTRIDGE.'CartridgePCL' '%s'))] ", - tid, old->library, old->cartridge); - if (in->cmd[0] != '\0') { - strlcat(cmd, in->cmd, sizeof (cmd)); - } - strlcat(cmd, ";", sizeof (cmd)); - - /* use existing session to unmount */ - st = mms_mgmt_send_cmd(old->session, "", cmd, "unmount volume", - &response); - - free_sess(old); - - decr_active(); - - return (st); -} - -static void -add_session(mnt_sess_t *in) -{ - if (!in) { - return; - } - - pthread_rwlock_wrlock(&sesslk); - in->next = sess_list; - sess_list = in; - pthread_rwlock_unlock(&sesslk); -} - -static void -free_sess(mnt_sess_t *in) -{ - if (!in) { - return; - } - - if (in->volname) { - free(in->volname); - } - - if (in->cartridge) { - free(in->cartridge); - } - - if (in->library) { - free(in->library); - } - - if (in->session) { - mms_goodbye(in->session, 0); - } - - free(in); -} - -static int -mount_vol(mmsmnt_arg_t *in) -{ - int st; - mnt_sess_t *new = NULL; - char *val; - void *sess = NULL; - void *response = NULL; - nvlist_t *mntattrs = NULL; - nvpair_t *nvp = NULL; - nvlist_t *volattrs = NULL; - char *app = NULL; - char *inst = NULL; - char *pass = NULL; - - if ((!in) || (in->cmd[0] == '\0')) { - return (EINVAL); - } - - incr_active(); - - if (in->app[0] != '\0') { - app = in->app; - } - if (in->inst[0] != '\0') { - inst = in->inst; - } - if (in->pass[0] != '\0') { - pass = in->pass; - } - - st = create_mm_clnt(app, inst, pass, NULL, &sess); - if (st != 0) { - goto done; - } - - new = calloc(1, sizeof (mnt_sess_t)); - if (new == NULL) { - st = ENOMEM; - goto done; - } - new->volname = strdup(in->volname); - new->cartridge = strdup(in->cartridge); - new->library = strdup(in->library); - - st = mms_mgmt_send_cmd(sess, "", in->cmd, "mount volume", &response); - if (st == 0) { - st = mmp_get_nvattrs("VolumeName", B_FALSE, response, - &mntattrs); - mms_free_rsp(response); - } - if (st != 0) { - goto done; - } - - new->session = sess; - - nvp = nvlist_next_nvpair(mntattrs, NULL); - if (nvp == NULL) { - /* should never happen! */ - st = ENOENT; - goto done; - } - - st = nvpair_value_nvlist(nvp, &volattrs); - if (st != 0) { - goto done; - } - - st = nvlist_lookup_string(volattrs, "MountLogicalHandle", &val); - if (st != 0) { - goto done; - } - new->localdev = strdup(val); - strlcat(in->devname, val, sizeof (in->devname)); - - add_session(new); - -done: - if (st != 0) { - if (sess) { - mms_goodbye(sess, 0); - new->session = NULL; - } - if (new) { - free_sess(new); - } - decr_active(); - } - - return (st); - -} - -static void -remove_session(mmsmnt_arg_t *in, mnt_sess_t **sess) -{ - mnt_sess_t *ent; - mnt_sess_t *prev = NULL; - - *sess = NULL; - - pthread_rwlock_wrlock(&sesslk); - ent = sess_list; - - /* match on devname if available, else look for cartridge/library */ - while (ent != NULL) { - if (in->devname[0] != '\0') { - if (strcmp(ent->localdev, in->devname) == 0) { - break; - } - } - if ((strcmp(ent->library, in->library) == 0) && - (strcmp(ent->cartridge, in->cartridge) == 0)) { - break; - } - prev = ent; - ent = ent->next; - } - - if (ent) { - if (!prev) { - /* first on list */ - sess_list = ent->next; - } else { - prev->next = ent->next; - } - *sess = ent; - } - pthread_rwlock_unlock(&sesslk); -} - -static void -log_err( - const char *errpfx, - const char *msg) -{ - char timbuf[MAXPATHLEN]; - time_t logtime; - char *pfxp = (char *)errpfx; - struct tm *tm = NULL; - - if (msg == NULL) { - return; - } - - if (pfxp == NULL) { - pfxp = ""; - } - - logtime = time(NULL); - tm = localtime(&logtime); - (void) strftime(timbuf, sizeof (timbuf), timefmt, tm); - (void) fprintf(errFilep, "%s [%ld] %s: %s\n", timbuf, mntd_pid, - pfxp, msg); - (void) fflush(errFilep); -} - -static void -do_log_err(char *errpfx, char *fmt, ...) -{ - va_list ap; - char buf[2048]; - - va_start(ap, fmt); - /* LINTED [E_SEC_PRINTF_VAR_FMT] */ - vsnprintf(buf, sizeof (buf), fmt, ap); - va_end(ap); - - log_err(errpfx, buf); -} - -static void -incr_active(void) -{ - pthread_mutex_lock(&mntmutex); - active++; - pthread_cond_signal(&mntcond); - pthread_mutex_unlock(&mntmutex); -} - -static void -decr_active(void) -{ - pthread_mutex_lock(&mntmutex); - active--; - pthread_cond_signal(&mntcond); - pthread_mutex_unlock(&mntmutex); -} - -/* - * function to shut down this server if we timeout waiting for requests - */ -static void * -exit_idle(void *arg) /* ARGSUSED */ -{ - struct timespec ts; - - /* sleep for 1 minute waiting for activity after we first start */ - ts.tv_sec = 60; - ts.tv_nsec = 0; - - nanosleep(&ts, NULL); - - pthread_mutex_lock(&mntmutex); - while (active > 0) { - pthread_cond_wait(&mntcond, &mntmutex); - - pthread_mutex_unlock(&mntmutex); - /* 1 minute of idle time, only */ - ts.tv_sec = 60; - ts.tv_nsec = 0; - - /* sleep for a little while */ - nanosleep(&ts, NULL); - pthread_mutex_lock(&mntmutex); - } - /* signal exit */ - pthread_mutex_unlock(&mntmutex); - sigsend(P_PID, getpid(), SIGTERM); - - return (NULL); -} diff --git a/usr/src/cmd/mms/mgmt/mnt/i386/Makefile b/usr/src/cmd/mms/mgmt/mnt/i386/Makefile deleted file mode 100644 index 732f299da3..0000000000 --- a/usr/src/cmd/mms/mgmt/mnt/i386/Makefile +++ /dev/null @@ -1,27 +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 $(SRC)/cmd/Makefile.cmd -include ../Makefile.com diff --git a/usr/src/cmd/mms/mgmt/mnt/sparc/Makefile b/usr/src/cmd/mms/mgmt/mnt/sparc/Makefile deleted file mode 100644 index 732f299da3..0000000000 --- a/usr/src/cmd/mms/mgmt/mnt/sparc/Makefile +++ /dev/null @@ -1,27 +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 $(SRC)/cmd/Makefile.cmd -include ../Makefile.com diff --git a/usr/src/cmd/mms/mm/Makefile b/usr/src/cmd/mms/mm/Makefile deleted file mode 100644 index 9912e2b4e7..0000000000 --- a/usr/src/cmd/mms/mm/Makefile +++ /dev/null @@ -1,28 +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. -# - -SUBDIRS = $(MACH) - -include ../Makefile.subdirs diff --git a/usr/src/cmd/mms/mm/Makefile.com b/usr/src/cmd/mms/mm/Makefile.com deleted file mode 100644 index ec954f9640..0000000000 --- a/usr/src/cmd/mms/mm/Makefile.com +++ /dev/null @@ -1,234 +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. -# - -.KEEP_STATE: -.SUFFIXES: - -PROG = mmsmm - -SRCS = mm.c mm_cfg.c mm_sql.c mm_mmp_sql.c mm_dmp_sql.c mm_lmp_sql.c \ - mm_util.c mm_notify.c mm_db.c mm_task.c mm_path.c mm_types.c \ - mm_msg.c mm_mmp_mount.c mm_mmp_cp.c -OBJS = $(SRCS:%.c=%.o) -lint_SRCS = $(SRCS:%.c=%.ln) - -include ../../../Makefile.cmd - -ROOTCMDDIR= $(ROOT)/lib/svc/method - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I. -I../common -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/lib/mms/mms/common -I$(SRC)/lib/mms/mms/common -CPPFLAGS += -I/usr/include/libxml2 -I/usr/postgres/8.3/include - -CFLAGS += $(CTF_FLAGS) $(CC_VERBOSE) -LDLIBS += -lc -lsocket -lnsl -luuid $(ZIGNORE) -LDLIBS += -lxml2 -lscf -L/usr/postgres/8.3/lib -lpq -R/usr/postgres/8.3/lib -LDLIBS += -L$(SRC)/lib/mms/mms/$(MACH) -lmms -R/usr/lib - -C99MODE= $(C99_ENABLE) - -# The mm database schema with database versions -DBMODS = ../common/mms_db - -# Generated mm database version header file -DBVER = ../common/mm_db_version.h - -# Print last database version found in mms_db -DBMODS_VER = nawk '{ line[NR] = $$0 } END { \ - i = 1; \ - last = 0; \ - while (i <= NR) { \ - if (line[i] ~ /^[^\#]/) { \ - rec = rec line[i] " " \ - } \ - if ((i+1 == NR || line[i+1] ~ /^[0-9]/) && length(rec)) { \ - n = index(rec, " "); \ - if (n == 0) { \ - n = index(rec, "\t"); \ - } \ - n = n - 1; \ - if (n < 2) { \ - exit 1 \ - } \ - rev = substr(rec, 0, n); \ - ver = substr(rev, 0, n - 1) + 0; \ - mod = substr(rev, n, n); \ - cmd = substr(rec, n + 1, length(rec)); \ - if (mod ~ /u/) { \ - last = ver; \ - } \ - rec = "" \ - } \ - i = i + 1 \ - } \ - if (last == 0) { \ - exit 1 \ - } \ - print last \ - }' - -# Check mm database version header file -DBVER_CHK = nawk '{ \ - if ($$0 ~ /\#define\tMM_DB_VERSION/) { \ - ver = $$3 \ - }} END { \ - if (length(ver) == 0 || ver < 1) { \ - exit 1 \ - }}' - -all: $(DBVER) .WAIT db_version_check .WAIT $(PROG) MKDIRS - -$(PROG): $(OBJS) - $(LINK.c) $(OBJS) -o $@ $(LDLIBS) - $(CTFMERGE) -L VERSION -o $@ $(OBJS) - $(POST_PROCESS) - -%.o: ../common/%.c - $(COMPILE.c) $< - $(CTFCONVERT_O) - -clean: - $(RM) $(OBJS) - -lint: $(lint_SRCS) - -%.ln: ../common/%.c - $(LINT.c) -c $< - -$(ROOTLIBSCSI)/%: % - $(INS.file) - -MMPATHS = $(ROOT)/etc/mms/config -MMTYPES = $(ROOT)/etc/mms/types -SSLCONF = $(ROOT)/var/mms/ssl/ca -MMDB = $(ROOT)/etc/mms/db -SCBIN = $(ROOT)/usr/bin -LIBSVC = $(ROOT)/lib/svc/method - -ETCPWD = $(ROOT)/etc/mms/passwd -VARHDL = $(ROOT)/var/mms/handle -LOGAPI = $(ROOT)/var/log/mms/api -LOGWCR = $(ROOT)/var/log/mms/wcr -SSLPUB = $(ROOT)/var/mms/ssl/pub -LOGDM = $(ROOT)/var/log/mms/dm -LOGLM = $(ROOT)/var/log/mms/lm -LOGMM = $(ROOT)/var/log/mms/mm -VARCORES = $(ROOT)/var/mms/cores - -FILES += $(MMPATHS)/mm_paths.xml -FILES += $(MMTYPES)/mm_types.xml -FILES += $(SCBIN)/mmsssl.sh -FILES += $(MMDB)/mms_db -FILES += $(SSLCONF)/mms_openssl.cnf - -install: all $(ROOTCMD) $(FILES) - -include ../../../Makefile.targ - -# Generate mm database version header file from mms_db file -$(DBVER): $(DBMODS) - -rm -f hdrs/mm_db_version.h - rm -f $(OBJ32)/mm.o $(OBJ32)/mm_db.o $(OBJ32)/mmsmm - rm -f $(OBJ64)/mm.o $(OBJ64)/mm_db.o $(OBJ64)/mmsmm - echo "#ifndef\t_MM_DB_VERSION_H" > $(DBVER) - echo "#define\t_MM_DB_VERSION_H" >> $(DBVER) - echo >> $(DBVER) - echo "/* Generated Database Version */" >> $(DBVER) - printf "#define\tMM_DB_VERSION " >> $(DBVER) - $(DBMODS_VER) < $(DBMODS) >> $(DBVER) - echo >> $(DBVER) - echo "#endif\t\t/* _MM_DB_VERSION_H */" >> $(DBVER) - -# Validate mm database version -db_version_check: - $(DBVER_CHK) < $(DBVER) - -$(MMPATHS): - $(INS.dir) - -$(MMTYPES): - $(INS.dir) - -$(MMDB): - $(INS.dir) - -$(SSLCONF): - $(INS.dir) - -$(MMPATHS)/% := FILEMODE = 0644 - -$(MMPATHS)/%: $(MMPATHS) ../common/% - $(INS.file) - -$(MMTYPES)/% := FILEMODE = 0644 - -$(MMTYPES)/%: $(MMTYPES) ../common/% - $(INS.file) - -$(SCBIN)/%: ../common/% - $(INS.file) - -$(SSLCONF)/% := FILEMODE = 0644 - -$(SSLCONF)/%: $(SSLCONF) ../common/% - $(INS.file) - -$(MMDB)/% := FILEMODE = 0644 - -$(MMDB)/%: $(MMDB) ../common/% - $(INS.file) - -$(ETCPWD): - $(INS.dir) - -$(VARHDL): - $(INS.dir) - -$(LOGAPI): - $(INS.dir) - -$(LOGWCR): - $(INS.dir) - -$(SSLPUB): - $(INS.dir) - -$(LOGDM): - $(INS.dir) - -$(LOGLM): - $(INS.dir) - -$(LOGMM): - $(INS.dir) - -$(VARCORES): - $(INS.dir) - - -MKDIRS: $(ETCPWD) $(VARHDL) $(LOGAPI) $(LOGWCR) $(SSLPUB) $(LOGDM) \ - $(LOGLM) $(LOGMM) $(VARCORES) diff --git a/usr/src/cmd/mms/mm/common/mm.c b/usr/src/cmd/mms/mm/common/mm.c deleted file mode 100644 index d268c7d9e9..0000000000 --- a/usr/src/cmd/mms/mm/common/mm.c +++ /dev/null @@ -1,5189 +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. - */ - - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> -#include <signal.h> -#include <unistd.h> -#include <syslog.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <pthread.h> -#include <pwd.h> -#include <unistd.h> -#include <sys/wait.h> -#include <mms_list.h> -#include <mms_parser.h> -#include <libgen.h> -#include <mms_trace.h> -#include <mms_strapp.h> -#include <netdb.h> -#include <mms_cores.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <sys/utsname.h> -#include <time.h> -#include <libscf.h> -#include "mm_db.h" -#include "mm.h" -#include "mm_util.h" -#include "mm_commands.h" -#include "mm_sql.h" -#include "mm_sql_impl.h" -#include "mm_task.h" -#include "mm_path.h" -#include "mm_db_version.h" -#include "mms_sock.h" -#include "mms_cfg.h" - -static char *_SrcFile = __FILE__; - -/* - * MM data - */ -int mm_exiting = 0; -int mm_refresh = 0; -static mm_data_t mm_data; -static mm_data_t *data = &mm_data; - -/* - * mm_signal_handler - * - * Parameters: - * -int signo - * - * This is the routine used to handle various signals - * - * Return Values: - * None - * - */ -static void -mm_signal_handler(int signo) -{ - switch (signo) { - case SIGINT: - mms_trace(MMS_DEVP, "SIGINT received"); - mm_exiting = 1; - break; - case SIGTERM: - mms_trace(MMS_DEVP, "SIGTERM received"); - mm_exiting = 1; - break; - case SIGHUP: - mms_trace(MMS_DEVP, "SIGHUP received"); - mm_refresh = 1; - break; - case SIGPIPE: - mms_trace(MMS_DEVP, "SIGPIPE received"); - break; - } -} - -/* - * mm_is_exiting - * - * Parameters: - * None - * - * This routine determines if mm is exiting by - * detecting if our smf service is disabled. - * - * Return Values: - * Non-zero if mm should exit. - * - */ -int -mm_is_exiting(void) -{ - int signum; - sigset_t mask; - struct timespec ts; - - /* any thread check for service disabled */ - sigemptyset(&mask); - sigaddset(&mask, SIGINT); - sigaddset(&mask, SIGHUP); - sigaddset(&mask, SIGTERM); - sigaddset(&mask, SIGPIPE); - - /* set timeout to zero, don't wait for signal */ - (void) memset(&ts, 0, sizeof (struct timespec)); - - /* query for pending signal */ - if ((signum = sigtimedwait(&mask, NULL, &ts)) != -1) { - /* let signal hander set state */ - mms_trace(MMS_DEVP, "thread %d signal check, signum %d", - pthread_self(), signum); - mm_signal_handler(signum); - } - - return (mm_exiting); -} - -/* - * mm_init_mm - * - * Parameters: - * - mm_data : Pointer to mm_data_t structure - * - * This function initialzes the various elements of mm_data - * - * Return Values: - * None - * - */ -void -mm_init_mm(mm_data_t *mm_data) -{ - memset(mm_data, 0, sizeof (mm_data_t)); - - mms_list_create(&mm_data->mm_cmd_queue, sizeof (mm_command_t), - offsetof(mm_command_t, cmd_next)); - mms_list_create(&mm_data->mm_wka_list, sizeof (mm_wka_t), - offsetof(mm_wka_t, wka_next)); - (void) mms_host_info(mm_data->mm_host_name, mm_data->mm_host_ip); - - /* list mutex */ - pthread_mutex_init(&mm_data->mm_queue_mutex, NULL); - pthread_mutex_init(&mm_data->mm_wka_mutex, NULL); - - /* worker */ - pthread_mutex_init(&mm_data->mm_worker_mutex, NULL); - pthread_cond_init(&mm_data->mm_work_cv, NULL); - pthread_cond_init(&mm_data->mm_accept_cv, NULL); - - /* Task Manager */ - pthread_mutex_init(&mm_data->mm_task_man_mutex, NULL); - pthread_cond_init(&mm_data->mm_task_cv, NULL); - pthread_mutex_init(&mm_data->mm_command_mutex, NULL); - - /* Notify */ - pthread_mutex_init(&mm_data->mm_notify_mutex, NULL); - pthread_cond_init(&mm_data->mm_notify_cv, NULL); - -} - - - -/* - * mm_init_attribute_info - * - * Parameters: - * - mm_data: Pointer to mm_data_t structure - * - * This function intializes the attr_info struct - * - * Return Values: - * 0 for success - * - */ -int -mm_init_attribute_info(mm_data_t *mm_data) { - mm_attribute_info_t *attr_info = &mm_data->mm_attr_info; - - /* Restricted Status OBJECTS */ - /* modifiable by 'system' */ - /* MM_NUM_STATUS_OBJS */ - attr_info->status_objs[0] = strdup("MOUNTLOGICAL"); - attr_info->status_objs[1] = strdup("MOUNTPHYSICAL"); - attr_info->status_objs[2] = strdup("DRIVECARTRIDGEACCESS"); - attr_info->status_objs[3] = strdup("CONNECTION"); - attr_info->status_objs[4] = strdup("SESSION"); - attr_info->status_objs[5] = strdup("TASK"); - attr_info->status_objs[6] = strdup("TASKCARTRIDGE"); - attr_info->status_objs[7] = strdup("TASKDRIVE"); - attr_info->status_objs[8] = strdup("TASKLIBRARY"); - attr_info->status_objs[9] = strdup("MESSAGE"); - attr_info->status_objs[10] = strdup("REQUEST"); - attr_info->status_objs[11] = strdup("STALEHANDLE"); - attr_info->status_objs[12] = strdup("SLOTCONFIG"); - attr_info->status_objs[13] = strdup("NOTIFY"); - - /* Restricted Status Attributes */ - /* modifiable by 'system' */ - /* MM_NUM_STATUS_ATTS */ - attr_info->status_atts[0] = strdup("LIBRARY.LibraryBroken"); - attr_info->status_atts[1] = strdup("LIBRARY.LibraryStateHard"); - attr_info->status_atts[2] = strdup("LIBRARY.LibraryStateSoft"); - attr_info->status_atts[3] = strdup("LM.LMHost"); - attr_info->status_atts[4] = strdup("LM.LMStateHard"); - attr_info->status_atts[5] = strdup("LM.LMStateSoft"); - attr_info->status_atts[6] = strdup("BAY.BayAccessible"); - attr_info->status_atts[7] = strdup("SLOT.CartridgeID"); - attr_info->status_atts[8] = strdup("SLOT.CartridgePCL"); - attr_info->status_atts[9] = strdup("SLOT.SlotAccessible"); - attr_info->status_atts[10] = strdup("SLOT.SlotOccupied"); - attr_info->status_atts[11] = strdup("DRIVE.DriveBroken"); - attr_info->status_atts[12] = strdup("DRIVE.DriveStateSoft"); - attr_info->status_atts[13] = strdup("DRIVE.DriveStateHard"); - attr_info->status_atts[14] = strdup("DRIVE.DriveTimeCreated"); - attr_info->status_atts[15] = strdup("DRIVE.DriveTimeMountedLast"); - attr_info->status_atts[16] = strdup("DRIVE.DriveTimeMountedTotal"); - attr_info->status_atts[17] = strdup("DRIVE.DriveNumberMounts"); - attr_info->status_atts[18] = - strdup("DRIVE.DriveNumberMountsSinceCleaning"); - attr_info->status_atts[19] = strdup("DRIVE.DriveLibraryAccessible"); - attr_info->status_atts[20] = strdup("DRIVE.DriveLibraryOccupied"); - attr_info->status_atts[21] = strdup("DRIVE.CartridgePCL"); - attr_info->status_atts[22] = strdup("DRIVE.DriveNeedsCleaning"); - attr_info->status_atts[23] = strdup("DRIVE.MaxMounts"); - attr_info->status_atts[24] = strdup("DM.DMHost"); - attr_info->status_atts[25] = strdup("DM.DMStateHard"); - attr_info->status_atts[26] = strdup("DM.DMStateSoft"); - attr_info->status_atts[27] = strdup("CARTRIDGE.CartridgeState"); - attr_info->status_atts[28] = strdup("CARTRIDGE.CartridgeTimeCreated"); - attr_info->status_atts[29] = - strdup("CARTRIDGE.CartridgeTimeMountedLast"); - attr_info->status_atts[30] = - strdup("CARTRIDGE.CartridgeTimeMountedTotal"); - attr_info->status_atts[31] = strdup("CARTRIDGE.CartridgeNumberMounts"); - attr_info->status_atts[32] = strdup("CARTRIDGE.CartridgeNumberVolumes"); - attr_info->status_atts[33] = strdup("SIDE.SideTimeCreated"); - attr_info->status_atts[34] = strdup("SIDE.SideTimeMountedLast"); - attr_info->status_atts[35] = strdup("SIDE.SideTimeMountedTotal"); - attr_info->status_atts[36] = strdup("PARTITION.PartitionAllocatable"); - attr_info->status_atts[37] = strdup("PARTITION.PartitionNumberMounts"); - attr_info->status_atts[38] = strdup("PARTITION.PartitionTimeCreated"); - attr_info->status_atts[39] = - strdup("PARTITION.PartitionTimeMountedTotal"); - attr_info->status_atts[40] = - strdup("PARTITION.PartitionTimeMountedLast"); - attr_info->status_atts[41] = strdup("VOLUME.VolumeNumberMounts"); - attr_info->status_atts[42] = strdup("VOLUME.VolumeTimeCreated"); - attr_info->status_atts[43] = strdup("VOLUME.VolumeTimeMountedLast"); - attr_info->status_atts[44] = strdup("VOLUME.VolumeTimeMountedTotal"); - attr_info->status_atts[45] = strdup("LIBRARY.LibraryOnline"); - attr_info->status_atts[46] = strdup("DRIVE.DriveOnline"); - attr_info->status_atts[47] = strdup("LIBRARY.LMName"); - attr_info->status_atts[48] = strdup("PARTITION.CartridgeID"); - attr_info->status_atts[49] = - strdup("CARTRIDGE.CartridgeWriteProtected"); - - /* Restricted Control Attributes */ - /* modifiable by 'administrator' */ - /* MM_NUM_CONTROL_ATTS */ - attr_info->control_atts[0] = strdup("LIBRARY.LibraryDisabled"); - attr_info->control_atts[1] = strdup("CARTRIDGE.LibraryName"); - attr_info->control_atts[2] = strdup("LM.LMMessageLevel"); - attr_info->control_atts[3] = strdup("DRIVE.DriveGroupName"); - attr_info->control_atts[4] = strdup("DRIVE.DrivePriority"); - attr_info->control_atts[5] = strdup("DRIVE.DMName"); - attr_info->control_atts[6] = strdup("DRIVE.DriveDisabled"); - attr_info->control_atts[7] = strdup("DRIVEGROUP.DriveGroupUnloadTime"); - attr_info->control_atts[8] = - strdup("DRIVEGROUPAPPLICATION.DriveGroupApplicationUnloadTime"); - attr_info->control_atts[9] = strdup("DM.DMMessageLevel"); - attr_info->control_atts[10] = strdup("CARTRIDGE.CartridgeGroupName"); - attr_info->control_atts[11] = - strdup("CARTRIDGEGROUP.CartridgeGroupPriority"); - attr_info->control_atts[12] = - strdup("CARTRIDGEGROUPAPPLICATION.CartridgeGroupApplicationPriority"); - - attr_info->control_atts[13] = strdup("CARTRIDGE.ApplicationName"); - - attr_info->control_atts[14] = strdup("LM.LMDisabled"); - attr_info->control_atts[15] = strdup("DM.DMDisabled"); - return (0); -} - - -/* - * mm_signal - * - * Parameters: - * - sig : signal - * - handler : function to handle sig - * - * Sets up a handler function for a given signal - * - * Return Values: - * None: - * - */ -static void -mm_signal(int sig, void (*handler) ()) -{ - /* - * Setup to catch signals - */ - struct sigaction act, oact; - - mms_trace(MMS_DEVP, "Setting signal handler for signal %d", sig); - memset(&act, 0, sizeof (act)); - act.sa_sigaction = handler; - sigemptyset(&act.sa_mask); - act.sa_flags = 0; - if (sig != SIGALRM) { - /* - * Allow alarm signal to interrupt - */ - act.sa_flags |= SA_RESTART; - } - if (sigaction(sig, &act, &oact) < 0) { - mms_trace(MMS_ERR, "Can't set signal handler for " - "signal %d: %s", sig, strerror(errno)); - exit(SMF_EXIT_ERR_FATAL); - } -} - - -/* - * mm_initialize - * - * Parameters: - * - mm_data : pointer to mm_data_t - * - * Initialzes structures, creates threads and starts db connections - * - * Return Values: - * None - * - */ -static void -mm_initialize(mm_data_t *mm_data, int daemon_mode) -{ - mms_err_t err; - char ebuf[MMS_EBUF_LEN]; - int i; - int fd_limit; - pid_t pid; - char *corename; - - - /* - * Initialize - */ - - /* - * Start tracing - */ - openlog("mm", LOG_PID, LOG_DAEMON); - - - /* - * Decome a daemon - */ - if (daemon_mode) { - if (pid = fork()) { - /* - * Parent process - */ - if (pid == (pid_t)(-1)) { - syslog(LOG_ERR, "%s:%d fork error", MMS_HERE); - exit(SMF_EXIT_ERR_FATAL); - } else { - /* Successfully forked, parent exits */ - exit(0); - } - } - } - - /* - * Direct stdin, stdout and stderr to /dev/null - */ - fopen("/dev/null", "r"); - fopen("/dev/null", "w"); - fopen("/dev/null", "w"); - - setsid(); - chdir("/"); - umask(0); - syslog(LOG_INFO, "%s:%d MM Starting", MMS_HERE); - - if (mms_set_core(MMS_CORES_DIR, NULL)) { - syslog(LOG_ERR, "%s:%d core setup %s", MMS_HERE, - strerror(errno)); - exit(SMF_EXIT_ERR_FATAL); - } - - corename = mms_strapp(NULL, "core.mmsmm"); - /* Check to see how many core files exist */ - if (mms_man_cores(MMS_CORES_DIR, corename)) { - syslog(LOG_ERR, - "%s:%d core management %s", MMS_HERE, - strerror(errno)); - } - free(corename); - - /* - * Close unused file descriptors - */ - for (i = 0; i < OPEN_MAX; i++) { - close(i); - } - - /* Initialize mm */ - - mm_init_mm(mm_data); - mm_data->mm_service_fd = -1; - mm_data->mm_work_todo = 0; - - /* - * Start tracing - */ - if (mms_trace_open(MM_TRACE_FN, MMS_ID_MM, -1, -1, 1, 1)) { - syslog(LOG_NOTICE, "%s:d MM mms_trace open failed", MMS_HERE); - } - (void) mms_trace_filter(mm_read_trace_level()); - - /* Use devp as default if debug build */ -#ifdef MMSDEBUG - (void) mms_trace_filter(MMS_SEV_DEVP); -#endif - mms_trace(MMS_INFO, "MM Starting"); - - /* - * Read config - */ - if (mm_cfg_read(&mm_data->mm_cfg)) { - syslog(LOG_NOTICE, "%s:%d MM read config failed", MMS_HERE); - mms_trace(MMS_ERR, "MM cfg read failed"); - exit(SMF_EXIT_ERR_CONFIG); - } - mm_data->mm_db.mm_db_cfg = &mm_data->mm_cfg.mm_db_cfg; - mm_data->mm_db_main.mm_db_cfg = &mm_data->mm_cfg.mm_db_cfg; - mm_data->mm_db_tm.mm_db_cfg = &mm_data->mm_cfg.mm_db_cfg; - - /* - * Load mms data model object pathing - */ - if (mm_init_paths(MM_PATHS_FN)) { - mms_trace(MMS_ERR, "MM failed to load object paths"); - exit(SMF_EXIT_ERR_CONFIG); - } - - if (mm_init_attribute_info(mm_data)) { - mms_trace(MMS_ERR, "MM failed to load attribute info"); - exit(SMF_EXIT_ERR_CONFIG); - } - - /* - * Start and initialize database server - */ - if (mm_db_init(&mm_data->mm_db) != MM_DB_OK) { - mms_trace(MMS_ERR, "unable to load or check db schema"); - exit(SMF_EXIT_ERR_CONFIG); - } - - /* - * Database - */ - mm_data->mm_db.mm_db_has_list = 0; - mm_data->mm_db.mm_db_resending = 0; - if (mm_db_connect(&mm_data->mm_db) != MM_DB_OK) { - mms_trace(MMS_ERR, "MM db connect failed"); - exit(SMF_EXIT_ERR_FATAL); - } - /* get system settings from database */ - mm_reconcile_trace_level(&mm_data->mm_db); - fd_limit = mm_get_fd_limit(&mm_data->mm_db); - if (mm_message_init(&mm_data->mm_db, mm_data)) { - mms_trace(MMS_ERR, "MM messages failed"); - exit(SMF_EXIT_ERR_FATAL); - } - if (mm_db_exec(HERE, &mm_data->mm_db, "update \"SYSTEM\" set " - "\"SystemName\" = '%s',\"SystemInstance\" = '%s';", - mm_data->mm_cfg.mm_network_cfg.cli_name, - mm_data->mm_cfg.mm_network_cfg.cli_inst) != MM_DB_OK) { - mms_trace(MMS_ERR, "MM system object update failed"); - exit(SMF_EXIT_ERR_FATAL); - } - /* cleanup database */ - if (mm_db_exec(HERE, &mm_data->mm_db, - "VACUUM VERBOSE ANALYZE;") != MM_DB_OK) { - mms_trace(MMS_ERR, "MM vacuum failed"); - exit(SMF_EXIT_ERR_FATAL); - } - if (mm_db_exec(HERE, &mm_data->mm_db, - "REINDEX DATABASE %s;", - mm_data->mm_db.mm_db_cfg->mm_db_name) != MM_DB_OK) { - mms_trace(MMS_ERR, "MM reindex failed"); - exit(SMF_EXIT_ERR_FATAL); - } - - mms_trace(MMS_DEVP, "Verify of supported device types"); - if (mm_init_types(mm_data, MM_TYPES_FN)) { - mms_trace(MMS_ERR, "MM failed to verify supported types"); - exit(SMF_EXIT_ERR_CONFIG); - } - - /* - * Set MMS password - */ - if (mm_db_exec_si(HERE, &mm_data->mm_db, - "update \"MMPASSWORD\" set \"Password\" = '%s' " - "where \"ApplicationName\" = '%s';", - mm_data->mm_cfg.mm_network_cfg.cli_pass, - MM_APP) != MM_DB_OK) { - mms_trace(MMS_ERR, "MM failed to update password"); - exit(SMF_EXIT_ERR_FATAL); - } - - mm_db_disconnect(&mm_data->mm_db); - - /* - * Setup open file descriptor limit - */ - if (mm_set_fd_limit(fd_limit)) { - mms_trace(MMS_DEVP, "MM failed to set fd limit %d", fd_limit); - } - - if (mms_listen(mm_data->mm_cfg.mm_network_cfg.cli_host, - mm_data->mm_cfg.mm_network_cfg.cli_port, - &mm_data->mm_service_fd, &err)) { - mms_get_error_string(&err, ebuf, MMS_EBUF_LEN); - mms_trace(MMS_ERR, "mm listen - %s", ebuf); - exit(SMF_EXIT_ERR_FATAL); - } - mms_trace(MMS_DEVP, "Server - fd %d", mm_data->mm_service_fd); - -#ifdef MMS_OPENSSL - if (mms_ssl_server(&mm_data->mm_cfg.mm_network_cfg, - mm_data->mm_cfg.mm_ssl_dh_file, - mm_data->mm_cfg.mm_ssl_verify_peer, - &mm_data->mm_ssl_data, &err)) { - mms_get_error_string(&err, ebuf, MMS_EBUF_LEN); - mms_trace(MMS_ERR, "ssl init - %s", ebuf); - exit(SMF_EXIT_ERR_CONFIG); - } -#endif /* MMS_OPENSSL */ - - /* - * Ready for mm clients to connect - */ - mms_trace(MMS_INFO, "MM initialized"); -} - -/* - * mm_char_list_destroy - * - * Parameters: - * - list: pointer to mm_list_t - * - * Free's memory for an entire mm_list_t - * caller must do a list_destroy - * - * Return Values: - * None - * - */ -void -mm_char_list_destroy(mms_list_t *list) { - mm_char_list_t *char_list; - mm_char_list_t *next_char_list; - - for (char_list = mms_list_head(list); - char_list != NULL; - char_list = next_char_list) { - free(char_list->text); - next_char_list = - mms_list_next(list, - char_list); - mms_list_remove(list, - char_list); - free(char_list); - } -} - -/* - * mm_free_cmi_drive - * - * Parameters: - * - drive: pointer to a cmd_dirve_list_t list - * - * free memory for an entire cmi_drive_list_t - * caller must do a list_destroy - * - * Return Values: - * None - * - */ -void -mm_free_cmi_drive(cmi_drive_list_t *drive) { - /* Drive */ - if (drive->cmi_drive_name) - free(drive->cmi_drive_name); - if (drive->cmi_dm_name) - free(drive->cmi_dm_name); - if (drive->cmi_loaded_pcl) - free(drive->cmi_loaded_pcl); - - free(drive); -} - -/* - * mm_free_cmi_cart - * - * Parameters: - * - cart : - * - * Free memory for a single cmi_cart_list_t - * - * Return Values: - * None - * - */ -void -mm_free_cmi_cart(cmi_cart_list_t *cart) { - - cmi_drive_list_t *drive; - cmi_drive_list_t *next_drive; - - - /* Cartridge */ - if (cart->cmi_library) - free(cart->cmi_library); - if (cart->cmi_side_name) - free(cart->cmi_side_name); - if (cart->cmi_cart_pcl) - free(cart->cmi_cart_pcl); - if (cart->cmi_cart_type) - free(cart->cmi_cart_type); - if (cart->cmi_bit_format) - free(cart->cmi_bit_format); - for (drive = mms_list_head(&cart-> - cmi_drive_list); - drive != NULL; - drive = next_drive) { - next_drive = - mms_list_next(&cart-> - cmi_drive_list, - drive); - mms_list_remove(&cart-> - cmi_drive_list, - drive); - mm_free_cmi_drive(drive); - } - mms_list_destroy(&cart->cmi_drive_list); - - free(cart); -} - - -/* - * mm_free_cmi_cart_list - * - * Parameters: - * - cart_list : mms_list_t of cmi_cart_list_t - * - * Free memory for an entire list of cmi_cart_list_t - * caller must do a list_destroy - * - * Return Values: - * None - * - */ -void -mm_free_cmi_cart_list(mms_list_t *cart_list) { - /* This function frees the cart list, */ - /* but does not destroy it */ - cmi_cart_list_t *next_cart = NULL; - cmi_cart_list_t *cart = NULL; - - for (cart = mms_list_head(cart_list); - cart != NULL; - cart = next_cart) { - next_cart = - mms_list_next(cart_list, - cart); - mms_list_remove(cart_list, - cart); - mm_free_cmi_cart(cart); - } -} - -/* - * mm_remove_from_depend - * - * Parameters: - * - cmd : cmd to remove from other commands depend list - * - * This function will remove cmd from the dependent command lists - * of all other commands. This should be called for every command - * when the command is being destroyed - * - * if not removed from all other commands, then next list - * access of the depend list containning this cmd will hit list_head - * assert since the memory has already been free'd - * - * Return Values: - * None - * - */ -void -mm_remove_from_depend(mm_command_t *cmd) { - mm_command_t *cur_cmd; - mm_command_t *depend_list; - mm_command_t *next_depend_list; - - pthread_mutex_lock(&data-> - mm_queue_mutex); - mms_list_foreach(&data->mm_cmd_queue, cur_cmd) { - if (cur_cmd == cmd) { - /* this is the command to remove */ - continue; - } - for (depend_list = mms_list_head(&cur_cmd->cmd_depend_list); - depend_list != NULL; - depend_list = next_depend_list) { - next_depend_list = - mms_list_next(&cur_cmd->cmd_depend_list, - depend_list); - if (depend_list == cmd) { - mms_list_remove(&cur_cmd->cmd_depend_list, - depend_list); - } - } - } - - pthread_mutex_unlock(&data-> - mm_queue_mutex); -} - - - -/* - * mm_destroy_cmd - * - * Parameters: - * - cmd : pointer to a command - * - * Does all cleanup necessary for the command - * and free's all memory associated with this command - * This includes reseting any data base states used - * by the command - * - * Return Values: - * 0 for success - * - */ -int -mm_destroy_cmd(mm_command_t *cmd) -{ - - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - cmi_mode_list_t *mode; - cmi_mode_list_t *next_mode; - cmi_cart_list_t *cart; - cmi_cart_list_t *next_cart; - mm_db_t *db = &cmd->cmd_mm_data->mm_db; - eject_cart_t *eject_cart; - eject_cart_t *next_eject_cart; - - /* begin end command list */ - mm_command_t *cur_cmd; - mm_command_t *next_cmd; - - - if (cmd->cmd_name == NULL) { - cmd->cmd_name = strdup("UNKNOWN COMMAND"); - } - mms_trace(MMS_DEVP, - "mm_destroy_cmd, %s (%p)", - cmd->cmd_name, - cmd); - - - if (cmd->cmd_func == mm_mount_cmd_func) { - if (mm_db_exec(HERE, db, - "delete from \"TASK\" where " \ - "\"TaskID\" = '%s';", - cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, "Error Removing task objects..."); - } - if (mm_db_exec(HERE, db, - "delete from \"REQUEST\" where " - "\"RequestingTaskID\" = '%s' and " - "\"RequestState\" != 'responded';", - cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, "Error Removing request objects..."); - } - if (cmd->cmd_mount_info.cmi_need_clear) { - if (cmd->cmd_mount_info.cmi_drive != NULL) { - mms_trace(MMS_DEBUG, "cmi_need_clear == true"); - (void) mm_add_clear_drive(cmd-> - cmd_mount_info.cmi_drive, - data, db, NULL, NULL, 1, 0); - } - } - } else if (cmd->cmd_func == mm_unmount_cmd_func) { - if (mm_db_exec(HERE, db, - "delete from \"TASK\" where " \ - "\"TaskID\" = '%s';", - cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, "Error Removing task objects..."); - } - if (mm_db_exec(HERE, db, - "delete from \"REQUEST\" where " - "\"RequestingTaskID\" = '%s' and " - "\"RequestState\" != 'responded';", - cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, "Error Removing request objects..."); - } - if (cmd->cmd_mount_info.cmi_need_clear) { - if (cmd->cmd_mount_info.cmi_drive != NULL) { - mms_trace(MMS_DEBUG, "cmi_need_clear == true"); - (void) mm_add_clear_drive(cmd-> - cmd_mount_info.cmi_drive, - data, db, NULL, NULL, 1, 0); - } - } - } - if ((cmd->cmd_func == mm_begin_cmd_func) || - (cmd->cmd_func == mm_end_cmd_func)) { - /* Free a begin end list */ - for (cur_cmd = mms_list_head(&cmd->cmd_beginend_list); - cur_cmd != NULL; - cur_cmd = next_cmd) { - next_cmd = - mms_list_next(&cmd->cmd_beginend_list, cur_cmd); - mms_list_remove(&cmd->cmd_beginend_list, - cur_cmd); - (void) mm_destroy_cmd(cur_cmd); - } - mms_list_destroy(&cmd->cmd_beginend_list); - } - - /* clean depend_list */ - mms_trace(MMS_DEVP, - "remove this cmd from all other cmd depend lists"); - mm_remove_from_depend(cmd); - for (cur_cmd = mms_list_head(&cmd->cmd_depend_list); - cur_cmd != NULL; - cur_cmd = next_cmd) { - next_cmd = - mms_list_next(&cmd->cmd_depend_list, - cur_cmd); - mms_list_remove(&cmd->cmd_depend_list, - cur_cmd); - } - mms_list_destroy(&cmd->cmd_depend_list); - - for (cart = mms_list_head(&mount_info-> - cmi_cart_list); - cart != NULL; - cart = next_cart) { - next_cart = - mms_list_next(&mount_info-> - cmi_cart_list, - cart); - mms_list_remove(&mount_info-> - cmi_cart_list, - cart); - mm_free_cmi_cart(cart); - } - mms_list_destroy(&mount_info->cmi_cart_list); - - for (mode = - mms_list_head(&mount_info-> - cmi_mode_list); - mode != NULL; - mode = next_mode) { - next_mode = - mms_list_next(&mount_info-> - cmi_mode_list, - mode); - mms_list_remove(&mount_info-> - cmi_mode_list, - mode); - free(mode); - } - mms_list_destroy(&mount_info->cmi_mode_list); - - if (cmd->cmd_root != NULL) { - mms_pn_destroy(cmd->cmd_root); - } - - (void) mm_cancel_request(db, cmd->cmd_reqid); - - if (cmd->cmd_response) { - mms_pn_destroy(cmd->cmd_response); - } - if (cmd->cmd_name) - free(cmd->cmd_name); - if (cmd->cmd_task) - free(cmd->cmd_task); - if (cmd->cmd_textcmd) - free(cmd->cmd_textcmd); - if (cmd->cmd_buf) - free(cmd->cmd_buf); - if (cmd->cmd_report) - free(cmd->cmd_report); - - - /* Free mount_info */ - if (mount_info->cmi_dm) - free(mount_info->cmi_dm); - if (mount_info->cmi_drive) - free(mount_info->cmi_drive); - if (mount_info->cmi_library) - free(mount_info->cmi_library); - if (mount_info->cmi_cartridge) - free(mount_info->cmi_cartridge); - if (mount_info->cmi_pcl) - free(mount_info->cmi_pcl); - if (mount_info->cmi_side_name) - free(mount_info->cmi_side_name); - if (mount_info->cmi_where) - free(mount_info->cmi_where); - if (mount_info->cmi_filename) - free(mount_info->cmi_filename); - if (mount_info->cmi_blocksize) - free(mount_info->cmi_blocksize); - if (mount_info->cmi_filesequence) - free(mount_info->cmi_filesequence); - if (mount_info->cmi_volumeid) - free(mount_info->cmi_volumeid); - if (mount_info->cmi_capability) - free(mount_info->cmi_capability); - if (mount_info->cmi_retention) - free(mount_info->cmi_retention); - if (mount_info->cmi_handle) - free(mount_info->cmi_handle); - if (mount_info->cmi_user) - free(mount_info->cmi_user); - /* Un mount */ - if (mount_info->cui_signature_type) - free(mount_info->cui_signature_type); - if (mount_info->cui_signature) - free(mount_info->cui_signature); - - if (mount_info->cmi_first_lib) - free(mount_info->cmi_first_lib); - if (mount_info->cmi_first_drive) - free(mount_info->cmi_first_drive); - if (mount_info->cmi_second_lib) - free(mount_info->cmi_second_lib); - if (mount_info->cmi_second_drive) - free(mount_info->cmi_second_drive); - - if (cmd->cmd_eclass) - free(cmd->cmd_eclass); - if (cmd->cmd_ecode) - free(cmd->cmd_ecode); - - /* Eject cartridge */ - if (cmd->cmd_eject) { - for (eject_cart = mms_list_head(&cmd->cmd_eject->eject_list); - eject_cart != NULL; - eject_cart = next_eject_cart) { - next_eject_cart = - mms_list_next(&cmd->cmd_eject->eject_list, - eject_cart); - - mms_list_remove(&cmd->cmd_eject->eject_list, - eject_cart); - - free(eject_cart->cart_cartid); - free(eject_cart->cart_cartpcl); - free(eject_cart->cart_slottype); - free(eject_cart->cart_slotname); - free(eject_cart->cart_library); - free(eject_cart); - } - mms_list_destroy(&cmd->cmd_eject->eject_list); - free(cmd->cmd_eject->eject_library); - free(cmd->cmd_eject->eject_lm); - free(cmd->cmd_eject->eject_slotgroup); - free(cmd->cmd_eject); - } - - /* Path Matching */ - if (cmd->cmd_has_list) { - mm_clear_source(cmd); - mm_clear_dest(cmd); - mm_clear_const(cmd); - mms_list_destroy(&cmd->cmd_source_list); - mms_list_destroy(&cmd->cmd_dest_list); - mms_list_destroy(&cmd->cmd_const_list); - mm_free_list(&cmd->cmd_resp_list); - mms_list_destroy(&cmd->cmd_resp_list); - mm_free_err_list(cmd); - mms_list_destroy(&cmd->cmd_err_list); - } - - /* Message */ - if (cmd->cmd_msg.msg_localized) { - free(cmd->cmd_msg.msg_localized); - } - - free(cmd); - return (0); -} - -/* - * mm_destroy_wka - * - * Parameters: - * - wka : pointer to a mm_wka_t - * - * Free's all memory associated with this client workarea - * - * Return Values: - * None - * - */ -void -mm_destroy_wka(mm_wka_t *wka) { - if (wka->wka_conn.cci_client) - free(wka->wka_conn.cci_client); - if (wka->wka_conn.cci_instance) - free(wka->wka_conn.cci_instance); - if (wka->wka_conn.cci_language) - free(wka->wka_conn.cci_language); - if (wka->wka_conn.cci_version) - free(wka->wka_conn.cci_version); - if (wka->wka_conn.cci_password) - free(wka->wka_conn.cci_password); - if (wka->wka_conn.cci_certificate) - free(wka->wka_conn.cci_certificate); - if (wka->wka_conn.cci_authentication) - free(wka->wka_conn.cci_authentication); - if (wka->mm_wka_conn) - free(wka->mm_wka_conn); - free(wka); -} - -/* - * mm_return_unload - * - * Parameters: - * - library : ptr to string of library name - * - drive : ptr to string of drive name - * - mm_data : pointer to mm_data_t - * - * For a given library and drive, search the command - * queue and return a pointer to the delay unload - * command for his library and drive - * - * Return Values: - * mm_command_t* : if the function finds a - * delay unload for this library - * and drive, it will return - * a ptr to that command - * NULL: If no unload is found - * the function will return NULL - * - */ -mm_command_t * -mm_return_unload(char *library, char *drive, - mm_data_t *mm_data) { - - cmd_mount_info_t *mount_info = NULL; - mm_command_t *cur_cmd; - mm_command_t *unload_cmd = NULL; - - pthread_mutex_lock(&mm_data->mm_queue_mutex); - mms_list_foreach(&mm_data->mm_cmd_queue, cur_cmd) { - if (cur_cmd->cmd_func == mm_delay_unmount_cmd_func) { - mount_info = &cur_cmd->cmd_mount_info; - if ((strcmp(library, mount_info->cmi_library) == 0) && - (strcmp(drive, mount_info->cmi_drive) == 0)) { - unload_cmd = cur_cmd; - break; - } - } - } - pthread_mutex_unlock(&mm_data-> - mm_queue_mutex); - return (unload_cmd); -} - -/* - * mm_set_depend_response - * - * Parameters: - * - cmd : ptr to mm_command_t - * - * Copy the response to for this command to each command - * dependent on this command (in this cmd's depend list) - * - * Return Values: - * 1 : if responses were copied - * 0 : if no responses were copied - * - */ -int -mm_set_depend_response(mm_command_t *cmd) { - mm_command_t *cur_depend = NULL; - int set_one = 0; - char *rsp_text = NULL; - - if (mm_has_depend(cmd) == 0) { - return (0); - } - /* Generate text cmd from cmd response */ - rsp_text = mms_pn_build_cmd_text(cmd->cmd_response); - if (rsp_text == NULL) { - mms_trace(MMS_ERR, - "error getting response text"); - return (0); - } - mms_list_foreach(&cmd->cmd_depend_list, cur_depend) { - set_one = 1; - mms_trace(MMS_DEVP, - "%s has parent, %s", - cmd->cmd_name, - cur_depend-> - cmd_name); - if (cur_depend-> - cmd_response != NULL) - free(cur_depend-> - cmd_response); - /* Rebuild parnode */ - switch (cmd->cmd_language) { - case MM_LANG_MMP: - cur_depend->cmd_response = - mm_text_to_par_node(rsp_text, - mms_mmp_parse); - break; - case MM_LANG_DMP: - cur_depend->cmd_response = - mm_text_to_par_node(rsp_text, - mms_dmpm_parse); - break; - case MM_LANG_LMP: - cur_depend->cmd_response = - mm_text_to_par_node(rsp_text, - mms_lmpm_parse); - break; - } - } - free(rsp_text); - mms_pn_destroy(cmd->cmd_response); - cmd->cmd_response = NULL; - return (set_one); -} - -/* - * mm_set_depend_error - * - * Parameters: - * - cmd : ptr to mm_command_t - * - * Copy the error response to for this command to each command - * dependent on this command (in this cmd's depend list) - * Set error flags for each dependent command - * - * Return Values: - * 1 : if responses were copied - * 0 : if no responses were copied - * - */ -int -mm_set_depend_error(mm_command_t *cmd) { - mm_command_t *cur_depend = NULL; - int set_one = 0; - char *rsp_text = NULL; - - /* this cmd had an error, */ - /* set error buf for every command */ - /* depending on this one */ - - /* - * Command has a parent - * Set error flags, - * and dispatch - * parent command func can - * handle the error - * Save the child's error - * response for the parent - */ - if (mm_has_depend(cmd) == 0) { - return (0); - } - - /* Generate text cmd from cmd response */ - rsp_text = mms_pn_build_cmd_text(cmd->cmd_response); - if (rsp_text == NULL) { - mms_trace(MMS_ERR, - "error getting response text"); - return (0); - } - - mms_list_foreach(&cmd->cmd_depend_list, cur_depend) { - set_one = 1; - mms_trace(MMS_DEVP, - "%s has parent, %s", - cmd->cmd_name, - cur_depend-> - cmd_name); - if (cur_depend-> - cmd_response != NULL) - free(cur_depend-> - cmd_response); - /* Rebuild parnode */ - switch (cmd->cmd_language) { - case MM_LANG_MMP: - cur_depend->cmd_response = - mm_text_to_par_node(rsp_text, - mms_mmp_parse); - break; - case MM_LANG_DMP: - cur_depend->cmd_response = - mm_text_to_par_node(rsp_text, - mms_dmpm_parse); - break; - case MM_LANG_LMP: - cur_depend->cmd_response = - mm_text_to_par_node(rsp_text, - mms_lmpm_parse); - break; - } - cur_depend->cmd_flags |= - MM_CMD_DEPEND_ERROR; - cur_depend->cmd_flags |= - MM_CMD_DISPATCHABLE; - - } - free(rsp_text); - mms_pn_destroy(cmd->cmd_response); - cmd->cmd_response = NULL; - return (set_one); -} - -/* - * mm_dispatch_all_depend - * - * Parameters: - * - cmd : ptr to mm_command_t - * - * Set every command dependent on this command - * ready for dispatch - * - * Return Values: - * None - * - */ -void -mm_dispatch_all_depend(mm_command_t *cmd) { - /* set every depend for this cmd for dispatch */ - mm_command_t *cur_depend = NULL; - mms_list_foreach(&cmd->cmd_depend_list, cur_depend) { - cur_depend->cmd_flags |= - MM_CMD_DISPATCHABLE; - } -} - -/* - * mm_remove_this_depend - * - * Parameters: - * - cmd : ptr to mm_command_t - * - remove : ptr to mm_command_t - * - * Removes the command 'remove' from the depend list in 'cmd' - * - * Return Values: - * none - * - */ -void -mm_remove_this_depend(mm_command_t *cmd, mm_command_t *remove) { - /* remove remove from cmd's depend list */ - mm_command_t *depend_list; - mm_command_t *next_depend_list; - for (depend_list = mms_list_head(&cmd->cmd_depend_list); - depend_list != NULL; - depend_list = next_depend_list) { - next_depend_list = - mms_list_next(&cmd->cmd_depend_list, - depend_list); - if (depend_list == remove) { - mms_list_remove(&cmd->cmd_depend_list, - depend_list); - } - } -} - -/* - * mm_remove_all_depend - * - * Parameters: - * - cmd : ptr to mm_command_t - * - * Removes all depedent commands from cmd's depend list - * - * Return Values: - * None - * - */ -void -mm_remove_all_depend(mm_command_t *cmd) { - /* remove and free all */ - mm_command_t *depend_list; - mm_command_t *next_depend_list; - for (depend_list = mms_list_head(&cmd->cmd_depend_list); - depend_list != NULL; - depend_list = next_depend_list) { - next_depend_list = - mms_list_next(&cmd->cmd_depend_list, - depend_list); - mms_list_remove(&cmd->cmd_depend_list, - depend_list); - } -} - -/* - * mm_is_parent - * - * Parameters: - * - parent : ptr to mm_command_t - * - child : ptr to mm_command_t - * - * Determines if parent is in the depend list of child - * - * Return Values: - * 1 : if parent is in the depend list - * of child - * 0 : if parent is not in the depend list - * of child - * - */ -int -mm_is_parent(mm_command_t *parent, mm_command_t *child) { - /* is parent, the parent of child? */ - mm_command_t *cur_depend = NULL; - mms_list_foreach(&child->cmd_depend_list, cur_depend) { - if (cur_depend == parent) { - return (1); - } - } - return (0); -} - - -/* - * mm_first_parent - * - * Parameters: - * - child : ptr to mm_command_t - * - * Returns the first command dependent on child - * - * Return Values: - * mm_command_t* : returns a pointer to the - * first parent of child - * NULL : returns NULL if there are - * no parents of child - * - */ -mm_command_t * -mm_first_parent(mm_command_t *child) { - mm_command_t *cur_depend = NULL; - - cur_depend = mms_list_head(&child->cmd_depend_list); - return (cur_depend); -} - -/* - * mm_top_parent - * - * Parameters: - * - child : ptr to mm_command_t - * - * Finds the 1st command to set child as a dependent - * - * Return Values: - * mm_command_t* : ptr to the 1st parent of child - * NULL : return NULL if child had no - * commands in its depend list - */ -mm_command_t * -mm_top_parent(mm_command_t *child) { - /* return parent of this child */ - mm_command_t *cur_depend = NULL; - if (mm_has_depend(child) == 0) { - /* No parent */ - return (NULL); - } - cur_depend = mms_list_head(&child->cmd_depend_list); - if (cur_depend == NULL) { - return (NULL); - } - if (mm_has_depend(cur_depend) == 0) { - return (cur_depend); - } - return (mm_top_parent(cur_depend)); -} - - -/* - * mm_has_depend - * - * Parameters: - * - cmd : ptr to mm_command_t - * - * Determine if cmd has any commands in its depend list - * - * Return Values: - * 0 : for no commands in its depend list - * 1 : for any command in its depend list - * - */ -int -mm_has_depend(mm_command_t *cmd) { - /* does this command have a depend in the list */ - if (mms_list_head(&cmd->cmd_depend_list) != NULL) { - return (1); - } - return (0); -} - -/* - * mm_add_depend - * - * Parameters: - * - child : ptr to mm_command_t - * - parent : ptr to mm_command_t - * - * Adds command pointed to by parent to the depend list - * of command pointed to by child - * - * Return Values: - * None - * - */ -void -mm_add_depend(mm_command_t *child, mm_command_t *parent) { - /* this function adds parent to the child */ - /* allows multiple parents per child */ - mms_trace(MMS_DEVP, - "mm_add_depend"); - if (parent == NULL) { - mms_trace(MMS_DEVP, - "passed a NULL parent"); - return; - } - - if (mm_is_parent(parent, child)) { - mms_trace(MMS_DEVP, - "%p is already a parent of %p", - parent, child); - return; - } - - mms_list_insert_tail(&child->cmd_depend_list, parent); - - mms_trace(MMS_DEVP, - "added %p as parent of %p", - parent, - child); - return; - - -} - -/* - * mm_set_unload_dispatch - * - * Parameters: - * - unmnt_cmd : ptr to mm_command_t - * - parent : ptr to mm_command_t - * - * set the command pointed to by unmnt_cmd ready for dispatch - * if parent is pointing to a command, add that command to - * unmnt_cmd's depend list - * - * Return Values: - * None - * - */ -void -mm_set_unload_dispatch(mm_command_t *unmnt_cmd, mm_command_t *parent) { - /* This sets the unmnt_cmd for dispatch */ - /* if parent != NULL */ - /* it will be added to this commands parents */ - time_t tm; - cmd_mount_info_t *mount_info = NULL; - - mount_info = &unmnt_cmd->cmd_mount_info; - - (void) time(&tm); - if (((mount_info->unload_tm - tm) <= 0) && - (unmnt_cmd->cmd_state >= 2)) { - /* this delay unload is */ - /* already running */ - mms_trace(MMS_DEVP, - "this delay unmout is " - "already running"); - } else { - MM_SET_FLAG(unmnt_cmd->cmd_flags, - MM_CMD_DISPATCHABLE); - mount_info->unload_tm = tm; - } - /* Need to set cmd */ - /* as part of cur_cmd */ - /* depend list */ - if (parent != NULL) - (void) mm_add_depend(unmnt_cmd, parent); - -} - -/* - * mm_dispatch_unload - * - * Parameters: - * - library : ptr to library name string - * - drive : ptr to drive name string - * - cmd : ptr to mm_command_t - * - mm_data : ptr to mm_data_t - * - * Find's the unload command the give library and drive - * and sets that ready for dispatch - * then add cmd to that unload command's depend list - * - * Return Values: - * mm_command_t : if an unload is found for library - * and drive, a ptr to that command - * is returned - * NULL : if an unload for library and drive - * cannot be found, NULL is returned - * - */ -mm_command_t * -mm_dispatch_unload(char *library, char *drive, mm_command_t *cmd, - mm_data_t *mm_data) { - /* searches the cmd_queue for a delay unmount cmd function */ - /* if the library and drive match, the cmd is set for dispatch */ - /* if cmd != NULL, then cmd will be set */ - /* as parent of the delay unmount */ - - cmd_mount_info_t *mount_info = NULL; - mm_command_t *cur_cmd; - - mm_command_t *unmnt_cmd = NULL; - - mms_trace(MMS_DEVP, "dispatching delay unmounts for %s %s", - library, drive); - - pthread_mutex_lock(&mm_data->mm_queue_mutex); - mms_list_foreach(&mm_data->mm_cmd_queue, cur_cmd) { - if (cur_cmd->cmd_func == mm_delay_unmount_cmd_func) { - mount_info = &cur_cmd->cmd_mount_info; - if ((strcmp(library, mount_info->cmi_library) == 0) && - (strcmp(drive, mount_info->cmi_drive) == 0)) { - mms_trace(MMS_DEVP, - "dispatch delay unmount, %s %s", - library, - drive); - mm_set_unload_dispatch(cur_cmd, cmd); - unmnt_cmd = cur_cmd; - } - } - } - pthread_mutex_unlock(&mm_data-> - mm_queue_mutex); - if (unmnt_cmd != NULL) - return (unmnt_cmd); - /* We did not find a delay unload */ - /* Search the list for a clear drive function */ - /* This cmd may be following an error recovery situation */ - /* where the delay was not correctly added */ - /* search for a clear drive instead */ - /* do not dispatch the clear drive */ - pthread_mutex_lock(&mm_data->mm_queue_mutex); - mms_list_foreach(&mm_data->mm_cmd_queue, cur_cmd) { - if (cur_cmd->cmd_func == mm_clear_drive_cmd_func) { - mount_info = &cur_cmd->cmd_mount_info; - if ((mount_info->cmi_library == NULL) || - (mount_info->cmi_drive == NULL)) { - continue; - } - if ((strcmp(library, mount_info->cmi_library) == 0) && - (strcmp(drive, mount_info->cmi_drive) == 0)) { - mms_trace(MMS_DEVP, - "found clear drive for, %s %s", - library, - drive); - if (cmd != NULL) - (void) mm_add_depend(cur_cmd, cmd); - unmnt_cmd = cur_cmd; - } - } - - } - pthread_mutex_unlock(&mm_data-> - mm_queue_mutex); - return (unmnt_cmd); -} - - -/* - * mm_remove_unload - * - * Parameters: - * - library : ptr to library name string - * - drive : ptr to drive name string - * - mm_data : ptr to mm_data_t - * - * Find the unload command for the given library and drive, - * then set that unload command for removal - * - * Return Values: - * 1 : return 1 if a command was set for removal - * 0 : return 0 if a command was not set for removal - * - */ -int -mm_remove_unload(char *library, char *drive, mm_data_t *mm_data) { - /* searches the cmd_queue for a delay unmount cmd function */ - /* if the library and drive match, the cmd is set for removal */ - cmd_mount_info_t *mount_info = NULL; - mm_command_t *cur_cmd; - int removed_one = 0; - - mms_trace(MMS_DEVP, "removeing delay unmounts for %s %s", - library, drive); - - pthread_mutex_lock(&mm_data->mm_queue_mutex); - mms_list_foreach(&mm_data->mm_cmd_queue, cur_cmd) { - if (cur_cmd->cmd_func == mm_delay_unmount_cmd_func) { - mount_info = &cur_cmd->cmd_mount_info; - if ((strcmp(library, mount_info->cmi_library) == 0) && - (strcmp(drive, mount_info->cmi_drive) == 0)) { - mms_trace(MMS_DEVP, - "remove delay unmount, %s %s", - library, - drive); - cur_cmd->cmd_remove = 1; - removed_one = 1; - } - } - } - pthread_mutex_unlock(&mm_data-> - mm_queue_mutex); - return (removed_one); -} - -/* - * mm_remove_commands - * - * Parameters: - * - mm_data : ptr to mm_data_t - * - db_main : ptr to valid db connection, mm_db_t - * - mm_wka : ptr to cli work area, mm_wka_t - * - * For the client workarea mm_wka points to, remove - * and clean up all commands associated with it. - * this may require updating states in the db - * - * Return Values: - * 0 : for success - * 1 : for errors - * - */ -int -mm_remove_commands(mm_data_t *mm_data, mm_db_t *db_main, mm_wka_t *mm_wka) { - - mm_command_t *cur_cmd; - - mms_trace(MMS_DEVP, "Removing client with uuid %s", - mm_wka->wka_conn.cci_uuid); - /* Set outstanding commands for remove */ - pthread_mutex_lock(&data->mm_queue_mutex); - mms_list_foreach(&mm_data->mm_cmd_queue, cur_cmd) { - - /* - * If this command is a mount command, - * set flag for clearing the drive - */ - if (cur_cmd->cmd_name == NULL) { - cur_cmd->cmd_name = strdup("**UNKNOWN CMD**"); - } - - if (strcmp(cur_cmd->wka_uuid, - mm_wka->wka_conn.cci_uuid) != 0) { - /* This is not a command from this wka */ - continue; - } - /* This IS a command from this client's wka */ - mms_trace(MMS_DEVP, "Matched client, " - "set for remove, %s", - cur_cmd->cmd_name); - if (cur_cmd->cmd_func == - mm_mount_cmd_func) { - mms_trace(MMS_DEVP, - "client has an outstanding " - "mount command"); - mms_trace(MMS_DEBUG, - "Mark a mount_cmd for " - "clear and reset states"); - /* Call mm_rm_mount */ - /* to clear resources */ - /* and reset manager states */ - cur_cmd->cmd_mount_info. - cmi_reset_states = 1; - (void) mm_rm_mount(cur_cmd, db_main); - cur_cmd->cmd_mount_info. - cmi_need_clear = 1; - /* Could optimize this clear */ - /* ie dont physical clear unless necessary */ - pthread_mutex_unlock(&data->mm_queue_mutex); - (void) mm_add_clear_drive(cur_cmd-> - cmd_mount_info.cmi_drive, - data, db_main, NULL, NULL, 1, 0); - pthread_mutex_lock(&data->mm_queue_mutex); - - } - if (cur_cmd->cmd_func == - mm_unmount_cmd_func) { - /* TODO fix manager states, */ - /* clear resources */ - mms_trace(MMS_DEVP, - "client has an outstanding " - "unmount command"); - (void) mm_rm_unmount(cur_cmd, db_main); - cur_cmd->cmd_mount_info. - cmi_need_clear = 1; - cur_cmd->cmd_mount_info. - cmi_reset_states = 1; - if (cur_cmd-> - cmd_mount_info.cui_physical == 1) { - pthread_mutex_unlock(&data->mm_queue_mutex); - (void) mm_add_clear_drive(cur_cmd-> - cmd_mount_info.cmi_drive, - data, db_main, NULL, NULL, 1, 0); - pthread_mutex_lock(&data->mm_queue_mutex); - } - } - - cur_cmd->cmd_remove = 1; - cur_cmd->wka_ptr = NULL; - - /* - * If this command is a depend, - * mark its parent - */ - mm_command_t *cur_depend = NULL; - if (mm_has_depend(cur_cmd)) { - mms_trace(MMS_DEVP, - "this command has depend's in list " - "mark each with MMS_ERROR and do not dispatch"); - mms_list_foreach(&cur_cmd->cmd_depend_list, - cur_depend) { - MM_SET_FLAG(cur_depend-> - cmd_flags, - MM_CMD_DEPEND_ERROR); - MM_SET_FLAG(cur_depend-> - cmd_flags, - MM_CMD_DISPATCHABLE); - } - /* Clear depend list so that the parents may be */ - /* used by other commands */ - mm_remove_all_depend(cur_cmd); - } - - /* - * If this command is a parent, - * Mark its children - */ - mm_command_t *child; - mms_list_foreach(&mm_data->mm_cmd_queue, - child) { - if (mm_is_parent(cur_cmd, child) == 0) { - /* not a parent of this child */ - continue; - } - if (child->cmd_name == NULL) { - child->cmd_name = - strdup("**UNKNOWN CMD**"); - } - - mms_trace(MMS_DEBUG, - " %s is child " - "of %s, set cmd " - "for remove", - child->cmd_name, - cur_cmd->cmd_name); - - /* TODO */ - /* - * What to do with outstanding - * commands? - * - * Cancel child commands in a mount - * Ensure that states are correct - * and drives are clear - * - * TEMP - * Remove all dependent commands - * If lmp munt is a child - * Allow it to complete, then - * clear the drive - */ - mm_remove_this_depend(child, cur_cmd); - if (strcmp(child->cmd_name, - "lmp mount") == 0) { - mms_trace(MMS_DEVP, "setting lmp " - "mount for clear_drive"); - /* Need clear for lmp mount */ - child->cmd_mount_info. - cmi_need_clear = 1; - } else if (strcmp(child->cmd_name, - "delay unmount") == 0) { - mms_trace(MMS_DEVP, - "do not remove " - "this delay unmount"); - } else { - child->cmd_remove = 1; - } - } - - } - pthread_mutex_unlock(&data->mm_queue_mutex); - mms_trace(MMS_DEVP, "Done removing commands"); - return (0); -} - - - -/* - * mm_remove_mmp_client - * - * Parameters: - * - mm_wka : ptr to cli work area, mm_wka_t - * - db_main : ptr to valid db connection, mm_db_t - * - * Does clean up for an MMP client, reset any states that need - * to be reset. If the client has a tape mounted, add commands - * to free that resource - * - * Return Values: - * 0 : for successful cleanup - * 1 : for errors - * - */ -int -mm_remove_mmp_client(mm_wka_t *mm_wka, mm_db_t *db_main) { - char *drive_name = NULL; - char *cartridge_pcl = NULL; - char *library_name = NULL; - - PGresult *mount_results; - int physical = 0; - - mm_data_t *mm_data = mm_wka->mm_data; - - int i = 0; - int num_mounts = 0; - - mm_command_t *cur_cmd; - - /* Do any MMP specific tasks here */ - - /* If this is a MMP client, check the MOUNTPHYSICAL */ - /* schedule a clear drive */ - if (mm_db_exec(HERE, db_main, - "select distinct " - "\"MOUNTPHYSICAL\".\"DriveName\"," - "\"MOUNTPHYSICAL\".\"CartridgePCL\", " - "\"MOUNTPHYSICAL\".\"LibraryName\" " - "from \"MOUNTPHYSICAL\"" - "where" - "(" - "\"MOUNTPHYSICAL\".\"SessionID\" = '%s');", - mm_wka->session_uuid) - != MM_DB_DATA) { - mms_trace(MMS_ERR, "Error getting MOUNTPHYSICAL"); - mm_clear_db(&db_main->mm_db_results); - return (1); - } - mount_results = db_main->mm_db_results; - num_mounts = PQntuples(mount_results); - mms_trace(MMS_DEVP, - "client has %d tapes mounted", - num_mounts); - for (i = 0; i < num_mounts; i++) { - drive_name = PQgetvalue(mount_results, - i, 0); - cartridge_pcl = PQgetvalue(mount_results, - i, 1); - library_name = PQgetvalue(mount_results, - i, 2); - - mms_trace(MMS_INFO, - "%s %s has tape mounted, %s %s %s, clear drive", - mm_wka->wka_conn.cci_client, - mm_wka->wka_conn.cci_instance, - cartridge_pcl, drive_name, - library_name); - /* Reset resources */ - - /* Set States For a Clear Drive */ - (void) mm_db_exec(HERE, db_main, - "update \"DRIVE\" set " - "\"DriveStateSoft\" = 'ready' " - "where \"DriveName\" = '%s';", - drive_name); - - (void) mm_db_exec(HERE, db_main, - "update \"CARTRIDGE\" set " - "\"CartridgeStatus\" = 'available' " - "where \"CartridgePCL\" = " - "'%s' and \"LibraryName\" = '%s';", - cartridge_pcl, - library_name); - - /* If this client does not have an outstanding */ - /* physical unmount, add a non-physical clear */ - pthread_mutex_lock(&data->mm_queue_mutex); - mms_list_foreach(&mm_data->mm_cmd_queue, cur_cmd) { - /* wka is the same, cmd is unmount */ - /* unmount is physical, and drive are the same */ - if ((cur_cmd->wka_ptr == mm_wka) && - (cur_cmd->cmd_func == mm_unmount_cmd_func) && - (cur_cmd->cmd_mount_info.cui_physical == 1) && - (strcmp(cur_cmd->cmd_mount_info.cmi_drive, - drive_name) == 0)) { - physical = 1; - } - } - pthread_mutex_unlock(&data->mm_queue_mutex); - - if (physical) { - mms_trace(MMS_DEVP, - "adding a physical force unmount"); - (void) mm_add_clear_drive(drive_name, - mm_wka->mm_data, - db_main, - NULL, - cartridge_pcl, 1, 0); - } else { - mms_trace(MMS_DEVP, - "adding a non-physical unmount "); - (void) mm_add_clear_drive(drive_name, - mm_wka->mm_data, - db_main, - NULL, - cartridge_pcl, 0, 1); - } - } - mm_clear_db(&mount_results); - - return (0); - - - -} - - -/* - * mm_remove_dmp_client - * - * Parameters: - * - mm_wka : ptr to cli work area, mm_wka_t - * - db_main : ptr to valid db connection, mm_db_t - * - * Does clean up for an DMP client, reset any states that need - * to be reset. Copy any existing handle information for this DM - * from MOUNTLOGICAL to STALEHANDLE - * - * If this DM recieved an unwelcome response, return without altering - * any state information - * - * Return Values: - * None - * - */ -void -mm_remove_dmp_client(mm_wka_t *mm_wka, mm_db_t *db_main) { - PGresult *mount_logical; - int rows; - int rc; - /* try to add dmdown event */ - /* copy mountlogical to stalehandle */ - /* delete the config for this dm */ - - if (mm_wka->wka_unwelcome) { - mms_trace(MMS_DEVP, - "mm_remove_dmp_client: " - "DM was unwelcome, skip clean up"); - return; - } - - (void) mm_notify_add_dmdown_dc(mm_wka, - db_main); - /* Move MOUNTLOGICAL to STALEHANDLE */ - rc = mm_db_exec(HERE, db_main, - "select \"ApplicationName\", " \ - "\"VolumeName\", \"PartitionName\", "\ - "\"SideName\", \"CartridgeID\", "\ - "\"DriveName\", \"DMName\", "\ - "\"MountLogicalHandle\" "\ - "from\"MOUNTLOGICAL\" " \ - "where \"DMName\" = '%s';", - mm_wka->wka_conn.cci_instance); - if (rc != MM_DB_DATA) { - /* error */ - mms_trace(MMS_ERR, "Error getting "\ - "MOUNTLOGICAL handles"); - mm_clear_db(&db_main->mm_db_results); - (void) mm_db_txn_rollback(db_main); - return; - } - - mount_logical = db_main->mm_db_results; - rows = PQntuples(mount_logical); - for (int i = 0; i < rows; i ++) { - /* Move 1 MOUNTLOGICAL to STALEHANDLE */ - if (mm_db_exec(HERE, db_main, - "insert into \"STALEHANDLE\" "\ - "(\"ApplicationName\", "\ - "\"VolumeName\", " \ - "\"PartitionName\", "\ - "\"SideName\", "\ - "\"CartridgeID\", " \ - "\"DriveName\", \"DMName\", "\ - "\"MountLogicalHandle\") "\ - "values " \ - "('%s', '%s', '%s', '%s', "\ - "'%s', '%s', '%s', '%s');", - PQgetvalue(mount_logical, i, 0), - PQgetvalue(mount_logical, i, 1), - PQgetvalue(mount_logical, i, 2), - PQgetvalue(mount_logical, i, 3), - PQgetvalue(mount_logical, i, 4), - PQgetvalue(mount_logical, i, 5), - PQgetvalue(mount_logical, i, 6), - PQgetvalue(mount_logical, - i, 7)) != MM_DB_OK) { - mms_trace(MMS_ERR, "Error moving " - "MOUNTLOGICAL to STALEHANDLE"); - mm_clear_db(&db_main->mm_db_results); - } - } - mm_clear_db(&mount_logical); - if (mm_db_exec(HERE, db_main, - "delete from \"MOUNTLOGICAL\" where "\ - "\"DMName\" = '%s';", - mm_wka->wka_conn.cci_instance) != - MM_DB_OK) { - mms_trace(MMS_ERR, "Error removeing "\ - "MOUNTLOGICAL"); - mm_clear_db(&db_main->mm_db_results); - } - - - if (mm_db_exec(HERE, db_main, - "update \"DM\" set "\ - "\"DMStateSoft\" = " \ - "'absent' where \"DMName\" = '%s';", - mm_wka->wka_conn.cci_instance) != - MM_DB_OK) { - mms_trace(MMS_ERR, - "Error updating "\ - "DMStateSoft"); - mm_clear_db(&db_main->mm_db_results); - } - - (void) delete_dm_config(mm_wka, db_main); - -} - - - -/* - * mm_remove_dmp_client - * - * Parameters: - * - mm_wka : ptr to cli work area, mm_wka_t - * - db_main : ptr to valid db connection, mm_db_t - * - * Does clean up for an LMP client, reset any states that need - * to be reset. - * - * If this LM recieved an unwelcome response, return without altering - * any state information - * - * Return Values: - * None - * - */ -void -mm_remove_lmp_client(mm_wka_t *mm_wka, mm_db_t *db_main) { - /* Try to add an lmdown event */ - /* Set LMStateSoft == 'absent' */ - - if (mm_wka->wka_unwelcome) { - mms_trace(MMS_DEVP, - "mm_remove_lmp_client: " - "LM was unwelcome, skip clean up"); - return; - } - - (void) mm_notify_add_lmdown_dc(mm_wka, - db_main); - if (mm_db_exec(HERE, db_main, "UPDATE \"LM\" SET " - "\"LMStateSoft\" = 'absent' WHERE \"LibraryName\" = '%s' " - "AND \"LMName\" = '%s';", mm_wka->wka_conn.cci_client, - mm_wka->wka_conn.cci_instance) != MM_DB_OK) { - mms_trace(MMS_ERR, - "Error removing LIBRARY LM"); - } -} - -/* - * mm_remove_connection - * - * Parameters: - * - mm_wka : ptr to cli work area, mm_wka_t - * - db_main : ptr to valid db connection, mm_db_t - * - * Do general clean up for all connections (MMP, DMP, LMP) - * Cancel any notficitaions for the client, reset connection - * object states - * - * Return Values: - * None - * - */ -void -mm_remove_connection(mm_wka_t *mm_wka, mm_db_t *db_main) { - char *savepoint = NULL; - PGresult *results; - - (void) mm_db_txn_begin(db_main); - if (mm_request_disconnect(db_main, mm_wka)) { - mms_trace(MMS_ERR, "Error updating REQUESTs"); - } - if (mm_db_exec(HERE, db_main, MM_DELETE_NOTIFY, - mm_wka->wka_conn.cci_uuid) - != MM_DB_OK) { - mms_trace(MMS_ERR, "Error removing NOTIFY"); - } - /* Get all NotifyId's and drop the rules */ - if (mm_db_exec(HERE, db_main, - "select \"NotifyID\",\"NotifyObject\"" - " from \"NOTIFYRULES\" where " - "\"ConnectionID\" = '%s';", - mm_wka->wka_conn.cci_uuid) == MM_DB_DATA) { - results = db_main->mm_db_results; - for (int i = 0; i < PQntuples(results); i++) { - savepoint = mms_strnew("\"%s\"", - PQgetvalue(results, i, 0)); - if (mm_db_txn_savepoint(db_main, - savepoint) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_remove_connection: " - "db error setting savepoint"); - } - if (mm_db_exec(HERE, db_main, - "drop rule \"%s\" on \"%s\";", - PQgetvalue(results, i, 0), - PQgetvalue(results, i, 1)) != - MM_DB_OK) { - if (mm_db_txn_savepoint_rollback(db_main, - savepoint) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_remove_connection: " - "db error rollingback savepoint"); - } - } - if (mm_db_txn_release_savepoint(db_main, - savepoint) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_remove_connection: " - "db error releasing savepoint"); - } - free(savepoint); - savepoint = NULL; - } - mm_clear_db(&results); - } else { - mms_trace(MMS_ERR, - "error reading notify id from table"); - mm_clear_db(&db_main->mm_db_results); - } - if (mm_db_exec(HERE, db_main, MM_DELETE_NOTIFYRULES, - mm_wka->wka_conn.cci_uuid) - != MM_DB_OK) { - mms_trace(MMS_ERR, "Error removing NOTIFYRULES"); - } - if (mm_wka->mm_wka_mm_lang == MM_LANG_MMP && - (mm_wka->session_uuid != NULL) && - mm_db_exec(HERE, db_main, MM_DELETE_SESSION, - mm_wka->session_uuid) - != MM_DB_OK) { - mms_trace(MMS_ERR, "Error removing SESSION"); - } - if (mm_db_exec(HERE, db_main, MM_DELETE_CONNECTION, - mm_wka->wka_conn.cci_uuid) - != MM_DB_OK) { - mms_trace(MMS_ERR, "Error removing CONNECTION"); - } - - (void) mm_db_txn_commit(db_main); -} - -/* - * mm_remove_clients - * - * Parameters: - * - mm_data : ptr to mm_data_t - * - db : ptr to valid db connection, mm_db_t - * - * Check all client work areas in the work area list for - * connections that need removal. For each client that needs - * to be removed, call the approperate clean up functions - * - * This function should cause the reset of the - * approperate db states and free memory assocated with - * the disconnected clients - * - * Return Values: - * 0 : return 0 for success - * 1 : return 1 for errors - * - */ -static int -mm_remove_clients(mm_data_t *mm_data, mm_db_t *db) -{ - - mm_wka_t *mm_wka; - int go = 1; - int remove; - - mms_trace(MMS_DEVP, - "mm_remove_clients"); - - /* - * Find bad file descriptors - * - * Also need to remove all commands from - * queue that are asscociated with - * the bad FD - */ - /* mms_trace(MMS_INFO, "Inside remove clients"); */ - if (mm_is_fd_valid(mm_data->mm_service_fd) != 0) { - mms_trace(MMS_ERR, "mm service not valid FD -> %d", - mm_data->mm_service_fd); - /* Service Not Valid */ - return (1); - } - - while (go) { - remove = 0; - pthread_mutex_lock(&data->mm_wka_mutex); - mms_list_foreach(&mm_data->mm_wka_list, mm_wka) { - /* mms_trace(MMS_INFO," Checking a wka"); */ - if (mm_wka->wka_remove) { - remove = 1; - break; - } - if (mm_is_fd_valid(mm_wka->mm_wka_conn->mms_fd) != 0) { - /* Not Valid */ - mms_trace(MMS_ERR, "mm_is_fd_valid found " - "bad FD -> %d", - mm_wka->mm_wka_conn->mms_fd); - - remove = 1; - break; - } - } - - pthread_mutex_unlock(&data->mm_wka_mutex); - - if (remove) { - /* Destroy the wka */ - pthread_mutex_lock(&data->mm_wka_mutex); - pthread_mutex_lock(&mm_wka->wka_local_lock); - mms_list_remove(&mm_data->mm_wka_list, mm_wka); - pthread_mutex_unlock(&data->mm_wka_mutex); - pthread_mutex_unlock(&mm_wka->wka_local_lock); - - - /* Remove commands associated with this wka */ - if (mm_remove_commands(mm_data, db, mm_wka)) { - mms_trace(MMS_ERR, "Error removing commands"); - } - - if (mm_wka->mm_wka_mm_lang == MM_LANG_MMP) { - /* Clean up for MMP client */ - (void) mm_remove_mmp_client(mm_wka, db); - } - if (mm_wka->mm_wka_mm_lang == MM_LANG_DMP) { - /* Clean up for DMP client */ - (void) mm_remove_dmp_client(mm_wka, db); - } - if (mm_wka->mm_wka_mm_lang == MM_LANG_LMP) { - /* Clean up for LMP client */ - (void) mm_remove_lmp_client(mm_wka, db); - } - - /* Clean up connections */ - mm_remove_connection(mm_wka, db); - - /* free(mm_wka); */ - mms_close(mm_wka->mm_wka_conn); - mm_destroy_wka(mm_wka); - } else { - go = 0; - } - } - - return (0); -} - - -/* - * mm_add_wka - * - * Parameters: - * - mm_data : ptr to mm_data_t - * - conn : ptr to MMS connection struct, mms_t - * - * Allocate and intialize a new client work area (mm_wka_t) - * using the connection information in conn - * - * Return Values: - * 0 : for success - * 1 : for errors - * - */ -int -mm_add_wka(mm_data_t *mm_data, mms_t *conn) -{ - mm_wka_t *mm_wka; - - mm_wka = (mm_wka_t *)calloc(1, sizeof (mm_wka_t)); - if (mm_wka == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_wka_t fd %d: %s", - conn->mms_fd, strerror(errno)); - mms_close(conn); - return (1); - } - /* - * Allocate empty connection strings for - * access before a client says hello. - */ - mm_wka->wka_conn.cci_client = strdup(""); - mm_wka->wka_conn.cci_instance = strdup(""); - mm_wka->wka_conn.cci_language = strdup(""); - mm_wka->wka_conn.cci_version = strdup(""); - mm_wka->wka_conn.cci_password = strdup(""); - mm_wka->wka_conn.cci_certificate = strdup(""); - mm_wka->wka_conn.cci_authentication = strdup(""); - - if (mm_connect_info(conn->mms_fd, &mm_wka->wka_conn)) { - mms_trace(MMS_ERR, "Connect id failed fd %d", conn->mms_fd); - free(mm_wka); - mms_close(conn); - return (1); - } - - mms_trace(MMS_INFO, - "Added client, host = %s(%s)", mm_wka->wka_conn.cci_host, - mm_wka->wka_conn.cci_ip); - - mm_wka->mm_wka_conn = conn; - mm_wka->mm_data = mm_data; - mm_wka->wka_hello_needed = B_TRUE; - mm_wka->wka_remove = 0; - mm_wka->wka_need_accept = 0; - mm_wka->wka_goodbye = 0; - mm_wka->wka_unwelcome = 0; - mm_get_uuid(mm_wka->wka_conn.cci_uuid); - pthread_mutex_init(&mm_wka->wka_local_lock, NULL); - - pthread_mutex_lock(&data->mm_wka_mutex); - mms_list_insert_tail(&mm_data->mm_wka_list, mm_wka); - pthread_mutex_unlock(&data->mm_wka_mutex); - mms_trace(MMS_DEVP, "Wka added Successfully- %d", - mm_wka->mm_wka_conn->mms_fd); - return (0); -} - -/* - * mm_response_cmd_func - * - * Parameters: - * - mm_wka : ptr to cli work area, mm_wka_t - * - rsp_cmd : ptr to mm_command_t - * - * command function for all responses, this function will - * find the command matching this response and set the response - * values for that command. it will also set the approperate - * flags for the command based on the type of response - * (error, accept, success) - * - * Return Values: - * One of the Dispatcher return codes, see mm.h - * (MM_CMD_DONE, MM_NO_DISPATCH etc...) - * - */ -int -mm_response_cmd_func(mm_wka_t *mm_wka, mm_command_t *rsp_cmd) -{ - - /* - * A response has been recieved, - * Find the the matching command in the queue, - * - * check: - * mm_wka->cci_uuid matches rsp_uuid (same connection) - * command's task is the same - * - * Set the command's flag to dispatchable - * Save parsed response in cmd_response - * return MM_CMD_DONE - */ - - char *rsp_uuid = mm_wka->wka_conn.cci_uuid; - char *rsp_task; - mm_command_t *cur_cmd; - mm_data_t *mm_data = mm_wka->mm_data; - char *task; - int skip = 0; - - - mms_trace(MMS_DEVP, "mm_response_cmd_func"); - - mms_trace(MMS_DEVP, "rsp_uuid %s", rsp_uuid); - rsp_task = mm_get_task(rsp_cmd->cmd_root); - if (rsp_task != NULL) { - mms_trace(MMS_DEVP, "rsp_task %s", rsp_task); - } else { - mms_trace(MMS_ERR, - "No task clause in response"); - return (MM_CMD_ERROR); - } - pthread_mutex_lock(&data->mm_queue_mutex); - mms_list_foreach(&mm_data->mm_cmd_queue, cur_cmd) { - if ((cur_cmd->cmd_remove == 1) || - (cur_cmd->wka_ptr == NULL)) { - mms_trace(MMS_ERR, "bad wka/cmd_remove " - "set for a cmd, continue"); - continue; - } - mms_trace(MMS_DEVP, "cur_cmd->wka_ptr->wka_conn.cci_uuid %s", - cur_cmd->wka_ptr->wka_conn.cci_uuid); - skip = 0; - if (cur_cmd != rsp_cmd) { - if (cur_cmd->cmd_root != NULL) { - if (strcmp(mms_pn_token(cur_cmd->cmd_root), - "response") == 0) { - skip = 1; - } - } - - if (strcmp(rsp_uuid, - cur_cmd->wka_ptr->wka_conn.cci_uuid) == 0) { - /* From the same connection */ - if ((task = cur_cmd->cmd_task) != NULL) { - mms_trace(MMS_DEVP, "task %s", task); - } - if (strcmp(rsp_task, task) == 0) { - mms_trace(MMS_DEVP, "same task"); - /* Same Task */ - if (!skip) - break; - } - } - } - } - pthread_mutex_unlock(&data->mm_queue_mutex); - - if (cur_cmd) { - (void) mm_message_command(rsp_cmd); - - if (mms_pn_lookup(rsp_cmd->cmd_root, - "accepted", - MMS_PN_KEYWORD, NULL)) { - mms_trace(MMS_DEBUG, "%s accepted", - cur_cmd->cmd_name); - if (cur_cmd->cmd_response != NULL) { - mms_pn_destroy(cur_cmd->cmd_response); - } - cur_cmd->cmd_response = rsp_cmd->cmd_root; - rsp_cmd->cmd_root = NULL; - cur_cmd->cmd_flags |= MM_CMD_DISPATCHABLE; - free(rsp_task); - return (MM_DISPATCH_AGAIN); - } else { - if (MM_IS_SET(cur_cmd->cmd_flags, MM_CMD_NEED_ACCEPT)) { - mms_trace(MMS_DEVP, "CMD still needs acc"); - rsp_cmd->cmd_flags |= MM_CMD_DISPATCHABLE; - free(rsp_task); - return (MM_NO_DISPATCH); - } - mms_trace(MMS_DEBUG, "%s final command response", - cur_cmd->cmd_name); - if (cur_cmd->cmd_response != NULL) { - mms_pn_destroy(cur_cmd->cmd_response); - } - cur_cmd->cmd_response = rsp_cmd->cmd_root; - rsp_cmd->cmd_root = NULL; - cur_cmd->cmd_flags |= MM_CMD_DISPATCHABLE; - if (cur_cmd->cmd_root != NULL) { - mms_trace(MMS_DEVP, "set %s for dispatch, %p", - mms_pn_token(cur_cmd->cmd_root), - cur_cmd); - } else { - mms_trace(MMS_DEVP, - "set NULL root for dispatch, %p", - cur_cmd); - } - free(rsp_task); - return (MM_DISPATCH_AGAIN); - } - } - mms_trace(MMS_DEBUG, "mm_response_cmd_func end MM_CMD_ERROR"); - mms_trace(MMS_ERR, "Couldnt match response to outstanding command"); - free(rsp_task); - return (MM_CMD_ERROR); -} - -/* - * mm_handle_parser_error - * - * Parameters: - * - cmd : ptf to mms_par_node_t of a MMP/DMP/LMP command - * - err_list : error list for this error, ptf to mms_list_t - * - * Attempt to parse the partial parse tree and determine what the cmd is - * If it can be determined that the command is a hello return unwelcome, - * if the command is an MMP/DMP/LMP command return unacceptable, - * if the command is a response or unknown, don't send a response - * - * Return Values: - * MM_PAR_ERROR : if cmd is unknown - * MM_PAR_SEND_UNWEL : if cmd is hello command - * MM_PAR_IS_RESP : if command is a response - * MM_PAR_NO_MEM : parser is out of memory - * MM_PAR_SEND_UNACC : if cmd requres an unaccep response - * - */ -int -mm_handle_parser_error(mms_par_node_t *cmd, mms_list_t *err_list) { - mms_par_err_t *err; /* Used to step through error list */ - mms_par_node_t *root; /* Ptr to cmd node of parse tree */ - int syntax = 0; /* Number of syntax errors in cmd */ - - /* Need unaccept list */ - int num_unaccept = 34; - char *unaccept[34]; - - int ret_val; - - unaccept[0] = strdup("mount"); - unaccept[1] = strdup("create"); - unaccept[2] = strdup("goodbye"); - unaccept[3] = strdup("delete"); - unaccept[4] = strdup("show"); - unaccept[5] = strdup("locale"); - unaccept[6] = strdup("privilege"); - unaccept[7] = strdup("begin"); - unaccept[8] = strdup("unmount"); - unaccept[9] = strdup("end"); - unaccept[10] = strdup("allocate"); - unaccept[11] = strdup("deallocate"); - unaccept[12] = strdup("rename"); - unaccept[13] = strdup("shutdown"); - unaccept[14] = strdup("cpscan"); - unaccept[15] = strdup("cpreset"); - unaccept[16] = strdup("cpexit"); - unaccept[17] = strdup("cpstart"); - unaccept[18] = strdup("move"); - unaccept[19] = strdup("eject"); - unaccept[20] = strdup("inject"); - unaccept[21] = strdup("cancel"); - unaccept[22] = strdup("notify_chg"); - unaccept[23] = strdup("config"); - unaccept[24] = strdup("activate"); - unaccept[25] = strdup("ready"); - unaccept[26] = strdup("private"); - unaccept[27] = strdup("drive"); - unaccept[28] = strdup("library"); - unaccept[29] = strdup("identity"); - unaccept[30] = strdup("request"); - unaccept[31] = strdup("message"); - unaccept[32] = strdup("direct"); - unaccept[33] = strdup("setpassword"); - - mms_list_foreach(err_list, err) { - switch (err->pe_code) { - case MMS_PE_NOMEM: - mms_trace(MMS_ERR, "mm_handle_parser_error: " - "Parser error detected no memory " - "available"); - ret_val = MM_PAR_NO_MEM; - goto end; - case MMS_PE_SYNTAX: - syntax++; - break; - case MMS_PE_MAX_LEVEL: - mms_trace(MMS_ERR, "mm_handle_parser_error: " - "Parser error detected max level " - "reached"); - ret_val = MM_PAR_ERROR; - goto end; - default: - mms_trace(MMS_ERR, "mm_handle_parser_error: " - "Invalid parser err encountered - %d", - err->pe_code); - /* XXX DO MMS_ERROR RECOVERY IN THIS. SNO */ - /* SINCE ONLY 3 MMS_ERROR CONDITIONS EXIST */ - ret_val = MM_PAR_ERROR; - goto end; - } - mms_trace(MMS_ERR, - "mm_handle_parser_error: error mms_mmp_parse, \n" - " line %d, col %d, near token \"%s\", " - "err code %d, %s", - err->pe_line, - err->pe_col, - err->pe_token, - err->pe_code, - err->pe_msg); - } - - if (!syntax) { - mms_trace(MMS_ERR, - "mm_handle_parser_error: Parse error was not " - "a valid error condition for MM, Unable to process " - "error"); - ret_val = MM_PAR_ERROR; - goto end; - } - - mms_trace(MMS_ERR, - "mm_handle_parser_error: Parse error was syntax error. " - "Num of errors - %d", syntax); - - root = mms_pn_lookup(cmd, NULL, MMS_PN_CMD, NULL); - if (root == NULL) { - mms_trace(MMS_ERR, "mm_handle_parser_error: Input string was a " - "complete mess, no cmd found"); - /* NEED TO HANDLE MMS_ERROR CASE, UNABLE DETERMINE IF MESSAGE */ - /* WAS A CMD, CMD RESPONSE, CMD ACCEPT, NOT ABLE TO DETERMINE */ - /* WHAT TYPE OF RESPONSE SHOULD BE SENT IF ONE SHOULD BE XXX */ - ret_val = MM_PAR_ERROR; - goto end; - } - - - /* The command has a syntax error, but root != NULL */ - /* Check root, send unaccept for valid commands, */ - /* send unwelcome for hello, skip resoponses and */ - /* unrecognized commands */ - - for (int i = 0; i < num_unaccept; i ++) { - if (strcmp(root->pn_string, - unaccept[i]) == 0) { - mms_trace(MMS_ERR, " %s had a syntax error," - " send unaccept", unaccept[i]); - ret_val = MM_PAR_SEND_UNACC; - goto end; - } - } - - if (strcmp(root->pn_string, "hello") == 0) { - mms_trace(MMS_ERR, " hello had a syntax error," - " send unwelcome"); - /* send an unwelcome for hello */ - ret_val = MM_PAR_SEND_UNWEL; - goto end; - } else if (strcmp(root->pn_string, - "response") == 0) { - /* Don't send an unacceptable for response */ - mms_trace(MMS_ERR, " response had a syntax error, " - "Don't send unacceptable"); - ret_val = MM_PAR_IS_RESP; - goto end; - } - /* shouldn't ever get here */ - ret_val = MM_PAR_ERROR; - -end: - for (int i = 0; i < num_unaccept; i ++) { - if (unaccept[i]) - free(unaccept[i]); - } - return (ret_val); -} - - -/* - * mm_setup_cmd - * - * Parameters: - * - cmd : ptr to mm_command_t - * - buf : pointer to char string of cmd text - * - * Parses the string in buf and sets up the mm_command_t struct - * Sets the cmd_function pointer for the command - * if there is problem parsing the command, send the approperate - * response to the client (unwelcome or unacceptable) - * - * Return Values: - * 0 : for errors - * 1 : for success - * 2 : for success and cmd was a part of a begin-end group - * - */ -int -mm_setup_cmd(mm_command_t *cmd, char *buf) -{ - mms_par_node_t *root; - int rc; - mms_list_t err_list; - mm_wka_t *mm_wka = cmd->wka_ptr; - int send_acc = 1; - int parse_error = 0; - - /* Parse error */ - int send_unwelcome = 0; - int send_unacceptable = 0; - int is_response = 0; - int p_err_rc; - - /* Begin-end */ - mm_command_t *cur_cmd; - - root = mms_pn_lookup(cmd->cmd_root, NULL, MMS_PN_CMD, NULL); - switch (cmd->cmd_language) { - case MM_LANG_MMP: - mms_trace(MMS_DEVP, "Parse MMP cmd"); - rc = mms_mmp_parse(&root, &err_list, buf); - if (rc) { - mms_trace(MMS_DEVP, "parse error fd -> %d", - cmd->wka_ptr->mm_wka_conn->mms_fd); - p_err_rc = mm_handle_parser_error(root, &err_list); - if (p_err_rc == MM_PAR_SEND_UNACC) { - send_unacceptable = 1; - } - if (p_err_rc == MM_PAR_SEND_UNWEL) { - send_unwelcome = 1; - } - if (p_err_rc == MM_PAR_IS_RESP) { - is_response = 1; - } - mms_pe_destroy(&err_list); - cmd->cmd_remove = 1; - parse_error = 1; - break; - } - mms_pe_destroy(&err_list); - - cmd->cmd_root = root; - cmd->cmd_task = mm_get_task(cmd->cmd_root); - - if (strcmp(mms_pn_token(root), "hello") == 0) { - cmd->cmd_func = mm_hello_cmd_func; - send_acc = 0; - } else if (strcmp(mms_pn_token(root), - "response") == 0) { - cmd->cmd_func = mm_response_cmd_func; - send_acc = 0; - } else if (strcmp(mms_pn_token(root), - "mount") == 0) { - cmd->cmd_func = mm_mount_cmd_func; - } else if (strcmp(mms_pn_token(root), - "create") == 0) { - cmd->cmd_func = mm_create_cmd_func; - } else if (strcmp(mms_pn_token(root), - "goodbye") == 0) { - cmd->cmd_func = mm_goodbye_cmd_func; - } else if (strcmp(mms_pn_token(root), - "delete") == 0) { - cmd->cmd_func = mm_delete_cmd_func; - } else if (strcmp(mms_pn_token(root), - "show") == 0) { - cmd->cmd_func = mm_show_cmd_func; - } else if (strcmp(mms_pn_token(root), - "attribute") == 0) { - cmd->cmd_func = mm_attribute_cmd_func; - } else if (strcmp(mms_pn_token(root), - "locale") == 0) { - cmd->cmd_func = mm_locale_cmd_func; - } else if (strcmp(mms_pn_token(root), - "privilege") == 0) { - cmd->cmd_func = mm_privilege_cmd_func; - } else if (strcmp(mms_pn_token(root), - "begin") == 0) { - cmd->cmd_func = mm_begin_cmd_func; - } else if (strcmp(mms_pn_token(root), - "unmount") == 0) { - cmd->cmd_func = mm_unmount_cmd_func; - } else if (strcmp(mms_pn_token(root), - "end") == 0) { - cmd->cmd_func = mm_end_cmd_func; - } else if (strcmp(mms_pn_token(root), - "allocate") == 0) { - cmd->cmd_func = mm_allocate_cmd_func; - } else if (strcmp(mms_pn_token(root), - "deallocate") == 0) { - cmd->cmd_func = mm_deallocate_cmd_func; - } else if (strcmp(mms_pn_token(root), - "rename") == 0) { - cmd->cmd_func = mm_rename_cmd_func; - } else if (strcmp(mms_pn_token(root), - "shutdown") == 0) { - cmd->cmd_func = mm_shutdown_cmd_func; - } else if (strcmp(mms_pn_token(root), - "cpscan") == 0) { - cmd->cmd_func = mm_cpscan_cmd_func; - } else if (strcmp(mms_pn_token(root), - "cpreset") == 0) { - cmd->cmd_func = mm_cpreset_cmd_func; - } else if (strcmp(mms_pn_token(root), - "cpexit") == 0) { - cmd->cmd_func = mm_cpexit_cmd_func; - } else if (strcmp(mms_pn_token(root), - "cpstart") == 0) { - cmd->cmd_func = mm_cpstart_cmd_func; - } else if (strcmp(mms_pn_token(root), - "move") == 0) { - cmd->cmd_func = mm_move_cmd_func; - } else if (strcmp(mms_pn_token(root), - "eject") == 0) { - cmd->cmd_func = mm_eject_cmd_func; - } else if (strcmp(mms_pn_token(root), - "inject") == 0) { - cmd->cmd_func = mm_inject_cmd_func; - } else if (strcmp(mms_pn_token(root), - "notify") == 0) { - cmd->cmd_func = mm_notify_chg_cmd_func; - } else if (strcmp(mms_pn_token(root), - "library") == 0) { - cmd->cmd_func = mm_libonline_cmd_func; - } else if (strcmp(mms_pn_token(root), - "drive") == 0) { - cmd->cmd_func = mm_drvonline_cmd_func; - } else if (strcmp(mms_pn_token(root), - "request") == 0) { - cmd->cmd_func = mm_request_cmd_func; - } else if (strcmp(mms_pn_token(root), - "accept") == 0) { - cmd->cmd_func = mm_accept_cmd_func; - } else if (strcmp(mms_pn_token(root), - "respond") == 0) { - cmd->cmd_func = mm_respond_cmd_func; - } else if (strcmp(mms_pn_token(root), - "release") == 0) { - cmd->cmd_func = mm_release_cmd_func; - } else if (strcmp(mms_pn_token(root), - "cancel") == 0) { - cmd->cmd_func = mm_cancel_cmd_func; - } else if (strcmp(mms_pn_token(root), - "identity") == 0) { - cmd->cmd_func = mm_identity_cmd_func; - } else if (strcmp(mms_pn_token(root), - "message") == 0) { - cmd->cmd_func = mm_message_cmd_func; - } else if (strcmp(mms_pn_token(root), - "direct") == 0) { - cmd->cmd_func = mm_direct_cmd_func; - } else if (strcmp(mms_pn_token(root), - "setpassword") == 0) { - cmd->cmd_func = mm_setpassword_cmd_func; - } else { - mms_trace(MMS_DEBUG, "Command Not implemented yet"); - } - break; - case MM_LANG_DMP: - mms_trace(MMS_DEVP, "Parse DMP cmd"); - rc = mms_dmpd_parse(&root, &err_list, buf); - if (rc) { - mms_trace(MMS_DEVP, "parse error fd -> %d", - cmd->wka_ptr->mm_wka_conn->mms_fd); - p_err_rc = mm_handle_parser_error(root, &err_list); - if (p_err_rc == MM_PAR_SEND_UNACC) { - send_unacceptable = 1; - } - if (p_err_rc == MM_PAR_SEND_UNWEL) { - send_unwelcome = 1; - } - if (p_err_rc == MM_PAR_IS_RESP) { - is_response = 1; - } - mms_pe_destroy(&err_list); - cmd->cmd_remove = 1; - parse_error = 1; - break; - } - mms_pe_destroy(&err_list); - - cmd->cmd_root = root; - cmd->cmd_task = mm_get_task(cmd->cmd_root); - - if (strcmp(mms_pn_token(root), "hello") == 0) { - cmd->cmd_func = mm_hello_cmd_func; - send_acc = 0; - } else if (strcmp(mms_pn_token(root), - "response") == 0) { - cmd->cmd_func = mm_response_cmd_func; - send_acc = 0; - } else if (strcmp(mms_pn_token(root), "show") == 0) { - cmd->cmd_func = mm_show_cmd_func; - } else if (strcmp(mms_pn_token(root), "attribute") == 0) { - cmd->cmd_func = mm_attribute_cmd_func; - } else if (strcmp(mms_pn_token(root), - "create") == 0) { - cmd->cmd_func = mm_create_cmd_func; - } else if (strcmp(mms_pn_token(root), "private") == 0) { - cmd->cmd_func = mm_private_cmd_func; - } else if (strcmp(mms_pn_token(root), "config") == 0) { - cmd->cmd_func = mm_dmp_config_cmd_func; - } else if (strcmp(mms_pn_token(root), "activate") == 0) { - cmd->cmd_func = mm_dmp_activate_cmd_func; - } else if (strcmp(mms_pn_token(root), "ready") == 0) { - cmd->cmd_func = mm_dmp_ready_cmd_func; - } else if (strcmp(mms_pn_token(root), - "notify") == 0) { - cmd->cmd_func = mm_notify_chg_cmd_func; - } else if (strcmp(mms_pn_token(root), "message") == 0) { - cmd->cmd_func = mm_message_cmd_func; - } else if (strcmp(mms_pn_token(root), "request") == 0) { - cmd->cmd_func = mm_request_cmd_func; - } else if (strcmp(mms_pn_token(root), "cancel") == 0) { - cmd->cmd_func = mm_dmp_cancel_cmd_func; - } else { - mms_trace(MMS_DEBUG, "Command Not implemented yet"); - } - break; - case MM_LANG_LMP: - mms_trace(MMS_DEVP, "Parse LMP cmd"); - rc = mms_lmpl_parse(&root, &err_list, buf); - if (rc) { - mms_trace(MMS_DEVP, "parse error fd -> %d", - cmd->wka_ptr->mm_wka_conn->mms_fd); - p_err_rc = mm_handle_parser_error(root, &err_list); - if (p_err_rc == MM_PAR_SEND_UNACC) { - send_unacceptable = 1; - } - if (p_err_rc == MM_PAR_SEND_UNWEL) { - send_unwelcome = 1; - } - if (p_err_rc == MM_PAR_IS_RESP) { - is_response = 1; - } - mms_pe_destroy(&err_list); - cmd->cmd_remove = 1; - parse_error = 1; - break; - } - mms_pe_destroy(&err_list); - - cmd->cmd_root = root; - cmd->cmd_task = mm_get_task(cmd->cmd_root); - - if (strcmp(mms_pn_token(root), "hello") == 0) { - cmd->cmd_func = mm_hello_cmd_func; - send_acc = 0; - } else if (strcmp(mms_pn_token(root), - "response") == 0) { - cmd->cmd_func = mm_response_cmd_func; - send_acc = 0; - } else if (strcmp(mms_pn_token(root), "show") == 0) { - cmd->cmd_func = mm_show_cmd_func; - } else if (strcmp(mms_pn_token(root), "attribute") == 0) { - cmd->cmd_func = mm_attribute_cmd_func; - } else if (strcmp(mms_pn_token(root), "private") == 0) { - cmd->cmd_func = mm_private_cmd_func; - } else if (strcmp(mms_pn_token(root), "config") == 0) { - cmd->cmd_func = mm_lmp_config_cmd_func; - } else if (strcmp(mms_pn_token(root), "ready") == 0) { - cmd->cmd_func = mm_lmp_ready_cmd_func; - } else if (strcmp(mms_pn_token(root), "activate") == 0) { - cmd->cmd_func = mm_lmp_activate_cmd_func; - } else if (strcmp(mms_pn_token(root), "mount") == 0) { - cmd->cmd_func = mm_lmp_mount_cmd_func; - } else if (strcmp(mms_pn_token(root), "unmount") == 0) { - cmd->cmd_func = mm_lmp_unmount_cmd_func; - } else if (strcmp(mms_pn_token(root), - "notify") == 0) { - cmd->cmd_func = mm_notify_chg_cmd_func; - } else if (strcmp(mms_pn_token(root), "message") == 0) { - cmd->cmd_func = mm_message_cmd_func; - } else if (strcmp(mms_pn_token(root), "request") == 0) { - cmd->cmd_func = mm_request_cmd_func; - } else if (strcmp(mms_pn_token(root), "cancel") == 0) { - cmd->cmd_func = mm_lmp_cancel_cmd_func; - } else { - mms_trace(MMS_DEBUG, "Command Not implemented yet"); - } - break; - - } - - if (parse_error == 0) { - char *buf_ptr; - - if (cmd->cmd_func == mm_hello_cmd_func || - cmd->cmd_func == mm_setpassword_cmd_func) { - buf_ptr = mms_pn_token(root); - } else { - buf_ptr = buf; - } - mms_trace(MMS_DEBUG, - "command %s %s fd -> %d" - "\n\n%s\n", - mm_wka->wka_conn.cci_client, - mm_wka->wka_conn.cci_instance, - mm_wka->mm_wka_conn->mms_fd, - buf_ptr); - } - - if (parse_error) { - if (send_unwelcome) { - /* Syntax error in a hello command */ - /* send unwelcome */ - mms_pn_destroy(root); - mms_trace(MMS_ERR, "Parse error- response unwelcome"); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(UNWELCOME_PROTO) + 1); - (void) sprintf(cmd->cmd_buf, UNWELCOME_PROTO); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (0); - } else if (send_unacceptable) { - /* Syntax error in valid MM command */ - /* send unacceptable */ - mms_pn_destroy(root); - mms_trace(MMS_ERR, - "Parse error- response unacceptable"); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_UNACCEPTABLE) + 1); - (void) sprintf(cmd->cmd_buf, RESPONSE_UNACCEPTABLE); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (0); - } else if (is_response) { - /* There was a syntax error in the response, */ - /* attempt to process anyways */ - mms_trace(MMS_ERR, "Parse error in response, " - "attempting anyways"); - cmd->cmd_root = root; - cmd->cmd_task = mm_get_task(cmd->cmd_root); - cmd->cmd_func = mm_response_cmd_func; - send_acc = 0; - cmd->cmd_name = strdup("response"); - cmd->cmd_remove = 0; - return (1); - - } else { - /* Unrecoverable error, syntax, no mem */ - /* What to do?? Print message and ignore for now */ - mms_pn_destroy(root); - mms_trace(MMS_ERR, "Unable to parse command root"); - /* Close the connection so the client does not hang */ - mms_close(cmd->wka_ptr->mm_wka_conn); - return (0); - } - - } - rc = 1; - - if (mm_wka->wka_goodbye) { - mms_trace(MMS_DEBUG, - "this client has already " - "sent a goodbye, send unaccept"); - mms_pn_destroy(root); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_UNACCEPTABLE) + 1); - (void) sprintf(cmd->cmd_buf, RESPONSE_UNACCEPTABLE); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (0); - } - - /* If this wka is involved in a begin-end command group, */ - /* send unaccept for all commands execpt, end, mount, unmount */ - if (mm_wka->wka_begin_end.be_active == B_TRUE) { - /* Client is in beg-end group */ - if ((strcmp(mms_pn_token(root), "mount") != 0) && - (strcmp(mms_pn_token(root), "unmount") != 0) && - (strcmp(mms_pn_token(root), "end") != 0)) { - mms_trace(MMS_ERR, - "client in begin end group" - " may only send mount,unmount, or end"); - mms_pn_destroy(root); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_UNACCEPTABLE) + 1); - (void) sprintf(cmd->cmd_buf, RESPONSE_UNACCEPTABLE); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (0); - } else if ((strcmp(mms_pn_token(root), "mount") == 0) || - (strcmp(mms_pn_token(root), "unmount") == 0)) { - /* if this is mount or unmount and to begin cmd list */ - /* Return 2 for special rc code */ - rc = 2; - } - } - - - /* Send an accept for all command that are not hello or response */ - - if (send_acc) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ACCEPTED) + - strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ACCEPTED, cmd->cmd_task); - /* If this command is a begin command */ - /* set begin end mode before sending the accept */ - if (cmd->cmd_func == mm_begin_cmd_func) { - mms_trace(MMS_INFO, - "begin-end mode active"); - mm_wka->wka_begin_end.be_active = B_TRUE; - } - /* If this command is a end command */ - /* set begin end mode off before sending the accept */ - if (cmd->cmd_func == mm_end_cmd_func) { - mms_trace(MMS_INFO, - "begin-end mode disabled"); - mm_wka->wka_begin_end.be_active = B_FALSE; - /* Match this end with a begin */ - pthread_mutex_lock(&data->mm_queue_mutex); - mms_list_foreach(&data->mm_cmd_queue, cur_cmd) { - if ((cur_cmd->wka_ptr == mm_wka) && - (cur_cmd->cmd_func == mm_begin_cmd_func) && - (cur_cmd->cmd_begin_has_end == 0)) { - /* found the begin for this end */ - cmd->cmd_begin_cmd = cur_cmd; - cur_cmd->cmd_begin_has_end = 1; - mms_trace(MMS_DEVP, - "mm_setup_cmd: " - "matched this end (%s, %p) " - "with begin (%s, %p)", - cmd->cmd_task, cmd, - cur_cmd->cmd_task, - cur_cmd); - break; - } - } - pthread_mutex_unlock(&data->mm_queue_mutex); - } - - - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - } - /* Set this commands name */ - cmd->cmd_name = strdup(mms_pn_token(root)); - return (rc); -no_mem: - MM_ABORT_NO_MEM(); - return (0); - - -} - -/* - * mm_add_beginend_cmd - * - * Parameters: - * - mm_wka : ptr to cli work area, mm_wka_t - * - mm_cmd : ptr to mm_command_t - * - mm_data : ptr to mm_data_t - * - * For the workarea pointed to by mm_wka, add the command - * mm_cmd to the currently active list of commands for the - * begin-end group - * - * Return Values: - * 0 : if the command was succesfully added to a - * begin-end group - * 1 : if the command was not added to a begin-end group - * - */ - -int -mm_add_beginend_cmd(mm_wka_t *mm_wka, mm_command_t *mm_cmd, - mm_data_t *mm_data) { - mm_command_t *cur_cmd; - - /* add this mount/unmount to beginend command block */ - mms_list_foreach(&mm_data->mm_cmd_queue, cur_cmd) { - if (cur_cmd->wka_ptr == NULL) - continue; - if ((cur_cmd->wka_ptr == mm_wka) && - (cur_cmd->cmd_func == mm_begin_cmd_func) && - (cur_cmd->cmd_begin_has_end == 0)) { - /* This clients begin cmd */ - mms_list_insert_tail(&cur_cmd->cmd_beginend_list, - mm_cmd); - return (0); - } - } - return (1); -} - - -/* - * mm_add_cmd - * - * Parameters: - * - mm_wka : ptr to cli work area, mm_wka_t - * - buf : ptr to char string of cmd text - * - mm_data : ptr to mm_data_t - * - * Adds command to mm's command queue - * Update CONNECTION information - * setup command and add the command to the approperate - * list based on the return from mm_setup_cmd - * - * Return Values: - * None - * - */ -void -mm_add_cmd(mm_wka_t *mm_wka, char *buf, mm_data_t *mm_data) -{ - mm_command_t *mm_cmd; - - int rc = 0; - - mms_trace(MMS_DEVP, "About to add command from fd -> %d", - mm_wka->mm_wka_conn->mms_fd); - - - - (void) mm_db_exec(HERE, &mm_wka->mm_data->mm_db_main, - "update \"CONNECTION\" " - "set \"ConnectionTimeLastActive\" = now() " - "where \"ConnectionID\" = '%s';", - mm_wka->wka_conn.cci_uuid); - - - if ((mm_cmd = mm_alloc_cmd(mm_wka)) == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_command_t: %s", - strerror(errno)); - mm_wka->wka_remove = 1; - return; - } - mm_get_uuid(mm_cmd->cmd_uuid); - - - rc = mm_setup_cmd(mm_cmd, buf); - if (rc == 0) { - mms_trace(MMS_ERR, "Parse error- couldnt add command"); - free(mm_cmd); - } else if (rc == 1) { - pthread_mutex_lock(&data->mm_queue_mutex); - mms_list_insert_tail(&mm_data->mm_cmd_queue, mm_cmd); - pthread_mutex_unlock(&data->mm_queue_mutex); - mms_trace(MMS_DEVP, "Command Successfully Added to Queue - %d", - mm_cmd->wka_ptr->mm_wka_conn->mms_fd); - } else if (rc == 2) { - /* Add this command to begin-end block commands */ - pthread_mutex_lock(&data->mm_queue_mutex); - if (mm_add_beginend_cmd(mm_wka, mm_cmd, mm_data)) { - mms_trace(MMS_ERR, - "couldn't find a begin command in cmd queue"); - free(mm_cmd); - } else { - mms_trace(MMS_DEVP, - "mount/unmount added to " - "begin-end block"); - } - pthread_mutex_unlock(&data->mm_queue_mutex); - - } else { - mms_trace(MMS_ERR, "Unknown return from setup cmd"); - free(mm_cmd); - } - -} - -/* - * mm_cmd_dispatch - * - * Parameters: - * - cmd : ptr to mm_command_t - * - * Determines if the command is ready for dipatch, - * if the command is ready, call the function in cmd's - * command function pointer. - * - * This function will put a postgres txn block around the - * command function so if the command function returns - * error, parial changes to the db are not committed - * - * Return Values: - * One of the Dispatcher return codes, see mm.h - * (MM_CMD_DONE, MM_NO_DISPATCH etc...) - * - */ -int -mm_cmd_dispatch(mm_command_t *cmd) -{ - int rc; - int txn; - - if (cmd->cmd_flags & MM_CMD_DISPATCHABLE) { - cmd->cmd_flags &= ~MM_CMD_DISPATCHABLE; - /* Dispatch the Command */ - if (cmd->cmd_func != NULL) { - - /* Skip db txn for the following funtions */ - txn = 1; - - /* Check for a valid wka before running cmd */ - - if (cmd->wka_ptr == NULL) { - mms_trace(MMS_ERR, - "this commands wka is NULL"); - rc = MM_CMD_ERROR; - } else if (cmd->wka_ptr->wka_remove == 1) { - mms_trace(MMS_ERR, - "this commands wka is set for remove"); - rc = MM_DISPATCH_AGAIN; - } else { - if (txn) { - (void) mm_db_txn_begin(&cmd->wka_ptr-> - mm_data->mm_db); - } - /* Lock this wka's local lock */ - pthread_mutex_lock(&cmd->wka_ptr-> - wka_local_lock); - mms_trace(MMS_DEVP, - "dispatching %s %s (%p) fd -> %d", - cmd->wka_ptr->wka_conn.cci_client, - cmd->wka_ptr->wka_conn.cci_instance, - cmd, - cmd->wka_ptr->mm_wka_conn->mms_fd); - rc = cmd->cmd_func(cmd->wka_ptr, cmd); - /* Unlock this wka's local lock */ - pthread_mutex_unlock(&cmd->wka_ptr-> - wka_local_lock); - - if (rc == MM_CMD_ERROR || - rc == MM_DEPEND_ERROR) { - if (txn) { - (void) mm_db_txn_rollback(&cmd-> - wka_ptr-> - mm_data->mm_db); - } - /* Notify Commit/Roll back */ - mm_notify_rollback(cmd->cmd_uuid); - - } else { - if (txn) { - (void) mm_db_txn_commit(&cmd-> - wka_ptr-> - mm_data->mm_db); - } - /* Notify Commit/Roll back */ - mm_notify_commit(cmd->cmd_uuid); - - } - if (rc == MM_CMD_DONE) { - (void) mm_message_command(cmd); - } - } - } else { - mms_trace(MMS_DEVP, "Command func is NULL"); - return (MM_NO_DISPATCH); - } - return (rc); - } else { - return (MM_NO_DISPATCH); - } -} - -/* - * mm_rm_unmount - * - * Parameters: - * - cmd : ptr to mm_command_t - * - db : ptr to valid db connection, mm_db_t - * - * - * Do additional steps to clean up when the command - * being removed is an unmount command - * check what subcommands are active, - * reset drive and cartridge states and add commands - * to clear the drive - * - * Return Values: - * 0 : for success - * 1 : for error - * - */ -int -mm_rm_unmount(mm_command_t *cmd, mm_db_t *db) { - PGresult *drive_results; - mm_command_t *cur_cmd; - - if (cmd->cmd_root == NULL) { - return (0); - } - - /* Check this cmd's sub cmd's */ - /* Allow detach release unload /unmount to complete */ - /* if they have already been accepted */ - mms_list_foreach(&data->mm_cmd_queue, cur_cmd) { - if (mm_is_parent(cmd, cur_cmd)) { - if (!MM_IS_SET(cur_cmd->cmd_flags, - MM_CMD_NEED_ACCEPT)) { - mm_remove_this_depend(cur_cmd, cmd); - } - } - } - - if (cmd->cmd_mount_info.cmi_drive != NULL) { - (void) mm_set_drive_statesoft(cmd-> - cmd_mount_info.cmi_drive, - "ready", db); - } - if (cmd->cmd_mount_info.cmi_drive != NULL) { - (void) mm_set_cartridge_status(cmd-> - cmd_mount_info.cmi_cartridge, - "available", db); - } - - if ((cmd->cmd_mount_info.cmi_drive != NULL) && - cmd->cmd_mount_info.cui_physical == 1) { - if (mm_db_exec(HERE, db, - "select \"DriveStateHard\" from \"DRIVE\" where" - "\"DRIVE\".\"DriveName\" = '%s';", - cmd->cmd_mount_info.cmi_drive) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "error checking DRIVE state"); - mm_clear_db(&db->mm_db_results); - return (0); - } - drive_results = db->mm_db_results; - if (PQntuples(drive_results) == 0) { - mms_trace(MMS_ERR, - "DRIVE results returned 0"); - mm_clear_db(&drive_results); - return (0); - } - if (strcmp(PQgetvalue(drive_results, 0, 0), "loaded") == 0) { - mms_trace(MMS_DEVP, - "drive is loaded, set DriveStateHard == unloading"); - (void) mm_db_exec(HERE, db, - "update \"DRIVE\" set " - "\"DriveStateHard\" = 'unloading' " - "where \"DriveName\" = '%s';", - cmd->cmd_mount_info.cmi_drive); - } - mm_clear_db(&drive_results); - } - return (0); -} - -/* - * mm_rm_mount - * - * Parameters: - * - cmd : ptr to mm_command_t - * - db : ptr to valid db connection, mm_db_t - * - * Do additional steps to clean up when the command - * being removed is a mount command - * check what subcommands are active, - * reset drive and cartridge states and add commands - * to clear the drive - * - * Return Values: - * 0 : for success - * 1 : for error - * - */ -int -mm_rm_mount(mm_command_t *cmd, mm_db_t *db) -{ - /* This function is called when a client has disconnected */ - /* with an outstanding mount command */ - /* need to deallocate the resources and reset device manager states */ - - PGresult *drive_results; - - if (cmd->cmd_root == NULL) { - return (0); - } - if ((strcmp(mms_pn_token(cmd->cmd_root), "mount") != 0) || - (cmd->cmd_language != MM_LANG_MMP)) { - /* command is not a MMP mount */ - mms_trace(MMS_DEVP, - "this command is not a MMP mount command"); - return (0); - } - - /* Do clean up for MMP mount command */ - mms_trace(MMS_DEVP, "removing a mount command state == %d", - cmd->cmd_state); - /* Cartridge is not in the drive */ - /* Reset CARTRIDGE and DRIVE */ - if (cmd->cmd_mount_info.cmi_cartridge != NULL) { - (void) mm_db_exec(HERE, db, - "update \"CARTRIDGE\" set " - "\"CartridgeStatus\" = 'available' " - "where \"CartridgeID\" = '%s';", - cmd->cmd_mount_info.cmi_cartridge); - } else { - mms_trace(MMS_DEVP, - "cmi_cartridge is NULL " - "cannot update state"); - } - if (cmd->cmd_mount_info.cmi_drive != NULL) { - (void) mm_db_exec(HERE, db, - "update \"DRIVE\" set " - "\"DriveStateSoft\" = 'ready' " - "where \"DriveName\" = '%s';", - cmd->cmd_mount_info.cmi_drive); - - if (mm_db_exec(HERE, db, - "select \"DriveStateHard\" from \"DRIVE\" where" - "\"DRIVE\".\"DriveName\" = '%s';", - cmd->cmd_mount_info.cmi_drive) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "error checking DRIVE state"); - mm_clear_db(&db->mm_db_results); - return (0); - } - drive_results = db->mm_db_results; - if (PQntuples(drive_results) == 0) { - mms_trace(MMS_ERR, - "DRIVE results returned 0"); - mm_clear_db(&drive_results); - return (0); - } - if ((strcmp(PQgetvalue(drive_results, 0, 0), - "loaded") == 0) || - (strcmp(PQgetvalue(drive_results, 0, 0), - "loadeding") == 0)) { - mms_trace(MMS_DEVP, - "drive is loaded/ing, set " - "DriveStateHard == unloading"); - (void) mm_db_exec(HERE, db, - "update \"DRIVE\" set " - "\"DriveStateHard\" = 'unloading' " - "where \"DriveName\" = '%s';", - cmd->cmd_mount_info.cmi_drive); - } - mm_clear_db(&drive_results); - - - } else { - mms_trace(MMS_DEVP, - "cmi_drive is NULL " - "cannot update state"); - } - return (0); -} - - -/* - * mm_print_cmd_queue - * - * Parameters: - * - mm_data : ptr to mm_data_t - * - * Traces the names of all commands in - * the current command queue - * - * Return Values: - * None - * - */ -void -mm_print_cmd_queue(mm_data_t *mm_data) { - - mm_command_t *cur_cmd; - mm_command_t *next; - - int print_one = 0; - - mm_command_t *cur_depend = NULL; - - char *print_buf = NULL; - - mms_trace(MMS_DEBUG, "Current Commands:"); - for (cur_cmd = mms_list_head(&mm_data->mm_cmd_queue); - cur_cmd != NULL; - cur_cmd = next) { - print_one = 1; - if (print_buf) - free(print_buf); - print_buf = NULL; - - next = mms_list_next(&mm_data-> - mm_cmd_queue, cur_cmd); - - if (cur_cmd->cmd_name != NULL) { - if (strcmp(cur_cmd->cmd_name, "response") == 0) { - switch (cur_cmd->cmd_language) { - case MM_LANG_MMP: - print_buf = mms_strapp(print_buf, - "MMP "); - break; - case MM_LANG_DMP: - print_buf = mms_strapp(print_buf, - "DMP "); - break; - case MM_LANG_LMP: - print_buf = mms_strapp(print_buf, - "LMP "); - break; - } - } - print_buf = mms_strapp(print_buf, - "%s", - cur_cmd->cmd_name); - } else { - print_buf = mms_strapp(print_buf, - "NULL command name"); - } - print_buf = mms_strapp(print_buf, - " (%p)", - cur_cmd); - - cur_depend = NULL; - if (cur_cmd->cmd_has_list) { - mms_list_foreach(&cur_cmd->cmd_depend_list, - cur_depend) { - /* Is a child command */ - print_buf = mms_strapp(print_buf, - " child of"); - - if (cur_depend->cmd_name != NULL) { - /* depend name has been set */ - print_buf = - mms_strapp(print_buf, - " %s", - cur_depend-> - cmd_name); - } else { - print_buf = mms_strapp(print_buf, - "NULL command name"); - } - print_buf = mms_strapp(print_buf, - " (%p)", - cur_depend); - } - } else { - print_buf = mms_strapp(print_buf, - " (no depend list)"); - } - - if (cur_cmd->wka_ptr != NULL) { - /* Has a valid wka */ - print_buf = mms_strapp(print_buf, - ", %s", - cur_cmd->wka_ptr-> - wka_conn.cci_instance); - - } - if (print_buf != NULL) { - mms_trace(MMS_DEBUG, - " %s", - print_buf); - } else { - mms_trace(MMS_ERR, "Error printing command queue"); - } - - } - if (!print_one) { - mms_trace(MMS_DEBUG, - " none"); - } - - if (print_buf) { - free(print_buf); - } - -} - -/* - * mm_dispatch_delay_unmount - * - * Parameters: - * - mm_data : ptr to mm_data_t - * - * Check each delay unmount in the command queue - * and test its timer to see if it is ready for dispatch - * dispach any command whose timer has expired - * - * Return Values: - * None - * - */ -void -mm_dispatch_delay_unmount(mm_data_t *mm_data) { - mm_command_t *cur_cmd; - time_t tm; - cmd_mount_info_t *mount_info; - - - mms_list_foreach(&mm_data->mm_cmd_queue, cur_cmd) { - if (cur_cmd->cmd_func == mm_delay_unmount_cmd_func) { - mount_info = &cur_cmd->cmd_mount_info; - (void) time(&tm); - if (((mount_info->unload_tm - tm) <= 0) && - (cur_cmd->cmd_state < 2)) { - mms_trace(MMS_DEVP, - "a delay unmount is ready for dispatch"); - /* Delay is over */ - /* command is in the 1st or 2nd state */ - MM_SET_FLAG(cur_cmd->cmd_flags, - MM_CMD_DISPATCHABLE); - } - } - } -} - - -/* - * mm_order_cmd_queue - * - * Parameters: - * - mm_data : ptr to mm_data_t - * - * Reorders the command queue to make processing more - * efficient. This will put all response first while maintaining - * the original order. This allows MM to do more work each - * pass through the command queue - * - * Return Values: - * None - * - */ -void -mm_order_cmd_queue(mm_data_t *mm_data) { - - /* - * Re order the queue: - * 1) Responses - * 2) LMP/DMP commands - * 3) Privilenged Commands - * 4) Remaning - */ - - /* Pull all DMP/LMP commands to the front of the list */ - - int print_message = 0; - - mms_list_t front_list; - mms_list_t response_list; - mms_list_t lmp_dmp_list; - - mm_command_t *cur_cmd; - mm_command_t *next; - - int bump = 0; - int response = 0; - int lmp_dmp = 0; - - char *bump_list[3]; - int num_bump_list = 3; - bump_list[0] = strdup("hello"); - bump_list[1] = strdup("mount"); - bump_list[2] = strdup("unmount"); - - - mms_list_create(&front_list, sizeof (mm_command_t), - offsetof(mm_command_t, cmd_next)); - mms_list_create(&response_list, sizeof (mm_command_t), - offsetof(mm_command_t, cmd_next)); - mms_list_create(&lmp_dmp_list, sizeof (mm_command_t), - offsetof(mm_command_t, cmd_next)); - - /* Test - print all the commands in the queue */ - - if (print_message) - mm_print_cmd_queue(mm_data); - - - for (cur_cmd = mms_list_head(&mm_data->mm_cmd_queue); - cur_cmd != NULL; - cur_cmd = next) { - bump = 0; - response = 0; - lmp_dmp = 0; - next = mms_list_next(&mm_data-> - mm_cmd_queue, cur_cmd); - - /* - * Find responses and privileged commands - */ - if ((cur_cmd->cmd_language == MM_LANG_LMP) || - (cur_cmd->cmd_language == MM_LANG_DMP)) { - lmp_dmp = 1; - } - if (cur_cmd->cmd_root != NULL) { - if (strcmp(mms_pn_token(cur_cmd-> - cmd_root), "response") == 0) { - response = 1; - } - for (int i = 0; i < num_bump_list; i ++) { - if (strcmp(mms_pn_token(cur_cmd->cmd_root), - bump_list[i]) == 0) { - bump = 1; - } - } - } - /* - * Add responses to response list, - * priviled to front list - */ - if (response) { - if (print_message) - mms_trace(MMS_DEVP, "Bump response"); - - mms_list_remove(&mm_data->mm_cmd_queue, - cur_cmd); - mms_list_insert_head(&response_list, cur_cmd); - } else if (lmp_dmp) { - if (print_message) - mms_trace(MMS_DEVP, "Bump LMP/DMP cmd"); - - mms_list_remove(&mm_data->mm_cmd_queue, - cur_cmd); - mms_list_insert_head(&lmp_dmp_list, cur_cmd); - } else if (bump) { - if (print_message) - mms_trace(MMS_DEVP, - "Bump this command to front"); - mms_list_remove(&mm_data->mm_cmd_queue, - cur_cmd); - mms_list_insert_head(&front_list, cur_cmd); - } else { - if (print_message) - mms_trace(MMS_DEVP, "No Bump"); - - } - - } - - /* Put commands back into the queue */ - - for (cur_cmd = mms_list_head(&front_list); - cur_cmd != NULL; - cur_cmd = next) { - next = mms_list_next(&front_list, cur_cmd); - mms_list_remove(&front_list, - cur_cmd); - mms_list_insert_head(&mm_data->mm_cmd_queue, cur_cmd); - - } - for (cur_cmd = mms_list_head(&lmp_dmp_list); - cur_cmd != NULL; - cur_cmd = next) { - next = mms_list_next(&lmp_dmp_list, cur_cmd); - mms_list_remove(&lmp_dmp_list, - cur_cmd); - mms_list_insert_head(&mm_data->mm_cmd_queue, cur_cmd); - - } - for (cur_cmd = mms_list_head(&response_list); - cur_cmd != NULL; - cur_cmd = next) { - next = mms_list_next(&response_list, cur_cmd); - mms_list_remove(&response_list, - cur_cmd); - mms_list_insert_head(&mm_data->mm_cmd_queue, cur_cmd); - - } - - /* Test - print all the commands in the queue */ - /* - * if (print_message) - */ - mm_print_cmd_queue(mm_data); - - - /* Clean up */ - mms_list_destroy(&front_list); - mms_list_destroy(&response_list); - mms_list_destroy(&lmp_dmp_list); - - for (int i = 0; i < num_bump_list; i ++) { - free(bump_list[i]); - } -} - -/* - * mm_notify - * - * Parameters: - * - arg : pointer to mm_data - * - * Main function for the notification thread - * - * This function will brodcast events to clients - * It checks the event list and event tables and - * sends the events to the approperate clients - * When all events have been sent, the thread will wait - * untill more events are generated - * - * Return Values: - * None - * - */ -void * -mm_notify(void * arg) { - mm_data_t *mm_data = arg; - - notify_cmd_t *event; - notify_cmd_t *next_event; - - pthread_mutex_t *notify_lock = mm_data->mm_notify_list_mutex; - mms_list_t *notify_list = mm_data->mm_notify_list_ptr; - - int done_one = 0; - - while (!mm_exiting) { - /* Wait for Work */ - mms_trace_flush(); /* flush mms_trace buffer */ - pthread_mutex_lock(&mm_data->mm_notify_mutex); - while (mm_data->mm_notify_work_todo == 0) { - mms_trace(MMS_DEVP, "Notify Thread is waiting...."); - pthread_cond_wait(&mm_data->mm_notify_cv, - &mm_data->mm_notify_mutex); - } - mm_data->mm_notify_work_todo = 0; - pthread_mutex_unlock(&mm_data->mm_notify_mutex); - - if (mm_exiting) - break; - - /* Do the notify work */ - mms_trace(MMS_DEVP, - "Notify Thread Processing Events..."); - pthread_mutex_lock(notify_lock); - done_one = 0; - for (event = mms_list_head(notify_list); - event != NULL; - event = next_event) { - next_event = mms_list_next(notify_list, event); - done_one = 1; - if (event->evt_cmd_uuid == NULL) { - /* - * This event is not - * associated with a command - * Set the event ready for dispatch - * This may already have been set - */ - event->evt_can_dispatch = 1; - } - if (event->evt_can_dispatch == 1) { - mms_list_remove(notify_list, event); - /* unlock to process event */ - /* This allows the worker to add events */ - /* while this thread proccess an event */ - pthread_mutex_unlock(notify_lock); - mms_trace(MMS_DEVP, "process event, %s", - event->evt_cmd); - /* brodcast the event */ - (void) notify_send(event); - /* clean up */ - mm_notify_destroy(event); - /* re lock */ - pthread_mutex_lock(notify_lock); - } else { - mms_trace(MMS_DEVP, - "event not dispatchable, %s", - event->evt_cmd); - } - } - pthread_mutex_unlock(notify_lock); - /* Send events in the event table */ - if (mm_notify_event_table(mm_data)) { - mms_trace(MMS_ERR, - "error sending status table events"); - } - if (mm_notify_event_rules(mm_data)) { - mms_trace(MMS_ERR, - "error sending status table events"); - } - if (!done_one) { - mms_trace(MMS_DEVP, - " No Events Found"); - } - } - return (NULL); -} - -/* - * mm_worker - * - * Parameters: - * - arg : ptr to mm_data - * - * Main function for the worker thread - * - * This function will loop through the command queue - * and attempt to dispatch commands. If no commands are dispatchable - * it will wait to be signaled by the main thread. - * - * For dispatchable commands, it will call a function to execute - * that commands specifc command function. mm_worker will use the return code - * of that command function to take the approperate action - * (see mm.h for return codes used by this function) - * - * After doing some work, this therad will wake the taskmanager thread - * and notification thread - * - * Return Values: - * None - * - */ -void * -mm_worker(void * arg) { - mm_data_t *mm_data = arg; - mm_command_t *next; - mm_command_t *cur_cmd; - int rc; - int command_count = 0; - int get_next_cmd; - - while (!mm_exiting) { - - /* Wake the task manager thread */ - pthread_mutex_lock(&data->mm_task_man_mutex); - data->mm_tm_work_todo = 1; - pthread_cond_signal(&data->mm_task_cv); - pthread_mutex_unlock(&data->mm_task_man_mutex); - - /* Wake the notify thread */ - pthread_mutex_lock(&data->mm_notify_mutex); - data->mm_notify_work_todo = 1; - pthread_cond_signal(&data->mm_notify_cv); - pthread_mutex_unlock(&data->mm_notify_mutex); - - - /* Wait for Work */ - mms_trace_flush(); /* flush mms_trace buffer */ - pthread_mutex_lock(&mm_data->mm_worker_mutex); - while (mm_data->mm_work_todo == 0) { - mms_trace(MMS_DEVP, "Worker is waiting...."); - pthread_cond_wait(&mm_data->mm_work_cv, - &mm_data->mm_worker_mutex); - } - - /* Remove disconnected clients */ - mms_trace(MMS_DEVP, - "clean up clients"); - if (mm_remove_clients(mm_data, &mm_data->mm_db)) { - /* Service fd is bad */ - mms_trace(MMS_ERR, "MM's service fd is bad, " - "setting mm_exiting"); - mm_exiting = 1; - } - - mm_data->mm_work_todo = 0; - pthread_mutex_unlock(&mm_data->mm_worker_mutex); - - if (mm_exiting) - break; - - /* Lock and Dispatch */ - pthread_mutex_lock(&mm_data->mm_queue_mutex); - mm_dispatch_delay_unmount(mm_data); - - /* - * Re order the queue: - * 1) Responses - * 2) Privilenged Commands - * 3) Remaning - */ - - mm_order_cmd_queue(mm_data); - - command_count = 0; - for (cur_cmd = mms_list_head(&mm_data->mm_cmd_queue); - cur_cmd != NULL; - cur_cmd = next) { - - pthread_mutex_unlock(&mm_data-> - mm_queue_mutex); - - command_count ++; - - get_next_cmd = 0; - - if (command_count > 10) { - mms_trace(MMS_DEVP, "done 10 commands, break"); - mm_data->mm_work_todo = 1; - pthread_mutex_lock(&mm_data-> - mm_queue_mutex); - break; - } - - - if (cur_cmd == NULL) { - mms_trace(MMS_ERR, "cur_cmd == NULL"); - rc = -1; - } else if (cur_cmd->cmd_remove) { - rc = MM_NO_DISPATCH; - } else { - rc = mm_cmd_dispatch(cur_cmd); - } - switch (rc) { - case MM_NO_DISPATCH: - if (cur_cmd->cmd_root != NULL) { - mms_trace(MMS_DEVP, - "A command "\ - "was not dispatchable - %s", - mms_pn_token(cur_cmd->cmd_root)); - } else { - mms_trace(MMS_DEVP, - "A command " \ - "was not dispatchable"); - } - /* Command not dispatchable-return to queue */ - if (cur_cmd->cmd_remove) { - if (cur_cmd->cmd_name == NULL) { - cur_cmd->cmd_name = - strdup("UNKNOWN COMMAND"); - } - mms_trace(MMS_DEVP, - "Removing cmd, %s %p", - cur_cmd->cmd_name, cur_cmd); - pthread_mutex_lock(&mm_data-> - mm_queue_mutex); - next = mms_list_next(&mm_data-> - mm_cmd_queue, cur_cmd); - mms_list_remove(&mm_data-> - mm_cmd_queue, cur_cmd); - pthread_mutex_unlock(&mm_data-> - mm_queue_mutex); - /* free(cur_cmd); */ - (void) mm_destroy_cmd(cur_cmd); - - } else { - get_next_cmd = 1; - } - /* - * non-dispatchable commands - * don't count in the command count - */ - command_count --; - break; - case MM_DISPATCH_DEPEND: - /* - * Parent Command has added - * a new command to the - * queue that is ready for dispatch, - * set todo = true; - */ - mm_data->mm_work_todo = 1; - get_next_cmd = 1; - break; - case MM_DEPEND_ERROR: - /* - * There was an error on a dependent command - * Recovery command has been added - */ - mm_data->mm_work_todo = 1; - get_next_cmd = 1; - break; - case MM_DEPEND_DONE: - /* - * Command With Parent is done, - * dispatch the parent and remove - * the completed command - */ - mm_dispatch_all_depend(cur_cmd); - - pthread_mutex_lock(&mm_data->mm_queue_mutex); - next = mms_list_next(&mm_data-> - mm_cmd_queue, cur_cmd); - mms_list_remove(&mm_data-> - mm_cmd_queue, cur_cmd); - pthread_mutex_unlock(&mm_data->mm_queue_mutex); - /* free(cur_cmd); */ - (void) mm_destroy_cmd(cur_cmd); - mm_data->mm_work_todo = 1; - break; - case MM_CMD_DONE: - /* The command has sucessfully completed */ - mms_trace(MMS_DEVP, "Command Completed!"); - if (mm_has_depend(cur_cmd)) { - mm_dispatch_all_depend(cur_cmd); - } - - pthread_mutex_lock(&mm_data-> - mm_queue_mutex); - next = mms_list_next(&mm_data-> - mm_cmd_queue, cur_cmd); - mms_list_remove(&mm_data-> - mm_cmd_queue, cur_cmd); - pthread_mutex_unlock(&mm_data-> - mm_queue_mutex); - /* free(cur_cmd); */ - (void) mm_destroy_cmd(cur_cmd); - /* - * mms_trace(MMS_INFO, "command destroyed..."); - */ - break; - case MM_CMD_ERROR: - mms_trace(MMS_DEBUG, - "Command Error - removing"); - if (mm_set_depend_error(cur_cmd)) { - mm_data->mm_work_todo = 1; - } - - /* If this is a failed mount */ - /* check if states need to be reset */ - if (cur_cmd->cmd_mount_info.cmi_reset_states) { - (void) mm_set_cartridge_status(cur_cmd-> - cmd_mount_info.cmi_cartridge, - "available", &mm_data->mm_db); - (void) mm_set_drive_statesoft(cur_cmd-> - cmd_mount_info.cmi_drive, - "ready", &mm_data->mm_db); - } - - pthread_mutex_lock(&mm_data-> - mm_queue_mutex); - next = mms_list_next(&mm_data-> - mm_cmd_queue, cur_cmd); - mms_list_remove(&mm_data-> - mm_cmd_queue, cur_cmd); - pthread_mutex_unlock(&mm_data-> - mm_queue_mutex); - /* free(cur_cmd); */ - (void) mm_destroy_cmd(cur_cmd); - break; - case MM_DISPATCH_AGAIN: - /* - * This RC means that the current - * command has finished, - * but has added another command to run - * Remove the first command and set todo = 1 - */ - mms_trace(MMS_DEVP, "Dispatch Again"); - /* If this command has depends, dispatch them */ - if (mm_has_depend(cur_cmd)) { - mm_dispatch_all_depend(cur_cmd); - } - pthread_mutex_lock(&mm_data-> - mm_queue_mutex); - next = mms_list_next(&mm_data-> - mm_cmd_queue, cur_cmd); - mms_list_remove(&mm_data-> - mm_cmd_queue, cur_cmd); - pthread_mutex_unlock(&mm_data-> - mm_queue_mutex); - /* free(cur_cmd); */ - (void) mm_destroy_cmd(cur_cmd); - mm_data->mm_work_todo = 1; - break; - case MM_ACCEPT_NEEDED: - /* - * A command has returned and needs an accept - * from an LM or DM, MM_CMD_NEED_ACCEPT - * flag should - * be set and command is NOT dispatchable - * Leave the cmd in the queue, - * when accept is recieved, the cmd will - * be dispatched - */ - get_next_cmd = 1; - break; - case MM_WORK_TODO: - /* A mount command state = 0 has finished */ - mm_data->mm_work_todo = 1; - get_next_cmd = 1; - break; - case (-1): - /* No commands left */ - get_next_cmd = 1; - break; - } - /* Lock queue for the for loop */ - pthread_mutex_lock(&mm_data-> - mm_queue_mutex); - if (get_next_cmd) { - next = mms_list_next(&mm_data-> - mm_cmd_queue, cur_cmd); - } - } - /* Check for responses */ - /* If all responses are not finished */ - /* set todo */ - for (cur_cmd = mms_list_head(&mm_data->mm_cmd_queue); - cur_cmd != NULL; - cur_cmd = next) { - next = mms_list_next(&mm_data-> - mm_cmd_queue, cur_cmd); - if (cur_cmd->cmd_root != NULL) { - if (strcmp(mms_pn_token(cur_cmd->cmd_root), - "response") == 0) { - mm_data->mm_work_todo = 1; - } - } - } - - pthread_mutex_unlock(&mm_data-> - mm_queue_mutex); - } - return (NULL); -} - - -/* - * mm_task_man - * - * Parameters: - * - arg : ptr to mm_data_T - * - * Main function for the task manager thread - * - * This function will attempt to dispatch any outstanding tasks - * by calling mm_get_tm_cmd - * After all tasks have been evaluated, the thread will wait - * untill signaled by the worker thread with new work. - * - * Return Values: - * None - * - */ -void * -mm_task_man(void * arg) -{ - mm_data_t *mm_data = arg; - - while (!mm_exiting) { - - /* Wait for Work */ - mms_trace_flush(); /* flush mms_trace buffer */ - pthread_mutex_lock(&mm_data->mm_task_man_mutex); - while (mm_data->mm_tm_work_todo == 0) { - mms_trace(MMS_DEVP, "TaskManager is waiting...."); - pthread_cond_wait(&mm_data->mm_task_cv, - &mm_data->mm_task_man_mutex); - } - mm_data->mm_tm_work_todo = 0; - pthread_mutex_unlock(&mm_data->mm_task_man_mutex); - (void) mm_check_drive_records(mm_data, &mm_data->mm_db_tm); - - if (mm_exiting) - break; - - /* Run TM algorithm */ - - (void) mm_get_tm_cmd(mm_data); - - } - return (NULL); -} - -/* - * mm_check_drive_records - * - * Parameters: - * - mm_data : ptr to mm_data_t - * - db : ptr to valid db connection, mm_db_t - * - * Checks and cleans drive records - * - * Return Values: - * 0 : for success - * - */ -int -mm_check_drive_records(mm_data_t *mm_data, mm_db_t *db) { - time_t tm; - (void) time(&tm); - if (tm >= mm_data->clean_drive_records_tm) { - (void) mm_clean_drive_records(mm_data, db); - } - return (0); -} - -/* - * mm_clean_drive_records - * - * Parameters: - * - mm_data : ptr to mm_data_t - * - db : ptr to valid db connection, mm_db_t - * - * Cleans drive records, records older than - * DriveRecordRetention will be removed from the db - * - * Return Values: - * 0 : for success - * 1 : for error - * - */ -int -mm_clean_drive_records(mm_data_t *mm_data, mm_db_t *db) { - PGresult *system_results; - char *wait; - time_t tm; - - if (mm_db_exec(HERE, db, - "select \"DriveRecordRetention\" " - "from \"SYSTEM\"") != MM_DB_DATA) { - mms_trace(MMS_ERR, - "error reading system object"); - mm_clear_db(&db->mm_db_results); - return (1); - } - - system_results = db->mm_db_results; - if (PQntuples(system_results) != 1) { - mms_trace(MMS_ERR, - "row number mismatch" - " reading system object"); - mm_clear_db(&system_results); - return (1); - } - wait = PQgetvalue(system_results, 0, 0); - - /* wait is in days, so days * 24 * 60 * 60 == wait in seconds */ - - if (mm_db_exec(HERE, db, - "delete from \"DRIVECARTRIDGEACCESS\" where " - "((extract(epoch from (\"DriveCartridgeAccessTimeUnmount\" - " - "\"DriveCartridgeAccessTimeMount\"))) + (%s * 24 * 60 * 60)) > 0", - wait) != MM_DB_OK) { - mms_trace(MMS_ERR, - "error removing drive records"); - mm_clear_db(&system_results); - return (1); - } - mm_clear_db(&system_results); - - /* Schedule the next clean of drive records 24 hours from now */ - (void) time(&tm); - mm_data->clean_drive_records_tm = tm + 24*60*60; - return (0); -} - - -/* - * mm_start_states - * - * Parameters: - * - mm_data : ptr to mm_data_t - * - * Set the starting states for the db - * this is called once when MM first starts - * - * Return Values: - * 0 : for success - * - */ -int -mm_start_states(mm_data_t *mm_data) -{ - mm_db_t *db = &mm_data->mm_db_main; - PGresult *mount_logical; - int rows; - int rc; - PGresult *notifyid_results; - - /* Set StateSoft to 'absent' until DM/LM's connect */ - /* TEMPORARY set HardState = ready */ - - (void) mm_db_exec(HERE, db, "update \"DM\" set "\ - "\"DMStateSoft\" = 'absent',"\ - "\"DMStateHard\" = 'ready';"); - (void) mm_db_exec(HERE, db, "update \"LM\" set "\ - "\"LMStateSoft\" = 'absent', "\ - "\"LMStateHard\" = 'ready';"); - (void) mm_db_exec(HERE, db, - "update \"CARTRIDGE\" set " - "\"CartridgeStatus\" = 'unavailable';"); - - /* Move MOUNTLOGICAL to STALEHANDLE */ - rc = mm_db_exec(HERE, db, "select \"ApplicationName\", "\ - "\"VolumeName\", \"PartitionName\", "\ - "\"SideName\", \"CartridgeID\", "\ - "\"DriveName\", \"DMName\", "\ - "\"MountLogicalHandle\" from\"MOUNTLOGICAL\";"); - if (rc != MM_DB_DATA) { - /* error */ - mms_trace(MMS_ERR, "Error getting MOUNTLOGICAL handles"); - mm_clear_db(&db->mm_db_results); - return (0); - } - - mount_logical = db->mm_db_results; - rows = PQntuples(mount_logical); - for (int i = 0; i < rows; i ++) { - /* Move 1 MOUNTLOGICAL to STALEHANDLE */ - if (mm_db_exec(HERE, db, - "insert into \"STALEHANDLE\" "\ - "(\"ApplicationName\", \"VolumeName\", "\ - "\"PartitionName\", "\ - "\"SideName\", \"CartridgeID\", "\ - "\"DriveName\", \"DMName\", "\ - "\"MountLogicalHandle\") values "\ - "('%s', '%s', '%s', '%s', "\ - "'%s', '%s', '%s', '%s');", - PQgetvalue(mount_logical, i, 0), - PQgetvalue(mount_logical, i, 1), - PQgetvalue(mount_logical, i, 2), - PQgetvalue(mount_logical, i, 3), - PQgetvalue(mount_logical, i, 4), - PQgetvalue(mount_logical, i, 5), - PQgetvalue(mount_logical, i, 6), - PQgetvalue(mount_logical, i, 7)) != MM_DB_OK) { - mms_trace(MMS_ERR, - "DB error copying MOUNTLOGICAL to STALEHANDLE"); - } - - /* Delete the old mount logical */ - if (mm_db_exec(HERE, db, - "delete from \"MOUNTLOGICAL\" " - "where \"CartridgeID\" = '%s';", - PQgetvalue(mount_logical, i, 4)) != MM_DB_OK) { - mms_trace(MMS_ERR, - "DB error deleting MOUNTLOGICAL"); - } - } - mm_clear_db(&mount_logical); - - (void) mm_db_exec(HERE, db, "delete from \"SLOT\";"); - (void) mm_db_exec(HERE, db, "delete from \"BAY\";"); - (void) mm_db_exec(HERE, db, "delete from \"SLOTGROUP\";"); - - - if (mm_db_exec(HERE, db, "update \"DRIVE\" set " - "\"DriveStateSoft\" = 'unavailable', " - "\"DriveLibraryOccupied\" = 'f', " - "\"DriveStateHard\" = 'unloaded', " - "\"BayName\" = DEFAULT, " - "\"DriveShapeName\" = DEFAULT, " - "\"DMName\" = DEFAULT;") != MM_DB_OK) { - MM_ABORT("drive set at init"); - } - - - (void) mm_db_exec(HERE, db, "delete from \"REQUEST\" where " - "\"RequestState\" != 'responded';"); - (void) mm_db_exec(HERE, db, "delete from \"NOTIFY\";"); - - (void) mm_db_exec(HERE, db, "delete from \"SESSION\";"); - (void) mm_db_exec(HERE, db, "delete from \"CONNECTION\";"); - (void) mm_db_exec(HERE, db, "delete from \"TASKCARTRIDGE\";"); - (void) mm_db_exec(HERE, db, "delete from \"TASKDRIVE\";"); - (void) mm_db_exec(HERE, db, "delete from \"TASKLIBRARY\";"); - (void) mm_db_exec(HERE, db, "delete from \"TASK\";"); - - /* Get any rules and drop them */ - if (mm_db_exec(HERE, db, - "select \"NotifyID\",\"NotifyObject\"" - " from \"NOTIFYRULES\";") == MM_DB_DATA) { - notifyid_results = db->mm_db_results; - for (int i = 0; i < PQntuples(notifyid_results); i ++) { - (void) mm_db_exec(HERE, db, - "drop rule \"%s\" on \"%s\";", - PQgetvalue(notifyid_results, i, 0), - PQgetvalue(notifyid_results, i, 1)); - } - mm_clear_db(¬ifyid_results); - } else { - mms_trace(MMS_ERR, - "error getting notifyid's"); - mm_clear_db(&db->mm_db_results); - } - - - (void) mm_db_exec(HERE, db, "delete from \"NOTIFYRULES\";"); - (void) mm_db_exec(HERE, db, "delete from \"EVENTRULES\";"); - - (void) mm_db_exec(HERE, db, "update \"LIBRARY\" set "\ - "\"LibraryStateSoft\" = 'ready';"); - - - /* Delete all DM Configs */ - (void) mm_db_exec(HERE, db, "delete from \"DMSHAPEPRIORITY\";"); - (void) mm_db_exec(HERE, db, "delete from \"DMDENSITYPRIORITY\";"); - (void) mm_db_exec(HERE, db, "delete from \"DMCAPABILITYTOKEN\";"); - (void) mm_db_exec(HERE, db, "delete from \"DMBITFORMAT\";"); - (void) mm_db_exec(HERE, db, "delete from \"DMBITFORMATTOKEN\";"); - (void) mm_db_exec(HERE, db, "delete from \"DMCAPABILITYGROUP\";"); - (void) mm_db_exec(HERE, db, "delete from \"DMCAPABILITYGROUPTOKEN\";"); - /* Clean the Event table */ - (void) mm_db_exec(HERE, db, "delete from \"EVENT\";"); - - /* Clean the drive records */ - (void) mm_clean_drive_records(mm_data, db); - - return (0); -} - -/* - * mm_calculate_timeout - * - * Parameters: - * - mm_data : ptr to mm_data_t - * - * Determines the correct timeout for MM's main thread pselect - * - * When there is a delay unload command present, MM will - * need to break out of pselect inorder to do the unload - * at the correct time. - * - * The timeout will be the time for the current delay - * unload's drivegroup minus the time since the delay was - * scheduled. - * - * There will only be a timeout if there is delay unload - * command on the queue. If the delay unload is not - * present the function returns 0 - * - * Return Values: - * timeout : return the timeout in seconds - * 0 : return 0 for no timeout - * - */ -int -mm_calculate_timout(mm_data_t *mm_data) { - - mm_db_t *db = &mm_data->mm_db_main; - - mm_command_t *cur_cmd; - time_t tm; - cmd_mount_info_t *mount_info; - - int wait = 0; - int wait_set = 0; - int any_command = 0; - /* Returns 0 for no timout */ - - - - pthread_mutex_lock(&mm_data->mm_queue_mutex); - mms_list_foreach(&mm_data->mm_cmd_queue, cur_cmd) { - any_command = 1; - if (cur_cmd->cmd_func == mm_delay_unmount_cmd_func) { - /* is a delay unload command */ - mount_info = &cur_cmd->cmd_mount_info; - (void) time(&tm); - if ((wait_set == 0) && - ((mount_info->unload_tm - tm) > 0)) { - /* The 1st delay unload */ - wait = mount_info->unload_tm - tm; - wait_set = 1; - } else if ((wait > (mount_info->unload_tm - tm)) && - ((mount_info->unload_tm - tm) > 0)) { - /* A delay shorter than the 1st */ - wait = mount_info->unload_tm - tm; - } - - } - } - pthread_mutex_unlock(&mm_data-> - mm_queue_mutex); - if (!any_command) { - mms_trace(MMS_DEVP, "no MM timeout"); - return (wait); - } - if (!wait_set) { - if (mm_db_exec(HERE, db, - "select \"DriveGroupUnloadTime\" from " - "\"DRIVEGROUP\" order by " - "\"DriveGroupUnloadTime\" asc limit 1;") - != MM_DB_DATA) { - mms_trace(MMS_ERR, "Exec returned with no Data"); - mm_clear_db(&db->mm_db_results); - return (0); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_DEVP, "No drivegorups exist"); - mm_clear_db(&db->mm_db_results); - return (0); - } - /* Timeout is in min, so mult by 60 for seconds */ - wait = 60*atoi(PQgetvalue(db->mm_db_results, 0, 0)); - } - mms_trace(MMS_DEVP, "MM timeout is %d", wait); - mm_clear_db(&db->mm_db_results); - return (wait); -} - -/* - * mm_reconfig - * - * Parameters: - * - mm_data : ptr to mm_data_t - * - * - * Referesh the MM's config information - * - * Return Values: - * 0 : for success - * - */ -static int -mm_reconfig(mm_data_t *data) -{ - mm_cfg_t mm_cfg; -#ifdef MMS_OPENSSL - mm_wka_t *mm_wka; - mms_err_t err; - char ebuf[MMS_EBUF_LEN]; -#endif - - /* - * Re-load configuration - */ - mm_refresh = 0; - if (mm_cfg_read(&mm_cfg)) { - mms_trace(MMS_ERR, "configuration refresh error"); - mm_cfg_free(&mm_cfg); - exit(SMF_EXIT_ERR_CONFIG); - } - - pthread_mutex_lock(&data->mm_wka_mutex); - mm_cfg_free(&data->mm_cfg); - (void) memcpy(&data->mm_cfg, &mm_cfg, sizeof (mm_cfg_t)); - pthread_mutex_unlock(&data->mm_wka_mutex); - mms_trace(MMS_INFO, "configuration refreshed"); - -#ifdef MMS_OPENSSL - if (data->mm_ssl_data) { - mms_ssl_server_set_verify_peer(data->mm_ssl_data, - mm_cfg.mm_ssl_verify_peer); - - /* - * Get updated CRL - */ - if (mms_ssl_reload_crl_file(data->mm_ssl_data, - data->mm_cfg.mm_network_cfg.ssl_crl_file, &err)) { - mms_get_error_string(&err, ebuf, MMS_EBUF_LEN); - mms_trace(MMS_ERR, "crl file reload failed %s", ebuf); - return (1); - } - - /* - * Check for revoked clients - */ - if (mms_ssl_has_crl(data->mm_ssl_data)) { - mms_trace(MMS_DEVP, "check for revoked clients"); - - pthread_mutex_lock(&data->mm_wka_mutex); - mms_list_foreach(&data->mm_wka_list, mm_wka) { - if (mms_ssl_check_conn_cert(data->mm_ssl_data, - mm_wka->mm_wka_conn)) { - - mms_get_error_string( - &err, ebuf, MMS_EBUF_LEN); - mms_trace(MMS_INFO, - "client revoked %s %s - %s", - mm_wka->wka_conn.cci_client, - mm_wka->wka_conn.cci_instance, - ebuf); - - mm_wka->wka_remove = 1; - } - } - pthread_mutex_unlock(&data->mm_wka_mutex); - } - } -#endif /* MMS_OPENSSL */ - (void) smf_refresh_instance(MMS_CFG_WCR_INST); - return (0); -} - - -/* - * main - * - * Parameters: - * No args - * - * This is the main function for MM - * - * This function first initializes the MM's tracing, - * db connections, core files, signal handleing, and - * creates the worker, task manager, and notification threads. - * - * Once MM has been intialized, this thread acts as the reader thread - * it will accept and proccess incomming command and clients. - * It will signal the other threads when there is work to be done. - * When commands/clients have completed/disconnected this thread will - * do the clean up and free any associated memory - * - * Return Values: - * N/A - * - */ -int -main(int argc, char **argv) -{ - fd_set rfds; - int mfd; - int rc; - char *buf = NULL; - sigset_t new_mask; - sigset_t old_mask; - mm_wka_t *mm_wka; - pthread_t tid; - pthread_t tm_tid; - pthread_t notify_tid; - mms_t *cli_conn; - char ebuf[MMS_EBUF_LEN]; - char c; - void *status; - /* Time out */ - struct timespec timeout; - int err; - int daemon_mode = 1; - - /* - * Get debug DM config option - */ - while ((c = getopt(argc, argv, "v(version)n(nodaemon)")) != -1) { - switch (c) { - case 'v': - printf("%d\n", MM_DB_VERSION); - return (0); - case 'n': - daemon_mode = 0; - break; - default: - break; - } - } - - - /* - * Setup MM data and services - */ - mm_initialize(&mm_data, daemon_mode); - - /* - * Setup to block signals MM cares about. - * This is inherited by the threads so they will not - * be interrupted by signals. - */ - sigemptyset(&new_mask); - sigaddset(&new_mask, SIGINT); - sigaddset(&new_mask, SIGHUP); - sigaddset(&new_mask, SIGTERM); - sigaddset(&new_mask, SIGPIPE); - pthread_sigmask(SIG_BLOCK, &new_mask, &old_mask); - - /* - * Get seperate database connections for worker and main threads - */ - mm_data.mm_db.mm_db_has_list = 0; - mm_data.mm_db_main.mm_db_has_list = 0; - mm_data.mm_db_tm.mm_db_has_list = 0; - mm_data.mm_db.mm_db_resending = 0; - mm_data.mm_db_main.mm_db_resending = 0; - mm_data.mm_db_tm.mm_db_resending = 0; - if (mm_db_connect(&mm_data.mm_db) != MM_DB_OK || - mm_db_connect(&mm_data.mm_db_main) != MM_DB_OK || - mm_db_connect(&mm_data.mm_db_tm) != MM_DB_OK) { - mms_trace(MMS_ERR, "unable to connect to database"); - exit(SMF_EXIT_ERR_FATAL); - } - /* initialze the db cmd lists */ - mms_list_create(&mm_data.mm_db.mm_db_cmds, sizeof (mm_char_list_t), - offsetof(mm_char_list_t, mm_char_list_next)); - mms_list_create(&mm_data.mm_db_main.mm_db_cmds, sizeof (mm_char_list_t), - offsetof(mm_char_list_t, mm_char_list_next)); - mms_list_create(&mm_data.mm_db_tm.mm_db_cmds, sizeof (mm_char_list_t), - offsetof(mm_char_list_t, mm_char_list_next)); - mm_data.mm_db.mm_db_has_list = 1; - mm_data.mm_db_main.mm_db_has_list = 1; - mm_data.mm_db_tm.mm_db_has_list = 1; - - - (void) mm_start_states(data); - /* create worker and task manager threads */ - - pthread_create(&tid, NULL, mm_worker, data); - - pthread_create(&tm_tid, NULL, mm_task_man, data); - - if (mm_notify_init(&mm_data)) { - mms_trace(MMS_ERR, "unable to init notification events"); - exit(SMF_EXIT_ERR_FATAL); - } - - pthread_create(¬ify_tid, NULL, mm_notify, data); - - /* - * Setup signal handlers - */ - mm_signal(SIGINT, mm_signal_handler); - mm_signal(SIGHUP, mm_signal_handler); - mm_signal(SIGTERM, mm_signal_handler); - mm_signal(SIGPIPE, mm_signal_handler); - - (void) mm_message(&mm_data.mm_db_main, - MESS_LOG, MESS_INFO, MM_5013_MSG, NULL); - - /* - * Accept new clients, read client input - */ - mms_trace(MMS_DEBUG, "Waiting for Commands..."); - while (!mm_exiting) { - - /* - * Setup for pselect - */ - FD_ZERO(&rfds); - FD_SET(mm_data.mm_service_fd, &rfds); - mfd = mm_data.mm_service_fd; - pthread_mutex_lock(&data->mm_wka_mutex); - mms_list_foreach(&mm_data.mm_wka_list, mm_wka) { - if (mm_wka->mm_wka_conn->mms_fd == -1) { - mms_trace(MMS_ERR, - "mms_fd == -1 for client," - "set wka_remove"); - mm_wka->wka_remove = 1; - continue; - } - FD_SET(mm_wka->mm_wka_conn->mms_fd, &rfds); - if (mfd < mm_wka->mm_wka_conn->mms_fd) { - mfd = mm_wka->mm_wka_conn->mms_fd; - } - } - pthread_mutex_unlock(&data->mm_wka_mutex); - - mms_trace(MMS_DEVP, "pselect"); - mms_trace_flush(); /* flush mms_trace buffer */ - - /* Calculate the time out */ - timeout.tv_nsec = 0; - if ((timeout.tv_sec = mm_calculate_timout(&mm_data)) == 0) { - rc = pselect(mfd + 1, &rfds, NULL, - NULL, NULL, &old_mask); - } else { - rc = pselect(mfd + 1, &rfds, NULL, - NULL, &timeout, &old_mask); - } - err = errno; - - if (mm_exiting) { - mms_trace(MMS_DEVP, "do exit"); - break; - } - if (mm_refresh) { - mms_trace(MMS_DEVP, "do refresh"); - if (mm_reconfig(&mm_data)) { - mms_trace(MMS_ERR, "mm reconfig"); - mm_exiting = 1; - break; - } - } - - /* Check for interupt and bad file descriptor */ - if (rc == -1) { - mms_trace(MMS_DEBUG, "errno = %d: %s", - err, strerror(err)); - if (err == EINTR) { - mms_trace(MMS_DEVP, "Pselect INTERRUPTED!!"); - /* Take action */ - continue; - } else if (err == EBADF) { - mms_trace(MMS_DEVP, "BAD FD!"); - /* Take action */ - } - - if (mm_is_fd_valid(mm_data.mm_service_fd) != 0) { - mms_trace(MMS_ERR, - "mm service not valid FD -> %d", - mm_data.mm_service_fd); - /* Service Not Valid */ - break; - } - - /* Get valid FD SET */ - continue; - } - - /* A wka FD is ready to be read... */ - pthread_mutex_lock(&data->mm_wka_mutex); - mms_list_foreach(&mm_data.mm_wka_list, mm_wka) { - if (mm_wka->wka_remove || - mm_wka->mm_wka_conn->mms_fd == -1) { - mms_trace(MMS_DEBUG, - "wka should be removed" - ", dont read"); - mm_wka->wka_remove = 1; - } else if (!mm_exiting && - FD_ISSET(mm_wka->mm_wka_conn->mms_fd, &rfds)) { - if (buf != NULL) { - free(buf); - buf = NULL; - } - rc = mms_reader(mm_wka->mm_wka_conn, &buf); - if (rc > 0) { - mms_trace(MMS_DEBUG, - "read %s %s fd -> %d", - mm_wka->wka_conn.cci_client, - mm_wka->wka_conn.cci_instance, - mm_wka->mm_wka_conn->mms_fd); - mm_add_cmd(mm_wka, buf, &mm_data); - } else if (mm_wka->wka_remove != 1) { - mm_wka->wka_remove = 1; - if (mm_wka->mm_wka_mm_lang == - MM_LANG_DMP) { - mms_trace(MMS_INFO, - "DM Disconnected " - "%s %s fd -> %d", - mm_wka->wka_conn.cci_client, - mm_wka-> - wka_conn.cci_instance, - mm_wka-> - mm_wka_conn->mms_fd); - } else if (mm_wka->mm_wka_mm_lang == - MM_LANG_LMP) { - mms_trace(MMS_INFO, - "LM Disconnected " - "%s %s fd -> %d", - mm_wka-> - wka_conn.cci_client, - mm_wka-> - wka_conn.cci_instance, - mm_wka-> - mm_wka_conn->mms_fd); - } else if (mm_wka->mm_wka_mm_lang == - MM_LANG_MMP) { - mms_trace(MMS_INFO, - "MM Client Disconnected " - "%s %s fd -> %d", - mm_wka-> - wka_conn.cci_client, - mm_wka-> - wka_conn.cci_instance, - mm_wka-> - mm_wka_conn->mms_fd); - } else { - mms_trace(MMS_INFO, - "bad read - " - "client disconnect " - "%s %s fd -> %d", - mm_wka-> - wka_conn.cci_client, - mm_wka-> - wka_conn.cci_instance, - mm_wka-> - mm_wka_conn->mms_fd); - } - } - } - } - pthread_mutex_unlock(&data->mm_wka_mutex); - - mms_trace_flush(); - if (FD_ISSET(mm_data.mm_service_fd, &rfds)) { - /* A new client has been found */ - if (mm_exiting) { - mms_trace(MMS_INFO, "mm exiting"); - break; - } - mms_trace(MMS_DEBUG, "Client connecting..."); - cli_conn = (mms_t *)calloc(1, sizeof (mms_t)); - if (cli_conn == NULL) { - mms_trace(MMS_ERR, "add client alloc"); - break; - } - if (mms_accept(mm_data.mm_service_fd, - mm_data.mm_ssl_data, - cli_conn)) { - mms_trace(MMS_ERR, - "Error accepting new client connection"); - mms_get_error_string(&cli_conn->mms_err, - ebuf, MMS_EBUF_LEN); - mms_trace(MMS_ERR, "Client Accept - fd %d, %s", - mm_data.mm_service_fd, ebuf); - free(cli_conn); - /* continue processing */ - } else { - if (mm_exiting) { - mms_trace(MMS_INFO, "mm exiting"); - break; - } - if (mm_add_wka(&mm_data, cli_conn)) { - free(cli_conn); - } - } - } - - if (mm_is_fd_valid(mm_data.mm_service_fd) != 0) { - mms_trace(MMS_ERR, "mm service not valid FD -> %d", - mm_data.mm_service_fd); - /* Service Not Valid */ - break; - } - - /* wakeup worker thread to do work */ - pthread_mutex_lock(&data->mm_worker_mutex); - data->mm_work_todo = 1; - pthread_cond_signal(&data->mm_work_cv); - pthread_mutex_unlock(&data->mm_worker_mutex); - - } - - /* - * Cleanup and exit - */ - mm_exiting = 1; - - mms_trace(MMS_DEBUG, "signal task manager"); - pthread_mutex_lock(&data->mm_task_man_mutex); - data->mm_tm_work_todo = 1; - pthread_cond_signal(&data->mm_task_cv); - pthread_mutex_unlock(&data->mm_task_man_mutex); - - mms_trace(MMS_DEBUG, "signal worker"); - pthread_mutex_lock(&data->mm_worker_mutex); - data->mm_work_todo = 1; - pthread_cond_signal(&data->mm_work_cv); - pthread_mutex_unlock(&data->mm_worker_mutex); - - mms_trace(MMS_DEBUG, "signal notify"); - pthread_mutex_lock(&data->mm_notify_mutex); - data->mm_notify_work_todo = 1; - pthread_cond_signal(&data->mm_notify_cv); - pthread_mutex_unlock(&data->mm_notify_mutex); - - mms_trace(MMS_INFO, "join task manager"); - pthread_join(tm_tid, &status); - - mms_trace(MMS_INFO, "join worker"); - pthread_join(tid, &status); - - mms_trace(MMS_INFO, "join notify"); - pthread_join(notify_tid, &status); - - mms_trace(MMS_DEBUG, "close connections"); - mm_notify_close(); - mm_message_close(); - mm_db_disconnect(&mm_data.mm_db); - mm_db_disconnect(&mm_data.mm_db_main); - mm_db_disconnect(&mm_data.mm_db_tm); - close(mm_data.mm_service_fd); -#ifdef MMS_OPENSSL - mms_ssl_finish(mm_data.mm_ssl_data); -#endif - - mms_trace(MMS_INFO, "MM Shutdown"); - mms_trace_close(); - closelog(); - - return (SMF_EXIT_OK); -} diff --git a/usr/src/cmd/mms/mm/common/mm.h b/usr/src/cmd/mms/mm/common/mm.h deleted file mode 100644 index df023fc887..0000000000 --- a/usr/src/cmd/mms/mm/common/mm.h +++ /dev/null @@ -1,1031 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _MM_H -#define _MM_H - - -#include <limits.h> -#include <mms_network.h> -#include <mms_mm_msg.h> -#include <host_ident.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define HERE _SrcFile, __LINE__ - -#define MM_APP "MMS" /* mms admin and oper application */ -#define MM_ADMIN "admin" /* mms administrator app instance */ -#define MM_OPER "oper" /* mms operator app instance */ - -#define MM_FD_LIMIT_MIN 256 /* mm fd limit min */ -#define MM_FD_LIMIT_MAX 65536 /* mm fd limit max */ - -/* Mount return codes */ -#define MM_MOUNT_ERROR 0 -#define MM_MOUNT_READY 1 -#define MM_MOUNT_NOT_READY 2 -#define MM_MOUNT_NEED_UNLOAD 3 -/* UNmount return codes */ -#define MM_UNMOUNT_ERROR 4 -#define MM_UNMOUNT_READY 5 -#define MM_UNMOUNT_NOT_READY 6 - -#define MM_DELETE_NOTIFY "delete from \"NOTIFY\" where "\ - "\"ConnectionID\" = '%s';" -#define MM_DELETE_NOTIFYRULES "delete from \"NOTIFYRULES\" where "\ - "\"ConnectionID\" = '%s';" -#define MM_DELETE_CONNECTION "delete from \"CONNECTION\" where "\ - "\"ConnectionID\" = '%s';" -#define MM_DELETE_SESSION "delete from \"SESSION\" where "\ - "\"SessionID\" = '%s';" - -/* This is the string for a PCL outside of MMS */ -/* postgres trigger in mm_db_plpgsql.c must use this string */ -#define MM_NON_MMS_CART "non-MMS" - -/* - * Core on fatal - */ -#define MM_ABORT(msg)\ -{ \ - syslog(LOG_ERR, "%s:%d %s", MMS_HERE, msg); \ - abort(); \ -} -#define MM_ABORT_NO_MEM() MM_ABORT("no mem") - -#define MM_SET_FLAG(flags, a_flag) \ - { \ - flags |= a_flag; \ -} - -#define MM_IS_SET(flags, a_flag) flags & a_flag -#define MM_UNSET_FLAG(flags, a_flag) \ - { \ - flags &= ~a_flag; \ -} - -#define MM_PROGNAME "mm" -#define MM_TRACE_FN "/var/log/mms/mm/mm.debug" -#define MM_PATHS_FN "/etc/mms/config/mm_paths.xml" -#define MM_TYPES_FN "/etc/mms/types/mm_types.xml" -#define UUID_PRINTF_SIZE 37 -#define CMI_NUM_FIRSTMOUNT 100 -#define CMI_NUM_ACCESSMODE 100 -#define MM_NO_TASK NULL -/* Defines the max size of MM response, default 32000? */ -/* 500 to test */ -#define MM_CMD_SIZE_LIMIT 32000 - -/* DM Debug Options */ -#define DEBUG_DM_CONFIG 1 /* Setting this to 1 makes DM config VERY slow */ - -typedef enum mm_lmp_scope mm_lmp_scope_t; -enum mm_lmp_scope { - SCOPE_FULL, - SCOPE_PARTIAL -}; - -typedef struct mm_command mm_command_t; -typedef char cci_ip_t[MMS_IP_IDENT_LEN+1]; -typedef char uuid_text_t[UUID_PRINTF_SIZE]; - -#define SQL_CMD_BUF_INCR (1024 * 8) -#define SQL_CHK_LEN(line, off, size, len) { \ - if (mm_sql_chk_len(line, off, size, len)) { \ - goto no_mem; \ - } \ - } - -/* - * MM config structure - */ -typedef struct mm_cfg mm_cfg_t; /* mm configuration */ -struct mm_cfg { - mms_network_cfg_t mm_network_cfg; /* mm network cfg file */ - mm_db_cfg_t mm_db_cfg; /* database configuration */ - char *mm_ssl_dh_file; /* DH parameter file */ - int mm_ssl_verify_peer; /* client cert required */ -}; - -/* - * MMP begin end mode - */ -typedef enum access_mode access_mode_t; /* begin-end access mode */ -enum access_mode { - ACCESS_MODE_IMMEDIATE, /* run now */ - ACCESS_MODE_BLOCKING /* willing to wait for resources */ -}; - -/* - * MMP begin end data - */ -typedef struct begin_end begin_end_t; /* begin-end command data */ -struct begin_end { - boolean_t be_active; /* active begin-end block */ - access_mode_t be_mode; /* now or willing to wait */ - mms_list_t be_list; /* mount / unmount list */ - mm_command_t *be_command; /* begin command */ -}; - - - -#define MM_NUM_STATUS_OBJS 14 -#define MM_NUM_STATUS_ATTS 50 -#define MM_NUM_CONTROL_ATTS 16 - -typedef struct mm_attribute_info mm_attribute_info_t; -struct mm_attribute_info { - char *status_objs[MM_NUM_STATUS_OBJS]; - char *status_atts[MM_NUM_STATUS_ATTS]; - char *control_atts[MM_NUM_CONTROL_ATTS]; -}; - -/* - * MM data structure - */ -typedef struct mm_data mm_data_t; -struct mm_data { - mm_cfg_t mm_cfg; /* mm configuration */ - int mm_service_fd; /* mm service */ - void *mm_ssl_data; /* mm secure socket layer context */ - mms_list_t mm_cmd_queue; /* active cmd queue */ - mms_list_t mm_wka_list; - mms_cli_host_t mm_host_name; - cci_ip_t mm_host_ip; - - /* Db pointer */ - mm_db_t mm_db; /* db for worker thread */ - mm_db_t mm_db_tm; /* db for TM thread */ - mm_db_t mm_db_main; /* db for Main thread */ - - pthread_mutex_t mm_worker_mutex; /* lock for worker thread */ - pthread_mutex_t mm_task_man_mutex; /* lock for task man thread */ - pthread_mutex_t mm_notify_mutex; /* lock for notify thread */ - pthread_mutex_t mm_queue_mutex; /* lock for cmd queues */ - pthread_mutex_t mm_wka_mutex; /* lock for wka list */ - pthread_cond_t mm_work_cv; - pthread_cond_t mm_accept_cv; /* not used now */ - pthread_cond_t mm_task_cv; - pthread_cond_t mm_notify_cv; - int mm_work_todo; - int mm_tm_work_todo; - int mm_notify_work_todo; - int mm_cmd_dispatchable; - pthread_mutex_t mm_command_mutex; /* not used now */ - mm_attribute_info_t mm_attr_info; - - pthread_mutex_t *mm_notify_list_mutex; /* lock for notify list */ - mms_list_t *mm_notify_list_ptr; - time_t clean_drive_records_tm; -}; - - - -typedef enum mm_lang mm_lang_t; /* mms language (mmp, dmp, lmp) */ -enum mm_lang { - MM_LANG_MMP, /* media manager */ - MM_LANG_DMP, /* drive manager */ - MM_LANG_LMP /* library manager */ -}; - -typedef enum mm_privilege mm_privilege_t; -enum mm_privilege { - MM_PRIV_STANDARD, /* unprivileged app */ - MM_PRIV_ADMIN, /* privileged app */ - MM_PRIV_SYSTEM /* super user */ -}; - -#define MM_SIDE_STRING "SIDE" -#define MM_PARTITION_STRING "PARTITION" -#define MM_VOLUME_STRING "VOLUME" - -typedef enum mm_mount_type mm_mount_type_t; -enum mm_mount_type { - MM_SIDE, - MM_PARTITION, - MM_VOLUME - -}; -typedef enum mm_mount_when mm_mount_when_t; -enum mm_mount_when { - MM_BLOCKING, - MM_IMMEDIATE -}; - -/* - * Client MMP, DMP, LMP parser function pointer - */ -typedef int (*parser_func_t)(mms_par_node_t **, mms_list_t *, char *); -typedef struct cci cci_t; /* client connection info */ -struct cci { - mms_cli_host_t cci_host; - cci_ip_t cci_ip; - uint_t cci_port; - char *cci_client; - char *cci_instance; - char *cci_language; - char *cci_version; - char *cci_password; - char *cci_certificate; - char *cci_authentication; - uuid_text_t cci_uuid; -}; - -typedef struct cmi_mode_list cmi_mode_list_t; -struct cmi_mode_list { - mms_list_node_t cmi_mode_next; - char *cmi_accessmode[CMI_NUM_ACCESSMODE]; - int cmi_num_accessmode; -}; -typedef struct cmi_cart_list cmi_cart_list_t; -struct cmi_cart_list { - mms_list_node_t cmi_cart_next; - uuid_text_t cmi_cart_id; - char *cmi_side_name; - char *cmi_library; - char *cmi_cart_pcl; - char *cmi_cart_type; - char *cmi_bit_format; - int cmi_cart_priority; - int cmi_cart_num_mounts; - mms_list_t cmi_drive_list; - int cmi_remove_cart; - int cmi_cart_not_ready; - int cmi_cart_loaded; - int cmi_cart_used; -}; - -typedef struct cmi_drive_list cmi_drive_list_t; -struct cmi_drive_list { - mms_list_node_t cmi_drive_next; - char *cmi_drive_name; - char *cmi_dm_name; - int cmi_drv_priority; - int cmi_drv_num_mounts; - int cmi_mode_valid; - int cmi_drive_loaded; - char *cmi_loaded_pcl; - int cmi_remove_drive; - int cmi_drive_not_ready; - int cmi_dm_shape_priority; - int cmi_dm_density_priority; - int cmi_drive_used; -}; - -#define MM_MOUNT 0 -#define MM_UNMOUNT 1 - -typedef struct cmd_mount_info cmd_mount_info_t; -struct cmd_mount_info { - int cmi_operation; - char *cmi_dm; - char *cmi_drive; - char *cmi_library; - char *cmi_cartridge; - char *cmi_pcl; - char *cmi_side_name; - mm_mount_type_t cmi_type; - char *cmi_capability; - char *cmi_handle; - mms_list_t cmi_cart_list; - int cmi_total_carts; - int cmi_mount_ok; - - /* Recovery */ - int cmi_retries; - int cmi_fail_type; - int cmi_fail_state; - int cmi_reset_states; - - /* mount */ - mm_mount_when_t cmi_when; - char *cmi_where; - char *cmi_firstmount[CMI_NUM_FIRSTMOUNT]; - int cmi_num_firstmount; - mms_list_t cmi_mode_list; - int cmi_total_modes; - char *cmi_filename; - char *cmi_user; - char *cmi_blocksize; - char *cmi_filesequence; - char *cmi_volumeid; - char *cmi_retention; - int cmi_need_clear; - int cmi_mount_cart_loaded; - - /* Dispatch info */ - int cmi_mount_type; - char *cmi_first_drive; - char *cmi_first_lib; - char *cmi_second_drive; - char *cmi_second_lib; - - /* unmount */ - int cui_physical; - int cui_signature_clean; - char *cui_signature_type; - char *cui_signature; - int cui_skip_unload; - int cui_force; - time_t unload_tm; - -}; - -#define MM_CANDIDATE_LOADED 5 -#define MM_OPEN_DRIVE 6 -#define MM_UNMOUNT_DRIVE 7 -#define MM_UNMOUNT_CART 8 -#define MM_UNMOUNT_2 9 - -typedef struct eject_cart eject_cart_t; -struct eject_cart { - mms_list_node_t cart_next; - char *cart_cartid; - char *cart_cartpcl; - char *cart_slottype; - char *cart_slotname; - char *cart_library; -}; - -typedef struct cmd_eject cmd_eject_t; -struct cmd_eject { - char *eject_library; - char *eject_lm; - char *eject_slotgroup; - mms_list_t eject_list; -}; - -typedef enum mm_msg_sev mm_msg_sev_t; -enum mm_msg_sev { - MESS_EMERG = 9, - MESS_ALERT = 8, - MESS_CRIT = 7, - MESS_ERROR = 6, - MESS_WARN = 5, - MESS_NOTICE = 4, - MESS_INFO = 3, - MESS_DEBUG = 2, - MESS_DEVP = 1 -}; - -typedef enum mm_msg_who mm_msg_who_t; -enum mm_msg_who { - MESS_LOG, - MESS_OPER, - MESS_ADMIN -}; - -#define MESS_MANUFACTURER "SUNW" -#define MESS_MODEL "MMS" -#define MESS_LANG "EN" -#define MESS_MM_STR "MM" -#define MESS_DM_STR "DM" -#define MESS_LM_STR "LM" -#define MESS_AI_STR "AI" -#define MM_TIMESTAMP 24 -typedef char mm_timestamp_t[MM_TIMESTAMP]; - -/* message flags */ -#define MESS_FLAG_FIFO 0x1 -#define MESS_FLAG_SLOG 0x2 -#define MESS_FLAG_HANDLED 0x4 - -typedef struct mm_msg mm_msg_t; -struct mm_msg { - char *msg_client_uuid; - uuid_text_t msg_uuid; - mm_msg_who_t msg_who; - mm_msg_sev_t msg_severity; - mm_timestamp_t msg_timestamp; - char *msg_type; - char *msg_client; - char *msg_instance; - char *msg_cid; - char *msg_host; - char *msg_manufacturer; - char *msg_model; - int msg_messageid; - char *msg_lang; - char *msg_text; - char *msg_localized; - mms_list_t *msg_args; - int msg_flags; -}; - -typedef struct mm_cmd_err mm_cmd_err_t; -struct mm_cmd_err { - mms_list_node_t mm_cmd_err_next; - char *ecode; - char *eclass; - char *err_buf; - int err_bufsize; - char *retry_drive; - char *retry_cart; - char *retry_lib; - int err_already_used; -}; - -typedef struct mm_wka { - cci_t wka_conn; - mms_list_node_t wka_next; - int mm_cmd_dispatchable; - mm_lang_t mm_wka_mm_lang; - parser_func_t mm_wka_parser; - mms_t *mm_wka_conn; - mm_data_t *mm_data; - mm_privilege_t wka_privilege; - boolean_t wka_hello_needed; - uuid_text_t session_uuid; - begin_end_t wka_begin_end; - int wka_remove; - pthread_mutex_t wka_local_lock; - int wka_need_accept; - int wka_goodbye; - int wka_unwelcome; -} mm_wka_t; - -struct mm_command { - mms_list_node_t cmd_next; - mms_list_node_t cmd_depend_list_next; - int cmd_flags; - /* Short name of command */ - char *cmd_name; - /* Continue from state */ - int cmd_state; - /* command root node */ - mms_par_node_t *cmd_root; - /* Parse tree for response */ - mms_par_node_t *cmd_response; - /* List of responses for each cmd */ - mms_list_t cmd_resp_list; - /* Generated report */ - char *cmd_report; - /* task string */ - char *cmd_task; - int (*cmd_func) (mm_wka_t *, mm_command_t *); - /* dispatch this cmd */ - - mms_list_t cmd_depend_list; - char *cmd_textcmd; - mm_wka_t *wka_ptr; - uuid_text_t cmd_uuid; - uuid_text_t wka_uuid; - mm_lang_t cmd_language; - /* command work buffer */ - char *cmd_buf; - int cmd_bufsize; - /* command removal flag */ - int cmd_remove; - /* mount information */ - cmd_mount_info_t cmd_mount_info; - mm_data_t *cmd_mm_data; - /* eject information */ - cmd_eject_t *cmd_eject; - - /* Path Information */ - int cmd_source_num; - int cmd_dest_num; - int cmd_const_num; - - int cmd_has_list; - mms_list_t cmd_source_list; - mms_list_t cmd_dest_list; - mms_list_t cmd_const_list; - /* error list */ - mms_list_t cmd_err_list; - mm_cmd_err_t *cmd_err_ptr; - - - mms_list_t cmd_beginend_list; - int cmd_begin_has_end; - mm_command_t *cmd_begin_cmd; - /* Used for notify to clause */ - int cmd_notify_to; - /* command message */ - mm_msg_t cmd_msg; - - /* command request id */ - uuid_text_t cmd_reqid; - - /* error class */ - char *cmd_eclass; - char *cmd_ecode; -}; - -/* Set and Unset Struct */ -typedef struct cmd_set cmd_set_t; -struct cmd_set { - mms_list_node_t cmd_set_next; - int cmd_set_type; - char *cmd_set_obj; - char *cmd_set_attr; - char *cmd_set_value; -}; - -typedef struct notify_cmd notify_cmd_t; -struct notify_cmd { - mms_list_node_t evt_next; - int evt_can_dispatch; - - /* Text of the command */ - char *evt_cmd; - uuid_text_t evt_cmd_uuid; - - /* Connection info about the event originator */ - uuid_text_t evt_cli_uuid; - uuid_text_t evt_session_uuid; - char *evt_cli_name; - char *evt_cli_instance; - - /* object is LM, DM, etc */ - char *evt_obj_name; - /* object instance 'dm1' 'lm1' */ - char *evt_obj_instance; - /* a host associated with the obj */ - char *evt_obj_host; - /* If there is a lib associated with this obj */ - char *evt_obj_library; - /* If there is a cartid associated with this obj */ - char *evt_obj_cartid; - /* If there is a drive associated with this obj */ - char *evt_obj_drive; - /* If there is a application associated with this obj */ - char *evt_obj_app; - /* If there is a application instance */ - /* associated with this obj */ - char *evt_obj_appinst; - -}; - -typedef struct mm_lib_stat mm_lib_stat_t; -struct mm_lib_stat { - char *lib_stat_name; - char *lib_stat_online; - char *lib_stat_disabled; - char *lib_stat_broken; - char *lib_stat_lm; -}; -typedef struct mm_lm_stat mm_lm_stat_t; -struct mm_lm_stat { - char *lm_stat_name; - char *lm_stat_hard; - char *lm_stat_soft; - char *lm_stat_disabled; - char *lm_stat_library; -}; -typedef struct mm_drive_stat mm_drive_stat_t; -struct mm_drive_stat { - char *drive_stat_name; - char *drive_stat_disabled; - char *drive_stat_broken; - char *drive_stat_soft; - char *drive_stat_hard; - char *drive_stat_lib_acc; - char *drive_stat_excl_app; - char *drive_stat_online; - char *drive_stat_group; - char *drive_stat_library; - char *drive_stat_priority; - char *drive_stat_dm; - char *drive_stat_geometry; - char *drive_stat_serial; - char *drive_stat_pcl; - char *drive_stat_drvlib_occ; -}; -typedef struct mm_dm_stat mm_dm_stat_t; -struct mm_dm_stat { - char *dm_stat_name; - char *dm_stat_soft; - char *dm_stat_hard; - char *dm_stat_drive; - char *dm_stat_disabled; - char *dm_stat_host; -}; - -/* For cmd_set_type */ -#define MM_SET 1 -#define MM_UNSET 2 - - - -/* Dispatcher return codes */ -#define MM_CMD_DONE 1 /* Successful completion of cmd function */ -#define MM_NO_DISPATCH 2 /* A command state completed, */ - /* no additional dispatch is necessary */ -#define MM_DISPATCH_DEPEND 3 /* Successful completion of command */ - /* that has triggered another command for */ - /* dispatch */ -#define MM_DEPEND_DONE 4 /* A command that has other commands */ - /* waiting for it has completed successfully */ -#define MM_CMD_ERROR 5 /* a command failed with an error */ -#define MM_DISPATCH_AGAIN 6 /* A command has finshed that */ - /* reqires additional commands to be */ - /* dispatched */ -#define MM_ACCEPT_NEEDED 7 /* The command is waiting for an accept */ -#define MM_WORK_TODO 8 /* A command has returned from a state */ - /* where more work is requried */ -#define MM_DEPEND_ERROR 9 /* A command that other commands are */ - /* waiting on has terminated with an error */ -#define MM_RESYNC 10 /* Used only for a mount cmd */ - /* when internal states */ - /* have gotten out of sync */ - -/* Command Flags */ -#define MM_CMD_DISPATCHABLE 0x01 -#define MM_CMD_NEED_ACCEPT 0x02 -#define MM_CMD_DEPEND_ERROR 0x04 -#define MM_CMD_ACCEPTED 0x08 - -/* DMP DM Command Types */ -#define MM_DMP_RESERVE 1 -#define MM_DMP_PRIV 2 -#define MM_DMP_LOAD 3 -#define MM_DMP_ATTACH 4 -#define MM_DMP_IDENTIFY 5 -#define MM_DMP_DETACH 6 -#define MM_DMP_UNLOAD 7 -#define MM_DMP_RELEASE 8 - -/* Recovery */ - -#define MM_MAX_RETRY 1 -#define MM_USE_RECOVER 0 -#define NONE 0 -#define LM 1 -#define DM 2 -#define MM 3 - -/* Parse Error Return Codes */ -#define MM_PAR_NO_MEM 1 -#define MM_PAR_ERROR 2 -#define MM_PAR_OK 3 -#define MM_PAR_SEND_UNACC 4 -#define MM_PAR_SEND_UNWEL 5 -#define MM_PAR_IS_RESP 6 - -/* Number-clause range */ -enum mm_range_type { - MM_RANGE_NONE, - MM_RANGE_FIRST_LAST, - MM_RANGE_FIRST, - MM_RANGE_LAST, - MM_RANGE_NUMS, - MM_RANGE_A_NUM -}; -typedef enum mm_range_type mm_range_type_t; - -typedef struct mm_range mm_range_t; -struct mm_range { - mm_range_type_t mm_range_type; - int mm_range_first; - int mm_range_last; -}; - -/* MM routines */ -int mm_is_exiting(void); -int mm_rm_mount(mm_command_t *cmd, mm_db_t *db); -int mm_rm_unmount(mm_command_t *cmd, mm_db_t *db); -extern int mm_candidate_cartridge_ok(mm_wka_t *mm_wka, - mm_command_t *cmd, mm_db_t *db, cmi_cart_list_t *cart); -extern int mm_candidate_drive_ok(mm_wka_t *mm_wka, - mm_command_t *cmd, mm_db_t *db, - char *candidate_cartid, cmi_drive_list_t *drive); -extern int mm_candidate_library_ok(mm_command_t *cmd, - mm_db_t *db, char *candidate_library); -extern void mm_set_cmd_err_buf(mm_command_t *cmd, char *class, char *token); -extern void mm_cfg_free(mm_cfg_t *cfg); -extern int mm_cfg_read(mm_cfg_t *cfg); -extern int mm_mc_load(mm_db_t *db, char *mc_fn); -extern int mm_mmp_add_act(mm_wka_t *mm_wka, mm_command_t *mnt_cmd); -extern char *mm_check_mode(mm_wka_t *mm_wka, mm_command_t *cmd, char *drive, - cmi_mode_list_t *mode, char *cart_id, mm_db_t *db); -extern void mm_sql_update_state(mm_data_t *data, char *object, - char *attribute, char *value, char *instance, char *name); -extern void mm_clear_source(mm_command_t *cmd); -extern void mm_clear_dest(mm_command_t *cmd); -extern void mm_clear_const(mm_command_t *cmd); -extern int mm_notify_chg_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_get_range(mm_command_t *cmd, mm_range_t *range); -extern int mm_add_match_list(char *str, mms_list_t *list); -extern int mm_errorcode_eq(mms_par_node_t *cmd_response, char *code); -extern void delete_dm_config(mm_wka_t *mm_wka, mm_db_t *db); -extern int notify_send(notify_cmd_t *event); -extern void mm_set_mount_info_pcl(char *pcl, - cmd_mount_info_t *mount_info); -extern void mm_set_mount_info_cart(char *cart_id, - cmd_mount_info_t *mount_info); -extern void mm_set_mount_info_drive(char *drive, - cmd_mount_info_t *mount_info); -extern void mm_set_mount_info_dm(char *dm, - cmd_mount_info_t *mount_info); -extern void mm_set_mount_info_library(char *library, - cmd_mount_info_t *mount_info); -int mm_remove_unload(char *library, char *drive, mm_data_t *mm_data); -extern int mm_schedule_unload(mm_wka_t *mm_wka, mm_command_t *cmd); -mm_command_t * -mm_dispatch_unload(char *library, char *drive, mm_command_t *cmd, - mm_data_t *mm_data); -void mm_free_cmi_drive(cmi_drive_list_t *drive); -void mm_free_cmi_cart(cmi_cart_list_t *cart); -extern mm_command_t *mm_alloc_cmd(mm_wka_t *mm_wka); -extern void mm_system_error(mm_command_t *cmd, char *fmt, ...); -extern void mm_clear_db(PGresult **results); -extern int mm_set_cartridge_status(char *id, char *status, mm_db_t *db); -extern int mm_set_drive_statesoft(char *drive, char *state, mm_db_t *db); -extern PGresult*mm_mount_cart_results(mm_wka_t *mm_wka, mm_command_t *cmd, - mm_db_t *db); -extern void mm_path_match_report(mm_command_t *cmd, mm_db_t *db); -extern int mm_sql_from_where(mm_command_t *cmd, mm_db_t *db); -extern int mm_mount_init_candidates(mm_command_t *cmd, - PGresult *cart_results, mm_db_t *db); -extern int mm_mount_check_candidates(mm_wka_t *mm_wka, mm_command_t *cmd, - mm_db_t *db); -extern void mm_print_accessmodes(mm_command_t *cmd); -extern void mm_print_mount_candidates(mm_command_t *cmd); -extern int mm_set_immediate_mount(mm_wka_t *mm_wka, mm_command_t *cmd, - mm_db_t *db); -extern void mm_free_cmi_cart_list(mms_list_t *cart_list); -extern int mm_mount_ready(mm_wka_t *mm_wka, mm_command_t *cmd, - mm_db_t *db, int is_retry); -extern int mm_unmount_ready(mm_wka_t *mm_wka, mm_command_t *cmd, mm_db_t *db); -extern int mm_set_cmd_dispatch(mm_data_t *mm_data, - char *cur_id, int need_unload); -extern int mm_add_to_source(mm_command_t *cmd, char *str); -extern int mm_add_to_dest(mm_command_t *cmd, char *str); -extern int mm_add_to_const(mm_command_t *cmd, char *str); -extern int mm_add_obj_list(mms_list_t *list, char *obj); -extern int mm_system_settings(mm_db_t *db, int *request_oper, int *auto_clear); -extern int mm_parse_mount_cmd(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_parse_unmount_cmd(mm_wka_t *mm_wka, mm_command_t *cmd); -extern PGresult*mm_unmount_cart_results(mm_wka_t *mm_wka, - mm_command_t *cmd, mm_db_t *db); -extern void mm_print_mount_summary(mm_wka_t *mm_wka, mm_command_t *cmd); -extern mm_command_t *mm_return_unload(char *library, char *drive, - mm_data_t *mm_data); -extern int mm_mount_candidate_loaded(mm_command_t *cmd); -extern int mm_mount_open_drive(mm_command_t *cmd); -extern int mm_mount_loaded_drive(mm_command_t *cmd, mm_db_t *db, - char **drive_to_unload, char **lib_to_unload); -extern int mm_unmount_2_drive(mm_command_t *cmd, - mm_db_t *db); -extern void mm_mount_clean_candidates(mm_command_t *cmd); -extern void mm_set_mount_objs(mm_command_t *cmd, mm_db_t *db); -extern void mm_set_unload_dispatch(mm_command_t *unmnt_cmd, - mm_command_t *parent); -extern mm_privilege_t mm_privileged(mm_wka_t *mm_wka, mm_command_t *cmd); -extern void mm_write_success(mm_command_t *cmd, char *fmt, ...); -extern int mm_notify_event_rules(mm_data_t *mm_data); -extern int mm_notify_chg_cmd_func_old(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_non_priv_const(mm_wka_t *mm_wka, mm_command_t *cmd); -extern char *mm_get_cart_pcl(mm_command_t *cmd, char *cart_id, mm_db_t *db); -extern int mm_check_drive_records(mm_data_t *mm_data, mm_db_t *db); -extern int mm_clean_drive_records(mm_data_t *mm_data, mm_db_t *db); -extern int mm_dispatch_now(mm_wka_t *mm_wka, mm_command_t *cmd, mm_db_t *db); -extern int mm_init_types(mm_data_t *mm_data, char *fn); -extern void mm_char_list_destroy(mms_list_t *list); -extern int mm_dispatch_now(mm_wka_t *mm_wka, mm_command_t *cmd, mm_db_t *db); - -/* Cmd Depend list functions */ -extern void -mm_add_depend(mm_command_t *child, mm_command_t *parent); -extern int -mm_has_depend(mm_command_t *cmd); -extern mm_command_t * -mm_top_parent(mm_command_t *child); -extern mm_command_t * -mm_first_parent(mm_command_t *child); -extern int -mm_is_parent(mm_command_t *parent, mm_command_t *child); -extern void -mm_remove_all_depend(mm_command_t *cmd); -extern void -mm_remove_this_depend(mm_command_t *cmd, mm_command_t *remove); -extern void -mm_dispatch_all_depend(mm_command_t *cmd); -extern -int -mm_set_depend_error(mm_command_t *cmd); - -/* MM Object Status */ -/* Call these functions to get status of MM objects */ -extern mm_lib_stat_t * -mm_get_library_status(char *library_name, mm_db_t *db); -extern void -mm_free_library_status(mm_lib_stat_t *lib_stat); -extern void -mm_print_library_status(mm_lib_stat_t *lib_stat); -extern mm_lm_stat_t * -mm_get_lm_status(char *lm_name, mm_db_t *db); -extern void -mm_free_lm_status(mm_lm_stat_t *lm_stat); -extern void -mm_print_lm_status(mm_lm_stat_t *lm_stat); -extern mm_drive_stat_t * -mm_get_drive_status(char *drive_name, mm_db_t *db); -extern void -mm_free_drive_status(mm_drive_stat_t *drive_stat); -extern void -mm_print_drive_status(mm_drive_stat_t *drive_stat); -extern mm_dm_stat_t * -mm_get_dm_status(char *dm_name, char *drive_name, char *host, mm_db_t *db); -extern void -mm_free_dm_status(mm_dm_stat_t *dm_stat); -extern void -mm_print_dm_status(mm_dm_stat_t *dm_stat); - -/* Event Notification Functions */ - -extern int mm_notify_init(mm_data_t *data); -extern int mm_notify_event_table(mm_data_t *mm_data); -extern void mm_notify_close(void); -extern void mm_notify_destroy(notify_cmd_t *event); -extern notify_cmd_t *mm_notify_add(char *event_fmt, ...); -extern void mm_notify_rollback(char *cmd_uuid); -extern void mm_notify_commit(char *cmd_uuid); -extern int mm_notify_now(char *cli_uuid, char *event_fmt, ...); -extern void mm_notify_add_newcartridge(mm_wka_t *mm_wka, - mm_command_t *cmd, - char *cartridgepcl, char *libraryname); -extern void mm_notify_add_newdrive(mm_wka_t *mm_wka, - mm_command_t *cmd, char *drivename, - char *libraryname); -extern int mm_notify_add_lmup(mm_wka_t *lm_wka, mm_command_t *cmd); -extern int mm_notify_add_lmdown(mm_wka_t *lm_wka, mm_command_t *cmd); -extern int mm_notify_add_config(mm_wka_t *mm_wka, mm_command_t *cmd, - char *type, - char *name, char *instance, char *host); -extern int mm_notify_add_driveonline(mm_wka_t *mm_wka, mm_command_t *cmd, - char *drivename); -extern int mm_notify_add_driveoffline(mm_wka_t *mm_wka, mm_command_t *cmd, - char *drivename); -extern void mm_notify_add_dmup(mm_wka_t *dm_wka, mm_command_t *cmd); -extern void mm_notify_add_dmdown(mm_wka_t *dm_wka, mm_command_t *cmd); -extern int mm_notify_add_volumeadd(mm_wka_t *mm_wka, mm_command_t *cmd, - char *volumename, char *cartid, mm_db_t *db); -extern int mm_notify_add_volumedelete(mm_wka_t *mm_wka, mm_command_t *cmd, - char *cartid, mm_db_t *db); -extern int mm_notify_add_dmdown_dc(mm_wka_t *dm_wka, mm_db_t *db); -extern int mm_notify_add_lmdown_dc(mm_wka_t *lm_wka, mm_db_t *db); -extern int mm_notify_add_volumeinject(mm_wka_t *lm_wka, mm_command_t *cmd, - char *pcl, mm_db_t *db); -extern int mm_notify_add_volumeeject(mm_wka_t *lm_wka, mm_command_t *cmd, - char *pcl, mm_db_t *db); -extern void mm_notify_add_librarycreate(mm_wka_t *mm_wka, mm_command_t *cmd, - char *libraryname); -extern void mm_notify_add_librarydelete(mm_db_t *db, mm_wka_t *mm_wka, - mm_command_t *cmd, int match_off); -extern void mm_notify_add_drivedelete(mm_db_t *db, mm_wka_t *mm_wka, - mm_command_t *cmd, int match_off); - -/* MMP Commands */ - -extern int mm_hello_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_private_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_cancel_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_inject_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_eject_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_move_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_cpreset_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_cpexit_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_cpstart_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_cpscan_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_shutdown_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_rename_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_deallocate_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_allocate_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_end_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_unmount_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_begin_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_privilege_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_locale_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_attribute_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_show_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_delete_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_mount_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_goodbye_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_create_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_libonline_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_drvonline_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_identity_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_direct_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_setpassword_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_delay_unmount_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_clear_drive_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); - -/* DMP Commands */ - -extern int mm_dmp_attach_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_dmp_load_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_dmp_private_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_dmp_ready_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_dmp_activate_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_dmp_config_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern mm_command_t *mm_dmp_add_cmd(mm_wka_t *mm_wka, - mm_command_t *mnt_cmd, char *dm_name, int type); -extern int mm_dmp_cancel_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_dmp_reset_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_dmp_exit_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); - -extern mm_command_t *mm_drive_dm_activate_enable(mm_wka_t *mm_wka); -extern int mm_drive_dm_activate_disable(mm_wka_t *mm_wka); - -/* LMP Commands */ - -extern int mm_lmp_config_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_sql_chk_len(char **line, int off, int *bufsize, int len); -extern int mm_sql_report_clause_new(mm_command_t *command, char *objname); -extern char *mm_get_task(mms_par_node_t *root); -extern mm_command_t *mm_add_clear_drive(char *drive_name, mm_data_t *mm_data, - mm_db_t *db, - mm_command_t *parent_cmd, char *cart_pcl, int force, int nonphysical); -extern int mm_library_lm_clear_states(mm_db_t *db); -extern mm_wka_t *mm_library_lm_wka(mm_data_t *mm_data, char *library, char *lm); -extern int mm_library_lm_connect(mm_wka_t *mm_wka); -extern int mm_library_lm_disconnect(mm_wka_t *mm_wka); -extern int mm_library_lm_cfg_conn_rdy(mm_command_t *cmd, - char *library, char *lm); -extern char *mm_library_lm_get_cap(mm_command_t *cmd, char *library, char *lm); -extern int mm_library_lm_activate_enable(mm_wka_t *mm_wka); -extern int mm_lmp_activate_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_lmp_ready_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_lmp_config_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_lmp_private_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_lmp_mount_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_lmp_unmount_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_lmp_inject_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_lmp_eject_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_lmp_scan_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_lmp_cancel_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -int -mm_add_lmp_scan(mm_data_t *mm_data, mm_command_t *parent_cmd, char *drive_name, - char *cartridge_pcl, char *library_name); -extern int mm_lmp_reset_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_lmp_exit_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); - -/* Message */ - -extern int mm_message_init(mm_db_t *db, mm_data_t *data); -extern void mm_message_close(void); -extern int mm_msg_tracing_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_message_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_message_command(mm_command_t *cmd); -extern int mm_msg_parse(mm_command_t *cmd, mms_par_node_t *root); -extern int mm_msg_exists(int message_id); -extern int mm_message(mm_db_t *db, mm_msg_who_t who, mm_msg_sev_t severity, - int messageid, ...); -extern int mm_msg_set_tracing(mm_wka_t *mm_wka, mm_command_t *cmd, int id); -extern int mm_msg_set_limit(mm_db_t *db); -extern void mm_response_error(mm_command_t *cmd, char *eclass, char *ecode, - int messageid, ...); -extern int mm_msg_send_tracing(mm_wka_t *mm_wka); -extern char *mm_msg_lang2component(mm_lang_t lang); - -/* System log file */ - -extern int mm_slog_set_fname(mm_db_t *db); -extern int mm_slog_set_sync(mm_db_t *db); -extern int mm_slog_set_level(mm_db_t *db); -extern int mm_slog_set_size(mm_db_t *db); - -/* Operator Commands */ - -extern int mm_make_request(mm_wka_t *mm_wka, mm_command_t *cmd, char *task, - int priority, int messageid, ...); -extern int mm_cancel_request(mm_db_t *db, char *reqid); -extern int mm_request_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_request_disconnect(mm_db_t *db, mm_wka_t *mm_wka); -extern int mm_accept_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_respond_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_release_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_request_history_limit(mm_db_t *db); - - -#ifdef __cplusplus -} -#endif - -#endif /* _MM_H */ diff --git a/usr/src/cmd/mms/mm/common/mm_cfg.c b/usr/src/cmd/mms/mm/common/mm_cfg.c deleted file mode 100644 index db0f153175..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_cfg.c +++ /dev/null @@ -1,117 +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 <string.h> -#include <stdlib.h> -#include <errno.h> -#include <syslog.h> -#include <sys/types.h> -#include <mms_list.h> -#include <mms_parser.h> -#include <mms_par_impl.h> -#include <mms_trace.h> -#include <host_ident.h> -#include <mms_cfg.h> -#include "mm_db.h" -#include "mm.h" -#include "mm_util.h" -#include "net_cfg_service.h" - -static char *_SrcFile = __FILE__; - -int -mm_cfg_read(mm_cfg_t *mm_cfg) -{ - char *port; - char host_name[MMS_HOST_IDENT_LEN + 1]; - char host_ip[MMS_IP_IDENT_LEN + 1]; - mms_network_cfg_t *net_cfg = &mm_cfg->mm_network_cfg; - mm_db_cfg_t *db_cfg = &mm_cfg->mm_db_cfg; - char *value; - - - mms_trace(MMS_DEVP, "mm_cfg_read"); - (void) memset(mm_cfg, 0, sizeof (mm_cfg_t)); - if (mms_net_cfg_service(net_cfg, "mm", "MMP", "1.0")) { - mms_trace(MMS_ERR, "net config read"); - goto out; - } - (void) mms_host_info(host_name, host_ip); - free(net_cfg->cli_host); - if ((net_cfg->cli_host = strdup(host_name)) == NULL) { - mms_trace(MMS_ERR, "config hostname"); - goto out; - } - db_cfg->mm_db_host = mms_cfg_alloc_getvar(MMS_CFG_MM_DB_HOST, NULL); - db_cfg->mm_db_port = -1; - if (port = mms_cfg_alloc_getvar(MMS_CFG_MM_DB_PORT, NULL)) { - db_cfg->mm_db_port = atoi(port); - free(port); - } - db_cfg->mm_db_name = mms_cfg_alloc_getvar(MMS_CFG_MM_DB_NAME, NULL); - db_cfg->mm_db_user = mms_cfg_alloc_getvar(MMS_CFG_MM_DB_USER, NULL); - db_cfg->mm_db_passwd = mms_net_cfg_read_pass_file(MMS_NET_CFG_DB_FILE); - mm_cfg->mm_ssl_dh_file = mms_cfg_alloc_getvar(MMS_CFG_SSL_DH_FILE, - NULL); - if (value = mms_cfg_alloc_getvar(MMS_CFG_SSL_VERIFY, NULL)) { - if (strcasecmp(value, "true") == 0) { - mm_cfg->mm_ssl_verify_peer = 1; - } - free(value); - } - if (net_cfg->cli_host == NULL || - net_cfg->cli_name == NULL || - net_cfg->cli_inst == NULL || - net_cfg->cli_pass == NULL || - db_cfg->mm_db_host == NULL || - db_cfg->mm_db_port < 0 || - db_cfg->mm_db_name == NULL || - db_cfg->mm_db_user == NULL) { - mms_trace(MMS_ERR, "invalid config"); - goto out; - } - return (0); - -out: - mm_cfg_free(mm_cfg); - return (1); -} - -void -mm_cfg_free(mm_cfg_t *mm_cfg) -{ - mms_network_cfg_t *net_cfg = &mm_cfg->mm_network_cfg; - mm_db_cfg_t *db_cfg = &mm_cfg->mm_db_cfg; - - mms_net_cfg_free(net_cfg); - free(mm_cfg->mm_ssl_dh_file); - free(db_cfg->mm_db_host); - free(db_cfg->mm_db_name); - free(db_cfg->mm_db_user); - free(db_cfg->mm_db_passwd); - - (void) memset(mm_cfg, 0, sizeof (mm_cfg_t)); -} diff --git a/usr/src/cmd/mms/mm/common/mm_commands.h b/usr/src/cmd/mms/mm/common/mm_commands.h deleted file mode 100644 index 3e1595d9bb..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_commands.h +++ /dev/null @@ -1,278 +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 _MM_COMMANDS_H -#define _MM_COMMANDS_H - - -#ifdef __cplusplus -extern "C" { -#endif - -#define RESPONSE_STR "response" -#define SUCCESS_STR "success" -#define ERROR_STR "error" -#define UNACCEPTABLE_STR "unacceptable" -#define ACCEPTED_STR "accepted" - -/* activate */ -#define ACTIVATE_ENABLE "activate task[\"%s\"] enable;" -#define ACTIVATE_DISABLE "activate task[\"%s\"] disable;" -#define ACTIVATE_RESERVE "activate task[\"%s\"] reserve;" -#define ACTIVATE_RELEASE "activate task[\"%s\"] release;" - -/* lmp mount */ -#define LMP_MOUNT "mount task[\"%s\"] slot [\"%s\" \"%s\" \"%s\"] "\ - "drive [\"%s\"];" - -/* lmp unmount */ -#define LMP_UNMOUNT "unmount task[\"%s\"] fromslot [\"%s\" \"%s\" \"%s\"] "\ - "drive [\"%s\"] toslot [\"%s\" \"%s\" \"%s\"];" - -/* lmp private */ -#define LMP_PVT_SET_DRV_GEO "private task[\"%s\"] set [\"drive\" \"%s\" "\ - "\"geometry\" \"%s\"];" -#define EDRVNODMCONFIGURED "EDRVNODMCONFIGURED" - -/* lmp inject */ -#define LMP_INJECT "inject task[\"%s\"] slotgroup[\"%s\"];" - -/* lmp eject */ -#define LMP_EJECT "eject task[\"%s\"] slotgroup[\"%s\"] " -#define LMP_EJECT_SLOT "slot[\"%s\" \"%s\"] " -#define LMP_EJECT_END ";" - -/* notify events */ -#define NOTIFY_EVENT_CFG "event config [\"%s\" \"%s\" \"%s\"];" -#define EVENT_CFG_NEW "new" -#define EVENT_CFG_DELETE "delete" -#define NOTIFY_EVENT_CFG_CHG "event config [\"%s\" \"change\" \"%s\" \"%s\"];" - -/* hello */ -#define MMS_WELCOME "welcome version[\"%s\"] servername[\"%s\"];" -#define WELCOME_PASS "welcome version[\"%s\"] servername[\"%s\"] "\ - "password[\"%s\"];" -#define WELCOME_CERT "welcome version[\"%s\"] servername[\"%s\"] "\ - "certificate[\"\n%s\n\" \"%s\"];" -#define UNWELCOME_DENIED "unwelcome \"SSAI_E_ACCESS_DENIED\";" -#define UNWELCOME_LANG "unwelcome \"SSAI_E_UNKNOWN_LANGUAGE\";" -#define UNWELCOME_UNSUP "unwelcome \"SSAI_E_UNSUPPORTED_LANGUAGE\";" -#define UNWELCOME_DUP "unwelcome \"SSAI_E_DUPLICATE_SESSION\";" -#define UNWELCOME_PROTO "unwelcome \"SSAI_E_PROTOCOL_ERROR\";" - -/* goodbye */ -#define EACCHANDLESTILLINUSE "EACCHANDLESTILLINUSE" -#define ENOINSTANCE "ENOINSTANCE" -#define ENOSESSION "ENOSESSION" -#define ECONNDELETE "ECONNDELETE" - -/* shutdown */ - -/* response */ -#define RESPONSE_ACCEPTED "response task[\"%s\"] accepted;" -#define RESPONSE_UNACCEPTABLE "response unacceptable;" -#define RESPONSE_SUCCESS "response task[\"%s\"] success;" -#define RESPONSE_INTERMEDIATE "response task[\"%s\"] intermediate %s;" -#define RESPONSE_SUCCESS_TEXT "response task[\"%s\"] success text [%s];" -#define RESPONSE_SUCCESS_TEXT_DQ "response task[\"%s\"] success text [\"%s\"];" -#define RESPONSE_SUCCESS_STR "response task[\"%s\"] success %s;" -#define RESPONSE_ERROR "response task[\"%s\"] error [%s %s];" -#define RESPONSE_ERROR_STR "response task[\"%s\"] error [%s %s] %s;" -#define RESPONSE_ERROR_TEXT "response task[\"%s\"] error [%s %s] "\ - "message [ id [ \"%s\" \"%s\" \"%d\" ] arguments [ %s ] "\ - "loctext [ \"%s\" \"%s\" ] ];" -#define SIMPLE_RESPONSE_ERROR_TEXT "response task[\"%s\"] error [%s %s] "\ - "message [ id [ \"ieee\" \"1244\" \"5001\" ] "\ - "loctext [ \"en\" \"%s\" ] ];" -#define RESPONSE_ERROR_ARG "response task[\"%s\"] error [%s %s] "\ - "message [ id [ \"%s\" \"%s\" \"%d\" ] arguments [ %s ] ];" -#define RESPONSE_CANCELLED "response task[\"%s\"] cancelled;" - -/* library/drive online */ -#define ELIBRARYNOEXIST "ELIBRARYNOEXIST" -#define EDRIVENOEXIST "EDRIVENOEXIST" -#define ELMNOEXIST "ELMNOEXIST" -#define ETOOMANYCLAUSES "ETOOMANYCLAUSES" - - -/* attribute */ -#define EOBJATTRTOOMANY "EOBJATTRTOOMANY" -#define EOBJSYSATTRMODDISALLOWED "EOBJSYSATTRMODDISALLOWED" -#define EOBJSYSATTRMODNOPRIV "EOBJSYSATTRMODNOPRIV" -#define EOBJUSRATTRCREATEDISALLOWED "EOBJUSRATTRCREATEDISALLOWED" -#define EOBJUSRATTRCREATENOPRIV "EOBJUSRATTRCREATENOPRIV" -#define EOBJATTRVALNULLSTRING "EOBJATTRVALNULLSTRING" -#define EOBJATTRVALNOTNUM "EOBJATTRVALNOTNUM" -#define EOBJATTRVALNOTENUM "EOBJATTRVALNOTENUM" -#define EOBJKEYCHANGE "EOBJKEYCHANGE" -#define EOBJKEYNOTUNIQUE "EOBJKEYNOTUNIQUE" -#define EOBJDEPENDNOEXIST "EOBJDEPENDNOEXIST" -#define ETRANSACTIONFAILED "ETRANSACTIONFAILED" -#define EOBJATTRMODDISALLOWED "EOBJATTRMODDISALLOWED" -#define ESYSATTRUNSETDISALLOWED "ESYSATTRUNSETDISALLOWED" -#define ESYSTEM "ESYSTEM" - -/* create */ -#define EOBJCREATEDISALLOWED "EOBJCREATEDISALLOWED" - -/* rename */ -#define EVOLINUSE "EVOLINUSE" -#define EVOLNAMEREWRITE "EVOLNAMEREWRITE" -#define ETRANSACTIONFAILED "ETRANSACTIONFAILED" -#define ERENAMEDVOLEXISTS "ERENAMEDVOLEXISTS" - -/* mm_mount */ -#define IMMEDIATE "immediate" -#define VOLUME "VOLUME" -#define SIDE "SIDE" -#define PARTITION "PARTITION" -#define EINVALIDTYPE "EINVALIDTYPE" -#define ENOMATCH "ENOMATCH" -#define ELIBRARYOFFLINE "ELIBRARYOFFLINE" -#define EDRIVEOFFLINE "EDRIVEOFFLINE" - -/* shutdown */ -#define ECOMMANDNOPRIVILEGE "ECOMMANDNOPRIVILEGE" -#define ESHUTDOWNFAILED "ESHUTDOWNFAILED" - -/* locale */ -#define ELANGNOTSUPPORTED "ELANGNOTSUPPORTED" -#define ESORTNOTSUPPORTED "ESORTNOTSUPPORTED" - -#define LANG_EN "en" -#define LANG_EN_US "en-US" - -/* message */ -#define MM_E_CMDARGS "MM_E_CMDARGS" -#define MM_E_INTERNAL "MM_E_INTERNAL" - -/* privilege */ -#define ENOSUCHPRIV "ENOSUCHPRIV" -#define EPRIVCHANGEDISALLOWED "EPRIVCHANGEDISALLOWED" -#define ENOPRIVCHANGE "ENOPRIVCHANGE" - -#define STANDARD "standard" -#define ADMINISTRATOR "administrator" -#define SYSTEM_PRIV "system" - -/* begin */ -#define BLOCKING "blocking" - -/* cpscan */ -#define ELIBNOLMCONFIGURED "ELIBNOLMCONFIGURED" -#define ELMNOTCONNECTED "ELMNOTCONNECTED" -#define ELMDMCOMMUNICATION "ELMDMCOMMUNICATION" -#define ETOOMANY "ETOOMANY" -#define ELMNOTREADY "ELMNOTREADY" - -/* cpreset */ -#define EDRVNODMCONFIGURED "EDRVNODMCONFIGURED" -#define EDMNOTCONNECTED "EDMNOTCONNECTED" -#define EDMNOTREADY "EDMNOTREADY" -#define EDRIVEONLINE "EDRIVEONLINE" -#define ELIBRARYONLINE "ELIBRARYONLINE" - -/* move */ -#define ENOSUCHCART "ENOSUCHCART" -#define ECARTNOTLOCATED "ECARTNOTLOCATED" - -/* eject */ -#define EINVALCLAUSEARG "EINVALCLAUSEARG" -#define ENOSUCHPCL "ENOSUCHPCL" -#define ECARTINUSE "ECARTINUSE" -#define ENOSLOT "ENOSLOT" -#define ESLOTNOTOCCUPIED "ESLOTNOTOCCUPIED" - -/* allocate */ -#define ENEWVOLEXISTS "ENEWVOLEXISTS" -#define ENEWVOLNAMECOUNT "ENEWVOLNAMECOUNT" -#define ENOTENOUGHPARTITIONS "ENOTENOUGHPARTITIONS" -#define EPARTITIONSTATECHANGE "EPARTITIONSTATECHANGE" -#define ECARTRIDGESTATECHANGE "ECARTRIDGESTATECHANGE" - -/* lm */ -#define ELMSTILLBOOTING "ELMSTILLBOOTING" -#define ELMNOTCONNECTED "ELMNOTCONNECTED" -#define ELMDMCOMMUNICATION "ELMDMCOMMUNICATION" - -/* accept */ -#define ENOSUCHREQ "ENOSUCHREQ" -#define EREQUESTALREADYACCEPTED "EREQUESTALREADYACCEPTED" -#define EREQUESTALREADYSATISFIED "EREQUESTALREADYSATISFIED" -#define EREQSTATECHANGEFAILED "EREQSTATECHANGEFAILED" - -/* respond */ -#define EREQUESTNOTACCEPTED "EREQUESTNOTACCEPTED" -#define EREQACCEPTEDBYDIFFSESS "EREQACCEPTEDBYDIFFSESS" - -/* release */ -#define EREQUESTNOTACCEPTED "EREQUESTNOTACCEPTED" - -/* cancel */ -#define ENOCANCELLABLETASKS "ENOCANCELLABLETASKS" -#define EDM_E_NOTASK "EDM_E_NOTASK" -#define EDM_E_NOCANC "EDM_E_NOCANC" -#define ELM_E_NOTASK "ELM_E_NOTASK" -#define ELM_E_NOCANC "ELM_E_NOCANC" - -/* direct */ -#define ECOMMUNICATION "ECOMMUNICATION" -#define ENOTCONNECTED "ENOTCONNECTED" - -/* Error classes */ -#define ECLASS_LANGUAGE "language" -#define ECLASS_EXPLICIT "explicit" -#define ECLASS_INTERNAL "internal" -#define ECLASS_INVALID "invalid" -#define ECLASS_DM_INVALID "dm_invalid" -#define ECLASS_DM_CONFIG "dm_config" -#define ECLASS_RETRY "retry" -#define ECLASS_EXIST "exist" -#define ECLASS_SUBOP "subop" -#define ECLASS_CONFIG "config" -#define ECLASS_STATE "state" -#define ECLASS_PERMPRIV "permpriv" -#define ECLASS_COMPAT "compat" - -/* - * Vendor-defined error codes - */ - -/* Sun MM System error codes */ -#define EDATABASE "EDATABASE" -#define ESYNTAX "ESYNTAX" -#define ENOTFOUND "ENOTFOUND" -#define ERESTRICTED "ERESTRICTED" -#define EPRIVNOTMMSADMIN "EPRIVNOTMMSADMIN" -#define MM_E_NOTASK "MM_E_NOTASK" -#define MM_E_TOOMANYTASKS "MM_E_TOOMANYTASKS" -#define ESYSTEMCONFIGCHANGE "ESYSTEMCONFIGCHANGE" - - -#ifdef __cplusplus -} -#endif - - -#endif /* _MM_COMMANDS_H */ diff --git a/usr/src/cmd/mms/mm/common/mm_db.c b/usr/src/cmd/mms/mm/common/mm_db.c deleted file mode 100644 index 97157d3af7..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_db.c +++ /dev/null @@ -1,1228 +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. - */ - - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <time.h> -#include <errno.h> -#include <sys/types.h> -#include <ctype.h> -#include <syslog.h> -#include <unistd.h> -#include <libpq-fe.h> -#include <mms_list.h> -#include <mms_parser.h> -#include <msg_sub.h> -#include <mms_trace.h> -#include <mms_strapp.h> -#include "mm_commands.h" -#include "mm_db.h" -#include "mm.h" -#include "mm_util.h" -#include "mm_db_version.h" -#include <mms_cfg.h> -#include <net_cfg_service.h> -#include <fcntl.h> - -static char *_SrcFile = __FILE__; -static mm_db_rval_t db_connect(mm_db_t *db, char *database_name); -static mm_db_rval_t mm_db_oid_init(mm_db_t *db); -static void notice_receiver(void *, const PGresult *); -static char *mm_db_get_sql_cmd(char *fmt, va_list args); -static mm_db_rval_t mm_db_do_exec(char *file, int line, mm_db_t *db, int flag, - char *fmt, va_list args); - -/* - * Initialize database, called once at startup. - * - * The MMS installation process must up-grade or down-grade the - * postgres database to the same version as mm is expecting. - */ -mm_db_rval_t -mm_db_init(mm_db_t *db) -{ - int exists; - int rows; - int row; - int try = 0; - const int retrys = 10; - char *initialized; - int db_version; - - - mms_trace(MMS_DEVP, "inspecting database"); - -try_again: - if (mm_is_exiting()) { - mms_trace(MMS_ERR, "MM Exiting"); - exit(SMF_EXIT_OK); - } - if (try >= retrys) { - mms_trace(MMS_ERR, "unable to initialize, retries exceed"); - mms_trace(MMS_INFO, - "HINT: make sure mms:db is configured and running"); - return (MM_DB_ERROR); - } else if (try > 1) { - mms_trace(MMS_DEVP, "trying to initialize again %d", try); - } - try++; - - if (db_connect(db, "template1") != MM_DB_OK) { - mms_trace(MMS_INFO, "can't connect to built-in database"); - sleep(2); - goto try_again; - } - if (mm_db_exec(HERE, db, "SELECT datname FROM pg_database " - "WHERE datname = '%s';", db->mm_db_cfg->mm_db_name) != MM_DB_DATA) { - mm_db_disconnect(db); - mms_trace(MMS_ERR, "can't query for database"); - return (MM_DB_ERROR); - } - rows = PQntuples(db->mm_db_results); - for (row = 0, exists = 0; row < rows && exists == 0; row++) { - if (strcmp(PQgetvalue(db->mm_db_results, row, 0), - db->mm_db_cfg->mm_db_name) == 0) { - mms_trace(MMS_DEVP, "found database %s", - db->mm_db_cfg->mm_db_name); - exists = 1; - break; - } - } - mm_clear_db(&db->mm_db_results); - if (exists == 0) { - mms_trace(MMS_ERR, "database %s not found", - db->mm_db_cfg->mm_db_name); - mms_trace(MMS_INFO, "HINT: run `mms.ksh data`"); - return (MM_DB_ERROR); - } - mm_db_disconnect(db); - - if (db_connect(db, db->mm_db_cfg->mm_db_name) != MM_DB_OK) { - mms_trace(MMS_ERR, "can't connect to database %s", - db->mm_db_cfg->mm_db_name); - mms_trace(MMS_INFO, "HINT: run `mms.ksh start`"); - return (MM_DB_ERROR); - } - if (mm_db_exec(HERE, db, "SELECT \"DBInitialized\",\"DBVersion\" " - "FROM \"MM\";") != MM_DB_DATA) { - mms_trace(MMS_ERR, "can't query internal mm object"); - mm_clear_db(&db->mm_db_results); - return (MM_DB_ERROR); - } - if (PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - mms_trace(MMS_ERR, "database not completely initialized"); - mms_trace(MMS_INFO, "HINT: run `mms.ksh clean; mms.ksh data`"); - return (MM_DB_ERROR); - } - initialized = PQgetvalue(db->mm_db_results, 0, 0); - if (strcmp(initialized, "true") != 0 && - strcmp(initialized, "t") != 0) { - mms_trace(MMS_ERR, "database not initialized"); - mms_trace(MMS_INFO, "HINT: run `mms.ksh clean; mms.ksh data`"); - mm_clear_db(&db->mm_db_results); - return (MM_DB_ERROR); - } - db_version = atoi(PQgetvalue(db->mm_db_results, 0, 1)); - if (db_version != MM_DB_VERSION) { - if (db_version > MM_DB_VERSION) { - mms_trace(MMS_INFO, - "down-grade database version from %d to %d", - db_version, MM_DB_VERSION); - if (mm_db_downgrade(db, db_version, MM_DB_VERSION) - != MM_DB_OK) { - mms_trace(MMS_ERR, - "down-grade database failed"); - return (MM_DB_ERROR); - } - } else { - mms_trace(MMS_INFO, - "up-grade database version from %d to %d", - db_version, MM_DB_VERSION); - if (mm_db_upgrade(db, db_version, MM_DB_VERSION) - != MM_DB_OK) { - mms_trace(MMS_ERR, "up-grade database failed"); - return (MM_DB_ERROR); - } - } - if (mm_db_exec(HERE, db, "UPDATE \"MM\" SET " - "\"DBVersion\" = '%d';", MM_DB_VERSION) != MM_DB_OK) { - mms_trace(MMS_ERR, "Error upgrade DBVersion"); - } - mm_clear_db(&db->mm_db_results); - mms_trace(MMS_DEVP, "database mods done"); - } - mms_trace(MMS_INFO, "mm and database version %d", MM_DB_VERSION); - mm_clear_db(&db->mm_db_results); - - if (mm_db_oid_init(db) != MM_DB_OK) { - mms_trace(MMS_ERR, "failed to read database OIDs"); - return (MM_DB_ERROR); - } - - mm_db_disconnect(db); - mms_trace(MMS_DEVP, "Initialization status - ok"); - return (MM_DB_OK); -} - -/* Connect to the database. */ -static mm_db_rval_t -db_connect(mm_db_t *db, char *database_name) -{ - mm_db_rval_t rval; - char *sql_cmd; - mm_db_cfg_t *db_cfg = db->mm_db_cfg; - - sql_cmd = mms_strnew("host=%s port=%d dbname=%s user=%s", - db->mm_db_cfg->mm_db_host, - db->mm_db_cfg->mm_db_port, - database_name, - db->mm_db_cfg->mm_db_user); - mms_trace(MMS_DEBUG, "connect command - %s", sql_cmd); - if (db_cfg->mm_db_passwd) { - mms_trace(MMS_DEBUG, "adding password"); - sql_cmd = mms_strapp(sql_cmd, " password=%s", - db_cfg->mm_db_passwd); - } - if (sql_cmd == NULL) { - mms_trace(MMS_ERR, "Connect - unable to build command"); - return (MM_DB_ERROR); - } - db->mm_db_rval = PQstatus(db->mm_db_conn = PQconnectdb(sql_cmd)); - switch (db->mm_db_rval) { - case CONNECTION_OK: - if ((db->mm_db_fd = PQsocket(db->mm_db_conn)) < 0) { - (void) mm_db_disconnect(db); - rval = MM_DB_ERROR; - mms_trace(MMS_DEVP, - "connect command status, no sockfd"); - } else { - rval = MM_DB_OK; - PQsetNoticeReceiver(db->mm_db_conn, notice_receiver, - NULL); - mms_trace(MMS_DEVP, "connect command status - ok"); - } - break; - default: - rval = MM_DB_ERROR; - mms_trace(MMS_DEVP, "connect command status - %d, %s", - db->mm_db_rval, PQerrorMessage(db->mm_db_conn)); - } - free(sql_cmd); - return (rval); -} - -/* Disconnect from the database. */ -void -mm_db_disconnect(mm_db_t *db) -{ - if (db != NULL && db->mm_db_conn != NULL) { - PQfinish(db->mm_db_conn); - db->mm_db_conn = NULL; - db->mm_db_fd = -1; - mms_trace(MMS_DEVP, "disconnect"); - } -} - -mm_db_rval_t -mm_db_resend(mm_db_t *db, char *sql_cmd) { - int num_retry = 0; - int rc; - - mm_char_list_t *node; - mm_char_list_t *next; - - int max_retry = 10; - int timeout = 3; - - char *buf = NULL; - - /* MM has disconnected from the db */ - /* attempt to reconnect and resend all commands */ - /* in the currect transaction block for this db connection */ - - if ((buf = mms_cfg_alloc_getvar(MMS_CFG_DB_RETRY, NULL)) == NULL) { - /* report service configuration repoistory scf_error() */ - mms_trace(MMS_ERR, "using default-path, ssi path cfg error"); - max_retry = 50; - } else { - max_retry = atoi(buf); - free(buf); - buf = NULL; - } - if ((buf = mms_cfg_alloc_getvar(MMS_CFG_DB_TIMEOUT, NULL)) == NULL) { - /* report service configuration repoistory scf_error() */ - mms_trace(MMS_ERR, "using default-path, ssi path cfg error"); - timeout = 3; - } else { - timeout = atoi(buf); - free(buf); - buf = NULL; - } - - mms_trace(MMS_DEVP, - "mm_db_resend: " - "connection to db lost fd - %d, " - "attempt to reconnect, max retry = %d, timeout = %d", - db->mm_db_fd, - max_retry, - timeout); - - while (mm_db_reconnect(db) == MM_DB_ERROR) { - - if (mm_is_exiting()) { - mms_trace(MMS_INFO, "MM Exiting"); - exit(SMF_EXIT_OK); - } - - num_retry ++; - if (num_retry > max_retry) { - mms_trace(MMS_ERR, - "mm_db_resend: " - "reconnect for db fd - %d failed " - "to many times %d, MM exiting", - db->mm_db_fd, - max_retry); - exit(SMF_EXIT_ERR_FATAL); - } - mms_trace(MMS_ERR, - "mm_db_resend: " - "error reconnecting to db fd - %d" - ", retry %d", - db->mm_db_fd, - num_retry); - sleep(timeout); - } - mms_trace(MMS_DEVP, - "mm_db_resend: " - "reconnect successful db fd -%d, " - "try to resend commands", - db->mm_db_fd); - db->mm_db_resending = 1; - if ((db->mm_db_txn_blk == 1) && - (db->mm_db_has_list)) { - mms_trace(MMS_ERR, - "mm_db_resend: " - "commands in list"); - /* have commands in list */ - for (node = mms_list_head(&db->mm_db_cmds); - node != NULL; - node = next) { - next = mms_list_next(&db->mm_db_cmds, node); - rc = mm_db_exec(HERE, db, node->text); - } - - } else { - mms_trace(MMS_ERR, - "mm_db_resend: " - "single command"); - /* don't have commands in list */ - /* resend sql_cmd */ - rc = mm_db_exec(HERE, db, sql_cmd); - } - mms_trace(MMS_DEVP, - "mm_db_resend: " - "reconnect successful db fd - %d, " - "commands sent", - db->mm_db_fd); - db->mm_db_resending = 0; - return (rc); - -} - -/* - * Execute sql command with sensitive information. - */ -mm_db_rval_t -mm_db_exec_si(char *file, int line, mm_db_t *db, char *fmt, ...) -{ - va_list args; - int rval; - - va_start(args, fmt); - rval = mm_db_do_exec(file, line, db, 0, fmt, args); - va_end(args); - - return (rval); -} - -/* - * Execute sql command. - */ -mm_db_rval_t -mm_db_exec(char *file, int line, mm_db_t *db, char *fmt, ...) -{ - va_list args; - int rval; - - va_start(args, fmt); - rval = mm_db_do_exec(file, line, db, 1, fmt, args); - va_end(args); - - return (rval); -} - -/* - * Add sql command terminator if needed. - */ -static char * -mm_db_get_sql_cmd(char *fmt, va_list args) -{ - int i; - char *sql_cmd; - - if ((sql_cmd = mms_vstrapp(NULL, fmt, args)) != NULL) { - /* add sql command terminator if needed */ - for (i = strlen(sql_cmd) - 1; i >= 0; i--) { - if (sql_cmd[i] == ';') { - break; - } - if (isspace(sql_cmd[i]) == 0) { - sql_cmd = mms_strapp(sql_cmd, ";"); - break; - } - } - } - return (sql_cmd); -} - -/* - * Execute synchronous sql command in auto-commit mode, no txn needed. - * Multiple commands can be wrapped in transaction block. - */ -static mm_db_rval_t -mm_db_do_exec(char *file, int line, mm_db_t *db, int flag, - char *fmt, va_list args) -{ - int rval; - char *count; - char *sql_cmd; - - if ((sql_cmd = mm_db_get_sql_cmd(fmt, args)) == NULL) { - mms_trace(MMS_ERR, "Exec %s:%d fd %d - unable to build command", - file, line, db->mm_db_fd); - return (MM_DB_ERROR); - } - /* add this cmd to this db's cmd list */ - if (db->mm_db_has_list && - db->mm_db_txn_blk && - (db->mm_db_resending == 0)) { - (void) mm_add_char(sql_cmd, &db->mm_db_cmds); - } - db->mm_db_results = PQexec(db->mm_db_conn, sql_cmd); - if (flag) { - mms_trace(MMS_DEVP, "Exec %s:%d fd %d - \n\n%s\n", file, line, - db->mm_db_fd, sql_cmd); - } else { - mms_trace(MMS_DEVP, "Exec %s:%d fd %d", file, line, - db->mm_db_fd); - } - db->mm_db_rval = PQresultStatus(db->mm_db_results); - db->mm_db_oid = PQoidValue(db->mm_db_results); - count = PQcmdTuples(db->mm_db_results); - db->mm_db_count = count ? atoi(count) : 0; - switch (db->mm_db_rval) { - case PGRES_COMMAND_OK: - rval = MM_DB_OK; - mms_trace(MMS_DEVP, "Exec %s:%d fd %d status - ok (%d %d)", - file, line, db->mm_db_fd, db->mm_db_oid, - db->mm_db_count); - mm_clear_db(&db->mm_db_results); - break; - case PGRES_TUPLES_OK: - rval = MM_DB_DATA; - mms_trace(MMS_DEVP, - "Exec %s:%d fd %d status - ok, data (%d %d)", - file, line, db->mm_db_fd, db->mm_db_oid, - db->mm_db_count); - break; - default: - rval = MM_DB_ERROR; - mms_trace(MMS_ERR, "Exec %s:%d fd %d status - %d, %s", - file, line, db->mm_db_fd, db->mm_db_rval, - PQerrorMessage(db->mm_db_conn)); - - if ((db->mm_db_rval == 7) && - ((strstr(PQerrorMessage(db->mm_db_conn), - "no connection to the server") != NULL) || - (strstr(PQerrorMessage(db->mm_db_conn), - "terminating connection due " - "to administrator command") != NULL) || - (strstr(PQerrorMessage(db->mm_db_conn), - "server closed the connection unexpectedly") != NULL))) { - /* DB has disconnected, attempt to reconnect */ - /* and resend the entire transaction block */ - /* associated with this db fd */ - mm_clear_db(&db->mm_db_results); - rval = mm_db_resend(db, sql_cmd); - free(sql_cmd); - return (rval); - - } - } - free(sql_cmd); - return (rval); -} - -/* Trace query execution notice and warning messages. */ -static void -/* LINTED: void *arg is required arg in PQsetNoticeReceiver */ -notice_receiver(void *arg, const PGresult *res) -{ - int rval; - - rval = PQresultStatus(res); - if (rval != 6) { - mms_trace(MMS_DEVP, "Notice Receiver - %d, %s", - rval, PQresultErrorMessage(res)); - } -} - - -/* Get database oids for mms string conversions. */ -static mm_db_rval_t -mm_db_oid_init(mm_db_t *db) -{ - char *value; - - if (mm_db_exec(HERE, db, "SELECT OID FROM pg_type " - "WHERE typname = 'bool';") != MM_DB_DATA) { - mms_trace(MMS_ERR, "boolean oid not found"); - return (MM_DB_ERROR); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, "missing boolean oid"); - mm_clear_db(&db->mm_db_results); - return (MM_DB_ERROR); - } - value = PQgetvalue(db->mm_db_results, 0, 0); - db->mm_db_cfg->mm_db_bool_oid = atoi(value); - mm_clear_db(&db->mm_db_results); - - if (mm_db_exec(HERE, db, "SELECT OID FROM pg_type " - "WHERE typname = 'timestamp';") != MM_DB_DATA) { - mms_trace(MMS_ERR, "timestamp oid not found"); - return (MM_DB_ERROR); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, "missing timestamp oid"); - mm_clear_db(&db->mm_db_results); - return (MM_DB_ERROR); - } - value = PQgetvalue(db->mm_db_results, 0, 0); - db->mm_db_cfg->mm_db_timestamp_oid = atoi(value); - mm_clear_db(&db->mm_db_results); - return (MM_DB_OK); -} - - -/* Connect to database. */ -mm_db_rval_t -mm_db_connect(mm_db_t *db) -{ - mms_trace(MMS_DEVP, "Connection"); - if (db_connect(db, db->mm_db_cfg->mm_db_name) != MM_DB_OK) { - mms_trace(MMS_DEVP, "Connection status - failed to connect"); - return (MM_DB_ERROR); - } - mms_trace(MMS_DEVP, "Connection status - ok"); - - return (MM_DB_OK); -} - -/* Reconnect to the database. */ -mm_db_rval_t -mm_db_reconnect(mm_db_t *db) -{ - mm_db_cfg_t *db_cfg = db->mm_db_cfg; - - /* Re-read password for db */ - db_cfg->mm_db_passwd = mms_net_cfg_read_pass_file(MMS_NET_CFG_DB_FILE); - - mm_db_disconnect(db); - if (mm_db_connect(db) != MM_DB_OK) { - mms_trace(MMS_DEVP, "reconnect init failed"); - return (MM_DB_ERROR); - } - if (mm_db_connected(db) == B_TRUE) { - return (MM_DB_OK); - } - mms_trace(MMS_DEVP, "reconnect failed"); - return (MM_DB_ERROR); -} - -/* Determine if database connection exists. */ -boolean_t -mm_db_connected(mm_db_t *db) -{ - if (db != NULL && - db->mm_db_conn != NULL && - PQstatus(db->mm_db_conn) == CONNECTION_OK) { - return (B_TRUE); - } - return (B_FALSE); -} - -/* Database transaction begin. */ -mm_db_rval_t -mm_db_txn_begin(mm_db_t *db) -{ - int rc; - - mms_trace(MMS_DEVP, "TXN begin"); - /* clear this db's cmd list */ - if (db->mm_db_has_list) - mm_free_list(&db->mm_db_cmds); - if ((rc = mm_db_exec(HERE, db, "BEGIN;")) == MM_DB_OK) { - db->mm_db_txn_blk = 1; - (void) mm_add_char("BEGIN;", - &db->mm_db_cmds); - } else { - db->mm_db_txn_blk = 0; - } - return (rc); -} - -/* Database transaction rollback. */ -mm_db_rval_t -mm_db_txn_rollback(mm_db_t *db) -{ - int rc; - mms_trace(MMS_DEVP, "TXN rollback"); - db->mm_db_txn_blk = 0; - rc = mm_db_exec(HERE, db, "ROLLBACK;"); - /* clear this db's cmd list */ - if (db->mm_db_has_list) - mm_free_list(&db->mm_db_cmds); - return (rc); -} - -/* Database transaction savepoint rollback. */ -mm_db_rval_t -mm_db_txn_savepoint_rollback(mm_db_t *db, char *savepoint) -{ - if (db->mm_db_txn_blk) { - mms_trace(MMS_DEVP, "TXN rollback to %s", savepoint); - return (mm_db_exec(HERE, db, "ROLLBACK TO %s;", savepoint)); - } - return (MM_DB_OK); -} - -/* Database transaction savepoint. */ -mm_db_rval_t -mm_db_txn_savepoint(mm_db_t *db, char *savepoint) -{ - if (db->mm_db_txn_blk) { - mms_trace(MMS_DEVP, "TXN savepoint %s", savepoint); - return (mm_db_exec(HERE, db, "SAVEPOINT %s;", savepoint)); - } - return (MM_DB_OK); -} - -/* Database transaction release savepoint. */ -mm_db_rval_t -mm_db_txn_release_savepoint(mm_db_t *db, char *savepoint) -{ - int rc; - - if (db->mm_db_txn_blk) { - mms_trace(MMS_DEVP, "TXN release savepoint %s", savepoint); - rc = mm_db_exec(HERE, db, "RELEASE SAVEPOINT %s;", savepoint); - return (rc); - } - return (MM_DB_OK); -} - -/* Database transaction commit. */ -mm_db_rval_t -mm_db_txn_commit(mm_db_t *db) -{ - int rc; - mms_trace(MMS_DEVP, "TXN commit"); - db->mm_db_txn_blk = 0; - rc = mm_db_exec(HERE, db, "COMMIT;"); - /* clear this db's cmd list */ - if (db->mm_db_has_list) - mm_free_list(&db->mm_db_cmds); - return (rc); -} - -/* Add attribute (column) to object (table). */ -mm_db_rval_t -mm_db_create_attribute(mm_db_t *db, char *objname, char *attribute) -{ - int col; - int cols; - int rows; - int found; - - mms_trace(MMS_DEBUG, "mm_db_create_attribute"); - - /* does this object allow user-defined attributes? */ - if (mm_db_exec(HERE, db, "SELECT * FROM \"SYSTEM_DEFINED\" " - "WHERE objname = '%s'", objname) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - return (MM_DB_ERROR); - } - rows = PQntuples(db->mm_db_results); - mm_clear_db(&db->mm_db_results); - if (rows == 0) { - /* user-defined attributes not allowed */ - return (MM_DB_OK); - } - /* does attribute already exist? */ - if (mm_db_exec(HERE, db, - "SELECT * FROM \"%s\"", objname) != MM_DB_DATA) { - return (MM_DB_ERROR); - } - found = 0; - cols = PQnfields(db->mm_db_results); - for (col = 0; !found && col < cols; col++) { - if (strcmp(PQfname(db->mm_db_results, col), attribute) == 0) { - found = 1; - } - } - mm_clear_db(&db->mm_db_results); - if (found) { - /* user-defined attributes already exists */ - return (MM_DB_OK); - } - /* add user-defined table column */ - if (mm_db_exec(HERE, db, "ALTER TABLE \"%s\" ADD \"%s\" text", - objname, attribute) != MM_DB_OK) { - return (MM_DB_ERROR); - } - /* user-defined table column added */ - return (MM_DB_OK); -} - -mm_db_rval_t -mm_db_create_attribute2(mm_db_t *db, char *objname, - char *attribute, char **send_buf) -{ - int col; - int cols; - int rows; - int found; - - /* does this object allow user-defined attributes? */ - if (mm_db_exec(HERE, db, "SELECT * FROM \"SYSTEM_DEFINED\" " - "WHERE objname = '%s'", objname) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - return (MM_DB_ERROR); - } - rows = PQntuples(db->mm_db_results); - mm_clear_db(&db->mm_db_results); - if (rows == 0) { - /* user-defined attributes not allowed */ - return (MM_DB_OK); - } - /* does attribute already exist? */ - if (mm_db_exec(HERE, db, - "SELECT * FROM \"%s\"", objname) != MM_DB_DATA) { - return (MM_DB_ERROR); - } - found = 0; - cols = PQnfields(db->mm_db_results); - for (col = 0; !found && col < cols; col++) { - if (strcmp(PQfname(db->mm_db_results, col), attribute) == 0) { - found = 1; - } - } - mm_clear_db(&db->mm_db_results); - if (found) { - /* user-defined attributes already exists */ - return (MM_DB_OK); - } - /* add user-defined table column */ - *send_buf = mms_strapp(*send_buf, "ALTER TABLE \"%s\" ADD \"%s\" text;", - objname, attribute); - - /* user-defined table column added */ - return (MM_DB_OK); -} - -/* Delete attribute (column) from object (table). */ -mm_db_rval_t -mm_db_delete_attribute(mm_db_t *db, char *objname, char *attribute) -{ - int row; - int rows; - int col; - int cols; - int found; - - - mms_trace(MMS_INFO, "mm_db_delete_attribute"); - - /* does object allow user-defined attributes? */ - if (mm_db_exec(HERE, db, "SELECT * FROM \"SYSTEM_DEFINED\" " - "WHERE objname = '%s'", objname) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - return (MM_DB_ERROR); - } - rows = PQntuples(db->mm_db_results); - mm_clear_db(&db->mm_db_results); - if (rows == 0) { - /* user-defined attributes not allowed */ - return (MM_DB_OK); - } - /* does object attribute exists? */ - if (mm_db_exec(HERE, db, - "SELECT * FROM \"%s\"", objname) != MM_DB_DATA) { - return (MM_DB_ERROR); - } - found = 0; - cols = PQnfields(db->mm_db_results); - for (col = 0; !found && col < cols; col++) { - if (strcmp(PQfname(db->mm_db_results, col), attribute) == 0) { - found = 1; - } - } - mm_clear_db(&db->mm_db_results); - if (!found) { - /* user-defined attribute not found */ - return (MM_DB_OK); - } - /* is attribute part of base data model? */ - if (mm_db_exec(HERE, db, "SELECT attribute FROM \"SYSTEM_DEFINED\" " - "WHERE attribute = '%s'", attribute) != MM_DB_DATA) { - return (MM_DB_ERROR); - } - found = 0; - rows = PQntuples(db->mm_db_results); - for (row = 0; !found && row < rows; row++) { - if (strcmp(PQgetvalue(db->mm_db_results, row, 0), - attribute) == 0) { - found = 1; - } - } - mm_clear_db(&db->mm_db_results); - if (found) { - /* attribute is part of base data model */ - return (MM_DB_OK); - } - /* remove user-defined object attribute */ - if (mm_db_exec(HERE, db, "ALTER TABLE \"%s\" DROP \"%s\"", - objname, attribute) != MM_DB_OK) { - return (MM_DB_ERROR); - } - /* user-defined object attribute removed */ - return (MM_DB_DROPPED); -} - -/* - * This is hard coded without database access because we are probably in a - * database transaction block that has failed and thus an additional database - * message catalog lookup would fail. - */ -char * -mm_db_sql_err_rsp(int mm_db_status, char *mm_db_error_message, - char *lang, char *taskid) -{ - char *dberrmsg; - char *response; - char args[100]; - char *p; - - - /* - * Replace ', ", ... with multi-character mms_escape sequences not - * processed by the parser. - */ - if ((dberrmsg = mms_strpar_escape_sequence(mm_db_error_message)) - == NULL) { - return (NULL); - } - /* - * Remove last new line from database error message(s). Leave new - * lines in-between multiline database error messages. - */ - if (p = strrchr(dberrmsg, '\n')) { - *p = '\0'; - } - /* - * Build command error response with loctext. - */ - snprintf(args, sizeof (args), "\"status\" \"%d\"", mm_db_status); - if (taskid && lang) { - response = mms_strnew(RESPONSE_ERROR_TEXT, taskid, - ECLASS_INTERNAL, - EDATABASE, MESS_MANUFACTURER, MESS_MODEL, 5001, - args, lang, dberrmsg); - } else { - response = mms_strnew(RESPONSE_UNACCEPTABLE); - } - free(dberrmsg); - - return (response); -} - -char * -mm_db_escape_string(char *from) -{ - char *to; - int len; - - len = strlen(from); - if ((to = (char *)malloc((len * 2) + 1)) == NULL) { - mms_trace(MMS_ERR, "mms_escape string out of memory"); - return (NULL); - } - PQescapeString(to, from, len); - if (strcmp(from, to) != 0) { - mms_trace(MMS_DEVP, - "mms_escape string\nfrom - %s\nto - %s", from, to); - } - return (to); -} - -mm_db_rval_t -mm_db_upgrade(mm_db_t *db, int dbcurver, int dbnewver) -{ - char linebuf[100]; - char *cmdbuf = NULL; - FILE *dbfp; - char *verpos; - char *sqlcmd = NULL; - char *dbpath = NULL; - char filebuf[4096]; - char cfgvar[2048]; - ptrdiff_t verlen; - char verbuf[10]; - int vernum; - int multicmd = 0; - int fileIn; - int fileOut; - int bytes; - int st = 0; - - if (db_version_check("/etc/mms/db/mms_db") != dbnewver) { - mms_trace(MMS_ERR, "Error, db file found in " - "/etc/mms/db/mms_db does not match new version %d", - dbnewver); - return (MM_DB_ERROR); - } - - if ((dbfp = fopen("/etc/mms/db/mms_db", "r")) == NULL) { - printf("Error, mms_db not found\n"); - return (-1); - } - - /* Begin transaction block */ - if (mm_db_exec(HERE, db, "BEGIN;") != MM_DB_OK) { - mms_trace(MMS_ERR, "Upgrade cmd" - " failed for BEGIN"); - return (MM_DB_ERROR); - } - - /* - * Read in a SQL command - * Check the database version - */ - while (fgets(linebuf, sizeof (linebuf), dbfp) != NULL) { - if (isdigit(linebuf[0])) { - verpos = strchr(linebuf, ' '); - verlen = verpos - linebuf; - strncpy(verbuf, linebuf, verlen); - vernum = atoi(verbuf); - if (vernum > dbcurver && linebuf[verlen - 1] == 'u') { - /* Start of a database command, read it in */ - if (strchr(linebuf, ';') != NULL) { - cmdbuf = mms_strapp(cmdbuf, "%s", - linebuf); - sqlcmd = strchr(cmdbuf, ' ') + 1; - /* Run SQL command on database */ - if (mm_db_exec(HERE, db, "%s", - sqlcmd) != MM_DB_OK) { - mms_trace(MMS_ERR, "Upgrade cmd" - " failed for %s", sqlcmd); - mm_clear_db(&db->mm_db_results); - (void) mm_db_exec(HERE, db, - "ROLLBACK;"); - return (MM_DB_ERROR); - } - free(cmdbuf); - cmdbuf = NULL; - sqlcmd = NULL; - } else { - cmdbuf = mms_strapp(cmdbuf, "%s", - linebuf); - multicmd = 1; - } - } - } else if (multicmd == 1) { - cmdbuf = mms_strapp(cmdbuf, "%s", - linebuf); - if (strchr(linebuf, ';') != NULL) { - multicmd = 0; - sqlcmd = strchr(cmdbuf, ' ') + 1; - /* Run SQL command on database */ - if (mm_db_exec(HERE, db, "%s", sqlcmd) - != MM_DB_OK) { - mms_trace(MMS_ERR, "Upgrade cmd" - " failed for %s", sqlcmd); - mm_clear_db(&db->mm_db_results); - (void) mm_db_exec(HERE, db, - "ROLLBACK;"); - return (MM_DB_ERROR); - } - free(cmdbuf); - cmdbuf = NULL; - sqlcmd = NULL; - } - } - } - - /* - * End transaction block - * Commit changes to db, db does rollback on error - */ - if (mm_db_exec(HERE, db, "COMMIT;") != MM_DB_OK) { - mms_trace(MMS_ERR, "Upgrade cmd" - " failed for COMMIT"); - return (MM_DB_ERROR); - } - - fclose(dbfp); - - /* Get path to mmsdb schema file */ - st = mms_cfg_getvar(MMS_CFG_DB_DATA, cfgvar); - if (st == 0) { - dbpath = mms_strapp(dbpath, "%s/../mmsdb", cfgvar); - } - - if (st != 0) { - mms_trace(MMS_ERR, "mms_cfg_getvar error," - "mmsdb not known"); - return (MM_DB_ERROR); - } - - /* Make a copy of the newer db schema */ - if ((fileIn = open("/etc/mms/db/mms_db", O_RDONLY)) == -1) { - mms_trace(MMS_ERR, "Failed to open db schema for read"); - } - - if ((fileOut = open(dbpath, O_WRONLY, O_CREAT)) == -1) { - mms_trace(MMS_ERR, "Failed to open db schema for write"); - } - - while ((bytes = read(fileIn, filebuf, sizeof (filebuf))) > 0) - write(fileOut, filebuf, bytes); - - close(fileIn); - close(fileOut); - - return (MM_DB_OK); -} - -mm_db_rval_t -mm_db_downgrade(mm_db_t *db, int dbcurver, int dbnewver) -{ - char linebuf[100]; - char *cmdbuf = NULL; - FILE *dbfp; - char *verpos; - int sqlcmdsize = 50; - char **sqlcmds = (char **)malloc(sqlcmdsize * - sizeof (char *)); - char **tmpbuf; - char *sqlptr; - char *dbpath = NULL; - char cfgvar[2048]; - int cmdcount = -1; - ptrdiff_t verlen; - char verbuf[10]; - int vernum; - int multicmd = 0; - int i; - int st = 0; - - /* Get path to mmsdb schema file */ - st = mms_cfg_getvar(MMS_CFG_DB_DATA, cfgvar); - if (st == 0) { - dbpath = mms_strapp(dbpath, "%s/../mmsdb", cfgvar); - } - - if (st != 0) { - mms_trace(MMS_ERR, "mms_cfg_getvar error," - "mmsdb not known"); - free(sqlcmds); - free(dbpath); - return (MM_DB_ERROR); - } - - if (db_version_check(dbpath) != dbcurver) { - mms_trace(MMS_ERR, "Error, db file found in %s" - "does not match current version %d", - dbpath, dbcurver); - free(dbpath); - free(sqlcmds); - return (MM_DB_ERROR); - } - - if ((dbfp = fopen(dbpath, "r")) == NULL) { - mms_trace(MMS_ERR, "Error, mmsdb not found for downgrade\n"); - free(dbpath); - free(sqlcmds); - return (MM_DB_ERROR); - } - - /* Begin transaction block */ - if (mm_db_exec(HERE, db, "BEGIN;") != MM_DB_OK) { - mms_trace(MMS_ERR, "Downgrade cmd" - " failed for BEGIN"); - free(dbpath); - free(sqlcmds); - return (MM_DB_ERROR); - } - - /* - * Read in a SQL command - * Check the database version - */ - while (fgets(linebuf, sizeof (linebuf), dbfp) != NULL) { - if (isdigit(linebuf[0])) { - verpos = strchr(linebuf, ' '); - verlen = verpos - linebuf; - strncpy(verbuf, linebuf, verlen); - vernum = atoi(verbuf); - if (vernum > dbnewver && linebuf[verlen - 1] == 'd') { - /* Check SQL cmd buffer size */ - if (cmdcount+1 > sqlcmdsize) { - sqlcmdsize = sqlcmdsize * 2; - tmpbuf = (char **) - realloc(sqlcmds, sqlcmdsize); - if (tmpbuf != NULL) - sqlcmds = tmpbuf; - else { - mms_trace(MMS_ERR, - "realloc failed in " - "mm_db_downgrade"); - free(dbpath); - for (i = 0; i < cmdcount - 1; - i++) - free(sqlcmds[i]); - free(sqlcmds); - return (MM_DB_ERROR); - } - } - - /* Start of a database command, read it in */ - if (strchr(linebuf, ';') != NULL) { - cmdbuf = mms_strapp(cmdbuf, "%s", - linebuf); - sqlptr = strchr(cmdbuf, ' ') + 1; - cmdcount++; - sqlcmds[cmdcount] = strdup(sqlptr); - free(cmdbuf); - cmdbuf = NULL; - sqlptr = NULL; - } else { - cmdbuf = mms_strapp(cmdbuf, "%s", - linebuf); - multicmd = 1; - } - } - } else if (multicmd == 1) { - cmdbuf = mms_strapp(cmdbuf, "%s", - linebuf); - if (strchr(linebuf, ';') != NULL) { - multicmd = 0; - sqlptr = strchr(cmdbuf, ' ') + 1; - cmdcount++; - sqlcmds[cmdcount] = strdup(sqlptr); - free(cmdbuf); - cmdbuf = NULL; - sqlptr = NULL; - } - } - } - for (i = cmdcount; i > -1; i--) { - /* Run SQL command on database */ - if (mm_db_exec(HERE, db, "%s", sqlcmds[i]) != MM_DB_OK) { - mms_trace(MMS_ERR, "Downgrade cmd" - " failed for %s", sqlcmds[i]); - mm_clear_db(&db->mm_db_results); - free(dbpath); - (void) mm_db_exec(HERE, db, "ROLLBACK;"); - return (MM_DB_ERROR); - } - free(sqlcmds[i]); - } - - free(sqlcmds); - - /* - * End transaction block - * Commit changes to db, db does rollback on error - */ - if (mm_db_exec(HERE, db, "COMMIT;") != MM_DB_OK) { - mms_trace(MMS_ERR, "Downgrade cmd" - " failed for COMMIT"); - free(dbpath); - return (MM_DB_ERROR); - } - - fclose(dbfp); - - free(dbpath); - return (MM_DB_OK); -} - -int -db_version_check(char *dbfile) -{ - char linebuf[100]; - char verbuf[10]; - char *verpos; - ptrdiff_t verlen; - FILE *dbfp; - int vernum; - int version = 0; - - if ((dbfp = fopen(dbfile, "r")) == NULL) { - mms_trace(MMS_ERR, "db_version_check " - "database file not found\n"); - return (-1); - } - - while (fgets(linebuf, sizeof (linebuf), dbfp) != NULL) { - if (isdigit(linebuf[0])) { - verpos = strchr(linebuf, ' '); - verlen = verpos - linebuf - 1; - strncpy(verbuf, linebuf, verlen); - vernum = atoi(verbuf); - if (vernum > version) - version = vernum; - memset(verbuf, '\0', sizeof (verbuf)); - } - } - - fclose(dbfp); - - return (version); -} diff --git a/usr/src/cmd/mms/mm/common/mm_db.h b/usr/src/cmd/mms/mm/common/mm_db.h deleted file mode 100644 index eddc25be1f..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_db.h +++ /dev/null @@ -1,90 +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 _MM_DB_H -#define _MM_DB_H - -#include <limits.h> -#include <sys/types.h> -#include <libpq-fe.h> - -typedef struct mm_db_cfg mm_db_cfg_t; /* database configuration */ -struct mm_db_cfg { - char *mm_db_host; - int mm_db_port; - char *mm_db_user; - char *mm_db_name; - char *mm_db_passwd; - int mm_db_bool_oid; - int mm_db_timestamp_oid; -}; - -typedef struct mm_db mm_db_t; /* database */ -struct mm_db { - PGconn *mm_db_conn; /* connection */ - PGresult *mm_db_results; /* query results */ - int mm_db_rval; /* database return value */ - int mm_db_oid; /* row oid, invalid if more than 1 */ - int mm_db_count; /* number of rows changed */ - int mm_db_txn_blk; /* transaction block flag */ - mm_db_cfg_t *mm_db_cfg; /* database config */ - int mm_db_fd; /* database socket file descriptor */ - mms_list_t mm_db_cmds; /* linked list of all text sql */ - /* commands for this db's txn block */ - int mm_db_has_list; - int mm_db_resending; -}; - -typedef enum mm_db_rval mm_db_rval_t; /* database function return codes */ -enum mm_db_rval { - MM_DB_OK = 0, /* operation successful */ - MM_DB_DATA, /* data (tuples) rows */ - MM_DB_ERROR, /* operation failed */ - MM_DB_DROPPED /* database item dropped */ -}; - -extern mm_db_rval_t mm_db_init(mm_db_t *); -extern mm_db_rval_t mm_db_connect(mm_db_t *); -extern mm_db_rval_t mm_db_reconnect(mm_db_t *); -extern boolean_t mm_db_connected(mm_db_t *); -extern void mm_db_disconnect(mm_db_t *); -extern mm_db_rval_t mm_db_exec_si(char *file, int line, mm_db_t *, char *, ...); -extern mm_db_rval_t mm_db_exec(char *file, int line, mm_db_t *, char *, ...); -extern mm_db_rval_t mm_db_txn_begin(mm_db_t *); -extern mm_db_rval_t mm_db_txn_rollback(mm_db_t *); -extern mm_db_rval_t mm_db_txn_savepoint_rollback(mm_db_t *, char *); -extern mm_db_rval_t mm_db_txn_savepoint(mm_db_t *, char *); -extern mm_db_rval_t mm_db_txn_release_savepoint(mm_db_t *, char *); -extern mm_db_rval_t mm_db_txn_commit(mm_db_t *); -extern mm_db_rval_t mm_db_create_attribute(mm_db_t *, char *, char *); -extern mm_db_rval_t mm_db_create_attribute2(mm_db_t *, char *, char *, char **); -extern mm_db_rval_t mm_db_delete_attribute(mm_db_t *, char *, char *); -extern mm_db_rval_t mm_db_upgrade(mm_db_t *db, int dbcurver, int dbnewver); -extern mm_db_rval_t mm_db_downgrade(mm_db_t *db, int dbcurver, int dbnewver); -extern int db_version_check(char *dbfile); -extern char *mm_db_sql_err_rsp(int, char *, char *, char *); -extern char *mm_db_escape_string(char *from); - -#endif /* _MM_DB_H */ diff --git a/usr/src/cmd/mms/mm/common/mm_dmp_sql.c b/usr/src/cmd/mms/mm/common/mm_dmp_sql.c deleted file mode 100644 index f83e4aa52d..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_dmp_sql.c +++ /dev/null @@ -1,2727 +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 <stdlib.h> -#include <string.h> -#include <errno.h> -#include <pthread.h> -#include <syslog.h> -#include <mms_list.h> -#include <mms_parser.h> -#include <mms_par_impl.h> -#include <libpq-fe.h> -#include <mms_trace.h> -#include <mms_strapp.h> -#include "mm_db.h" -#include "mm.h" - -#include "mm_util.h" -#include "mm_commands.h" -#include "mm_sql.h" -#include "mm_sql_impl.h" - -static char *_SrcFile = __FILE__; - -#define INS_DMCAPABILITYGROUP "INSERT INTO \"DMCAPABILITYGROUP\" "\ - "(\"DriveName\", \"DMName\", "\ - "\"DMCapabilityGroupName\", \"DMCapabilityGroupDefaultName\", "\ - "\"DMCapabilityGroupType\") "\ - "VALUES ('%s', '%s', '%s', '%s' , '%s');" - - -#define INS_DMCAPABILITYGROUPTOKEN "INSERT INTO \"DMCAPABILITYGROUPTOKEN\" "\ - "(\"DriveName\", \"DMName\", "\ - "\"DMCapabilityGroupName\", \"DMCapabilityToken\") "\ - "VALUES ('%s', '%s', '%s', '%s'); " - -#define INS_DMCAPABILITY "INSERT INTO \"DMCAPABILITY\" (\"DriveName\", "\ - "\"DMName\", "\ - "\"DMCapabilityName\") "\ - "VALUES ('%s', '%s', '%s'); " - -#define INS_DMCAPABILITYTOKEN "INSERT INTO \"DMCAPABILITYTOKEN\" "\ - "(\"DriveName\", "\ - "\"DMName\", \"DMCapabilityName\", \"DMCapabilityToken\") "\ - "VALUES ('%s', '%s', '%s', '%s'); " - -#define INS_DMBITFORMAT "INSERT INTO \"DMBITFORMAT\" "\ - "(\"DriveName\", \"DMName\", \"DMBitFormatName\", "\ - "\"DMBitFormatDefaultToken\") "\ - "VALUES('%s', '%s', '%s', '%s');" - -#define INS_DMBITFORMATTOKEN "INSERT INTO \"DMBITFORMATTOKEN\" "\ - "(\"DriveName\", "\ - "\"DMName\", \"DMBitFormatName\", "\ - "\"DMCapabilityToken\") "\ - "VALUES('%s', '%s', '%s', '%s');" - -#define INS_BITFORMATDEFAULTTOKEN "UPDATE \"DMBITFORMAT\" SET "\ - "\"DMBitFormatDefaultToken\" = '%s' WHERE "\ - "( \"DriveName\" = '%s' AND \"DMName\" = '%s' AND "\ - "\"DMBitFormatName\" = '%s');" - -#define INS_ATTR "UPDATE \"DMCAPABILITY\" SET \"%s\" = '%s' WHERE "\ - "( \"DriveName\" = '%s' AND \"DMName\" = '%s' AND "\ - "\"DMCapabilityName\" = '%s');" - -#define DEL_DMCAPABILITYGROUPTOKEN "DELETE FROM \"DMCAPABILITYGROUPTOKEN\" "\ - "WHERE ((\"DMCAPABILITYGROUPTOKEN\".\"DriveName\" = '%s') AND "\ - "(\"DMCAPABILITYGROUPTOKEN\".\"DMName\" = '%s'));" - -#define DEL_DMCAPABILITYGROUP "DELETE FROM \"DMCAPABILITYGROUP\" "\ - "WHERE ((\"DMCAPABILITYGROUP\".\"DriveName\" = '%s') AND "\ - "(\"DMCAPABILITYGROUP\".\"DMName\" = '%s'));" - -#define DEL_DMCAPABILITYTOKEN "DELETE FROM \"DMCAPABILITYTOKEN\" "\ - "WHERE ((\"DMCAPABILITYTOKEN\".\"DriveName\" = '%s') "\ - "AND (\"DMCAPABILITYTOKEN\".\"DMName\" = '%s'));" - -#define DEL_DMCAPABILITY "DELETE FROM \"DMCAPABILITY\" WHERE "\ - "((\"DMCAPABILITY\".\"DriveName\" = '%s') AND "\ - "(\"DMCAPABILITY\".\"DMName\" = '%s'));" - -#define DEL_DMBITFORMATTOKEN "DELETE FROM \"DMBITFORMATTOKEN\" WHERE "\ - "((\"DMBITFORMATTOKEN\".\"DriveName\" = '%s') AND "\ - "(\"DMBITFORMATTOKEN\".\"DMName\" = '%s'));" - -#define DEL_DMBITFORMAT "DELETE FROM \"DMBITFORMAT\" WHERE "\ - "((\"DMBITFORMAT\".\"DriveName\" = '%s') AND "\ - "(\"DMBITFORMAT\".\"DMName\" = '%s'));" - - -int -mm_dmp_clear_at_enable(mm_wka_t *mm_wka) { - /* Check if DM has a STALEHANDLE */ - /* Clear drive if the session for */ - /* stale handle is no longer connected */ - mm_db_t *db = &mm_wka->mm_data->mm_db; - cci_t *conn = &mm_wka->wka_conn; - char *DriveName = conn->cci_client; - char *DMName = conn->cci_instance; - - PGresult *cartid; - char *CartridgeID = NULL; - - PGresult *session; - char *AppName = NULL; - char *AIName = NULL; - - if (mm_db_exec(HERE, db, - "select \"CartridgeID\" from \"STALEHANDLE\" " - "where \"DMName\" = '%s' and" - "\"DriveName\" = '%s';", - DMName, DriveName) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error in mm_dmp_has_stalehandle"); - mm_clear_db(&db->mm_db_results); - return (0); - } - cartid = db->mm_db_results; - if (PQntuples(cartid) != 0) { - CartridgeID = PQgetvalue(cartid, 0, 0); - /* DM has a stale handle */ - mms_trace(MMS_DEBUG, - "%s %s, has STALEHANDLE for cart %s", - DMName, DriveName, CartridgeID); - /* Check if mounting session is still connected */ - if (mm_db_exec(HERE, db, - "select \"SESSION\".\"ApplicationName\"," - "\"SESSION\".\"AIName\" " - " from \"SESSION\",\"MOUNTPHYSICAL\" " - "where \"SESSION\".\"SessionID\" = " - "\"MOUNTPHYSICAL\".\"SessionID\" and " - "\"MOUNTPHYSICAL\".\"CartridgeID\" = '%s';", - CartridgeID) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error in mm_dmp_has_stalehandle"); - mm_clear_db(&db->mm_db_results); - mm_clear_db(&cartid); - return (0); - } - session = db->mm_db_results; - if (PQntuples(session) != 0) { - AppName = PQgetvalue(session, 0, 0); - AIName = PQgetvalue(session, 0, 1); - mms_trace(MMS_DEBUG, - "%s %s session still active, " - "skip clear and reserve DM, %s %s %s", - AppName, AIName, - DMName, DriveName, CartridgeID); - - /* Add activate command */ - if (mm_dmp_add_cmd(mm_wka, NULL, DMName, - MM_DMP_RESERVE) == NULL) { - mms_trace(MMS_ERR, - "mm_dmp_clear_at_enable: " - "error adding dmp reserve"); - } - - mm_clear_db(&session); - mm_clear_db(&cartid); - return (0); - } - mms_trace(MMS_DEBUG, - "no active client session " - "found, clear drive, %s %s", - DMName, DriveName); - mm_clear_db(&session); - mm_clear_db(&cartid); - return (1); - } - mms_trace(MMS_DEBUG, - "no STALEHANDLE found, %s %s", - DMName, DriveName); - mm_clear_db(&cartid); - return (0); - - -} - -int -inc_current(int current[100], int num_cap_groups, int num_group_tokens[100]) { - int least_sig = num_cap_groups; - current[least_sig-1] ++; - if (current[least_sig-1] < num_group_tokens[least_sig-1]) { - /* Ok */ - return (0); - } - if (least_sig == 1) { - current[least_sig-1] --; - return (1); - } - current[least_sig-1] = 0; - least_sig --; - return (inc_current(current, least_sig, num_group_tokens)); -} - - -int -mm_drive_dm_activate_disable(mm_wka_t *mm_wka) { - int rc; - uuid_text_t task; - mm_db_t *db = &mm_wka->mm_data->mm_db; - mm_command_t *cmd; - - char *dmname = mm_wka->wka_conn.cci_instance; - char *drivename = mm_wka->wka_conn.cci_client; - /* - * Determine if activate disable can be sent - * return 1 for fail, 0 for success - */ - rc = mm_db_exec(HERE, db, - "select \"DM\".\"DMStateHard\"," - "\"DM\".\"DMStateSoft\"," - "\"DRIVE\".\"DriveBroken\"," - "\"DRIVE\".\"DriveStateSoft\"," - "\"DRIVE\".\"DriveDisabled\", " - "\"DRIVE\".\"DriveOnline\" " - "from \"DM\",\"DRIVE\" where " - "\"DM\".\"DriveName\" = " - "\"DRIVE\".\"DriveName\" and " - "\"DM\".\"DMName\" = '%s';", - dmname); - if ((rc != MM_DB_DATA) || - (PQntuples(db->mm_db_results) != 1)) { - mms_trace(MMS_ERR, - "db error getting DM/DRIVE info, " - "skip DM disable"); - return (1); - } - - - mms_trace(MMS_DEVP, - "DM/DRIVE info:"); - mms_trace(MMS_DEVP, - " DMStateHard = %s", - PQgetvalue(db->mm_db_results, 0, 0)); - mms_trace(MMS_DEVP, - " DMStateSoft = %s", - PQgetvalue(db->mm_db_results, 0, 1)); - mms_trace(MMS_DEVP, - " DriveBroken = %s", - PQgetvalue(db->mm_db_results, 0, 2)); - mms_trace(MMS_DEVP, - " DriveStateSoft = %s", - PQgetvalue(db->mm_db_results, 0, 3)); - mms_trace(MMS_DEVP, - " DriveDisabled = %s", - PQgetvalue(db->mm_db_results, 0, 4)); - mms_trace(MMS_DEVP, - " DriveOnline = %s", - PQgetvalue(db->mm_db_results, 0, 5)); - - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), - "ready") != 0) { - mms_trace(MMS_DEVP, - "DMStateHard != ready, skip disable"); - mm_clear_db(&db->mm_db_results); - return (1); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 1), - "ready") != 0) { - mms_trace(MMS_DEVP, - "DMStateSoft != ready, skip disable"); - mm_clear_db(&db->mm_db_results); - return (1); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 2), - "f") != 0) { - mms_trace(MMS_DEVP, - "DriveBroken != f, skip disable"); - mm_clear_db(&db->mm_db_results); - return (1); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 3), - "ready") != 0) { - mms_trace(MMS_DEVP, - "DriveStateSoft != f, skip disable"); - mm_clear_db(&db->mm_db_results); - return (1); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 4), - "false") != 0) { - mms_trace(MMS_DEVP, - "DriveDisabled != false, skip disable"); - mm_clear_db(&db->mm_db_results); - return (1); - } - - if (strcmp(PQgetvalue(db->mm_db_results, 0, 5), - "f") != 0) { - mms_trace(MMS_DEVP, - "DriveOnline != f, skip disable"); - mm_clear_db(&db->mm_db_results); - return (1); - } - mm_clear_db(&db->mm_db_results); - - mms_trace(MMS_DEBUG, "Add an activate disable for %s %s", - dmname, drivename); - - - /* Allocate and add an activate command to the queue */ - /* - * Build an activate disable command - */ - if ((cmd = mm_alloc_cmd(mm_wka)) == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_command_t: %s", - strerror(errno)); - return (1); - } - mm_get_uuid(task); - cmd->cmd_textcmd = mms_strnew(ACTIVATE_DISABLE, task); - cmd->cmd_root = mm_text_to_par_node(cmd->cmd_textcmd, mms_dmpm_parse); - cmd->cmd_task = mm_get_task(cmd->cmd_root); - cmd->cmd_func = mm_dmp_activate_cmd_func; - cmd->cmd_name = strdup("dmp activate disable"); - - if (cmd->cmd_textcmd == NULL || cmd->cmd_root == NULL) { - MM_ABORT_NO_MEM(); - return (1); - } - - pthread_mutex_lock(&mm_wka->mm_data->mm_queue_mutex); - mms_list_insert_tail(&mm_wka->mm_data->mm_cmd_queue, cmd); - pthread_mutex_unlock(&mm_wka->mm_data->mm_queue_mutex); - - /* - * Activate dm is inprogress. - */ - return (0); -} - -mm_command_t * -mm_alloc_dm_enable(mm_wka_t *mm_wka) { - uuid_text_t task; - mm_command_t *cmd; - - /* Allocate and add an activate command to the queue */ - /* - * Build an activate enable command - */ - if ((cmd = mm_alloc_cmd(mm_wka)) == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_command_t: %s", - strerror(errno)); - return (NULL); - } - mm_get_uuid(task); - cmd->cmd_textcmd = mms_strnew(ACTIVATE_ENABLE, task); - cmd->cmd_root = mm_text_to_par_node(cmd->cmd_textcmd, mms_dmpm_parse); - cmd->cmd_task = mm_get_task(cmd->cmd_root); - cmd->cmd_func = mm_dmp_activate_cmd_func; - cmd->cmd_name = strdup("dmp activate enable"); - - if (cmd->cmd_textcmd == NULL || cmd->cmd_root == NULL) { - MM_ABORT_NO_MEM(); - return (NULL); - } - - pthread_mutex_lock(&mm_wka->mm_data->mm_queue_mutex); - mms_list_insert_tail(&mm_wka->mm_data->mm_cmd_queue, cmd); - pthread_mutex_unlock(&mm_wka->mm_data->mm_queue_mutex); - - /* - * Activate dm is inprogress. - */ - return (cmd); -} - -mm_command_t * -mm_drive_dm_activate_enable(mm_wka_t *mm_wka) { - int rc; - mm_db_t *db = &mm_wka->mm_data->mm_db; - mm_command_t *cmd; - - char *dmname = mm_wka->wka_conn.cci_instance; - char *drivename = mm_wka->wka_conn.cci_client; - - - /* - * Determine if activate enable can be sent - * return NULL for fail, pointer to the enable command for success - */ - rc = mm_db_exec(HERE, db, - "select \"DM\".\"DMStateHard\"," - "\"DM\".\"DMStateSoft\"," - "\"DRIVE\".\"DriveBroken\"," - "\"DRIVE\".\"DriveStateSoft\"," - "\"DRIVE\".\"DriveDisabled\", " - "\"DRIVE\".\"DriveOnline\" " - "from \"DM\",\"DRIVE\" where " - "\"DM\".\"DriveName\" = " - "\"DRIVE\".\"DriveName\" and " - "\"DM\".\"DMName\" = '%s';", - dmname); - if ((rc != MM_DB_DATA) || - (PQntuples(db->mm_db_results) != 1)) { - mms_trace(MMS_ERR, - "db error getting DM/DRIVE info, " - "skip DM enable"); - return (NULL); - } - - - mms_trace(MMS_DEVP, - "DM/DRIVE info:"); - mms_trace(MMS_DEVP, - " DMStateHard = %s", - PQgetvalue(db->mm_db_results, 0, 0)); - mms_trace(MMS_DEVP, - " DMStateSoft = %s", - PQgetvalue(db->mm_db_results, 0, 1)); - mms_trace(MMS_DEVP, - " DriveBroken = %s", - PQgetvalue(db->mm_db_results, 0, 2)); - mms_trace(MMS_DEVP, - " DriveStateSoft = %s", - PQgetvalue(db->mm_db_results, 0, 3)); - mms_trace(MMS_DEVP, - " DriveDisabled = %s", - PQgetvalue(db->mm_db_results, 0, 4)); - mms_trace(MMS_DEVP, - " DriveOnline = %s", - PQgetvalue(db->mm_db_results, 0, 5)); - - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), - "ready") != 0) { - mms_trace(MMS_DEVP, - "DMStateHard != ready, skip enable"); - mm_clear_db(&db->mm_db_results); - return (NULL); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 1), - "present") != 0) { - mms_trace(MMS_DEVP, - "DMStateSoft != present, skip enable"); - mm_clear_db(&db->mm_db_results); - return (NULL); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 2), - "f") != 0) { - mms_trace(MMS_DEVP, - "DriveBroken != f, skip enable"); - mm_clear_db(&db->mm_db_results); - return (NULL); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 3), - "unavailable") == 0) { - mms_trace(MMS_DEVP, - "DriveStateSoft == unavailable, " - "wait on DM activate"); - mm_clear_db(&db->mm_db_results); - return (NULL); - } - - if (strcmp(PQgetvalue(db->mm_db_results, 0, 3), - "ready") != 0) { - mms_trace(MMS_DEVP, - "DriveStateSoft != ready"); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 4), - "false") != 0) { - mms_trace(MMS_DEVP, - "DriveDisabled != false, skip enable"); - mm_clear_db(&db->mm_db_results); - return (NULL); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 5), - "t") != 0) { - mms_trace(MMS_DEVP, - "DriveOnline != t, skip enable"); - mm_clear_db(&db->mm_db_results); - return (NULL); - } - mm_clear_db(&db->mm_db_results); - mms_trace(MMS_DEBUG, "Add an activate enable for %s %s", - dmname, drivename); - - cmd = mm_alloc_dm_enable(mm_wka); - if (cmd == NULL) { - mms_trace(MMS_ERR, - "unable to malloc dm enable cmd"); - return (NULL); - } - - /* - * Activate dm is inprogress. - */ - return (cmd); -} - -/* - * This function deletes the config for a DM - * who's wka is mm_wka - * db should be the calling thread's - * database pointer - */ - -void -delete_dm_config(mm_wka_t *mm_wka, mm_db_t *db) { - - - if (mm_db_exec(HERE, db, - "delete from "\ - "\"DMSHAPEPRIORITY\" " \ - "where \"DMName\" = '%s'", - mm_wka->wka_conn.cci_instance) - != MM_DB_OK) { - mms_trace(MMS_ERR, - "Error removing "\ - "DMSHAPEPRIORITY"); - } - if (mm_db_exec(HERE, db, - "delete from "\ - "\"DMDENSITYPRIORITY\" " \ - "where \"DMName\" = '%s'", - mm_wka->wka_conn.cci_instance) - != MM_DB_OK) { - mms_trace(MMS_ERR, - "Error removing "\ - "DMDENSITYPRIORITY"); - } - if (mm_db_exec(HERE, db, - "delete from "\ - "\"DMCAPABILITYGROUP\" " \ - "where \"DMName\" = '%s'", - mm_wka->wka_conn.cci_instance) - != MM_DB_OK) { - mms_trace(MMS_ERR, - "Error removing "\ - "DMCAPABILITYGROUP"); - } - if (mm_db_exec(HERE, db, - "delete from "\ - "\"DMCAPABILITY\" " \ - "where \"DMName\" = '%s'", - mm_wka->wka_conn.cci_instance) - != MM_DB_OK) { - mms_trace(MMS_ERR, - "Error removing DMCAPABILITY"); - } - if (mm_db_exec(HERE, db, - "delete from "\ - "\"DMBITFORMAT\" " \ - "where \"DMName\" = '%s'", - mm_wka->wka_conn.cci_instance) - != MM_DB_OK) { - mms_trace(MMS_ERR, - "Error removing DMBITFORMAT"); - } - if (mm_db_exec(HERE, db, - "delete from "\ - "\"DMBITFORMATTOKEN\" " \ - "where \"DMName\" = '%s'", - mm_wka->wka_conn.cci_instance) - != MM_DB_OK) { - mms_trace(MMS_ERR, - "Error removing "\ - "DMBITFORMATTOKEN"); - } -} - -int -mm_dmp_config_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *arg; - mms_par_node_t *value; - int scope_full; - mms_par_node_t *work = NULL; - mms_par_node_t *item = NULL; - int go; - int count; - mms_par_node_t *cap_list_work; - mms_par_node_t *group; - char *group_name; - char *group_type; - char *default_cap_token; - char *group_cap_token[512]; - mms_par_node_t *cap; - char *cap_name; - mms_par_node_t *cap_list; - char *cap_list_cap_token[512]; - mms_par_node_t *attr; - char *attr_name; - char *attr_value; - mms_par_node_t *bitformat; - char *bit_name; - char *default_bit_token; - char *bit_cap_token[512]; - - mms_par_node_t *shapepriority; - mms_par_node_t *densitypriority; - - mm_db_t *db = &mm_wka->mm_data->mm_db; - cci_t *conn = &mm_wka->wka_conn; - char *DriveName = conn->cci_client; - char *DMName = conn->cci_instance; - char *send_buf = NULL; - - int shape_count = 1; - int density_count = 1; - - int i; - - - /* - * buf = mms_strapp(buf, DMP_PRIVATE_BLOCKSIZE, - * mount_info->cmi_blocksize); - */ - - - mms_trace(MMS_DEVP, "dmp sql trans config cmd"); - - if (cmd->cmd_state == 100) { - /* Response for DM debug Config Command */ - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - /* - * Error In Debug Config - * return MMS_ERROR response and - * delete config from DataBase - */ - delete_dm_config(mm_wka, &mm_wka->mm_data->mm_db); - - mms_trace(MMS_ERR, "DEBUG CONFIG " \ - "ERROR"); - /* - * cmd->cmd_remove = 1; - * mm_sql_db_err_rsp_new(cmd, db); - * mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - */ - goto not_found; - } else { - /* Config is MMS_OK */ - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + - strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, - cmd->cmd_task); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - - mms_trace(MMS_INFO, "DM Connected and Configured"); - return (MM_DISPATCH_AGAIN); - } - - } - - /* Begin Parsing Config Command */ - MMS_PN_LOOKUP(arg, cmd->cmd_root, "scope", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, arg, NULL, MMS_PN_KEYWORD, NULL); - if (strcmp(value->pn_string, "full") == 0) { - scope_full = 1; - mms_trace(MMS_DEVP, "scope: full"); - } else if (strcmp(value->pn_string, "partial") == 0) { - scope_full = 0; - mms_trace(MMS_DEVP, "scope: partial"); - } else { - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - goto error; - } - - /* - * If scope is 'full' then remove all existing config entries - * in db for the current dm and drive - */ - - if (scope_full) { - - /* Remove DMBITFORMATTOKEN from db */ - if (mm_db_exec(HERE, db, DEL_DMBITFORMATTOKEN, DriveName, - DMName) != MM_DB_OK) { - mms_trace(MMS_ERR, "Error removing " - "DMBITFORMATTOKEN"); - cmd->cmd_remove = 1; - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - goto error; - } - /* Remove DMBITFORMAT from db */ - if (mm_db_exec(HERE, db, DEL_DMBITFORMAT, DriveName, - DMName) != MM_DB_OK) { - mms_trace(MMS_ERR, "Error removing " - "DMBITFORMAT"); - cmd->cmd_remove = 1; - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - goto error; - } - /* Revomve DMCAPABILITYGROUPTOKEN from db */ - if (mm_db_exec(HERE, db, DEL_DMCAPABILITYGROUPTOKEN, DriveName, - DMName) != MM_DB_OK) { - mms_trace(MMS_ERR, "Error removing "\ - "DMCAPABILITYGROUPTOKEN"); - cmd->cmd_remove = 1; - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - goto error; - } - /* Revomve DMCAPABILITYGROUP from db */ - if (mm_db_exec(HERE, db, DEL_DMCAPABILITYGROUP, DriveName, - DMName) != MM_DB_OK) { - mms_trace(MMS_ERR, "Error removing "\ - "DMCAPABILITYGROUP"); - cmd->cmd_remove = 1; - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - goto error; - } - /* Revomve DMCAPABILITYTOKEN from db */ - if (mm_db_exec(HERE, db, DEL_DMCAPABILITYTOKEN, DriveName, - DMName) != MM_DB_OK) { - mms_trace(MMS_ERR, "Error removing "\ - "DMCAPABILITYTOKEN"); - cmd->cmd_remove = 1; - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - goto error; - } - /* Revomve DMCAPABILITY from db */ - if (mm_db_exec(HERE, db, DEL_DMCAPABILITY, DriveName, - DMName) != MM_DB_OK) { - mms_trace(MMS_ERR, "Error removing "\ - "DMCAPABILITY"); - cmd->cmd_remove = 1; - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - goto error; - } - - } - - - /* Get Group Config */ - - /* mms_trace(MMS_DEVP, "group"); */ - work = NULL; - for (group = mms_pn_lookup(cmd->cmd_root, "group", - MMS_PN_CLAUSE, &work); - group != NULL; - group = mms_pn_lookup(cmd->cmd_root, "group", - MMS_PN_CLAUSE, &work)) { - int i; - item = NULL; - MMS_PN_LOOKUP(value, group, NULL, MMS_PN_STRING, &item); - group_name = value->pn_string; - - MMS_PN_LOOKUP(value, group, NULL, MMS_PN_STRING, &item); - group_type = value->pn_string; - - MMS_PN_LOOKUP(value, group, NULL, MMS_PN_STRING, &item); - default_cap_token = value->pn_string; - - /* Insert DMCAPABILITYGROUP into db */ - if (mm_db_exec(HERE, db, - INS_DMCAPABILITYGROUP, DriveName, - DMName, group_name, default_cap_token, - group_type) != MM_DB_OK) { - mms_trace(MMS_ERR, - "Error adding cap group " - "%s %s %s %s %s", - DriveName, - DMName, group_name, - default_cap_token, - group_type); - cmd->cmd_remove = 1; - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - goto error; - } - - - /* Get the Other Group Cap Tokens */ - - count = 0; - go = 1; - while (go) { - if ((value = mms_pn_lookup(group, NULL, - MMS_PN_STRING, - &item)) == NULL) { - go = 0; - } else { - group_cap_token[count] = - value->pn_string; - count ++; - } - } - - /* Insert DMCAPABILITYGROUPTOKEN into db */ - /* Insert the default token */ - if (mm_db_exec(HERE, db, - INS_DMCAPABILITYGROUPTOKEN, - DriveName, - DMName, group_name, - default_cap_token) != MM_DB_OK) { - mms_trace(MMS_ERR, - "Error adding cap group token" - "%s %s %s %s", - DriveName, - DMName, group_name, - default_cap_token); - cmd->cmd_remove = 1; - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - goto error; - } - - - - /* Insert the other tokens */ - for (i = 0; i < count; i++) { - if (mm_db_exec(HERE, db, - INS_DMCAPABILITYGROUPTOKEN, - DriveName, - DMName, group_name, - group_cap_token[i]) != MM_DB_OK) { - mms_trace(MMS_ERR, - "Error adding cap group token" - "%s %s %s %s", - DriveName, - DMName, group_name, - group_cap_token[i]); - cmd->cmd_remove = 1; - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - goto error; - } - } - } - - /* Capabilities */ - - mms_trace(MMS_DEVP, "Parsing cap clauses"); - work = NULL; - for (cap = mms_pn_lookup(cmd->cmd_root, "cap", - MMS_PN_CLAUSE, &work); - cap != NULL; - cap = mms_pn_lookup(cmd->cmd_root, "cap", - MMS_PN_CLAUSE, &work)) { - item = NULL; - MMS_PN_LOOKUP(value, cap, NULL, MMS_PN_STRING, &item); - cap_name = value->pn_string; - - /* Insert DMCAPABILITY into db */ - if (mm_db_exec(HERE, db, - INS_DMCAPABILITY, DriveName, - DMName, cap_name) != MM_DB_OK) { - mms_trace(MMS_ERR, - "Error adding cap " - "%s %s %s", - DriveName, - DMName, cap_name); - cmd->cmd_remove = 1; - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - goto error; - } - - mms_trace(MMS_DEVP, " cap: %s", cap_name); - - /* Get the tokens in the CapList */ - - if ((cap_list = mms_pn_lookup(cap, "caplist", - MMS_PN_CLAUSE, - &item)) == NULL) { - mms_trace(MMS_ERR, "No caplist found"); - } - mms_trace(MMS_DEVP, " caplist"); - value = NULL; - count = 0; - go = 1; - cap_list_work = NULL; - while (go) { - if ((value = mms_pn_lookup(cap_list, NULL, - MMS_PN_STRING, - &cap_list_work)) == NULL) { - go = 0; - } else { - cap_list_cap_token[count] = - value->pn_string; - count ++; - } - } - /* Insert DMCAPABILITYTOKEN into db */ - for (i = 0; i < count; i++) { - if (mm_db_exec(HERE, db, - INS_DMCAPABILITYTOKEN, DriveName, - DMName, cap_name, - cap_list_cap_token[i]) != MM_DB_OK) { - mms_trace(MMS_ERR, - "Error adding cap " - "%s %s %s %s", - DriveName, - DMName, cap_name, - cap_list_cap_token[i]); - cmd->cmd_remove = 1; - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - goto error; - } - - } - - /* Get the attribute name/value pairs */ - - cap_list_work = NULL; - for (attr = mms_pn_lookup(cap, "attr", - MMS_PN_CLAUSE, &cap_list_work); - attr != NULL; - attr = mms_pn_lookup(cap, "attr", - MMS_PN_CLAUSE, &cap_list_work)) { - mms_trace(MMS_DEVP, " attr"); - item = NULL; - MMS_PN_LOOKUP(value, attr, NULL, - MMS_PN_STRING, &item); - attr_name = value->pn_string; - MMS_PN_LOOKUP(value, attr, NULL, - MMS_PN_STRING, &item); - attr_value = value->pn_string; - - if (mm_db_create_attribute2(db, "DMCAPABILITY", - attr_name, &send_buf) - != MM_DB_OK) { - mms_trace(MMS_ERR, - "Error creating new attribute"); - cmd->cmd_remove = 1; - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - goto error; - } - send_buf = mms_strapp(send_buf, INS_ATTR, attr_name, - attr_value, DriveName, DMName, cap_name); - - mms_trace(MMS_DEVP, "attr_name: %s , attr_value: %s", - attr_name, attr_value); - - } - - - } - - - if (send_buf != NULL) { - if (mm_db_exec(HERE, db, send_buf) != MM_DB_OK) { - mms_trace(MMS_ERR, "Error adding " \ - "config"); - cmd->cmd_remove = 1; - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - goto error; - } - free(send_buf); - send_buf = NULL; - } - - - mms_trace(MMS_DEVP, "bitformat"); - work = NULL; - for (bitformat = mms_pn_lookup(cmd->cmd_root, "bitformat", - MMS_PN_CLAUSE, &work); - bitformat != NULL; - bitformat = mms_pn_lookup(cmd->cmd_root, "bitformat", - MMS_PN_CLAUSE, &work)) { - item = NULL; - MMS_PN_LOOKUP(value, bitformat, NULL, - MMS_PN_STRING, &item); - bit_name = value->pn_string; - - MMS_PN_LOOKUP(value, bitformat, NULL, - MMS_PN_STRING, &item); - default_bit_token = value->pn_string; - - /* Insert DMBITFORMAT into db */ - - send_buf = mms_strapp(send_buf, INS_DMBITFORMAT, DriveName, - DMName, bit_name, default_bit_token); - - mms_trace(MMS_DEVP, "Bit name is %s, Default token is %s", - bit_name, default_bit_token); - /* Get the remaining tokens */ - count = 0; - go = 1; - while (go) { - if ((value = mms_pn_lookup(bitformat, NULL, - MMS_PN_STRING, - &item)) == NULL) { - go = 0; - } else { - bit_cap_token[count] = - value->pn_string; - count ++; - } - } - /* Insert DMBITFORMATTOKEN into db */ - - /* Insert the default token */ - - send_buf = mms_strapp(send_buf, INS_DMBITFORMATTOKEN, - DriveName, - DMName, bit_name, - default_bit_token); - - - /* Insert the rest */ - for (i = 0; i < count; i++) { - send_buf = mms_strapp(send_buf, INS_DMBITFORMATTOKEN, - DriveName, - DMName, bit_name, - bit_cap_token[i]); - mms_trace(MMS_DEVP, - "BitToken %d: %s", i, bit_cap_token[i]); - } - - } - - /* Add the send_buf */ - if (mm_db_exec(HERE, db, send_buf) != MM_DB_OK) { - mms_trace(MMS_ERR, "Error adding " \ - "config"); - cmd->cmd_remove = 1; - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - goto error; - } - - free(send_buf); - - - /* Cartridge Shape and Density Priority */ - /* Shape priority */ - - - mms_trace(MMS_DEVP, "shapepriority"); - work = NULL; - if ((shapepriority = mms_pn_lookup(cmd->cmd_root, - "shapepriority", - MMS_PN_CLAUSE, NULL)) == NULL) { - mms_trace(MMS_ERR, - "DM config is missing the shapepriority clause"); - } else { - item = NULL; - while ((item = mms_pn_lookup(shapepriority, NULL, - MMS_PN_STRING, &work)) != NULL) { - if (mm_db_exec(HERE, db, - "insert into \"DMSHAPEPRIORITY\" " - "(\"DMName\", \"DMShapePriority\", " - "\"DMShapeName\") " - "values('%s', '%d', '%s');", - DMName, shape_count, - item->pn_string) != MM_DB_OK) { - mms_trace(MMS_ERR, "Error adding " - "shapepriority"); - cmd->cmd_remove = 1; - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - goto error; - } - if (shape_count == 1) { - /* set DriveShapeName */ - if (mm_db_exec(HERE, db, - "update \"DRIVE\" " - "set \"DriveShapeName\" = '%s'" - " where \"DriveName\" = '%s'", - item->pn_string, - DriveName) != MM_DB_OK) { - mms_trace(MMS_ERR, "Error setting" - "DriveShapeName"); - cmd->cmd_remove = 1; - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - goto error; - } - } - shape_count ++; - } - } - /* Density priority */ - - mms_trace(MMS_DEVP, "densitypriority"); - work = NULL; - if ((densitypriority = mms_pn_lookup(cmd->cmd_root, - "densitypriority", - MMS_PN_CLAUSE, NULL)) == NULL) { - mms_trace(MMS_ERR, - "DM config is missing the densitypriority clause"); - } else { - item = NULL; - while ((item = mms_pn_lookup(densitypriority, NULL, - MMS_PN_STRING, &work)) != NULL) { - if (mm_db_exec(HERE, db, - "insert into \"DMDENSITYPRIORITY\" " - "(\"DMName\", \"DMDensityPriority\", " - "\"DMDensityName\") " - "values('%s', '%d', '%s');", - DMName, density_count, - item->pn_string) != MM_DB_OK) { - mms_trace(MMS_ERR, "Error adding " - "densitypriority"); - cmd->cmd_remove = 1; - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - goto error; - } - density_count ++; - } - } - - /* Done Parsing */ - - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - mms_trace(MMS_INFO, "DM Connected and Configured -> %s", - mm_wka->wka_conn.cci_instance); - return (MM_DISPATCH_AGAIN); - - -no_mem: - MM_ABORT_NO_MEM(); - goto error; - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - goto error; -error: - mm_sql_update_state(mm_wka->mm_data, "DM", - "DMStateSoft", - "not ready", "DMName", - DMName); - return (MM_CMD_ERROR); - -} -#define DMP_SEND_ATTACH "attach task [\"%s\"] " \ - "modename [\"%s\"];" - -int -mm_dmp_attach_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - cci_t *conn = &mm_wka->wka_conn; - char *DMName = conn->cci_instance; - mms_par_node_t *work = NULL; - mms_par_node_t *arg; - mms_par_node_t *value; - char *task = cmd->cmd_task; - char *buf = NULL; - int bufsize = 0; - mm_response_t response; - mm_command_t *parent = NULL; - cmd_mount_info_t *mount_info = NULL; - - - mms_trace(MMS_DEVP, "mm_dmp_attach_cmd_func"); - parent = mm_first_parent(cmd); - mount_info = &parent->cmd_mount_info; - if (cmd->cmd_state == 0) { - /* send the attach to DM */ - mms_trace(MMS_DEVP, "DM Name is %s, task id is %s", - DMName, task); - if (mount_info->cmi_capability == NULL) { - mms_trace(MMS_DEVP, "No capability found..."); - return (MM_CMD_ERROR); - } - - SQL_CHK_LEN(&buf, 0, &bufsize, - strlen(DMP_SEND_ATTACH) + - strlen(task) + - strlen(mount_info->cmi_capability) + 1); - (void) snprintf(buf, bufsize, - DMP_SEND_ATTACH, task, - mount_info->cmi_capability); - mms_trace(MMS_DEVP, "send buf is '%s' to fd %d ", buf, - mm_wka->mm_wka_conn->mms_fd); - - mm_send_text(mm_wka->mm_wka_conn, - buf); - cmd->cmd_state = 1; - MM_SET_FLAG(cmd->cmd_flags, MM_CMD_NEED_ACCEPT); - free(buf); - return (MM_ACCEPT_NEEDED); - - } else if (cmd->cmd_state == 1) { - /* revieved accept */ - mms_trace(MMS_DEVP, "ATTACH STATE 1"); - if (mm_parse_response(cmd->cmd_response, &response) != 0 || - response.response_type != MM_RESPONSE_ACCEPTED) { - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - mms_trace(MMS_DEVP, "PARSE RESPONSE DONE!!"); - cmd->cmd_flags &= ~MM_CMD_NEED_ACCEPT; - cmd->cmd_flags |= MM_CMD_ACCEPTED; - cmd->cmd_state = 2; - mms_trace(MMS_DEVP, "ATTACH STATE 1 DONE!!"); - return (MM_DISPATCH_DEPEND); - } else if (cmd->cmd_state == 2) { - /* recieved success */ - mms_trace(MMS_DEVP, "ATTACH STATE 2!"); - if (mm_parse_response(cmd->cmd_response, &response) != 0 || - response.response_type != MM_RESPONSE_SUCCESS) { - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - /* Get text */ - work = NULL; - arg = mms_pn_lookup(cmd->cmd_response, "text", - MMS_PN_CLAUSE, &work); - if (arg != NULL) { - MMS_PN_LOOKUP(value, arg, NULL, - MMS_PN_STRING, NULL); - if (value->pn_string != NULL) { - mms_trace(MMS_DEVP, "Response text is %s", - value->pn_string); - } else { - mms_trace(MMS_DEVP, "Response text was NULL"); - } - } else { - mms_trace(MMS_DEVP, "Response text clause missing"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - mount_info->cmi_handle = strdup(value->pn_string); - if (mount_info->cmi_handle == NULL) { - mms_trace(MMS_ERR, "Error malloc cmi_handle"); - return (MM_CMD_ERROR); - } - cmd->cmd_remove = 1; - return (MM_DEPEND_DONE); - - } else { - mms_trace(MMS_DEVP, "Bad command state"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -not_found: - mms_trace(MMS_ERR, "Not Found!!"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); -} - -#define DMP_SEND_IDENTIFY "identify task [\"%s\"] type [\"none\"];" - -int -mm_dmp_identify_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - cci_t *conn = &mm_wka->wka_conn; - char *DMName = conn->cci_instance; - mms_par_node_t *work = NULL; - mms_par_node_t *value; - mms_par_node_t *arg; - char *task = cmd->cmd_task; - char *buf = NULL; - int bufsize = 0; - mm_response_t response; - - mms_trace(MMS_DEVP, "mm_dmp_identify_cmd_func"); - if (cmd->cmd_state == 0) { - /* send the load to DM */ - mms_trace(MMS_DEVP, "DM Name is %s, task id is %s", - DMName, task); - - SQL_CHK_LEN(&buf, 0, &bufsize, - strlen(DMP_SEND_IDENTIFY) + - strlen(task) + 1); - (void) snprintf(buf, bufsize, - DMP_SEND_IDENTIFY, task); - mms_trace(MMS_DEVP, "send buf is '%s' to fd %d ", buf, - mm_wka->mm_wka_conn->mms_fd); - mm_send_text(mm_wka->mm_wka_conn, - buf); - cmd->cmd_state = 1; - MM_SET_FLAG(cmd->cmd_flags, MM_CMD_NEED_ACCEPT); - free(buf); - return (MM_ACCEPT_NEEDED); - - } else if (cmd->cmd_state == 1) { - /* revieved accept */ - mms_trace(MMS_DEVP, "IDENTIFY STATE 1"); - if (mm_parse_response(cmd->cmd_response, &response) != 0 || - response.response_type != MM_RESPONSE_ACCEPTED) { - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - mms_trace(MMS_DEVP, "PARSE RESPONSE DONE!!"); - cmd->cmd_flags &= ~MM_CMD_NEED_ACCEPT; - cmd->cmd_flags |= MM_CMD_ACCEPTED; - cmd->cmd_state = 2; - mms_trace(MMS_DEVP, "IDENTIFY STATE 1 DONE!!"); - return (MM_DISPATCH_DEPEND); - } else if (cmd->cmd_state == 2) { - /* recieved success */ - mms_trace(MMS_DEVP, "IDENTIFY STATE 2!"); - if (mm_parse_response(cmd->cmd_response, &response) != 0 || - response.response_type != MM_RESPONSE_SUCCESS) { - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - /* Get text */ - work = NULL; - arg = mms_pn_lookup(cmd->cmd_response, "text", - MMS_PN_CLAUSE, &work); - if (arg != NULL) { - MMS_PN_LOOKUP(value, arg, NULL, - MMS_PN_STRING, NULL); - if (value->pn_string != NULL) { - mms_trace(MMS_DEVP, "Response text is %s", - value->pn_string); - } else { - mms_trace(MMS_DEVP, "Response text was NULL"); - } - } else { - mms_trace(MMS_DEVP, "Response text clause missing"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - cmd->cmd_remove = 1; - return (MM_DEPEND_DONE); - } else { - mms_trace(MMS_DEVP, "Bad command state"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -not_found: - mms_trace(MMS_ERR, "Not Found!!"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); -} - - -#define DMP_SEND_ACT "activate task[\"%s\"] enable;" - -int -mm_dmp_activate_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - cci_t *conn = &mm_wka->wka_conn; - char *DriveName = conn->cci_client; - char *DMName = conn->cci_instance; - char *task = cmd->cmd_task; - mm_response_t response; - - - - mms_trace(MMS_DEVP, "dmp activate cmd"); - - if (cmd->cmd_state == 0) { - mms_trace(MMS_DEVP, "DM Name is %s, task id is %s", - DMName, task); - - /* set "DMStateSoft" to notready */ - mm_sql_update_state(mm_wka->mm_data, "DM", - "DMStateSoft", - "not ready", "DMName", - DMName); - - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_textcmd); - cmd->cmd_state = 1; - MM_SET_FLAG(cmd->cmd_flags, MM_CMD_NEED_ACCEPT); - return (MM_ACCEPT_NEEDED); - } - if (cmd->cmd_state == 1) { - mms_trace(MMS_DEVP, "ACTIVATE STATE 1"); - - if (mm_parse_response(cmd->cmd_response, &response) != 0 || - response.response_type != MM_RESPONSE_ACCEPTED) { - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - cmd->cmd_flags &= ~MM_CMD_NEED_ACCEPT; - cmd->cmd_flags |= MM_CMD_ACCEPTED; - cmd->cmd_state = 2; - mms_trace(MMS_DEVP, "End of activate state = 1"); - return (MM_NO_DISPATCH); - - - } - if (cmd->cmd_state == 2) { - mms_trace(MMS_DEVP, "ACTIVATE STATE 2!"); - if (mm_parse_response(cmd->cmd_response, &response) != 0 || - response.response_type != MM_RESPONSE_SUCCESS) { - if (mm_errorcode_eq(cmd->cmd_response, - "DM_E_ENABLED")) { - /* DM has aleady been enabled */ - mms_trace(MMS_DEBUG, - "%s %s already enabled", - DMName, DriveName); - mm_sql_update_state(mm_wka->mm_data, "DM", - "DMStateSoft", - "ready", "DMName", - DMName); - /* Add a DMUP event */ - mm_notify_add_dmup(mm_wka, cmd); - - /* Check if this DM has any handles */ - mms_trace(MMS_DEVP, - "check if %s has any STALEHANDLE", - DMName); - - if (mm_dmp_clear_at_enable(mm_wka)) { - /* DM has a stale handle */ - /* The client session is */ - /* not connected */ - /* Need to clear the drive */ - mms_trace(MMS_DEBUG, - "Adding clear drive for %s %s", - DMName, DriveName); - if (mm_add_clear_drive(DriveName, - mm_wka->mm_data, - db, - NULL, - NULL, 1, 0) == NULL) { - mms_trace(MMS_ERR, - "mm_dmp_activate_cmd_func: " - "unable to add a " - "clear drive cmd"); - } - } - } else { - mms_trace(MMS_ERR, - "DM activate command error"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - } - - /* Set the correct DMSoftState */ - if ((mms_pn_lookup(cmd->cmd_root, "enable", - MMS_PN_KEYWORD, NULL)) != NULL) { - mms_trace(MMS_DEBUG, - "%s %s enabled", - DMName, DriveName); - mm_sql_update_state(mm_wka->mm_data, "DM", - "DMStateSoft", - "ready", "DMName", - DMName); - /* Add a DMUP event */ - mm_notify_add_dmup(mm_wka, cmd); - if (mm_dmp_clear_at_enable(mm_wka)) { - /* DM has a stale handle */ - /* The client session is not connected */ - /* Need to clear the drive */ - mms_trace(MMS_DEBUG, - "Adding clear drive for %s %s", - DMName, DriveName); - if (mm_add_clear_drive(DriveName, - mm_wka->mm_data, - db, - NULL, - NULL, 1, 0) == NULL) { - mms_trace(MMS_ERR, - "mm_dmp_activate_cmd_func: " - "unable to add a clear drive cmd"); - } - } - } else if ((mms_pn_lookup(cmd->cmd_root, "disable", - MMS_PN_KEYWORD, NULL)) != NULL) { - mms_trace(MMS_DEBUG, - "%s %s disabled", - DMName, DriveName); - mm_sql_update_state(mm_wka->mm_data, "DM", - "DMStateSoft", - "present", "DMName", - DMName); - delete_dm_config(mm_wka, &mm_wka->mm_data->mm_db); - /* Add a DMDOWN event */ - mm_notify_add_dmdown(mm_wka, cmd); - - } else if ((mms_pn_lookup(cmd->cmd_root, "reserve", - MMS_PN_KEYWORD, NULL)) != NULL) { - mms_trace(MMS_DEBUG, - "%s reserved %s", - DMName, DriveName); - mm_sql_update_state(mm_wka->mm_data, "DM", - "DMStateSoft", - "reserved", "DMName", - DMName); - } else if ((mms_pn_lookup(cmd->cmd_root, "release", - MMS_PN_KEYWORD, NULL)) != NULL) { - mms_trace(MMS_DEBUG, - "%s released %s", - DMName, DriveName); - mm_sql_update_state(mm_wka->mm_data, "DM", - "DMStateSoft", - "ready", "DMName", - DMName); - if (mm_db_exec(HERE, db, - "update \"DRIVE\" set " - "\"DMName\" = DEFAULT " - "where \"DMName\" = '%s';", - DMName) != MM_DB_OK) { - mms_trace(MMS_ERR, - "Error udating DRIVE.DMName"); - } - } else { - mms_trace(MMS_ERR, - "Unknown type - %s", - cmd->cmd_textcmd); - return (MM_CMD_ERROR); - } - - - cmd->cmd_remove = 1; - if (mm_has_depend(cmd)) { - return (MM_DEPEND_DONE); - } - return (MM_CMD_DONE); - } -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -} - - -#define DMP_PRIVATE "private task['%s'] " \ - "set['cap' '%s' " \ - "'filename' '%s' " \ - "'volumeid' '%s' " \ - "'CartridgePCL' '%s' " \ - "'VolumeName' '%s' " - -#define DMP_PRIVATE_PRIVILEGE "'privileged' '%s' " -#define DMP_PRIVATE_BLOCKSIZE "'blocksize' '%s' " -#define DMP_PRIVATE_FSEQ "'filesequence' '%s'" -#define DMP_PRIVATE_USER "'user' '%s'" -#define DMP_PRIVATE_RETENTION "'retention' '%s'" -#define DMP_RESERVE_DRIVE "select \"ReserveDrive\" "\ - "from \"DRIVE\" where \"DriveName\" = '%s';" -#define DMP_DEFAULT_FILENAME "select \"VolumeName\" "\ - "from \"VOLUME\" where "\ - "\"CartridgeID\" = '%s';" -#define DMP_DEFAULT_VOLID "select \"CartridgePCL\" "\ - "from \"CARTRIDGE\" where " \ - "\"CartridgeID\" = '%s';" - -int -mm_dmp_private_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - cci_t *conn = &mm_wka->wka_conn; - char *DriveName = conn->cci_client; - char *DMName = conn->cci_instance; - char *task = cmd->cmd_task; - char *buf = NULL; - int bufsize = 0; - mm_response_t response; - mm_command_t *parent = NULL; - mm_wka_t *parent_wka = NULL; - cmi_mode_list_t *mode; - cmd_mount_info_t *mount_info = NULL; - char *cap_tokens = NULL; - int rc; - PGresult *reserve_drive; - PGresult *default_filename; - PGresult *default_volumeid; - int a_mode = 0; - char *VolumeName = NULL; - - /* Send a DM mount information */ - mms_trace(MMS_DEVP, "mm_dmp_private_cmd_func"); - - parent = mm_first_parent(cmd); - parent_wka = parent->wka_ptr; - mount_info = &parent->cmd_mount_info; - - mms_trace(MMS_DEVP, "DM PRIVATE CMD FUNC STATE IS %d", cmd->cmd_state); - if (MM_IS_SET(cmd->cmd_flags, MM_CMD_NEED_ACCEPT)) { - mms_trace(MMS_DEVP, "MM_CMD_NEED_ACCEPT is set!"); - } else { - mms_trace(MMS_DEVP, "MM_CMD_NEED_ACCEPT not set!"); - } - - if (cmd->cmd_state == 0) { - mms_trace(MMS_DEVP, "DM Name is %s, task id is %s", - DMName, task); - mms_list_foreach(&mount_info->cmi_mode_list, mode) { - a_mode = 1; - cap_tokens = (char *)mm_check_mode(parent_wka, - parent, DriveName, - mode, - mount_info->cmi_cartridge, db); - if (cap_tokens != NULL) { - /* mode is ok */ - break; - } - } - if (!a_mode) { - cap_tokens = (char *)mm_check_mode(parent_wka, - parent, DriveName, - NULL, - mount_info->cmi_cartridge, db); - } - - if (cap_tokens == NULL) { - mms_trace(MMS_ERR, - "couldn't create capability token string," - " verify DM connected/configured"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - mms_trace(MMS_DEVP, "cap tokens are %s", - cap_tokens); - - /* quert DRIVE for reserve drive */ - rc = mm_db_exec(HERE, db, DMP_RESERVE_DRIVE, - DriveName); - if (rc != MM_DB_DATA) { - mms_trace(MMS_DEVP, "Exec returned with no Data"); - cmd->cmd_remove = 1; - free(cap_tokens); - mm_clear_db(&db->mm_db_results); - return (MM_CMD_ERROR); - } - reserve_drive = db->mm_db_results; - - /* - * file name not specified use default - * 1st 17 chars of VolumeName - */ - rc = mm_db_exec(HERE, db, DMP_DEFAULT_FILENAME, - mount_info->cmi_cartridge); - if (rc != MM_DB_DATA) { - mms_trace(MMS_DEVP, "Exec returned with no Data"); - cmd->cmd_remove = 1; - mm_clear_db(&reserve_drive); - mm_clear_db(&db->mm_db_results); - free(cap_tokens); - return (MM_CMD_ERROR); - } - default_filename = db->mm_db_results; - VolumeName = - strdup(PQgetvalue(default_filename, 0, 0)); - - if (mount_info->cmi_filename == NULL) { - mount_info->cmi_filename = - strdup(PQgetvalue(default_filename, 0, 0)); - } - - - rc = mm_db_exec(HERE, db, DMP_DEFAULT_VOLID, - mount_info->cmi_cartridge); - if (rc != MM_DB_DATA) { - mms_trace(MMS_DEVP, "Exec returned with no Data"); - cmd->cmd_remove = 1; - mm_clear_db(&reserve_drive); - mm_clear_db(&default_filename); - mm_clear_db(&db->mm_db_results); - free(cap_tokens); - free(VolumeName); - return (MM_CMD_ERROR); - } - default_volumeid = db->mm_db_results; - if (mount_info->cmi_volumeid == NULL) { - /* - * volumeid not specifed use default - * CartridgePCL - */ - mount_info->cmi_volumeid = - strdup(PQgetvalue(default_volumeid, 0, 0)); - } - - /* ***************************** */ - SQL_CHK_LEN(&buf, 0, &bufsize, - strlen(DMP_PRIVATE) + - strlen(task) + - strlen(cap_tokens) + - strlen(mount_info->cmi_filename) + - strlen(mount_info->cmi_volumeid) + - strlen(PQgetvalue(default_volumeid, - 0, 0)) + - strlen(VolumeName) + 1); - (void) snprintf(buf, bufsize, - DMP_PRIVATE, - task, - cap_tokens, - mount_info->cmi_filename, - mount_info->cmi_volumeid, - PQgetvalue(default_volumeid, - 0, 0), - VolumeName); - - free(VolumeName); - - if (mount_info->cmi_blocksize != NULL) { - /* if we were passed a blocksize, include it */ - buf = mms_strapp(buf, DMP_PRIVATE_BLOCKSIZE, - mount_info->cmi_blocksize); - } - - if (mount_info->cmi_retention != NULL) { - /* if we were passed a retention, include it */ - buf = mms_strapp(buf, DMP_PRIVATE_RETENTION, - mount_info->cmi_retention); - } - /* Add the new privleged name/value pair */ - if (parent_wka->wka_privilege == MM_PRIV_STANDARD) { - buf = mms_strapp(buf, DMP_PRIVATE_PRIVILEGE, - "false"); - } else { - buf = mms_strapp(buf, DMP_PRIVATE_PRIVILEGE, - "true"); - } - /* Always include the default blocksize */ - /* find default blocksize for this drive */ - rc = mm_db_exec(HERE, db, - "select \"DefaultBlocksize\" " - "from \"DRIVE\" where " - "\"DriveName\" = '%s';", - DriveName); - if (rc != MM_DB_DATA) { - mms_trace(MMS_DEVP, "Exec returned with no Data"); - cmd->cmd_remove = 1; - mm_clear_db(&reserve_drive); - mm_clear_db(&default_filename); - mm_clear_db(&default_volumeid); - mm_clear_db(&db->mm_db_results); - free(cap_tokens); - return (MM_CMD_ERROR); - } - - if (mount_info->cmi_filesequence != NULL) { - buf = mms_strapp(buf, DMP_PRIVATE_FSEQ, - mount_info->cmi_filesequence); - } - if (mount_info->cmi_user != NULL) { - buf = mms_strapp(buf, DMP_PRIVATE_USER, - mount_info->cmi_user); - } - buf = mms_strapp(buf, " ];"); - /* - * mms_trace(MMS_DEVP, "send buf is '%s' to - * fd %d ", buf, mm_wka->mm_wka_conn->mms_fd); - */ - mm_send_text(mm_wka->mm_wka_conn, - buf); - /* ***************************** */ - cmd->cmd_state = 1; - MM_SET_FLAG(cmd->cmd_flags, MM_CMD_NEED_ACCEPT); - free(buf); - free(cap_tokens); - mm_clear_db(&reserve_drive); - mm_clear_db(&default_filename); - mm_clear_db(&default_volumeid); - mm_clear_db(&db->mm_db_results); - return (MM_ACCEPT_NEEDED); - } - if (cmd->cmd_state == 1) { - mms_trace(MMS_DEVP, "PRIVATE STATE 1"); - if (mm_parse_response(cmd->cmd_response, &response) != 0 || - response.response_type != MM_RESPONSE_ACCEPTED) { - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - mms_trace(MMS_DEVP, "PARSE RESPONSE DONE!!"); - cmd->cmd_flags &= ~MM_CMD_NEED_ACCEPT; - cmd->cmd_flags |= MM_CMD_ACCEPTED; - cmd->cmd_state = 2; - mms_trace(MMS_DEVP, "PRIVATE STATE 1 DONE!!"); - return (MM_DISPATCH_DEPEND); - - - } - if (cmd->cmd_state == 2) { - mms_trace(MMS_DEVP, "PRIVATE STATE 2!"); - if (mm_parse_response(cmd->cmd_response, &response) != 0 || - response.response_type != MM_RESPONSE_SUCCESS) { - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - cmd->cmd_remove = 1; - return (MM_DEPEND_DONE); - } -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -} - -#define DMP_SEND_LOAD "load task[\"%s\"];" - -int -mm_dmp_load_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - - cci_t *conn = &mm_wka->wka_conn; - char *DMName = conn->cci_instance; - char *task = cmd->cmd_task; - char *buf = NULL; - int bufsize = 0; - mm_response_t response; - mm_command_t *parent = NULL; - cmd_mount_info_t *mount_info = NULL; - - mms_trace(MMS_DEVP, "mm_dmp_load_cmd_func"); - parent = mm_first_parent(cmd); - mount_info = &parent->cmd_mount_info; - if (cmd->cmd_state == 0) { - /* send the load to DM */ - mms_trace(MMS_DEVP, "DM Name is %s, task id is %s", - DMName, task); - - SQL_CHK_LEN(&buf, 0, &bufsize, - strlen(DMP_SEND_LOAD) + - strlen(task) + 1); - (void) snprintf(buf, bufsize, - DMP_SEND_LOAD, task); - mms_trace(MMS_DEVP, "send buf is '%s' to fd %d ", buf, - mm_wka->mm_wka_conn->mms_fd); - mm_send_text(mm_wka->mm_wka_conn, - buf); - cmd->cmd_state = 1; - MM_SET_FLAG(cmd->cmd_flags, MM_CMD_NEED_ACCEPT); - free(buf); - return (MM_ACCEPT_NEEDED); - - } else if (cmd->cmd_state == 1) { - /* revieved accept */ - mms_trace(MMS_DEVP, "LOAD STATE 1"); - if (mm_parse_response(cmd->cmd_response, &response) != 0 || - response.response_type != MM_RESPONSE_ACCEPTED) { - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - /* set "DriveStateHard" to loading */ - mm_sql_update_state(mm_wka->mm_data, "DRIVE", - "DriveStateHard", - "loading", "DriveName", - mount_info->cmi_drive); - - mms_trace(MMS_DEVP, "PARSE RESPONSE DONE!!"); - cmd->cmd_flags &= ~MM_CMD_NEED_ACCEPT; - cmd->cmd_flags |= MM_CMD_ACCEPTED; - cmd->cmd_state = 2; - mms_trace(MMS_DEVP, "LOAD STATE 1 DONE!!"); - return (MM_DISPATCH_DEPEND); - } else if (cmd->cmd_state == 2) { - /* recieved success */ - mms_trace(MMS_DEVP, "LOAD STATE 2!"); - if (mm_parse_response(cmd->cmd_response, &response) != 0 || - response.response_type != MM_RESPONSE_SUCCESS) { - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - /* set "DriveStateHard" to loaded */ - mm_sql_update_state(mm_wka->mm_data, "DRIVE", - "DriveStateHard", - "loaded", "DriveName", - mount_info->cmi_drive); - - cmd->cmd_remove = 1; - return (MM_DEPEND_DONE); - } else { - mms_trace(MMS_DEVP, "Bad command state"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -} - - -int -mm_dmp_ready_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *message; - mms_par_node_t *work = NULL; - mms_par_node_t *text_work = NULL; - int go; - int name; - mms_par_node_t *value; - mms_par_node_t *id; - mms_par_node_t *args; - mms_par_node_t *text; - cci_t *conn = &mm_wka->wka_conn; - char *DMName = conn->cci_instance; - mm_db_t *db = &cmd->wka_ptr->mm_data->mm_db; - - mms_trace(MMS_DEVP, "mm_dmp_ready_cmd_func"); - if ((value = mms_pn_lookup(cmd->cmd_root, "broken", - MMS_PN_KEYWORD, NULL)) != NULL) { - mms_trace(MMS_DEVP, "ready broken"); - mm_sql_update_state(mm_wka->mm_data, "DM", - "DMStateSoft", - "not ready", "DMName", - DMName); - mm_sql_update_state(mm_wka->mm_data, "DM", - "DMStateHard", - "broken", "DMName", - DMName); - - } else if ((value = mms_pn_lookup(cmd->cmd_root, "not", - MMS_PN_KEYWORD, NULL)) != NULL) { - mms_trace(MMS_DEVP, "ready not"); - mm_sql_update_state(mm_wka->mm_data, "DM", - "DMStateSoft", - "not ready", "DMName", - DMName); - } else if ((value = mms_pn_lookup(cmd->cmd_root, "disconnected", - MMS_PN_KEYWORD, NULL)) != NULL) { - mms_trace(MMS_DEVP, "ready disconnected"); - mm_sql_update_state(mm_wka->mm_data, "DM", - "DMStateSoft", - "disconnected", "DMName", - DMName); - } else { - /* Drive is READY! */ - mm_sql_update_state(mm_wka->mm_data, "DM", - "DMStateSoft", - "ready", "DMName", - DMName); - mm_path_match_report(cmd, db); - mm_send_response(mm_wka->mm_wka_conn, cmd); - cmd->cmd_remove = 1; - return (MM_CMD_DONE); - } - - message = mms_pn_lookup(cmd->cmd_root, "message", - MMS_PN_CLAUSE, &work); - if (message != NULL) { - work = NULL; - id = mms_pn_lookup(message, "id", - MMS_PN_CLAUSE, &work); - if (id != NULL) { - work = NULL; - MMS_PN_LOOKUP(value, id, NULL, - MMS_PN_STRING, &work); - mms_trace(MMS_DEVP, "Manufacturer identifer -> %s", - value->pn_string); - MMS_PN_LOOKUP(value, id, NULL, - MMS_PN_STRING, &work); - mms_trace(MMS_DEVP, "Catalog -> %s", - value->pn_string); - MMS_PN_LOOKUP(value, id, NULL, - MMS_PN_STRING, &work); - mms_trace(MMS_DEVP, "Message ID -> %s", - value->pn_string); - } else { - mms_trace(MMS_DEVP, "Missing an id clause"); - } - - work = NULL; - args = mms_pn_lookup(message, "arguments", - MMS_PN_CLAUSE, &work); - if (args != NULL) { - mms_trace(MMS_DEVP, "Name, Value"); - work = NULL; - go = 1; - name = 0; - while (go) { - if ((value = mms_pn_lookup(args, NULL, - MMS_PN_STRING, - &work)) == NULL) { - go = 0; - } else { - if (name == 0) { - /* got name */ - name = 1; - mms_trace(MMS_DEVP, - "Name -> %s", - value->pn_string); - } else { - name = 0; - mms_trace(MMS_DEVP, - " Value -> %s", - value->pn_string); - } - } - } - if (name == 1) { - /* got name and are missing a value */ - mms_trace(MMS_DEVP, "Missing value "\ - "in argument clause"); - goto not_found; - } - - } else { - mms_trace(MMS_DEVP, "Missing an arguements clause"); - } - text_work = NULL; - text = mms_pn_lookup(message, "loctext", - MMS_PN_CLAUSE, &text_work); - while (text != NULL) { - work = NULL; - MMS_PN_LOOKUP(value, text, NULL, - MMS_PN_STRING, &work); - mms_trace(MMS_DEVP, "Language -> %s", - value->pn_string); - MMS_PN_LOOKUP(value, text, NULL, - MMS_PN_STRING, &work); - mms_trace(MMS_DEVP, "Format -> %s", - value->pn_string); - text = mms_pn_lookup(message, "loctext", - MMS_PN_CLAUSE, &text_work); - } - } else { - mms_trace(MMS_DEVP, "Didn't find a message..."); - } - - mm_path_match_report(cmd, db); - mm_send_response(mm_wka->mm_wka_conn, cmd); - cmd->cmd_remove = 1; - return (MM_CMD_DONE); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); -} - -#define DMP_SEND_UNLOAD "unload task [\"%s\"];" - - - -int -mm_dmp_unload_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - cci_t *conn = &mm_wka->wka_conn; - char *DriveName = conn->cci_client; - char *DMName = conn->cci_instance; - char *task = cmd->cmd_task; - char *buf = NULL; - int bufsize = 0; - mm_response_t response; - mms_par_node_t *work = NULL; - int go; - int name; - mms_par_node_t *value; - mms_par_node_t *text; - - mms_trace(MMS_DEVP, "mm_dmp_unload_cmd_func"); - if (cmd->cmd_state == 0) { - /* send the unload to DM */ - mms_trace(MMS_DEVP, "DM Name is %s, task id is %s", - DMName, task); - - SQL_CHK_LEN(&buf, 0, &bufsize, - strlen(DMP_SEND_UNLOAD) + - strlen(task) + 1); - (void) snprintf(buf, bufsize, - DMP_SEND_UNLOAD, task); - mms_trace(MMS_DEVP, "send buf is '%s' to fd %d ", buf, - mm_wka->mm_wka_conn->mms_fd); - - /* Set DriveStateHard to UNLOADING */ - mm_sql_update_state(mm_wka->mm_data, - "DRIVE", "DriveStateHard", - "unloading", "DriveName", - DriveName); - - mm_send_text(mm_wka->mm_wka_conn, - buf); - cmd->cmd_state = 1; - MM_SET_FLAG(cmd->cmd_flags, MM_CMD_NEED_ACCEPT); - free(buf); - return (MM_ACCEPT_NEEDED); - - } else if (cmd->cmd_state == 1) { - /* revieved accept */ - mms_trace(MMS_DEVP, "UNLOAD STATE 1"); - if (mm_parse_response(cmd->cmd_response, &response) != 0 || - response.response_type != MM_RESPONSE_ACCEPTED) { - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - cmd->cmd_flags &= ~MM_CMD_NEED_ACCEPT; - cmd->cmd_flags |= MM_CMD_ACCEPTED; - cmd->cmd_state = 2; - return (MM_DISPATCH_DEPEND); - } else if (cmd->cmd_state == 2) { - /* recieved success */ - mms_trace(MMS_DEVP, "UNLOAD STATE 2!"); - if (mm_parse_response(cmd->cmd_response, &response) != 0 || - response.response_type != MM_RESPONSE_SUCCESS) { - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - work = NULL; - text = mms_pn_lookup(cmd->cmd_response, "text", - MMS_PN_CLAUSE, &work); - if (text != NULL) { - mms_trace(MMS_DEVP, "Name, Value"); - work = NULL; - go = 1; - name = 0; - while (go) { - if ((value = mms_pn_lookup(text, NULL, - MMS_PN_STRING, - &work)) == NULL) { - go = 0; - } else { - if (name == 0) { - /* got name */ - name = 1; - mms_trace(MMS_DEVP, - "Name -> %s", - value->pn_string); - } else { - name = 0; - mms_trace(MMS_DEVP, - " Value -> %s", - value->pn_string); - } - } - } - if (name == 1) { - /* got name and are missing a value */ - mms_trace(MMS_DEVP, "Missing value "\ - "in text clause"); - goto not_found; - } - - } else { - mms_trace(MMS_DEVP, "Missing an text clause"); - } - - cmd->cmd_remove = 1; - return (MM_DEPEND_DONE); - - } else { - mms_trace(MMS_DEVP, "Bad command state"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - mms_trace(MMS_ERR, "Not Found!!"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); -} - -#define DMP_SEND_DETACH "detach task [\"%s\"] "\ - "drivehandle [\"%s\"] stale [\"%s\"];" -int -mm_dmp_detach_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - cci_t *conn = &mm_wka->wka_conn; - char *DriveName = conn->cci_client; - char *DMName = conn->cci_instance; - char *task = cmd->cmd_task; - char *buf = NULL; - int bufsize = 0; - mm_response_t response; - mm_command_t *parent = NULL; - cmd_mount_info_t *mount_info = NULL; - int rc; - PGresult *handle; - int stale = 0; - - mms_trace(MMS_DEVP, "mm_dmp_detach_cmd_func"); - parent = mm_first_parent(cmd); - mount_info = &parent->cmd_mount_info; - if (cmd->cmd_state == 0) { - /* send the detach to DM */ - mms_trace(MMS_DEVP, "DM Name is %s, task id is %s", - DMName, task); - - /* Get the handle from MOUNTLOGICAL */ - - rc = mm_db_exec(HERE, db, "select \"MountLogicalHandle\" "\ - "from \"MOUNTLOGICAL\" where "\ - "\"DriveName\" = '%s' and \"DMName\" = '%s';", - DriveName, DMName); - if (rc != MM_DB_DATA) { - mms_trace(MMS_ERR, "Exec returned with no Data"); - return (MM_CMD_ERROR); - } - handle = db->mm_db_results; - if (PQntuples(handle) == 0) { - /* NO handle found */ - mms_trace(MMS_NOTICE, - "No MOUNTLOGICAL handle found..."); - /* No MOUNLOGICAL handle, check for STALEHANDLE */ - rc = mm_db_exec(HERE, db, - "select \"MountLogicalHandle\" " - "from \"STALEHANDLE\" where " - "\"DriveName\" = '%s' " - "and \"DMName\" = '%s';", - DriveName, DMName); - if (rc != MM_DB_DATA) { - mms_trace(MMS_DEVP, - "Exec returned with no Data"); - mm_clear_db(&handle); - return (MM_CMD_ERROR); - } - mm_clear_db(&handle); - handle = db->mm_db_results; - if (PQntuples(handle) == 0) { - /* NO handle found */ - mms_trace(MMS_NOTICE, "No STALEHANDLE or "\ - "MOUNTLOGICAL found, skipping detach"); - mm_clear_db(&handle); - return (MM_DEPEND_DONE); - } else { - stale = 1; - } - } - - mount_info->cmi_handle = strdup(PQgetvalue(handle, 0, 0)); - if (stale) { - SQL_CHK_LEN(&buf, 0, &bufsize, - strlen(DMP_SEND_DETACH) + - strlen(task) + - strlen(mount_info->cmi_handle) + 4 + 1); - (void) snprintf(buf, bufsize, - DMP_SEND_DETACH, task, - mount_info->cmi_handle, "true"); - } else { - SQL_CHK_LEN(&buf, 0, &bufsize, - strlen(DMP_SEND_DETACH) + - strlen(task) + - strlen(mount_info->cmi_handle) + 5 + 1); - (void) snprintf(buf, bufsize, - DMP_SEND_DETACH, task, - mount_info->cmi_handle, "false"); - } - mms_trace(MMS_DEVP, "send buf is '%s' to fd %d ", buf, - mm_wka->mm_wka_conn->mms_fd); - - mm_send_text(mm_wka->mm_wka_conn, - buf); - cmd->cmd_state = 1; - MM_SET_FLAG(cmd->cmd_flags, MM_CMD_NEED_ACCEPT); - free(buf); - mm_clear_db(&handle); - return (MM_ACCEPT_NEEDED); - - } else if (cmd->cmd_state == 1) { - /* revieved accept */ - mms_trace(MMS_DEVP, "DETACH STATE 1"); - if (mm_parse_response(cmd->cmd_response, &response) != 0 || - response.response_type != MM_RESPONSE_ACCEPTED) { - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - cmd->cmd_flags &= ~MM_CMD_NEED_ACCEPT; - cmd->cmd_flags |= MM_CMD_ACCEPTED; - cmd->cmd_state = 2; - return (MM_DISPATCH_DEPEND); - } else if (cmd->cmd_state == 2) { - /* recieved success */ - mms_trace(MMS_DEVP, "DETACH STATE 2!"); - if (mm_parse_response(cmd->cmd_response, &response) != 0 || - response.response_type != MM_RESPONSE_SUCCESS) { - mms_trace(MMS_ERR, "DM Detach - %s %s", - response.error_class, - response.error_code); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - - } - cmd->cmd_remove = 1; - return (MM_DEPEND_DONE); - - } else { - mms_trace(MMS_DEVP, "Bad command state"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - mms_trace(MMS_ERR, "Not Found!!"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); -} - -mm_command_t * -mm_dmp_add_cmd(mm_wka_t *mm_wka, mm_command_t *mnt_cmd, char *dm_name, int type) -{ - mm_command_t *cmd; - mm_data_t *mm_data = mm_wka->mm_data; - mm_wka_t *dm_wka; - uuid_text_t uuid; - int recover = 0; - - mms_trace(MMS_DEVP, "mm_dmp_add_cmd"); - switch (type) { - case MM_DMP_RESERVE: - mms_trace(MMS_DEVP, "About to add activate reserve command "); - break; - case MM_DMP_PRIV: - mms_trace(MMS_DEVP, "About to add private command "); - break; - case MM_DMP_LOAD: - mms_trace(MMS_DEVP, "About to add load command "); - break; - case MM_DMP_ATTACH: - mms_trace(MMS_DEVP, "About to add attach command "); - break; - case MM_DMP_IDENTIFY: - mms_trace(MMS_DEVP, "About to add identify command "); - break; - case MM_DMP_DETACH: - mms_trace(MMS_DEVP, "About to add detach command "); - break; - case MM_DMP_UNLOAD: - mms_trace(MMS_DEVP, "About to add unload command "); - break; - case MM_DMP_RELEASE: - mms_trace(MMS_DEVP, "About to add activate release command "); - break; - } - - /* Set cmd->wka_ptr to point to the dm's wka */ - dm_wka = NULL; - if (!recover) { - mms_list_foreach(&mm_data->mm_wka_list, dm_wka) { - if (strcmp(dm_wka->wka_conn.cci_instance, - dm_name) == 0) { - /* Found the wka of dm */ - break; - } - - } - if ((dm_wka == NULL) || (strcmp(dm_wka->wka_conn.cci_instance, - dm_name) != 0)) { - /* bad wka */ - mms_trace(MMS_DEVP, "DM not connected!!"); - return (NULL); - } - } else { - dm_wka = mm_wka; - } - if ((cmd = mm_alloc_cmd(dm_wka)) == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_command_t: %s", - strerror(errno)); - return (NULL); - } - - mm_get_uuid(uuid); - mm_add_depend(cmd, mnt_cmd); - cmd->cmd_task = NULL; - cmd->cmd_task = strdup(uuid); - if (cmd->cmd_task == NULL) { - mms_trace(MMS_ERR, "Error malloc cmd_task in add cmd"); - return (NULL); - } - - switch (type) { - case MM_DMP_RESERVE: - cmd->cmd_func = mm_dmp_activate_cmd_func; - cmd->cmd_name = strdup("dmp activate reserve"); - cmd->cmd_textcmd = mms_strnew(ACTIVATE_RESERVE, cmd->cmd_task); - cmd->cmd_root = mm_text_to_par_node(cmd->cmd_textcmd, - mms_dmpm_parse); - break; - case MM_DMP_PRIV: - cmd->cmd_func = mm_dmp_private_cmd_func; - cmd->cmd_name = strdup("dmp private"); - break; - case MM_DMP_LOAD: - cmd->cmd_func = mm_dmp_load_cmd_func; - cmd->cmd_name = strdup("dmp load"); - break; - case MM_DMP_ATTACH: - cmd->cmd_func = mm_dmp_attach_cmd_func; - cmd->cmd_name = strdup("dmp attach"); - break; - case MM_DMP_IDENTIFY: - cmd->cmd_func = mm_dmp_identify_cmd_func; - cmd->cmd_name = strdup("dmp identify"); - break; - case MM_DMP_DETACH: - cmd->cmd_func = mm_dmp_detach_cmd_func; - cmd->cmd_name = strdup("dmp detach"); - break; - case MM_DMP_UNLOAD: - cmd->cmd_func = mm_dmp_unload_cmd_func; - cmd->cmd_name = strdup("dmp unload"); - break; - case MM_DMP_RELEASE: - cmd->cmd_func = mm_dmp_activate_cmd_func; - cmd->cmd_name = strdup("dmp activate release"); - cmd->cmd_textcmd = mms_strnew(ACTIVATE_RELEASE, cmd->cmd_task); - cmd->cmd_root = mm_text_to_par_node(cmd->cmd_textcmd, - mms_dmpm_parse); - break; - } - pthread_mutex_lock(&mm_data-> - mm_queue_mutex); - mms_list_insert_tail(&mm_wka->mm_data->mm_cmd_queue, cmd); - pthread_mutex_unlock(&mm_data-> - mm_queue_mutex); - mms_trace(MMS_DEVP, "DMP Command Added to Queue - %d", - mm_wka->mm_wka_conn); - return (cmd); -} - -int -mm_dmp_cancel_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - - mms_par_node_t *value; - mms_par_node_t *arg; - mm_data_t *data = mm_wka->mm_data; - char *taskid; - mm_db_t *db = &mm_wka->mm_data->mm_db; - mm_command_t *cmd_p; - mm_command_t *cmd_q; - char *cmd_name = NULL; - uuid_text_t cmd_reqid; - - mms_trace(MMS_DEVP, "mm_dmp_cancel_cmd_func"); - - MMS_PN_LOOKUP(arg, cmd->cmd_root, "whichtask", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, arg, NULL, MMS_PN_STRING, NULL); - taskid = value->pn_string; - - pthread_mutex_lock(&data->mm_queue_mutex); - mms_list_foreach(&data->mm_cmd_queue, cmd_p) { - if (strcmp(cmd_p->wka_ptr->wka_conn.cci_uuid, - cmd->wka_ptr->wka_conn.cci_uuid) == 0 && - strcmp(cmd_p->cmd_task, taskid) == 0) { - - /* is this a command we know how to cancel */ - if (strcmp(mms_pn_token(cmd_p->cmd_root), - "request") == 0) { - cmd_name = strdup("request"); - strcpy(cmd_reqid, cmd_p->cmd_reqid); - } - break; - } - } - pthread_mutex_unlock(&data->mm_queue_mutex); - - /* command not found */ - if (cmd_p == NULL) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_INVALID) + strlen(EDM_E_NOTASK) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INVALID, EDM_E_NOTASK); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - /* cancel command */ - if (strcmp(cmd_name, "request") == 0) { - free(cmd_name); - if (mm_db_exec(HERE, db, "select \"RequestState\" " - "from \"REQUEST\" where \"RequestID\" = '%s';", - cmd_reqid) != MM_DB_DATA || - PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + - strlen(cmd->cmd_task) + - strlen(ECLASS_INTERNAL) + - strlen(EDATABASE) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, - cmd->cmd_task, ECLASS_INTERNAL, EDATABASE); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), - "responded") == 0) { - mm_clear_db(&db->mm_db_results); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + - strlen(cmd->cmd_task) + - strlen(ECLASS_INVALID) + - strlen(EDM_E_NOCANC) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, - cmd->cmd_task, - ECLASS_INVALID, EDM_E_NOCANC); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - - /* remove the request */ - if (mm_db_exec(HERE, db, "delete from \"REQUEST\" where " - "\"RequestID\" = '%s';", cmd_reqid) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + - strlen(cmd->cmd_task) + - strlen(ECLASS_INTERNAL) + - strlen(EDATABASE) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, - cmd->cmd_task, ECLASS_INTERNAL, EDATABASE); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - } else { - free(cmd_name); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_INVALID) + strlen(EDM_E_NOCANC) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INVALID, EDM_E_NOCANC); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - /* send cancelled command's final-command response */ - pthread_mutex_lock(&data->mm_queue_mutex); - mms_list_foreach(&data->mm_cmd_queue, cmd_q) { - if (cmd_q == cmd_p) { - /* send cancelled command response */ - SQL_CHK_LEN(&cmd_p->cmd_buf, 0, - &cmd_p->cmd_bufsize, - strlen(RESPONSE_CANCELLED) + - strlen(cmd_p->cmd_task) + 1); - (void) snprintf(cmd_p->cmd_buf, cmd_p->cmd_bufsize, - RESPONSE_CANCELLED, cmd_p->cmd_task); - mm_send_text(mm_wka->mm_wka_conn, - cmd_p->cmd_buf); - cmd_p->cmd_remove = 1; - break; - } - } - pthread_mutex_unlock(&data->mm_queue_mutex); - - /* same command not found or error sending cancelled response */ - if (cmd_q == NULL) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_INVALID) + strlen(ELM_E_NOTASK) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INVALID, ELM_E_NOTASK); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_DONE); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -} - -int -mm_dmp_reset_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - cci_t *conn = &mm_wka->wka_conn; - mm_response_t response; - - - mms_trace(MMS_DEBUG, - "dmp reset, state %d, %s", - cmd->cmd_state, - cmd->cmd_textcmd); - - if (cmd->cmd_state == 0) { - mms_trace(MMS_INFO, - "Issuing reset for %s %s", - conn->cci_instance, - conn->cci_client); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_textcmd); - cmd->cmd_flags |= MM_CMD_NEED_ACCEPT; - cmd->cmd_state = 1; - return (MM_ACCEPT_NEEDED); - - } else if (cmd->cmd_state == 1) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_ACCEPTED) { - mms_trace(MMS_DEVP, "dmp reset accepted"); - cmd->cmd_flags &= ~MM_CMD_NEED_ACCEPT; - cmd->cmd_flags |= MM_CMD_ACCEPTED; - cmd->cmd_state = 2; - return (MM_NO_DISPATCH); - } else { - mms_trace(MMS_ERR, "dmp cmd not accepted"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - } else if (cmd->cmd_state == 2) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_SUCCESS) { - mms_trace(MMS_DEVP, "dmp reset success"); - cmd->cmd_remove = 1; - return (MM_DEPEND_DONE); - } - } - - mms_trace(MMS_DEVP, "dmp reset failed"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); -} - -int -mm_dmp_exit_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - cci_t *conn = &mm_wka->wka_conn; - mm_response_t response; - - - mms_trace(MMS_DEBUG, - "dmp exit, state %d, %s", - cmd->cmd_state, - cmd->cmd_textcmd); - - if (cmd->cmd_state == 0) { - mms_trace(MMS_INFO, - "Issuing exit for %s %s", - conn->cci_instance, - conn->cci_client); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_textcmd); - cmd->cmd_flags |= MM_CMD_NEED_ACCEPT; - cmd->cmd_state = 1; - return (MM_ACCEPT_NEEDED); - } else if (cmd->cmd_state == 1) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_ACCEPTED) { - mms_trace(MMS_DEVP, "dmp exit accepted"); - cmd->cmd_flags &= ~MM_CMD_NEED_ACCEPT; - cmd->cmd_flags |= MM_CMD_ACCEPTED; - cmd->cmd_state = 2; - return (MM_NO_DISPATCH); - } else { - mms_trace(MMS_ERR, "dmp cmd not accepted"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - } else if (cmd->cmd_state == 2) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_SUCCESS) { - mms_trace(MMS_DEVP, "dmp exit success"); - cmd->cmd_remove = 1; - return (MM_DEPEND_DONE); - } - } - - mms_trace(MMS_DEVP, "dmp exit failed"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); -} diff --git a/usr/src/cmd/mms/mm/common/mm_lmp_sql.c b/usr/src/cmd/mms/mm/common/mm_lmp_sql.c deleted file mode 100644 index 168199ca4b..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_lmp_sql.c +++ /dev/null @@ -1,2926 +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 <stdlib.h> -#include <string.h> -#include <errno.h> -#include <pthread.h> -#include <syslog.h> -#include <ctype.h> -#include <mms_list.h> -#include <mms_parser.h> -#include <mms_par_impl.h> -#include <libpq-fe.h> -#include <mms_trace.h> -#include <mms_strapp.h> -#include "mm_db.h" -#include "mm.h" -#include "mm_util.h" -#include "mm_commands.h" -#include "mm_sql.h" -#include "mm_sql_impl.h" - -static char *_SrcFile = __FILE__; - -static int mm_lm_state_hard(mm_wka_t *mm_wka, char *state); -static int mm_lm_state_soft(mm_wka_t *mm_wka, char *state); -mm_command_t *mm_lmp_add_dm_enable(char *drive_name, char *cart_pcl, - char *state_soft, char *drive_online, mm_wka_t *mm_wka); -mm_command_t *mm_alloc_dm_enable(mm_wka_t *mm_wka); - - - -#define MM_LM_READY 0 -#define MM_LM_NOT_READY 1 -#define MM_LM_ABSENT 2 -#define MM_LM_PRESENT 3 -#define MM_LM_DISCONNECTED 4 -#define MM_LM_ERROR 5 -#define MM_LM_WAIT 6 -#define MM_LM_SEND 7 - - -int -mm_lm_get_state(mm_command_t *cmd, mm_wka_t *lm_wka) { - - mm_db_t *db = &lm_wka->mm_data->mm_db; - char *lm_name = lm_wka->wka_conn.cci_instance; - char *lm_state = NULL; - - if (mm_db_exec(HERE, db, "select \"LMStateSoft\" from \"LM\" " - "where \"LMName\" = '%s'", - lm_name) != MM_DB_DATA) { - mms_trace(MMS_DEVP, "Error getting state info"); - mm_sql_db_err_rsp_new(cmd, db); - return (MM_LM_ERROR); - } - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_DEVP, "could not find lm in database"); - mm_system_error(cmd, - "could not find lm in database"); - mm_clear_db(&db->mm_db_results); - return (MM_LM_ERROR); - } - lm_state = PQgetvalue(db->mm_db_results, 0, 0); - mms_trace(MMS_DEVP, - "%s is %s", - lm_name, lm_state); - if (strcmp(lm_state, "ready") == 0) { - mm_clear_db(&db->mm_db_results); - return (MM_LM_READY); - } - if (strcmp(lm_state, "not ready") == 0) { - mm_clear_db(&db->mm_db_results); - return (MM_LM_NOT_READY); - } - if (strcmp(lm_state, "present") == 0) { - mm_clear_db(&db->mm_db_results); - return (MM_LM_PRESENT); - } - if (strcmp(lm_state, "absent") == 0) { - mm_clear_db(&db->mm_db_results); - return (MM_LM_ABSENT); - } - if (strcmp(lm_state, "disconnected") == 0) { - mm_clear_db(&db->mm_db_results); - return (MM_LM_DISCONNECTED); - } - mm_clear_db(&db->mm_db_results); - return (MM_LM_ERROR); -} - -int -mm_lm_send_ok(mm_command_t *cmd, mm_wka_t *lm_wka) { - int rc = 0; - mm_db_t *db = &lm_wka->mm_data->mm_db; - char *lm_name = lm_wka->wka_conn.cci_instance; - - /* check if lm is supposed to be online/active */ - /* if not, then return MM_LM_ERROR */ - /* because this lmp command cannot be sent to the lm */ - if (mm_db_exec(HERE, db, - "select \"LibraryName\" from \"LIBRARY\"" - " where \"LibraryOnline\" = 'true' and " - "\"LMName\" = '%s'; ", - lm_name) != MM_DB_DATA) { - mms_trace(MMS_DEVP, "Error getting online info"); - mm_sql_db_err_rsp_new(cmd, db); - return (MM_LM_ERROR); - } - if (PQntuples(db->mm_db_results) == 0) { - /* this lm is not an active online lm */ - mms_trace(MMS_DEVP, "LM is not the active lm for " - "an online library"); - mm_system_error(cmd, "LM is not the active lm for " - "an online library"); - mm_clear_db(&db->mm_db_results); - return (MM_LM_ERROR); - } - mm_clear_db(&db->mm_db_results); - /* LM is supposed to be online and active */ - - rc = mm_lm_get_state(cmd, lm_wka); - if (rc == MM_LM_ERROR) { - mms_trace(MMS_DEVP, "Error getting state info"); - cmd->cmd_remove = 1; - return (MM_LM_ERROR); - } - if (rc == MM_LM_NOT_READY) { - mms_trace(MMS_DEVP, - "need to wait on this cmd "); - return (MM_LM_WAIT); - } else if (rc == MM_LM_READY) { - mms_trace(MMS_DEVP, - "lm ready continue"); - return (MM_LM_SEND); - } else if (rc == MM_LM_PRESENT) { - mms_trace(MMS_DEVP, - "active but not ready"); - return (MM_LM_WAIT); - } else { - /* lm is present/disconnected/absent */ - mms_trace(MMS_DEVP, "Current LM state prevents " - "this command from running"); - cmd->cmd_remove = 1; - mm_system_error(cmd, "Current LM state prevents " - "this command from running"); - return (MM_LM_ERROR); - } -} - - - - -int -mm_add_lmp_scan(mm_data_t *mm_data, mm_command_t *parent_cmd, char *drive_name, - char *cartridge_pcl, char *library_name) { - - /* THIS FUNCTION MAY ONLY BE CALLED BY WORKER THREAD */ - /* To multi thread, must pass the db ptr */ - - mm_command_t *cmd = NULL; - mm_db_t *db = &mm_data->mm_db; - mm_wka_t *lm_wka = NULL; - uuid_text_t uuid; - - PGresult *lm_name = NULL; - - mms_trace(MMS_DEVP, "mm_add_lmp_scan"); - - /* check args */ - if (mm_data == NULL) { - mms_trace(MMS_ERR, "mm_data cannot be NULL"); - return (1); - } - if (library_name == NULL) { - mms_trace(MMS_ERR, "missing a library name"); - return (1); - } - if ((drive_name == NULL) && - (cartridge_pcl == NULL)) { - mms_trace(MMS_ERR, - "need a drive name or cartridge pcl"); - return (1); - } else if ((drive_name) && - (cartridge_pcl)) { - mms_trace(MMS_ERR, - "cannot have both a drive name and a pcl"); - return (1); - } - if (parent_cmd == NULL) { - mms_trace(MMS_DEVP, - "No parent command, scan will run independantly"); - } else { - mms_trace(MMS_DEVP, - "Found a parent, scan will be a child command"); - } - - /* get the lm name */ - if (mm_db_exec(HERE, db, - "select \"LMName\" from " - "\"LIBRARY\" where " - "\"LibraryName\" = '%s';", - library_name) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error getting lm name for LMP scan"); - return (1); - } - lm_name = db->mm_db_results; - if (PQntuples(lm_name) != 1) { - mms_trace(MMS_ERR, - "Error getting lm name information, " - "library %s, db results != 1", - library_name); - mm_clear_db(&lm_name); - return (1); - } - - /* find the lm's wka */ - lm_wka = NULL; - mms_list_foreach(&mm_data->mm_wka_list, lm_wka) { - if ((lm_wka->mm_wka_mm_lang == MM_LANG_LMP) && - (strcmp(lm_wka->wka_conn.cci_instance, - PQgetvalue(lm_name, 0, 0)) == 0)) { - /* Found the wka of dm */ - break; - } - - } - if ((lm_wka == NULL) || (strcmp(lm_wka->wka_conn.cci_instance, - PQgetvalue(lm_name, 0, 0)) != 0)) { - /* bad wka */ - mms_trace(MMS_DEBUG, "Could not find lm's wka, " - "lm may not have connected yet"); - mm_clear_db(&lm_name); - return (1); - } - mm_clear_db(&lm_name); - - if ((cmd = mm_alloc_cmd(lm_wka)) == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_command_t: %s", - strerror(errno)); - return (1); - } - - mm_get_uuid(uuid); - cmd->cmd_task = strdup(uuid); - cmd->cmd_func = mm_lmp_scan_cmd_func; - cmd->cmd_name = strdup("lmp scan"); - mm_add_depend(cmd, parent_cmd); - /* Create the text command */ - cmd->cmd_textcmd = NULL; - cmd->cmd_textcmd = mms_strapp(cmd->cmd_textcmd, - "scan task[\"%s\"] ", - cmd->cmd_task); - if (drive_name) { - cmd->cmd_textcmd = mms_strapp(cmd->cmd_textcmd, - "drive [\"%s\"]", - drive_name); - } else if (cartridge_pcl) { - cmd->cmd_textcmd = mms_strapp(cmd->cmd_textcmd, - "slot [\"%s\"]", - cartridge_pcl); - } - cmd->cmd_textcmd = mms_strapp(cmd->cmd_textcmd, ";"); - - mms_trace(MMS_DEVP, "%s", cmd->cmd_textcmd); - pthread_mutex_lock(&mm_data-> - mm_queue_mutex); - mms_list_insert_tail(&mm_data->mm_cmd_queue, cmd); - pthread_mutex_unlock(&mm_data-> - mm_queue_mutex); - mms_trace(MMS_DEVP, "LMP Scan Command Added to Queue"); - return (0); -} - -/* - * mm_library_lm_clear_states(db) - * - * Clear all library and lm states at mm startup. - */ -int -mm_library_lm_clear_states(mm_db_t *db) -{ - int rc = 0; - - /* - * Reset all libraries and lms states - */ - if (mm_db_exec(HERE, db, "UPDATE \"LIBRARY\" SET " - "\"LibraryBroken\" = default, " - "\"LibraryStateHard\" = default, " - "\"LibraryStateSoft\" = default;") != MM_DB_OK) { - rc = 1; - } - - if (mm_db_exec(HERE, db, "UPDATE \"LM\" SET " - "\"LMStateHard\" = default, " - "\"LMStateSoft\" = default, " - "\"LMHost\" = NULL;") != MM_DB_OK) { - rc = 1; - } - - return (rc); -} - -/* - * mm_library_mm_wka(mm_data, library, lm) - * - * Find library in list of work areas by library, lm, or both. - */ -mm_wka_t * -mm_library_lm_wka(mm_data_t *mm_data, char *library, char *lm) -{ - mm_wka_t *mm_wka = NULL; - - /* pthread_mutex_lock(&mm_data->mm_wka_mutex); */ - mms_list_foreach(&mm_data->mm_wka_list, mm_wka) { - if ((library != NULL && lm == NULL) && - strcmp(mm_wka->wka_conn.cci_client, library) == 0) { - break; - } else if ((library == NULL && lm != NULL) && - strcmp(mm_wka->wka_conn.cci_instance, lm) == 0) { - break; - } else if ((library != NULL && lm != NULL) && - strcmp(mm_wka->wka_conn.cci_client, library) == 0 && - strcmp(mm_wka->wka_conn.cci_instance, lm) == 0) { - break; - } - } - /* pthread_mutex_unlock(&mm_data->mm_wka_mutex); */ - - return (mm_wka); -} - -/* - * mm_library_lm_connect(mm_wka) - * - * Activate library lm at connection time if possiable. - */ -int -mm_library_lm_connect(mm_wka_t *mm_wka) -{ - /* - * Set lm states - */ - if (mm_lm_state_hard(mm_wka, "ready") || - mm_lm_state_soft(mm_wka, "present")) { - mms_trace(MMS_DEVP, "unable to change lm states"); - return (1); - } - return (0); -} - -/* - * mm_library_lm_activate_enable(mm_wka) - * - * Activate the library lm if possiable. - */ -int -mm_library_lm_activate_enable(mm_wka_t *mm_wka) -{ - int rc = 0; - uuid_text_t task; - int rows = 0; - mm_db_t *db = &mm_wka->mm_data->mm_db; - mm_command_t *cmd = NULL; - - /* - * Determine if activate enable can be sent - */ - rc = mm_db_exec(HERE, db, "SELECT \"LIBRARY\".\"LibraryName\" FROM " - "\"LIBRARY\",\"LM\" WHERE " - "\"LIBRARY\".\"LibraryDisabled\" = 'false' AND " - "\"LIBRARY\".\"LibraryStateSoft\" = 'ready' AND " - "\"LIBRARY\".\"LibraryBroken\" = 'false' AND " - "\"LIBRARY\".\"LibraryOnline\" = 'true' AND " - "\"LIBRARY\".\"LibraryName\" = '%s' AND " - "\"LIBRARY\".\"LMName\" = '%s' AND " - "\"LM\".\"LMStateHard\" = 'ready' AND " - "\"LM\".\"LMStateSoft\" = 'present' AND " - "\"LM\".\"LibraryName\" = '%s' AND " - "\"LM\".\"LMName\" = '%s';", mm_wka->wka_conn.cci_client, - mm_wka->wka_conn.cci_instance, mm_wka->wka_conn.cci_client, - mm_wka->wka_conn.cci_instance); - rows = PQntuples(db->mm_db_results); - mm_clear_db(&db->mm_db_results); - if (rc != MM_DB_DATA) { - mms_trace(MMS_DEVP, "library state query failed"); - return (1); - } else if (rows != 1) { - mms_trace(MMS_DEVP, "library not ready for activate"); - return (0); - } - - /* - * Build library activate enable command - */ - - if ((cmd = mm_alloc_cmd(mm_wka)) == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_command_t: %s", - strerror(errno)); - return (1); - } - - mm_get_uuid(task); - cmd->cmd_textcmd = mms_strnew(ACTIVATE_ENABLE, task); - cmd->cmd_root = mm_text_to_par_node(cmd->cmd_textcmd, mms_lmpm_parse); - cmd->cmd_task = mm_get_task(cmd->cmd_root); - cmd->cmd_func = mm_lmp_activate_cmd_func; - cmd->cmd_name = strdup("lmp activate enable"); - - if (cmd->cmd_textcmd == NULL || cmd->cmd_root == NULL) { - MM_ABORT_NO_MEM(); - return (1); - } - - pthread_mutex_lock(&mm_wka->mm_data->mm_queue_mutex); - mms_list_insert_tail(&mm_wka->mm_data->mm_cmd_queue, cmd); - pthread_mutex_unlock(&mm_wka->mm_data->mm_queue_mutex); - - /* - * Activate library is inprogress. - */ - return (0); - -no_mem: - MM_ABORT_NO_MEM(); - return (1); -} - -/* - * mm_library_lm_disconnect(mm_wka) - * - * Clear library and lm connection states. - */ -int -mm_library_lm_disconnect(mm_wka_t *mm_wka) -{ - - /* - * Only change the library state soft and lm state soft - * preserving possiable 'broken' state. - */ - - if (mm_lm_state_soft(mm_wka, "absent")) { - return (1); - } - - return (0); -} - -/* - * mm_lm_state_hard(mm_wka, state) - * - * Set lm hard state to 'ready' or 'broken'. - */ -static int -mm_lm_state_hard(mm_wka_t *mm_wka, char *state) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - - if (mm_db_exec(HERE, db, "UPDATE \"LM\" SET " - "\"LMStateHard\" = '%s' WHERE \"LibraryName\" = '%s' AND " - "\"LMName\" = '%s';", state, mm_wka->wka_conn.cci_client, - mm_wka->wka_conn.cci_instance) != MM_DB_OK) { - return (1); - } - return (0); -} - -/* - * mm_lm_state_soft(mm_wka, state) - * - * Set lm soft state to 'absent', 'present', 'not ready', - * 'disconnected', or 'ready'. - */ -static int -mm_lm_state_soft(mm_wka_t *mm_wka, char *state) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - - if (mm_db_exec(HERE, db, "UPDATE \"LM\" SET " - "\"LMStateSoft\" = '%s' WHERE \"LibraryName\" = '%s' AND " - "\"LMName\" = '%s';", state, mm_wka->wka_conn.cci_client, - mm_wka->wka_conn.cci_instance) != MM_DB_OK) { - return (1); - } - return (0); -} - -#ifdef MM_LIBRARY_LM_REMOVE - -static int -mm_library_lm_remove(mm_wka_t *mm_wka) -{ - mms_trace(MMS_DEVP, "library lm remove"); - - /* - * Unrecoverable error, deactivate the client, - * flag the library as not in use, and - * remove the client - */ - mm_wka->wka_remove = 1; - return (mm_lm_state_soft(mm_wka, "not ready")); -} -#endif - -/* Library and lm configured, connected, and ready. */ -int -mm_library_lm_cfg_conn_rdy(mm_command_t *cmd, char *library, char *lm) -{ - mm_db_t *db = &cmd->wka_ptr->mm_data->mm_db; - - mms_trace(MMS_DEVP, "library lm cfg conn rdy"); - - if (mm_db_exec(HERE, db, "SELECT " - "\"LIBRARY\".\"LibraryStateSoft\",\"LM\".\"LMStateSoft\" " - "FROM \"LIBRARY\",\"LM\" " - "WHERE (\"LIBRARY\".\"LibraryName\" = '%s' AND " - "\"LIBRARY\".\"LMName\" = '%s') AND " - "(\"LM\".\"LibraryName\" = '%s' AND " - "\"LM\".\"LMName\" = '%s');", - library, lm, library, lm) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - return (1); - } - if (PQntuples(db->mm_db_results) == 0) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_CONFIG) + - strlen(ELIBNOLMCONFIGURED) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, - cmd->cmd_task, ECLASS_CONFIG, ELIBNOLMCONFIGURED); - mm_clear_db(&db->mm_db_results); - return (1); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), "ready") != 0 || - strcmp(PQgetvalue(db->mm_db_results, 0, 1), "absent") == 0) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_RETRY) + strlen(ELMNOTCONNECTED) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, - cmd->cmd_task, ECLASS_RETRY, ELMNOTCONNECTED); - mm_clear_db(&db->mm_db_results); - return (1); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), "ready") != 0 || - strcmp(PQgetvalue(db->mm_db_results, 0, 1), "ready") != 0) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_RETRY) + strlen(ELMNOTREADY) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, - cmd->cmd_task, ECLASS_RETRY, ELMNOTREADY); - mm_clear_db(&db->mm_db_results); - return (1); - } - mm_clear_db(&db->mm_db_results); - - return (0); - -no_mem: - MM_ABORT_NO_MEM(); - return (1); -} - -/* Find a library lm cap for import export */ -char * -mm_library_lm_get_cap(mm_command_t *cmd, char *library, char *lm) -{ - mm_db_t *db = &cmd->wka_ptr->mm_data->mm_db; - char *slotgroup = NULL; - - mms_trace(MMS_DEVP, "library lm get cap"); - - if (mm_db_exec(HERE, db, "SELECT * FROM \"SLOTGROUP\" " - "WHERE \"LibraryName\" = '%s' " - "AND \"LMName\" = '%s' " - "AND \"Type\" = 'port' " - "AND (\"Direction\" = 'both' " - "OR \"Direction\" = 'in');", - library, lm) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - return (NULL); - } - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_DEVP, "%s doesn't have a cap", library); - SQL_CHK_LEN(&cmd->cmd_buf, 0, - &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + - strlen(cmd->cmd_task) + - strlen(ECLASS_EXIST) + - strlen(ENOMATCH) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, - cmd->cmd_task, ECLASS_EXIST, ENOMATCH); - mm_clear_db(&db->mm_db_results); - return (NULL); - } - - /* default to using first cap in list */ - slotgroup = strdup(PQgetvalue(db->mm_db_results, 0, 0)); - mm_clear_db(&db->mm_db_results); - return (slotgroup); - -no_mem: - MM_ABORT_NO_MEM(); - return (NULL); -} - -/* - * mm_lmp_activate_cmd_func(mm_wka, cmd) - * - * Activate enable or disable library lm. - */ -int -mm_lmp_activate_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_response_t response; - int flag = 0; - mm_db_t *db = &mm_wka->mm_data->mm_db; - - int rc2 = 0; - PGresult *drives = NULL; - int rows = 0; - int i = 0; - - char *cart_pcl = NULL; - char *drive_name = NULL; - char *state_soft = NULL; - char *drive_online = NULL; - - char *library_name = NULL; - char *lm_name = NULL; - - library_name = mm_wka->wka_conn.cci_client; - lm_name = mm_wka->wka_conn.cci_instance; - - mms_trace(MMS_DEVP, "activate cmd func state=%d %s %s", - cmd->cmd_state, - library_name, lm_name); - - flag = (mms_pn_lookup(cmd->cmd_root, "enable", - MMS_PN_KEYWORD, NULL) != NULL ? 1 : 0); - - if (cmd->cmd_state == 0) { - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_textcmd); - cmd->cmd_flags |= MM_CMD_NEED_ACCEPT; - cmd->cmd_state = 1; - return (MM_ACCEPT_NEEDED); - } else if (cmd->cmd_state == 1) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_ACCEPTED) { - mms_trace(MMS_DEVP, "lmp activate %d accepted", flag); - cmd->cmd_flags &= ~MM_CMD_NEED_ACCEPT; - cmd->cmd_flags |= MM_CMD_ACCEPTED; - cmd->cmd_state = 2; - return (MM_NO_DISPATCH); - } else { - mms_trace(MMS_ERR, - "lmp activate %d not accepted", flag); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - } else if (cmd->cmd_state == 2) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_SUCCESS) { - mms_trace(MMS_DEVP, "lmp activate %d success", flag); - if (flag == 0) { - /* - * Library should not get any more - * lmp commands - */ - mms_trace(MMS_DEVP, "LM disabled, " - "set state 'present'"); - if (mm_lm_state_soft(mm_wka, "present")) { - mms_trace(MMS_ERR, - "mm_lmp_activate_cmd_func: " - "LM state changed failed"); - } - /* remove and return */ - cmd->cmd_remove = 1; - if (mm_has_depend(cmd)) { - return (MM_DEPEND_DONE); - } - return (MM_CMD_DONE); - - } else { - /* - * Library is ready for lmp commands - */ - if (mm_lm_state_soft(mm_wka, "ready")) { - mms_trace(MMS_ERR, - "mm_lmp_activate_cmd_func: " - "LM state changed failed"); - } - } - - /* An LMP activate enable is finishing successfully */ - /* Get list of drives for this lib/lm */ - /* mm_lmp_add_dm_enable will: */ - /* 1) Add DM enable for all ready drives */ - /* 2 )Clear drives with cartridges loaded */ - /* and setup DM enables dependent on the clear */ - rc2 = mm_db_exec(HERE, db, - "select distinct \"DRIVE\".\"DriveName\", " - "\"DRIVE\".\"CartridgePCL\", " - "\"DRIVE\".\"DriveStateSoft\", " - "\"DRIVE\".\"DriveOnline\" " - "from \"DRIVE\"" - "where (\"DRIVE\".\"LibraryName\" = '%s'); ", - library_name); - if (rc2 != MM_DB_DATA) { - /* error */ - mms_trace(MMS_ERR, - "Error getting DRIVE information"); - return (MM_CMD_DONE); - } - drives = db->mm_db_results; - rows = PQntuples(drives); - for (i = 0; i < rows; i ++) { - drive_name = PQgetvalue(drives, i, 0); - cart_pcl = PQgetvalue(drives, i, 1); - state_soft = PQgetvalue(drives, i, 2); - drive_online = PQgetvalue(drives, i, 3); - /* For ready and online drives */ - /* add the activate enable now */ - if (mm_lmp_add_dm_enable(drive_name, cart_pcl, - state_soft, drive_online, mm_wka) == NULL) { - mms_trace(MMS_ERR, - "mm_lmp_activate_cmd_func: " - "add dm enabled failed"); - } - } - mm_clear_db(&drives); - rows = 0; - rc2 = 0; - - /* remove and return */ - cmd->cmd_remove = 1; - if (mm_has_depend(cmd)) { - return (MM_DEPEND_DONE); - } - return (MM_CMD_DONE); - } - } - - mms_trace(MMS_ERR, "lm activate %d failed, set LM to present", flag); - if (mm_lm_state_soft(mm_wka, "present")) { - mms_trace(MMS_ERR, - "mm_lmp_activate_cmd_func: " - "LM state changed failed"); - } - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); -} - - -int -mm_lmp_ready_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - int rc = 0; - mm_db_t *db = &mm_wka->mm_data->mm_db; - char *lib_name = mm_wka->wka_conn.cci_client; - cmd->cmd_remove = 1; - - if (mms_pn_lookup(cmd->cmd_root, "not", - MMS_PN_KEYWORD, NULL)) { - /* Do state changes for 'not ready' */ - rc = mm_lm_state_soft(mm_wka, "not ready"); - } else if (mms_pn_lookup(cmd->cmd_root, "broken", - MMS_PN_KEYWORD, NULL)) { - /* Do state changes for 'broken' */ - if (mm_lm_state_hard(mm_wka, "broken") || - mm_lm_state_soft(mm_wka, "not ready")) { - rc = 1; - } - if (rc != 1) { - mms_trace(MMS_INFO, - "%s set %s to broken", - mm_wka->wka_conn.cci_instance, - lib_name); - /* Update library state */ - if (mm_db_exec(HERE, db, - "update \"LIBRARY\" " - "set \"LibraryBroken\" = 't' " - "where \"LibraryName\" = '%s';", - lib_name) != MM_DB_OK) { - mms_trace(MMS_ERR, - "Error setting LIBRARY.LibraryBroken"); - rc = 1; - } - /* Library Down event */ - if (mm_notify_add_lmdown(mm_wka, cmd)) { - mms_trace(MMS_ERR, - "mm_lmp_ready_cmd_func: " - "error adding lm down event"); - } - } - - - } else if (mms_pn_lookup(cmd->cmd_root, "disconnected", - MMS_PN_KEYWORD, NULL)) { - /* Do state changes for 'disconnected' */ - rc = mm_lm_state_soft(mm_wka, "disconnected"); - mms_trace(MMS_INFO, - "%s disconnected from %s", - mm_wka->wka_conn.cci_instance, - lib_name); - /* Library Down event */ - if (mm_notify_add_lmdown(mm_wka, cmd)) { - mms_trace(MMS_ERR, - "mm_lmp_ready_cmd_func: " - "error adding lm down event"); - } - } else if (mms_pn_lookup(cmd->cmd_root, "present", - MMS_PN_KEYWORD, NULL)) { - /* Do state changes for 'present' */ - rc = mm_lm_state_soft(mm_wka, "present"); - mms_trace(MMS_INFO, - "%s, %s in present state ", - mm_wka->wka_conn.cci_instance, - lib_name); - /* Library Down event */ - if (mm_notify_add_lmdown(mm_wka, cmd)) { - mms_trace(MMS_ERR, - "mm_lmp_ready_cmd_func: " - "error adding lm down event"); - } - } else { - mms_trace(MMS_INFO, "LM ready for commands -> %s", - mm_wka->wka_conn.cci_instance); - rc = mm_lm_state_soft(mm_wka, "ready"); - /* Library Ready event */ - if (mm_notify_add_lmup(mm_wka, cmd)) { - mms_trace(MMS_ERR, - "mm_lmp_ready_cmd_func: " - "error adding lm up event"); - } - } - - if (rc) { - mms_trace(MMS_DEVP, "lm state soft change failed"); - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - - return (MM_CMD_DONE); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -} - -mm_command_t * -mm_lmp_add_dm_enable(char *drive_name, char *cart_pcl, - char *state_soft, char *drive_online, mm_wka_t *mm_wka) { - - - mm_db_t *db = &mm_wka->mm_data->mm_db; - int i = 0; - int num_dm = 0; - PGresult *dm_results = NULL; - char *cur_dm_name = NULL; - char *cur_dm_state = NULL; - mm_wka_t *cur_wka = NULL; - mm_data_t *data = mm_wka->mm_data; - mm_command_t *dm_enable = NULL; - mm_command_t *clear_cmd = NULL; - - int request_oper = 0; - int auto_clear = 0; - - mms_trace(MMS_DEVP, "mm_lmp_add_dm_enable"); - - if (drive_name == NULL || - cart_pcl == NULL || - state_soft == NULL || - drive_online == NULL || - mm_wka == NULL) { - mms_trace(MMS_ERR, - "mm_lmp_add_dm_enable passed a NULL arg, " - "cannot enable DM"); - return (NULL); - } - - - - mms_trace(MMS_DEVP, "drive name, %s", - drive_name); - mms_trace(MMS_DEVP, "cart pcl, %s", - cart_pcl); - mms_trace(MMS_DEVP, "state soft, %s", - state_soft); - mms_trace(MMS_DEVP, "drive online, %s", - drive_online); - - /* Determine if this drive needs a clear */ - /* if so set up the clear */ - if (mm_system_settings(db, - &request_oper, &auto_clear)) { - mms_trace(MMS_ERR, - "mm_lmp_add_dm_enable: " - "db error getting system settings"); - request_oper = 0; - auto_clear = 1; - } - - - if ((strcmp(cart_pcl, MM_NON_MMS_CART) == 0) && - (auto_clear)) { - clear_cmd = mm_add_clear_drive(drive_name, - mm_wka->mm_data, - db, NULL, - MM_NON_MMS_CART, 1, 0); - if (clear_cmd == NULL) { - mms_trace(MMS_ERR, - "mm_lmp_add_dm_enable : error " - "adding clear drive" - "for non-mms cart"); - } else { - mms_trace(MMS_DEVP, - "added clear for non-mms tape, %s", - drive_name); - } - - /* If this drive is 'in use' do not add a clear */ - /* This function is only called as part on an lmp enable */ - /* If state is 'in use' this MUST be an LM that has */ - /* Restarted while a client has a tape mounted */ - - } else if ((strcmp(cart_pcl, "") != 0) && - (strcmp(state_soft, "in use") != 0)) { - /* This cart_pcl is not empty */ - /* - * Check for MOUNTPHYSICAL - * only add a clear drive func - * for drives W/O a MOUNTPHYSICAL - */ - mms_trace(MMS_INFO, "Adding clear drive " \ - "func for %s", - drive_name); - clear_cmd = mm_add_clear_drive(drive_name, - mm_wka->mm_data, db, - NULL, NULL, 0, 0); - if (clear_cmd == NULL) { - mms_trace(MMS_ERR, - "mm_lmp_add_dm_enable : error " - "adding clear drive" - "for %s %s", - drive_name, - cart_pcl); - } else { - mms_trace(MMS_DEVP, - "added clear for %s %s", - drive_name, cart_pcl); - } - } - - /* Check the DM's */ - if (mm_db_exec(HERE, db, - "select distinct \"DM\".\"DMName\"," - "\"DM\".\"DMStateSoft\" from \"DM\"" - "cross join \"DRIVE\" where" - "((\"DM\".\"DriveName\" = \"DRIVE\".\"DriveName\")" - " and((\"DRIVE\".\"DriveName\" = '%s') AND" - "(\"DRIVE\".\"DriveOnline\" = 'true')));", - drive_name) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "error getting DM names for drive, %s", - drive_name); - return (NULL); - } - dm_results = db->mm_db_results; - num_dm = PQntuples(dm_results); - mms_trace(MMS_DEVP, - "trying to activate %d dm's for drive %s", - num_dm, drive_name); - /* call mm_drive_dm_activate_enable(mm_wka_t *mm_wka) */ - /* on the wka of each dm whose name is in PQresults */ - for (i = 0; i < num_dm; i++) { - cur_dm_name = PQgetvalue(dm_results, i, 0); - cur_dm_state = PQgetvalue(dm_results, i, 1); - cur_wka = NULL; - - /* check DM state soft */ - /* if state soft is ready, or reserved */ - /* Dont attempt to enable */ - - if ((strcmp(cur_dm_state, "ready") == 0) || - (strcmp(cur_dm_state, "reserved") == 0)) { - mms_trace(MMS_DEVP, - "DM, %s, StateSoft == %s, " - "skip enable", - cur_dm_name, - cur_dm_state); - continue; - } - mms_list_foreach(&data->mm_wka_list, cur_wka) { - if (strcmp(cur_wka->wka_conn.cci_instance, - cur_dm_name) == 0) { - /* to wka found */ - break; - } - } - - if (cur_wka == NULL) { - mms_trace(MMS_DEVP, - "didn't find a wka for %s", - cur_dm_name); - } else { - if (clear_cmd == NULL) { - dm_enable = - mm_drive_dm_activate_enable(cur_wka); - } else { - mms_trace(MMS_DEVP, - "alloc dm enable, run enable " - "before clear drive"); - /* Have the dm enable run */ - /* before the clear drive */ - dm_enable = - mm_alloc_dm_enable(cur_wka); - if (dm_enable != NULL) { - mm_add_depend(dm_enable, - clear_cmd); - MM_UNSET_FLAG(clear_cmd->cmd_flags, - MM_CMD_DISPATCHABLE); - MM_SET_FLAG(dm_enable->cmd_flags, - MM_CMD_DISPATCHABLE); - } - } - } - } - mm_clear_db(&dm_results); - return (dm_enable); - - -} - - -void -mm_update_cart_loaded(mm_wka_t *mm_wka, char *cart_id) -{ - mm_data_t *mm_data = mm_wka->mm_data; - mm_command_t *cur_cmd = NULL; - cmd_mount_info_t *mount_info = NULL; - cmi_cart_list_t *cart = NULL; - char *cur_cartid = NULL; - - mms_trace(MMS_DEVP, - "mm_update_cart_loaded: "); - - pthread_mutex_lock(&mm_data->mm_queue_mutex); - mms_list_foreach(&mm_data->mm_cmd_queue, cur_cmd) { - mount_info = &cur_cmd->cmd_mount_info; - if (cur_cmd->cmd_func == - mm_mount_cmd_func) { - mms_list_foreach(&mount_info->cmi_cart_list, cart) { - cur_cartid = cart->cmi_cart_id; - if ((cart->cmi_cart_loaded == 1) && - (strcmp(cart_id, cur_cartid) == 0)) { - /* same cart */ - cart->cmi_cart_loaded = 0; - cart->cmi_cart_not_ready = 0; - mms_trace(MMS_DEVP, - "mm_update_cart_loaded: " - "set cart unloaded and ready"); - } - } - } - } - pthread_mutex_unlock(&mm_data->mm_queue_mutex); - -} - -void -mm_lmp_set_clear_pcl(mm_wka_t *mm_wka, char *drive_name, char *drive_cart_pcl) { - mm_data_t *mm_data = mm_wka->mm_data; - /* If there is a clear drive for this drive */ - mm_command_t *cur_cmd = NULL; - pthread_mutex_lock(&mm_data->mm_queue_mutex); - mms_list_foreach(&mm_data->mm_cmd_queue, cur_cmd) { - if ((cur_cmd->cmd_func == - mm_clear_drive_cmd_func) && - (cur_cmd->cmd_state == 1) && - (strcmp(cur_cmd->cmd_mount_info.cmi_drive, - drive_name) == 0)) { - mms_trace(MMS_DEVP, - "set pcl, %s, in clear drive " - "for this non-mms tape", - drive_cart_pcl); - mm_set_mount_info_pcl(drive_cart_pcl, - &cur_cmd->cmd_mount_info); - } - } - pthread_mutex_unlock(&mm_data->mm_queue_mutex); -} - -/* - * mm_lmp_config_cmd_func(mm_wka, cmd) - * - * Process lmp config partial and full commands. - */ -int -mm_lmp_config_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *arg = NULL; - mms_par_node_t *value = NULL; - mm_lmp_scope_t scope; - mms_par_node_t *work = NULL; - mms_par_node_t *item = NULL; - mms_par_node_t *slot = NULL; - char *slot_name = NULL; - char *slot_bay_name = NULL; - char *slotgroup_name = NULL; - char *slot_cart_id = NULL; - char *slot_cart_id_status = NULL; - char *slot_cart_pcl = NULL; - char *slot_type = NULL; - char *slot_occupied = NULL; - char *slot_accessible = NULL; - mms_par_node_t *bay = NULL; - char *bay_name = NULL; - char *bay_accessible = NULL; - mms_par_node_t *drive = NULL; - char *drive_name = NULL; - char *drive_bay_name = NULL; - char *drive_cart_pcl = NULL; - char *drive_occupied = NULL; - char *drive_accessible = NULL; - PGresult *results = NULL; - PGresult *drive_state_results = NULL; - mms_par_node_t *freeslots = NULL; - char *freeslots_bay_name = NULL; - char *freeslots_slot_type = NULL; - int freeslots_num_slots = NULL; - mms_par_node_t *delslots = NULL; - char *delslots_slot_name = NULL; - mms_par_node_t *slotgrp = NULL; - char *slotgrp_name = NULL; - char *slotgrp_bay_name = NULL; - char *slotgrp_direction = NULL; - char *slotgrp_type = NULL; - mms_par_node_t *perf = NULL; - int perfno = 0; - char *drive_serial_num = NULL; - char *drive_geometry = NULL; - int rc = 0; - int row = 0; - int rows = 0; - int found = 0; - mm_db_t *db = &mm_wka->mm_data->mm_db; - cci_t *conn = &mm_wka->wka_conn; - int do_update_drive = 0; - - - int has_serial = 1; - int has_geometry = 1; - int has_cart_pcl = 0; - int update_cart_state = 0; - - mms_trace(MMS_DEBUG, "lmp config cmd"); - - /* - * Partial or full config - */ - MMS_PN_LOOKUP(arg, cmd->cmd_root, "scope", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, arg, NULL, MMS_PN_KEYWORD, NULL); - if (strcmp(value->pn_string, "full") == 0) { - scope = SCOPE_FULL; - mms_trace(MMS_DEBUG, "scope: full"); - } else if (strcmp(value->pn_string, "partial") == 0) { - scope = SCOPE_PARTIAL; - mms_trace(MMS_DEBUG, "scope: partial"); - } - - /* - * Full config delete. The difference between full and partial - * scope is a full scope deletes the config. A full scope does - * not check for all attributes being present in the command. - */ - if (scope == SCOPE_FULL) { - if (mm_db_exec(HERE, db, "DELETE FROM \"SLOT\" WHERE " - "\"LibraryName\" = '%s' AND \"LMName\" = '%s';", - conn->cci_client, - conn->cci_instance) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (mm_db_exec(HERE, db, "DELETE FROM \"SLOTCONFIG\" WHERE " - "\"LibraryName\" = '%s' AND \"LMName\" = '%s';", - conn->cci_client, - conn->cci_instance) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (mm_db_exec(HERE, db, "DELETE FROM \"SLOTGROUP\" WHERE " - "\"LibraryName\" = '%s' AND \"LMName\" = '%s';", - conn->cci_client, - conn->cci_instance) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (mm_db_exec(HERE, db, "UPDATE \"DRIVE\" SET " - "\"BayName\" = NULL, " - "\"DriveLibraryAccessible\" = 'false', " - "\"DriveLibraryOccupied\" = 'false', " - "\"CartridgePCL\" = NULL WHERE " - "\"LibraryName\" = '%s';", - conn->cci_client) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (mm_db_exec(HERE, db, "DELETE FROM \"BAY\" WHERE " - "\"LibraryName\" = '%s' AND \"LMName\" = '%s';", - conn->cci_client, - conn->cci_instance) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - - /* - * Library config - */ - - mms_trace(MMS_DEBUG, "bay"); - work = NULL; - for (bay = mms_pn_lookup(cmd->cmd_root, "bay", - MMS_PN_CLAUSE, &work); - bay != NULL; - bay = mms_pn_lookup(cmd->cmd_root, "bay", - MMS_PN_CLAUSE, &work)) { - item = NULL; - MMS_PN_LOOKUP(value, bay, NULL, MMS_PN_STRING, &item); - bay_name = value->pn_string; - - MMS_PN_LOOKUP(value, bay, NULL, MMS_PN_KEYWORD, &item); - bay_accessible = value->pn_string; - - mms_trace(MMS_DEBUG, "bay: %s, %s", bay_name, bay_accessible); - - /* partial config */ - if (scope == SCOPE_PARTIAL && - mm_db_exec(HERE, db, "SELECT \"BayAccessible\" FROM " - "\"BAY\" WHERE \"BayName\" = '%s' AND " - "\"LibraryName\" = '%s' AND \"LMName\" = '%s';", - bay_name, conn->cci_client, - conn->cci_instance) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (scope == SCOPE_PARTIAL) { - rows = PQntuples(db->mm_db_results); - mm_clear_db(&db->mm_db_results); - } else { - rows = 0; - } - - /* update bay */ - if (rows == 0 && mm_db_exec(HERE, db, "INSERT INTO \"BAY\" " - "(\"BayName\", \"LibraryName\", "\ - "\"LMName\", " - "\"BayAccessible\") "\ - "VALUES ('%s', '%s', '%s', '%s');", - bay_name, conn->cci_client, - conn->cci_instance, - bay_accessible) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } else if (mm_db_exec(HERE, db, "UPDATE \"BAY\" SET " - "\"BayAccessible\" = '%s' "\ - "WHERE \"BayName\" = '%s' AND " - "\"LibraryName\" = '%s' AND "\ - "\"LMName\" = '%s';", - bay_accessible, bay_name, - conn->cci_client, - conn->cci_instance) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - - mms_trace(MMS_DEBUG, "slotgroup"); - work = NULL; - for (slotgrp = mms_pn_lookup(cmd->cmd_root, "slotgroup", - MMS_PN_CLAUSE, &work); - slotgrp != NULL; - slotgrp = mms_pn_lookup(cmd->cmd_root, "slotgroup", - MMS_PN_CLAUSE, &work)) { - item = NULL; - MMS_PN_LOOKUP(value, slotgrp, NULL, MMS_PN_STRING, &item); - slotgrp_name = value->pn_string; - - MMS_PN_LOOKUP(value, slotgrp, NULL, MMS_PN_STRING, &item); - slotgrp_bay_name = value->pn_string; - - MMS_PN_LOOKUP(value, slotgrp, NULL, MMS_PN_KEYWORD, &item); - slotgrp_direction = value->pn_string; - - MMS_PN_LOOKUP(value, slotgrp, NULL, MMS_PN_STRING, &item); - slotgrp_type = value->pn_string; - - mms_trace(MMS_DEBUG, "slotgroup: %s, %s, %s, %s", - slotgrp_name, slotgrp_bay_name, slotgrp_direction, - slotgrp_type); - - /* partial config */ - if (scope == SCOPE_PARTIAL && - mm_db_exec(HERE, db, "SELECT \"SlotGroupName\" " - "FROM \"SLOTGROUP\" "\ - "WHERE \"BayName\" = '%s' AND " - "\"LibraryName\" = '%s' AND \"LMName\" = '%s';", - slotgrp_bay_name, conn->cci_client, - conn->cci_instance) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (scope == SCOPE_PARTIAL) { - rows = PQntuples(db->mm_db_results); - mm_clear_db(&db->mm_db_results); - } else { - rows = 0; - } - - /* full or partial config */ - if (rows == 0 && mm_db_exec(HERE, db, - "INSERT INTO \"SLOTGROUP\" " - "(\"SlotGroupName\", \"BayName\", " - "\"Direction\", " - "\"Type\", \"LibraryName\", " - "\"LMName\") VALUES " - "('%s', '%s', '%s', '%s', " - "'%s', '%s');", - slotgrp_name, - slotgrp_bay_name, slotgrp_direction, - slotgrp_type, conn->cci_client, - conn->cci_instance) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } else if (mm_db_exec(HERE, db, "UPDATE \"SLOTGROUP\" SET " - "\"Direction\" = '%s', "\ - "\"Type\" = '%s' WHERE " - "\"SlotGroupName\" = '%s' AND "\ - "\"BayName\" = '%s' AND " - "\"LibraryName\" = '%s' AND "\ - "\"LMName\" = '%s';", - slotgrp_direction, - slotgrp_type, - slotgrp_name, - slotgrp_bay_name, conn->cci_client, - conn->cci_instance) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - - mms_trace(MMS_DEBUG, "slot"); - work = NULL; - for (slot = mms_pn_lookup(cmd->cmd_root, "slot", - MMS_PN_CLAUSE, &work); - slot != NULL; - slot = mms_pn_lookup(cmd->cmd_root, "slot", - MMS_PN_CLAUSE, &work)) { - item = NULL; - MMS_PN_LOOKUP(value, slot, NULL, MMS_PN_STRING, &item); - slot_name = value->pn_string; - - MMS_PN_LOOKUP(value, slot, NULL, MMS_PN_STRING, &item); - slot_bay_name = value->pn_string; - - MMS_PN_LOOKUP(value, slot, NULL, MMS_PN_STRING, &item); - slotgroup_name = value->pn_string; - - MMS_PN_LOOKUP(value, slot, NULL, MMS_PN_STRING, &item); - slot_cart_pcl = value->pn_string; - - MMS_PN_LOOKUP(value, slot, NULL, MMS_PN_STRING, &item); - slot_type = value->pn_string; - - MMS_PN_LOOKUP(value, slot, NULL, MMS_PN_KEYWORD, &item); - slot_occupied = value->pn_string; - - MMS_PN_LOOKUP(value, slot, NULL, MMS_PN_KEYWORD, &item); - slot_accessible = value->pn_string; - - mms_trace(MMS_DEBUG, "slot: %s, %s, %s, %s, %s, %s, %s", - slot_name, slot_bay_name, slotgroup_name, - slot_cart_pcl, slot_type, slot_occupied, - slot_accessible); - - /* verify mms object depends on */ - if (mm_db_exec(HERE, db, "SELECT \"SlotTypeName\", " - "\"CartridgeShapeName\" FROM " - "\"SLOTTYPE\" WHERE \"SlotTypeName\" = '%s';", - slot_type) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - rows = PQntuples(db->mm_db_results); - for (row = 0, found = 0; row < rows; row++) { - if (strcmp(slot_type, - PQgetvalue(db->mm_db_results, 0, 0)) == 0) { - found = 1; - break; - } - } - mm_clear_db(&db->mm_db_results); - if (found == 0) { - mms_trace(MMS_ERR, - "no slot type found"); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(ECLASS_LANGUAGE) + - strlen(cmd->cmd_task) + - strlen(ESYNTAX) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, - cmd->cmd_task, - ECLASS_LANGUAGE, ESYNTAX); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - /* get cartridge id by cartridge pcl */ - if (mm_db_exec(HERE, db, "SELECT \"CartridgeID\"," - "\"CartridgeStatus\" FROM " - "\"CARTRIDGE\" WHERE "\ - "\"CartridgePCL\" = '%s' AND " - "\"LibraryName\" = '%s';", slot_cart_pcl, - conn->cci_client) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if ((rows = PQntuples(db->mm_db_results)) != 1) { - results = NULL; - slot_cart_id = NULL; - mm_clear_db(&db->mm_db_results); - } else { - results = db->mm_db_results; - slot_cart_id = PQgetvalue(results, 0, 0); - slot_cart_id_status = PQgetvalue(results, 0, 1); - } - - /* partial config find slot */ - if (scope == SCOPE_PARTIAL && - mm_db_exec(HERE, db, "SELECT \"SlotTypeName\" FROM " - "\"SLOT\" WHERE \"SlotName\" = '%s' AND " - "\"LibraryName\" = '%s' AND " - "\"LMName\" = '%s';", - slot_name, conn->cci_client, - conn->cci_instance) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (scope == SCOPE_PARTIAL) { - rows = PQntuples(db->mm_db_results); - mm_clear_db(&db->mm_db_results); - } else { - rows = 0; - } - - if (slot_cart_id) { - /* Cartridge is not in a drive */ - if (strcmp(slot_cart_id_status, "unavailable") == 0) { - /* This cartridge has not */ - /* had a config done yet */ - if (mm_db_exec(HERE, db, - "update \"CARTRIDGE\" " - "set \"CartridgeStatus\" " - "= 'available' where " - "\"CartridgeID\" = '%s';", - slot_cart_id) != - MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - if (mm_db_exec(HERE, db, - "update \"CARTRIDGE\" " - "set \"CartridgeDriveOccupied\" " - "= 'false' where " - "\"CartridgeID\" = '%s';", - slot_cart_id) != - MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - /* If this cartridge is a candidate for a mount */ - /* must update cart->cmi_cart_loaded */ - /* since this cart is no longer loaded */ - mm_update_cart_loaded(mm_wka, slot_cart_id); - - - } - - if (slot_cart_id && rows == 0 && - mm_db_exec(HERE, db, "INSERT INTO \"SLOT\" " - "(\"SlotName\", \"LibraryName\", \"LMName\", " - "\"BayName\", \"SlotGroupName\", " - "\"SlotTypeName\", " - "\"CartridgeID\", \"CartridgePCL\", " - "\"SlotAccessable\", " - "\"SlotOccupied\") VALUES " - "('%s', '%s', '%s', '%s', '%s', " - "'%s', '%s', '%s', '%s', '%s');", slot_name, - conn->cci_client, - conn->cci_instance, - slot_bay_name, slotgroup_name, slot_type, - slot_cart_id, slot_cart_pcl, - slot_accessible, slot_occupied) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } else if (slot_cart_id && - mm_db_exec(HERE, db, "UPDATE \"SLOT\" " - "SET \"SlotTypeName\" = '%s', " - "\"CartridgeID\" = '%s', " - "\"CartridgePCL\" = '%s', " - "\"SlotAccessable\" = '%s', " - "\"SlotOccupied\" = '%s', " - "\"BayName\" = '%s', " - "\"SlotGroupName\" = '%s' WHERE " - "\"SlotName\" = '%s' AND " - "\"LibraryName\" = '%s' AND " - "\"LMName\" = '%s';", - slot_type, slot_cart_id, - slot_cart_pcl, slot_accessible, - slot_occupied, slot_bay_name, - slotgroup_name, slot_name, - conn->cci_client, - conn->cci_instance) != - MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (results) { - mm_clear_db(&results); - } - } - - mms_trace(MMS_DEBUG, "drive"); - work = NULL; - for (drive = mms_pn_lookup(cmd->cmd_root, "drive", - MMS_PN_CLAUSE, &work); - drive != NULL; - drive = mms_pn_lookup(cmd->cmd_root, "drive", - MMS_PN_CLAUSE, &work)) { - - has_serial = 1; - has_geometry = 1; - has_cart_pcl = 0; - update_cart_state = 0; - - item = NULL; - MMS_PN_LOOKUP(value, drive, NULL, MMS_PN_STRING, &item); - drive_serial_num = - value->pn_string; /* drive serial number */ - - MMS_PN_LOOKUP(value, drive, NULL, MMS_PN_STRING, &item); - drive_geometry = - value->pn_string; /* drive geometry */ - - MMS_PN_LOOKUP(value, drive, NULL, MMS_PN_STRING, &item); - drive_bay_name = value->pn_string; - - MMS_PN_LOOKUP(value, drive, NULL, MMS_PN_STRING, &item); - drive_cart_pcl = value->pn_string; - - MMS_PN_LOOKUP(value, drive, NULL, MMS_PN_KEYWORD, &item); - drive_occupied = value->pn_string; - - MMS_PN_LOOKUP(value, drive, NULL, MMS_PN_KEYWORD, &item); - drive_accessible = value->pn_string; - - if (strcmp(drive_serial_num, "") == 0) { - has_serial = 0; - } - if (strcmp(drive_geometry, "") == 0) { - has_geometry = 0; - } - if (!has_serial && !has_geometry) { - mms_trace(MMS_ERR, - "drive spec missing serialnumber/geometry"); - continue; - } - if (has_serial) { - if (has_geometry) { - mms_trace(MMS_DEBUG, - "drive: %s, %s, %s, %s, %s, %s", - drive_serial_num, drive_geometry, - drive_bay_name, - drive_cart_pcl, drive_occupied, - drive_accessible); - } else { - mms_trace(MMS_DEBUG, - "drive: %s, %s, %s, %s, %s", - drive_serial_num, - drive_bay_name, drive_cart_pcl, - drive_occupied, - drive_accessible); - } - } else { - mms_trace(MMS_DEBUG, "drive: %s, %s, %s, %s, %s", - drive_geometry, - drive_bay_name, drive_cart_pcl, - drive_occupied, - drive_accessible); - } - - - - /* determine if drive is configured */ - if (has_serial) { - rc = mm_db_exec(HERE, db, "SELECT \"DriveName\"," - "\"DriveStateSoft\" FROM " - "\"DRIVE\" WHERE \"DriveSerialNum\" = '%s';", - drive_serial_num); - } else { - rc = mm_db_exec(HERE, db, "SELECT \"DriveName\"," - "\"DriveStateSoft\" FROM " - "\"DRIVE\" WHERE \"DriveGeometry\" = '%s';", - drive_geometry); - } - if (rc != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - drive_state_results = db->mm_db_results; - if ((do_update_drive = PQntuples(drive_state_results)) == 1) { - /* get mm drive name from db */ - drive_name = PQgetvalue(drive_state_results, 0, 0); - - /* set geometry for this drive */ - if (has_geometry && - has_serial && - (mm_db_exec(HERE, db, - "update \"DRIVE\" set \"DriveGeometry\" = '%s' " - "where \"DriveSerialNum\" = '%s';", - drive_geometry, drive_serial_num) != MM_DB_OK)) { - mm_sql_db_err_rsp_new(cmd, db); - mms_trace(MMS_ERR, - "error setting drive geometry"); - } - } else { - /* drive not configured */ - drive_name = NULL; - do_update_drive = 0; - } - - if (strcmp(drive_occupied, "true") == 0 && - strcmp(drive_cart_pcl, "none") != 0) { - has_cart_pcl = 1; - } - - - /* update drive states and location */ - if ((do_update_drive) && - has_cart_pcl) { - if (mm_db_exec(HERE, db, - "select \"CartridgePCL\", " - "\"CartridgeStatus\" " - "from \"CARTRIDGE\" where " - "\"CartridgePCL\" = '%s' " - "and \"LibraryName\" = '%s';", - drive_cart_pcl, - conn->cci_client) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - mm_clear_db(&drive_state_results); - return (MM_CMD_ERROR); - } else { - if (PQntuples(db->mm_db_results) != 1) { - - /* PCL does not exists to MMS */ - mms_trace(MMS_ERR, - "Cartridge %s does not " - "belong to MMS", - drive_cart_pcl); - do_update_drive = 0; - mm_clear_db(&db->mm_db_results); - if (mm_db_exec(HERE, db, - "UPDATE \"DRIVE\" SET " - "\"DriveLibrary" - "Accessible\" " - "= '%s', " - "\"DriveLibraryOccupied\" " - "= '%s', " - "\"BayName\" = '%s', " - "\"CartridgePCL\" " - "= '%s' " - "WHERE " - "\"DRIVE\".\"LibraryName\" " - "= '%s' AND " - "\"DRIVE\".\"DriveName\" " - "= '%s' ;", - drive_accessible, - drive_occupied, - drive_bay_name, - MM_NON_MMS_CART, - conn->cci_client, - drive_name) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, - db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka-> - mm_wka_conn, - cmd->cmd_buf); - mm_clear_db( - &drive_state_results); - return (MM_CMD_ERROR); - } - mm_lmp_set_clear_pcl(mm_wka, drive_name, - drive_cart_pcl); - - } else { - mm_clear_db(&db->mm_db_results); - } - } - } - - - if (do_update_drive) { - /* PCL exists to MMS */ - - if (strcmp(drive_cart_pcl, "none") != 0) { - if (mm_db_exec(HERE, db, "UPDATE \"DRIVE\" SET " - "\"DriveLibraryAccessible\" = '%s', " - "\"DriveLibraryOccupied\" = '%s', " - "\"BayName\" = '%s', " - "\"CartridgePCL\" = '%s' WHERE " - "\"DRIVE\".\"LibraryName\" = '%s' AND " - "\"DRIVE\".\"DriveName\" = '%s' ;", - drive_accessible, drive_occupied, - drive_bay_name, drive_cart_pcl, - conn->cci_client, - drive_name) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - mm_clear_db(&drive_state_results); - return (MM_CMD_ERROR); - } - } else { - if (mm_db_exec(HERE, db, "UPDATE \"DRIVE\" SET " - "\"DriveLibraryAccessible\" = '%s', " - "\"DriveLibraryOccupied\" = '%s', " - "\"BayName\" = '%s', " - "\"DriveStateHard\" = 'unloaded', " - "\"CartridgePCL\" = NULL WHERE " - "\"DRIVE\".\"LibraryName\" = '%s' AND " - "\"DRIVE\".\"DriveName\" = '%s' ;", - drive_accessible, drive_occupied, - drive_bay_name, - conn->cci_client, - drive_name) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - mm_clear_db(&drive_state_results); - return (MM_CMD_ERROR); - } - } - if (strcmp(drive_cart_pcl, "none") != 0) { - if (mm_db_exec(HERE, db, - "update \"CARTRIDGE\" set " - "\"CartridgeDriveOccupied\" = 'true' " - "where \"CartridgePCL\" = " - "'%s' and \"LibraryName\" = '%s';", - drive_cart_pcl, - conn->cci_client) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - mm_clear_db(&drive_state_results); - return (MM_CMD_ERROR); - } - } else if (strcmp(PQgetvalue(drive_state_results, 0, 1), - "unavailable") == 0) { - /* this drive does not have a cart loaded */ - /* if this drive state is not 'unavailable' */ - /* set the state to 'ready' */ - if (mm_db_exec(HERE, db, - "update \"DRIVE\" set " - "\"DriveStateSoft\" = 'ready' " - "where \"DriveName\" = " - "'%s';", - drive_name) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - mm_clear_db(&drive_state_results); - return (MM_CMD_ERROR); - } - - - } - if (update_cart_state) { - /* This cartridge does not have a */ - /* SLOT object yet */ - if (mm_db_exec(HERE, db, - "update \"CARTRIDGE\" set " - "\"CartridgeStatus\" = 'available' " - "where \"CartridgePCL\" = " - "'%s' and \"LibraryName\" = '%s';", - drive_cart_pcl, - conn->cci_client) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - mm_clear_db(&drive_state_results); - return (MM_CMD_ERROR); - } - } - - } - mm_clear_db(&drive_state_results); - } - - mms_trace(MMS_DEBUG, "%s", "freeslots"); - work = NULL; - for (freeslots = mms_pn_lookup(cmd->cmd_root, "freeslots", - MMS_PN_CLAUSE, &work); - freeslots != NULL; - freeslots = mms_pn_lookup(cmd->cmd_root, "freeslots", - MMS_PN_CLAUSE, &work)) { - mms_trace(MMS_DEBUG, "%s", "freeslots bay name"); - item = NULL; - MMS_PN_LOOKUP(value, freeslots, NULL, MMS_PN_STRING, &item); - freeslots_bay_name = value->pn_string; - - mms_trace(MMS_DEBUG, "freeslots slot type"); - MMS_PN_LOOKUP(value, freeslots, NULL, MMS_PN_STRING, &item); - freeslots_slot_type = value->pn_string; - - mms_trace(MMS_DEBUG, "freeslots num slots"); - MMS_PN_LOOKUP(value, freeslots, NULL, MMS_PN_STRING, &item); - freeslots_num_slots = atoi(value->pn_string); - - mms_trace(MMS_DEBUG, - "freeslots: %s, %s, %d", freeslots_bay_name, - freeslots_slot_type, freeslots_num_slots); - - if (scope == SCOPE_PARTIAL && - mm_db_exec(HERE, db, "SELECT \"SlotConfigNumberFree\" FROM " - "\"SLOTCONFIG\" WHERE "\ - "\"LibraryName\" = '%s' AND " - "\"LMName\" = '%s' AND \"BayName\" = '%s' AND " - "\"SlotTypeName\" = '%s';") != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (scope == SCOPE_PARTIAL) { - rows = PQntuples(db->mm_db_results); - mm_clear_db(&db->mm_db_results); - } else { - rows = 0; - } - - if (rows == 0 && mm_db_exec(HERE, db, - "INSERT INTO \"SLOTCONFIG\" " - "(\"LibraryName\", \"LMName\", " - "\"BayName\", " - "\"SlotTypeName\", " - "\"SlotConfigNumberFree\") VALUES " - "('%s', '%s', '%s', '%s', '%d');", - conn->cci_client, - conn->cci_instance, - freeslots_bay_name, - freeslots_slot_type, - freeslots_num_slots) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } else if (mm_db_exec(HERE, db, "UPDATE \"SLOTCONFIG\" SET " - "\"SlotConfigNumberFree\" = '%d' WHERE " - "\"LibraryName\" = '%s' AND "\ - "\"LMName\" = '%s' AND " - "\"BayName\" = '%s' AND "\ - "\"SlotTypeName\" = '%s';", - freeslots_num_slots, conn->cci_client, - conn->cci_instance, freeslots_bay_name, - freeslots_slot_type) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - - mms_trace(MMS_DEBUG, "delslots"); - work = NULL; - for (delslots = mms_pn_lookup(cmd->cmd_root, "delslots", - MMS_PN_CLAUSE, &work); - delslots != NULL; - delslots = mms_pn_lookup(cmd->cmd_root, "delslots", - MMS_PN_CLAUSE, &work)) { - item = NULL; - MMS_PN_LOOKUP(value, delslots, NULL, MMS_PN_STRING, &item); - delslots_slot_name = value->pn_string; - - mms_trace(MMS_DEBUG, "delslots: %s", delslots_slot_name); - - if (mm_db_exec(HERE, db, "DELETE FROM \"SLOT\" WHERE " - "\"SlotName\" = '%s' AND "\ - "\"LibraryName\" = '%s' AND " - "\"LMName\" = '%s';", delslots_slot_name, - conn->cci_client, - conn->cci_instance) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - - mms_trace(MMS_DEBUG, "perf"); - work = NULL; - for (perf = mms_pn_lookup(cmd->cmd_root, "perf", - MMS_PN_CLAUSE, &work); - perf != NULL; - perf = mms_pn_lookup(cmd->cmd_root, "perf", - MMS_PN_CLAUSE, &work)) { - item = NULL; - MMS_PN_LOOKUP(value, perf, NULL, MMS_PN_STRING, &item); - perfno = atoi(value->pn_string); - - mms_trace(MMS_DEBUG, "perf: %d", perfno); - } - - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_DONE); - -no_mem: - MM_ABORT_NO_MEM(); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - -} - -/* - * mm_lmp_private_cmd_func(mm_wka, cmd) - * - * Send private command to set, unset, or get lm attribute values. - */ -int -mm_lmp_private_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_response_t response; - - - mms_trace(MMS_DEVP, "lmp private cmd func: state=%d", - cmd->cmd_state); - - if (cmd->cmd_state == 0) { - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_textcmd); - cmd->cmd_flags |= MM_CMD_NEED_ACCEPT; - cmd->cmd_state = 1; - return (MM_ACCEPT_NEEDED); - } else if (cmd->cmd_state == 1) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_ACCEPTED) { - mms_trace(MMS_DEVP, "lmp private accepted"); - cmd->cmd_flags &= ~MM_CMD_NEED_ACCEPT; - cmd->cmd_flags |= MM_CMD_ACCEPTED; - cmd->cmd_state = 2; - return (MM_NO_DISPATCH); - } else { - mms_trace(MMS_ERR, "lmp cmd not accepted"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - } else if (cmd->cmd_state == 2) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_SUCCESS) { - mms_trace(MMS_DEVP, "lmp private success"); - cmd->cmd_remove = 1; - if (mm_has_depend(cmd)) { - return (MM_DEPEND_DONE); - } - return (MM_CMD_DONE); - } - } - - mms_trace(MMS_DEVP, "lmp private failed"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); -} - -/* - * mm_lmp_mount_cmd_func(mm_wka, cmd) - * - * Mount a cartridge on a drive. - */ -int -mm_lmp_mount_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - int rc = 0; - mm_response_t response; - mm_db_t *db = &mm_wka->mm_data->mm_db; - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - char *cart_pcl = NULL; - - mms_trace(MMS_DEVP, "lmp mount cmd func: state=%d", - cmd->cmd_state); - - if (cmd->cmd_state == 0) { - /* Check LM state before sending */ - mms_trace(MMS_DEVP, - "check lm state before sending"); - rc = mm_lm_send_ok(cmd, mm_wka); - if (rc == MM_LM_ERROR) { - mms_trace(MMS_DEVP, "Cannot send this lmp command"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } else if (rc == MM_LM_WAIT) { - mms_trace(MMS_DEVP, - "wait to send the lmp command "); - MM_SET_FLAG(cmd->cmd_flags, - MM_CMD_DISPATCHABLE); - return (MM_NO_DISPATCH); - } else if (rc == MM_LM_SEND) { - mms_trace(MMS_DEVP, - "lm send the lmp command"); - } - - - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_textcmd); - cmd->cmd_flags |= MM_CMD_NEED_ACCEPT; - cmd->cmd_state = 1; - return (MM_ACCEPT_NEEDED); - } else if (cmd->cmd_state == 1) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_ACCEPTED) { - mms_trace(MMS_DEVP, "lmp mount accepted"); - cmd->cmd_flags &= ~MM_CMD_NEED_ACCEPT; - cmd->cmd_flags |= MM_CMD_ACCEPTED; - cmd->cmd_state = 2; - return (MM_NO_DISPATCH); - } else { - mms_trace(MMS_ERR, "lmp cmd not accepted"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - } else if (cmd->cmd_state == 2) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_SUCCESS) { - mms_trace(MMS_DEVP, "lmp mount success"); - - /* Verify the drive and cartridge */ - /* states have been correctly set */ - /* should be set from the lmp partial */ - /* config that accompanies */ - /* the mount command */ - cart_pcl = mm_get_cart_pcl(cmd, - mount_info->cmi_cartridge, db); - if (mm_db_exec(HERE, db, - "select \"DriveLibraryOccupied\", " - "\"CartridgePCL\" from \"DRIVE\" " - "where \"DriveName\" = '%s';", - mount_info->cmi_drive) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "error checking drive states after mount"); - mm_sql_db_err_rsp_new(cmd, db); - free(cart_pcl); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, - "error checking drive state," - "num drives returned != 1, %d returned", - PQntuples(db->mm_db_results)); - mm_system_error(cmd, - "error checking drive state," - "num drives returned != 1, %d returned", - PQntuples(db->mm_db_results)); - mm_clear_db(&db->mm_db_results); - free(cart_pcl); - return (MM_CMD_ERROR); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), - "t") != 0) { - mms_trace(MMS_ERR, - "error checking drive state," - "DriveOccupied is not true"); - mm_system_error(cmd, - "error checking drive state," - "DriveOccupied is not true"); - mm_clear_db(&db->mm_db_results); - free(cart_pcl); - return (MM_CMD_ERROR); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 1), - cart_pcl) != 0) { - mms_trace(MMS_ERR, - "error checking drive state," - "CartridgePCL, %s != %s", - cart_pcl, - PQgetvalue(db->mm_db_results, 0, 1)); - mm_system_error(cmd, - "error checking drive state," - "CartridgePCL, %s != %s", - cart_pcl, - PQgetvalue(db->mm_db_results, 0, 1)); - mm_clear_db(&db->mm_db_results); - free(cart_pcl); - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - - - /* Update Drive and Cartridge Stats */ - rc = mm_db_exec(HERE, db, - "update \"DRIVE\" " - "set \"DriveNumberMounts\" = " - "\"DriveNumberMounts\" + 1, " - "\"DriveTimeMountedLast\" = now(), " - "\"DriveNumberMountsSinceCleaning\" " - "= \"DriveNumberMountsSinceCleaning\" + 1 " - "where \"DriveName\" = '%s';", - mount_info->cmi_drive); - if (rc != MM_DB_OK) { - mms_trace(MMS_ERR, - "db error updating stats"); - free(cart_pcl); - return (MM_CMD_ERROR); - } - - /* Update Cartridge Table */ - rc = mm_db_exec(HERE, db, - "update \"CARTRIDGE\" " \ - "set \"CartridgeTimeMountedLast\" = now(), " \ - "\"CartridgeNumberMounts\" = "\ - "\"CartridgeNumberMounts\" + 1 " \ - "where \"CartridgeID\" = '%s';", - mount_info->cmi_cartridge); - if (rc != MM_DB_OK) { - mms_trace(MMS_ERR, - "db error updating stats"); - free(cart_pcl); - return (MM_CMD_ERROR); - } - /* Update Side Table */ - rc = mm_db_exec(HERE, db, - "update \"SIDE\" " \ - "set \"SideTimeMountedLast\" = now(), "\ - "\"SideNumberMounts\" = "\ - "\"SideNumberMounts\" + 1 "\ - "where \"CartridgeID\" = '%s';", - mount_info->cmi_cartridge); - if (rc != MM_DB_OK) { - mms_trace(MMS_ERR, - "db error updating stats"); - free(cart_pcl); - return (MM_CMD_ERROR); - } - /* Update Partition Table */ - rc = mm_db_exec(HERE, db, - "update \"PARTITION\" "\ - "set \"PartitionNumberMounts\" = "\ - "\"PartitionNumberMounts\" + 1, "\ - "\"PartitionTimeMountedLast\" = now() "\ - "where \"CartridgeID\" = '%s';", - mount_info->cmi_cartridge); - if (rc != MM_DB_OK) { - mms_trace(MMS_ERR, - "db error updating stats"); - free(cart_pcl); - return (MM_CMD_ERROR); - } - /* Update Volume Table */ - rc = mm_db_exec(HERE, db, - "update \"VOLUME\" "\ - "set \"VolumeNumberMounts\" = "\ - "\"VolumeNumberMounts\" + 1, "\ - "\"VolumeTimeMountedLast\" = now() "\ - "where \"CartridgeID\" = '%s';", - mount_info->cmi_cartridge); - if (rc != MM_DB_OK) { - mms_trace(MMS_ERR, - "db error updating stats"); - free(cart_pcl); - return (MM_CMD_ERROR); - } - - free(cart_pcl); - cmd->cmd_remove = 1; - if (mm_has_depend(cmd)) { - return (MM_DEPEND_DONE); - } - return (MM_CMD_DONE); - } - } - - mms_trace(MMS_DEVP, "lmp mount failed"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); -} - -/* - * mm_lmp_unmount_cmd_func(mm_wka, cmd) - * - * Unmount cartridge from drive. - */ -int -mm_lmp_unmount_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - int rc = 0; - mm_response_t response; - mm_db_t *db = &mm_wka->mm_data->mm_db; - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - mms_trace(MMS_DEVP, "lmp unmount cmd func: state=%d", - cmd->cmd_state); - - if (cmd->cmd_state == 0) { - /* Check LM state before sending */ - mms_trace(MMS_DEVP, - "check lm state before sending"); - rc = mm_lm_send_ok(cmd, mm_wka); - if (rc == MM_LM_ERROR) { - mms_trace(MMS_DEVP, "Cannot send this lmp command"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } else if (rc == MM_LM_WAIT) { - mms_trace(MMS_DEVP, - "wait to send the lmp command "); - MM_SET_FLAG(cmd->cmd_flags, - MM_CMD_DISPATCHABLE); - return (MM_NO_DISPATCH); - } else if (rc == MM_LM_SEND) { - mms_trace(MMS_DEVP, - "lm send the lmp command"); - } - - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_textcmd); - cmd->cmd_flags |= MM_CMD_NEED_ACCEPT; - cmd->cmd_state = 1; - return (MM_ACCEPT_NEEDED); - } else if (cmd->cmd_state == 1) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_ACCEPTED) { - mms_trace(MMS_DEVP, "lmp unmount accepted"); - cmd->cmd_flags &= ~MM_CMD_NEED_ACCEPT; - cmd->cmd_flags |= MM_CMD_ACCEPTED; - cmd->cmd_state = 2; - return (MM_NO_DISPATCH); - } else { - mms_trace(MMS_ERR, "lmp cmd not accepted"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - } else if (cmd->cmd_state == 2) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_SUCCESS) { - mms_trace(MMS_DEVP, "lmp unmount success"); - - /* Verify the drive and cartridge */ - /* states have been correctly set */ - /* should be set from the lmp partial */ - /* config that accompanies */ - /* the mount command */ - if (mm_db_exec(HERE, db, - "select \"DriveLibraryOccupied\", " - "\"CartridgePCL\" from \"DRIVE\" " - "where \"DriveName\" = '%s';", - mount_info->cmi_drive) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "error checking drive states after mount"); - mm_sql_db_err_rsp_new(cmd, db); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, - "error checking drive state," - "num drives returned != 1, %d returned", - PQntuples(db->mm_db_results)); - mm_system_error(cmd, - "error checking drive state," - "num drives returned != 1, %d returned", - PQntuples(db->mm_db_results)); - mm_clear_db(&db->mm_db_results); - return (MM_CMD_ERROR); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), - "f") != 0) { - mms_trace(MMS_ERR, - "error checking drive state," - "DriveOccupied is not true"); - mm_system_error(cmd, - "error checking drive state," - "DriveOccupied is not true"); - mm_clear_db(&db->mm_db_results); - return (MM_CMD_ERROR); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 1), - "") != 0) { - mms_trace(MMS_ERR, - "error checking drive state," - "CartridgePCL, %s != NULL", - PQgetvalue(db->mm_db_results, 0, 1)); - mm_system_error(cmd, - "error checking drive state," - "CartridgePCL, %s != NULL", - PQgetvalue(db->mm_db_results, 0, 1)); - mm_clear_db(&db->mm_db_results); - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - cmd->cmd_remove = 1; - if (mm_has_depend(cmd)) { - return (MM_DEPEND_DONE); - } - return (MM_CMD_DONE); - } - } - - mms_trace(MMS_DEVP, "lmp unmount failed"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); -} - -/* - * mm_lmp_inject_cmd_func(mm_wka, cmd) - * - * Inject (import) cartridge from mailslot (cap). - */ -int -mm_lmp_inject_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_response_t response; - mm_db_t *db = &mm_wka->mm_data->mm_db; - - mms_par_node_t *arg = NULL; - mms_par_node_t *work = NULL; - - mms_par_node_t *cart_pcl = NULL; - - mms_trace(MMS_DEVP, "lmp inject cmd func: state=%d", - cmd->cmd_state); - - if (cmd->cmd_state == 0) { - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_textcmd); - cmd->cmd_flags |= MM_CMD_NEED_ACCEPT; - cmd->cmd_state = 1; - return (MM_ACCEPT_NEEDED); - } else if (cmd->cmd_state == 1) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_ACCEPTED) { - mms_trace(MMS_DEVP, "lmp inject accepted"); - cmd->cmd_flags &= ~MM_CMD_NEED_ACCEPT; - cmd->cmd_flags |= MM_CMD_ACCEPTED; - cmd->cmd_state = 2; - return (MM_NO_DISPATCH); - } else { - mms_trace(MMS_ERR, "lmp cmd not accepted"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - } else if (cmd->cmd_state == 2) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_SUCCESS) { - mms_trace(MMS_DEVP, "lmp inject success"); - /* Add eject event for all injected cartridges */ - arg = mms_pn_lookup(cmd->cmd_response, "text", - MMS_PN_CLAUSE, 0); - if (arg != NULL) { - mms_trace(MMS_INFO, - "Injected Cartridges:"); - while ((cart_pcl = mms_pn_lookup(arg, NULL, - MMS_PN_STRING, &work)) != NULL) { - /* Add event for this cartridge here */ - mms_trace(MMS_INFO, - " %s", - cart_pcl->pn_string); - if (mm_notify_add_volumeinject(mm_wka, - cmd, - cart_pcl->pn_string, - db)) { - mms_trace(MMS_ERR, - "mm_lmp_inject_cmd_func: " - "error adding volume " - "inject event"); - } - } - } - - cmd->cmd_remove = 1; - if (mm_has_depend(cmd)) { - return (MM_DEPEND_DONE); - } - return (MM_CMD_DONE); - } - } - - mms_trace(MMS_DEVP, "lmp inject failed"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); -} - -/* - * mm_lmp_eject_cmd_func(mm_wka, cmd) - * - * Eject (export) cartridge from mailslot (cap). - */ -int -mm_lmp_eject_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - mm_response_t response; - - mms_par_node_t *arg = NULL; - mms_par_node_t *work = NULL; - - mms_par_node_t *cart_pcl = NULL; - - - mms_trace(MMS_DEVP, "lmp eject cmd func: state=%d", - cmd->cmd_state); - - if (cmd->cmd_state == 0) { - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_textcmd); - cmd->cmd_flags |= MM_CMD_NEED_ACCEPT; - cmd->cmd_state = 1; - return (MM_ACCEPT_NEEDED); - } else if (cmd->cmd_state == 1) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_ACCEPTED) { - mms_trace(MMS_DEVP, "lmp eject accepted"); - cmd->cmd_flags &= ~MM_CMD_NEED_ACCEPT; - cmd->cmd_flags |= MM_CMD_ACCEPTED; - cmd->cmd_state = 2; - return (MM_NO_DISPATCH); - } else { - mms_trace(MMS_ERR, "lmp cmd not accepted"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - } else if (cmd->cmd_state == 2) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_SUCCESS) { - mms_trace(MMS_DEVP, "lmp eject success"); - mms_trace(MMS_DEVP, "Looking up arg's"); - /* Add eject event for all ejected cartridges */ - arg = mms_pn_lookup(cmd->cmd_response, "text", - MMS_PN_CLAUSE, 0); - if (arg != NULL) { - mms_trace(MMS_INFO, - "Ejected Cartridges:"); - while ((cart_pcl = mms_pn_lookup(arg, NULL, - MMS_PN_STRING, &work)) != NULL) { - /* Add event for this cartridge here */ - mms_trace(MMS_INFO, - " %s", - cart_pcl->pn_string); - if (mm_notify_add_volumeeject(mm_wka, - cmd, - cart_pcl->pn_string, - db)) { - mms_trace(MMS_ERR, - "mm_lmp_eject_cmd_func: " - "error adding volume " - "eject event"); - } - } - } - - cmd->cmd_remove = 1; - if (mm_has_depend(cmd)) { - return (MM_DEPEND_DONE); - } - return (MM_CMD_DONE); - } - } - - mms_trace(MMS_DEVP, "lmp eject failed"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); -} - -/* - * mm_lmp_cpscan_cmd_func(mm_wka, cmd) - * - * Scan the robot. - */ -int -mm_lmp_scan_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - int rc = 0; - mm_response_t response; - - - if (mm_wka->mm_wka_mm_lang != MM_LANG_LMP) { - mms_trace(MMS_ERR, - "lmp scan sent to non-lmp client"); - return (MM_CMD_ERROR); - } - - mms_trace(MMS_DEVP, "lmp scan cmd func: state=%d", - cmd->cmd_state); - - if (cmd->cmd_state == 0) { - - /* Check LM state before sending */ - mms_trace(MMS_DEVP, - "check lm state before sending"); - rc = mm_lm_send_ok(cmd, mm_wka); - if (rc == MM_LM_ERROR) { - mms_trace(MMS_DEVP, "Cannot send this lmp command"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } else if (rc == MM_LM_WAIT) { - mms_trace(MMS_DEVP, - "wait to send the lmp command "); - MM_SET_FLAG(cmd->cmd_flags, - MM_CMD_DISPATCHABLE); - return (MM_NO_DISPATCH); - } else if (rc == MM_LM_SEND) { - mms_trace(MMS_DEVP, - "lm send the lmp command"); - } - - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_textcmd); - cmd->cmd_flags |= MM_CMD_NEED_ACCEPT; - cmd->cmd_state = 1; - return (MM_ACCEPT_NEEDED); - } else if (cmd->cmd_state == 1) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_ACCEPTED) { - mms_trace(MMS_DEVP, "lmp scan accepted"); - cmd->cmd_flags &= ~MM_CMD_NEED_ACCEPT; - cmd->cmd_flags |= MM_CMD_ACCEPTED; - cmd->cmd_state = 2; - return (MM_NO_DISPATCH); - } else { - mms_trace(MMS_ERR, "lmp cmd not accepted"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - } else if (cmd->cmd_state == 2) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_SUCCESS) { - mms_trace(MMS_DEVP, "lmp scan success"); - cmd->cmd_remove = 1; - if (mm_has_depend(cmd)) { - return (MM_DEPEND_DONE); - } - return (MM_CMD_DONE); - } - } - - mms_trace(MMS_DEVP, "lmp scan failed"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); -} - -int -mm_lmp_cancel_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *value = NULL; - mms_par_node_t *arg = NULL; - mm_data_t *data = mm_wka->mm_data; - char *taskid = NULL; - mm_db_t *db = &mm_wka->mm_data->mm_db; - mm_command_t *cmd_p = NULL; - mm_command_t *cmd_q = NULL; - char *cmd_name = NULL; - uuid_text_t cmd_reqid; - - mms_trace(MMS_DEBUG, "mm_lmp_cancel_cmd_func"); - - MMS_PN_LOOKUP(arg, cmd->cmd_root, "whichtask", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, arg, NULL, MMS_PN_STRING, NULL); - taskid = value->pn_string; - - pthread_mutex_lock(&data->mm_queue_mutex); - mms_list_foreach(&data->mm_cmd_queue, cmd_p) { - if (strcmp(cmd_p->wka_ptr->wka_conn.cci_uuid, - cmd->wka_ptr->wka_conn.cci_uuid) == 0 && - strcmp(cmd_p->cmd_task, taskid) == 0) { - - /* is this a command we know how to cancel */ - if (strcmp(mms_pn_token(cmd_p->cmd_root), - "request") == 0) { - cmd_name = strdup("request"); - strcpy(cmd_reqid, cmd_p->cmd_reqid); - } - break; - } - } - pthread_mutex_unlock(&data->mm_queue_mutex); - - /* command not found */ - if (cmd_p == NULL) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_INVALID) + strlen(ELM_E_NOTASK) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INVALID, ELM_E_NOTASK); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - /* cancel command */ - if (strcmp(cmd_name, "request") == 0) { - free(cmd_name); - if (mm_db_exec(HERE, db, "select \"RequestState\" " - "from \"REQUEST\" where \"RequestID\" = '%s';", - cmd_reqid) != MM_DB_DATA || - PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + - strlen(cmd->cmd_task) + - strlen(ECLASS_INTERNAL) + - strlen(EDATABASE) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, - cmd->cmd_task, ECLASS_INTERNAL, EDATABASE); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), - "responded") == 0) { - mm_clear_db(&db->mm_db_results); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + - strlen(cmd->cmd_task) + - strlen(ECLASS_INVALID) + - strlen(ELM_E_NOCANC) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, - cmd->cmd_task, - ECLASS_INVALID, ELM_E_NOCANC); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - - /* remove the request */ - if (mm_db_exec(HERE, db, "delete from \"REQUEST\" where " - "\"RequestID\" = '%s';", cmd_reqid) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + - strlen(cmd->cmd_task) + - strlen(ECLASS_INTERNAL) + - strlen(EDATABASE) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, - cmd->cmd_task, ECLASS_INTERNAL, EDATABASE); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - } else { - free(cmd_name); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_INVALID) + strlen(ELM_E_NOCANC) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INVALID, ELM_E_NOCANC); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - /* send cancelled command's final-command response */ - pthread_mutex_lock(&data->mm_queue_mutex); - mms_list_foreach(&data->mm_cmd_queue, cmd_q) { - if (cmd_q == cmd_p) { - /* send cancelled command response */ - SQL_CHK_LEN(&cmd_p->cmd_buf, 0, - &cmd_p->cmd_bufsize, - strlen(RESPONSE_CANCELLED) + - strlen(cmd_p->cmd_task) + 1); - (void) snprintf(cmd_p->cmd_buf, cmd_p->cmd_bufsize, - RESPONSE_CANCELLED, cmd_p->cmd_task); - mm_send_text(mm_wka->mm_wka_conn, - cmd_p->cmd_buf); - cmd_p->cmd_remove = 1; - break; - } - } - pthread_mutex_unlock(&data->mm_queue_mutex); - - /* same command not found or error sending cancelled response */ - if (cmd_q == NULL) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_INVALID) + strlen(ELM_E_NOTASK) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INVALID, ELM_E_NOTASK); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_DONE); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -} - -int -mm_lmp_reset_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - cci_t *conn = &mm_wka->wka_conn; - mm_response_t response; - - - mms_trace(MMS_DEBUG, - "lmp reset state %d, %s", - cmd->cmd_state, - cmd->cmd_textcmd); - - if (cmd->cmd_state == 0) { - mms_trace(MMS_INFO, - "Issuing reset for %s %s", - conn->cci_instance, - conn->cci_client); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_textcmd); - cmd->cmd_flags |= MM_CMD_NEED_ACCEPT; - cmd->cmd_state = 1; - return (MM_ACCEPT_NEEDED); - } else if (cmd->cmd_state == 1) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_ACCEPTED) { - mms_trace(MMS_DEVP, "lmp reset accepted"); - cmd->cmd_flags &= ~MM_CMD_NEED_ACCEPT; - cmd->cmd_flags |= MM_CMD_ACCEPTED; - cmd->cmd_state = 2; - return (MM_NO_DISPATCH); - } else { - mms_trace(MMS_ERR, "lmp cmd not accepted"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - } else if (cmd->cmd_state == 2) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_SUCCESS) { - mms_trace(MMS_DEVP, "lmp reset success"); - cmd->cmd_remove = 1; - return (MM_DEPEND_DONE); - } - } - - mms_trace(MMS_DEVP, "lmp reset failed"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); -} - -int -mm_lmp_exit_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - cci_t *conn = &mm_wka->wka_conn; - mm_response_t response; - - - mms_trace(MMS_DEBUG, - "lmp exit state %d, %s", - cmd->cmd_state, - cmd->cmd_textcmd); - - if (cmd->cmd_state == 0) { - mms_trace(MMS_INFO, - "Issuing exit for %s %s", - conn->cci_instance, - conn->cci_client); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_textcmd); - cmd->cmd_flags |= MM_CMD_NEED_ACCEPT; - cmd->cmd_state = 1; - return (MM_ACCEPT_NEEDED); - } else if (cmd->cmd_state == 1) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_ACCEPTED) { - mms_trace(MMS_DEVP, "lmp exit accepted"); - cmd->cmd_flags &= ~MM_CMD_NEED_ACCEPT; - cmd->cmd_flags |= MM_CMD_ACCEPTED; - cmd->cmd_state = 2; - return (MM_NO_DISPATCH); - } else { - mms_trace(MMS_ERR, "lmp cmd not accepted"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - } else if (cmd->cmd_state == 2) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_SUCCESS) { - mms_trace(MMS_DEVP, "lmp exit success"); - cmd->cmd_remove = 1; - return (MM_DEPEND_DONE); - } - } - - mms_trace(MMS_DEVP, "lmp exit failed"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); -} diff --git a/usr/src/cmd/mms/mm/common/mm_mmp_cp.c b/usr/src/cmd/mms/mm/common/mm_mmp_cp.c deleted file mode 100644 index 8435b1363e..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_mmp_cp.c +++ /dev/null @@ -1,1250 +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 <stdlib.h> -#include <string.h> -#include <errno.h> -#include <pthread.h> -#include <syslog.h> -#include <mms_list.h> -#include <mms_parser.h> -#include <mms_par_impl.h> -#include <libpq-fe.h> -#include <mms_trace.h> -#include <mms_strapp.h> -#include "mm_db.h" -#include "mm.h" -#include "mm_util.h" -#include "mm_commands.h" -#include "mm_sql.h" -#include "mm_sql_impl.h" -#include "mm_task.h" -#include "mm_path.h" - - - -static char *_SrcFile = __FILE__; - -extern mm_privilege_t mm_privileged(mm_wka_t *mm_wka, mm_command_t *cmd); - - -int -mm_cpexit_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *arg; - mms_par_node_t *value; - char *type; - int rows; - PGresult *dev_results; - int rc; - uuid_text_t task; - char *dev_name; - char *mgr_name; - mm_db_t *db = &mm_wka->mm_data->mm_db; - mm_wka_t *mgr_wka = NULL; - mm_data_t *data = mm_wka->mm_data; - mm_command_t *exit_cmd; - char *query; - char *host; - char *disabled; - - mms_trace(MMS_DEVP, "mm cpexit command, state %d", cmd->cmd_state); - if (cmd->cmd_state == 1) { - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - char *response_message = NULL; - mms_trace(MMS_DEVP, "device manager exit failed"); - response_message = - mm_ret_response_msg(cmd); - mm_response_error(cmd, - ECLASS_SUBOP, - ELMDMCOMMUNICATION, - MM_5055_MSG, - "msg_rsp", response_message, - NULL); - free(response_message); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - - } - - mms_trace(MMS_INFO, "Device Manager exit success"); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_DONE); - - } - - if (mm_privileged(mm_wka, cmd) == MM_PRIV_STANDARD) { - return (MM_CMD_ERROR); - } - - /* device type */ - MMS_PN_LOOKUP(arg, cmd->cmd_root, "cptype", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, arg, NULL, MMS_PN_KEYWORD, NULL); - type = value->pn_string; - - - /* find device manager */ - (void) mm_get_dest(mm_wka, cmd); - (void) mm_get_const(mm_wka, cmd); - if (strcmp(type, "DM") == 0) { - if (mm_add_char("DM", &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_cpexit_cmd_func: " - "out of mem creating source list"); - mm_system_error(cmd, - "out of mem creating source list"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - query = "select distinct " - "\"DM\".\"DriveName\",\"DM\".\"DMName\"," - "\"DM\".\"DMTargetHost\",\"DM\".\"DMDisabled\" from "; - } else { - if (mm_add_char("LM", &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_cpexit_cmd_func: " - "out of mem creating source list"); - mm_system_error(cmd, - "out of mem creating source list"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - query = "select distinct " - "\"LM\".\"LibraryName\",\"LM\".\"LMName\"," - "\"LM\".\"LMTargetHost\",\"LM\".\"LMDisabled\" from "; - } - cmd->cmd_source_num = 1; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, strlen(query) + 1); - strcpy(cmd->cmd_buf, query); - if (mm_sql_from_where(cmd, db)) { - mms_trace(MMS_ERR, - "mm_cpexit_cmd_func: " - "db error creating helper functions"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mm_sql_order(cmd); - mm_sql_number(cmd); - - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_DATA) { - goto db_error; - } - rows = PQntuples(db->mm_db_results); - if (rows == 0) { - mm_clear_db(&db->mm_db_results); - mm_response_error(cmd, - ECLASS_EXPLICIT, - ENOMATCH, - MM_5079_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } else if (rows > 1) { - /* Can only have 1 dev manager */ - mm_clear_db(&db->mm_db_results); - mm_response_error(cmd, - ECLASS_EXPLICIT, - ETOOMANY, - MM_5076_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - dev_results = db->mm_db_results; - - dev_name = PQgetvalue(dev_results, 0, 0); - mgr_name = PQgetvalue(dev_results, 0, 1); - host = PQgetvalue(dev_results, 0, 2); - disabled = PQgetvalue(dev_results, 0, 3); - - /* - * Disable device manager - */ - if (strcmp(disabled, "false") == 0) { - if (strcmp(type, "DM") == 0) { - rc = mm_db_exec(HERE, db, "update \"DM\" " - "set \"DMDisabled\" = 'true' " - "where \"DriveName\" = '%s' and " - "\"DMName\" = '%s';", - dev_name, mgr_name); - } else { - rc = mm_db_exec(HERE, db, "update \"LM\" " - "set \"LMDisabled\" = 'true' " - "where \"LibraryName\" = '%s' and " - "\"LMName\" = '%s';", - dev_name, mgr_name); - } - if (rc != MM_DB_OK) { - goto db_error; - } - - } - - /* - * Check for connection - */ - mms_list_foreach(&data->mm_wka_list, mgr_wka) { - if ((strcmp(mgr_wka->wka_conn.cci_instance, - mgr_name) == 0) && - (strcmp(mgr_wka->wka_conn.cci_client, - dev_name) == 0)) { - /* Found the wka of dev manager */ - break; - } - } - if (mgr_wka == NULL) { - mms_trace(MMS_INFO, "Device Manager exit success"); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_DONE); - } - - /* Allocate command and add to the queue */ - - /* - * exit command - */ - if ((exit_cmd = mm_alloc_cmd(mgr_wka)) == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_command_t: %s", - strerror(errno)); - return (1); - } - if (strcmp(type, "DM") == 0) { - exit_cmd->cmd_func = mm_dmp_exit_cmd_func; - } else { - exit_cmd->cmd_func = mm_lmp_exit_cmd_func; - } - mm_get_uuid(task); - exit_cmd->cmd_textcmd = mms_strnew("exit task[\"%s\"];", task); - - mms_trace(MMS_DEVP, "%s", exit_cmd->cmd_textcmd); - if (strcmp(type, "DM") == 0) { - exit_cmd->cmd_root = - mm_text_to_par_node(exit_cmd->cmd_textcmd, - mms_dmpm_parse); - exit_cmd->cmd_name = strdup("dmp exit"); - } else { - exit_cmd->cmd_root = - mm_text_to_par_node(exit_cmd->cmd_textcmd, - mms_lmpm_parse); - exit_cmd->cmd_name = strdup("lmp exit"); - } - exit_cmd->cmd_task = mms_strapp(exit_cmd->cmd_task, - task); - mm_add_depend(exit_cmd, cmd); - - pthread_mutex_lock(&mm_wka->mm_data->mm_queue_mutex); - mms_list_insert_tail(&mm_wka->mm_data->mm_cmd_queue, exit_cmd); - pthread_mutex_unlock(&mm_wka->mm_data->mm_queue_mutex); - - mm_clear_db(&dev_results); - - - /* - * Notify watcher - */ - if (mm_notify_add_config(mm_wka, cmd, "disable", - type, mgr_name, host)) { - mm_system_error(cmd, - "failed to add config " - "event for watcher"); - mm_clear_db(&dev_results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - - cmd->cmd_state = 1; - mms_trace(MMS_DEBUG, - "added exit command for %s %s", - mgr_name, dev_name); - - return (MM_DISPATCH_DEPEND); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - -db_error: - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - return (rc); -} - - - -int -mm_cpstart_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *arg; - mms_par_node_t *value; - char *type; - int rows; - PGresult *dev_results; - int rc; - char *dev_name; - char *mgr_name; - mm_db_t *db = &mm_wka->mm_data->mm_db; - char *query; - char *host; - char *disabled; - char *state_soft; - char *state_hard; - - mms_trace(MMS_DEVP, "mm cpstart command"); - - if (mm_privileged(mm_wka, cmd) == MM_PRIV_STANDARD) { - return (MM_CMD_ERROR); - } - - /* device type */ - MMS_PN_LOOKUP(arg, cmd->cmd_root, "cptype", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, arg, NULL, MMS_PN_KEYWORD, NULL); - type = value->pn_string; - - - /* find device manager */ - (void) mm_get_dest(mm_wka, cmd); - (void) mm_get_const(mm_wka, cmd); - if (strcmp(type, "DM") == 0) { - if (mm_add_char("DM", &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_cpstart_cmd_func: " - "out of mem creating source list"); - mm_system_error(cmd, - "out of mem creating source list"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - query = "select distinct " - "\"DM\".\"DriveName\",\"DM\".\"DMName\"," - "\"DM\".\"DMTargetHost\",\"DM\".\"DMDisabled\", " - "\"DM\".\"DMStateSoft\",\"DM\".\"DMStateHard\" from "; - } else { - if (mm_add_char("LM", &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_cpstart_cmd_func: " - "out of mem creating source list"); - mm_system_error(cmd, - "out of mem creating source list"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - query = "select distinct " - "\"LM\".\"LibraryName\",\"LM\".\"LMName\"," - "\"LM\".\"LMTargetHost\",\"LM\".\"LMDisabled\", " - "\"LM\".\"LMStateSoft\",\"LM\".\"LMStateHard\" from "; - } - cmd->cmd_source_num = 1; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, strlen(query) + 1); - strcpy(cmd->cmd_buf, query); - if (mm_sql_from_where(cmd, db)) { - mms_trace(MMS_ERR, - "mm_cpstart_cmd_func: " - "db error creating helper functions"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mm_sql_order(cmd); - mm_sql_number(cmd); - - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_DATA) { - goto db_error; - } - rows = PQntuples(db->mm_db_results); - if (rows == 0) { - mm_clear_db(&db->mm_db_results); - mm_response_error(cmd, - ECLASS_EXPLICIT, - ENOMATCH, - MM_5079_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } else if (rows > 1) { - /* Can only have 1 dev manager */ - mm_clear_db(&db->mm_db_results); - mm_response_error(cmd, - ECLASS_EXPLICIT, - ETOOMANY, - MM_5076_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - dev_results = db->mm_db_results; - - dev_name = PQgetvalue(dev_results, 0, 0); - mgr_name = PQgetvalue(dev_results, 0, 1); - host = PQgetvalue(dev_results, 0, 2); - disabled = PQgetvalue(dev_results, 0, 3); - state_soft = PQgetvalue(dev_results, 0, 4); - state_hard = PQgetvalue(dev_results, 0, 5); - - if ((strcmp(disabled, "false") == 0) && - (strcmp(state_soft, "absent") != 0)) { - /* manager is already enabled + connected */ - mms_trace(MMS_DEVP, "device manager already " - "enabled and connected"); - mm_write_success(cmd, - "%s is already enabled and connected", - mgr_name); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - mm_clear_db(&dev_results); - return (MM_CMD_DONE); - } - - /* - * Clear broken state - */ - if (strcmp(state_hard, "broken") == 0) { - if (strcmp(type, "DM") == 0) { - rc = mm_db_exec(HERE, db, "update \"DM\" " - "set \"DMStateHard\" = 'ready' " - "where \"DriveName\" = '%s' and " - "\"DMName\" = '%s';", - dev_name, mgr_name); - } else { - rc = mm_db_exec(HERE, db, "update \"LM\" " - "set \"LMStateHard\" = 'ready' " - "where \"LibraryName\" = '%s' and " - "\"LMName\" = '%s';", - dev_name, mgr_name); - } - if (rc != MM_DB_OK) { - goto db_error; - } - } - - /* - * Enable device manager - */ - if (strcmp(disabled, "true") == 0) { - if (strcmp(type, "DM") == 0) { - rc = mm_db_exec(HERE, db, "update \"DM\" " - "set \"DMDisabled\" = 'false' " - "where \"DriveName\" = '%s' and " - "\"DMName\" = '%s';", - dev_name, mgr_name); - } else { - rc = mm_db_exec(HERE, db, "update \"LM\" " - "set \"LMDisabled\" = 'false' " - "where \"LibraryName\" = '%s' and " - "\"LMName\" = '%s';", - dev_name, mgr_name); - } - if (rc != MM_DB_OK) { - goto db_error; - } - if (strcmp(state_soft, "absent") != 0) { - mms_trace(MMS_DEVP, "disabled device manager " - "is already connected, %s", - mgr_name); - mm_write_success(cmd, - "disabled device manager " - "is already connected, %s", - mgr_name); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - mm_clear_db(&dev_results); - return (MM_CMD_DONE); - } - /* - * Notify watcher - */ - if (mm_notify_add_config(mm_wka, cmd, - "enable", - type, mgr_name, host)) { - mm_system_error(cmd, - "failed to add config " - "enable event"); - mm_clear_db(&dev_results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - - mms_trace(MMS_INFO, "Notified watcher that " - "device manager should be started, %s", - mgr_name); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - - mm_clear_db(&dev_results); - return (MM_CMD_DONE); - } - if ((strcmp(disabled, "false") == 0) && - (strcmp(state_soft, "absent") == 0)) { - mms_trace(MMS_INFO, - "manager is enabled but not connecetd," - " notify watcher to restart, %s", - mgr_name); - /* - * Notify watcher - */ - if (mm_notify_add_config(mm_wka, cmd, - "enable", - type, mgr_name, host)) { - mm_system_error(cmd, - "failed to add config " - "enable event"); - mm_clear_db(&dev_results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - - mms_trace(MMS_INFO, "Notified watcher that " - "device manager should be started, %s", - mgr_name); - mm_write_success(cmd, - "%s is already enabled but not connected, " - "attempting to restart", - mgr_name); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - mm_clear_db(&dev_results); - return (MM_CMD_DONE); - } - - - mm_clear_db(&dev_results); - - mms_trace(MMS_INFO, "Device Manager start success"); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_DONE); - - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - -db_error: - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - return (rc); -} - - - -int -mm_cpscan_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *arg; - mms_par_node_t *value; - char *fromslot; - char *toslot; - char *drive_name; - char *slot_name; - int slot = 0; - int drive = 0; - int range = 0; /* all slots */ - int rows; - PGresult *lm_results; - uuid_text_t lm_task; - char *lib_name; - char *lm_name; - mm_db_t *db = &mm_wka->mm_data->mm_db; - mm_command_t *lmp_scan_cmd; - const char *query; - mm_wka_t *lm_wka; - int rc; - - - mms_trace(MMS_DEVP, "mm cpscan command %d", cmd->cmd_state); - - if (cmd->cmd_state == 0) { - if (mm_privileged(mm_wka, cmd) == MM_PRIV_STANDARD) { - return (MM_CMD_ERROR); - } - - /* slot range */ - if (arg = mms_pn_lookup(cmd->cmd_root, "fromslot", - MMS_PN_CLAUSE, NULL)) { - MMS_PN_LOOKUP(value, arg, NULL, - MMS_PN_STRING, NULL); - fromslot = value->pn_string; - MMS_PN_LOOKUP(arg, cmd->cmd_root, "toslot", - MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, arg, NULL, - MMS_PN_STRING, NULL); - toslot = value->pn_string; - range = 1; - } - /* single slot */ - if (arg = mms_pn_lookup(cmd->cmd_root, "slot", - MMS_PN_CLAUSE, NULL)) { - MMS_PN_LOOKUP(value, arg, NULL, - MMS_PN_STRING, NULL); - slot_name = value->pn_string; - slot = 1; - } - /* single drive */ - if (arg = mms_pn_lookup(cmd->cmd_root, "drive", - MMS_PN_CLAUSE, NULL)) { - MMS_PN_LOOKUP(value, arg, NULL, - MMS_PN_STRING, NULL); - drive_name = value->pn_string; - drive = 1; - } - - /* find lm */ - - (void) mm_get_dest(mm_wka, cmd); - (void) mm_get_const(mm_wka, cmd); - if (mm_add_char("LM", &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_cpscan_cmd_func: " - "out of mem creating source list"); - mm_system_error(cmd, - "out of mem creating source list"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - cmd->cmd_source_num = 1; - query = "select \"LM\".\"LibraryName\"," - "\"LM\".\"LMName\" from "; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(query) + 1); - strcpy(cmd->cmd_buf, query); - if (mm_sql_from_where(cmd, db)) { - mms_trace(MMS_ERR, - "mm_cpscan_cmd_func: " - "db error creating helper functions"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - mm_sql_order(cmd); - mm_sql_number(cmd); - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&db->mm_db_results); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - if ((rows = PQntuples(db->mm_db_results)) == 0) { - mm_clear_db(&db->mm_db_results); - mm_response_error(cmd, - ECLASS_CONFIG, - ELIBNOLMCONFIGURED, - MM_5080_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } else if (rows > 1) { - mm_clear_db(&db->mm_db_results); - mm_response_error(cmd, - ECLASS_EXPLICIT, - ETOOMANY, - MM_5076_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - lm_results = db->mm_db_results; - lib_name = PQgetvalue(lm_results, 0, 0); - lm_name = PQgetvalue(lm_results, 0, 1); - - /* check for library ready and online */ - if (mm_db_exec(HERE, db, "SELECT " - "\"LIBRARY\".\"LibraryStateSoft\"," - "\"LM\".\"LMStateSoft\"," - "\"LIBRARY\".\"LibraryOnline\" " - "FROM \"LIBRARY\",\"LM\" " - "WHERE (\"LIBRARY\".\"LibraryName\" = '%s' AND " - "\"LIBRARY\".\"LMName\" = '%s') AND " - "(\"LM\".\"LibraryName\" = '%s' AND " - "\"LM\".\"LMName\" = '%s')", - lib_name, lm_name, lib_name, lm_name) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&db->mm_db_results); - mm_clear_db(&lm_results); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) == 0) { - mm_response_error(cmd, - ECLASS_CONFIG, - ELIBNOLMCONFIGURED, - MM_5021_MSG, - "lm", - lm_name, - NULL); - mm_clear_db(&db->mm_db_results); - mm_clear_db(&lm_results); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), - "ready") != 0 || - strcmp(PQgetvalue(db->mm_db_results, 0, 1), - "ready") != 0 || - strcmp(PQgetvalue(db->mm_db_results, 0, 2), - "true") != 0) { - mms_trace(MMS_DEVP, "%s %s - %s %s %s", lib_name, - lm_name, - PQgetvalue(db->mm_db_results, 0, 0), - PQgetvalue(db->mm_db_results, 0, 1), - PQgetvalue(db->mm_db_results, 0, 2)); - mm_response_error(cmd, - ECLASS_RETRY, - ELMNOTREADY, - MM_5021_MSG, - "lm", - lm_name, - NULL); - mm_clear_db(&db->mm_db_results); - mm_clear_db(&lm_results); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - - /* begin lm scan command */ - mm_get_uuid(lm_task); - - if (range) { /* build lm scan cmd */ - /* scan part of slots */ - query = "scan task[\"%s\"] fromslot[\"%s\"] " - "toslot[\"%s\"];"; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(query) + strlen(lm_task) + - strlen(fromslot) + strlen(toslot) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - query, - lm_task, fromslot, toslot); - } else if (slot) { - /* single slot */ - query = "scan task[\"%s\"] slot[\"%s\"];"; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(query) + strlen(lm_task) + - strlen(slot_name) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - query, - lm_task, slot_name); - } else if (drive) { - /* single drive */ - query = "scan task[\"%s\"] drive[\"%s\"];"; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(query) + strlen(lm_task) + - strlen(drive_name) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - query, - lm_task, drive_name); - } else { - /* scan all slots */ - query = "scan task[\"%s\"] all;"; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(query) + strlen(lm_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - query, lm_task); - } - - mms_trace(MMS_DEVP, "Adding lmp scan command"); - - /* - * LMP scan command - */ - lm_wka = mm_library_lm_wka(cmd->wka_ptr->mm_data, - lib_name, NULL); - - - - lmp_scan_cmd = mm_alloc_cmd(lm_wka); - lmp_scan_cmd->cmd_func = mm_lmp_scan_cmd_func; - lmp_scan_cmd->cmd_textcmd = strdup(cmd->cmd_buf); - lmp_scan_cmd->cmd_root = - mm_text_to_par_node(lmp_scan_cmd->cmd_textcmd, - mms_lmpm_parse); - lmp_scan_cmd->cmd_task = mm_get_task(lmp_scan_cmd->cmd_root); - lmp_scan_cmd->cmd_flags |= MM_CMD_DISPATCHABLE; - lmp_scan_cmd->cmd_language = MM_LANG_LMP; - lmp_scan_cmd->cmd_name = strdup("lmp scan"); - mm_add_depend(lmp_scan_cmd, cmd); - - mm_clear_db(&lm_results); - - cmd->cmd_state = 1; - - pthread_mutex_lock(&mm_wka->mm_data->mm_queue_mutex); - mms_list_insert_tail(&mm_wka->mm_data->mm_cmd_queue, - lmp_scan_cmd); - pthread_mutex_unlock(&mm_wka->mm_data->mm_queue_mutex); - - return (MM_DISPATCH_DEPEND); - - } else if (cmd->cmd_state == 1) { - - free(cmd->cmd_buf); - cmd->cmd_buf = NULL; - cmd->cmd_bufsize = 0; - - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - /* Send Failure */ - char *response_message = NULL; - response_message = - mm_ret_response_msg(cmd); - mm_response_error(cmd, - ECLASS_SUBOP, - ELMDMCOMMUNICATION, - MM_5055_MSG, - "msg_rsp", response_message, - NULL); - free(response_message); - rc = MM_CMD_ERROR; - } else { - /* Send Success */ - mm_path_match_report(cmd, db); - rc = MM_CMD_DONE; - } - mm_send_response(mm_wka->mm_wka_conn, cmd); - cmd->cmd_remove = 1; - - return (rc); - } - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); -} - - -int -mm_cpreset_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - - mms_par_node_t *arg; - mms_par_node_t *value; - char *type; - int scope = 0; /* full reset */ - int rows; - PGresult *dev_results; - int rc; - uuid_text_t task; - char *dev_name; - char *mgr_name; - mm_db_t *db = &mm_wka->mm_data->mm_db; - mm_wka_t *mgr_wka = NULL; - mm_data_t *data = mm_wka->mm_data; - mm_command_t *reset_cmd; - char *query; - - mms_trace(MMS_DEVP, "mm cpreset command, state %d", cmd->cmd_state); - if (cmd->cmd_state == 1) { - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - char *response_message = NULL; - mms_trace(MMS_DEVP, "device manager reset failed"); - response_message = - mm_ret_response_msg(cmd); - mm_response_error(cmd, - ECLASS_SUBOP, - ELMDMCOMMUNICATION, - MM_5055_MSG, - "msg_rsp", response_message, - NULL); - free(response_message); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - - } - - mms_trace(MMS_INFO, "Device Manager reset success"); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_DONE); - - } - - if (mm_privileged(mm_wka, cmd) == MM_PRIV_STANDARD) { - return (MM_CMD_ERROR); - } - - /* device type */ - MMS_PN_LOOKUP(arg, cmd->cmd_root, "cptype", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, arg, NULL, MMS_PN_KEYWORD, NULL); - type = value->pn_string; - - /* reset scope */ - if (arg = mms_pn_lookup(cmd->cmd_root, "partial", - MMS_PN_KEYWORD, NULL)) { - scope = 1; - } - - - /* find device manager */ - (void) mm_get_dest(mm_wka, cmd); - (void) mm_get_const(mm_wka, cmd); - if (strcmp(type, "DM") == 0) { - if (mm_add_char("DM", &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_cpreset_cmd_func: " - "out of mem creating source list"); - mm_system_error(cmd, - "out of mem creating source list"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - query = "select distinct " - "\"DM\".\"DriveName\",\"DM\".\"DMName\" from "; - } else { - if (mm_add_char("LM", &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_cpreset_cmd_func: " - "out of mem creating source list"); - mm_system_error(cmd, - "out of mem creating source list"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - query = "select distinct " - "\"LM\".\"LibraryName\",\"LM\".\"LMName\" from "; - } - cmd->cmd_source_num = 1; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, strlen(query) + 1); - strcpy(cmd->cmd_buf, query); - if (mm_sql_from_where(cmd, db)) { - mms_trace(MMS_ERR, - "mm_cpreset_cmd_func: " - "db error creating helper functions"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mm_sql_order(cmd); - mm_sql_number(cmd); - - - mms_trace(MMS_DEVP, - "cmd buf is %s", - cmd->cmd_buf); - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_DATA) { - goto db_error; - } - rows = PQntuples(db->mm_db_results); - if (rows == 0) { - mm_clear_db(&db->mm_db_results); - if (strcmp(type, "DM") == 0) { - mm_response_error(cmd, - ECLASS_CONFIG, - EDRVNODMCONFIGURED, - MM_5074_MSG, - NULL); - } else { - mm_response_error(cmd, - ECLASS_CONFIG, - ELIBNOLMCONFIGURED, - MM_5075_MSG, - NULL); - } - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } else if (rows > 1) { - /* Can only have 1 dev manager */ - mm_clear_db(&db->mm_db_results); - mm_response_error(cmd, - ECLASS_EXPLICIT, - ETOOMANY, - MM_5076_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - dev_results = db->mm_db_results; - - /* check device connections */ - - dev_name = PQgetvalue(dev_results, 0, 0); - mgr_name = PQgetvalue(dev_results, 0, 1); - - /* check for connected device */ - if (strcmp(type, "DM") == 0) { - if (mm_db_exec(HERE, db, "SELECT " - "\"DM\".\"DMStateSoft\" FROM \"DM\" " - "WHERE \"DM\".\"DriveName\" = '%s' AND " - "\"DM\".\"DMName\" ='%s';", - dev_name, mgr_name) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - mm_clear_db(&dev_results); - goto db_error; - } - } else if (mm_db_exec(HERE, db, "SELECT " - "\"LM\".\"LMStateSoft\" FROM \"LM\" " - "WHERE \"LM\".\"LibraryName\" = '%s' AND " - "\"LM\".\"LMName\" = '%s';", - dev_name, mgr_name) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - mm_clear_db(&dev_results); - goto db_error; - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, - "Error getting device manager state"); - mm_clear_db(&db->mm_db_results); - mm_clear_db(&dev_results); - mm_system_error(cmd, - "Error getting device manager state"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - mms_trace(MMS_DEVP, - "Device and Manager State:"); - mms_trace(MMS_DEVP, - " Device = %s", - PQgetvalue(db->mm_db_results, 0, 0)); - - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), "absent") == 0) { - if (strcmp(type, "DM") == 0) { - mm_response_error(cmd, - ECLASS_RETRY, - EDMNOTCONNECTED, - MM_5077_MSG, - "dm", - mgr_name, - NULL); - } else { - mm_response_error(cmd, - ECLASS_RETRY, - ELMNOTCONNECTED, - MM_5078_MSG, - "lm", - mgr_name, - NULL); - } - mm_clear_db(&db->mm_db_results); - mm_clear_db(&dev_results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - - } - mm_clear_db(&db->mm_db_results); - - mms_list_foreach(&data->mm_wka_list, mgr_wka) { - if ((strcmp(mgr_wka->wka_conn.cci_instance, - mgr_name) == 0) && - (strcmp(mgr_wka->wka_conn.cci_client, - dev_name) == 0)) { - /* Found the wka of dev manager */ - break; - } - } - if (mgr_wka == NULL) { - if (strcmp(type, "DM") == 0) { - mm_response_error(cmd, - ECLASS_RETRY, - EDMNOTCONNECTED, - MM_5077_MSG, - "dm", - mgr_name, - NULL); - } else { - mm_response_error(cmd, - ECLASS_RETRY, - ELMNOTCONNECTED, - MM_5078_MSG, - "lm", - mgr_name, - NULL); - } - mm_clear_db(&dev_results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - /* Allocate command and add to the queue */ - - /* - * reset command - */ - - if ((reset_cmd = mm_alloc_cmd(mgr_wka)) == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_command_t: %s", - strerror(errno)); - return (1); - } - if (strcmp(type, "DM") == 0) { - reset_cmd->cmd_func = mm_dmp_reset_cmd_func; - } else { - reset_cmd->cmd_func = mm_lmp_reset_cmd_func; - } - mm_get_uuid(task); - if (scope) { /* build device reset cmd */ - reset_cmd->cmd_textcmd = mms_strnew("reset task[\"%s\"] " - "partial;", task); - } else { - reset_cmd->cmd_textcmd = mms_strnew("reset task[\"%s\"] full;", - task); - } - - mms_trace(MMS_DEVP, "%s", reset_cmd->cmd_textcmd); - if (strcmp(type, "DM") == 0) { - reset_cmd->cmd_root = - mm_text_to_par_node(reset_cmd->cmd_textcmd, - mms_dmpm_parse); - reset_cmd->cmd_name = strdup("dmp reset"); - } else { - reset_cmd->cmd_root = - mm_text_to_par_node(reset_cmd->cmd_textcmd, - mms_lmpm_parse); - reset_cmd->cmd_name = strdup("lmp reset"); - } - reset_cmd->cmd_task = mm_get_task(reset_cmd->cmd_root); - mm_add_depend(reset_cmd, cmd); - - pthread_mutex_lock(&mm_wka->mm_data->mm_queue_mutex); - mms_list_insert_tail(&mm_wka->mm_data->mm_cmd_queue, reset_cmd); - pthread_mutex_unlock(&mm_wka->mm_data->mm_queue_mutex); - - mm_clear_db(&dev_results); - - cmd->cmd_state = 1; - mms_trace(MMS_DEBUG, - "added reset command for %s %s", - mgr_name, dev_name); - - return (MM_DISPATCH_DEPEND); - - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - -db_error: - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - return (rc); -} diff --git a/usr/src/cmd/mms/mm/common/mm_mmp_mount.c b/usr/src/cmd/mms/mm/common/mm_mmp_mount.c deleted file mode 100644 index 2fd87cd93c..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_mmp_mount.c +++ /dev/null @@ -1,5726 +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 <stdlib.h> -#include <string.h> -#include <errno.h> -#include <pthread.h> -#include <syslog.h> -#include <mms_list.h> -#include <mms_parser.h> -#include <mms_par_impl.h> -#include <libpq-fe.h> -#include <mms_trace.h> -#include <mms_strapp.h> -#include "mm_db.h" -#include "mm.h" -#include "mm_util.h" -#include "mm_commands.h" -#include "mm_sql.h" -#include "mm_sql_impl.h" -#include "mm_task.h" -#include "mm_path.h" - -static char *_SrcFile = __FILE__; - -#define SELECT_GETALL "select \"DriveName\" from " \ - "getall('%s', '%s', '%s');" - -#define SELECT_LIB "select \"LibraryName\" from " \ - "gettypename('%s', '%s');" - -/* Unmount command states */ -#define UM_CANDIDATE_SELECTION 0 -#define UM_DM_DETACH 1 -#define UM_SCHEDULE_UNLOAD 2 -#define UM_DM_UNLOAD 3 -#define UM_DM_RELEASE 4 -#define UM_LM_UNMOUNT 5 -#define UM_FINAL 100 - -extern int mm_get_dest(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_get_source(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_get_const(mm_wka_t *mm_wka, mm_command_t *cmd); -extern int mm_add_match_list(char *str, mms_list_t *list); -extern void tm_be_cancel_all(mm_command_t *cmd); - -void -mm_print_unmount_state(int state) { - switch (state) { - case UM_CANDIDATE_SELECTION: - mms_trace(MMS_DEBUG, - "unmount candidate selection"); - return; - case UM_DM_DETACH: - mms_trace(MMS_DEBUG, - "add dm detach command"); - return; - case UM_SCHEDULE_UNLOAD: - mms_trace(MMS_DEBUG, - "schedule dm unload command"); - return; - case UM_DM_UNLOAD: - mms_trace(MMS_DEBUG, - "add dm unload command"); - return; - case UM_DM_RELEASE: - mms_trace(MMS_DEBUG, - "add dm release command"); - return; - - case UM_LM_UNMOUNT: - mms_trace(MMS_DEBUG, - "add lm unmount command"); - return; - - case UM_FINAL: - mms_trace(MMS_DEBUG, - "umount final commmand state"); - return; - - } -} - -void -mm_print_mount_candidates(mm_command_t *cmd) { - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - cmi_cart_list_t *cart = NULL; - cmi_drive_list_t *drive = NULL; - - mms_trace(MMS_INFO, "Candidate Cartridges are :"); - mms_list_foreach(&mount_info->cmi_cart_list, cart) { - if (cart->cmi_cart_not_ready) { - mms_trace(MMS_INFO, " Cartridge, %s, (not ready)", - cart->cmi_cart_id); - } else { - mms_trace(MMS_INFO, " Cartridge, %s", - cart->cmi_cart_id); - } - if (cart->cmi_cart_pcl != NULL) { - mms_trace(MMS_INFO, " %s", - cart->cmi_cart_pcl); - } - mms_trace(MMS_INFO, " Library, %s", - cart->cmi_library); - mms_trace(MMS_INFO, - " Drive Candidates:"); - mms_list_foreach(&cart->cmi_drive_list, drive) { - if (drive->cmi_mode_valid == 0) { - mms_trace(MMS_INFO, " %s" - " * no DM configured *", - drive->cmi_drive_name); - } else { - if (drive->cmi_drive_not_ready) { - mms_trace(MMS_INFO, - " %s, (not ready)", - drive->cmi_drive_name); - } else { - mms_trace(MMS_INFO, " %s", - drive->cmi_drive_name); - } - } - } - } -} -void -mm_print_accessmodes(mm_command_t *cmd) { - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - cmi_mode_list_t *mode = NULL; - int i; - - mms_trace(MMS_INFO, "Number of First Mount Tokens's is %d", - mount_info->cmi_num_firstmount); - - for (i = 0; i < mount_info->cmi_num_firstmount; i ++) { - mms_trace(MMS_INFO, " First Mount Token %d is %s", i, - mount_info->cmi_firstmount[i]); - } - mms_trace(MMS_INFO, "Total Number of Access Modes is %d", - mount_info->cmi_total_modes); - mms_list_foreach(&mount_info->cmi_mode_list, mode) { - for (i = 0; - i < mode->cmi_num_accessmode; - i ++) { - mms_trace(MMS_INFO, " Mode Token %d is %s", i, - mode->cmi_accessmode[i]); - } - } -} -void -mm_print_mount_summary(mm_wka_t *mm_wka, mm_command_t *cmd) { - - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - cci_t *conn = &mm_wka->wka_conn; - - /* Print mount information */ - if (mount_info->cmi_operation == MM_MOUNT) { - mms_trace(MMS_INFO, "*** Mount Summary ***"); - } else { - mms_trace(MMS_INFO, "*** UnMount Summary ***"); - } - mms_trace(MMS_INFO, "Application is %s", - conn->cci_client); - mms_trace(MMS_INFO, "Instance is %s", - conn->cci_instance); - if (cmd->wka_ptr->wka_privilege == MM_PRIV_STANDARD) { - mms_trace(MMS_INFO, - "Standard Privilege"); - } else { - mms_trace(MMS_INFO, - "Privileged Client"); - } - switch (mount_info->cmi_type) { - case MM_SIDE: - mms_trace(MMS_INFO, " Type is SIDE"); - break; - case MM_PARTITION: - mms_trace(MMS_INFO, " Type is PARTITION"); - break; - case MM_VOLUME: - mms_trace(MMS_INFO, " Type is VOLUME"); - break; - } - switch (mount_info->cmi_when) { - case MM_BLOCKING: - mms_trace(MMS_INFO, " When is 'blocking'"); - break; - case MM_IMMEDIATE: - mms_trace(MMS_INFO, " When is 'immediate'"); - break; - } - - if (mount_info->cmi_where) - mms_trace(MMS_INFO, - " Where is %s", mount_info->cmi_where); - - - /* Print access modes */ - if (mount_info->cmi_operation == MM_MOUNT) - mm_print_accessmodes(cmd); - - /* Print all the cartridge/library/drive information */ - mm_print_mount_candidates(cmd); -} - -int -mm_check_drive(mm_wka_t *mm_wka, mm_command_t *cmd, - cmi_drive_list_t *drive_struct, - char *cart_id, char *dm_name, mm_db_t *db) -{ - /* Need to set cmd error buf for every return (0) */ - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - cmi_mode_list_t *mode; - - char *cap_tokens = NULL; - int a_mode = 0; - char *drive = drive_struct->cmi_drive_name; - - /* Check if a DM is configured for this drive */ - if (mm_db_exec(HERE, db, "select * from \"DMCAPABILITYGROUP\" " - "where \"DriveName\" = '%s';", drive) != MM_DB_DATA) { - mms_trace(MMS_ERR, "Error getting DMCAPABILITYGROUP"); - mm_sql_db_err_rsp_new(cmd, db); - return (0); - } - if (PQntuples(db->mm_db_results) == 0) { - /* DM is not configured for this drive */ - mm_response_error(cmd, - ECLASS_CONFIG, - "EDRVNODMCONFIGURED", - MM_5035_MSG, - "dm", - dm_name, - "drive", - drive, - NULL); - mm_clear_db(&db->mm_db_results); - return (0); - } - mm_clear_db(&db->mm_db_results); - - /* Check the cartridge shape */ - if (mm_db_exec(HERE, db, - "select distinct * from drive_cart('%s', '%s');", - drive, cart_id) != MM_DB_DATA) { - mms_trace(MMS_ERR, "Error checking drive shape"); - mm_sql_db_err_rsp_new(cmd, db); - return (0); - } - if (PQntuples(db->mm_db_results) == 0) { - /* Drive does not support this cartridge shape */ - mms_trace(MMS_DEVP, "Drive does not support "\ - "this cartridge shape, %s %s", drive, cart_id); - mm_response_error(cmd, - ECLASS_COMPAT, - "ECARTDRVNOTCOMPATIBLE", - MM_5096_MSG, - "drive", - drive, - "cart", - cart_id, - NULL); - mm_clear_db(&db->mm_db_results); - return (0); - } - mm_clear_db(&db->mm_db_results); - - /* For each Access Mode, check if the drive supports it */ - mms_list_foreach(&mount_info->cmi_mode_list, mode) { - mms_trace(MMS_DEVP, - "checking a mode"); - a_mode = 1; - cap_tokens = (char *)mm_check_mode(mm_wka, - cmd, drive, mode, - cart_id, db); - if (cap_tokens != NULL) { - /* There is at least one supported mode */ - mms_trace(MMS_DEVP, "Good mode is %s", - cap_tokens); - /* mode is ok */ - free(cap_tokens); - return (1); - } - } - if (a_mode) { - /* there was at least 1 mode passed, */ - /* and none were not good, return error */ - if (cap_tokens != NULL) { - free(cap_tokens); - } - mm_response_error(cmd, - ECLASS_COMPAT, - "ECARTDRVNOTCOMPATIBLE", - MM_5036_MSG, - "dm", - dm_name, - "drive", - drive, - NULL); - return (0); - } - /* No modes exist, access is default */ - if (cap_tokens != NULL) { - free(cap_tokens); - } - return (1); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -} - -#ifdef MM_LIBRARY_DRIVE_HAS_PCL -static int -mm_library_drive_has_pcl(mm_command_t *cmd, char *library, char *drive, - char *cart_pcl) -{ - mm_db_t *db = &cmd->wka_ptr->mm_data->mm_db; - int loaded; - - if (mm_db_exec(HERE, db, "select \"DriveName\" from \"DRIVE\" " - "where \"LibraryName\" = '%s' " - "and \"DriveName\" = '%s' " - "and \"CartridgePCL\" = '%s' " - "and \"DriveLibraryAccessible\" = 'true' " - "and \"DriveLibraryOccupied\" = 'true' " - "and \"DriveBroken\" = 'false' " - "and \"DriveDisabled\" = 'false';", - library, drive, cart_pcl) != MM_DB_DATA) { - return (0); - } - loaded = (PQntuples(db->mm_db_results) != 1 ? 0 : 1); - mm_clear_db(&db->mm_db_results); - return (loaded); -} -#endif -int -mm_candidate_drive_ok(mm_wka_t *mm_wka, - mm_command_t *cmd, mm_db_t *db, - char *candidate_cartid, - cmi_drive_list_t *drive) { - - /* Determines if the candidate drive */ - /* is available as a candidate */ - char *candidate_drive = drive->cmi_drive_name; - char *candidate_dm = drive->cmi_dm_name; - - cci_t *conn = &mm_wka->wka_conn; - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - mm_dm_stat_t *dm_stat = NULL; - mm_drive_stat_t *drive_stat = NULL; - - int rc; - mms_trace(MMS_DEVP, "mm_candidate_drive_ok"); - if ((drive_stat = mm_get_drive_status(candidate_drive, db)) == NULL) { - mms_trace(MMS_ERR, - "Error getting drive information, " - "drive %s", - candidate_drive); - mm_system_error(cmd, - "failed to get drive information"); - rc = 0; goto end; - } - - /* For mounts we know drive and host, for umounts we know dm */ - /* Use the approperate call to getdmstatus */ - if (mount_info->cmi_operation == MM_MOUNT) { - if ((dm_stat = mm_get_dm_status(NULL, candidate_drive, - mount_info->cmi_where, db)) == NULL) { - mms_trace(MMS_ERR, - "Error getting dm information, " - "drive %s", - candidate_drive); - mm_system_error(cmd, - "failed to get dm information"); - rc = 0; goto end; - } - } else { - mms_trace(MMS_DEVP, - "cmi_dm_name/candidate_dm == %s", - candidate_dm); - if ((dm_stat = mm_get_dm_status(candidate_dm, NULL, - NULL, db)) == NULL) { - mms_trace(MMS_ERR, - "Error getting dm information, " - "drive %s", - candidate_drive); - mm_system_error(cmd, - "failed to get dm information"); - rc = 0; goto end; - } - } - - mm_print_drive_status(drive_stat); - - - mm_print_dm_status(dm_stat); - - /* The order of check is the order errors get returned */ - /* check higher level problems before lower level */ - /* ie. online, diabled first */ - - /* Exclusive access check */ - if (strcmp(drive_stat->drive_stat_excl_app, "none") != 0) { - if (strcmp(conn->cci_client, - drive_stat->drive_stat_excl_app) != 0) { - mms_trace(MMS_DEVP, - "%s exclusive app is not clients app," - " ExclusiveAppName != %s or none", - candidate_drive, - conn->cci_client); - mm_response_error(cmd, - ECLASS_EXPLICIT, - "EAPPDRVNOACC", - MM_5027_MSG, - "app", conn->cci_client, - "drive", candidate_drive, - NULL); - rc = 0; goto end; - } - } - - /* DRIVEGROUPAPPLICATION check */ - if (cmd->wka_ptr->wka_privilege == MM_PRIV_STANDARD) { - mms_trace(MMS_DEVP, - "Non-privileged client, " - "checking Drive Access"); - /* standard priv, check drive group access */ - if (mm_db_exec(HERE, db, - "select \"DRIVEGROUPAPPLICATION\".\"ApplicationName\" " - "from \"DRIVEGROUPAPPLICATION\" " - "where \"DriveGroupName\" = '%s' and " - "\"ApplicationName\" = '%s';", - drive_stat->drive_stat_group, - conn->cci_client) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "Error getting drive group information, " - "drive %s, db trans failed", - candidate_drive); - mm_sql_db_err_rsp_new(cmd, db); - rc = 0; goto end; - } - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_DEVP, - "%s does not have " - "access to drive group %s", - conn->cci_client, - drive_stat->drive_stat_group); - mm_response_error(cmd, - ECLASS_EXPLICIT, - "EAPPDRVNOACC", - MM_5030_MSG, - "app", conn->cci_client, - "drive", candidate_drive, - NULL); - mm_clear_db(&db->mm_db_results); - rc = 0; goto end; - } - mm_clear_db(&db->mm_db_results); - } else { - mms_trace(MMS_DEVP, - "Privileged Client, " - "skip Drive Access check"); - } - - - /* Online check */ - if ((strcmp(drive_stat->drive_stat_online, "false") == 0) || - (strcmp(drive_stat->drive_stat_online, "f") == 0)) { - mms_trace(MMS_DEVP, - "%s is not online", - candidate_drive); - mm_response_error(cmd, - ECLASS_PERMPRIV, - "EDRIVEOFFLINE", - MM_5029_MSG, - "drive", candidate_drive, - NULL); - rc = 0; goto end; - } - - /* Drive In use */ - if ((mount_info->cmi_operation == MM_MOUNT) && - (strcmp(drive_stat->drive_stat_soft, "ready") != 0)) { - mms_trace(MMS_DEVP, - "%s is not ready," - " DriveStateSoft != ready ", - candidate_drive); - drive->cmi_drive_not_ready = 1; - mm_response_error(cmd, - ECLASS_RETRY, - "EDRVINUSE", - MM_5025_MSG, - "drive", candidate_drive, - NULL); - mm_set_retry_drive(cmd, - candidate_drive); - if (mount_info->cmi_when == MM_IMMEDIATE) { - rc = 0; goto end; - } else { - mms_trace(MMS_DEVP, - "drive in use, keep as" - " candidate for blocking mounts"); - mm_response_error(cmd, - ECLASS_RETRY, - "EDRVINUSE", - MM_5025_MSG, - "drive", candidate_drive, - NULL); - mm_set_retry_drive(cmd, - candidate_drive); - } - /* Keep this drive as a candidate for blocking mounts */ - - } - - if ((mount_info->cmi_operation == MM_MOUNT) && - ((strcmp(drive_stat->drive_stat_hard, "loaded") == 0) || - (strcmp(drive_stat->drive_stat_drvlib_occ, "true") == 0) || - (strcmp(drive_stat->drive_stat_drvlib_occ, "t") == 0))) { - /* Find this drive's delayed unload and set to dispatch */ - mms_trace(MMS_DEVP, - "drive is loaded with %s, need to unload", - drive_stat->drive_stat_pcl); - - if ((strcmp(drive_stat->drive_stat_hard, "unloading") == 0) || - (strcmp(drive_stat->drive_stat_hard, "loading") == 0)) { - /* This drive is in the process of unloading */ - mms_trace(MMS_DEVP, - "This drive is in the process of " - "unloading/loading"); - drive->cmi_drive_not_ready = 1; - mm_response_error(cmd, - ECLASS_RETRY, - "EDRVUNLOADING", - MM_5102_MSG, - "drive", candidate_drive, - NULL); - mm_set_retry_drive(cmd, - candidate_drive); - if (mount_info->cmi_when == MM_IMMEDIATE) { - rc = 0; goto end; - } - } else { - drive->cmi_drive_loaded = 1; - drive->cmi_loaded_pcl = NULL; - drive->cmi_loaded_pcl = mms_strapp(drive-> - cmi_loaded_pcl, - drive_stat->drive_stat_pcl); - if (strcmp(MM_NON_MMS_CART, - drive_stat->drive_stat_pcl) == 0) { - drive->cmi_drive_not_ready = 1; - mms_trace(MMS_DEVP, - "drive is loaded with a non-mms tape"); - mm_response_error(cmd, - ECLASS_RETRY, - "EDRVINUSE", - MM_5028_MSG, - "drive", candidate_drive, - NULL); - mm_set_retry_drive(cmd, - candidate_drive); - if (mount_info->cmi_when == MM_IMMEDIATE) { - rc = 0; goto end; - } - } - } - } - - if (mount_info->cmi_operation == MM_UNMOUNT) { - if ((strcmp(drive_stat->drive_stat_hard, "loaded") != 0) || - (strcmp(drive_stat->drive_stat_drvlib_occ, "t") != 0)) { - mms_trace(MMS_DEVP, - "%s not loaded/occupied with tape, " - "but has MOUNTPHYSICAL", - candidate_drive); - mm_system_error(cmd, - "drive with MOUNTPHYSICAL not " - "loaded/occupied with tape"); - rc = 0; goto end; - } - } - - - /* Drive disabled */ - if ((strcmp(drive_stat->drive_stat_disabled, "true") == 0) || - (strcmp(drive_stat->drive_stat_disabled, "t") == 0)) { - mms_trace(MMS_DEVP, - "%s is disabled", - candidate_drive); - if (strcmp(drive_stat->drive_stat_disabled, - "temporary") == 0) { - mm_response_error(cmd, - ECLASS_PERMPRIV, - "EDRVDISABLEDTEMP", - MM_5022_MSG, - "drive", candidate_drive, - NULL); - - } else { - mm_response_error(cmd, - ECLASS_PERMPRIV, - "EDRVDISABLEDPERM", - MM_5023_MSG, - "drive", candidate_drive, - NULL); - } - rc = 0; goto end; - } - /* Drive Broken */ - if ((strcmp(drive_stat->drive_stat_broken, "true") == 0) || - (strcmp(drive_stat->drive_stat_broken, "t") == 0)) { - mms_trace(MMS_DEVP, - "%s is broken", - candidate_drive); - mm_response_error(cmd, - ECLASS_CONFIG, - "EDRVBROKEN", - MM_5024_MSG, - "drive", candidate_drive, - NULL); - rc = 0; goto end; - } - - /* Drive is library accessible */ - if ((strcmp(drive_stat->drive_stat_lib_acc, "false") == 0) || - (strcmp(drive_stat->drive_stat_lib_acc, "f") == 0)) { - mms_trace(MMS_DEVP, - "%s is not accessible", - candidate_drive); - mm_response_error(cmd, - ECLASS_INTERNAL, - "ELMDRVNOTACCESS", - MM_5026_MSG, - "drive", candidate_drive, - NULL); - rc = 0; goto end; - } - - /* DM Status Checks */ - if (strcmp(dm_stat->dm_stat_soft, "ready") != 0) { - mms_trace(MMS_DEVP, - "DM for %s is not ready," - " DMStateSoft != ready ", - candidate_drive); - - if (strcmp(dm_stat->dm_stat_soft, - "absent") == 0) { - mm_response_error(cmd, - ECLASS_RETRY, - "EDMNOTCONNECTED", - MM_5032_MSG, - "dm", - dm_stat->dm_stat_name, - "drive", - candidate_drive, - NULL); - rc = 0; goto end; - } else if (strcmp(dm_stat->dm_stat_soft, - "disconnected") == 0) { - mm_response_error(cmd, - ECLASS_CONFIG, - "EDRVBROKEN", - MM_5033_MSG, - "dm", - dm_stat->dm_stat_name, - "drive", - candidate_drive, - NULL); - mm_set_retry_drive(cmd, - candidate_drive); - rc = 0; goto end; - } else if (strcmp(dm_stat->dm_stat_soft, - "not ready") == 0) { - /* drive is not ready for blocked */ - drive->cmi_drive_not_ready = 1; - mm_response_error(cmd, - ECLASS_RETRY, - "EDMSTILLBOOTING", - MM_5034_MSG, - "dm", - dm_stat->dm_stat_name, - "drive", - candidate_drive, - NULL); - if (mount_info->cmi_when == MM_IMMEDIATE) { - rc = 0; goto end; - } - } else if (strcmp(dm_stat->dm_stat_soft, - "present") == 0) { - /* drive is not ready for blocked */ - drive->cmi_drive_not_ready = 1; - mm_response_error(cmd, - ECLASS_CONFIG, - "EDRVNODMCONFIGURED", - MM_5034_MSG, - "dm", - dm_stat->dm_stat_name, - "drive", - candidate_drive, - NULL); - mm_set_retry_drive(cmd, - candidate_drive); - if (mount_info->cmi_when == MM_IMMEDIATE) { - rc = 0; goto end; - } - } else if ((mount_info->cmi_operation == MM_MOUNT) && - (strcmp(dm_stat->dm_stat_soft, - "reserved") == 0)) { - /* drive is not ready for blocked */ - drive->cmi_drive_not_ready = 1; - mm_response_error(cmd, - ECLASS_RETRY, - "EDRVINUSE", - MM_5098_MSG, - "dm", - dm_stat->dm_stat_name, - NULL); - mm_set_retry_drive(cmd, - candidate_drive); - if (mount_info->cmi_when == MM_IMMEDIATE) { - rc = 0; goto end; - } - } - } else if (mount_info->cmi_operation == MM_UNMOUNT) { - /* Unmount, and DM is ready */ - mms_trace(MMS_DEVP, - "%s is in incorrect state for unmount", - dm_stat->dm_stat_name); - mm_system_error(cmd, - "DM is in incorrect state for unmount"); - rc = 0; goto end; - } - - if (strcmp(dm_stat->dm_stat_hard, "ready") != 0) { - mms_trace(MMS_DEVP, - "DM for %s is not ready," - " DMStateHard != ready ", - candidate_drive); - mm_response_error(cmd, - ECLASS_CONFIG, - "EDRVBROKEN", - MM_5031_MSG, - "drive", - candidate_drive, - "dm", - dm_stat->dm_stat_name, - NULL); - rc = 0; goto end; - } - if (mount_info->cmi_operation == MM_UNMOUNT) { - mms_trace(MMS_DEVP, - "Drive/DM Status ok for unmounts"); - rc = 1; goto end; - } - - - mms_trace(MMS_DEVP, - "DM Status ok, check DM accessmodes DM, %s", - dm_stat->dm_stat_name); - - if (mm_check_drive(mm_wka, cmd, - drive, - candidate_cartid, - dm_stat->dm_stat_name, - db) == 1) { - /* DM supports the access modes */ - mms_trace(MMS_DEVP, - "DM configured for at least 1 access mode"); - } else { - mms_trace(MMS_DEVP, - "DM not configured to support the access mode"); - /* Error buf should be set by check drive */ - rc = 0; goto end; - } - - - rc = 1; goto end; - -end: - mm_free_drive_status(drive_stat); - mm_free_dm_status(dm_stat); - return (rc); -} - -int -mm_candidate_cartridge_ok(mm_wka_t *mm_wka, - mm_command_t *cmd, mm_db_t *db, - cmi_cart_list_t *cart_struct) { - - uuid_text_t *candidate_cartid = &cart_struct->cmi_cart_id; - - cci_t *conn = &mm_wka->wka_conn; - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - PGresult *cart = NULL; - PGresult *volume = NULL; - PGresult *slot = NULL; - - int rc; - mms_trace(MMS_DEVP, "mm_candidate_cartridge_ok"); - if (mm_db_exec(HERE, db, - "select " - "\"CARTRIDGE\".\"CartridgeState\", " - "\"CARTRIDGE\".\"CartridgeStatus\", " - "\"CARTRIDGE\".\"CartridgeGroupName\", " - "\"CARTRIDGE\".\"CartridgeDriveOccupied\" " - "from \"CARTRIDGE\" " - "where \"CartridgeID\" = '%s';", - candidate_cartid) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "Error getting cartridge information, " - "cartridge, %s, db trans failed", - candidate_cartid); - mm_sql_db_err_rsp_new(cmd, db); - rc = 0; goto end; - } - cart = db->mm_db_results; - if (PQntuples(cart) != 1) { - mms_trace(MMS_ERR, - "Error getting cartridge information, " - "cartridge, %s, db results != 1", - candidate_cartid); - mm_system_error(cmd, - "row number mismatch getting " - "cartridge information"); - rc = 0; goto end; - } - mms_trace(MMS_DEVP, - "Cartridge Status for Cartridge, %s", - candidate_cartid); - mms_trace(MMS_DEVP, - " CartridgeState = %s", - PQgetvalue(cart, 0, 0)); - mms_trace(MMS_DEVP, - " CartridgeStatus = %s", - PQgetvalue(cart, 0, 1)); - mms_trace(MMS_DEVP, - " CartridgeGroup = %s", - PQgetvalue(cart, 0, 2)); - mms_trace(MMS_DEVP, - " CartridgeDriveOccupied = %s", - PQgetvalue(cart, 0, 3)); - - /* Ignore this attribute for now */ - /* - * if (strcmp(PQgetvalue(cart, 0, 0), "defined") != 0) { - * - * } - */ - - if ((mount_info->cmi_operation == MM_MOUNT) && - (strcmp(PQgetvalue(cart, 0, 1), "available") != 0)) { - mms_trace(MMS_DEVP, - "%s is in use," - " CartridgeStatus != available ", - candidate_cartid); - if (strcmp(PQgetvalue(cart, 0, 1), - "unavailable") == 0) { - mm_response_error(cmd, - ECLASS_CONFIG, - "ECARTNOTLOCATED", - MM_5037_MSG, - "cart", - candidate_cartid, - NULL); - rc = 0; goto end; - } - /* mark this cartridge not ready */ - /* for blocked mounts */ - cart_struct->cmi_cart_not_ready = 1; - /* State is 'in use' */ - mm_response_error(cmd, - ECLASS_RETRY, - "ECARTINUSE", - MM_5038_MSG, - "cart", - candidate_cartid, - NULL); - mm_set_retry_cart(cmd, - (char *)candidate_cartid); - if (mount_info->cmi_when == MM_IMMEDIATE) { - rc = 0; goto end; - } - } - if ((mount_info->cmi_operation == MM_UNMOUNT) && - (strcmp(PQgetvalue(cart, 0, 1), "in use") != 0)) { - mms_trace(MMS_DEVP, - "%s is not in use," - " CartridgeStatus != in use ", - candidate_cartid); - mm_system_error(cmd, - "cartridge status is not in use"); - rc = 0; goto end; - } - - /* Check if this CARTRIDGE has a SLOT created for it */ - if (mm_db_exec(HERE, db, - "select \"SlotName\" " - "from \"SLOT\" " - "where \"CartridgeID\" = '%s';", - candidate_cartid) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "Error getting slot info, " - "cartridge, %s, db trans failed", - candidate_cartid); - mm_sql_db_err_rsp_new(cmd, db); - rc = 0; goto end; - } - slot = db->mm_db_results; - if (PQntuples(slot) == 0) { - mms_trace(MMS_DEVP, - "no slot found for cartridge, %s", - candidate_cartid); - mm_response_error(cmd, - ECLASS_CONFIG, - "ENOSLOT", - MM_5095_MSG, - "cart", - candidate_cartid, - NULL); - rc = 0; goto end; - } - - - if (mount_info->cmi_operation == MM_UNMOUNT) { - /* skip volume check */ - /* This cart already has mapped to mount physical */ - mms_trace(MMS_DEVP, - "skip vol check for unmount"); - rc = 1; goto end; - } - - - /* Get VOLUME information */ - mms_trace(MMS_DEVP, - "Checking for Volumes"); - if (mm_db_exec(HERE, db, - "select \"ApplicationName\" " - "from \"VOLUME\" where " - "\"CartridgeID\" = '%s' and " - "\"ApplicationName\" = '%s';", - candidate_cartid, - conn->cci_client) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "Error getting volume information, " - "cartridge, %s, db trans failed", - candidate_cartid); - mm_sql_db_err_rsp_new(cmd, db); - rc = 0; goto end; - } - volume = db->mm_db_results; - if (PQntuples(volume) == 0) { - mms_trace(MMS_DEVP, - "%s doesn't have a volume " - "on cartridge, %s", - conn->cci_client, - candidate_cartid); - mm_response_error(cmd, - ECLASS_CONFIG, - "EAPPHASNOVOLS", - MM_5040_MSG, - "app", - conn->cci_client, - "cart", - candidate_cartid, - NULL); - rc = 0; goto end; - } - - - rc = 1; goto end; - -end: - if (cart != NULL) { - mm_clear_db(&cart); - } - if (volume != NULL) { - mm_clear_db(&volume); - } - if (slot != NULL) { - mm_clear_db(&slot); - } - return (rc); - -} - - -int -mm_candidate_library_ok(mm_command_t *cmd, mm_db_t *db, - char *candidate_library) { - - /* Determines if the candidate library */ - /* is available as a candidate */ - - mm_lm_stat_t *lm_stat = NULL; - mm_lib_stat_t *lib_stat = NULL; - - int rc; - mms_trace(MMS_DEVP, "mm_candidate_library_ok"); - if ((lib_stat = mm_get_library_status(candidate_library, db)) == NULL) { - mms_trace(MMS_ERR, - "Error getting library information, " - "library %s", - candidate_library); - mm_system_error(cmd, - "failed to get library " - "information from database"); - rc = 0; goto end; - } - - mm_print_library_status(lib_stat); - - if ((strcmp(lib_stat->lib_stat_online, "false") == 0) || - (strcmp(lib_stat->lib_stat_online, "f") == 0)) { - mms_trace(MMS_DEVP, - "%s is not online", - candidate_library); - mm_response_error(cmd, - ECLASS_PERMPRIV, - "ELIBRARYOFFLINE", - MM_5041_MSG, - "lib", - candidate_library, - NULL); - rc = 0; goto end; - } - if ((strcmp(lib_stat->lib_stat_disabled, "true") == 0) || - (strcmp(lib_stat->lib_stat_disabled, "t") == 0)) { - mms_trace(MMS_DEVP, - "%s is disabled", - candidate_library); - if (strcmp(lib_stat->lib_stat_disabled, - "temporary") == 0) { - mm_response_error(cmd, - ECLASS_PERMPRIV, - "ELIBDISABLEDTEMP", - MM_5042_MSG, - "lib", - candidate_library, - NULL); - } else { - mm_response_error(cmd, - ECLASS_PERMPRIV, - "ELIBDISABLEDPERM", - MM_5043_MSG, - "lib", - candidate_library, - NULL); - } - rc = 0; goto end; - } - if ((strcmp(lib_stat->lib_stat_broken, "true") == 0) || - (strcmp(lib_stat->lib_stat_broken, "t") == 0)) { - mms_trace(MMS_DEVP, - "%s is broken", - candidate_library); - mm_response_error(cmd, - ECLASS_CONFIG, - "ELIBBROKEN", - MM_5044_MSG, - "lib", - candidate_library, - NULL); - rc = 0; goto end; - } - mms_trace(MMS_DEVP, - "Library status ok, check LM"); - - /* Library is online and ready, get LM status */ - - if ((lm_stat = mm_get_lm_status(lib_stat->lib_stat_lm, - db)) == NULL) { - mms_trace(MMS_ERR, - "Error getting lm information, " - "library %s", - candidate_library); - mm_system_error(cmd, - "failed to get lm information"); - rc = 0; goto end; - } - - mm_print_lm_status(lm_stat); - - if (strcmp(lm_stat->lm_stat_hard, "ready") != 0) { - mms_trace(MMS_DEVP, - "%s is not ready," - " LMStateHard != ready ", - lib_stat->lib_stat_lm); - mm_response_error(cmd, - ECLASS_CONFIG, - "ELIBBROKEN", - MM_5045_MSG, - "lm", - lib_stat->lib_stat_lm, - NULL); - rc = 0; goto end; - } - if (strcmp(lm_stat->lm_stat_soft, "ready") != 0) { - mms_trace(MMS_DEVP, - "%s is not ready," - " LMStateSoft != ready ", - lib_stat->lib_stat_lm); - if (strcmp(lm_stat->lm_stat_soft, - "absent") == 0) { - mm_response_error(cmd, - ECLASS_RETRY, - "ELMNOTCONNECTED", - MM_5046_MSG, - "lm", - lib_stat->lib_stat_lm, - "lib", - lib_stat->lib_stat_name, - NULL); - mm_set_retry_lib(cmd, - candidate_library); - } - if (strcmp(lm_stat->lm_stat_soft, - "present") == 0) { - mm_response_error(cmd, - ECLASS_RETRY, - "ELMNOTREADY", - MM_5047_MSG, - "lm", - lib_stat->lib_stat_lm, - "lib", - lib_stat->lib_stat_name, - NULL); - mm_set_retry_lib(cmd, - candidate_library); - } - if (strcmp(lm_stat->lm_stat_soft, - "disconnected") == 0) { - mm_response_error(cmd, - ECLASS_CONFIG, - "ELIBBROKEN", - MM_5048_MSG, - "lm", - lib_stat->lib_stat_lm, - "lib", - lib_stat->lib_stat_name, - NULL); - - } - if (strcmp(lm_stat->lm_stat_soft, - "not ready") == 0) { - mm_response_error(cmd, - ECLASS_RETRY, - "ELMSTILLBOOTING", - MM_5049_MSG, - "lm", - lib_stat->lib_stat_lm, - "lib", - lib_stat->lib_stat_name, - NULL); - mm_set_retry_lib(cmd, - candidate_library); - } - rc = 0; goto end; - } - mms_trace(MMS_DEVP, - "LM status ok"); - - rc = 1; goto end; - -end: - mm_free_library_status(lib_stat); - mm_free_lm_status(lm_stat); - return (rc); - -} - - -int -mm_insert_next_drive(mms_list_t *drive_list, cmi_drive_list_t *drive_struct) { - - /* - * This will insert the drive_struct into its - * proper place in drive_list - * - * the drives are inserted in order of drive_priority - * check the dm shape and dm density priority to - * arrange the drives within each drive priority group - */ - - cmi_drive_list_t *drive; - cmi_drive_list_t *next_drive; - - int drv_priority; - int dm_shape_priority; - int dm_density_priority; - - int cur_drv_priority; - int cur_shape_priority; - int cur_density_priority; - - int next_drv_priority; - - int a_drive = 0; - - drv_priority = drive_struct->cmi_drv_priority; - dm_shape_priority = drive_struct->cmi_dm_shape_priority; - dm_density_priority = drive_struct->cmi_dm_density_priority; - - for (drive = mms_list_head(drive_list); - drive != NULL; - drive = next_drive) { - a_drive = 1; - next_drive = - mms_list_next(drive_list, - drive); - cur_drv_priority = drive->cmi_drv_priority; - cur_shape_priority = drive->cmi_dm_shape_priority; - cur_density_priority = drive->cmi_dm_density_priority; - - if (cur_drv_priority != drv_priority) { - /* go to the next drive */ - continue; - } - if (cur_shape_priority > dm_shape_priority) { - /* Insert before cur */ - mms_list_insert_before(drive_list, drive, drive_struct); - return (0); - } - if ((cur_shape_priority == dm_shape_priority) && - (cur_density_priority > dm_density_priority)) { - /* Insert before cur */ - mms_list_insert_before(drive_list, drive, drive_struct); - return (0); - } - if (next_drive == NULL) { - mms_list_insert_after(drive_list, drive, drive_struct); - return (0); - } - next_drv_priority = next_drive->cmi_drv_priority; - if (next_drv_priority != drv_priority) { - mms_list_insert_after(drive_list, drive, drive_struct); - return (0); - } - } - mms_list_insert_tail(drive_list, - drive_struct); - return (a_drive); -} - -cmi_drive_list_t * -mm_setup_drive_unmount(mm_command_t *cmd, - mm_db_t *db, - cmi_cart_list_t *cart, - PGresult *drive_results, - int drive_row) { - - cmi_drive_list_t *drive = NULL; - - PGresult *dm; - char *dm_name = NULL; - - char *candidate_drive = PQgetvalue(drive_results, drive_row, 0); - - mms_trace(MMS_DEVP, "mm_setup_drive_unmount"); - - if (mm_db_exec(HERE, db, - "select \"DMName\"" - " from \"DRIVE\" where " - "\"DriveName\" = '%s';", - candidate_drive) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "Error getting dm information"); - mm_sql_db_err_rsp_new(cmd, db); - return (NULL); - } - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_ERR, - "Coudn't find DRIVE for " - "this drive, %s", - candidate_drive); - mm_system_error(cmd, - "missing DRIVE obj during unmount"); - mm_clear_db(&db->mm_db_results); - return (NULL); - } - dm = db->mm_db_results; - dm_name = PQgetvalue(dm, 0, 0); - - drive = NULL; - drive = (cmi_drive_list_t *) - calloc(1, - sizeof (cmi_drive_list_t)); - if (drive == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc"\ - " cmi_drive_list: %s", - strerror(errno)); - mm_system_error(cmd, - "unable to allocate mem for drive stat"); - mm_clear_db(&dm); - return (NULL); - } - drive->cmi_drive_name = - strdup(candidate_drive); - drive->cmi_mode_valid = 1; - drive->cmi_drive_not_ready = 0; - drive->cmi_drive_used = 0; - - drive->cmi_dm_name = mms_strapp(drive->cmi_dm_name, dm_name); - drive->cmi_dm_shape_priority = 0; - drive->cmi_dm_density_priority = 0; - /* Column references must match what is in mm_mount_init_candidates */ - drive->cmi_drv_priority = atoi(PQgetvalue(drive_results, - drive_row, 2)); - drive->cmi_drv_num_mounts = atoi(PQgetvalue(drive_results, - drive_row, 3)); - mms_list_insert_tail(&cart->cmi_drive_list, - drive); - mm_clear_db(&dm); - return (drive); - - -} - -cmi_drive_list_t * -mm_setup_drive(mm_command_t *cmd, - mm_db_t *db, - cmi_cart_list_t *cart, - PGresult *drive_results, - int drive_row) { - - /* drive_results is created in mm_init_candidates */ - - cmi_drive_list_t *drive = NULL; - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - PGresult *dm_shape; - int dm_shape_priority; - int dm_density_priority; - PGresult *dm; - char *dm_name = NULL; - char *cart_type = cart->cmi_cart_type; - char *bit_format = cart->cmi_bit_format; - int drive_not_ready; - int i; - - char *candidate_drive = PQgetvalue(drive_results, - drive_row, 0); - - char *cur_dm_shape; - char *cur_dm_shape_priority; - char *cur_dm_density; - char *cur_dm_density_priority; - - /* get the dm name */ - /* get name by host */ - if (mm_db_exec(HERE, db, - "select \"DMName\"" - " from \"DM\" where " - "\"DriveName\" = '%s' " - "and pg_host_ident(" - "\"DMTargetHost\") " - "= pg_host_ident('%s');", - candidate_drive, - mount_info->cmi_where) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "Error getting dm information"); - mm_sql_db_err_rsp_new(cmd, db); - return (NULL); - } - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_ERR, - "No dm configured for " - "this drive, on host %s", - mount_info->cmi_where); - mm_response_error(cmd, - ECLASS_COMPAT, - "EAPPDMDIFFHOSTS", - MM_5050_MSG, - "host", - mount_info->cmi_where, - NULL); - mm_clear_db(&db->mm_db_results); - return (NULL); - } - dm = db->mm_db_results; - dm_name = PQgetvalue(dm, 0, 0); - /* Check the cartridge shape */ - if (mm_db_exec(HERE, db, - "select \"DMSHAPEPRIORITY\".\"DMName\", " - "\"DMSHAPEPRIORITY\".\"DMShapeName\"," - "\"DMSHAPEPRIORITY\".\"DMShapePriority\"," - "\"DMDENSITYPRIORITY\".\"DMDensityName\"," - "\"DMDENSITYPRIORITY\".\"DMDensityPriority\" from " - "\"DMSHAPEPRIORITY\",\"DMDENSITYPRIORITY\"" - "where " - "\"DMSHAPEPRIORITY\".\"DMName\" = '%s' and " - "\"DMDENSITYPRIORITY\".\"DMName\" = '%s';", - dm_name, - dm_name) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "Error checking cartridge shape"); - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&dm); - return (NULL); - } - drive_not_ready = 0; - if (PQntuples(db->mm_db_results) == 0) { - /* This will be an error for immediate mounts */ - /* for blocking keep drive, and set drive_not_ready */ - mms_trace(MMS_ERR, - "dm has not been configured for this drive"); - drive_not_ready = 1; - - } - dm_shape = db->mm_db_results; - dm_shape_priority = -1; - /* Default density is 1 */ - dm_density_priority = 1; - - for (i = 0; i < PQntuples(dm_shape); i++) { - cur_dm_shape = PQgetvalue(dm_shape, i, 1); - cur_dm_shape_priority = PQgetvalue(dm_shape, i, 2); - cur_dm_density = PQgetvalue(dm_shape, i, 3); - cur_dm_density_priority = PQgetvalue(dm_shape, i, 4); - if (strcmp(cart_type, cur_dm_shape) == 0) { - dm_shape_priority = atoi(cur_dm_shape_priority); - } - if (strcmp(bit_format, cur_dm_density) == 0) { - dm_density_priority = atoi(cur_dm_density_priority); - } - } - if ((dm_shape_priority == -1) && - (drive_not_ready != 1)) { - /* Drive has configed dm, but slot does not match */ - /* Didn't find this dm_shape */ - mms_trace(MMS_ERR, - "dm is not configured for this slot type"); - mm_response_error(cmd, - ECLASS_COMPAT, - "ECARTDRVSLOTMISMATCH", - MM_5097_MSG, - NULL); - mm_clear_db(&dm); - mm_clear_db(&dm_shape); - return (NULL); - } - - mm_clear_db(&dm_shape); - - drive = NULL; - drive = (cmi_drive_list_t *) - calloc(1, - sizeof (cmi_drive_list_t)); - if (drive == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc"\ - " cmi_drive_list: %s", - strerror(errno)); - mm_system_error(cmd, - "unable to allocate mem for drive stat"); - mm_clear_db(&dm); - return (NULL); - } - drive->cmi_drive_name = - strdup(candidate_drive); - drive->cmi_mode_valid = 1; - drive->cmi_drive_not_ready = drive_not_ready; - drive->cmi_drive_used = 0; - - drive->cmi_dm_name = - strdup(PQgetvalue(dm, - 0, 0)); - drive->cmi_dm_shape_priority = dm_shape_priority; - drive->cmi_dm_density_priority = dm_density_priority; - /* Column references must match what is in mm_mount_init_candidates */ - drive->cmi_drv_priority = atoi(PQgetvalue(drive_results, - drive_row, 2)); - drive->cmi_drv_num_mounts = atoi(PQgetvalue(drive_results, - drive_row, 3)); - - - /* Insert Drives into the correct place in the list here */ - /* Drives are already orderd by priority and number mounts */ - /* Enforce shape and density priority here */ - /* Go down the drive list and find where this */ - /* drive's pritoriy group starts */ - /* Then insert the current drive according to dm_shape_priority */ - /* Maintain the original ordering within like prioritys */ - if (mm_insert_next_drive(&cart->cmi_drive_list, - drive)) { - mms_trace(MMS_ERR, - "error inserting drive into list"); - mm_free_cmi_drive(drive); - drive = NULL; - } - mm_clear_db(&dm); - return (drive); -} - -cmi_cart_list_t * -mm_setup_cart(mm_command_t *cmd, - mm_db_t *db, - PGresult *cart_results, - int row_number) { - - cmi_cart_list_t *cart = NULL; - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - /* Column references must match what is in mm_mount_cart_results */ - char *candidate_cartid = PQgetvalue(cart_results, row_number, 0); - char *candidate_library = PQgetvalue(cart_results, row_number, 1); - char *candidate_priority = PQgetvalue(cart_results, row_number, 2); - char *candidate_num_mounts = PQgetvalue(cart_results, row_number, 3); - char *cart_type = PQgetvalue(cart_results, row_number, 4); - char *cart_pcl = PQgetvalue(cart_results, row_number, 5); - char *cart_loaded = PQgetvalue(cart_results, row_number, 6); - - PGresult *partition_results; - char *bit_format = NULL; - - /* Get PARTITION."PartitionBitFormat" */ - if (mm_db_exec(HERE, db, - "select \"PARTITION\".\"PartitionBitFormat\" " - "from \"PARTITION\" where \"CartridgeID\" = '%s';", - candidate_cartid) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mms_trace(MMS_ERR, - "db error getting PartitionBitFormat"); - return (NULL); - } - partition_results = db->mm_db_results; - if (PQntuples(partition_results) == 0) { - mms_trace(MMS_ERR, - "couldn't find PARTITION for %s", - candidate_cartid); - mm_system_error(cmd, - "couldn't find PARTITION"); - mm_clear_db(&partition_results); - return (NULL); - } - bit_format = PQgetvalue(db->mm_db_results, 0, 0); - - - cart = (cmi_cart_list_t *) - calloc(1, sizeof (cmi_cart_list_t)); - if (cart == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc cmi_cart_list: %s", - strerror(errno)); - mm_system_error(cmd, - "unable to allocate mem for drive list"); - mm_clear_db(&partition_results); - return (NULL); - } - mms_list_create(&cart->cmi_drive_list, - sizeof (cmi_drive_list_t), - offsetof(cmi_drive_list_t, - cmi_drive_next)); - - strcpy(cart->cmi_cart_id, candidate_cartid); - cart->cmi_library = NULL; - cart->cmi_library = mms_strapp(cart->cmi_library, - candidate_library); - cart->cmi_cart_pcl = mms_strapp(cart->cmi_cart_pcl, - cart_pcl); - cart->cmi_cart_type = mms_strapp(cart->cmi_cart_type, - cart_type); - cart->cmi_bit_format = mms_strapp(cart->cmi_bit_format, - bit_format); - - cart->cmi_cart_not_ready = 0; - cart->cmi_cart_used = 0; - - cart->cmi_cart_priority = atoi(candidate_priority); - cart->cmi_cart_num_mounts = atoi(candidate_num_mounts); - if ((strcmp(cart_loaded, "true") == 0) || - (strcmp(cart_loaded, "t") == 0)) { - cart->cmi_cart_loaded = 1; - } else { - cart->cmi_cart_loaded = 0; - } - - mms_list_insert_tail(&mount_info->cmi_cart_list, - cart); - - mm_clear_db(&partition_results); - return (cart); -} - -int -mm_mount_candidate_loaded(mm_command_t *cmd) { - - /* - * this function needs to determine if a candidate - * cartridge is already loaded into a candidate drive. - * If there is, it must set the mount_info - * for the cart/lib/drive/dm - */ - - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - cmi_cart_list_t *cart = NULL; - cmi_drive_list_t *drive = NULL; - - char *cur_pcl = NULL; - char *cur_cartid = NULL; - char *cur_library = NULL; - char *cur_dm = NULL; - char *cur_drive = NULL; - - char *drive_pcl = NULL; - - mms_trace(MMS_DEVP, - "mm_mount_candidate_loaded: "); - - mount_info->cmi_mount_cart_loaded = 0; - - /* The list should already be ordered */ - /* select the 1st available */ - mms_list_foreach(&mount_info->cmi_cart_list, cart) { - cur_pcl = cart->cmi_cart_pcl; - cur_library = cart->cmi_library; - cur_cartid = cart->cmi_cart_id; - /* The list should already be ordered */ - /* select the 1st available */ - if (cart->cmi_cart_not_ready || - cart->cmi_cart_used) { - continue; - } - mms_list_foreach(&cart->cmi_drive_list, drive) { - if (drive->cmi_drive_not_ready || - drive->cmi_drive_used) { - continue; - } - if (drive->cmi_drive_loaded) { - drive_pcl = drive->cmi_loaded_pcl; - cur_drive = drive->cmi_drive_name; - cur_dm = drive->cmi_dm_name; - if (strcmp(cur_pcl, drive_pcl) == 0) { - /* set this mount info and return */ - mm_set_mount_info_cart(cur_cartid, - mount_info); - mm_set_mount_info_drive(cur_drive, - mount_info); - mm_set_mount_info_dm(cur_dm, - mount_info); - mm_set_mount_info_library(cur_library, - mount_info); - mount_info->cmi_mount_cart_loaded = 1; - return (1); - } - } - } - } - return (0); - -} -int -mm_mount_open_drive(mm_command_t *cmd) { - /* - * this function needs to determine if there is an - * open drive for a candidate cartridge - * If there is, it must set the mount_info - * for the cart/lib/drive/dm - */ - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - cmi_cart_list_t *cart = NULL; - cmi_drive_list_t *drive = NULL; - - char *cur_cartid = NULL; - char *cur_library = NULL; - char *cur_dm = NULL; - char *cur_drive = NULL; - - mms_trace(MMS_DEVP, - "mm_mount_open_drive: "); - - /* The list should already be ordered */ - /* select the 1st available */ - mms_list_foreach(&mount_info->cmi_cart_list, cart) { - if (cart->cmi_cart_not_ready || - cart->cmi_cart_used) { - continue; - } - cur_library = cart->cmi_library; - cur_cartid = cart->cmi_cart_id; - /* only look at non loaded carts */ - if (cart->cmi_cart_loaded) { - continue; - } - /* The list should already be ordered */ - /* select the 1st available */ - mms_list_foreach(&cart->cmi_drive_list, drive) { - if (drive->cmi_drive_not_ready || - drive->cmi_drive_used) { - continue; - } - /* only look at non-loaded drives */ - if (drive->cmi_drive_loaded) { - continue; - } - cur_drive = drive->cmi_drive_name; - cur_dm = drive->cmi_dm_name; - /* set this mount info and return */ - mm_set_mount_info_cart(cur_cartid, - mount_info); - mm_set_mount_info_drive(cur_drive, - mount_info); - mm_set_mount_info_dm(cur_dm, - mount_info); - mm_set_mount_info_library(cur_library, - mount_info); - return (1); - } - } - return (0); - -} - -int -mm_unmount_2_drive(mm_command_t *cmd, mm_db_t *db) { - /* check if a loaded candidate cartridge */ - /* must be mounted in a drive loaded with a non-candidate */ - /* need unmount candidate drive and candidate cart */ - /* then mount */ - - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - cmi_cart_list_t *cart = NULL; - cmi_drive_list_t *drive = NULL; - - char *cur_cartid = NULL; - char *cur_pcl = NULL; - char *cur_library = NULL; - char *cur_dm = NULL; - char *cur_drive = NULL; - - mms_trace(MMS_DEVP, - "mm_unmount_2_drive: "); - - mms_list_foreach(&mount_info->cmi_cart_list, cart) { - if (cart->cmi_cart_not_ready || - cart->cmi_cart_used) { - continue; - } - cur_library = cart->cmi_library; - cur_cartid = cart->cmi_cart_id; - cur_pcl = cart->cmi_cart_pcl; - mms_list_foreach(&cart->cmi_drive_list, drive) { - if (drive->cmi_drive_not_ready || - drive->cmi_drive_used) { - continue; - } - cur_drive = drive->cmi_drive_name; - cur_dm = drive->cmi_dm_name; - if (cart->cmi_cart_loaded && - drive->cmi_drive_loaded) { - if (mm_db_exec(HERE, db, - "select \"LibraryName\",\"DriveName\" " - "from \"DRIVE\" where \"DRIVE\"." - "\"CartridgePCL\" = '%s' and " - "\"DRIVE\".\"DriveName\" = '%s';", - cur_pcl, cur_drive) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "mm_unmount_2_drive:" - " db error reading data"); - mm_clear_db(&db->mm_db_results); - continue; - } - - if (PQntuples(db->mm_db_results) == 0) { - /* Cur cart is not loaded */ - mms_trace(MMS_ERR, - "%s not found in drive %s", - cur_pcl, cur_drive); - mm_clear_db(&db->mm_db_results); - continue; - } - - mm_set_mount_info_cart(cur_cartid, - mount_info); - mm_set_mount_info_drive(cur_drive, - mount_info); - mm_set_mount_info_dm(cur_dm, - mount_info); - mm_set_mount_info_library(cur_library, - mount_info); - mms_trace(MMS_DEVP, - "** 2 Unmount Summary **"); - mms_trace(MMS_DEVP, - "1st unmount %s %s", - cur_library, - cur_drive); - mms_trace(MMS_DEVP, - "2nd unmount %s %s", - PQgetvalue(db->mm_db_results, 0, 0), - PQgetvalue(db->mm_db_results, 0, 1)); - - mount_info->cmi_first_lib = - strdup(cur_library); - mount_info->cmi_first_drive = - strdup(cur_drive); - mount_info->cmi_second_lib = - strdup(PQgetvalue(db->mm_db_results, 0, 0)); - mount_info->cmi_second_drive = - strdup(PQgetvalue(db->mm_db_results, 0, 1)); - - - mm_clear_db(&db->mm_db_results); - return (1); - } - } - } - return (0); - -} - -int -mm_mount_loaded_drive(mm_command_t *cmd, mm_db_t *db, - char **drive_to_unload, char **lib_to_unload) { - /* - * this function needs to determine if a candidate - * cartridge must be mounted on a drive already loaded - * with a non-candidate cartridge that needs to be unmounted - * OR - * If a candidate cartridge is loaded in a non-candidate drive - * that 1st must be unmounted - * If there is, it must set the mount_info - * for the cart/lib/drive/dm - */ - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - cmi_cart_list_t *cart = NULL; - cmi_drive_list_t *drive = NULL; - - char *cur_cartid = NULL; - char *cur_pcl = NULL; - char *cur_library = NULL; - char *cur_dm = NULL; - char *cur_drive = NULL; - - mms_trace(MMS_DEVP, - "mm_mount_loaded_drive: "); - - /* The list should already be ordered */ - /* select the 1st available */ - mms_list_foreach(&mount_info->cmi_cart_list, cart) { - if (cart->cmi_cart_not_ready || - cart->cmi_cart_used) { - continue; - } - cur_library = cart->cmi_library; - cur_cartid = cart->cmi_cart_id; - cur_pcl = cart->cmi_cart_pcl; - - /* If the cartridge is not mounted */ - - /* The list should already be ordered */ - /* select the 1st available */ - - mms_list_foreach(&cart->cmi_drive_list, drive) { - if (drive->cmi_drive_not_ready || - drive->cmi_drive_used) { - continue; - } - cur_drive = drive->cmi_drive_name; - cur_dm = drive->cmi_dm_name; - - if (cart->cmi_cart_loaded && - (drive->cmi_drive_loaded == 0)) { - /* Candidate is loaded and drive is empty */ - - /* this candidate cart is loaded in a drive */ - /* Get the lib/drive name where */ - /* this cartridge is mounted */ - if (mm_db_exec(HERE, db, - "select \"LibraryName\",\"DriveName\" " - "from \"DRIVE\" where \"DRIVE\"." - "\"CartridgePCL\" = '%s';", - cur_pcl) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "mm_mount_loaded_drive: " - "db error getting data"); - continue; - } - - if (PQntuples(db->mm_db_results) == 0) { - /* Cur cart is not loaded */ - mms_trace(MMS_ERR, - "%s not found in a drive", - cur_pcl); - mm_clear_db(&db->mm_db_results); - continue; - } else { - /* cur cart is loaded */ - *(drive_to_unload) = - mms_strapp(*(drive_to_unload), - PQgetvalue(db->mm_db_results, - 0, 1)); - *(lib_to_unload) = - mms_strapp(*(lib_to_unload), - PQgetvalue(db->mm_db_results, - 0, 0)); - mms_trace(MMS_DEVP, - "%s loaded in %s %s", - cur_pcl, - PQgetvalue(db->mm_db_results, - 0, 0), - PQgetvalue(db->mm_db_results, - 0, 1)); - } - mm_clear_db(&db->mm_db_results); - - mm_set_mount_info_cart(cur_cartid, - mount_info); - mm_set_mount_info_drive(cur_drive, - mount_info); - mm_set_mount_info_dm(cur_dm, - mount_info); - mm_set_mount_info_library(cur_library, - mount_info); - return (1); - - } else if ((cart->cmi_cart_loaded == 0) && - (drive->cmi_drive_loaded == 1)) { - - /* set this mount info and return */ - *(drive_to_unload) = NULL; - *(lib_to_unload) = NULL; - mm_set_mount_info_cart(cur_cartid, - mount_info); - mm_set_mount_info_drive(cur_drive, - mount_info); - mm_set_mount_info_dm(cur_dm, - mount_info); - mm_set_mount_info_library(cur_library, - mount_info); - return (1); - } - } - } - return (0); -} - -int -mm_set_immediate_unmount(mm_command_t *cmd, mm_db_t *db) { - - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - cmi_cart_list_t *cart = NULL; - cmi_drive_list_t *drive = NULL; - - char *cur_cartid = NULL; - char *cur_library = NULL; - char *cur_dm = NULL; - char *cur_drive = NULL; - - - int rc = MM_CMD_DONE; - - - /* The list should already be ordered */ - /* select the 1st available */ - - cart = mms_list_head(&mount_info->cmi_cart_list); - if (cart == NULL) { - mms_trace(MMS_ERR, - "internal error setting cmi info, " - "cannot find candidate carts structfound"); - mm_system_error(cmd, - "internal error setting cmi info, " - "no candidate carts found"); - return (MM_CMD_ERROR); - } - cur_library = cart->cmi_library; - cur_cartid = cart->cmi_cart_id; - - drive = mms_list_head(&cart->cmi_drive_list); - if (drive == NULL) { - mms_trace(MMS_ERR, - "internal error setting cmi info, " - "no candidate drives found"); - mm_system_error(cmd, - "internal error setting cmi info, " - "no candidate drives found"); - return (MM_CMD_ERROR); - } - - cur_drive = drive->cmi_drive_name; - cur_dm = drive->cmi_dm_name; - - - mm_set_mount_info_cart(cur_cartid, - mount_info); - mm_set_mount_info_drive(cur_drive, - mount_info); - mm_set_mount_info_dm(cur_dm, - mount_info); - mm_set_mount_info_library(cur_library, - mount_info); - if (mount_info->cmi_pcl == NULL) { - mount_info->cmi_pcl = - mm_get_cart_pcl(cmd, mount_info->cmi_cartridge, db); - } - /* Select Is done - print the results */ - mms_trace(MMS_DEVP, "Cart/Lib/Drive selection " - "complete for task %s", - cmd->cmd_uuid); - mms_trace(MMS_DEVP, "Cartridge ID is %s", - mount_info->cmi_cartridge); - mms_trace(MMS_DEVP, "Cartridge PCL is %s", - mount_info->cmi_pcl); - mms_trace(MMS_DEVP, "Library is %s", - mount_info->cmi_library); - mms_trace(MMS_DEVP, "Drive is %s", - mount_info->cmi_drive); - mms_trace(MMS_DEVP, "DM is %s", - mount_info->cmi_dm); - - if (mm_db_exec(HERE, db, "delete from \"TASK\" " - "where \"TaskID\" = '%s';", - cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_unmount: " - "db error removing TASK"); - } - - if (mm_new_tm_task(db, cmd, "dispatched") != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_unmount: " - "db error creating TASK"); - } - - /* Delete all old TASK objects and create them anew */ - if (mm_db_exec(HERE, db, "delete from \"TASKDRIVE\" " - "where \"TaskID\" = '%s';", - cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_unmount: " - "db error removing TASKDRIVE"); - } - if (mm_db_exec(HERE, db, "delete from \"TASKLIBRARY\" " - "where \"TaskID\" = '%s';", - cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_unmount: " - "db error removing TASKLIBRARY"); - } - if (mm_db_exec(HERE, db, "delete from \"TASKCARTRIDGE\" " - "where \"TaskID\" = '%s';", - cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_unmount: " - "db error removing TASKCARTRIDGE"); - } - - - if (mm_set_tm_drive(db, - cmd->cmd_uuid, - mount_info->cmi_drive) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_unmount: " - "db error setting TASKDRIVE"); - } - if (mm_set_tm_library(db, - cmd->cmd_uuid, - mount_info->cmi_library) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_unmount: " - "db error setting TASKLIBRARY"); - } - - if (mm_set_tm_cartridge(db, - cmd->cmd_uuid, - mount_info->cmi_cartridge) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_unmount: " - "db error setting TASKCARTRIDGE"); - } - - if (mm_db_exec(HERE, db, "update \"DRIVE\"" - "set \"DriveStateSoft\" = 'in use'" - "where \"DriveName\" = '%s';", - mount_info->cmi_drive) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_unmount: " - "db error setting DriveStateSoft"); - } - if (mm_db_exec(HERE, db, "update \"DRIVE\"" - "set \"DMName\" = '%s' " - "where \"DriveName\" = '%s';", - mount_info->cmi_dm, - mount_info->cmi_drive) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_unmount: " - "db error setting DMName"); - } - - if (mm_db_exec(HERE, db, - "update \"CARTRIDGE\" set " - "\"CartridgeStatus\" = 'in use' " - "where \"CartridgeID\" = '%s';", - mount_info->cmi_cartridge) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_unmount: " - "db error setting CartridgeStatus"); - } - - - return (rc); - -} -void -mm_set_mount_objs(mm_command_t *cmd, mm_db_t *db) { - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - - - if (mm_db_exec(HERE, db, "delete from \"TASK\" " - "where \"TaskID\" = '%s';", - cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_mount_objs: " - "db error deleting TASK"); - } - - /* Delete all old TASK objects and create them anew */ - if (mm_db_exec(HERE, db, "delete from \"TASKDRIVE\" " - "where \"TaskID\" = '%s';", - cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_mount_objs: " - "db error deleting TASKDRIVE"); - } - if (mm_db_exec(HERE, db, "delete from \"TASKLIBRARY\" " - "where \"TaskID\" = '%s';", - cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_mount_objs: " - "db error deleting TASKLIBRARY"); - } - if (mm_db_exec(HERE, db, "delete from \"TASKCARTRIDGE\" " - "where \"TaskID\" = '%s';", - cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_mount_objs: " - "db error deleting TASKCARTRIDGE"); - } - - if ((mount_info->cmi_drive == NULL) || - (mount_info->cmi_library == NULL) || - (mount_info->cmi_cartridge == NULL) || - (mount_info->cmi_dm == NULL)) { - mms_trace(MMS_ERR, - "mm_set_mount_objs: " - "mount info incomplete"); - mm_system_error(cmd, - "internal error setting task info, " - "mount info incomplete"); - return; - } - - if (mm_new_tm_task(db, cmd, "dispatched") != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_mount_objs: " - "db error inserting TASK"); - } - - if (mm_set_tm_drive(db, - cmd->cmd_uuid, - mount_info->cmi_drive) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_mount_objs: " - "db error inserting TASKDRIVE"); - } - if (mm_set_tm_library(db, - cmd->cmd_uuid, - mount_info->cmi_library) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_mount_objs: " - "db error inserting TASKLIBRARY"); - } - if (mm_set_tm_cartridge(db, - cmd->cmd_uuid, - mount_info->cmi_cartridge) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_mount_objs: " - "db error inserting TASKCARTRIDGE"); - } - - if (mm_db_exec(HERE, db, "update \"DRIVE\"" - "set \"DriveStateSoft\" = 'in use'" - "where \"DriveName\" = '%s';", - mount_info->cmi_drive) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_mount_objs: " - "db error updating DriveStateSoft"); - } - if (mm_db_exec(HERE, db, "update \"DRIVE\"" - "set \"DMName\" = '%s' " - "where \"DriveName\" = '%s';", - mount_info->cmi_dm, - mount_info->cmi_drive) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_mount_objs: " - "db error updating DMName"); - } - - if (mm_db_exec(HERE, db, - "update \"CARTRIDGE\" set " - "\"CartridgeStatus\" = 'in use' " - "where \"CartridgeID\" = '%s';", - mount_info->cmi_cartridge) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_mount_objs: " - "db error updating CartridgeStatus"); - } - -} - -int -mm_dispatch_now(mm_wka_t *mm_wka, mm_command_t *cmd, mm_db_t *db) { - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - mm_command_t *unmnt_cmd_1 = NULL; - mm_command_t *unmnt_cmd_2 = NULL; - - /* This function is used to setup the command */ - /* flags and depend pointers for the mount */ - - /* Need to set error message in this function */ - if (mount_info->cmi_mount_type == - MM_CANDIDATE_LOADED) { - mms_trace(MMS_DEVP, - "MM_CANDIDATE_LOADED"); - /* Remove the delay unload command */ - (void) mm_remove_unload(mount_info->cmi_library, - mount_info->cmi_drive, - mm_wka->mm_data); - return (0); - } - if (mount_info->cmi_mount_type == - MM_OPEN_DRIVE) { - mms_trace(MMS_DEVP, - "MM_OPEN_DRIVE"); - return (0); - } - if (mount_info->cmi_mount_type == - MM_UNMOUNT_DRIVE) { - mms_trace(MMS_DEVP, - "MM_UNMOUNT_DRIVE"); - /* Set the delay unload for immdiate dispatch */ - if (mm_dispatch_unload(mount_info->cmi_library, - mount_info->cmi_drive, - cmd, - mm_wka->mm_data) == NULL) { - /* Instead of return error */ - /* attempt to fix by adding a clear_drive */ - /* for this drive, set this */ - /* command as parent of */ - /* the clear drive */ - mms_trace(MMS_ERR, - "could not find delay unload, " - "attempt to clear and continue"); - if (mm_add_clear_drive(mount_info->cmi_drive, - mm_wka->mm_data, - db, cmd, NULL, 1, 0) == NULL) { - mm_system_error(cmd, - "error adding clear drive cmd"); - return (1); - } - } - MM_UNSET_FLAG(cmd->cmd_flags, MM_CMD_DISPATCHABLE); - return (0); - } - if (mount_info->cmi_mount_type == - MM_UNMOUNT_CART) { - mms_trace(MMS_DEVP, - "MM_UNMOUNT_CART"); - /* Set the delay unload for immdiate dispatch */ - if (mm_dispatch_unload(mount_info-> - cmi_first_lib, - mount_info->cmi_first_drive, - cmd, - mm_wka->mm_data) == NULL) { - /* Instead of return error */ - /* attempt to fix by adding a clear_drive */ - /* for this drive, set this */ - /* command as parent of */ - /* the clear drive */ - mms_trace(MMS_ERR, - "could not find delay unload, " - "attempt to clear and continue"); - if (mm_add_clear_drive(mount_info-> - cmi_first_drive, - mm_wka->mm_data, - db, cmd, NULL, 1, 0) == NULL) { - mm_system_error(cmd, - "error adding clear drive cmd"); - return (1); - } - } - MM_UNSET_FLAG(cmd->cmd_flags, MM_CMD_DISPATCHABLE); - return (0); - } - if (mount_info->cmi_mount_type == - MM_UNMOUNT_2) { - mms_trace(MMS_DEVP, - "MM_UNMOUNT_2"); - if ((unmnt_cmd_1 = - mm_dispatch_unload(mount_info->cmi_first_lib, - mount_info->cmi_first_drive, - NULL, - mm_wka->mm_data)) == NULL) { - mms_trace(MMS_ERR, - "error finding unmount command"); - - if ((unmnt_cmd_1 = - mm_add_clear_drive(mount_info->cmi_first_drive, - mm_wka->mm_data, - db, cmd, NULL, 1, 0)) == NULL) { - mm_system_error(cmd, - "error adding clear drive cmd"); - return (1); - } - } - - if ((unmnt_cmd_2 = - mm_return_unload(mount_info->cmi_second_lib, - mount_info->cmi_second_drive, - mm_wka->mm_data)) == NULL) { - mms_trace(MMS_ERR, - "error finding unmount command"); - if ((unmnt_cmd_2 = - mm_add_clear_drive(mount_info->cmi_second_drive, - mm_wka->mm_data, - db, cmd, NULL, 1, 0)) == NULL) { - mm_system_error(cmd, - "error adding clear drive cmd"); - return (1); - } - } - mm_add_depend(unmnt_cmd_1, unmnt_cmd_2); - mm_add_depend(unmnt_cmd_2, cmd); - MM_SET_FLAG(unmnt_cmd_1->cmd_flags, - MM_CMD_DISPATCHABLE); - MM_UNSET_FLAG(unmnt_cmd_2->cmd_flags, - MM_CMD_DISPATCHABLE); - MM_UNSET_FLAG(cmd->cmd_flags, - MM_CMD_DISPATCHABLE); - return (0); - } - mm_system_error(cmd, - "encountered unknown mount type"); - return (1); - -} - -int -mm_set_immediate_mount(mm_wka_t *mm_wka, mm_command_t *cmd, mm_db_t *db) { - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - int rc = MM_CMD_DONE; - - char *drive_to_unload = NULL; - char *lib_to_unload = NULL; - - mms_trace(MMS_DEVP, "mm_set_immediate_mount"); - - /* select the exact cart/drive/dm/lib combination */ - - /* Every candidate is currently in a ready state */ - /* Drives may be loaded with a cartridge */ - /* Cartridge could be: */ - /* a. a non-candidate cartridge */ - /* b. a candidate cartridge */ - - /* If a candidate drive has a candidate loaded, use that now */ - /* If their are no candidate cartridge's loaded, */ - /* try to find an open drive */ - /* If there are no open drives, use a drive loaded */ - /* with a non-candidate cartridge */ - - if (mm_mount_candidate_loaded(cmd)) { - /* 0 mount time */ - mms_trace(MMS_DEVP, - "a candidate cartridge is loaded"); - mount_info->cmi_mount_type = - MM_CANDIDATE_LOADED; - } else if (mm_mount_open_drive(cmd)) { - /* 1 mount time */ - mms_trace(MMS_DEVP, - "open drive found"); - mount_info->cmi_mount_type = - MM_OPEN_DRIVE; - } else if (mm_mount_loaded_drive(cmd, db, &drive_to_unload, - &lib_to_unload)) { - /* 2 mount time */ - /* these mounts need an unmount, then mount */ - if (drive_to_unload == NULL && - lib_to_unload == NULL) { - mount_info->cmi_mount_type = - MM_UNMOUNT_DRIVE; - mms_trace(MMS_DEVP, - "drive loaded with non-candidate " - "must unload 1st"); - /* Need to set up parent command */ - /* return as dispatch depend */ - mms_trace(MMS_DEVP, - "%s needs unload to complete first", - mount_info->cmi_drive); - MM_UNSET_FLAG(cmd->cmd_flags, - MM_CMD_DISPATCHABLE); - rc = MM_DISPATCH_DEPEND; - } else { - mms_trace(MMS_DEVP, - "candidate loaded in non-candidate drive " - "must unload 1st"); - mount_info->cmi_mount_type = - MM_UNMOUNT_CART; - mount_info->cmi_first_drive = - strdup(drive_to_unload); - mount_info->cmi_first_lib = - strdup(lib_to_unload); - - /* Need to set up parent command */ - /* return as dispatch depend */ - mms_trace(MMS_DEVP, - "%s needs unload to complete first", - drive_to_unload); - MM_UNSET_FLAG(cmd->cmd_flags, - MM_CMD_DISPATCHABLE); - rc = MM_DISPATCH_DEPEND; - free(drive_to_unload); - free(lib_to_unload); - } - - } else if (mm_unmount_2_drive(cmd, db)) { - mount_info->cmi_mount_type = - MM_UNMOUNT_2; - /* 3 mount time */ - /* Candidate cart is mounted, */ - /* the only candidate drive is loaded with non-candidate */ - /* need to unmount candidate cart, unmount candidate drive */ - /* then mount candidate cart/drive */ - MM_UNSET_FLAG(cmd->cmd_flags, MM_CMD_DISPATCHABLE); - rc = MM_DISPATCH_DEPEND; - } else { - - /* should never reach herer */ - mms_trace(MMS_ERR, - "MMS_ERROR - no drives found"); - mm_system_error(cmd, - "internal error, " - "could not find ready drive, " - "submitt a bug if you hit this!," - "MM internal states out of sync"); - mms_trace(MMS_INFO, "mm_set_immediate_mount: " - "returning MM_RESYNC"); - return (MM_RESYNC); - - } - - if (mount_info->cmi_pcl == NULL) { - mount_info->cmi_pcl = - mm_get_cart_pcl(cmd, mount_info->cmi_cartridge, db); - } - - /* call function to kick off delay unmounts */ - - if (mm_dispatch_now(mm_wka, cmd, db)) { - /* error should be set */ - mms_trace(MMS_ERR, - "error setting up mount for dispatch"); - return (MM_CMD_ERROR); - } - - /* Select Is done - print the results */ - mms_trace(MMS_DEVP, "Cart/Lib/Drive selection " - "complete for task %s", - cmd->cmd_uuid); - mms_trace(MMS_DEVP, "Cartridge ID is %s", - mount_info->cmi_cartridge); - mms_trace(MMS_DEVP, "Cartridge PCL is %s", - mount_info->cmi_pcl); - mms_trace(MMS_DEVP, "Library is %s", - mount_info->cmi_library); - mms_trace(MMS_DEVP, "Drive is %s", - mount_info->cmi_drive); - mms_trace(MMS_DEVP, "DM is %s", - mount_info->cmi_dm); - - if (mm_db_exec(HERE, db, "delete from \"TASK\" " - "where \"TaskID\" = '%s';", - cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_mount: " - "db error removing TASK"); - } - - if (mm_new_tm_task(db, cmd, "dispatched") != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_mount: " - "db error creating TASK"); - } - - /* Delete all old TASK objects and create them anew */ - if (mm_db_exec(HERE, db, "delete from \"TASKDRIVE\" " - "where \"TaskID\" = '%s';", - cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_mount: " - "db error removing TASKDRIVE"); - } - if (mm_db_exec(HERE, db, "delete from \"TASKLIBRARY\" " - "where \"TaskID\" = '%s';", - cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_mount: " - "db error removing TASKLIBRARY"); - } - if (mm_db_exec(HERE, db, "delete from \"TASKCARTRIDGE\" " - "where \"TaskID\" = '%s';", - cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_mount: " - "db error removing TASKCARTRIDGE"); - } - - - if (mm_set_tm_drive(db, - cmd->cmd_uuid, - mount_info->cmi_drive) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_mount: " - "db error creating TASKDRIVE"); - } - if (mm_set_tm_library(db, - cmd->cmd_uuid, - mount_info->cmi_library) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_mount: " - "db error creating TASKLIBRARY"); - } - if (mm_set_tm_cartridge(db, - cmd->cmd_uuid, - mount_info->cmi_cartridge) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_mount: " - "db error creating TASKCARTRIDGE"); - } - - if (mm_db_exec(HERE, db, "update \"DRIVE\"" \ - "set \"DriveStateSoft\" = 'in use'" \ - "where \"DriveName\" = '%s';", - mount_info->cmi_drive) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_mount: " - "db error updating DriveStateSoft"); - } - if (mm_db_exec(HERE, db, "update \"DRIVE\""\ - "set \"DMName\" = '%s' "\ - "where \"DriveName\" = '%s';", - mount_info->cmi_dm, - mount_info->cmi_drive) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_mount: " - "db error updating DMName"); - } - if (mm_db_exec(HERE, db, - "update \"CARTRIDGE\" set " - "\"CartridgeStatus\" = 'in use' " - "where \"CartridgeID\" = '%s';", - mount_info->cmi_cartridge) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_immediate_mount: " - "db error updating CartridgeStatus"); - } - - - return (rc); - - -} - - -int -mm_parse_mount_cmd(mm_wka_t *mm_wka, mm_command_t *cmd) { - - cci_t *conn = &mm_wka->wka_conn; - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - mms_par_node_t *arg; - mms_par_node_t *value; - mms_par_node_t *work = NULL; - mms_par_node_t *item = NULL; - int go; - int count; - - char *dm_host; - - cmi_mode_list_t *mode = NULL; - - mms_trace(MMS_DEVP, "mm_parse_mount_cmd"); - mount_info->cmi_operation = MM_MOUNT; - - - /* Get the type */ - mms_trace(MMS_DEVP, "type"); - MMS_PN_LOOKUP(arg, cmd->cmd_root, "type", - MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, arg, NULL, MMS_PN_KEYWORD, NULL); - if (strcmp(value->pn_string, "SIDE") == 0) { - mount_info->cmi_type = MM_SIDE; - } else if (strcmp(value->pn_string, "PARTITION") == 0) { - mount_info->cmi_type = MM_PARTITION; - } else if (strcmp(value->pn_string, "VOLUME") == 0) { - mount_info->cmi_type = MM_VOLUME; - } else { - mms_trace(MMS_ERR, "Invalid mount type specified"); - mm_response_error(cmd, - EINVALIDTYPE, - ESYNTAX, - MM_5051_MSG, - NULL); - return (MM_CMD_ERROR); - } - - /* Get when */ - mms_trace(MMS_DEVP, "when"); - arg = mms_pn_lookup(cmd->cmd_root, "when", - MMS_PN_CLAUSE, NULL); - if (arg != NULL) { - MMS_PN_LOOKUP(value, - arg, NULL, MMS_PN_KEYWORD, NULL); - if (strcmp(value->pn_string, "blocking") == 0) { - mount_info->cmi_when = MM_BLOCKING; - } else { - mount_info->cmi_when = MM_IMMEDIATE; - } - } else { - /* when is optional and defaults to immediate */ - mount_info->cmi_when = MM_IMMEDIATE; - } - - /* Get where */ - mms_trace(MMS_DEVP, "where"); - work = NULL; - arg = mms_pn_lookup(cmd->cmd_root, "where", - MMS_PN_CLAUSE, &work); - if (arg != NULL) { - MMS_PN_LOOKUP(value, arg, NULL, - MMS_PN_STRING, NULL); - if (value->pn_string != NULL) { - dm_host = value->pn_string; - } else { - dm_host = mm_cci_host_ident(conn); - } - } else { - mms_trace(MMS_DEVP, "Didn't find a where clause..."); - dm_host = mm_cci_host_ident(conn); - } - mount_info->cmi_where = mm_host_ident(dm_host); - mms_trace(MMS_DEVP, "where %s", mount_info->cmi_where); - - /* Get File Name - Optional */ - mms_trace(MMS_DEVP, "filename"); - work = NULL; - arg = mms_pn_lookup(cmd->cmd_root, "filename", - MMS_PN_CLAUSE, &work); - if (arg != NULL) { - MMS_PN_LOOKUP(value, arg, NULL, - MMS_PN_STRING, NULL); - if (value->pn_string != NULL) { - mount_info->cmi_filename = - strdup(value->pn_string); - } else { - mount_info->cmi_filename = NULL; - } - } else { - mms_trace(MMS_DEVP, "Didn't find a filename clause..."); - mount_info->cmi_filename = NULL; - } - /* Get BlockSize - Optional */ - mms_trace(MMS_DEVP, "blocksize"); - work = NULL; - arg = mms_pn_lookup(cmd->cmd_root, "blocksize", - MMS_PN_CLAUSE, &work); - if (arg != NULL) { - MMS_PN_LOOKUP(value, arg, NULL, - MMS_PN_STRING, NULL); - if (value->pn_string != NULL) { - mount_info->cmi_blocksize = - strdup(value->pn_string); - } else { - mount_info->cmi_blocksize = NULL; - } - } else { - mms_trace(MMS_DEVP, "Didn't find a blocksize clause..."); - mount_info->cmi_blocksize = NULL; - } - /* Get volumeid - Optional */ - mms_trace(MMS_DEVP, "volumeid"); - work = NULL; - arg = mms_pn_lookup(cmd->cmd_root, "volumeid", - MMS_PN_CLAUSE, &work); - if (arg != NULL) { - MMS_PN_LOOKUP(value, arg, NULL, - MMS_PN_STRING, NULL); - if (value->pn_string != NULL) { - mount_info->cmi_volumeid = - strdup(value->pn_string); - } else { - mount_info->cmi_volumeid = NULL; - } - } else { - mms_trace(MMS_DEVP, "Didn't find a volumeid clause..."); - mount_info->cmi_volumeid = NULL; - } - /* Get filesequence - Optional */ - mms_trace(MMS_DEVP, "filesequence"); - work = NULL; - arg = mms_pn_lookup(cmd->cmd_root, "filesequence", - MMS_PN_CLAUSE, &work); - if (arg != NULL) { - MMS_PN_LOOKUP(value, arg, NULL, - MMS_PN_STRING, NULL); - if (value->pn_string != NULL) { - mount_info->cmi_filesequence = - strdup(value->pn_string); - } else { - mount_info->cmi_filesequence = NULL; - } - } else { - mms_trace(MMS_DEVP, "Didn't find a filesequence clause..."); - mount_info->cmi_filesequence = NULL; - } - /* Get user - Optional */ - mms_trace(MMS_DEVP, "user"); - work = NULL; - arg = mms_pn_lookup(cmd->cmd_root, "user", - MMS_PN_CLAUSE, &work); - if (arg != NULL) { - MMS_PN_LOOKUP(value, arg, NULL, - MMS_PN_STRING, NULL); - if (value->pn_string != NULL) { - mount_info->cmi_user = - strdup(value->pn_string); - } else { - mount_info->cmi_user = NULL; - } - } else { - mms_trace(MMS_DEVP, "Didn't find a user clause..."); - mount_info->cmi_user = NULL; - } - - /* Get First Mount Clause */ - mms_trace(MMS_DEVP, "firstmount"); - work = NULL; - arg = mms_pn_lookup(cmd->cmd_root, "firstmount", - MMS_PN_CLAUSE, &work); - item = NULL; - if (arg != NULL) { - count = 0; - go = 1; - while (go) { - - if ((value = - mms_pn_lookup(arg, NULL, - MMS_PN_STRING, - &item)) == NULL) { - go = 0; - } else { - mount_info->cmi_firstmount[count] = - value->pn_string; - count ++; - } - - } - mount_info->cmi_num_firstmount = count; - } else { - mms_trace(MMS_DEVP, "Didin't find a first mount clause"); - } - - /* Get Access Mode Clause */ - mms_trace(MMS_DEVP, "accessmode"); - - work = NULL; - for (arg = mms_pn_lookup(cmd->cmd_root, "accessmode", - MMS_PN_CLAUSE, &work); - arg != NULL; - arg = mms_pn_lookup(cmd->cmd_root, "accessmode", - MMS_PN_CLAUSE, &work)) { - /* Malloc a new mode object */ - mode = (cmi_mode_list_t *) - calloc(1, sizeof (cmi_mode_list_t)); - if (mode == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc cmi_mode_list: %s", - strerror(errno)); - mm_system_error(cmd, - "unable to allocate " - "memory for mode list"); - return (MM_CMD_ERROR); - } - /* Get all of the access Mode tokens */ - item = NULL; - count = 0; - go = 1; - while (go) { - if ((value = - mms_pn_lookup(arg, NULL, - MMS_PN_STRING, - &item)) == NULL) { - go = 0; - } else { - mode->cmi_accessmode[count] = - value->pn_string; - count ++; - } - } - /* Put this access mode into the Accessmode list */ - mount_info->cmi_total_modes ++; - mode->cmi_num_accessmode = count; - mms_list_insert_tail(&mount_info->cmi_mode_list, mode); - } - - /* Get retention clause */ - /* Get user - Optional */ - mms_trace(MMS_DEVP, "retention"); - work = NULL; - arg = mms_pn_lookup(cmd->cmd_root, "retention", - MMS_PN_CLAUSE, &work); - if (arg != NULL) { - MMS_PN_LOOKUP(value, arg, NULL, - MMS_PN_STRING, NULL); - if (value->pn_string != NULL) { - mount_info->cmi_retention = - strdup(value->pn_string); - } else { - mount_info->cmi_retention = NULL; - } - } else { - mms_trace(MMS_DEVP, "Didn't find a retention clause"); - mount_info->cmi_retention = NULL; - } - return (MM_CMD_DONE); - - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -} - - -void -mm_mount_clean_candidates(mm_command_t *cmd) { - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - cmi_cart_list_t *cart = NULL; - cmi_drive_list_t *drive = NULL; - - int has_drive = 0; - - - cmi_cart_list_t *next_cart; - - cmi_drive_list_t *next_drive; - - - mms_trace(MMS_DEVP, "mm_mount_clean_candidates"); - - - /* Cannot use mms_list_foreach when removing list elements */ - /* For each cart */ - for (cart = mms_list_head(&mount_info-> - cmi_cart_list); - cart != NULL; - cart = next_cart) { - next_cart = - mms_list_next(&mount_info-> - cmi_cart_list, - cart); - - mms_trace(MMS_DEVP, " check cart %s", - cart->cmi_cart_pcl); - has_drive = 0; - - /* For each drive */ - for (drive = mms_list_head(&cart-> - cmi_drive_list); - drive != NULL; - drive = next_drive) { - next_drive = - mms_list_next(&cart-> - cmi_drive_list, - drive); - - mms_trace(MMS_DEVP, " check drive %s", - drive->cmi_drive_name); - if (drive->cmi_remove_drive) { - mms_list_remove(&cart-> - cmi_drive_list, - drive); - mms_trace(MMS_DEVP, - " free drive %s", - drive->cmi_drive_name); - mm_free_cmi_drive(drive); - } else { - mms_trace(MMS_DEVP, - " drive good, %s", - drive->cmi_drive_name); - has_drive = 1; - } - } - if (has_drive == 0) - cart->cmi_remove_cart = 1; - if (cart->cmi_remove_cart) { - mms_list_remove(&mount_info->cmi_cart_list, cart); - mms_trace(MMS_DEVP, - " free cart, %s", - cart->cmi_cart_pcl); - mm_free_cmi_cart(cart); - } else { - mms_trace(MMS_DEVP, - " cart good, %s", - cart->cmi_cart_pcl); - } - } - -} - -int -mm_mount_check_candidates(mm_wka_t *mm_wka, mm_command_t *cmd, - mm_db_t *db) { - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - cmi_cart_list_t *cart = NULL; - cmi_drive_list_t *drive = NULL; - - char *candidate_cartid = NULL; - char *candidate_drive = NULL; - - mms_list_foreach(&mount_info->cmi_cart_list, cart) { - - candidate_cartid = cart->cmi_cart_id; - - mms_trace(MMS_INFO, "Check Cartridge, %s", - candidate_cartid); - - if (mm_candidate_cartridge_ok(mm_wka, - cmd, db, - cart)) { - /* Cartridge is ok */ - if (cart->cmi_cart_not_ready) { - mms_trace(MMS_DEVP, - "cartridge %s is not " - "ready/in use", - candidate_cartid); - } else { - mms_trace(MMS_DEVP, - "Cartridge, %s, is available", - candidate_cartid); - } - } else { - /* Cartridge not available */ - mms_trace(MMS_DEVP, - "Cartridge, %s, is not " - "available for mount", - candidate_cartid); - cart->cmi_remove_cart = 1; - /* Go on to next cartridge */ - continue; - } - - - mms_list_foreach(&cart->cmi_drive_list, drive) { - - candidate_drive = drive->cmi_drive_name; - if (cart->cmi_cart_not_ready) { - drive->cmi_drive_not_ready = 1; - continue; - } - - mms_trace(MMS_INFO, - "Check Drive, %s", candidate_drive); - if (mm_candidate_drive_ok(mm_wka, - cmd, db, - candidate_cartid, - drive)) { - if (drive->cmi_drive_not_ready) { - mms_trace(MMS_DEVP, - "Drive, %s, is not ready/in use", - candidate_drive); - } else { - mms_trace(MMS_DEVP, - "Drive, %s, is available", - candidate_drive); - } - } else { - mms_trace(MMS_DEVP, - "Drive, %s, not available" - " for mounts", - candidate_drive); - drive->cmi_remove_drive = 1; - } - } - } - - mm_mount_clean_candidates(cmd); - return (0); -} - -int -mm_mount_init_candidates(mm_command_t *cmd, - PGresult *cart_results, mm_db_t *db) { - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - - cmi_cart_list_t *cur_cart; - - - int cart_rows; - int cart_row; - int drive_rows; - int drive_row; - - char *candidate_library = NULL; - char *candidate_drive = NULL; - char *candidate_cartid = NULL; - - - - PGresult *drive_results; - - cart_rows = PQntuples(cart_results); - mm_free_cmi_cart_list(&mount_info->cmi_cart_list); - - for (cart_row = 0; cart_row < cart_rows; cart_row ++) { - candidate_cartid = PQgetvalue(cart_results, cart_row, 0); - candidate_library = PQgetvalue(cart_results, cart_row, 1); - mms_trace(MMS_DEVP, - "mm_mount_init_candidates: cartid = %s, library = %s", - candidate_cartid, candidate_library); - - /* Allocate this cartridge */ - cur_cart = NULL; - cur_cart = mm_setup_cart(cmd, - db, - cart_results, - cart_row); - if (cur_cart == NULL) { - mms_trace(MMS_ERR, "error allocing candidate cart"); - mm_system_error(cmd, - "error allocing candidate cart"); - return (1); - } - mms_trace(MMS_INFO, "Check Library, %s", - candidate_library); - if (mm_candidate_library_ok(cmd, db, - candidate_library)) { - mms_trace(MMS_DEVP, - "Library, %s, is available", - candidate_library); - } else { - mms_trace(MMS_DEVP, - "Library, %s, not available", - candidate_library); - cur_cart->cmi_remove_cart = 1; - /* Go on to next cartridge */ - continue; - } - - - /* Get the drives in this library */ - /* Do some ordering of drives here */ - /* mm_mount_order_candidates will do the ordering */ - if (cmd->cmd_func == mm_mount_cmd_func) { - if (mm_db_exec(HERE, db, - "select distinct \"DriveName\"," - "\"LibraryName\",\"DrivePriority\"," - "\"DriveNumberMounts\" from (" - "select \"DriveName\",\"LibraryName\"," - "\"DrivePriority\",\"DriveNumberMounts\"" - "from \"DRIVE\"" - "where (\"DRIVE\".\"LibraryName\" = '%s')" - "order by \"DRIVE\".\"DriveNumberMounts\"" - ") as foo order by \"DrivePriority\";", - candidate_library) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error, init candidate cart"); - mm_sql_db_err_rsp_new(cmd, db); - return (1); - } - } else { - if (mm_db_exec(HERE, db, - "select distinct \"DriveName\"," - "\"LibraryName\",\"DrivePriority\"," - "\"DriveNumberMounts\" from (" - "select \"DriveName\",\"LibraryName\"," - "\"DrivePriority\",\"DriveNumberMounts\"" - "from \"DRIVE\"" - "where (\"DRIVE\".\"LibraryName\" = '%s' " - "and \"DRIVE\".\"CartridgePCL\" = '%s')" - "order by \"DRIVE\".\"DriveNumberMounts\"" - ") as foo order by \"DrivePriority\";", - candidate_library, - cur_cart->cmi_cart_pcl) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error, init candidate cart"); - mm_sql_db_err_rsp_new(cmd, db); - return (1); - } - } - drive_results = db->mm_db_results; - drive_rows = PQntuples(drive_results); - if (drive_rows == 0) { - mms_trace(MMS_ERR, - "couldn't match any drives for library %s", - candidate_library); - mm_response_error(cmd, - ECLASS_EXPLICIT, ENOMATCH, - MM_5094_MSG, - "lib", - candidate_library, - NULL); - mm_clear_db(&drive_results); - return (1); - } - - for (drive_row = 0; drive_row < drive_rows; drive_row ++) { - - candidate_drive = PQgetvalue(drive_results, - drive_row, 0); - - mms_trace(MMS_DEVP, - "mm_mount_init_candidates: drive = %s", - candidate_drive); - - /* mm_set_dirve_unmount and */ - /* mm_setup_drive return a pointer */ - /* to the set up drive struct */ - if (mount_info->cmi_operation == MM_UNMOUNT) { - (void) mm_setup_drive_unmount(cmd, - db, - cur_cart, - drive_results, - drive_row); - } else { - (void) mm_setup_drive(cmd, - db, - cur_cart, - drive_results, - drive_row); - } - - } - mm_clear_db(&drive_results); - } - - mm_mount_clean_candidates(cmd); - return (0); - -} - - -PGresult* mm_mount_cart_results(mm_wka_t *mm_wka, - mm_command_t *cmd, mm_db_t *db) { - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - char *path_buf = NULL; - char *tmp_buf = NULL; - - cci_t *conn = &mm_wka->wka_conn; - char *app_name = conn->cci_client; - int i; - - - mm_clear_source(cmd); - mm_clear_dest(cmd); - mm_clear_const(cmd); - - if (mm_get_dest(mm_wka, cmd)) { - /* Command does not have a match/volname clause */ - mms_trace(MMS_DEVP, "No match/volname Clause???"); - } else { - /* TEMP - Trace out our dest info */ - mms_trace(MMS_DEVP, "Dest count is %d", cmd->cmd_dest_num); - mm_print_char_list(&cmd->cmd_dest_list); - } - - if (mm_get_const(mm_wka, cmd)) { - /* Command does not have a match/volname clause */ - mms_trace(MMS_DEVP, "No match/volname Clause???"); - } else { - /* TEMP - Trace out our const info */ - mms_trace(MMS_DEVP, "Const count is %d", cmd->cmd_const_num); - mm_print_char_list(&cmd->cmd_const_list); - } - - if (cmd->wka_ptr->wka_privilege == MM_PRIV_STANDARD) { - /* add CARTRIDGEGROUPAPPLICATION constraint */ - (void) mm_add_to_dest(cmd, - "CARTRIDGEGROUPAPPLICATION"); - if (tmp_buf) - free(tmp_buf); - tmp_buf = NULL; - tmp_buf = mms_strapp(tmp_buf, - "\"CARTRIDGEGROUPAPPLICATION\"." - "\"ApplicationName\" = '%s'", - app_name); - (void) mm_add_to_const(cmd, tmp_buf); - if (tmp_buf) - free(tmp_buf); - tmp_buf = NULL; - } - - /* Clear cmd_buf */ - if (cmd->cmd_buf) - SQL_CHK_LEN(&cmd->cmd_buf, NULL, - &cmd->cmd_bufsize, 0); - - - /* Make path_buf and set source */ - path_buf = mms_strapp(path_buf, - "select distinct"); - if (mount_info->cmi_type == MM_VOLUME) { - - if (mm_add_char("VOLUME", - &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_mount_cart_results: " - "Error adding char to source list"); - mm_system_error(cmd, - "out of mem adding to source list"); - return (NULL); - } - path_buf = mms_strapp(path_buf, - "\"VOLUME\""); - - } - if (mount_info->cmi_type == MM_PARTITION) { - if (mm_add_char("PARTITION", - &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_mount_cart_results: " - "Error adding char to source list"); - mm_system_error(cmd, - "out of mem adding to source list"); - return (NULL); - } - path_buf = mms_strapp(path_buf, - "\"PARTITION\""); - } - if (mount_info->cmi_type == MM_SIDE) { - if (mm_add_char("SIDE", - &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_mount_cart_results: " - "Error adding char to source list"); - mm_system_error(cmd, - "out of mem adding to source list"); - return (NULL); - } - path_buf = mms_strapp(path_buf, - "\"SIDE\""); - } - if (tmp_buf != NULL) { - free(tmp_buf); - tmp_buf = NULL; - } - - - /* Put path_buf into cmd_buf */ - path_buf = mms_strapp(path_buf, - ".\"CartridgeID\" from\n"); - SQL_CHK_LEN(&cmd->cmd_buf, NULL, - &cmd->cmd_bufsize, strlen(path_buf) + 1); - strcpy(cmd->cmd_buf, path_buf); - free(path_buf); - path_buf = NULL; - cmd->cmd_source_num = 1; - /* Make report funcs */ - - if (mm_sql_from_where(cmd, db)) { - mms_trace(MMS_ERR, - "mm_mount_cart_results: " - "db error creating helper functions"); - return (NULL); - } - - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mms_trace(MMS_ERR, - "db error getting candidate cartridges"); - return (NULL); - } - - if (PQntuples(db->mm_db_results) == 0) { - /* no cartridge matches */ - mms_trace(MMS_INFO, - "match statment in mount " - "didn't match any cartridge/volumes"); - mm_response_error(cmd, - ECLASS_EXPLICIT, ENOMATCH, - MM_5052_MSG, - NULL); - mm_clear_db(&db->mm_db_results); - return (NULL); - } - - - /* Order cartridges based on priority and last time mounted */ - /* Additional Cartridge Ordering */ - /* done in mm_mount_order_candidates */ - tmp_buf = mms_strapp(tmp_buf, - "select distinct \"CartridgeID\"," - "\"LibraryName\",\"CartridgeGroupPriority\"," - "\"CartridgeNumberMounts\", " - "\"CartridgeShapeName\",\"CartridgePCL\", " - "\"CartridgeDriveOccupied\" " - "from ( " - "select \"CartridgeID\",\"LibraryName\", " - "\"CartridgeGroupPriority\"," - "\"CartridgeNumberMounts\", " - "\"CartridgeShapeName\",\"CartridgePCL\", " - "\"CartridgeDriveOccupied\" " - "from \"CARTRIDGE\"," - "\"CARTRIDGEGROUP\",\"CARTRIDGETYPE\" "); - for (i = 0; i < PQntuples(db->mm_db_results); i++) { - if (i == 0) { - tmp_buf = mms_strapp(tmp_buf, "where ("); - } else { - tmp_buf = mms_strapp(tmp_buf, "or "); - } - tmp_buf = mms_strapp(tmp_buf, " (\"CartridgeID\" = '%s')", - PQgetvalue(db->mm_db_results, i, 0)); - } - tmp_buf = mms_strapp(tmp_buf, - ") and" - "(\"CARTRIDGEGROUP\".\"CartridgeGroupName\" " - "= \"CARTRIDGE\".\"CartridgeGroupName\")" - "and" - "(\"CARTRIDGE\".\"CartridgeTypeName\" " - "= \"CARTRIDGETYPE\".\"CartridgeTypeName\")" - "order by \"CARTRIDGE\".\"CartridgeTimeMountedLast\"" - ") as foo order by \"CartridgeGroupPriority\";"); - mm_clear_db(&db->mm_db_results); - if (mm_db_exec(HERE, db, tmp_buf) != MM_DB_DATA) { - free(tmp_buf); - mm_sql_db_err_rsp_new(cmd, db); - return (NULL); - } - free(tmp_buf); - return (db->mm_db_results); -no_mem: - MM_ABORT_NO_MEM(); - return (NULL); - -} - -int -mm_mount_ready(mm_wka_t *mm_wka, mm_command_t *cmd, mm_db_t *db, int is_retry) { - - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - - PGresult *cart_results; - int cart_rows; - - cmi_cart_list_t *cart = NULL; - cmi_drive_list_t *drive = NULL; - - - int found_cart_drive = 0; - int found_ready_cart_drive = 0; - - int rc; - - int resync_tries = 5; - int i = 0; - - /* Do drive/cart/lib selection using path matching */ - if ((cart_results = mm_mount_cart_results(mm_wka, - cmd, db)) == NULL) { - /* No carts or error */ - return (MM_MOUNT_ERROR); - } - - cart_rows = PQntuples(cart_results); - mms_trace(MMS_DEVP, "Number of Cartridges is %d", cart_rows); - - if (cart_rows == 0) { - /* No Cartridge Matches Error */ - mms_trace(MMS_INFO, - "match statment in mount " - "didn't match any cartridge/volumes"); - mm_response_error(cmd, - ECLASS_EXPLICIT, ENOMATCH, - MM_5052_MSG, - NULL); - mm_clear_db(&cart_results); - return (MM_MOUNT_ERROR); - } - /* Create the list objects for */ - /* every cartridge/drive candidate */ - if (mm_mount_init_candidates(cmd, cart_results, - db)) { - mms_trace(MMS_ERR, - "error initializing candidate lists"); - /* err buf should be set by mm_mount_init */ - /* so return and remove */ - mm_clear_db(&cart_results); - return (MM_MOUNT_ERROR); - } - mms_trace(MMS_DEVP, "candidate list created, check availability "); - mm_clear_db(&cart_results); - /* Check the availability of the candidates */ - if (mm_mount_check_candidates(mm_wka, cmd, - db)) { - mms_trace(MMS_ERR, - "error checking candidate lists"); - mm_system_error(cmd, - "error checking candidate lists"); - return (MM_MOUNT_ERROR); - } - mms_trace(MMS_DEVP, "done checking list"); - - - - /* Print mount information */ - mm_print_mount_summary(mm_wka, cmd); - - - /* - * For blocking mounts, - * check that at least some cart/drive combo exists - * if that cart/drive exists, but is not ready, return not ready - * - * for immediate mounts, check that at least one combination exists - */ - - found_cart_drive = 0; - found_ready_cart_drive = 0; - - /* if cart/drive is not reay, set for remove */ - mms_list_foreach(&mount_info->cmi_cart_list, cart) { - if (cart->cmi_cart_not_ready) - cart->cmi_remove_cart = 1; - mms_list_foreach(&cart->cmi_drive_list, drive) { - found_cart_drive = 1; - if ((cart->cmi_cart_not_ready == 0) && - (drive->cmi_drive_not_ready == 0)) { - found_ready_cart_drive = 1; - } - if (drive->cmi_drive_not_ready) - drive->cmi_remove_drive = 1; - } - } - - - /* If there is a library or drive error */ - /* the error buff has already been set */ - if (found_cart_drive == 0) { - mms_trace(MMS_INFO, - "No candidate " - "cartridge/library/drive " - "combination found"); - /* set least severe error */ - mm_set_least_severe(cmd); - return (MM_MOUNT_ERROR); - } - if (found_ready_cart_drive == 0) { - mms_trace(MMS_INFO, - "candidate " - "cartridge/library/drive " - "combination found, but is not ready"); - return (MM_MOUNT_NOT_READY); - } - /* There is a ready cart/drive */ - /* we may have set some non ready for remove */ - /* so call the clean func before contine */ - mm_mount_clean_candidates(cmd); - cmd->cmd_state = 1; - rc = mm_set_immediate_mount(mm_wka, cmd, db); - - if (rc == MM_RESYNC) { - if (is_retry) { - return (rc); - } - /* Destroy all cart lists */ - mms_trace(MMS_INFO, - "mm_mount_ready: " - "states out of sync, attempt to resync this mount"); - for (i = 0; i < resync_tries; i++) { - mm_free_cmi_cart_list(&mount_info->cmi_cart_list); - rc = mm_mount_ready(mm_wka, cmd, db, 1); - if (rc != MM_RESYNC) { - mms_trace(MMS_INFO, - "mm_mount_ready: " - "resync successful"); - return (rc); - } - } - mms_trace(MMS_INFO, - "mm_mount_ready: " - "states out of sync, resync failed"); - return (MM_MOUNT_ERROR); - } - if (rc == MM_CMD_ERROR) { - mms_trace(MMS_ERR, - "error setting up immediate mount"); - /* set least severe error */ - mm_set_least_severe(cmd); - return (MM_MOUNT_ERROR); - } else if (rc == MM_DISPATCH_DEPEND) { - /* this immediate mount needs to */ - /* wait for an unload */ - mms_trace(MMS_DEVP, - " mount waiting " - "for unload to complete"); - return (MM_MOUNT_NEED_UNLOAD); - } - mms_trace(MMS_DEVP, - "mount ready for dispatch"); - - return (MM_MOUNT_READY); - -db_error: - mm_sql_db_err_rsp_new(cmd, db); - return (MM_MOUNT_ERROR); - -} - - -int -mm_mount_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - - mm_db_t *db = &mm_wka->mm_data->mm_db; - cci_t *conn = &mm_wka->wka_conn; - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - int rows; - int rc; - char *response_message = NULL; - mm_command_t *dmp_release = NULL; - - mms_trace(MMS_DEVP, "mm mount cmd state %d", cmd->cmd_state); - - if (cmd->cmd_state == 0) { - - mms_trace(MMS_INFO, "Processing Mount Request..."); - /* - * Generate Candidate Cartridge and Drive lists - * First parse and save the mount info - * then use SQL queries to gereate the lists - */ - - mount_info->cmi_mount_cart_loaded = 0; - mount_info->cmi_fail_type = NONE; - if (mm_parse_mount_cmd(mm_wka, cmd) == MM_CMD_ERROR) { - mms_trace(MMS_ERR, - "error parsing mount command"); - /* Error buf should already be set */ - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mms_trace(MMS_DEVP, "done parsing"); - - - - /* ***DONE PARSING MOUNT COMMAND*** */ - - if (mount_info->cmi_when == MM_BLOCKING) { - if (mm_set_tm_task(db, cmd) != MM_DB_OK) { - goto db_error; - } - mms_trace(MMS_DEVP, - "blocking mount will be passed to task manager"); - return (MM_WORK_TODO); - } - /* This is an immediate mount */ - rc = mm_mount_ready(mm_wka, cmd, db, 0); - switch (rc) { - - case MM_MOUNT_ERROR: - /* Error code should be set */ - mms_trace(MMS_ERR, - "internal error, mm_mount_ready"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - - case MM_MOUNT_READY: - /* The mount is ready, mount_info should be set */ - /* continue to state 1 */ - cmd->cmd_state = 1; - mms_trace(MMS_DEVP, - "mount is ready to go, " - "continue to state 1"); - break; - - case MM_MOUNT_NEED_UNLOAD: - /* this immediate mount needs to */ - /* wait for an unload */ - cmd->cmd_state = 1; - mms_trace(MMS_DEVP, - "mount waiting " - "for unload to complete"); - return (MM_DISPATCH_DEPEND); - - case MM_MOUNT_NOT_READY: - /* Error code should be set */ - mms_trace(MMS_ERR, - "immediate mount not ready, " - "send error to client"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - - default: - mms_trace(MMS_ERR, - "bad rc mm_mount_ready"); - mm_system_error(cmd, - "bad rc mm_mount_ready"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - - } - } - -start: - if (cmd->cmd_state == 1) { - mms_trace(MMS_INFO, "Mounting tape..."); - - /* Reserve the DM */ - /* - * mm_sql_update_state(mm_wka->mm_data, "DM", - * "DMStateSoft", - * "reserved", "DMName", - * mount_info->cmi_dm); - */ - mm_sql_update_state(mm_wka->mm_data, "DRIVE", - "DMName", - mount_info->cmi_dm, "DriveName", - mount_info->cmi_drive); - - /* Add activate command */ - if (mm_dmp_add_cmd(mm_wka, cmd, mount_info->cmi_dm, - MM_DMP_RESERVE) == NULL) { - mms_trace(MMS_ERR, - "error adding dmp reserve"); - mm_system_error(cmd, - "error adding dmp reserve"); - goto reset_states; - } - cmd->cmd_state = 3; - return (MM_DISPATCH_DEPEND); - } else if (cmd->cmd_state == 3) { - - /* - * Mount cartridge in the library drive - */ - - mm_command_t *lmp_mnt_cmd; - mm_wka_t *lm_wka; - uuid_text_t new_task; - char *cart_pcl; - char *side_name; - - /* - * DM Activate failed - */ - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - mms_trace(MMS_DEVP, "DM reserve failed"); - /* Reset drive and cartridge */ - /* return error to client */ - mount_info->cmi_reset_states = 1; - goto lm_dm_error; - } - - if (mount_info->cmi_mount_cart_loaded) { - /* Skip lmp mount */ - cmd->cmd_state = 4; - goto start; - } - /* - * Cartridge pcl and side name - */ - if ((cart_pcl = mm_get_cart_pcl(cmd, - cmd->cmd_mount_info.cmi_cartridge, db)) == NULL) { - /* Error buf should be set in mm_get_cart_pcl */ - goto reset_states; - } - - /* TODO side name needs to be generated in candidate query */ - if ((side_name = cmd->cmd_mount_info.cmi_side_name) == NULL) { - side_name = "side 1"; - } - - /* - * LMP mount command - */ - lm_wka = mm_library_lm_wka(cmd->wka_ptr->mm_data, - cmd->cmd_mount_info.cmi_library, NULL); - if ((lmp_mnt_cmd = mm_alloc_cmd(lm_wka)) == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_command_t: %s", - strerror(errno)); - mm_system_error(cmd, - "Unable to malloc lmp mount cmd"); - goto reset_states; - } - - lmp_mnt_cmd->cmd_func = mm_lmp_mount_cmd_func; - mm_get_uuid(new_task); - lmp_mnt_cmd->cmd_textcmd = mms_strnew(LMP_MOUNT, new_task, - cart_pcl, cart_pcl, side_name, - cmd->cmd_mount_info.cmi_drive); - lmp_mnt_cmd->cmd_root = - mm_text_to_par_node(lmp_mnt_cmd->cmd_textcmd, - mms_lmpm_parse); - lmp_mnt_cmd->cmd_task = mm_get_task(lmp_mnt_cmd->cmd_root); - mm_add_depend(lmp_mnt_cmd, cmd); - lmp_mnt_cmd->cmd_name = strdup("lmp mount"); - lmp_mnt_cmd->cmd_mount_info.cmi_drive = - strdup(cmd->cmd_mount_info.cmi_drive); - lmp_mnt_cmd->cmd_mount_info.cmi_cartridge = - strdup(cmd->cmd_mount_info.cmi_cartridge); - cmd->cmd_state = 4; - - pthread_mutex_lock(&mm_wka->mm_data->mm_queue_mutex); - mms_list_insert_tail(&mm_wka->mm_data->mm_cmd_queue, - lmp_mnt_cmd); - pthread_mutex_unlock(&mm_wka->mm_data->mm_queue_mutex); - - free(cart_pcl); - - return (MM_DISPATCH_DEPEND); - - } else if (cmd->cmd_state == 4) { - - /* - * LMP Mount command failed - */ - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - mms_trace(MMS_DEVP, "lm mount failed"); - /* Reset drive and cartridge */ - /* return error to client */ - mount_info->cmi_reset_states = 1; - mount_info->cmi_need_clear = 1; - /* DM is reserved, release the DM */ - if (dmp_release = mm_dmp_add_cmd(mm_wka, - cmd, mount_info->cmi_dm, - MM_DMP_RELEASE)) { - /* run withtout parent */ - mm_remove_all_depend(dmp_release); - } - /* Generate error message */ - response_message = - mm_ret_response_msg(cmd); - mm_response_error(cmd, - "subop", "ELMPMOUNT", MM_5018_MSG, - "cartridge", mount_info->cmi_cartridge, - "drive", mount_info->cmi_drive, - "msg_rsp", response_message, - NULL); - free(response_message); - /* Set cmd for remove, send message to client */ - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - if (mm_dmp_add_cmd(mm_wka, cmd, mount_info->cmi_dm, - MM_DMP_PRIV) == NULL) { - mms_trace(MMS_ERR, - "error adding dmp private"); - mm_system_error(cmd, - "error adding dmp private"); - goto reset_states; - } - cmd->cmd_state = 5; - return (MM_DISPATCH_DEPEND); - } else if (cmd->cmd_state == 5) { - - /* DM_load state */ - /* - * Private has finished, add a load command to the - * queue - */ - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - mms_trace(MMS_DEVP, "mmp_mount-> DMP private error"); - /* Reset drive and cartridge */ - /* return error to client */ - mount_info->cmi_reset_states = 1; - mount_info->cmi_need_clear = 1; - /* DM is reserved, release the DM */ - if (dmp_release = mm_dmp_add_cmd(mm_wka, - cmd, mount_info->cmi_dm, - MM_DMP_RELEASE)) { - /* run withtout parent */ - mm_remove_all_depend(dmp_release); - } - goto lm_dm_error; - } - - if (mm_dmp_add_cmd(mm_wka, cmd, mount_info->cmi_dm, - MM_DMP_LOAD) == NULL) { - mms_trace(MMS_ERR, - "error adding dmp load"); - mm_system_error(cmd, - "error adding dmp load"); - goto reset_states; - } - cmd->cmd_state = 6; - return (MM_DISPATCH_DEPEND); - } else if (cmd->cmd_state == 6) { - /* load command has finished, add an attach */ - /* Update Drive Table */ - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - mms_trace(MMS_DEVP, "mmp_mount-> DMP load error"); - /* Reset drive and cartridge */ - /* return error to client */ - mount_info->cmi_reset_states = 1; - mount_info->cmi_need_clear = 1; - /* DM is reserved, release the DM */ - if (dmp_release = mm_dmp_add_cmd(mm_wka, - NULL, mount_info->cmi_dm, - MM_DMP_RELEASE)) { - /* run withtout parent */ - mm_remove_all_depend(dmp_release); - } - response_message = - mm_ret_response_msg(cmd); - mm_response_error(cmd, - ECLASS_SUBOP, - "EDMPLOAD", - MM_5053_MSG, - "cartridge", - mount_info->cmi_cartridge, - "drive", - mount_info->cmi_drive, - "msg_rsp", - response_message, - NULL); - free(response_message); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - - if (mm_dmp_add_cmd(mm_wka, cmd, mount_info->cmi_dm, - MM_DMP_ATTACH) == NULL) { - mms_trace(MMS_ERR, - "error adding dmp attach"); - mm_system_error(cmd, - "error adding dmp attach"); - goto reset_states; - } - cmd->cmd_state = 7; - return (MM_DISPATCH_DEPEND); - } else if (cmd->cmd_state == 7) { - - PGresult *side; - PGresult *slot; - PGresult *mount_log; - PGresult *results; - int priv_no_vol = 0; - char *side_name = NULL; - char *slot_name = NULL; - char *slot_pcl = NULL; - - /* DM_identify tester state */ - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - mms_trace(MMS_DEVP, "mmp_mount-> DMP attach error"); - /* Reset drive and cartridge */ - /* return error to client */ - mount_info->cmi_reset_states = 1; - mount_info->cmi_need_clear = 1; - /* DM is reserved, release the DM */ - if (dmp_release = mm_dmp_add_cmd(mm_wka, - cmd, mount_info->cmi_dm, - MM_DMP_RELEASE)) { - /* run withtout parent */ - mm_remove_all_depend(dmp_release); - } - /* write error message */ - response_message = - mm_ret_response_msg(cmd); - mm_response_error(cmd, - ECLASS_SUBOP, - "EDMPATTACH", - MM_5054_MSG, - "cartridge", - mount_info->cmi_cartridge, - "drive", - mount_info->cmi_drive, - "msg_rsp", - response_message, - NULL); - free(response_message); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - - rc = mm_db_exec(HERE, db, - "select * from \"MOUNTPHYSICAL\" "\ - "where \"CartridgeID\" = '%s';", - mount_info->cmi_cartridge); - if (rc != MM_DB_DATA) { - mms_trace(MMS_ERR, "Exec returned with no Data"); - mm_sql_db_err_rsp_new(cmd, db); - goto reset_states; - } - mount_log = db->mm_db_results; - rows = PQntuples(mount_log); - mm_clear_db(&mount_log); - /* attach command has finished, add an indentify */ - /* insert row into MOUNTLOGICAL */ - - rc = mm_db_exec(HERE, db, - "select \"VolumeName\", " - "\"PartitionName\", \"SideName\" " - "from \"VOLUME\" where \"CartridgeID\" = '%s'" - "and \"ApplicationName\" = '%s';", - mount_info->cmi_cartridge, - conn->cci_client); - - if (rc != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - goto reset_states; - } - results = db->mm_db_results; - if ((PQntuples(results) == 0) && - (cmd->wka_ptr->wka_privilege != MM_PRIV_STANDARD)) { - /* Priv app doesn't have a volume */ - rc = mm_db_exec(HERE, db, - "select \"VolumeName\", " - "\"PartitionName\", \"SideName\", " - "\"ApplicationName\" " - "from \"VOLUME\" where \"CartridgeID\" = '%s';", - mount_info->cmi_cartridge); - priv_no_vol = 1; - mm_clear_db(&results); - results = db->mm_db_results; - } - - rc = mm_db_exec(HERE, db, - "select \"SideName\" from " \ - "\"SIDE\" where \"CartridgeID\" = '%s';", - mount_info->cmi_cartridge); - if (rc != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&results); - goto reset_states; - } - side = db->mm_db_results; - - - if (PQntuples(side) == 0) { - mms_trace(MMS_DEVP, - "missing SIDE obj for %s", - mount_info->cmi_cartridge); - mm_system_error(cmd, - "cartridge missing SIDE obj"); - mm_clear_db(&results); - mm_clear_db(&side); - goto reset_states; - } - side_name = PQgetvalue(side, 0, 0); - - rc = mm_db_exec(HERE, db, - "select \"SlotName\", "\ - "\"CartridgePCL\" from \"SLOT\" "\ - "where \"CartridgeID\" = '%s';", - mount_info->cmi_cartridge); - if (rc != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&results); - mm_clear_db(&side); - goto reset_states; - } - slot = db->mm_db_results; - if (PQntuples(slot) == 0) { - mms_trace(MMS_DEVP, - "missing SLOT obj for %s", - mount_info->cmi_cartridge); - mm_system_error(cmd, - "cartridge missing SLOT obj"); - mm_clear_db(&results); - mm_clear_db(&side); - mm_clear_db(&slot); - goto reset_states; - } - slot_name = PQgetvalue(slot, 0, 0); - slot_pcl = PQgetvalue(slot, 0, 1); - - if (rows == 0) { - if (priv_no_vol) { - rc = mm_db_exec(HERE, db, - "insert into \"MOUNTLOGICAL\" "\ - "(\"ApplicationName\", \"VolumeName\", "\ - "\"PartitionName\", \"SideName\", "\ - "\"CartridgeID\", \"DriveName\", "\ - "\"DMName\", \"DMCapabilityName\", "\ - "\"MountLogicalHandle\", "\ - "\"MountLogicalTimeWhenMounted\") "\ - "values ('%s', '%s', '%s', '%s', "\ - "'%s', '%s', '%s', '%s', '%s', now());", - PQgetvalue(results, 0, 3), - PQgetvalue(results, 0, 0), - PQgetvalue(results, 0, 1), - PQgetvalue(results, 0, 2), - mount_info->cmi_cartridge, - mount_info->cmi_drive, - mount_info->cmi_dm, - mount_info->cmi_capability, - mount_info->cmi_handle); - } else { - rc = mm_db_exec(HERE, db, - "insert into \"MOUNTLOGICAL\" " - "(\"ApplicationName\", \"VolumeName\", " - "\"PartitionName\", \"SideName\", " - "\"CartridgeID\", \"DriveName\", " - "\"DMName\", \"DMCapabilityName\", " - "\"MountLogicalHandle\", " - "\"MountLogicalTimeWhenMounted\") " - "values ('%s', '%s', '%s', '%s', " - "'%s', '%s', '%s', '%s', '%s', now());", - conn->cci_client, - PQgetvalue(results, 0, 0), - PQgetvalue(results, 0, 1), - PQgetvalue(results, 0, 2), - mount_info->cmi_cartridge, - mount_info->cmi_drive, - mount_info->cmi_dm, - mount_info->cmi_capability, - mount_info->cmi_handle); - } - if (rc != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_mount_cmd_func: " - "error inserting MOUNTLOGICAL"); - } - - if (mm_db_exec(HERE, db, - "insert into \"MOUNTPHYSICAL\" " - "(\"ApplicationName\",\"DriveName\", " - "\"LibraryName\", " - "\"CartridgeID\", \"CartridgePCL\", " - "\"SideName\", " - "\"SlotName\", " - "\"MountPhysicalTimeWhenMounted\", " - "\"SessionID\") " - "values('%s', '%s', '%s', '%s', " - "'%s', '%s', '%s', now(), '%s');", - conn->cci_client, - mount_info->cmi_drive, - mount_info->cmi_library, - mount_info->cmi_cartridge, - slot_pcl, - side_name, - slot_name, - mm_wka->session_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_mount_cmd_func: " - "error inserting MOUNTPHYSICAL"); - } - } else { - if (mm_db_exec(HERE, db, - "delete from \"MOUNTLOGICAL\" "\ - "where \"CartridgeID\" = '%s';", - mount_info->cmi_cartridge) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_mount_cmd_func: " - "error deleting MOUNTLOGICAL"); - } - rc = mm_db_exec(HERE, db, - "insert into \"MOUNTLOGICAL\" "\ - "(\"ApplicationName\", \"VolumeName\", "\ - "\"PartitionName\", \"SideName\", "\ - "\"CartridgeID\", \"DriveName\", "\ - "\"DMName\", \"DMCapabilityName\", "\ - "\"MountLogicalHandle\", "\ - "\"MountLogicalTimeWhenMounted\") "\ - "values ('%s', '%s', '%s', '%s', "\ - "'%s', '%s', '%s', '%s', '%s', now());", - conn->cci_client, - PQgetvalue(results, 0, 0), - PQgetvalue(results, 0, 1), - PQgetvalue(results, 0, 2), - mount_info->cmi_cartridge, - mount_info->cmi_drive, - mount_info->cmi_dm, - mount_info->cmi_capability, - mount_info->cmi_handle); - if (rc != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_mount_cmd_func: " - "error inserting MOUNTLOGICAL"); - } - - } - mm_clear_db(&results); - mm_clear_db(&side); - mm_clear_db(&slot); - if (mm_dmp_add_cmd(mm_wka, cmd, mount_info->cmi_dm, - MM_DMP_IDENTIFY) == NULL) { - mms_trace(MMS_ERR, - "error adding dmp identify"); - mm_system_error(cmd, - "error adding dmp identify"); - goto reset_states; - } - cmd->cmd_state = 8; - return (MM_DISPATCH_DEPEND); - } else if (cmd->cmd_state == 8) { - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - mms_trace(MMS_DEVP, "mmp_mount-> DMP identify error"); - /* Reset drive and cartridge */ - /* return error to client */ - mount_info->cmi_reset_states = 1; - mount_info->cmi_need_clear = 1; - /* DM is reserved, release the DM */ - if (dmp_release = mm_dmp_add_cmd(mm_wka, - cmd, mount_info->cmi_dm, - MM_DMP_RELEASE)) { - /* run withtout parent */ - mm_remove_all_depend(dmp_release); - } - goto lm_dm_error; - } - /* The command is finished so generate a report */ - - /* Remove the TASK objs */ - if (mm_db_exec(HERE, db, "delete from \"TASKCARTRIDGE\"" - "where \"TaskID\" = '%s';", - cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_mount_cmd_func: " - "db error deleting TASKCARTRIDGE"); - } - if (mm_db_exec(HERE, db, "delete from \"TASKDRIVE\" " - "where \"TaskID\" = '%s';", cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_mount_cmd_func: " - "db error deleting TASKDRIVE"); - } - if (mm_db_exec(HERE, db, "delete from \"TASKLIBRARY\" " - "where \"TaskID\" = '%s';", cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_mount_cmd_func: " - "db error deleting TASKLIBRARY"); - } - if (mm_db_exec(HERE, db, "delete from \"TASK\" " - "where \"TaskID\" = '%s';", cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_mount_cmd_func: " - "db error deleting TASK"); - } - /* - * Report clause. - */ - cmd->cmd_remove = 1; - mm_path_match_report(cmd, db); - mm_send_response(mm_wka->mm_wka_conn, cmd); - mms_trace(MMS_INFO, "Tape Successfully Mounted"); - rc = MM_CMD_DONE; - goto end; - - } - - cmd->cmd_remove = 1; - rc = MM_CMD_ERROR; - goto end; - -reset_states: - mount_info->cmi_reset_states = 1; - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); -no_mem: - MM_ABORT_NO_MEM(); - rc = MM_CMD_ERROR; - goto end; - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; -lm_dm_error: - response_message = - mm_ret_response_msg(cmd); - mm_response_error(cmd, - ECLASS_SUBOP, - ELMDMCOMMUNICATION, - MM_5055_MSG, - "msg_rsp", response_message, - NULL); - free(response_message); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - /* Clear the Drive */ - if (mount_info->cmi_drive != NULL) { - mount_info->cmi_need_clear = 1; - - } - rc = MM_CMD_ERROR; - goto end; - -db_error: - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - -end: - - return (rc); - -} - - -int -mm_delay_unmount_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - - time_t tm; - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - mm_db_t *db = &mm_wka->mm_data->mm_db; - char *response_message = NULL; - - mms_trace(MMS_DEVP, "mm_delay_unmount_cmd_func %s", - cmd->cmd_mount_info.cmi_drive); - - if (cmd->cmd_state == 0) { - (void) time(&tm); - - if (tm < mount_info->unload_tm) { - mms_trace(MMS_DEVP, - "wait longer for this unload"); - return (MM_DISPATCH_DEPEND); - } - - if (mount_info->cui_skip_unload) { - mms_trace(MMS_DEVP, - "procced with unload, " - "but skip the DM unload command"); - return (MM_CMD_DONE); - } - cmd->cmd_state = 1; - mms_trace(MMS_DEVP, - "proceed with DM unload command"); - - } - - if (cmd->cmd_state == 1) { - if (mm_dmp_add_cmd(mm_wka, cmd, mount_info->cmi_dm, - MM_DMP_UNLOAD) == NULL) { - mms_trace(MMS_ERR, - "mm_delay_unmount_cmd_func: " - "error adding dmp unload"); - return (MM_CMD_ERROR); - } - cmd->cmd_state = 2; - return (MM_DISPATCH_DEPEND); - } - - if (cmd->cmd_state == 2) { - mm_command_t *lmp_umnt_cmd; - mm_wka_t *lm_wka; - uuid_text_t new_task; - char *cart_pcl; - char *side_name; - /* - * Unload has returned - * check error, update states - */ - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - mms_trace(MMS_DEVP, "delay unmount-> DMP unload error"); - response_message = mm_ret_response_msg(cmd); - mm_response_error(cmd, - ECLASS_SUBOP, - ELMDMCOMMUNICATION, - MM_5055_MSG, - "msg_rsp", response_message, - NULL); - free(response_message); - response_message = NULL; - - } - - /* - * Cartridge pcl and side name - */ - if ((cart_pcl = mm_get_cart_pcl(cmd, - cmd->cmd_mount_info.cmi_cartridge, db)) == NULL) { - cmd->cmd_remove = 1; - mms_trace(MMS_ERR, - "mm_get_cart_pcl error"); - return (MM_CMD_ERROR); - } - - mm_set_mount_info_pcl(cart_pcl, - mount_info); - - /* TODO side name needs to be generated in candidate query */ - if ((side_name = cmd->cmd_mount_info.cmi_side_name) == NULL) { - side_name = "side 1"; - } - - /* - * LMP unmount command - */ - lm_wka = mm_library_lm_wka(cmd->wka_ptr->mm_data, - cmd->cmd_mount_info.cmi_library, NULL); - if ((lmp_umnt_cmd = mm_alloc_cmd(lm_wka)) == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_command_t: %s", - strerror(errno)); - return (MM_CMD_ERROR); - } - lmp_umnt_cmd->cmd_func = mm_lmp_unmount_cmd_func; - mm_get_uuid(new_task); - lmp_umnt_cmd->cmd_textcmd = mms_strnew(LMP_UNMOUNT, new_task, - cart_pcl, cart_pcl, side_name, - cmd->cmd_mount_info.cmi_drive, - cart_pcl, cart_pcl, side_name); - mm_set_mount_info_drive(cmd->cmd_mount_info.cmi_drive, - &lmp_umnt_cmd->cmd_mount_info); - lmp_umnt_cmd->cmd_root = - mm_text_to_par_node(lmp_umnt_cmd->cmd_textcmd, - mms_lmpm_parse); - lmp_umnt_cmd->cmd_task = mm_get_task(lmp_umnt_cmd->cmd_root); - mm_add_depend(lmp_umnt_cmd, cmd); - lmp_umnt_cmd->cmd_name = strdup("lmp unmount"); - - - cmd->cmd_state = 3; - - pthread_mutex_lock(&mm_wka->mm_data->mm_queue_mutex); - mms_list_insert_tail(&mm_wka->mm_data->mm_cmd_queue, - lmp_umnt_cmd); - pthread_mutex_unlock(&mm_wka->mm_data->mm_queue_mutex); - - free(cart_pcl); - - return (MM_DISPATCH_DEPEND); - - } - if (cmd->cmd_state == 3) { - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - mms_trace(MMS_ERR, "LMP unmount error, " - "scan both drive and slot"); - /* Clear depend error flags */ - MM_UNSET_FLAG(cmd->cmd_flags, - MM_CMD_DEPEND_ERROR); - - /* Add LMP scan command for this drive */ - if (mm_add_lmp_scan(mm_wka->mm_data, cmd, - mount_info->cmi_drive, - NULL, mount_info->cmi_library)) { - mms_trace(MMS_ERR, - "Error adding LMP scan"); - return (MM_CMD_ERROR); - } else { - mms_trace(MMS_DEBUG, - "Added LMP scan"); - } - cmd->cmd_state = 4; - return (MM_DISPATCH_DEPEND); - } - - - mms_trace(MMS_INFO, "Tape Unmounted Successfully"); - /* - * Don't reset the soft state - * "\"DriveStateSoft\" = 'ready'," - */ - - if (mm_db_exec(HERE, db, "update \"DRIVE\" set " - "\"DMName\" = ''," - "\"DriveStateHard\" = 'unloaded' where " - "\"DriveName\" = '%s';", - cmd->cmd_mount_info.cmi_drive) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_delay_unmount_cmd_func: " - "db error updating DriveStateHard"); - } - - /* Don't update the cartridge soft state */ - /* The unload may be part of a mount sequence */ - - if (mm_has_depend(cmd)) { - mm_command_t *cur_depend = NULL; - mms_list_foreach(&cmd->cmd_depend_list, cur_depend) { - if (cur_depend->cmd_func == - mm_delay_unmount_cmd_func) { - mms_trace(MMS_DEVP, - "this delay unmount has " - "delay unmount as parent," - " set parent ready for dispatch"); - mm_set_unload_dispatch(cur_depend, - NULL); - } - } - return (MM_DEPEND_DONE); - } - - return (MM_CMD_DONE); - } - if (cmd->cmd_state == 4) { - /* This is state after lmp scan of drive */ - /* send a scan of the cartridge now */ - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - mms_trace(MMS_ERR, "error in LMP drive scan, try" - "slot scan anyways"); - /* Clear depend error flags */ - MM_UNSET_FLAG(cmd->cmd_flags, - MM_CMD_DEPEND_ERROR); - } - mms_trace(MMS_DEVP, "drive scan done, scan slot"); - - /* Add LMP scan command for this drive */ - if (mm_add_lmp_scan(mm_wka->mm_data, cmd, - NULL, - mount_info->cmi_pcl, - mount_info->cmi_library)) { - mms_trace(MMS_ERR, - "Error adding LMP scan"); - return (MM_CMD_ERROR); - } else { - mms_trace(MMS_DEBUG, - "Added LMP scan"); - } - cmd->cmd_state = 5; - return (MM_DISPATCH_DEPEND); - - } - if (cmd->cmd_state == 5) { - /* cartridge scan returned , return cmd done */ - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - mms_trace(MMS_ERR, "error in LMP slot scan"); - } - mms_trace(MMS_DEVP, "slot scan done"); - - /* Don't update the cartridge soft state */ - /* The unload may be part of a mount sequence */ - - if (mm_has_depend(cmd)) { - mm_command_t *cur_depend = NULL; - mms_list_foreach(&cmd->cmd_depend_list, cur_depend) { - if (cur_depend->cmd_func == - mm_delay_unmount_cmd_func) { - mms_trace(MMS_DEVP, - "this delay unmount has " - "delay unmount as parent," - " set parent ready for dispatch"); - mm_set_unload_dispatch(cur_depend, - NULL); - } - } - return (MM_DEPEND_DONE); - } - - return (MM_CMD_DONE); - } - - mms_trace(MMS_ERR, - "mm_delay_unmount_cmd_func: unknown command state"); - return (MM_CMD_ERROR); - -} - - -int -mm_schedule_unload(mm_wka_t *mm_wka, mm_command_t *cmd) { - - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - mm_data_t *mm_data = mm_wka->mm_data; - mm_db_t *db = &mm_wka->mm_data->mm_db; - - mm_command_t *unmount_cmd; - mm_wka_t *lm_wka; - uuid_text_t uuid; - - /* Time releated */ - char cur_date[100]; - char unload_date[100]; - time_t tm; - struct tm cur_time; - struct tm unload_time; - - /* allocate the unmount command */ - lm_wka = NULL; - lm_wka = mm_library_lm_wka(cmd->wka_ptr->mm_data, - cmd->cmd_mount_info.cmi_library, NULL); - if ((unmount_cmd = mm_alloc_cmd(lm_wka)) == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_command_t: %s", - strerror(errno)); - return (1); - } - mm_get_uuid(uuid); - unmount_cmd->cmd_root = NULL; - unmount_cmd->cmd_task = NULL; - unmount_cmd->cmd_task = strdup(uuid); - unmount_cmd->cmd_func = mm_delay_unmount_cmd_func; - unmount_cmd->cmd_name = strdup("delay unmount"); - - /* Copy over the mount info to the new command */ - if (mount_info->cmi_cartridge != NULL) - unmount_cmd->cmd_mount_info.cmi_cartridge = - strdup(mount_info->cmi_cartridge); - if (mount_info->cmi_drive != NULL) - unmount_cmd->cmd_mount_info.cmi_drive = - strdup(mount_info->cmi_drive); - if (mount_info->cmi_side_name != NULL) - unmount_cmd->cmd_mount_info.cmi_side_name = - strdup(mount_info->cmi_side_name); - if (mount_info->cmi_library != NULL) - unmount_cmd->cmd_mount_info.cmi_library = - strdup(mount_info->cmi_library); - if (mount_info->cmi_dm != NULL) - unmount_cmd->cmd_mount_info.cmi_dm = - strdup(mount_info->cmi_dm); - - unmount_cmd->cmd_mount_info.cui_skip_unload = - mount_info->cui_skip_unload; - - /* Set up timer */ - - if (mm_db_exec(HERE, db, - "select \"DriveGroupUnloadTime\" from " - "\"DRIVEGROUP\",\"DRIVE\" where " - "\"DRIVE\".\"DriveGroupName\" = " - "\"DRIVEGROUP\".\"DriveGroupName\" and " - "\"DRIVE\".\"DriveName\" = '%s';", - mount_info->cmi_drive) != MM_DB_DATA) { - mms_trace(MMS_ERR, "Exec returned with no Data"); - return (1); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, "Exec rows != 1"); - mm_clear_db(&db->mm_db_results); - return (1); - } - - /* set the time to unload */ - /* Get the delay time, get the current time */ - (void) time(&tm); - mms_trace(MMS_DEVP, "Current tm is %d", tm); - (void) localtime_r(&tm, &cur_time); - (void) strftime(cur_date, 100, "%Y/%m/%d %H:%M:%S", &cur_time); - - /* unload time is in min, so mult by 60 for sec */ - tm = tm + 60*atoi(PQgetvalue(db->mm_db_results, 0, 0)); - unmount_cmd->cmd_mount_info.unload_tm = tm; - - mms_trace(MMS_DEVP, "Unload tm is %d", tm); - (void) localtime_r(&tm, &unload_time); - (void) strftime(unload_date, 100, "%Y/%m/%d %H:%M:%S", &unload_time); - mms_trace(MMS_DEVP, - "Current time is %s, delay time is %s mins, unload at %s", - cur_date, PQgetvalue(db->mm_db_results, 0, 0), unload_date); - - - pthread_mutex_lock(&mm_data-> - mm_queue_mutex); - mms_list_insert_tail(&mm_data->mm_cmd_queue, unmount_cmd); - pthread_mutex_unlock(&mm_data-> - mm_queue_mutex); - - mm_clear_db(&db->mm_db_results); - return (0); - - -} - -int -mm_parse_unmount_cmd(mm_wka_t *mm_wka, mm_command_t *cmd) { - - - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - - mms_par_node_t *arg; - mms_par_node_t *value; - - mms_par_node_t *work = NULL; - - - mms_trace(MMS_DEVP, "mm_parse_unmount_cmd"); - mount_info->cmi_operation = MM_UNMOUNT; - - /* Get the type */ - mms_trace(MMS_DEVP, "type"); - MMS_PN_LOOKUP(arg, cmd->cmd_root, "type", - MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, arg, NULL, MMS_PN_KEYWORD, NULL); - if (strcmp(value->pn_string, "SIDE") == 0) { - mount_info->cmi_type = MM_SIDE; - } else if (strcmp(value->pn_string, "PARTITION") == 0) { - mount_info->cmi_type = MM_PARTITION; - } else if (strcmp(value->pn_string, "VOLUME") == 0) { - mount_info->cmi_type = MM_VOLUME; - } - mms_trace(MMS_DEVP, "type %s", value->pn_string); - - if (mms_pn_lookup(cmd->cmd_root, "physicalunmount", - MMS_PN_KEYWORD, NULL)) { - mount_info->cui_physical = 1; - } - mms_trace(MMS_DEVP, "physicalunmount %d", - mount_info->cui_physical); - - /* signature optional */ - if (arg = mms_pn_lookup(cmd->cmd_root, "signature", - MMS_PN_CLAUSE, NULL)) { - value = mms_pn_lookup(arg, NULL, MMS_PN_KEYWORD, - NULL); - if (value && - strcmp(value->pn_string, "CLEAN") == 0) { - mount_info->cui_signature_clean = 1; - mms_trace(MMS_DEVP, "signature clean"); - } else { - work = NULL; - MMS_PN_LOOKUP(value, arg, NULL, - MMS_PN_STRING, &work); - mount_info->cui_signature_type = - strdup(value->pn_string); - MMS_PN_LOOKUP(value, arg, NULL, - MMS_PN_STRING, &work); - mount_info->cui_signature = - strdup(value->pn_string); - mms_trace(MMS_DEVP, "signature %s %s", - mount_info->cui_signature_type, - mount_info->cui_signature); - } - } else { - /* default signature */ - mount_info->cui_signature_clean = 1; - mms_trace(MMS_DEVP, "signature defaults to clean"); - } - - return (MM_CMD_DONE); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -} - - -PGresult* -mm_unmount_cart_results(mm_wka_t *mm_wka, - mm_command_t *cmd, mm_db_t *db) { - - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - char *tmp_buf = NULL; - - cci_t *conn = &mm_wka->wka_conn; - char *app_name = conn->cci_client; - char *type = NULL; - int i; - - - - mm_clear_source(cmd); - mm_clear_dest(cmd); - mm_clear_const(cmd); - - switch (mount_info->cmi_type) { - case MM_SIDE: - type = mms_strapp(type, MM_SIDE_STRING); - break; - case MM_PARTITION: - type = mms_strapp(type, MM_PARTITION_STRING); - break; - case MM_VOLUME: - type = mms_strapp(type, MM_VOLUME_STRING); - break; - } - - /* Do drive/cart/lib selection using path matching */ - - if (mm_get_dest(mm_wka, cmd)) { - /* Command does not have a match/volname clause */ - mms_trace(MMS_DEVP, "No match/volname Clause???"); - } else { - /* TEMP - Trace out our dest info */ - mms_trace(MMS_DEVP, "Dest count is %d", cmd->cmd_dest_num); - mm_print_char_list(&cmd->cmd_dest_list); - } - - if (mm_get_const(mm_wka, cmd)) { - /* Command does not have a match/volname clause */ - mms_trace(MMS_DEVP, "No match/volname Clause???"); - } else { - /* TEMP - Trace out our const info */ - mms_trace(MMS_DEVP, "Const count is %d", cmd->cmd_const_num); - mm_print_char_list(&cmd->cmd_const_list); - } - - if (cmd->wka_ptr->wka_privilege == MM_PRIV_STANDARD) { - /* add CARTRIDGEGROUPAPPLICATION constraint */ - (void) mm_add_to_dest(cmd, - "CARTRIDGEGROUPAPPLICATION"); - if (tmp_buf) - free(tmp_buf); - tmp_buf = NULL; - tmp_buf = mms_strapp(tmp_buf, - "\"CARTRIDGEGROUPAPPLICATION\"." - "\"ApplicationName\" = '%s'", - app_name); - (void) mm_add_to_const(cmd, tmp_buf); - if (tmp_buf) - free(tmp_buf); - tmp_buf = NULL; - } - /* Constrain to only cartridges mounted by this session */ - /* Maybe a forced unmount will not use this constraint */ - (void) mm_add_to_dest(cmd, - "SESSION"); - if (tmp_buf) - free(tmp_buf); - tmp_buf = NULL; - tmp_buf = mms_strapp(tmp_buf, - "\"SESSION\"." - "\"ConnectionID\" = '%s'", - conn->cci_uuid); - (void) mm_add_to_const(cmd, tmp_buf); - if (tmp_buf) - free(tmp_buf); - tmp_buf = NULL; - - /* Add MOUNTPHYSICAL constraint */ - /* Maybe a forced unmount will not use this constraint */ - (void) mm_add_to_dest(cmd, - "MOUNTPHYSICAL"); - if (tmp_buf) - free(tmp_buf); - tmp_buf = NULL; - tmp_buf = mms_strapp(tmp_buf, - "(\"MOUNTPHYSICAL\".\"CartridgeID\" " - "= \"%s\".\"CartridgeID\")", type); - (void) mm_add_to_const(cmd, tmp_buf); - if (tmp_buf) - free(tmp_buf); - tmp_buf = NULL; - /* Make tmp_buf and set source */ - (void) mm_add_to_source(cmd, type); - tmp_buf = mms_strapp(tmp_buf, - "select \"%s\"." - "\"CartridgeID\" from\n ", type); - if (type) - free(type); - type = NULL; - - SQL_CHK_LEN(&cmd->cmd_buf, NULL, - &cmd->cmd_bufsize, strlen(tmp_buf) + 1); - strcpy(cmd->cmd_buf, tmp_buf); - - if (tmp_buf) - free(tmp_buf); - tmp_buf = NULL; - - if (mm_sql_from_where(cmd, db)) { - mms_trace(MMS_ERR, - "mm_unmount_cart_results: " - "db error creating helper functions"); - return (NULL); - } - - - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - return (NULL); - } - if (PQntuples(db->mm_db_results) == 0) { - /* no cartridge matches */ - mms_trace(MMS_INFO, - "match statment in mount " - "didn't match any cartridge/volumes"); - mm_response_error(cmd, - ECLASS_EXPLICIT, ENOMATCH, - MM_5052_MSG, - NULL); - return (NULL); - } - tmp_buf = mms_strapp(tmp_buf, - "select distinct \"CartridgeID\"," - "\"LibraryName\",\"CartridgeGroupPriority\"," - "\"CartridgeNumberMounts\", " - "\"CartridgeTypeName\",\"CartridgePCL\", " - "\"CartridgeDriveOccupied\" " - "from ( " - "select \"CartridgeID\",\"LibraryName\", " - "\"CartridgeGroupPriority\"," - "\"CartridgeNumberMounts\", " - "\"CartridgeTypeName\",\"CartridgePCL\", " - "\"CartridgeDriveOccupied\" " - "from \"CARTRIDGE\",\"CARTRIDGEGROUP\""); - for (i = 0; i < PQntuples(db->mm_db_results); i++) { - if (i == 0) { - tmp_buf = mms_strapp(tmp_buf, "where ("); - } else { - tmp_buf = mms_strapp(tmp_buf, "or "); - } - tmp_buf = mms_strapp(tmp_buf, " (\"CartridgeID\" = '%s')", - PQgetvalue(db->mm_db_results, i, 0)); - } - tmp_buf = mms_strapp(tmp_buf, - ") and" - "(\"CARTRIDGEGROUP\".\"CartridgeGroupName\" " - "= \"CARTRIDGE\".\"CartridgeGroupName\")" - "order by \"CARTRIDGE\".\"CartridgeTimeMountedLast\"" - ") as foo order by \"CartridgeGroupPriority\";"); - mm_clear_db(&db->mm_db_results); - if (mm_db_exec(HERE, db, tmp_buf) != MM_DB_DATA) { - if (tmp_buf) - free(tmp_buf); - tmp_buf = NULL; - mm_sql_db_err_rsp_new(cmd, db); - return (NULL); - } - if (tmp_buf) - free(tmp_buf); - tmp_buf = NULL; - return (db->mm_db_results); -no_mem: - MM_ABORT_NO_MEM(); - return (NULL); -} - -int -mm_unmount_ready(mm_wka_t *mm_wka, mm_command_t *cmd, mm_db_t *db) { - - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - PGresult *cart_results; - int cart_rows; - - int found_cart_drive = 0; - int found_ready_cart_drive = 0; - - cmi_cart_list_t *cart = NULL; - cmi_drive_list_t *drive = NULL; - - int rc; - - /* Do drive/cart/lib selection using path matching */ - if ((cart_results = mm_unmount_cart_results(mm_wka, - cmd, db)) == NULL) { - /* No carts or error */ - return (MM_UNMOUNT_ERROR); - } - - cart_rows = PQntuples(cart_results); - mms_trace(MMS_DEVP, "Number of Cartridges is %d", cart_rows); - if (cart_rows == 0) { - /* No Cartridge Matches Error */ - mms_trace(MMS_INFO, - "match statment in mount " - "didn't match any cartridge/volumes"); - mm_response_error(cmd, - ECLASS_EXPLICIT, ENOMATCH, - MM_5052_MSG, - NULL); - mm_clear_db(&cart_results); - return (MM_UNMOUNT_ERROR); - } - - /* Create the list objects for */ - /* every cartridge/drive candidate */ - if (mm_mount_init_candidates(cmd, cart_results, - db)) { - mms_trace(MMS_ERR, - "error initializing candidate lists"); - /* err buf should be set by mm_mount_init */ - /* so return and remove */ - mm_clear_db(&cart_results); - return (MM_UNMOUNT_ERROR); - } - mms_trace(MMS_DEVP, "candidate list created, check availability "); - mm_clear_db(&cart_results); - /* Check the availability of the candidates */ - if (mm_mount_check_candidates(mm_wka, cmd, - db)) { - mms_trace(MMS_ERR, - "error checking candidate lists"); - mm_system_error(cmd, - "error checking candidate lists"); - return (MM_UNMOUNT_ERROR); - } - mms_trace(MMS_DEVP, "done checking list"); - - - /* Print mount information */ - mm_print_mount_summary(mm_wka, cmd); - found_cart_drive = 0; - found_ready_cart_drive = 0; - - mms_list_foreach(&mount_info->cmi_cart_list, cart) { - if (cart->cmi_cart_not_ready) - cart->cmi_remove_cart = 1; - mms_list_foreach(&cart->cmi_drive_list, drive) { - found_cart_drive = 1; - if ((cart->cmi_cart_not_ready == 0) && - (drive->cmi_drive_not_ready == 0)) { - found_ready_cart_drive = 1; - } - if (drive->cmi_drive_not_ready) - drive->cmi_remove_drive = 1; - } - } - - - /* If there is a library or drive error */ - /* the error buff has already been set */ - if (found_cart_drive == 0) { - mms_trace(MMS_INFO, - "No candidate " - "cartridge/library/drive " - "combination found"); - return (MM_UNMOUNT_ERROR); - } - if (found_ready_cart_drive == 0) { - mms_trace(MMS_INFO, - "candidate " - "cartridge/library/drive " - "combination found, but is not ready"); - return (MM_UNMOUNT_NOT_READY); - } - /* There is a ready cart/drive */ - /* we may have set some non ready for remove */ - /* so call the clean func before contine */ - mm_mount_clean_candidates(cmd); - cmd->cmd_state = 1; - rc = mm_set_immediate_unmount(cmd, db); - - if (rc == MM_CMD_ERROR) { - mms_trace(MMS_ERR, - "error setting up immediate mount"); - return (MM_UNMOUNT_ERROR); - } - mms_trace(MMS_DEVP, - "mount ready for dispatch"); - - return (MM_UNMOUNT_READY); - -} - -int -mm_unmount_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - int rc; - char *response_message = NULL; - - mms_trace(MMS_DEVP, "mm unmount state %d", cmd->cmd_state); - mm_print_unmount_state(cmd->cmd_state); - - /* UM_CANDIDATE_SELECTION == 0 */ - if (cmd->cmd_state == UM_CANDIDATE_SELECTION) { - - mms_trace(MMS_INFO, "Processing Unmount Request..."); - /* - * Generate Candidate Cartridge and Drive lists - * First parse and save the mount info - * then use SQL queries to gereate the lists - */ - - if (mm_parse_unmount_cmd(mm_wka, cmd) == MM_CMD_ERROR) { - mms_trace(MMS_ERR, - "error parsing unmount command"); - /* Error buf should already be set */ - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mms_trace(MMS_DEVP, "done parsing unmount"); - - if (mm_set_tm_task(db, cmd) != MM_DB_OK) { - goto db_error; - } - mms_trace(MMS_DEVP, - "unmount will be passed to task manager"); - return (MM_WORK_TODO); - - } else if (cmd->cmd_state == UM_DM_DETACH) { - mms_trace(MMS_INFO, "Unmounting Tape..."); - /* - * Add Detach command - */ - if (mm_dmp_add_cmd(mm_wka, cmd, - mount_info->cmi_dm, - MM_DMP_DETACH) == NULL) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "error adding dmp unload"); - mm_system_error(cmd, - "error adding dmp unload"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - cmd->cmd_state = UM_DM_RELEASE; - return (MM_DISPATCH_DEPEND); - - } - if (cmd->cmd_state == UM_DM_RELEASE) { - /* - * Detach has returned - * check error, update states - * Add release command - */ - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - mms_trace(MMS_DEVP, "mmp_unmount-> DMP detach error"); - - if ((cmd->cmd_response != NULL) && - mm_errorcode_eq(cmd->cmd_response, - "DM_E_NOEXISTHANDLE")) { - - /* DM doesn't know about the handle */ - /* Continue with unmount regardless */ - /* skip unload */ - mms_trace(MMS_DEVP, - "DM doesn't know the handle, " - "skip DMP unload, " - "send LMP unmount"); - mount_info->cui_skip_unload = 1; - /* Clear depend error flags */ - MM_UNSET_FLAG(cmd->cmd_flags, - MM_CMD_DEPEND_ERROR); - } else { - mount_info->cmi_reset_states = 1; - mount_info->cmi_need_clear = 1; - response_message = - mm_ret_response_msg(cmd); - mm_response_error(cmd, - ECLASS_SUBOP, - ELMDMCOMMUNICATION, - MM_5055_MSG, - "msg_rsp", response_message, - NULL); - free(response_message); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - } - - if (mm_db_exec(HERE, db, "delete from \"MOUNTLOGICAL\" " \ - "where \"CartridgeID\" = '%s';", - mount_info->cmi_cartridge) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "db error deleteing MOUNTLOGICAL"); - } - if (mm_db_exec(HERE, db, "delete from \"STALEHANDLE\" "\ - "where \"CartridgeID\" = '%s';", - mount_info->cmi_cartridge) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "db error deleteing STALEHANDLE"); - } - - if (mm_dmp_add_cmd(mm_wka, cmd, mount_info->cmi_dm, - MM_DMP_RELEASE) == NULL) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "error adding dmp release"); - mm_system_error(cmd, - "error adding dmp release"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - cmd->cmd_state = UM_SCHEDULE_UNLOAD; - return (MM_DISPATCH_DEPEND); - } - if (cmd->cmd_state == UM_SCHEDULE_UNLOAD) { - /* - * release command has returned - * check for errors, update states - */ - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - mms_trace(MMS_DEVP, "mmp_unmount-> DMP release error"); - mount_info->cmi_reset_states = 1; - mount_info->cmi_need_clear = 1; - mm_response_error(cmd, - ECLASS_SUBOP, - ELMDMCOMMUNICATION, - MM_5055_MSG, - "msg_rsp", mm_ret_response_msg(cmd), - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - - if (mount_info->cui_physical) { - /* This is a physical unmount */ - cmd->cmd_state = UM_LM_UNMOUNT; - - if (mm_dmp_add_cmd(mm_wka, cmd, mount_info->cmi_dm, - MM_DMP_UNLOAD) == NULL) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "error adding dmp unload"); - mm_system_error(cmd, - "error adding dmp unload"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - rc = MM_DISPATCH_DEPEND; - goto end; - - } - /* Delayed unmount */ - - mms_trace(MMS_DEVP, - "DELAY UNLOAD NOW!!!!"); - - /* update drive and cartridge states */ - if (mm_db_exec(HERE, db, "update \"DRIVE\" set " - "\"DriveStateSoft\" = 'ready'," - "\"DMName\" = ''" - " where " - "\"DriveName\" = '%s';", - cmd->cmd_mount_info.cmi_drive) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "db error updating DriveStateSoft"); - } - - if (mm_db_exec(HERE, db, - "update \"CARTRIDGE\" set \"CartridgeStatus\" " - "= 'available' where " - "\"CartridgeID\" = '%s';", - cmd->cmd_mount_info.cmi_cartridge) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "db error updating CartridgeStatus"); - } - - if (mm_db_exec(HERE, db, "delete from \"TASKCARTRIDGE\"" - "where \"TaskID\" = '%s';", cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "db error deleting TASKCARTRIDGE"); - } - if (mm_db_exec(HERE, db, "delete from \"TASKDRIVE\" " - "where \"TaskID\" = '%s';", cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "db error deleting TASKDRIVE"); - } - if (mm_db_exec(HERE, db, "delete from \"TASKLIBRARY\" " - "where \"TaskID\" = '%s';", cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "db error deleting TASKLIBRARY"); - } - if (mm_db_exec(HERE, db, "delete from \"TASK\" " - "where \"TaskID\" = '%s';", cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "db error deleting TASK"); - } - if (mm_db_exec(HERE, db, "delete from \"MOUNTPHYSICAL\" " - "where \"CartridgeID\" = '%s';", - mount_info->cmi_cartridge) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "db error deleting MOUNTPHYSICAL"); - } - - - if (mm_schedule_unload(mm_wka, cmd)) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "error scheduling unload"); - } - /* Send success for the unmount */ - mm_path_match_report(cmd, db); - cmd->cmd_remove = 1; - mm_send_response(mm_wka->mm_wka_conn, cmd); - rc = MM_DISPATCH_AGAIN; - goto end; - - } - - if (cmd->cmd_state == UM_LM_UNMOUNT) { - mm_command_t *lmp_umnt_cmd; - mm_wka_t *lm_wka; - uuid_text_t new_task; - char *cart_pcl; - char *side_name; - - /* - * Unload has returned - * check error, update states - * Add release command - */ - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - mount_info->cmi_reset_states = 1; - mount_info->cmi_need_clear = 1; - - mms_trace(MMS_DEVP, "mmp_unmount-> DMP unload error"); - response_message = - mm_ret_response_msg(cmd); - mm_response_error(cmd, - ECLASS_SUBOP, - ELMDMCOMMUNICATION, - MM_5055_MSG, - "msg_rsp", response_message, - NULL); - free(response_message); - cmd->cmd_remove = 1; - - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - - rc = MM_CMD_ERROR; - goto end; - } - - /* - * Cartridge pcl and side name - */ - if ((cart_pcl = mm_get_cart_pcl(cmd, - cmd->cmd_mount_info.cmi_cartridge, db)) == NULL) { - cmd->cmd_remove = 1; - mms_trace(MMS_ERR, - "mm_get_cart_pcl error"); - return (MM_CMD_ERROR); - } - - - /* TODO side name needs to be generated in candidate query */ - if ((side_name = cmd->cmd_mount_info.cmi_side_name) == NULL) { - side_name = "side 1"; - } - - /* - * LMP unmount command - */ - lm_wka = mm_library_lm_wka(cmd->wka_ptr->mm_data, - cmd->cmd_mount_info.cmi_library, NULL); - if ((lmp_umnt_cmd = mm_alloc_cmd(lm_wka)) == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_command_t: %s", - strerror(errno)); - return (MM_CMD_ERROR); - } - lmp_umnt_cmd->cmd_func = mm_lmp_unmount_cmd_func; - mm_get_uuid(new_task); - lmp_umnt_cmd->cmd_textcmd = mms_strnew(LMP_UNMOUNT, new_task, - cart_pcl, cart_pcl, side_name, - cmd->cmd_mount_info.cmi_drive, - cart_pcl, cart_pcl, side_name); - mm_set_mount_info_drive(cmd->cmd_mount_info.cmi_drive, - &lmp_umnt_cmd->cmd_mount_info); - mm_set_mount_info_pcl(cart_pcl, - &lmp_umnt_cmd->cmd_mount_info); - lmp_umnt_cmd->cmd_root = - mm_text_to_par_node(lmp_umnt_cmd->cmd_textcmd, - mms_lmpm_parse); - lmp_umnt_cmd->cmd_task = mm_get_task(lmp_umnt_cmd->cmd_root); - mm_add_depend(lmp_umnt_cmd, cmd); - lmp_umnt_cmd->cmd_name = strdup("lmp unmount"); - - cmd->cmd_state = UM_FINAL; - - pthread_mutex_lock(&mm_wka->mm_data->mm_queue_mutex); - mms_list_insert_tail(&mm_wka->mm_data-> - mm_cmd_queue, lmp_umnt_cmd); - pthread_mutex_unlock(&mm_wka->mm_data->mm_queue_mutex); - - free(cart_pcl); - - return (MM_DISPATCH_DEPEND); - - } else if (cmd->cmd_state == UM_FINAL) { - - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - mms_trace(MMS_DEVP, "lm unmount failed"); - mount_info->cmi_reset_states = 1; - mount_info->cmi_need_clear = 1; - response_message = - mm_ret_response_msg(cmd); - mm_response_error(cmd, - ECLASS_SUBOP, - ELMDMCOMMUNICATION, - MM_5055_MSG, - "msg_rsp", response_message, - NULL); - free(response_message); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - - /* - * TEMPORARY update drive states remove TASK objs - */ - - /* If cmd_depend is set this is part of a begin-end group */ - /* so do not reset the drive state */ - if (mm_has_depend(cmd) == 0) { - if (mm_db_exec(HERE, db, "update \"DRIVE\" set " - "\"DriveStateSoft\" = 'ready'," - "\"DMName\" = ''," - "\"DriveStateHard\" = 'unloaded' where " - "\"DriveName\" = '%s';", - cmd->cmd_mount_info.cmi_drive) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "db error updating DRIVE"); - } - - } else { - if (mm_db_exec(HERE, db, "update \"DRIVE\" set " - "\"DMName\" = ''," - "\"DriveStateHard\" = 'unloaded' where " - "\"DriveName\" = '%s';", - cmd->cmd_mount_info.cmi_drive) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "db error updating DRIVE"); - } - } - if (mm_db_exec(HERE, db, - "update \"CARTRIDGE\" set \"CartridgeStatus\" " - "= 'available' where " - "\"CartridgeID\" = '%s';", - cmd->cmd_mount_info.cmi_cartridge) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "db error updating CartridgeStatus"); - } - - - if (mm_db_exec(HERE, db, "delete from \"TASKCARTRIDGE\"" - "where \"TaskID\" = '%s';", cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "db error deleting TASKCARTRIDGE"); - } - if (mm_db_exec(HERE, db, "delete from \"TASKDRIVE\" " - "where \"TaskID\" = '%s';", cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "db error deleting TASKDRIVE"); - } - if (mm_db_exec(HERE, db, "delete from \"TASKLIBRARY\" " - "where \"TaskID\" = '%s';", cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "db error deleting TASKLIBRARY"); - } - if (mm_db_exec(HERE, db, "delete from \"TASK\" " - "where \"TaskID\" = '%s';", cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "db error deleting TASK"); - } - if (mm_db_exec(HERE, db, "delete from \"MOUNTPHYSICAL\" " - "where \"CartridgeID\" = '%s';", - mount_info->cmi_cartridge) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_unmount_cmd_func: " - "db error deleting MOUNTPHYSICAL"); - } - - /* - * Report clause. - */ - - mm_path_match_report(cmd, db); - cmd->cmd_remove = 1; - mm_send_response(mm_wka->mm_wka_conn, cmd); - mms_trace(MMS_INFO, "Tape Unmounted Successfully"); - - if (mm_has_depend(cmd)) { - mm_command_t *cur_depend = NULL; - mms_list_foreach(&cmd->cmd_depend_list, cur_depend) { - if (cur_depend->cmd_func == - mm_delay_unmount_cmd_func) { - mms_trace(MMS_DEVP, - "this delay unmount has " - "delay unmount as parent," - " set parent ready for dispatch"); - mm_set_unload_dispatch(cur_depend, - NULL); - } - } - rc = MM_DEPEND_DONE; - goto end; - } - rc = MM_CMD_DONE; - goto end; - } - mms_trace(MMS_ERR, "Unknown state"); - cmd->cmd_remove = 1; - rc = MM_CMD_ERROR; - goto end; - -no_mem: - MM_ABORT_NO_MEM(); - rc = MM_CMD_ERROR; - goto end; - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; -db_error: - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - -end: - return (rc); - -} - - - -int -mm_begin_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *arg; - mms_par_node_t *value; - mm_db_t *db = &mm_wka->mm_data->mm_db; - - mms_trace(MMS_DEVP, "sql trans begin cmd"); - if (cmd->cmd_state == 0) { - mms_trace(MMS_DEVP, "when"); - arg = mms_pn_lookup(cmd->cmd_root, "when", - MMS_PN_CLAUSE, NULL); - if (arg != NULL) { - MMS_PN_LOOKUP(value, - arg, NULL, MMS_PN_KEYWORD, NULL); - if (strcmp(value->pn_string, "blocking") == 0) { - mm_wka->wka_begin_end.be_mode = - ACCESS_MODE_BLOCKING; - } else { - mm_wka->wka_begin_end.be_mode = - ACCESS_MODE_IMMEDIATE; - } - } else { - /* when is optional and defaults to immediate */ - mm_wka->wka_begin_end.be_mode = ACCESS_MODE_IMMEDIATE; - } - mms_trace(MMS_DEVP, "ready for mount unmount command group"); - /* return MM_DISPATCH_DEPEND??? */ - cmd->cmd_state = 1; - return (MM_DISPATCH_DEPEND); - } - if (cmd->cmd_state == 1) { - /* when End has been accepted, send success for begin */ - /* Send success */ - mm_path_match_report(cmd, db); - cmd->cmd_remove = 1; - mm_send_response(mm_wka->mm_wka_conn, cmd); - return (MM_DEPEND_DONE); - } - - mms_trace(MMS_ERR, - "bad command state- begin command"); - mm_system_error(cmd, - "bad command state- begin command"); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - mm_wka->wka_begin_end.be_active = B_FALSE; - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); -} - - -void -mm_mv_beginend(mm_command_t *begin, mm_command_t *end) { - /* begin end command list */ - mm_command_t *cur_cmd; - mm_command_t *next_cmd; - - /* Move beginend commands from begin to end */ - for (cur_cmd = mms_list_head(&begin->cmd_beginend_list); - cur_cmd != NULL; - cur_cmd = next_cmd) { - next_cmd = - mms_list_next(&begin->cmd_beginend_list, - cur_cmd); - mms_list_remove(&begin->cmd_beginend_list, - cur_cmd); - mms_list_insert_tail(&end->cmd_beginend_list, - cur_cmd); - } -} - -int -mm_be_parse_cmds(mm_command_t *cmd) { - - mm_command_t *cur_cmd; - int cmd_count = 0; - mm_wka_t *mm_wka = cmd->wka_ptr; - - cmd_count = 0; - mms_list_foreach(&cmd->cmd_beginend_list, cur_cmd) { - cmd_count ++; - mms_trace(MMS_DEVP, - "Begin-end cmd %d, %s", - cmd_count, cur_cmd->cmd_name); - - if (cur_cmd->cmd_func == mm_mount_cmd_func) { - if (mm_parse_mount_cmd(cur_cmd->wka_ptr, - cur_cmd) == MM_CMD_ERROR) { - mms_trace(MMS_ERR, - "error parsing unmount command"); - /* Error buf should already be set */ - return (-1); - } - } else { - if (mm_parse_unmount_cmd(cur_cmd->wka_ptr, - cur_cmd) == MM_CMD_ERROR) { - mms_trace(MMS_ERR, - "error parsing unmount command"); - /* Error buf should already be set */ - return (-1); - } - } - if (mm_wka->wka_begin_end.be_mode == ACCESS_MODE_IMMEDIATE) { - cur_cmd->cmd_mount_info.cmi_when = MM_IMMEDIATE; - } else { - cur_cmd->cmd_mount_info.cmi_when = MM_BLOCKING; - } - } - return (cmd_count); -} - -int -mm_end_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_command_t *be_command = NULL; - int cmd_count; - mm_db_t *db = &mm_wka->mm_data->mm_db; - - mms_trace(MMS_DEVP, "mm_end_cmd_func"); - if (cmd->cmd_state == 0) { - be_command = cmd->cmd_begin_cmd; - if (be_command == NULL) { - mms_trace(MMS_ERR, - "couldn't find begin for this end"); - mm_system_error(cmd, - "couldn't find begin for this end"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - /* Copy begin cmd list ptr */ - /* set begin for dispatch */ - /* as depend */ - mm_add_depend(be_command, cmd); - mm_mv_beginend(be_command, cmd); - MM_SET_FLAG(be_command->cmd_flags, - MM_CMD_DISPATCHABLE); - cmd->cmd_state = 1; - return (MM_DISPATCH_DEPEND); - } - if (cmd->cmd_state == 1) { - /* Begin has returned success */ - - /* abort command group */ - if (mms_pn_lookup(cmd->cmd_root, "abort", - MMS_PN_KEYWORD, NULL)) { - /* Cancel all the commands */ - /* and return success for the abort */ - mms_trace(MMS_DEVP, "begin-end abort"); - mm_path_match_report(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - tm_be_cancel_all(cmd); - return (MM_CMD_DONE); - } - - if ((cmd_count = mm_be_parse_cmds(cmd)) == -1) { - /* Error parsing a command */ - mm_system_error(cmd, - "error parsing mount/unmount " - "inside begin-end group"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - - } else if (cmd_count == 0) { - /* No commands in this command group */ - /* Send success ??? */ - mm_path_match_report(cmd, db); - cmd->cmd_remove = 1; - mm_send_response(mm_wka->mm_wka_conn, cmd); - return (MM_CMD_DONE); - } - - mms_trace(MMS_DEVP, - "done parsing %d commands for begin-end group", - cmd_count); - if (mm_set_tm_task(db, cmd) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - cmd->cmd_state = 2; - mms_trace(MMS_DEVP, - "begin-end group will be passed to task manager"); - - return (MM_WORK_TODO); - } - if (cmd->cmd_state == 2) { - /* Task manager has dispatched this command */ - /* Send success for end */ - mms_trace(MMS_DEVP, "end command state 2"); - - cmd->cmd_remove = 1; - return (MM_CMD_DONE); - } - mms_trace(MMS_ERR, - "bad command state- end command"); - mm_system_error(cmd, - "bad command state- end command"); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -} diff --git a/usr/src/cmd/mms/mm/common/mm_mmp_sql.c b/usr/src/cmd/mms/mm/common/mm_mmp_sql.c deleted file mode 100644 index e9ed5c4639..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_mmp_sql.c +++ /dev/null @@ -1,10375 +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 <stdlib.h> -#include <string.h> -#include <errno.h> -#include <pthread.h> -#include <syslog.h> -#include <unistd.h> -#include <libscf.h> -#include <mms_list.h> -#include <mms_parser.h> -#include <mms_par_impl.h> -#include <libpq-fe.h> -#include <mms_trace.h> -#include <mms_strapp.h> -#include "mm_db.h" -#include "mm.h" -#include "mm_util.h" -#include "mm_commands.h" -#include "mm_sql.h" -#include "mm_sql_impl.h" -#include "mm_task.h" -#include "mm_path.h" -#include "mms_sock.h" -#include "net_cfg_service.h" -#include "mms_cfg.h" -#include "mms_cat.h" - -static char *_SrcFile = __FILE__; - -/* - * Macros with a %s that create a function - * need to be dropped before each use - */ - -/* Need to drop GET_TYPE_SQL */ -#define GET_TYPE_SQL "CREATE FUNCTION gettype() RETURNS " \ - "SETOF \"%s\" AS $$ SELECT * FROM \"%s\" %s; " \ - "$$ LANGUAGE SQL;" - -#define GET_ID_SQL "select distinct \"CartridgeID\" " \ - "from getcart() where \"CartridgeGroupName\" in " \ - "(select distinct \"CartridgeGroupName\" " \ - "from \"CARTRIDGEGROUPAPPLICATION\" " \ - "where \"ApplicationName\" = '%s');" - -#define SELECT_CAP_GROUP "select distinct " \ - "\"DMCapabilityGroupName\" from " \ - "\"DMCAPABILITYGROUPTOKEN\" where " \ - "\"DriveName\" = '%s';" - -#define SELECT_CAP_TOK "select \"DMCapabilityToken\" " \ - "from \"DMCAPABILITYGROUPTOKEN\" where " \ - "\"DMCapabilityGroupName\" = '%s' and " \ - "\"DriveName\" = '%s' and \"DMCapabilityToken\" = '%s' " \ - "and \"DMName\" " \ - "in (select \"DMName\" from \"DM\" " \ - "where pg_host_ident(\"DMTargetHost\") = pg_host_ident('%s'));" - -#define SELECT_DEFAULT_TOK "select \"DMCapabilityGroupDefaultName\" " \ - "from \"DMCAPABILITYGROUP\" " \ - "where \"DriveName\" = '%s' " \ - "and \"DMCapabilityGroupName\" = '%s';" - -extern int mm_attribute_match(mm_command_t *cmd); -extern void mm_print_char_list(mms_list_t *list); -extern int mm_add_char(char *str, mms_list_t *list); -extern int mm_sql_report_func_attr(mm_command_t *cmd); -extern int mm_sql_report_func(mm_command_t *cmd, mm_db_t *db); -extern int mm_get_set_clause(mm_command_t *cmd, mms_list_t *set_list, - mms_list_t *obj_list); -extern int mm_notify_delete(mm_db_t *db, mm_command_t *cmd, char *objname, - int match_off); -static int mm_change_attendance_mode(mm_wka_t *mm_wka); -extern void mm_cancel_cmd_buf(mm_command_t *cmd); -extern int mm_exiting; - -void -mm_write_success(mm_command_t *cmd, char *fmt, ...) { - va_list args; - char *text; - va_start(args, fmt); - text = mms_vstrapp(NULL, fmt, args); - va_end(args); - if (text == NULL) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - free(text); - return; - } - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS_TEXT_DQ) + - strlen(cmd->cmd_task) + - strlen(text) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS_TEXT_DQ, cmd->cmd_task, text); - free(text); - return; -no_mem: - MM_ABORT_NO_MEM(); -} - - -int -mm_add_lib_lm_activate(mm_command_t *parent, mm_wka_t *lm_wka, int type) { - - mm_command_t *cmd; - uuid_text_t uuid; - - if (type == 1) { - /* activate enable */ - mms_trace(MMS_DEVP, "add activate enable"); - } else if (type == 2) { - /* activate disable */ - mms_trace(MMS_DEVP, "add activate disable"); - } else { - mms_trace(MMS_ERR, "unknown type passed"); - return (1); - } - - - if ((cmd = mm_alloc_cmd(lm_wka)) == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_command_t: %s", - strerror(errno)); - return (1); - } - mm_add_depend(cmd, parent); - mm_get_uuid(uuid); - cmd->cmd_root = NULL; - cmd->cmd_task = NULL; - cmd->cmd_task = strdup(uuid); - if (cmd->cmd_task == NULL) { - mms_trace(MMS_ERR, "Error malloc cmd_task in add cmd"); - return (1); - } - if (type == 1) { - /* activate enable */ - cmd->cmd_textcmd = mms_strnew(ACTIVATE_ENABLE, cmd->cmd_task); - cmd->cmd_name = strdup("lmp activate"); - if (cmd->cmd_name == NULL) { - mms_trace(MMS_ERR, "Error malloc cmd->name " - "in add cmd"); - return (1); - } - } else if (type == 2) { - /* activate disable */ - cmd->cmd_textcmd = mms_strnew(ACTIVATE_DISABLE, cmd->cmd_task); - cmd->cmd_name = strdup("lmp activate"); - if (cmd->cmd_name == NULL) { - mms_trace(MMS_ERR, "Error malloc cmd->name " - "in add cmd"); - return (1); - } - } - cmd->cmd_func = mm_lmp_activate_cmd_func; - cmd->cmd_root = mm_text_to_par_node(cmd->cmd_textcmd, mms_lmpm_parse); - - pthread_mutex_lock(&lm_wka->mm_data->mm_queue_mutex); - mms_list_insert_tail(&lm_wka->mm_data->mm_cmd_queue, cmd); - pthread_mutex_unlock(&lm_wka->mm_data->mm_queue_mutex); - mms_trace(MMS_INFO, - "LM activate added, %s", lm_wka->wka_conn.cci_instance); - - return (0); -} - -int -mm_libonline_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - mms_par_node_t *arg; - mms_par_node_t *value; - mms_par_node_t *work; - mms_par_node_t *item; - int print_message = 1; - int rc; - - char *lib_name = NULL; - char *lm_name = NULL; - int online = 0; - int offline = 0; - int lib_broken = 0; - char *cmd_buf = NULL; - - char *response_message = NULL; - - mm_data_t *mm_data = mm_wka->mm_data; - mm_wka_t *next; - mm_wka_t *cur_wka; - int found = 0; - - - mms_trace(MMS_DEBUG, "mm_libonline_cmd_func"); - - - if (cmd->cmd_state == 2) { - /* An activate command has completed */ - /* Check for errors */ - mms_trace(MMS_DEVP, " cmd_state == 2"); - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - mms_trace(MMS_ERR, "LM activate failed"); - response_message = - mm_ret_response_msg(cmd); - mm_response_error(cmd, - ECLASS_SUBOP, - ELMDMCOMMUNICATION, - MM_5055_MSG, - "msg_rsp", response_message, - NULL); - free(response_message); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - /* The sql command should still be cmd->cmd_buf */ - /* send it to the data base */ - - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_OK) { - goto db_error; - } - - /* Send Success */ - mm_path_match_report(cmd, db); - mm_send_response(mm_wka->mm_wka_conn, cmd); - rc = MM_CMD_DONE; - goto end; - } - - - - /* Online clause */ - work = NULL; - arg = mms_pn_lookup(cmd->cmd_root, "online", - MMS_PN_CLAUSE, &work); - if (arg != NULL) { - if (print_message) - mms_trace(MMS_DEVP, "online clause"); - item = NULL; - - /* Get Library Name */ - if ((value = - mms_pn_lookup(arg, NULL, - MMS_PN_STRING, - &item)) == NULL) { - /* Missing a Library Name */ - mms_trace(MMS_ERR, "Missing a library Name"); - goto not_found; - } else { - /* Have a library Name */ - online = 1; - lib_name = mms_strapp(lib_name, - value->pn_string); - if (print_message) - mms_trace(MMS_DEVP, " %s", - value->pn_string); - } - /* Try to get LMName */ - if ((value = - mms_pn_lookup(arg, NULL, - MMS_PN_STRING, - &item)) == NULL) { - /* Should never hit here... */ - /* Missing a LM Name */ - mms_trace(MMS_ERR, "Missing a LM Name"); - goto not_found; - } else { - /* Have a lm Name */ - lm_name = mms_strapp(lm_name, - value->pn_string); - if (print_message) - mms_trace(MMS_DEVP, " %s", - value->pn_string); - } - - } else { - /* Didn't find a online clause */ - if (print_message) - mms_trace(MMS_DEVP, "Didn't find a online clause"); - } - - /* Offline clause */ - work = NULL; - arg = mms_pn_lookup(cmd->cmd_root, "offline", - MMS_PN_CLAUSE, &work); - if (arg != NULL) { - if (print_message) - mms_trace(MMS_DEVP, "offline clause"); - /* Get Drive Name */ - item = NULL; - - if ((value = - mms_pn_lookup(arg, NULL, - MMS_PN_STRING, - &item)) == NULL) { - mms_trace(MMS_ERR, "Missing a library name"); - goto not_found; - - } else { - /* Have the library name */ - offline = 1; - lib_name = mms_strapp(lib_name, - value->pn_string); - if (print_message) - mms_trace(MMS_DEVP, " %s", - value->pn_string); - } - - } else { - /* Didn't find a offline clause */ - if (print_message) - mms_trace(MMS_DEVP, "Didn't find a offline clause"); - } - - if (online && offline) { - /* Shouldn't ever get here */ - mms_trace(MMS_ERR, "Cannot have both an " - "online and offline clause"); - /* ECLASS_LANGUAGE, ELIBRARYNOEXIST */ - mm_response_error(cmd, - ECLASS_LANGUAGE, - ETOOMANYCLAUSES, - MM_5057_MSG, - NULL); - /* Create new error codes */ - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto not_found; - } - - /* Check Priv, library ownership */ - - /* Check if library exists */ - /* Determine if the library is broken or not */ - if (mm_db_exec(HERE, db, - "select \"LibraryName\",\"LibraryBroken\" " - "from \"LIBRARY\" where " - "\"LibraryName\" = '%s';", - lib_name) != MM_DB_DATA) { - goto db_error; - } else { - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, "Library does not exist"); - /* No library exists */ - /* ECLASS_EXIST, ELIBRARYNOEXIST */ - mm_response_error(cmd, - ECLASS_EXIST, - ELIBRARYNOEXIST, - MM_5058_MSG, - NULL); - /* Create new error codes */ - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - - } else { - if (strcmp(PQgetvalue(db->mm_db_results, - 0, 1), "t") == 0) { - mms_trace(MMS_INFO, "Library %s is broken", - lib_name); - lib_broken = 1; - } - } - } - - - mm_clear_db(&db->mm_db_results); - if (online) { - /* If library is broken, error */ - if (lib_broken) { - /* Library is broken */ - mms_trace(MMS_ERR, "Library broken"); - mm_response_error(cmd, - ECLASS_CONFIG, - "ELIBBROKEN", - MM_5044_MSG, - NULL); - /* Create new error codes */ - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - /* Is the library already online */ - - if (mm_db_exec(HERE, db, - "select \"LibraryName\" " - "from \"LIBRARY\" where " - "\"LibraryName\" = '%s'" - "and \"LibraryOnline\" = 'true';", - lib_name) != MM_DB_DATA) { - goto db_error; - } else { - if (PQntuples(db->mm_db_results) == 1) { - mms_trace(MMS_ERR, "Library already online"); - /* Library already online */ - /* ECLASS_PREMPRIV, ELIBALREADYONLINE */ - mm_response_error(cmd, - ECLASS_PERMPRIV, - "ELIBALREADYONLINE", - MM_5059_MSG, - "lib", - lib_name, - NULL); - /* Create new error codes */ - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - - } - } - mm_clear_db(&db->mm_db_results); - /* Check if LM exists */ - if (mm_db_exec(HERE, db, - "select \"LMName\" " - "from \"LM\" where " - "\"LMName\" = '%s';", - lm_name) != MM_DB_DATA) { - goto db_error; - } else { - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, "LM does not exist"); - /* No lm exists */ - /* ECLASS_EXIST, ELMNOEXIST */ - mm_response_error(cmd, - ECLASS_EXIST, - ELMNOEXIST, - MM_5060_MSG, - NULL); - /* Create new error codes */ - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - - } - } - - /* Do online specific checks */ - - /* Do online */ - cmd_buf = mms_strapp(cmd_buf, - "update \"LIBRARY\" set " - "\"LMName\" = '%s', " - "\"LibraryOnline\" = 'true', " - "\"LibraryDisabled\" = 'false', " - "\"LibraryBroken\" = 'f' " - "where \"LibraryName\" = '%s';", - lm_name, - lib_name); - } else if (offline) { - - /* Do offline specific checks */ - /* Is the library already offline */ - - if (mm_db_exec(HERE, db, - "select \"LibraryName\" " - "from \"LIBRARY\" where " - "\"LibraryName\" = '%s'" - "and \"LibraryOnline\" = 'false';", - lib_name) != MM_DB_DATA) { - goto db_error; - } else { - if (PQntuples(db->mm_db_results) == 1) { - mms_trace(MMS_ERR, "Library already offline"); - /* Library already offline */ - /* ECLASS_PREMPRIV, ELIBALREADYOFFLINE */ - mm_response_error(cmd, - ECLASS_PERMPRIV, - "ELIBALREADYOFFLINE", - MM_5061_MSG, - "lib", - lib_name, - NULL); - /* Create new error codes */ - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - - } - } - mm_clear_db(&db->mm_db_results); - /* Find the controlling LM's name */ - if (mm_db_exec(HERE, db, - "select \"LMName\" " - "from \"LIBRARY\" where " - "\"LibraryName\" = '%s';", - lib_name) != MM_DB_DATA) { - goto db_error; - } else { - lm_name = - mms_strapp(lm_name, PQgetvalue(db->mm_db_results, - 0, 0)); - } - /* Do offline */ - cmd_buf = mms_strapp(cmd_buf, - "update \"LIBRARY\" set " - "\"LMName\" = NULL, " - "\"LibraryOnline\" = 'false', " - "\"LibraryBroken\" = 'false' " - "where \"LibraryName\" = '%s';", - lib_name); - /* Update states */ - cmd_buf = mms_strapp(cmd_buf, - " delete from \"SLOT\" where" - "\"LMName\" = '%s'; " - " delete from \"BAY\" where" - "\"LMName\" = '%s'; " - " delete from \"SLOTGROUP\" where" - "\"LMName\" = '%s'; " - "update \"DRIVE\" " - "set \"BayName\" = DEFAULT " - "where \"LibraryName\" = '%s';", - lm_name, - lm_name, - lm_name, - lib_name); - } else { - /* Shouldn't ever get here */ - mms_trace(MMS_ERR, "Missing an online or offline clause"); - goto not_found; - } - - /* Send cmd_buf to data base */ - if (print_message) - mms_trace(MMS_DEVP, "\n%s\n", - cmd_buf); - - - /* Create activate enable/disable commands to dispatch */ - /* if no lm is connected, return success */ - - for (cur_wka = mms_list_head(&mm_data->mm_wka_list); - cur_wka != NULL; - cur_wka = next) { - next = mms_list_next(&mm_data-> - mm_wka_list, cur_wka); - if ((strcmp(cur_wka->wka_conn.cci_client, - lib_name) == 0) && - (strcmp(cur_wka->wka_conn.cci_instance, - lm_name) == 0)) { - found = 1; - break; - } - } - /* If this is an offline and the library is broken */ - /* skip the activate disable */ - if (!found) { - mms_trace(MMS_DEVP, "LM is not connected"); - } else if (!lib_broken) { - mms_trace(MMS_DEVP, "LM is connected"); - if (online) { - mms_trace(MMS_DEVP, "Adding activate enable"); - - if (mm_add_lib_lm_activate(cmd, cur_wka, 1)) { - mms_trace(MMS_ERR, - "mm_libonline_cmd_func: " - "could not add " - "lm activate enable"); - mm_system_error(cmd, - "could not add " - "lm activate enable"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - cmd->cmd_state = 2; - rc = MM_DISPATCH_DEPEND; - /* Copy local cmd_buf into cmd->cmd_buf */ - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(cmd_buf) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - "%s", cmd_buf); - goto end; - } else if (offline) { - mms_trace(MMS_DEVP, "Adding activate disable"); - if (mm_add_lib_lm_activate(cmd, cur_wka, 2)) { - mms_trace(MMS_ERR, - "mm_libonline_cmd_func: " - "could not add " - "lm activate disable"); - mm_system_error(cmd, - "could not add " - "lm activate disable"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - cmd->cmd_state = 2; - rc = MM_DISPATCH_DEPEND; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(cmd_buf) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - "%s", cmd_buf); - goto end; - } - } else { - mms_trace(MMS_DEVP, "LM connected and library broken, " - "skipping activate"); - } - /* Send success for non-connected LM's */ - mm_clear_db(&db->mm_db_results); - if (mm_db_exec(HERE, db, cmd_buf) != MM_DB_OK) { - goto db_error; - } - /* Send Success */ - mm_path_match_report(cmd, db); - mm_send_response(mm_wka->mm_wka_conn, cmd); - rc = MM_CMD_DONE; - goto end; - -db_error: - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - - goto end; -end: - mm_clear_db(&db->mm_db_results); - if (cmd_buf) - free(cmd_buf); - if (lib_name) - free(lib_name); - if (lm_name) - free(lm_name); - return (rc); - -} - -int -mm_drvonline_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - mms_par_node_t *arg; - mms_par_node_t *value; - mms_par_node_t *work; - mms_par_node_t *item; - int print_message = 1; - int rc; - - char *drive_name = NULL; - int online = 0; - int offline = 0; - - char *cmd_buf = NULL; - - mm_wka_t *dm_wka; - - mms_trace(MMS_DEBUG, "mm_drvonline_cmd_func"); - - /* - * NOTES: May need to issue a scan command to LM to - * determine the current state of the drive. - * What to do in error cases? - */ - - /* Online clause */ - work = NULL; - arg = mms_pn_lookup(cmd->cmd_root, "online", - MMS_PN_CLAUSE, &work); - if (arg != NULL) { - if (print_message) - mms_trace(MMS_DEVP, "online clause"); - /* Get Drive Name */ - item = NULL; - - if ((value = - mms_pn_lookup(arg, NULL, - MMS_PN_STRING, - &item)) == NULL) { - mms_trace(MMS_ERR, "Missing a drive name"); - goto not_found; - - } else { - /* Have the drive name */ - online = 1; - drive_name = mms_strapp(drive_name, - value->pn_string); - if (print_message) - mms_trace(MMS_DEVP, " %s", - value->pn_string); - } - - } else { - /* Didn't find a online clause */ - if (print_message) - mms_trace(MMS_DEVP, "Didn't find a online clause"); - } - - /* Offline clause */ - work = NULL; - arg = mms_pn_lookup(cmd->cmd_root, "offline", - MMS_PN_CLAUSE, &work); - if (arg != NULL) { - if (print_message) - mms_trace(MMS_DEVP, "offline clause"); - /* Get Drive Name */ - item = NULL; - - if ((value = - mms_pn_lookup(arg, NULL, - MMS_PN_STRING, - &item)) == NULL) { - mms_trace(MMS_ERR, "Missing a drive name"); - goto not_found; - - } else { - /* Have the drive name */ - offline = 1; - drive_name = mms_strapp(drive_name, - value->pn_string); - if (print_message) - mms_trace(MMS_DEVP, " %s", - value->pn_string); - } - - } else { - /* Didn't find a offline clause */ - if (print_message) - mms_trace(MMS_DEVP, "Didn't find a offline clause"); - } - - if (online && offline) { - /* Shouldn't ever get here */ - mms_trace(MMS_ERR, "Cannot have both an " - "online and offline clause"); - goto not_found; - } - - /* Check if drive exists */ - if (mm_db_exec(HERE, db, - "select \"DriveName\" " - "from \"DRIVE\" where " - "\"DriveName\" = '%s';", - drive_name) != MM_DB_DATA) { - goto db_error; - } else { - if (PQntuples(db->mm_db_results) != 1) { - /* No drive exists */ - mms_trace(MMS_ERR, "Drive does not exist"); - /* ECLASS_EXIST, EDRIVENOEXIST */ - mm_response_error(cmd, - ECLASS_EXIST, - EDRIVENOEXIST, - MM_5063_MSG, - NULL); - /* Create new error codes */ - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - mm_clear_db(&db->mm_db_results); - goto end; - } - } - mm_clear_db(&db->mm_db_results); - - /* Check Priv, drive group ownership */ - - - if (online) { - /* Do online specific checks */ - /* Is drive already online? */ - if (mm_db_exec(HERE, db, - "select \"DriveName\" " - "from \"DRIVE\" where " - "\"DriveName\" = '%s'" - " and \"DriveOnline\" = 'true';", - drive_name) != MM_DB_DATA) { - goto db_error; - } else { - if (PQntuples(db->mm_db_results) == 1) { - mms_trace(MMS_ERR, "Drive already on line"); - /* Drive Already online */ - /* ECLASS_PREMPRIV, EDRIVEONLINE */ - - mm_response_error(cmd, - ECLASS_PERMPRIV, - "EDRIVEALREADYONLINE", - MM_5064_MSG, - "drive", - drive_name, - NULL); - /* Create new error codes */ - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - - } - } - mm_clear_db(&db->mm_db_results); - /* Do online */ - /* clear DriveDisabled DriveBroken */ - /* don't clear DriveLibraryAccess or DriveNeedsCleaning */ - cmd_buf = mms_strapp(cmd_buf, - "update \"DRIVE\" set " - "\"DriveOnline\" = 't', " - "\"DriveDisabled\" = 'false', " - "\"DriveBroken\" = 'f' where " - "\"DriveName\" = '%s';", - drive_name); - } else if (offline) { - /* Do offline specific checks */ - - /* Check if drive has a tape currently mounted */ - if (mm_db_exec(HERE, db, - " select \"DriveName\" " - "from \"DRIVE\" where " - "\"CartridgePCL\" ISNULL " - "and \"DriveStateHard\" " - "= 'unloaded' and " - "\"DriveName\" = '%s';", - drive_name) != MM_DB_DATA) { - goto db_error; - } else { - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, "Drive has tape loaded"); - /* Drive Already online */ - mm_response_error(cmd, - ECLASS_INTERNAL, - "EMNTCARTPRES", - MM_5065_MSG, - "drive", - drive_name, - NULL); - /* Create new error codes */ - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - - } - } - mm_clear_db(&db->mm_db_results); - if (mm_db_exec(HERE, db, - "select \"DriveName\" " - "from \"DRIVE\" where " - "\"DriveName\" = '%s'" - " and \"DriveOnline\" = 'false';", - drive_name) != MM_DB_DATA) { - goto db_error; - } else { - if (PQntuples(db->mm_db_results) == 1) { - mms_trace(MMS_ERR, "Drive already off line"); - /* Drive Already offline */ - /* ECLASS_PREMPRIV, EDRIVEOFFLINE */ - mm_response_error(cmd, - ECLASS_PERMPRIV, - "EDRIVEALREADYOFFLINE", - MM_5066_MSG, - "drive", - drive_name, - NULL); - /* Create new error codes */ - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - - } - } - mm_clear_db(&db->mm_db_results); - /* - * Don't allow offline if drive - * has cartridge mounted? - */ - - /* Do offline */ - cmd_buf = mms_strapp(cmd_buf, - "update \"DRIVE\" set \"DriveOnline\" = " - "'false' where \"DRIVE\".\"DriveName\" = '%s';", - drive_name); - } else { - /* Shouldn't ever get here */ - mms_trace(MMS_ERR, "Missing an online or offline clause"); - goto not_found; - } - - /* Send cmd_buf to data base */ - if (print_message) - mms_trace(MMS_DEVP, "\n%s\n", - cmd_buf); - - /* Add events */ - if (online) { - if (mm_notify_add_driveonline(mm_wka, cmd, drive_name)) { - mms_trace(MMS_ERR, - "mm_drvonline_cmd_func: " - "error adding drive online event"); - } - } - - if (offline) { - if (mm_notify_add_driveoffline(mm_wka, cmd, drive_name)) { - mms_trace(MMS_ERR, - "mm_drvonline_cmd_func: " - "error adding drive offline event"); - } - } - - - if (mm_db_exec(HERE, db, cmd_buf) != MM_DB_OK) { - goto db_error; - } - /* Add any activate enables for DM's */ - /* These will run as independent commands */ - dm_wka = NULL; - mms_list_foreach(&mm_wka->mm_data->mm_wka_list, dm_wka) { - if (strcmp(dm_wka->wka_conn.cci_client, - drive_name) == 0) { - if (online) { - /* Found the wka of dm for this drive */ - if (mm_drive_dm_activate_enable(dm_wka) - == NULL) { - mms_trace(MMS_DEVP, - "Failed to add activate enable"); - } else { - mms_trace(MMS_DEVP, - "added activate enable for %s %s", - dm_wka->wka_conn.cci_instance, - dm_wka->wka_conn.cci_client); - } - } else { - if (mm_drive_dm_activate_disable(dm_wka)) { - mms_trace(MMS_DEVP, - "Failed to add activate enable"); - } else { - mms_trace(MMS_DEVP, - "added activate enable for %s %s", - dm_wka->wka_conn.cci_instance, - dm_wka->wka_conn.cci_client); - } - - } - } - - } - /* Send Success */ - - mm_path_match_report(cmd, db); - mm_send_response(mm_wka->mm_wka_conn, cmd); - rc = MM_CMD_DONE; - goto end; - -db_error: - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; -end: - mm_clear_db(&db->mm_db_results); - if (cmd_buf) - free(cmd_buf); - if (drive_name) - free(drive_name); - return (rc); -} -#define NOTIFY_NEW "INSERT" -#define NOTIFY_DELETE "DELETE" -#define NOTIFY_CHANGE "UPDATE" -#define NOTIFY_NEW_OBJ "NEW" -#define NOTIFY_DELETE_OBJ "OLD" - -int -mm_build_event_rule(mm_command_t *cmd, mm_db_t *db, uuid_text_t *notify_uuid, - char *action, mms_par_node_t *data_clause) { - char *buf = NULL; - char *rule_buf = NULL; - mm_path_t *path = NULL; - char *joined[100]; - int joined_count = 0; - int skip = 0; - int wrote_one = 0; - int y; - int j; - int k; - int x; - int l; - int p; - - char *source_buf; - char *dest_buf; - - int print_message = 0; - - mm_pkey_t *source_pkey; - - char *sql_action; - char *sql_object; - - mms_par_node_t *data_string = NULL; - mms_par_node_t *work = NULL; - - mms_trace(MMS_DEBUG, "mm_build_event_rule"); - - /* map action string to the correct sql thingys */ - if (strcmp(action, "add") == 0) { - sql_action = NOTIFY_NEW; - sql_object = NOTIFY_NEW_OBJ; - } - if (strcmp(action, "change") == 0) { - sql_action = NOTIFY_CHANGE; - sql_object = NOTIFY_NEW_OBJ; - } - if (strcmp(action, "delete") == 0) { - sql_action = NOTIFY_DELETE; - sql_object = NOTIFY_DELETE_OBJ; - } - - - for (y = 0; y < 100; y ++) { - joined[y] = NULL; - } - - source_buf = - (char *)mm_return_char(&cmd->cmd_source_list, 0); - /* sohuld be only 1 source */ - buf = mms_strapp(buf, - "from \"%s\" ", - source_buf); - joined_count = 0; - joined[0] = NULL; - joined[0] = mms_strapp(joined[0], source_buf); - - joined_count ++; - for (j = 0; j < cmd->cmd_dest_num; j ++) { - dest_buf = - (char *)mm_return_char(&cmd->cmd_dest_list, j); - - if (print_message) { - mms_trace(MMS_DEVP, " 1) Dest %d -> %s", - j, dest_buf); - - mms_trace(MMS_DEVP, "mm_get_path(%s, %s)", - dest_buf, - source_buf); - } - - - if ((path = mm_get_path(dest_buf, - source_buf)) == NULL) { - mms_trace(MMS_DEVP, "Path is NULL, %s to %s", - dest_buf, - source_buf); - - } else { - for (k = 0; k < path->mm_node_num; k++) { - skip = 0; - for (x = 0; x < joined_count; x++) { - - if (strcmp(joined[x], - path->mm_node[k]->mm_obj) == 0) { - /* same so skip */ - skip = 1; - } - } - if (!skip) { - buf = mms_strapp(buf, - "\ncross join \"%s\" ", - path->mm_node[k]->mm_obj); - - joined[joined_count] = NULL; - joined[joined_count] = - mms_strapp(joined[joined_count], - path->mm_node[k]->mm_obj); - joined_count ++; - } - } - } - - } - - - for (j = 0; j < cmd->cmd_dest_num; j ++) { - /* j cmd_dest_num */ - if (j == 0) { - buf = mms_strapp(buf, - "\nwhere \n(\n"); - } - dest_buf = - (char *)mm_return_char(&cmd->cmd_dest_list, j); - if (print_message) { - mms_trace(MMS_DEVP, " 2) Dest %d -> %s", - j, dest_buf); - mms_trace(MMS_DEVP, "mm_get_path(%s, %s)", - dest_buf, - source_buf); - } - - if ((path = mm_get_path(dest_buf, - source_buf)) == NULL) { - - if (strcmp(dest_buf, - source_buf) == 0) { - /* same object */ - buf = mms_strapp(buf, "(true)\n"); - wrote_one = 1; - } else { - /* no path between */ - buf = mms_strapp(buf, "(false)\n"); - wrote_one = 1; - } - - } else { - - - for (k = path->mm_node_num - 1; k >= 0; k--) { - - /* node[%d] has %d edges, k, */ - /* path->mm_node[k]->mm_edge_num */ - for (l = 0; - l < path->mm_node[k]->mm_edge_num; - l++) { - /* - * if (path->mm_node[k]-> - * mm_edge[l]->mm_ref_att != NULL) { - * - * } - */ - - /* add this edge constraint */ - wrote_one = 1; - if (k == path->mm_node_num - 1) { - buf = mms_strapp(buf, - "(\"%s\".", - source_buf); - } else { - buf = mms_strapp(buf, - "(\"%s\".", - path->mm_node - [k+1]->mm_obj); - } - if (path->mm_node[k]-> - mm_edge[l]->mm_ref_att == NULL) { - buf = mms_strapp(buf, - "\"%s\" = ", - path->mm_node[k]-> - mm_edge[l]->mm_att); - } else { - buf = mms_strapp(buf, - "\"%s\" = ", - path->mm_node[k]-> - mm_edge[l]->mm_ref_att); - } - buf = mms_strapp(buf, - "\"%s\".\"%s\")\n", - path->mm_node[k]->mm_obj, - path->mm_node[k]-> - mm_edge[l]->mm_att); - - if (l+1 < path->mm_node[k]-> - mm_edge_num) { - buf = mms_strapp(buf, "and\n"); - } - - } - - - if (k - 1 >= 0) { - buf = mms_strapp(buf, "and\n"); - } - - } - - } - if (j + 1 < cmd->cmd_dest_num) { - buf = mms_strapp(buf, "and\n"); - } - - - - if (j + 1 == cmd->cmd_dest_num) { - /* Add all constraints here */ - - for (p = 0; - p < cmd->cmd_const_num; - p ++) { - if (p == 0) { - if (wrote_one) - buf = mms_strapp(buf, - "and\n(\n"); - } - buf = mms_strapp(buf, - (char *) - mm_return_char(&cmd-> - cmd_const_list, p)); - if (p+1 < cmd->cmd_const_num) { - buf = - mms_strapp(buf, - "and\n"); - } - if (p + 1 == - cmd->cmd_const_num) { - /* parenn for constraints */ - buf = mms_strapp(buf, ")\n"); - } - } - /* paren for where ( */ - if (wrote_one) { - buf = mms_strapp(buf, - ")\n"); - } else { - buf = mms_strapp(buf, - "\n"); - } - } - - } - - for (y = 0; y < joined_count; y ++) { - free(joined[y]); - joined[y] = NULL; - } - - /* now build the ru1le buf, we use buf for each pkey in source */ - rule_buf = mms_strapp(rule_buf, - "CREATE RULE \"%s\" AS ON %s TO \"%s\" " - "WHERE ( ", notify_uuid, sql_action, source_buf); - - source_pkey = mm_get_pkey(source_buf); - for (j = 0; j < source_pkey->mm_att_num; j ++) { - /* p_key->mm_att[j] */ - if (j != 0) { - rule_buf = mms_strapp(rule_buf, "and\n"); - - } - rule_buf = mms_strapp(rule_buf, - "(%s.\"%s\" in " - "(select distinct \"%s\".\"%s\" %s))", - sql_object, - source_pkey->mm_att[j], - source_buf, - source_pkey->mm_att[j], - buf); - - } - if (data_clause == NULL) { - rule_buf = mms_strapp(rule_buf, - ") DO INSERT INTO \"EVENTRULES\" VALUES ('%s', '%s');", - notify_uuid, source_buf); - } else { - rule_buf = mms_strapp(rule_buf, - ") DO INSERT INTO \"EVENTRULES\" VALUES ('%s', '%s'", - notify_uuid, source_buf); - while ((data_string = mms_pn_lookup(data_clause, - NULL, MMS_PN_STRING, &work)) != NULL) { - /* Determine if data needs to be cast */ - if (mm_db_exec(HERE, db, - "select \"%s\"" - " from \"%s\" limit 1;", - data_string->pn_string, - source_buf) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "error checking type " - "of data attribute"); - mm_sql_db_err_rsp_new(cmd, db); - free(buf); - free(rule_buf); - return (1); - } - if (PQftype(db->mm_db_results, 0) == - db->mm_db_cfg->mm_db_bool_oid) { - /* column is a bool */ - rule_buf = mms_strapp(rule_buf, - ", bool_to_text(%s.\"%s\")", - sql_object, - data_string->pn_string); - } else { - /* Column is not a bool */ - /* int, timestamp etc work w/o cast */ - rule_buf = mms_strapp(rule_buf, - ", %s.\"%s\"", - sql_object, - data_string->pn_string); - } - mm_clear_db(&db->mm_db_results); - } - rule_buf = mms_strapp(rule_buf, ");"); - } - - - if (mm_db_exec(HERE, db, rule_buf) != MM_DB_OK) { - mms_trace(MMS_ERR, "Error adding rule"); - mm_sql_db_err_rsp_new(cmd, db); - free(buf); - free(rule_buf); - return (1); - } - - - /* Free char buf */ - free(buf); - free(rule_buf); - return (0); - -} - -int -mm_notify_chg_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - cci_t *conn = &mm_wka->wka_conn; - char *db_buf = NULL; - - mms_par_node_t *cmd_root; - - char *object = NULL; - char *tag = NULL; - - - - /* Receive clause */ - uuid_text_t notify_uuid; - - mms_par_node_t *receive_work = NULL; - mms_par_node_t *receive_node = NULL; - mms_par_node_t *receive_clause = NULL; - mms_par_node_t *receive_to_clause = NULL; - mms_par_node_t *receive_from_clause = NULL; - mms_par_node_t *receive_string = NULL; - - mms_par_node_t *data_clause = NULL; - mms_par_node_t *data_string = NULL; - int data_count = 0; - int i; - - char *action = NULL; - char *scope = NULL; - - mms_par_node_t *work; - char *attr_buf; - - /* Cancel clause */ - mms_par_node_t *cancel_work = NULL; - mms_par_node_t *cancel_node = NULL; - mms_par_node_t *cancel_clause = NULL; - mms_par_node_t *cancel_string = NULL; - PGresult *notifyid_results; - - - - mms_trace(MMS_DEBUG, "mm_notify_chg_cmd_func"); - /* Parse cmd */ - /* Check to see if this is a new or old format notfiy cmd */ - /* every new format notify cmd has either a tag or object clause */ - - if ((receive_clause = mms_pn_lookup(cmd->cmd_root, "object", - MMS_PN_CLAUSE, 0)) == NULL) { - /* check for tag clause */ - if ((receive_clause = mms_pn_lookup(cmd->cmd_root, "tag", - MMS_PN_CLAUSE, 0)) == NULL) { - mms_trace(MMS_DEVP, "No tag/object clause found," - " Try processing as old notify cmd"); - return (mm_notify_chg_cmd_func_old(mm_wka, cmd)); - } - } - - /* Recieve clause */ - receive_work = NULL; - while ((receive_node = mms_pn_lookup(cmd->cmd_root, "receive", - MMS_PN_CLAUSE, &receive_work)) != NULL) { - if (db_buf) - free(db_buf); - db_buf = NULL; - object = NULL; - tag = NULL; - action = NULL; - mm_clear_source(cmd); - mm_clear_dest(cmd); - mm_clear_const(cmd); - mms_trace(MMS_DEVP, "receive clause"); - - /* Get object */ - if ((receive_clause = mms_pn_lookup(receive_node, "object", - MMS_PN_CLAUSE, 0)) == NULL) { - mms_trace(MMS_ERR, "Receive clause missing" - " object clause"); - mm_response_error(cmd, - ECLASS_LANGUAGE, - "ECLAUSENEEDSARG", - MM_5067_MSG, - "text", - "reveive clause missing" - " object clause", - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - receive_string = mms_pn_lookup(receive_clause, - NULL, MMS_PN_OBJ, 0); - if (receive_string == NULL) { - mms_trace(MMS_ERR, "Receive clause missing" - " object string"); - mm_response_error(cmd, - ECLASS_LANGUAGE, - "ECLAUSENEEDSARG", - MM_5067_MSG, - "text", - "reveive clause missing" - " object string", - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - object = receive_string->pn_string; - - receive_string = NULL; - mms_trace(MMS_DEVP, - "object -> %s", object); - if (mm_add_char(object, - &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_notify_chg_cmd_func: " - "out of mem creating source list"); - mm_system_error(cmd, - "out of mem creating source list"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - cmd->cmd_source_num = 1; - if (mm_add_char(object, - &cmd->cmd_dest_list)) { - mms_trace(MMS_ERR, - "mm_notify_chg_cmd_func: " - "out of mem creating dest list"); - mm_system_error(cmd, - "out of mem creating dest list"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - cmd->cmd_dest_num = 1; - cmd->cmd_const_num = 0; - /* Add the constrants in the attribute clause */ - work = NULL; - while ((receive_string = mms_pn_lookup(receive_clause, - NULL, MMS_PN_STRING, &work)) != NULL) { - /* Check that this is actally an attribute */ - if (mm_db_exec(HERE, db, - "select \"%s\" from " - "\"%s\" limit 1;", - receive_string->pn_string, - object) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "attribute %s in object clause " - "is not in object %s", - receive_string->pn_string, - object); - mm_system_error(cmd, - "attribute %s in object clause " - "is not in object %s", - receive_string->pn_string, - object); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - mm_clear_db(&db->mm_db_results); - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - - attr_buf = NULL; - attr_buf = mms_strapp(attr_buf, - "(\"%s\".\"%s\" != NEW.\"%s\")", - object, receive_string->pn_string, - receive_string->pn_string); - if (mm_add_char(attr_buf, &cmd->cmd_const_list)) { - mms_trace(MMS_ERR, - "mm_notify_chg_cmd_func: " - "out of mem creating const list"); - mm_system_error(cmd, - "out of mem creating const list"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - cmd->cmd_const_num ++; - free(attr_buf); - receive_string = NULL; - } - receive_clause = NULL; - mms_trace(MMS_DEVP, - "const list after additions, %d", - cmd->cmd_const_num); - mm_print_char_list(&cmd->cmd_const_list); - - /* Get tag */ - if ((receive_clause = mms_pn_lookup(receive_node, "tag", - MMS_PN_CLAUSE, 0)) == NULL) { - mms_trace(MMS_ERR, "Receive clause missing" - " tag clause"); - mm_response_error(cmd, - ECLASS_LANGUAGE, - "ECLAUSENEEDSARG", - MM_5067_MSG, - "text", - "reveive clause missing" - " tag clause", - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - receive_string = mms_pn_lookup(receive_clause, - NULL, MMS_PN_STRING, 0); - if (receive_string == NULL) { - mms_trace(MMS_ERR, "Receive clause missing" - " tag string"); - mm_response_error(cmd, - ECLASS_LANGUAGE, - "ECLAUSENEEDSARG", - MM_5067_MSG, - "text", - "reveive clause missing" - " tag string", - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - tag = receive_string->pn_string; - receive_clause = NULL; - receive_string = NULL; - - /* Confirm tag does not exist for this client */ - mms_trace(MMS_DEVP, - "tag -> %s", tag); - if (mm_db_exec(HERE, db, - "select \"NotifyID\" from " - "\"NOTIFYRULES\" where \"ConnectionID\" = " - "'%s' and " - "\"NotifyTag\" = '%s';", - conn->cci_uuid, - tag) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) > 0) { - mms_trace(MMS_ERR, - "Tag %s already in use", - tag); - mm_system_error(cmd, - "Tag %s already in use", - tag); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - mm_clear_db(&db->mm_db_results); - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - - /* Get action */ - if ((receive_clause = mms_pn_lookup(receive_node, "action", - MMS_PN_CLAUSE, 0)) == NULL) { - mms_trace(MMS_ERR, "Receive clause missing" - " action clause"); - mm_response_error(cmd, - ECLASS_LANGUAGE, - "ECLAUSENEEDSARG", - MM_5067_MSG, - "text", - "reveive clause missing" - " action clause", - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - receive_string = mms_pn_lookup(receive_clause, - NULL, MMS_PN_KEYWORD, 0); - if (receive_string == NULL) { - mms_trace(MMS_ERR, "Receive clause missing" - " action string"); - mm_response_error(cmd, - ECLASS_LANGUAGE, - "ECLAUSENEEDSARG", - MM_5067_MSG, - "text", - "reveive clause missing" - " action string", - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - action = receive_string->pn_string; - receive_clause = NULL; - receive_string = NULL; - mms_trace(MMS_DEVP, - "action -> %s", action); - /* Match clause */ - /* If this action is add or delete */ - /* Look up match in receive */ - /* if this is change need to look for to/from */ - if (strcmp(action, "change") == 0) { - /* set cmd->cmd_notify_to = 1 */ - /* before calling add_const */ - /* reset to 0 after */ - /* Get to clause and add constrants to const list */ - receive_to_clause = mms_pn_lookup(receive_node, "to", - MMS_PN_CLAUSE, 0); - if (receive_to_clause != NULL) { - receive_clause = - mms_pn_lookup(receive_to_clause, - "match", - MMS_PN_CLAUSE, 0); - cmd_root = cmd->cmd_root; - cmd->cmd_root = receive_clause; - cmd->cmd_notify_to = 1; - (void) mm_get_const(mm_wka, cmd); - cmd->cmd_root = cmd_root; - cmd->cmd_notify_to = 0; - } else { - mms_trace(MMS_DEVP, - "didn't see a to clause"); - } - receive_clause = NULL; - - /* set receive clause to match inside from */ - receive_clause = - mms_pn_lookup_arg(receive_node, "match", - MMS_PN_CLAUSE, 0); - if (receive_from_clause == NULL) { - mms_trace(MMS_ERR, - "found from clause but " - "could not find match"); - } else { - mms_trace(MMS_DEVP, - "didn't see a match clause"); - } - } else { - receive_clause = mms_pn_lookup(receive_node, "match", - MMS_PN_CLAUSE, 0); - } - if (receive_clause != NULL) { - scope = mms_pn_build_cmd_text(receive_clause); - if (scope == NULL) { - mms_trace(MMS_ERR, - "Unable build match clause " - "from receive clause"); - mm_system_error(cmd, - "Unable build match clause " - "from receive clause"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - /* Get notifyID */ - mm_get_uuid(notify_uuid); - /* insert this into notify */ - db_buf = mms_strapp(db_buf, - "insert into \"NOTIFYRULES\" (\"ConnectionID\"," - "\"NotifyTag\",\"NotifyObject\"," - "\"NotifyAction\",\"NotifyScope\"," - "\"NotifyID\")" - "VALUES('%s', '%s'," - "'%s', '%s', $$%s$$, '%s');", - conn->cci_uuid, tag, object, - action, scope, notify_uuid); - cmd_root = cmd->cmd_root; - cmd->cmd_root = receive_clause; - (void) mm_get_dest(mm_wka, cmd); - (void) mm_get_const(mm_wka, cmd); - cmd->cmd_root = cmd_root; - - } else { - /* Get notifyID */ - mm_get_uuid(notify_uuid); - /* insert this into notify */ - db_buf = mms_strapp(db_buf, - "insert into \"NOTIFYRULES\" (\"ConnectionID\"," - "\"NotifyTag\",\"NotifyObject\"," - "\"NotifyAction\", \"NotifyID\")" - "VALUES('%s', '%s'," - "'%s', '%s', '%s');", - conn->cci_uuid, tag, object, action, notify_uuid); - } - if (mm_db_exec(HERE, db, db_buf) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (cmd->wka_ptr->wka_privilege == MM_PRIV_STANDARD) { - mms_trace(MMS_DEVP, - "add non-priv constraints"); - /* Need to check source list and */ - /* add constraints as necessary */ - if (mm_non_priv_const(mm_wka, cmd)) { - mms_trace(MMS_ERR, - "error adding non-priv " - "client constraints"); - } - mms_trace(MMS_DEVP, - "const list after additions, %d", - cmd->cmd_const_num); - mm_print_char_list(&cmd->cmd_const_list); - } else { - mms_trace(MMS_DEVP, - "skip constraints forpriv client"); - } - - /* Data clause */ - if ((data_clause = mms_pn_lookup(receive_node, "data", - MMS_PN_CLAUSE, 0)) == NULL) { - mms_trace(MMS_DEVP, "No data clause found"); - } else { - /* Verify these attributes */ - mms_trace(MMS_DEVP, "Found a data clause"); - work = NULL; - while ((data_string = mms_pn_lookup(data_clause, - NULL, MMS_PN_STRING, &work)) != NULL) { - data_count ++; - if (data_count > 5) { - /* 6th data string */ - /* only 5 allowed */ - mms_trace(MMS_ERR, - "only 5 attributes are allowed in" - "a data clause"); - mm_system_error(cmd, - "only 5 attributes are allowed in" - "a data clause"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - - } - /* Verify that this data string is */ - /* an attribute of object */ - if (mm_db_exec(HERE, db, - "select \"%s\" from " - "\"%s\" limit 1;", - data_string->pn_string, - object) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "attribute %s in data clause" - " is not in object %s", - data_string->pn_string, - object); - mm_system_error(cmd, - "attribute %s in data clause" - " is not in object %s", - data_string->pn_string, - object); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - mm_clear_db(&db->mm_db_results); - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - } - } - - /* create rule */ - /* insert rule into rule table */ - /* write new func based on mm_sql_report_func( */ - /* to generate the path matching part of the event rule */ - if (mm_build_event_rule(cmd, db, ¬ify_uuid, - action, data_clause)) { - mms_trace(MMS_ERR, - "Unable build event rule from receive clause"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - if (db_buf) - free(db_buf); - db_buf = NULL; - - /* end of recieve clause */ - } - - - /* Cancel clause */ - cancel_work = NULL; - while ((cancel_node = mms_pn_lookup(cmd->cmd_root, "cancel", - MMS_PN_CLAUSE, &cancel_work)) != NULL) { - object = NULL; - tag = NULL; - if (db_buf) - free(db_buf); - db_buf = NULL; - mms_trace(MMS_DEVP, "cancel clause"); - cancel_string = NULL; - /* Get object */ - if ((cancel_clause = mms_pn_lookup(cancel_node, "object", - MMS_PN_CLAUSE, 0)) != NULL) { - cancel_string = mms_pn_lookup(cancel_clause, - NULL, MMS_PN_OBJ, 0); - if (cancel_string == NULL) { - mms_trace(MMS_ERR, "Cancel clause missing" - " object string"); - mm_response_error(cmd, - ECLASS_LANGUAGE, - "ECLAUSENEEDSARG", - MM_5067_MSG, - "text", - "reveive clause missing" - " object string", - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - object = cancel_string->pn_string; - cancel_clause = NULL; - cancel_string = NULL; - mms_trace(MMS_DEVP, - "drop all event rules for obj %s, conn %s", - object, conn->cci_uuid); - if (mm_db_exec(HERE, db, - "select \"NotifyID\" from \"NOTIFYRULES\" where " - "\"ConnectionID\" = '%s' " - "and \"NotifyObject\" = '%s';", - conn->cci_uuid, object) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - notifyid_results = db->mm_db_results; - for (i = 0; i < PQntuples(notifyid_results); i ++) { - /* Drop event rules for these id's */ - if (mm_db_exec(HERE, db, - "drop rule \"%s\" on \"%s\";", - PQgetvalue(notifyid_results, i, 0), - object) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - mm_clear_db(¬ifyid_results); - return (MM_CMD_ERROR); - } - /* Delete rules for this tag from NOTIFYRULES */ - if (mm_db_exec(HERE, db, - "delete " - " from \"NOTIFYRULES\" where " - "\"ConnectionID\" = '%s' and " - "\"NotifyObject\" = '%s';", - conn->cci_uuid, object) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - /* Go to next cancel clause */ - mm_clear_db(¬ifyid_results); - continue; - } else { - mms_trace(MMS_DEVP, "cancel clause missing" - " object clause"); - } - - /* Get tag */ - if ((cancel_clause = mms_pn_lookup(cancel_node, "tag", - MMS_PN_CLAUSE, 0)) != NULL) { - cancel_string = mms_pn_lookup(cancel_clause, - NULL, MMS_PN_STRING, 0); - if (cancel_string == NULL) { - mms_trace(MMS_ERR, "Cancel clause missing" - " tag string"); - mm_response_error(cmd, - ECLASS_LANGUAGE, - "ECLAUSENEEDSARG", - MM_5067_MSG, - "text", - "reveive clause missing" - " tag string", - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - tag = cancel_string->pn_string; - cancel_clause = NULL; - cancel_string = NULL; - mms_trace(MMS_DEVP, - "drop all event rules for tag %s, conn %s", - tag, conn->cci_uuid); - if (mm_db_exec(HERE, db, - "select \"NotifyID\",\"NotifyObject\"" - " from \"NOTIFYRULES\" where " - "\"ConnectionID\" = '%s' and \"NotifyTag\" = '%s';", - conn->cci_uuid, tag) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - notifyid_results = db->mm_db_results; - for (i = 0; i < PQntuples(notifyid_results); i ++) { - /* Drop event rules for these id's */ - if (mm_db_exec(HERE, db, - "drop rule \"%s\" on \"%s\";", - PQgetvalue(notifyid_results, i, 0), - PQgetvalue(notifyid_results, i, 1)) != - MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - mm_clear_db(¬ifyid_results); - return (MM_CMD_ERROR); - } - } - mm_clear_db(¬ifyid_results); - /* Delete rules for this tag from NOTIFYRULES */ - if (mm_db_exec(HERE, db, - "delete " - " from \"NOTIFYRULES\" where " - "\"ConnectionID\" = '%s' and \"NotifyTag\" = '%s';", - conn->cci_uuid, tag) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - } else { - /* Missing tag and obj clause */ - /* parser should prevent this situation */ - mms_trace(MMS_ERR, - "cancel clause missing tag/object clause"); - mm_system_error(cmd, - "cancel clause missing tag/object clause"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - - } - - - } - - if (db_buf) - free(db_buf); - db_buf = NULL; - mm_write_success(cmd, NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_DONE); - -} - - -int -mm_notify_chg_cmd_func_old(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - cci_t *conn = &mm_wka->wka_conn; - mms_par_node_t *arg; - - mms_par_node_t *value; - - int print_message = 1; - - int go; - mms_par_node_t *item; - - char *cmd_buf = NULL; - - int wrote_one = 0; - mms_par_node_t *work; - mms_par_node_t *receive_work; - mms_par_node_t *receive_node; - mms_par_node_t *receive_event; - mms_par_node_t *receive_scope; - /* This is the function to process the */ - /* old format notfiy commands */ - - mms_trace(MMS_DEBUG, "mm_notify_chg_cmd_func"); - - cmd_buf = mms_strapp(cmd_buf, - "update \"NOTIFY\" set "); - - /* Recieve clause */ - receive_work = NULL; - while ((receive_node = mms_pn_lookup(cmd->cmd_root, "receive", - MMS_PN_CLAUSE, &receive_work)) != NULL) { - if (print_message) - mms_trace(MMS_DEVP, "receive clause"); - - work = NULL; - if ((receive_event = mms_pn_lookup(receive_node, NULL, - MMS_PN_STRING, &work)) == NULL) { - mms_trace(MMS_ERR, "Receive clause missing event"); - mm_response_error(cmd, - ECLASS_LANGUAGE, - "ECLAUSENEEDSARG", - MM_5067_MSG, - "text", - "reveive clause missing event arg", - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if ((receive_scope = mms_pn_lookup(receive_node, NULL, - MMS_PN_STRING, &work)) == NULL) { - mms_trace(MMS_ERR, "Receive clause missing scope"); - mm_response_error(cmd, - ECLASS_LANGUAGE, - "ECLAUSENEEDSARG", - MM_5067_MSG, - "text", - "reveive clause missing scope arg", - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (wrote_one) - cmd_buf = mms_strapp(cmd_buf, - ","); - cmd_buf = mms_strapp(cmd_buf, - " \"%s\" = '%s'", - receive_event->pn_string, - receive_scope->pn_string); - wrote_one = 1; - mms_trace(MMS_DEVP, - "Receive %s, scope, %s", - receive_event->pn_string, - receive_scope->pn_string); - } - - - /* Cancel clause */ - work = NULL; - arg = mms_pn_lookup(cmd->cmd_root, "cancel", - MMS_PN_CLAUSE, &work); - if (arg != NULL) { - if (print_message) - mms_trace(MMS_DEVP, "cancel clause"); - /* Set each value to 'yes' */ - item = NULL; - go = 1; - while (go) { - if ((value = - mms_pn_lookup(arg, NULL, - MMS_PN_STRING, - &item)) == NULL) { - go = 0; - } else { - if (wrote_one) - cmd_buf = mms_strapp(cmd_buf, - ","); - cmd_buf = mms_strapp(cmd_buf, - " \"%s\" = 'off'", - value->pn_string); - wrote_one = 1; - - if (print_message) - mms_trace(MMS_DEVP, " %s", - value->pn_string); - } - } - } else { - /* Didn't find a cancel clause */ - if (print_message) - mms_trace(MMS_DEVP, "Didn't find a cancel clause"); - } - - /* add where clause */ - if (conn->cci_uuid == NULL) { - if (print_message) - mms_trace(MMS_DEVP, "uuid is NULL"); - } else { - if (print_message) - mms_trace(MMS_DEVP, "uuid is %s", conn->cci_uuid); - } - - cmd_buf = mms_strapp(cmd_buf, " where \"ConnectionID\" = '%s';", - conn->cci_uuid); - - - /* Send cmd_buf to data base */ - if (print_message) - mms_trace(MMS_DEVP, "\n%s\n", - cmd_buf); - - - if (mm_db_exec(HERE, db, cmd_buf) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - /* Send Success */ - - if (cmd_buf) - free(cmd_buf); - - mm_path_match_report(cmd, db); - mm_send_response(mm_wka->mm_wka_conn, cmd); - - return (MM_CMD_DONE); - - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - - if (cmd_buf) - free(cmd_buf); - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); -} - - -int -mm_inject_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *arg; - mms_par_node_t *value; - char *slotgroup = NULL; - int rows; - char *query; - mm_db_t *db = &mm_wka->mm_data->mm_db; - mm_command_t *lmp_inject_cmd; - mm_wka_t *lm_wka; - uuid_text_t new_task; - char *library; - char *lm; - PGresult *lib_results; - char *constraint; - - - mms_trace(MMS_DEVP, "mm inject state %d", cmd->cmd_state); - - if (cmd->cmd_state == 0) { - if (mm_privileged(mm_wka, cmd) == MM_PRIV_STANDARD) { - return (MM_CMD_ERROR); - } - - (void) mm_get_dest(mm_wka, cmd); - (void) mm_get_const(mm_wka, cmd); /* constraints */ - if (mm_add_char("LM", &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_inject_cmd_func: " - "out of mem creating source list"); - mm_system_error(cmd, - "out of mem creating source list"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - cmd->cmd_source_num = 1; - if (mm_add_char("LIBRARY", &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_inject_cmd_func: " - "out of mem creating source list"); - mm_system_error(cmd, - "out of mem creating source list"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - cmd->cmd_source_num = 2; - query = "select distinct " - "\"LM\".\"LibraryName\",\"LM\".\"LMName\" from "; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(query) + 1); - (void) strlcpy(cmd->cmd_buf, query, cmd->cmd_bufsize); - - if (mm_sql_from_where(cmd, db)) { - mms_trace(MMS_ERR, - "mm_inject_cmd_func: " - "db error creating helper functions"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - constraint = "and ((\"LIBRARY\".\"LibraryName\" = " - "\"LM\".\"LibraryName\") and " - "(\"LIBRARY\".\"LibraryOnline\" = 'true'))"; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(constraint) + 1); - strcat(cmd->cmd_buf, constraint); - mm_sql_order(cmd); - mm_sql_number(cmd); - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - lib_results = db->mm_db_results; - rows = PQntuples(lib_results); - if (rows == 0) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_EXIST) + strlen(ENOMATCH) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_EXIST, ENOMATCH); - mm_clear_db(&lib_results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } else if (rows > 1) { - mms_trace(MMS_DEVP, - "user constaints selected more than " - "one library"); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_EXPLICIT) + strlen(ETOOMANY) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_EXPLICIT, ETOOMANY); - mm_clear_db(&lib_results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - library = PQgetvalue(lib_results, 0, 0); - lm = PQgetvalue(lib_results, 0, 1); - - /* find cap */ - if (arg = mms_pn_lookup(cmd->cmd_root, "slotgroup", - MMS_PN_CLAUSE, NULL)) { - MMS_PN_LOOKUP(value, arg, NULL, - MMS_PN_STRING, NULL); - slotgroup = strdup(value->pn_string); - } else if ((slotgroup = mm_library_lm_get_cap(cmd, - library, lm)) == NULL) { - mm_clear_db(&lib_results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mms_trace(MMS_DEVP, "cap %s", slotgroup); - - /* - * Report clause, query before data model changed. - * Actually, this should be about the context of command - * and report what was injected. - */ - mm_path_match_report(cmd, db); - cmd->cmd_report = strdup(cmd->cmd_buf); - - /* - * LMP inject command - */ - mms_trace(MMS_INFO, "Sending Inject to %s", library); - lm_wka = mm_library_lm_wka(cmd->wka_ptr->mm_data, - library, NULL); - if ((lmp_inject_cmd = mm_alloc_cmd(lm_wka)) == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_command_t: %s", - strerror(errno)); - mm_system_error(cmd, - "unable to allocate memory for lmp inject"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - lmp_inject_cmd->cmd_name = strdup("lmp inject"); - lmp_inject_cmd->cmd_func = mm_lmp_inject_cmd_func; - mm_get_uuid(new_task); - lmp_inject_cmd->cmd_textcmd = mms_strnew(LMP_INJECT, new_task, - slotgroup); - lmp_inject_cmd->cmd_root = - mm_text_to_par_node(lmp_inject_cmd->cmd_textcmd, - mms_lmpm_parse); - lmp_inject_cmd->cmd_task = - mm_get_task(lmp_inject_cmd->cmd_root); - mm_add_depend(lmp_inject_cmd, cmd); - /* create task */ - if (mm_new_tm_task(db, cmd, "dispatched") != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_inject_cmd_func: " - "error inserting new task"); - mm_system_error(cmd, - "error inserting new task"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (mm_set_tm_library(db, - cmd->cmd_uuid, library) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_inject_cmd_func: " - "error updating TASKLIBRARY"); - mm_system_error(cmd, - "error updating TASKLIBRARY"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - mm_clear_db(&lib_results); - free(slotgroup); - - cmd->cmd_state = 1; - - pthread_mutex_lock(&mm_wka->mm_data->mm_queue_mutex); - mms_list_insert_tail(&mm_wka->mm_data->mm_cmd_queue, - lmp_inject_cmd); - pthread_mutex_unlock(&mm_wka->mm_data->mm_queue_mutex); - - return (MM_DISPATCH_DEPEND); - - } else if (cmd->cmd_state == 1) { - char *response_message = NULL; - /* remove completed task */ - (void) mm_del_tm_cmd(db, cmd->cmd_uuid); - - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - mms_trace(MMS_DEVP, "lm inject failed"); - response_message = mm_ret_response_msg(cmd); - mm_response_error(cmd, - ECLASS_SUBOP, - ELMDMCOMMUNICATION, - MM_5055_MSG, - "msg_rsp", response_message, - NULL); - free(response_message); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - /* - * Report clause (previously generated). - */ - cmd->cmd_remove = 1; - mm_send_response(mm_wka->mm_wka_conn, cmd); - mms_trace(MMS_INFO, "Injected Cartridge(s) Successfully"); - return (MM_CMD_DONE); - } - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); -} - - -int -mm_eject_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *arg; - mms_par_node_t *value; - int rows; - int row; - int rc; - uuid_text_t new_task; - mms_par_node_t *work; - char *cartid; - char *cartpcl; - char *slottype; - mms_par_node_t *cart; - mms_par_node_t *id; - mm_db_t *db = &mm_wka->mm_data->mm_db; - mm_command_t *lmp_eject_cmd; - eject_cart_t *eject_cart; - PGresult *taskcart_results; - mm_wka_t *lm_wka; - mms_par_node_t *index; - char *query; - - - mms_trace(MMS_DEVP, "mm eject state %d", cmd->cmd_state); - - if (cmd->cmd_state == 0) { - if (mm_privileged(mm_wka, cmd) == MM_PRIV_STANDARD) { - return (MM_CMD_ERROR); - } - - mms_trace(MMS_DEVP, "cartridge eject list"); - if ((cmd->cmd_eject = (cmd_eject_t *)calloc(1, - sizeof (cmd_eject_t))) == NULL) { - MM_ABORT_NO_MEM(); - } - mms_list_create(&cmd->cmd_eject->eject_list, - sizeof (eject_cart_t), - offsetof(eject_cart_t, cart_next)); - - /* get cart(s) by id */ - work = NULL; - for (id = mms_pn_lookup(cmd->cmd_root, "cartid", - MMS_PN_CLAUSE, &work); - id != NULL; - id = mms_pn_lookup(cmd->cmd_root, "cartid", - MMS_PN_CLAUSE, &work)) { - - mms_trace(MMS_DEVP, "get cartridge by id"); - - MMS_PN_LOOKUP(value, id, NULL, MMS_PN_STRING, NULL); - cartid = value->pn_string; - - mms_trace(MMS_DEVP, "cartid %s", cartid); - - if (mm_db_exec(HERE, db, "SELECT \"CartridgePCL\"," - "\"SlotTypeName\"," - "\"LibraryName\"," - "\"SlotName\" " - "FROM \"SLOT\" " - "WHERE \"CartridgeID\" = '%s';", - cartid) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_DEVP, - "cartid %s not found", cartid); - mm_response_error(cmd, - ECLASS_EXPLICIT, - ENOSUCHCART, - MM_5004_MSG, "cartid", cartid, - NULL); - mm_clear_db(&db->mm_db_results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - /* add cartridge to list of ejectable cartridges */ - if ((eject_cart = (eject_cart_t *)calloc(1, - sizeof (eject_cart_t))) == NULL) { - MM_ABORT_NO_MEM(); - } - eject_cart->cart_cartid = strdup(cartid); - eject_cart->cart_cartpcl = - strdup(PQgetvalue(db->mm_db_results, 0, 0)); - eject_cart->cart_slottype = - strdup(PQgetvalue(db->mm_db_results, 0, 1)); - eject_cart->cart_library = - strdup(PQgetvalue(db->mm_db_results, 0, 2)); - eject_cart->cart_slotname = - strdup(PQgetvalue(db->mm_db_results, 0, 3)); - mm_clear_db(&db->mm_db_results); - mms_list_insert_tail(&cmd->cmd_eject->eject_list, - eject_cart); - } - - /* get cart(s) by pcl and slottype */ - work = NULL; - for (cart = mms_pn_lookup(cmd->cmd_root, "cart", - MMS_PN_CLAUSE, &work); - cart != NULL; - cart = mms_pn_lookup(cmd->cmd_root, "cart", - MMS_PN_CLAUSE, &work)) { - - mms_trace(MMS_DEVP, - "get cartridge by pcl and slottype"); - - index = 0; - MMS_PN_LOOKUP(value, cart, NULL, - MMS_PN_STRING, &index); - cartpcl = value->pn_string; - - MMS_PN_LOOKUP(value, cart, NULL, - MMS_PN_STRING, &index); - slottype = value->pn_string; - - mms_trace(MMS_DEVP, "cartpcl %s, slottype %s", - cartpcl, slottype); - - if (mm_db_exec(HERE, db, "SELECT \"CartridgeID\"," - "\"LibraryName\"," - "\"SlotName\" " - "FROM \"SLOT\" " - "WHERE (\"CartridgePCL\" = '%s') " - "AND (\"SlotTypeName\" = '%s');", - cartpcl, slottype) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_DEVP, "cartpcl %s slottype %s " - "not found", cartpcl, slottype); - mm_response_error(cmd, - ECLASS_EXPLICIT, - ENOSUCHPCL, - MM_5005_MSG, "cartpcl", cartpcl, - NULL); - mm_clear_db(&db->mm_db_results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if ((eject_cart = (eject_cart_t *)calloc(1, - sizeof (eject_cart_t))) == NULL) { - MM_ABORT_NO_MEM(); - } - eject_cart->cart_cartid = - strdup(PQgetvalue(db->mm_db_results, 0, 0)); - eject_cart->cart_cartpcl = strdup(cartpcl); - eject_cart->cart_slottype = strdup(slottype); - eject_cart->cart_library = - strdup(PQgetvalue(db->mm_db_results, 0, 1)); - eject_cart->cart_slotname = - strdup(PQgetvalue(db->mm_db_results, 0, 2)); - mm_clear_db(&db->mm_db_results); - mms_list_insert_tail(&cmd->cmd_eject->eject_list, - eject_cart); - } - - /* get cart(s) by match */ - if (mms_pn_lookup(cmd->cmd_root, "match", - MMS_PN_CLAUSE, NULL)) { - mms_trace(MMS_DEVP, "find carts using match"); - (void) mm_get_dest(mm_wka, cmd); - (void) mm_get_const(mm_wka, cmd); /* constraints */ - if (mm_add_char("CARTRIDGE", &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_eject_cmd_func: " - "out of mem creating source list"); - mm_system_error(cmd, - "out of mem creating source list"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - cmd->cmd_source_num = 1; - if (mm_add_char("SLOT", &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_eject_cmd_func: " - "out of mem creating source list"); - mm_system_error(cmd, - "out of mem creating source list"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - cmd->cmd_source_num = 2; - query = "select distinct " - "\"CARTRIDGE\".\"CartridgeID\"," - "\"CARTRIDGE\".\"CartridgePCL\"," - "\"SLOT\".\"SlotTypeName\"," - "\"CARTRIDGE\".\"LibraryName\"," - "\"SLOT\".\"SlotName\" " - "from "; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(query) + 1); - (void) strlcpy(cmd->cmd_buf, query, cmd->cmd_bufsize); - if (mm_sql_from_where(cmd, db)) { - mms_trace(MMS_ERR, - "mm_eject_cmd_func: " - "db error creating helper functions"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mm_sql_order(cmd); - mm_sql_number(cmd); - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if ((rows = PQntuples(db->mm_db_results)) == 0) { - mms_trace(MMS_DEVP, "no match"); - mm_response_error(cmd, - ECLASS_EXPLICIT, - ENOMATCH, - MM_5068_MSG, - NULL); - mm_clear_db(&db->mm_db_results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mms_trace(MMS_DEVP, "%d cartridge matches", - rows); - for (row = 0; row < rows; row++) { - - if ((eject_cart = (eject_cart_t *)calloc(1, - sizeof (eject_cart_t))) == NULL) { - MM_ABORT_NO_MEM(); - } - mms_trace(MMS_DEVP, " cart, %s", - PQgetvalue(db->mm_db_results, row, 0)); - eject_cart->cart_cartid = - strdup(PQgetvalue(db->mm_db_results, - row, 0)); - eject_cart->cart_cartpcl = - strdup(PQgetvalue(db->mm_db_results, - row, 1)); - eject_cart->cart_slottype = - strdup(PQgetvalue(db->mm_db_results, - row, 2)); - eject_cart->cart_library = - strdup(PQgetvalue(db->mm_db_results, - row, 3)); - eject_cart->cart_slotname = - strdup(PQgetvalue(db->mm_db_results, - row, 4)); - mms_list_insert_tail(&cmd-> - cmd_eject->eject_list, - eject_cart); - } - mm_clear_db(&db->mm_db_results); - } - - /* check for at least one cart */ - if (mms_list_head(&cmd->cmd_eject->eject_list) == NULL) { - mms_trace(MMS_DEVP, "no carts found to eject"); - mm_response_error(cmd, - ECLASS_EXPLICIT, - ENOMATCH, - MM_5068_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - /* check cartridge state */ - mms_list_foreach(&cmd->cmd_eject->eject_list, eject_cart) { - mms_trace(MMS_DEVP, - "check cartridge state for %s", - eject_cart->cart_cartid); - - /* cartridge is not mount candidate */ - if (mm_db_exec(HERE, db, "SELECT \"CartridgeID\"," - "\"TaskID\" " - "FROM \"TASKCARTRIDGE\" " - "WHERE (\"CartridgeID\" = '%s');", - eject_cart->cart_cartid) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - taskcart_results = db->mm_db_results; - rows = PQntuples(taskcart_results); - for (row = 0; row < rows; row++) { - if (mm_db_exec(HERE, db, "SELECT \"TaskType\" " - "FROM \"TASK\" " - "WHERE (\"TaskID\" = '%s');", - PQgetvalue(taskcart_results, row, 0)) - != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&taskcart_results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) == 1) { - rc = strcmp("mount", - PQgetvalue(taskcart_results, 0, 0)); - if (rc == 0) { - mm_clear_db(&taskcart_results); - mm_clear_db(&db->mm_db_results); - mms_trace(MMS_DEVP, "cart is " - "mount candidate"); - mm_response_error(cmd, - ECLASS_RETRY, - ECARTINUSE, - MM_5006_MSG, "cartid", - eject_cart->cart_cartid, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka-> - mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - mm_clear_db(&db->mm_db_results); - } - mm_clear_db(&taskcart_results); - - /* check for cart in slot */ - if (mm_db_exec(HERE, db, "select \"SlotOccupied\" " - "from \"SLOT\" where \"CartridgeID\" = '%s';", - eject_cart->cart_cartid) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) != 1) { - mm_response_error(cmd, - ECLASS_EXPLICIT, - ENOSLOT, - MM_5010_MSG, "cartid", - eject_cart->cart_cartid, - NULL); - mm_clear_db(&db->mm_db_results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), - "true") != 0 && - strcmp(PQgetvalue(db->mm_db_results, 0, 0), - "t") != 0) { - mm_response_error(cmd, - ECLASS_EXPLICIT, - ESLOTNOTOCCUPIED, - MM_5011_MSG, "cartid", - eject_cart->cart_cartid, - NULL); - mm_clear_db(&db->mm_db_results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - - /* check for carts in same library */ - if (cmd->cmd_eject->eject_library == NULL) { - cmd->cmd_eject->eject_library = - strdup(eject_cart->cart_library); - } else if (strcmp(cmd->cmd_eject->eject_library, - eject_cart->cart_library) != 0) { - mms_trace(MMS_DEVP, "cart not in same library"); - mm_response_error(cmd, - ECLASS_EXPLICIT, - ETOOMANY, - MM_5007_MSG, - "cartid1", eject_cart->cart_cartid, - "lib1", eject_cart->cart_library, - "lib2", cmd->cmd_eject->eject_library, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - - /* get lm */ - if (mm_db_exec(HERE, db, "SELECT \"LMName\" FROM \"LM\" " - "WHERE \"LibraryName\" = '%s'", - cmd->cmd_eject->eject_library) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) == 0) { - mm_response_error(cmd, - ECLASS_CONFIG, - ELIBNOLMCONFIGURED, - MM_5008_MSG, "lib", cmd->cmd_eject->eject_library, - NULL); - mm_clear_db(&db->mm_db_results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) != 1) { - mm_response_error(cmd, - ECLASS_EXPLICIT, - ETOOMANY, - MM_5009_MSG, "lib", cmd->cmd_eject->eject_library, - NULL); - mm_clear_db(&db->mm_db_results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - cmd->cmd_eject->eject_lm = - strdup(PQgetvalue(db->mm_db_results, 0, 0)); - mm_clear_db(&db->mm_db_results); - - /* check for configured, connected, and ready library */ - if (mm_library_lm_cfg_conn_rdy(cmd, - cmd->cmd_eject->eject_library, - cmd->cmd_eject->eject_lm) != 0) { - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - /* find cap */ - if (arg = mms_pn_lookup(cmd->cmd_root, "slotgroup", - MMS_PN_CLAUSE, NULL)) { - MMS_PN_LOOKUP(value, arg, NULL, - MMS_PN_STRING, NULL); - cmd->cmd_eject->eject_slotgroup = - strdup(value->pn_string); - } else if ((cmd->cmd_eject->eject_slotgroup = - mm_library_lm_get_cap(cmd, - cmd->cmd_eject->eject_library, - cmd->cmd_eject->eject_lm)) == NULL) { - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mms_trace(MMS_DEVP, "cap %s", cmd->cmd_eject->eject_slotgroup); - - /* - * Report clause, get before data model changes. - */ - mm_path_match_report(cmd, db); - cmd->cmd_report = strdup(cmd->cmd_buf); - - /* - * LMP eject command - */ - mms_trace(MMS_INFO, "Sending Eject to %s", - cmd->cmd_eject->eject_library); - - lm_wka = mm_library_lm_wka(cmd->wka_ptr->mm_data, - cmd->cmd_eject->eject_library, NULL); - if ((lmp_eject_cmd = mm_alloc_cmd(lm_wka)) == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_command_t: %s", - strerror(errno)); - mm_system_error(cmd, - "unable to allocate memory " - "for eject cmd"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - lmp_eject_cmd->cmd_func = mm_lmp_eject_cmd_func; - mm_get_uuid(new_task); - lmp_eject_cmd->cmd_textcmd = mms_strnew(LMP_EJECT, new_task, - cmd->cmd_eject->eject_slotgroup); - if (mm_new_tm_task(db, cmd, "dispatched") != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_eject_cmd_func: " - "error inserting new task"); - mm_system_error(cmd, - "error inserting new task"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - if (mm_set_tm_library(db, cmd->cmd_uuid, - cmd->cmd_eject->eject_library) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_eject_cmd_func: " - "error updating TASKLIBRARY"); - mm_system_error(cmd, - "error updating TASKLIBRARY"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - - mms_list_foreach(&cmd->cmd_eject->eject_list, eject_cart) { - lmp_eject_cmd->cmd_textcmd = - mms_strapp(lmp_eject_cmd->cmd_textcmd, - LMP_EJECT_SLOT, - eject_cart->cart_slotname, - eject_cart->cart_cartpcl); - if (mm_set_tm_cartridge(db, cmd->cmd_uuid, - eject_cart->cart_cartid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_eject_cmd_func: " - "db error inserting TASKCARTRIDGE"); - } - } - lmp_eject_cmd->cmd_textcmd = - mms_strapp(lmp_eject_cmd->cmd_textcmd, LMP_EJECT_END); - lmp_eject_cmd->cmd_name = strdup("lmp eject"); - lmp_eject_cmd->cmd_root = - mm_text_to_par_node(lmp_eject_cmd->cmd_textcmd, - mms_lmpm_parse); - lmp_eject_cmd->cmd_task = mm_get_task(lmp_eject_cmd->cmd_root); - mm_add_depend(lmp_eject_cmd, cmd); - cmd->cmd_state = 1; - - pthread_mutex_lock(&mm_wka->mm_data->mm_queue_mutex); - mms_list_insert_tail(&mm_wka->mm_data->mm_cmd_queue, - lmp_eject_cmd); - pthread_mutex_unlock(&mm_wka->mm_data->mm_queue_mutex); - - return (MM_DISPATCH_DEPEND); - - } else if (cmd->cmd_state == 1) { - char *response_message = NULL; - /* remove completed task */ - (void) mm_del_tm_cmd(db, cmd->cmd_uuid); - - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - mms_trace(MMS_DEVP, "lm eject failed"); - response_message = - mm_ret_response_msg(cmd); - mm_response_error(cmd, - ECLASS_SUBOP, - ELMDMCOMMUNICATION, - MM_5055_MSG, - "msg_rsp", response_message, - NULL); - free(response_message); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - /* - * Report clause (previously generated). - */ - cmd->cmd_remove = 1; - mm_send_response(mm_wka->mm_wka_conn, cmd); - mms_trace(MMS_INFO, "Ejected Cartridge(s) Successfully"); - return (MM_CMD_DONE); - } - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); -} - - -int -mm_private_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - - int off; - mms_par_node_t *work; - mms_par_node_t *item; - mms_par_node_t *itemcnt; - mms_par_node_t *object; - mms_par_node_t *attr; - mms_par_node_t *value; - mms_par_node_t *get; - mms_par_node_t *set; - mms_par_node_t *unset; - char *objname; - int get_once = 0; - int rc; - int error = 0; - mm_db_t *db = &mm_wka->mm_data->mm_db; - char *notify_obj = NULL; - int col; - int cols; - char date[24]; - char *data = NULL; - int datasize = 0; - char *id; - char *name; - char *val; - Oid oid; - char *seen_id[2] = {NULL, NULL}; - char *seen_name[2] = {NULL, NULL}; - char *query; - char *response = NULL; - int responsesize = 0; - mm_lang_t lang = cmd->cmd_language; - cci_t *conn = &mm_wka->wka_conn; - int i; - int len; - - - mms_trace(MMS_DEVP, "sql trans dmp/d or lmp/l private cmd"); - - /* - * Get all values in a single query - */ - off = 0; - work = NULL; - for (get = mms_pn_lookup(cmd->cmd_root, "get", - MMS_PN_CLAUSE, &work); - get != NULL; - get = mms_pn_lookup(cmd->cmd_root, "get", - MMS_PN_CLAUSE, &work)) { - item = NULL; - itemcnt = NULL; - for (object = mms_pn_lookup(get, NULL, - MMS_PN_OBJ, &item); - object != NULL; - object = mms_pn_lookup(get, NULL, - MMS_PN_OBJ, &item)) { - objname = object->pn_string; - - /* gather sql query constraints */ - if (strcmp(objname, "DRIVE") == 0 && - lang == MM_LANG_DMP) { - seen_id[0] = "DRIVE"; - seen_name[0] = "DriveName"; - } else if (strcmp(objname, "DM") == 0 && - lang == MM_LANG_DMP) { - seen_id[1] = "DM"; - seen_name[1] = "DMName"; - } else if (strcmp(objname, "LIBRARY") == 0 && - lang == MM_LANG_LMP) { - seen_id[0] = "LIBRARY"; - seen_name[0] = "LibraryName"; - } else if (strcmp(objname, "LM") == 0 && - lang == MM_LANG_LMP) { - seen_id[1] = "LM"; - seen_name[1] = "LMName"; - } else { - /* invalid object */ - SQL_CHK_LEN(&cmd->cmd_buf, 0, - &cmd->cmd_bufsize, - strlen(ECLASS_LANGUAGE) + - strlen(cmd->cmd_task) + - strlen(ESYNTAX) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_LANGUAGE, ESYNTAX); - free(data); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - /* initialize query buffer */ - if (!get_once) { - SQL_CHK_LEN(&data, 0, &datasize, 8); - off = snprintf(data, datasize, "SELECT "); - get_once = 1; - } - - /* add which sql query table and field */ - MMS_PN_LOOKUP(attr, get, NULL, MMS_PN_STRING, - &itemcnt); - SQL_CHK_LEN(&data, off, &datasize, strlen(objname) + - strlen(attr->pn_string) + 7); - off += snprintf(data + off, datasize - off, - "\"%s\".\"%s\",", objname, attr->pn_string); - } - } - if (get_once) { - off--; /* overwrite the last comma */ - data[off] = '\0'; - - /* add query constraints */ - if (seen_id[0] && seen_id[1]) { - query = mms_strnew("%s FROM \"%s\",\"%s\" WHERE " - "\"%s\".\"%s\" = '%s' AND " - "\"%s\".\"%s\" = '%s'", - data, seen_id[0], seen_id[1], - seen_id[0], seen_name[0], - conn->cci_client, - seen_id[1], seen_name[1], - conn->cci_instance); - } else if (seen_id[0] && strcmp(seen_id[0], "DRIVE") == 0) { - query = mms_strnew("%s FROM \"%s\" WHERE " - "\"%s\".\"DriveName\" = '%s'", - data, seen_id[0], seen_id[0], - conn->cci_client); - } else if (seen_id[0] && strcmp(seen_id[0], "LIBRARY") == 0) { - query = mms_strnew("%s FROM \"%s\" WHERE " - "\"%s\".\"LibraryName\" = '%s'", - data, seen_id[0], seen_id[0], - conn->cci_client); - } else { - query = mms_strnew("%s FROM \"%s\" WHERE " - "\"%s\" = '%s'", - data, seen_id[1], seen_name[1], - conn->cci_instance); - } - free(data); - data = NULL; - datasize = 0; - if (query == NULL) { - MM_ABORT_NO_MEM(); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - /* query the database */ - rc = mm_db_exec(HERE, db, query); - free(query); - if (rc != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + - strlen(cmd->cmd_task) + - strlen(ECLASS_INTERNAL) + - strlen(EDATABASE) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INTERNAL, EDATABASE); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - cols = PQnfields(db->mm_db_results); - - - /* convert strings from postgres to mms */ - off = 0; - for (col = 0; col < cols; col++) { - name = PQfname(db->mm_db_results, col); - val = PQgetvalue(db->mm_db_results, 0, col); - if (val[0] == '\0') { - /* empty object attribute string */ - val = "none"; - } - - /* database data types to mms string conversions */ - oid = PQftype(db->mm_db_results, col); - if (oid == db->mm_db_cfg->mm_db_bool_oid) { - if (strcmp(val, "t") == 0) { - val = "true"; - } else if (strcmp(val, "f") == 0) { - val = "false"; - } - } else if (oid == db->mm_db_cfg->mm_db_timestamp_oid) { - if (strcmp(val, "-infinity") == 0) { - /* mms time not set */ - val = "0000 00 00 00 00 00 000"; - } else { - (void) strlcpy(date, val, - sizeof (date)); - val = date; - /* mms localtime format */ - val[4] = ' '; /* - */ - val[7] = ' '; /* - */ - val[13] = ' '; /* : */ - val[16] = ' '; /* : */ - if (val[19] == '\0') { - val[20] = '\0'; - } - val[19] = ' '; /* . */ - - len = strlen(val); - for (i = len; i < 23; i++) { - val[i] = '0'; - } - val[23] = '\0'; - } - } - - SQL_CHK_LEN(&data, off, &datasize, strlen(name) + - strlen(val) + 7); - off += snprintf(data + off, datasize - off, - "\"%s\" \"%s\" ", name, val); - } - mm_clear_db(&db->mm_db_results); - - if (data) { - /* build successful response with text */ - SQL_CHK_LEN(&response, 0, &responsesize, - strlen(RESPONSE_SUCCESS_TEXT) + - strlen(cmd->cmd_task) + - strlen(data) + 1); - (void) snprintf(response, responsesize, - RESPONSE_SUCCESS_TEXT, cmd->cmd_task, data); - free(data); - data = NULL; - datasize = 0; - } - } - if (response == NULL) { /* nothing to report */ - SQL_CHK_LEN(&response, 0, &responsesize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(response, responsesize, - RESPONSE_SUCCESS, cmd->cmd_task); - } - - /* - * Set values one at a time - */ - work = NULL; - for (set = mms_pn_lookup(cmd->cmd_root, "set", - MMS_PN_CLAUSE, &work); - set != NULL; - set = mms_pn_lookup(cmd->cmd_root, "set", - MMS_PN_CLAUSE, &work)) { - item = NULL; - itemcnt = NULL; - for (object = mms_pn_lookup(set, NULL, MMS_PN_OBJ, &item); - object != NULL; - object = mms_pn_lookup(set, NULL, MMS_PN_OBJ, &item)) { - objname = object->pn_string; - MMS_PN_LOOKUP(attr, set, NULL, - MMS_PN_STRING, &itemcnt); - MMS_PN_LOOKUP(value, set, NULL, - MMS_PN_STRING, &itemcnt); - - /* check for name changes and flag change event */ - if (strcmp(objname, "DRIVE") == 0 && - lang == MM_LANG_DMP) { - id = "DriveName"; - name = conn->cci_client; - } else if (strcmp(objname, "DM") == 0 && - lang == MM_LANG_DMP) { - id = "DMName"; - name = conn->cci_instance; - notify_obj = "DM"; - } else if (strcmp(objname, "LIBRARY") == 0 && - lang == MM_LANG_LMP) { - id = "LibraryName"; - name = conn->cci_client; - } else if (strcmp(objname, "LM") == 0 && - lang == MM_LANG_LMP) { - id = "LMName"; - name = conn->cci_instance; - notify_obj = "LM"; - } else { - error = 1; /* invalid object */ - } - if (strcmp(attr->pn_string, id) == 0 || error) { - /* name change not allowed or invalid object */ - SQL_CHK_LEN(&cmd->cmd_buf, 0, - &cmd->cmd_bufsize, - strlen(ECLASS_LANGUAGE) + - strlen(cmd->cmd_task) + - strlen(ESYNTAX) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_LANGUAGE, ESYNTAX); - free(response); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(objname) + 14); - off = snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - "UPDATE \"%s\" SET ", objname); - - if (value->pn_type & MMS_PN_NULLSTR) { - SQL_CHK_LEN(&cmd->cmd_buf, off, - &cmd->cmd_bufsize, - strlen(attr->pn_string) + - strlen(id) + strlen(name) + 8); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, - "\"%s\" = default " - "WHERE \"%s\" = '%s'", - attr->pn_string, - id, name); - } else { - SQL_CHK_LEN(&cmd->cmd_buf, off, - &cmd->cmd_bufsize, - strlen(attr->pn_string) + - strlen(value->pn_string) + - strlen(id) + strlen(name) + 8); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, - "\"%s\" = '%s' " - "WHERE \"%s\" = '%s'", - attr->pn_string, - value->pn_string, id, name); - } - - /* create the attribute if needed */ - if (mm_db_create_attribute(db, objname, - attr->pn_string) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - free(response); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - /* change the attribute value */ - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - free(response); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - } - - /* - * Unset values one at a time - */ - for (unset = mms_pn_lookup(cmd->cmd_root, "unset", - MMS_PN_CLAUSE, &work); - unset != NULL; - unset = mms_pn_lookup(cmd->cmd_root, "unset", - MMS_PN_CLAUSE, &work)) { - item = NULL; - itemcnt = NULL; - for (object = mms_pn_lookup(unset, NULL, MMS_PN_OBJ, &item); - object != NULL; - object = mms_pn_lookup(unset, NULL, MMS_PN_OBJ, - &item)) { - objname = object->pn_string; - MMS_PN_LOOKUP(attr, unset, NULL, - MMS_PN_STRING, &itemcnt); - - /* check for name changes and flag change event */ - if (strcmp(objname, "DRIVE") == 0 && - lang == MM_LANG_DMP) { - id = "DriveName"; - name = conn->cci_client; - } else if (strcmp(objname, "DM") == 0 && - lang == MM_LANG_DMP) { - id = "DMName"; - name = conn->cci_instance; - notify_obj = "DM"; - } else if (strcmp(objname, "LIBRARY") == 0 && - lang == MM_LANG_LMP) { - id = "LibraryName"; - name = conn->cci_client; - } else if (strcmp(objname, "LM") == 0 && - lang == MM_LANG_LMP) { - id = "LMName"; - name = conn->cci_instance; - notify_obj = "LM"; - } else { - error = 1; /* invalid object */ - } - if (strcmp(attr->pn_string, id) == 0 || error) { - /* name change not allowed or invalid object */ - SQL_CHK_LEN(&cmd->cmd_buf, 0, - &cmd->cmd_bufsize, - strlen(ECLASS_LANGUAGE) + - strlen(cmd->cmd_task) + - strlen(ESYNTAX) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_LANGUAGE, ESYNTAX); - free(response); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - /* remove device manager created attributes */ - if ((rc = mm_db_delete_attribute(db, objname, - attr->pn_string)) == MM_DB_DROPPED) { - continue; /* object attribute removed */ - } else if (rc == MM_DB_ERROR) { - mm_sql_db_err_rsp_new(cmd, db); - free(response); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - /* set the attribute to its default */ - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(objname) + 15); - off = snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - "UPDATE \"%s\" SET ", objname); - - SQL_CHK_LEN(&cmd->cmd_buf, off, &cmd->cmd_bufsize, - strlen(attr->pn_string) + 14); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, - "\"%s\" = DEFAULT WHERE \"%s\" = '%s'", - attr->pn_string, id, name); - - /* set attribute to default */ - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - free(response); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - } - - /* - * Notify clients - */ - if (notify_obj) { - if (mm_notify_add_config(mm_wka, - cmd, - "change", notify_obj, - cmd->wka_ptr->wka_conn.cci_instance, - cmd->wka_ptr->wka_conn.cci_host)) { - mms_trace(MMS_ERR, - "mm_private_cmd_func: " - "error adding config change event"); - } - } - - /* - * Return the get report - */ - if (cmd->cmd_buf) { - free(cmd->cmd_buf); - cmd->cmd_buf = NULL; - cmd->cmd_bufsize = 0; - } - cmd->cmd_buf = response; - cmd->cmd_bufsize = strlen(response) + 1; - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_DONE); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - free(data); - free(response); - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - -} - -int -mm_startup_private(mm_wka_t *mm_wka) { - mm_db_t *db = &mm_wka->mm_data->mm_db; - cci_t *conn = &mm_wka->wka_conn; - uuid_text_t task; - char *buf; - mm_command_t *pvt_cmd; - - PGresult *system_results; - - /* - * Add change tracing private command to command queue - */ - - if (mm_db_exec(HERE, db, - "select \"SystemDiskMountTimeout\" " - "from \"SYSTEM\";") != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - mms_trace(MMS_ERR, - "error getting SystemDiskMountTimeout"); - return (1); - } - - system_results = db->mm_db_results; - - if (mm_wka->mm_wka_mm_lang == MM_LANG_LMP) { - - mms_trace(MMS_DEVP, "Set lmp tracing"); - - if (mm_db_exec(HERE, db, "select \"LMMessageLevel\"," - "\"TraceLevel\",\"TraceFileSize\" from \"LM\" where " - "\"LMName\" = '%s';", conn->cci_instance) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - mm_clear_db(&system_results); - return (1); - } - if (PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - mm_clear_db(&system_results); - return (1); - } - - mm_get_uuid(task); - - buf = mms_strnew("private task[\"%s\"] " - "set[\"LMMessageLevel\" \"%s\" " - "\"TraceLevel\" \"%s\" " - "\"TraceFileSize\" \"%s\" " - "\"SystemDiskMountTimeout\" \"%s\"];", - task, - PQgetvalue(db->mm_db_results, 0, 0), - PQgetvalue(db->mm_db_results, 0, 1), - PQgetvalue(db->mm_db_results, 0, 2), - PQgetvalue(system_results, 0, 0)); - mm_clear_db(&system_results); - - mm_clear_db(&db->mm_db_results); - pvt_cmd = mm_alloc_cmd(mm_wka); - pvt_cmd->cmd_textcmd = buf; - pvt_cmd->cmd_root = mm_text_to_par_node(pvt_cmd->cmd_textcmd, - mms_lmpm_parse); - pvt_cmd->cmd_task = mm_get_task(pvt_cmd->cmd_root); - pvt_cmd->wka_ptr = mm_wka; - pvt_cmd->cmd_func = mm_msg_tracing_cmd_func; - pvt_cmd->cmd_flags = MM_CMD_DISPATCHABLE; - pvt_cmd->cmd_language = MM_LANG_LMP; - pvt_cmd->cmd_name = strdup("lmp tracing"); - - pthread_mutex_lock(&mm_wka->mm_data->mm_queue_mutex); - mms_list_insert_tail(&mm_wka->mm_data->mm_cmd_queue, pvt_cmd); - pthread_mutex_unlock(&mm_wka->mm_data->mm_queue_mutex); - - mms_trace(MMS_DEVP, "Added set lmp tracing"); - - } else if (mm_wka->mm_wka_mm_lang == MM_LANG_DMP) { - - mms_trace(MMS_DEVP, "Set dmp tracing"); - - if (mm_db_exec(HERE, db, "select \"DMMessageLevel\"," - "\"TraceLevel\",\"TraceFileSize\" from \"DM\" where " - "\"DMName\" = '%s';", conn->cci_instance) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - mm_clear_db(&system_results); - return (1); - } - if (PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - mm_clear_db(&system_results); - return (1); - } - - mm_get_uuid(task); - - buf = mms_strnew("private task[\"%s\"] " - "set[\"DMMessageLevel\" \"%s\" " - "\"TraceLevel\" \"%s\" " - "\"TraceFileSize\" \"%s\" " - "\"SystemDiskMountTimeout\" \"%s\"];", - task, - PQgetvalue(db->mm_db_results, 0, 0), - PQgetvalue(db->mm_db_results, 0, 1), - PQgetvalue(db->mm_db_results, 0, 2), - PQgetvalue(system_results, 0, 0)); - - mm_clear_db(&db->mm_db_results); - mm_clear_db(&system_results); - - pvt_cmd = mm_alloc_cmd(mm_wka); - pvt_cmd->cmd_textcmd = buf; - pvt_cmd->cmd_root = mm_text_to_par_node(pvt_cmd->cmd_textcmd, - mms_dmpm_parse); - pvt_cmd->cmd_task = mm_get_task(pvt_cmd->cmd_root); - pvt_cmd->wka_ptr = mm_wka; - pvt_cmd->cmd_func = mm_msg_tracing_cmd_func; - pvt_cmd->cmd_flags = MM_CMD_DISPATCHABLE; - pvt_cmd->cmd_language = MM_LANG_DMP; - pvt_cmd->cmd_name = strdup("dmp tracing"); - - pthread_mutex_lock(&mm_wka->mm_data->mm_queue_mutex); - mms_list_insert_tail(&mm_wka->mm_data->mm_cmd_queue, pvt_cmd); - pthread_mutex_unlock(&mm_wka->mm_data->mm_queue_mutex); - - mms_trace(MMS_DEVP, "Added set dmp tracing"); - } - - return (0); - - -} - -int -mm_hello_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - - int row = 0; - int rows = 0; - mms_par_node_t *clause = NULL; - mms_par_node_t *value = NULL; - - int error = 0; - int found = 0; - mms_par_node_t *work = NULL; - char *tag = NULL; - - char *password = NULL; - char *mm_password = NULL; - -#ifdef MMS_OPENSSL - char *certificate = NULL; - char *auth_message = NULL; - mms_err_t err; - char ebuf[MMS_EBUF_LEN]; -#endif /* MMS_OPENSSL */ - - mm_db_t *db = &mm_wka->mm_data->mm_db; - cci_t *conn = &mm_wka->wka_conn; - - int configured; - int rc; - - mms_trace(MMS_DEVP, "mm hello command"); - if (cmd->cmd_state == 0) { - if (mm_wka->wka_hello_needed == B_FALSE) { - mms_trace(MMS_DEVP, "No hello Necessary..."); - goto unsupported; - - } - /* get client connection info */ - clause = mms_pn_lookup_arg(cmd->cmd_root, "client", - MMS_PN_CLAUSE, NULL); - if (clause == NULL) { - mms_trace(MMS_ERR, - "mm_hello_cmd_func: " - "missing client clause"); - goto unsupported; - } - /* client clause is present */ - value = mms_pn_lookup_arg(clause, NULL, - MMS_PN_STRING, NULL); - if ((value == NULL) || - (value->pn_string == NULL)) { - mms_trace(MMS_ERR, - "mm_hello_cmd_func: " - "missing client clause string"); - goto unsupported; - } - conn->cci_client = mms_strapp(conn->cci_client, - value->pn_string); - if (conn->cci_client == NULL) { - mms_trace(MMS_ERR, "null connection client"); - goto unsupported; - } - - mms_trace(MMS_DEBUG, "client %s", conn->cci_client); - clause = NULL; - value = NULL; - /* get instance info */ - clause = mms_pn_lookup_arg(cmd->cmd_root, "instance", - MMS_PN_CLAUSE, NULL); - if (clause == NULL) { - mms_trace(MMS_ERR, - "mm_hello_cmd_func: " - "missing instance clause"); - goto unsupported; - } - /* instance clause is present */ - value = mms_pn_lookup_arg(clause, NULL, - MMS_PN_STRING, NULL); - if ((value == NULL) || - (value->pn_string == NULL)) { - mms_trace(MMS_ERR, - "mm_hello_cmd_func: " - "missing instance clause string"); - goto unsupported; - } - conn->cci_instance = mms_strapp(conn->cci_instance, - value->pn_string); - if (conn->cci_instance == NULL) { - mms_trace(MMS_ERR, "null connection instance"); - goto unsupported; - } - mms_trace(MMS_DEBUG, "instance %s", conn->cci_instance); - - /* Get optional tag arg */ - clause = mms_pn_lookup_arg(cmd->cmd_root, "tag", - MMS_PN_CLAUSE, NULL); - if (clause != NULL) { - /* tag clause is present */ - value = mms_pn_lookup_arg(clause, NULL, - MMS_PN_STRING, NULL); - tag = value->pn_string; - mms_trace(MMS_DEVP, - "session tag will be %s", - tag); - } - - clause = NULL; - value = NULL; - /* get language info */ - clause = mms_pn_lookup_arg(cmd->cmd_root, "language", - MMS_PN_CLAUSE, NULL); - if (clause == NULL) { - mms_trace(MMS_ERR, - "mm_hello_cmd_func: " - "missing language clause"); - goto unsupported; - } - /* language clause is present */ - value = mms_pn_lookup_arg(clause, NULL, - MMS_PN_KEYWORD, NULL); - if ((value == NULL) || - (value->pn_string == NULL)) { - mms_trace(MMS_ERR, - "mm_hello_cmd_func: " - "missing language clause keyword"); - goto unsupported; - } - mm_wka->wka_privilege = MM_PRIV_STANDARD; - if (strcmp(value->pn_string, "MMP") == 0) { - cmd->cmd_language = MM_LANG_MMP; - mm_wka->mm_wka_mm_lang = MM_LANG_MMP; - if (strcmp(conn->cci_client, MM_APP) == 0 && - (strcmp(conn->cci_instance, MM_ADMIN) == 0 || - strcmp(conn->cci_instance, MM_OPER) == 0)) { - mm_wka->wka_privilege = MM_PRIV_ADMIN; - } - } else if (strcmp(value->pn_string, "DMP") == 0) { - cmd->cmd_language = MM_LANG_DMP; - mm_wka->mm_wka_mm_lang = MM_LANG_DMP; - mm_wka->wka_privilege = MM_PRIV_SYSTEM; - } else if (strcmp(value->pn_string, "LMP") == 0) { - cmd->cmd_language = MM_LANG_LMP; - mm_wka->mm_wka_mm_lang = MM_LANG_LMP; - mm_wka->wka_privilege = MM_PRIV_SYSTEM; - } else { - mms_trace(MMS_ERR, - "mm_hello_cmd_func: " - "unknown language in hello"); - mm_wka->wka_unwelcome = 1; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(UNWELCOME_LANG) + 1); - - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - UNWELCOME_LANG); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_DONE); - } - conn->cci_language = mms_strapp(conn->cci_language, - value->pn_string); - if (conn->cci_language == NULL) { - mms_trace(MMS_ERR, "null connection language"); - goto unsupported; - } - mms_trace(MMS_DEBUG, "language %s", conn->cci_language); - - clause = NULL; - value = NULL; - clause = mms_pn_lookup_arg(cmd->cmd_root, "version", - MMS_PN_CLAUSE, NULL); - if (clause == NULL) { - mms_trace(MMS_ERR, - "mm_hello_cmd_func: " - "missing version clause"); - goto unsupported; - } - - found = 0; - work = NULL; - while (!found && (value = mms_pn_lookup(clause, NULL, - MMS_PN_STRING, - &work)) != NULL) { - mms_trace(MMS_DEBUG, "version %s", value->pn_string); - if (strcmp(value->pn_string, "1.0") == 0) { - conn->cci_version = - mms_strapp(conn->cci_version, - value->pn_string); - if (conn->cci_version == NULL) { - mms_trace(MMS_ERR, - "null connection version"); - goto unsupported; - } - found = 1; - } - } - - if (!found) { - mms_trace(MMS_DEVP, "version not found"); - goto unsupported; - } - - switch (cmd->cmd_language) { - case MM_LANG_MMP: - rc = mm_db_exec_si(HERE, db, - "select \"Password\" " - "from \"MMPASSWORD\" " - "where \"ApplicationName\" = '%s';", - conn->cci_client); - break; - case MM_LANG_LMP: - case MM_LANG_DMP: - /* lm and dm use watcher's password */ - rc = mm_db_exec_si(HERE, db, - "select \"Password\" " - "from \"MMPASSWORD\" " - "where \"ApplicationName\" = '%s';", - MM_APP); - break; - } - if (rc != MM_DB_DATA || - PQntuples(db->mm_db_results) != 1 || - (password = PQgetvalue(db->mm_db_results, 0, 0)) == NULL) { - mm_clear_db(&db->mm_db_results); - mms_trace(MMS_ERR, "expected password retrieval"); - goto denied; - } - - free(conn->cci_password); - conn->cci_password = strdup(password); - mm_clear_db(&db->mm_db_results); - password = NULL; - - /* verify hello password or cert clause */ - if ((clause = mms_pn_lookup_arg(cmd->cmd_root, "password", - MMS_PN_CLAUSE, NULL)) != NULL) { - value = mms_pn_lookup_arg(clause, NULL, - MMS_PN_STRING, NULL); - password = strdup(value->pn_string); - } -#ifdef MMS_OPENSSL - if ((clause = mms_pn_lookup_arg(cmd->cmd_root, "certificate", - MMS_PN_CLAUSE, NULL)) != NULL) { - mms_par_node_t *index = NULL; - - value = mms_pn_lookup_arg(clause, NULL, - MMS_PN_STRING, &index); - certificate = value->pn_string; - - value = mms_pn_lookup_arg(clause, NULL, - MMS_PN_STRING, &index); - auth_message = value->pn_string; - - mms_trace(MMS_DEBUG, - "certificate/auth\n%s\n%s", - certificate, - auth_message); - - /* get password from encrypted data */ - if (mms_ssl_verify_cert_clause( - mm_wka->mm_data->mm_ssl_data, - mm_wka->mm_wka_conn, - certificate, - auth_message, - &password)) { - mms_get_error_string(&err, - ebuf, MMS_EBUF_LEN); - mms_trace(MMS_ERR, - "invalid cert clause %s", ebuf); - goto denied; - } - } -#endif /* MMS_OPENSSL */ - if (password == NULL) { - mms_trace(MMS_ERR, "no password"); - goto denied; - } - /* get password hash */ - rc = mm_db_exec_si(HERE, db, - "select mm_func_getpassword('%s');", - password); - free(password); - if (rc != MM_DB_DATA || PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, "get password hash"); - mm_clear_db(&db->mm_db_results); - goto denied; - } - /* compare password hashes */ - rc = strcmp(conn->cci_password, - PQgetvalue(db->mm_db_results, 0, 0)); - mm_clear_db(&db->mm_db_results); - if (rc == 0) { - mms_trace(MMS_DEVP, "password ok"); - } else { - mms_trace(MMS_ERR, "invalid password"); - goto denied; - } - - - error = 0; - configured = 0; - switch (cmd->cmd_language) { - case MM_LANG_MMP: - if (mm_db_exec(HERE, db, - "SELECT "\ - "\"APPLICATION\".\"ApplicationName\"," - "\"AI\".\"AIName\", "\ - "\"AI\".\"ApplicationName\"," - "\"AI\".\"SessionsAllowed\" FROM " - "\"APPLICATION\",\"AI\" WHERE " - "(\"APPLICATION\".\"ApplicationName\" "\ - "= '%s' AND " - "\"AI\".\"AIName\" = '%s') AND " - "\"AI\".\"ApplicationName\" = '%s'", - conn->cci_client, - conn->cci_instance, - conn->cci_client) != MM_DB_DATA) { - error = 1; - } else if (PQntuples(db->mm_db_results) == 1) { - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), - conn->cci_client) == 0 && - strcmp(PQgetvalue(db->mm_db_results, 0, 1), - conn->cci_instance) == 0 && - strcmp(PQgetvalue(db->mm_db_results, 0, 2), - conn->cci_client) == 0) { - configured = 1; - } - } - mm_clear_db(&db->mm_db_results); - break; - case MM_LANG_DMP: - /* - * Drive.DMName is only set when DM is activate enable. - */ - if (mm_db_exec(HERE, db, - "SELECT \"DRIVE\".\"DriveName\"," - "\"DM\".\"DMName\",\"DM\"."\ - "\"DriveName\" " - "FROM \"DRIVE\",\"DM\" WHERE " - "(\"DRIVE\".\"DriveName\" = '%s' AND " - "\"DM\".\"DMName\" = '%s' AND " - "\"DM\".\"DriveName\" = '%s')", - conn->cci_client, conn->cci_instance, - conn->cci_client) != MM_DB_DATA) { - error = 1; - } else if (PQntuples(db->mm_db_results) == 1) { - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), - conn->cci_client) == 0 && - - strcmp(PQgetvalue(db->mm_db_results, 0, 1), - conn->cci_instance) == 0 && - - strcmp(PQgetvalue(db->mm_db_results, 0, 2), - conn->cci_client) == 0) { - - configured = 1; - } - } - mm_clear_db(&db->mm_db_results); - break; - case MM_LANG_LMP: - /* - * LIBRARY.LMName is set by the user. - */ - if (mm_db_exec(HERE, db, - "SELECT \"LIBRARY\".\"LibraryName\"," - "\"LM\".\"LMName\",\"LM\"."\ - "\"LibraryName\" " - "FROM \"LIBRARY\",\"LM\" WHERE " - "(\"LIBRARY\".\"LibraryName\" "\ - "= '%s' AND " - "\"LM\".\"LMName\" = '%s' AND " - "\"LM\".\"LibraryName\" = '%s')", - conn->cci_client, conn->cci_instance, - conn->cci_client) != MM_DB_DATA) { - error = 1; - } else if (PQntuples(db->mm_db_results) == 1) { - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), - conn->cci_client) == 0 && - - strcmp(PQgetvalue(db->mm_db_results, 0, 1), - conn->cci_instance) == 0 && - - strcmp(PQgetvalue(db->mm_db_results, 0, 2), - conn->cci_client) == 0) { - - configured = 1; - } - } - mm_clear_db(&db->mm_db_results); - break; - } - if (error == 1 || configured == 0) { - if (error) - mms_trace(MMS_ERR, "unable to validate config"); - if (!configured) - mms_trace(MMS_INFO, "HINT: %s %s (%s) " - "not configured", - conn->cci_client, - conn->cci_instance, - mm_cci_host_ident(conn)); - goto denied; - } - /* check for duplicate device managers on same host */ - if (mm_db_exec(HERE, db, "SELECT \"ConnectionClientName\"," - "\"ConnectionClientInstance\", "\ - "\"ConnectionClientHost\" " - "FROM \"CONNECTION\"") != MM_DB_DATA) { - mms_trace(MMS_ERR, - "mm_hello_cmd_func: " - "db error getting connection info," - "return unwelcome"); - goto denied; - } - rows = PQntuples(db->mm_db_results); - for (row = 0; row < rows; row++) { - switch (cmd->cmd_language) { - case MM_LANG_DMP: - case MM_LANG_LMP: - if (strcmp(PQgetvalue(db->mm_db_results, - row, 0), - conn->cci_client) == 0 && - strcmp(PQgetvalue(db->mm_db_results, - row, 1), - conn->cci_instance) == 0 && - strcmp(PQgetvalue(db->mm_db_results, - row, 2), - mm_cci_host_ident(conn)) == 0) { - - mm_clear_db(&db->mm_db_results); - - mms_trace(MMS_ERR, - "mm_hello_cmd_func: " - "duplicate session found, " - "return unwelcome"); - mm_wka->wka_unwelcome = 1; - SQL_CHK_LEN(&cmd->cmd_buf, 0, - &cmd->cmd_bufsize, - strlen(UNWELCOME_DUP) + 1); - - (void) snprintf(cmd->cmd_buf, - cmd->cmd_bufsize, UNWELCOME_DUP); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_DONE); - } - break; - } - } - mm_clear_db(&db->mm_db_results); - - /* For MMP clients, check that Ai.SessionsAllowed */ - /* allows them to conect */ - if (cmd->cmd_language == MM_LANG_MMP) { - if (mm_db_exec(HERE, db, - "SELECT \"CONNECTION\".\"ConnectionID\"," - "\"AI\".\"SessionsAllowed\" FROM" - "\"CONNECTION\" cross join \"AI\"" - "where" - "(" - "(\"CONNECTION\"." - "\"ConnectionClientInstance\" = " - "\"AI\".\"AIName\")" - "and" - "(\"CONNECTION\"." - "\"ConnectionClientName\" = " - "\"AI\".\"ApplicationName\")" - "and" - "(\"AI\".\"AIName\" = '%s')" - "and" - "(\"AI\".\"ApplicationName\" = '%s')" - ");", - conn->cci_instance, - conn->cci_client) != MM_DB_DATA) { - goto denied; - } - if ((PQntuples(db->mm_db_results) != 0) && - (strcmp(PQgetvalue(db->mm_db_results, 0, 1), - "single") == 0)) { - /* This is a duplicate session */ - /* with single session allowed */ - mms_trace(MMS_ERR, - "multiple sessions not allowed for %s, %s", - conn->cci_client, - conn->cci_instance); - mm_clear_db(&db->mm_db_results); - mm_wka->wka_unwelcome = 1; - SQL_CHK_LEN(&cmd->cmd_buf, 0, - &cmd->cmd_bufsize, - strlen(UNWELCOME_DUP) + 1); - - (void) snprintf(cmd->cmd_buf, - cmd->cmd_bufsize, UNWELCOME_DUP); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_DONE); - } - mm_clear_db(&db->mm_db_results); - } - - - if (mm_db_exec(HERE, db, "INSERT INTO \"CONNECTION\" " - "(\"Language\",\"ConnectionClientName\"," - "\"ConnectionClientInstance\", "\ - "\"ConnectionClientHost\"," - "\"ConnectionClientPort\", "\ - "\"ConnectionID\") " - "VALUES('%s','%s','%s','%s','%d','%s')", - conn->cci_language, - conn->cci_client, - conn->cci_instance, - mm_cci_host_ident(conn), - conn->cci_port, - mm_wka->wka_conn.cci_uuid) - != MM_DB_OK) { - goto denied; - } - - if (mm_db_exec(HERE, db, "INSERT INTO \"NOTIFY\" " - "(\"ConnectionClientName\", " - "\"ConnectionClientInstance\"," - "\"ConnectionID\") " - "VALUES ('%s','%s','%s')", - conn->cci_client, - conn->cci_instance, - mm_wka->wka_conn.cci_uuid) != MM_DB_OK) { - goto denied; - } - - /* add session */ - if (cmd->cmd_language == MM_LANG_MMP) { - mm_get_uuid(mm_wka->session_uuid); - if (mm_db_exec(HERE, db, - "INSERT INTO \"SESSION\" " - "(\"SessionID\", " - "\"ApplicationName\", " - "\"AIName\"," - "\"SessionClientHost\", " - "\"SessionClientPort\", " - "\"ConnectionID\") " - "VALUES ('%s','%s','%s'," - "'%s','%d','%s')", - mm_wka->session_uuid, - conn->cci_client, - conn->cci_instance, - mm_cci_host_ident(conn), - conn->cci_port, - mm_wka->wka_conn.cci_uuid) - != MM_DB_OK) { - mms_trace(MMS_ERR, - "db error inserting session obj"); - goto denied; - } - if (tag != NULL) { - /* Set the session tag */ - if (mm_db_exec(HERE, db, - "update \"SESSION\" set " - "\"SessionTag\" = '%s'" - " where \"SessionID\" = '%s';", - tag, mm_wka->session_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "db error setting session tag"); - goto denied; - } - } - - } else if (cmd->cmd_language == MM_LANG_DMP) { - /* update dm host */ - if (mm_db_exec(HERE, db, "update \"DM\" " - "set \"DMHost\" = '%s' " - "where \"DriveName\" = '%s' " - "and \"DMName\" = '%s';", - mm_cci_host_ident(conn), - conn->cci_client, - conn->cci_instance) != MM_DB_OK) { - goto denied; - } - } else if (cmd->cmd_language == MM_LANG_LMP) { - /* update lm host */ - if (mm_db_exec(HERE, db, "update \"LM\" " - "set \"LMHost\" = '%s' " - "where \"LibraryName\" = '%s' " - "and \"LMName\" = '%s';", - mm_cci_host_ident(conn), - conn->cci_client, - conn->cci_instance) != MM_DB_OK) { - goto denied; - } - } - - /* welcome new client */ - mm_password = mm_wka->mm_data->mm_cfg.mm_network_cfg.mm_pass; - if (mm_password == NULL) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, - &cmd->cmd_bufsize, strlen(MMS_WELCOME) + - strlen(conn->cci_version) + - strlen(mm_wka->mm_data->mm_cfg. - mm_network_cfg.cli_name) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - MMS_WELCOME, conn->cci_version, - mm_wka->mm_data->mm_cfg.mm_network_cfg.cli_name); -#ifdef MMS_OPENSSL - } else if (mms_ssl_has_cert_clause(mm_wka-> - mm_data->mm_ssl_data, - mm_wka->mm_wka_conn)) { - if (mms_ssl_build_cert_clause(mm_wka->mm_data-> - mm_ssl_data, - mm_wka->mm_wka_conn, - mm_password, - &certificate, - &auth_message)) { - mms_get_error_string(&err, ebuf, - MMS_EBUF_LEN); - mms_trace(MMS_ERR, "welcome cert clause - %s", - ebuf); - goto denied; - - } - SQL_CHK_LEN(&cmd->cmd_buf, 0, - &cmd->cmd_bufsize, strlen(WELCOME_CERT) + - strlen(conn->cci_version) + - strlen(mm_wka->mm_data->mm_cfg. - mm_network_cfg.cli_name) + - strlen(certificate) + - strlen(auth_message) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - WELCOME_CERT, conn->cci_version, - mm_wka->mm_data->mm_cfg.mm_network_cfg.cli_name, - certificate, - auth_message); - mms_trace(MMS_DEBUG, - "certificate/auth\n%s\n%s", - certificate, - auth_message); - free(certificate); - free(auth_message); -#endif /* MMS_OPENSSL */ - } else { - SQL_CHK_LEN(&cmd->cmd_buf, 0, - &cmd->cmd_bufsize, strlen(WELCOME_PASS) + - strlen(conn->cci_version) + - strlen(mm_wka->mm_data->mm_cfg. - mm_network_cfg.cli_name) + - strlen(mm_password) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - WELCOME_PASS, conn->cci_version, - mm_wka->mm_data->mm_cfg.mm_network_cfg.cli_name, - mm_password); - mms_trace(MMS_DEBUG, "adding password"); - } - mm_wka->wka_hello_needed = B_FALSE; - cmd->cmd_remove = 1; - - mms_trace(MMS_INFO, "Welcome, %s, %s, %s", - conn->cci_client, - conn->cci_instance, - conn->cci_language); - - if ((strcmp(conn->cci_client, "MMS") == 0) && - (strcmp(conn->cci_instance, "watcher") == 0)) { - mm_wka->wka_privilege = MM_PRIV_ADMIN; - } - - mm_send_text_si(mm_wka->mm_wka_conn, cmd->cmd_buf); - - if (cmd->cmd_language != MM_LANG_MMP) { - /* Send device manager private cmd */ - if (mm_startup_private(mm_wka)) { - mms_trace(MMS_ERR, - "error sending " - "private command"); - } - } - - /* Add LM Activate */ - - if (rc == 0 && cmd->cmd_language == MM_LANG_LMP) { - /* activate enable library lm */ - if (mm_library_lm_connect(mm_wka)) { - mms_trace(MMS_ERR, "library lm access"); - return (MM_CMD_ERROR); - } else if (mm_library_lm_activate_enable(mm_wka) == 0) { - mms_trace(MMS_INFO, "Added LM Activate Enable" - "for %s", - mm_wka->wka_conn.cci_instance); - return (MM_DISPATCH_AGAIN); - } - } - - /* Add DM Activate */ - - if (rc == 0 && cmd->cmd_language == MM_LANG_DMP) { - /* activate enable */ - mm_sql_update_state(mm_wka->mm_data, "DM", - "DMStateSoft", - "present", "DMName", - mm_wka->wka_conn.cci_instance); - if (mm_drive_dm_activate_enable(mm_wka) != NULL) { - mms_trace(MMS_INFO, "Added DM Activate Enable" - "for %s", - mm_wka->wka_conn.cci_instance); - return (MM_DISPATCH_AGAIN); - } - } - - /* hello complete */ - return (MM_CMD_DONE); - } - - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - - -not_found: - mms_trace(MMS_ERR, "not_found in hello cmd func"); - mm_wka->wka_unwelcome = 1; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(UNWELCOME_PROTO) + 1); - - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, UNWELCOME_PROTO); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - - -unsupported: - mms_trace(MMS_ERR, "unsupported in hello cmd func"); - mm_wka->wka_unwelcome = 1; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(UNWELCOME_UNSUP) + 1); - - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, UNWELCOME_UNSUP); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - - return (MM_CMD_DONE); - - -denied: - mms_trace(MMS_ERR, "denied in hello cmd func"); - mm_wka->wka_unwelcome = 1; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(UNWELCOME_DENIED) + 1); - - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, UNWELCOME_DENIED); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - - return (MM_CMD_DONE); -} - - - -int -mm_move_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *arg; - mms_par_node_t *value; - char *toslot; - int rows; - PGresult *cart_results; - PGresult *lm_results; - int rc; - char taskid[UUID_PRINTF_SIZE]; - char *libname; - char *lmname; - mms_par_node_t *work = NULL; - mms_par_node_t *next; - char *cartid; - char *sidename; - char *cartpcl; - char *slottype; - const char *query; - mms_par_node_t *cart; - char *slotname; - char *state; - mm_db_t *db = &mm_wka->mm_data->mm_db; - char *const_buf = NULL; - - - mms_trace(MMS_DEVP, "mm move command"); - if (mm_privileged(mm_wka, cmd) == MM_PRIV_STANDARD) { - rc = MM_CMD_ERROR; - goto end; - } - - /* slot */ - MMS_PN_LOOKUP(arg, cmd->cmd_root, "toslot", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, arg, NULL, MMS_PN_STRING, NULL); - toslot = value->pn_string; - - - /* constraints */ - if (cart = mms_pn_lookup(cmd->cmd_root, "cartid", - MMS_PN_CLAUSE, &work)) { - - mms_trace(MMS_DEVP, - "move command cartid clause"); - - if (const_buf != NULL) { - free(const_buf); - const_buf = NULL; - } - - if (mm_add_match_list("SIDE", &cmd->cmd_dest_list)) { - mms_trace(MMS_DEVP, "SIDE " - "already in dest list"); - } else { - cmd->cmd_dest_num ++; - } - - - mms_trace(MMS_DEVP, " lookup cartid"); - work = NULL; - MMS_PN_LOOKUP(value, cart, NULL, MMS_PN_STRING, &work); - cartid = value->pn_string; - - const_buf = mms_strapp(const_buf, - "(\"SIDE\".\"CartridgeID\" = '%s' AND ", - cartid); - - mms_trace(MMS_DEVP, " lookup sidename"); - - MMS_PN_LOOKUP(value, cart, NULL, MMS_PN_STRING, &work); - sidename = value->pn_string; - const_buf = mms_strapp(const_buf, - "\"SIDE\".\"SideName\" = '%s') ", - sidename); - if (mm_add_match_list(const_buf, &cmd->cmd_const_list)) { - mms_trace(MMS_DEVP, "SIDE constraint " - "already in const list"); - } else { - cmd->cmd_const_num ++; - } - if (const_buf != NULL) { - free(const_buf); - const_buf = NULL; - } - - - } else if (cart = mms_pn_lookup(cmd->cmd_root, "cart", - MMS_PN_CLAUSE, &work)) { - mms_trace(MMS_DEVP, - "move command cart clause"); - mms_trace(MMS_DEVP, " lookup cartpcl"); - MMS_PN_LOOKUP(value, cart, NULL, MMS_PN_STRING, NULL); - cartpcl = value->pn_string; - - mms_trace(MMS_DEVP, " lookup slottype"); - MMS_PN_LOOKUP(next, cart, "cart", MMS_PN_CLAUSE, &work); - MMS_PN_LOOKUP(value, next, NULL, MMS_PN_STRING, NULL); - slottype = value->pn_string; - - mms_trace(MMS_DEVP, " lookup sidename"); - MMS_PN_LOOKUP(next, cart, "cart", MMS_PN_CLAUSE, &work); - MMS_PN_LOOKUP(value, next, NULL, MMS_PN_STRING, NULL); - sidename = value->pn_string; - - if (const_buf != NULL) { - free(const_buf); - const_buf = NULL; - } - if (mm_add_match_list("SIDE", - &cmd->cmd_dest_list)) { - mms_trace(MMS_DEVP, "SIDE " - "already in dest list"); - } else { - cmd->cmd_dest_num ++; - } - if (mm_add_match_list("CARTRIDGE", - &cmd->cmd_dest_list)) { - mms_trace(MMS_DEVP, "CARTRIDGE " - "already in dest list"); - } else { - cmd->cmd_dest_num ++; - } - if (mm_add_match_list("SLOTTYPE", - &cmd->cmd_dest_list)) { - mms_trace(MMS_DEVP, "SLOTTYPE " - "already in dest list"); - } else { - cmd->cmd_dest_num ++; - } - const_buf = mms_strapp(const_buf, - "(\"CARTRIDGE\".\"CartridgePCL\" = '%s' AND " - "\"SLOTTYPE\".\"SlotTypeName\" = '%s' AND " - "\"SIDE\".\"SideName\" = '%s') ", - cartpcl, - slottype, sidename); - if (mm_add_match_list(const_buf, &cmd->cmd_const_list)) { - mms_trace(MMS_DEVP, "cart constraint " - "already in const list"); - } else { - cmd->cmd_const_num ++; - } - - } else { - mms_trace(MMS_DEVP, - "move command match clause"); - - if (mm_get_dest(mm_wka, cmd)) { - /* Command does not have a match/volname clause */ - mms_trace(MMS_DEVP, "No match/volname Clause???"); - } else { - /* TEMP - Trace out our dest info */ - mms_trace(MMS_DEVP, - "Dest count is %d", cmd->cmd_dest_num); - mm_print_char_list(&cmd->cmd_dest_list); - } - if (mm_get_const(mm_wka, cmd)) { - /* Command does not have a match/volname clause */ - mms_trace(MMS_DEVP, "No match/volname Clause???"); - } else { - /* TEMP - Trace out our const info */ - mms_trace(MMS_DEVP, - "Const count is %d", cmd->cmd_const_num); - mm_print_char_list(&cmd->cmd_const_list); - } - - } - - /* cartridge */ - query = "SELECT \"SLOT\".\"SlotName\",\"CARTRIDGE\".\"CartridgePCL\"," - "\"SIDE\".\"SideName\",\"CARTRIDGE\".\"LibraryName\"," - "\"CARTRIDGE\".\"CartridgeState\" FROM "; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, strlen(query) + 1); - - if (mm_add_match_list("SLOT", &cmd->cmd_source_list)) { - mms_trace(MMS_DEVP, "SLOT already in source list"); - } else { - cmd->cmd_source_num ++; - } - if (mm_add_match_list("CARTRIDGE", &cmd->cmd_source_list)) { - mms_trace(MMS_DEVP, "CARTRIDGE already in source list"); - } else { - cmd->cmd_source_num ++; - } - if (mm_add_match_list("SIDE", &cmd->cmd_source_list)) { - mms_trace(MMS_DEVP, "SIDE already in source list"); - } else { - cmd->cmd_source_num ++; - } - - if (mm_sql_from_where(cmd, db)) { - mms_trace(MMS_ERR, - "mm_move_cmd_func: " - "db error creating helper functions"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - mm_sql_order(cmd); - mm_sql_number(cmd); - - - - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_DATA) { - goto db_error; - } - rows = PQntuples(db->mm_db_results); - if (rows == 0) { - mm_clear_db(&db->mm_db_results); - if (cart) { - mm_response_error(cmd, - ECLASS_EXIST, - ENOSUCHCART, - MM_5069_MSG, - NULL); - - } else { - mm_response_error(cmd, - ECLASS_EXIST, - ENOMATCH, - MM_5069_MSG, - NULL); - } - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } else if (rows > 1) { - mm_clear_db(&db->mm_db_results); - mm_response_error(cmd, - ECLASS_EXPLICIT, - ETOOMANY, - MM_5070_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - cart_results = db->mm_db_results; - - slotname = PQgetvalue(cart_results, 0, 0); - cartpcl = PQgetvalue(cart_results, 0, 1); - sidename = PQgetvalue(cart_results, 0, 2); - libname = PQgetvalue(cart_results, 0, 3); - state = PQgetvalue(cart_results, 0, 4); - - if (strcmp(state, "identified") == 0) { - mm_clear_db(&cart_results); - mm_response_error(cmd, - ECLASS_CONFIG, - ECARTNOTLOCATED, - MM_5071_MSG, - "pcl", - cartpcl, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - if (mm_db_exec(HERE, db, "SELECT \"LMName\" FROM \"LM\" WHERE " - "\"LibraryName\" = '%s'", libname) != MM_DB_DATA) { - mm_clear_db(&cart_results); - goto db_error; - } - rows = PQntuples(db->mm_db_results); - if (rows == 0) { - mm_clear_db(&db->mm_db_results); - mm_clear_db(&cart_results); - mm_response_error(cmd, - ECLASS_CONFIG, - ELIBNOLMCONFIGURED, - MM_5072_MSG, - "lib", - libname, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } else if (rows > 1) { - mm_clear_db(&db->mm_db_results); - mm_clear_db(&cart_results); - mm_system_error(cmd, - "row number mismatch, " - "to many device manager rows returned"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - lm_results = db->mm_db_results; - lmname = PQgetvalue(lm_results, 0, 0); - - /* check for online library */ - if (mm_db_exec(HERE, db, "SELECT " - "\"LIBRARY\".\"LibraryStateSoft\",\"LM\".\"LMStateSoft\" " - "FROM \"LIBRARY\",\"LM\" " - "WHERE (\"LIBRARY\".\"LibraryName\" = '%s' AND " - "\"LIBRARY\".\"LMName\" = '%s') AND " - "(\"LM\".\"LibraryName\" = '%s' AND " - "\"LM\".\"LMName\" = '%s')", - libname, lmname, libname, lmname) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - mm_clear_db(&lm_results); - mm_clear_db(&cart_results); - goto db_error; - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), - "ready") != 0 || - strcmp(PQgetvalue(db->mm_db_results, 0, 1), - "ready") != 0) { - mm_response_error(cmd, - ECLASS_RETRY, - ELMNOTREADY, - MM_5073_MSG, - "lm", - lmname, - NULL); - mm_clear_db(&db->mm_db_results); - mm_clear_db(&lm_results); - mm_clear_db(&cart_results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - mm_clear_db(&db->mm_db_results); - mm_clear_db(&lm_results); - - /* issue lm move command */ - mm_get_uuid(taskid); - /* build lm scan cmd */ - query = "move task[\"%s\"] from[\"%s\" \"%s\" \"%s\"] " - "to[\"%s\" \"%s\"]"; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, strlen(query) + - strlen(taskid) + strlen(slotname) + strlen(cartpcl) + - strlen(sidename) + strlen(toslot) + strlen(sidename) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, query, - taskid, slotname, cartpcl, sidename, toslot, sidename); - - mms_trace(MMS_DEVP, "%s", cmd->cmd_buf); - - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_DONE; - goto end; - -db_error: - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - mms_trace(MMS_ERR, - "move command not_found"); - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - - rc = MM_CMD_ERROR; - goto end; -end: - - return (rc); -} - - - - - - - - -int -mm_shutdown_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *clause; - mms_par_node_t *value; - mms_par_node_t *tw; - char *type = NULL; - char *restart = NULL; - - - mms_trace(MMS_DEVP, "mm shutdown command %d", cmd->cmd_state); - - if (mm_privileged(mm_wka, cmd) == MM_PRIV_STANDARD) { - return (MM_CMD_ERROR); - } - - tw = NULL; - MMS_PN_LOOKUP(clause, cmd->cmd_root, "type", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, clause, NULL, MMS_PN_KEYWORD, &tw); - if (strcmp(value->pn_string, "restart") == 0) { - restart = value->pn_string; - } else { - type = value->pn_string; - } - if (value = mms_pn_lookup(clause, NULL, MMS_PN_KEYWORD, &tw)) { - if (strcmp(value->pn_string, "restart") == 0) { - restart = value->pn_string; - } else { - type = value->pn_string; - } - } - - if (value = mms_pn_lookup(cmd->cmd_root, "restart", - MMS_PN_KEYWORD, NULL)) { - restart = value->pn_string; - } - - if (type) - mms_trace(MMS_DEVP, "type %s", type); - if (restart) - mms_trace(MMS_DEVP, "kw %s", restart); - - /* - * TBD: Args: nonewapps, nonewmounts, abortqueue, force, restart. - * Send device managers activate disable - */ - - mm_exiting = 1; - close(mm_wka->mm_data->mm_service_fd); - mm_wka->mm_data->mm_service_fd = -1; - - mms_trace(MMS_DEVP, "success"); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_DONE); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - - -} - - -int -mm_rename_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *vol; - mms_par_node_t *value; - mms_par_node_t *work; - int row; - int rows; - int count; - int index; - char **volname = NULL; - PGresult *results; - int i; - mm_db_t *db = &mm_wka->mm_data->mm_db; - cci_t *conn = &mm_wka->wka_conn; - - char *buf = NULL; - char *query = NULL; - - - - - mms_trace(MMS_DEVP, "sql trans rename cmd"); - - /* - * Get volume names. - */ - work = NULL; - count = 0; - MMS_PN_LOOKUP(vol, cmd->cmd_root, "newvolname", - MMS_PN_CLAUSE, NULL); - while (mms_pn_lookup(vol, NULL, MMS_PN_STRING, &work) != NULL) { - count++; - } - if ((volname = (char **) malloc(sizeof (char *) * count) + 1) == NULL) { - MM_ABORT_NO_MEM(); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - work = NULL; - index = 0; - for (value = mms_pn_lookup(vol, NULL, MMS_PN_STRING, &work); - value != NULL && index < count; - value = mms_pn_lookup(vol, NULL, MMS_PN_STRING, &work)) { - volname[index++] = value->pn_string; - } - for (index = 0; index < count; index++) - mms_trace(MMS_DEVP, "newvolname[%d] %s", index, volname[index]); - - /* check for duplicate volumes */ - for (index = 0; index < count; index++) { - for (i = 0; i < count; i++) { - if (i != index && - strcmp(volname[index], volname[i]) == 0) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, - &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + - strlen(cmd->cmd_task) + - strlen(ECLASS_INVALID) + - strlen(EVOLNAMEREWRITE) + 1); - (void) snprintf(cmd->cmd_buf, - cmd->cmd_bufsize, RESPONSE_ERROR, - cmd->cmd_task, ECLASS_INVALID, - EVOLNAMEREWRITE); - free(volname); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - } - - /* - * Find distinct volumes to rename. - */ - mms_trace(MMS_DEVP, "find"); - - mm_clear_source(cmd); - mm_clear_dest(cmd); - mm_clear_const(cmd); - (void) mm_get_dest(mm_wka, cmd); - (void) mm_get_const(mm_wka, cmd); - - /* Add the VOLUME constraint */ - buf = mms_strapp(buf, - "(\"VOLUME\".\"ApplicationName\" = '%s') ", - conn->cci_client); - - - if (!mm_add_match_list(buf, &cmd->cmd_const_list)) { - cmd->cmd_const_num ++; - } - - free(buf); - if (!mm_add_match_list("VOLUME", &cmd->cmd_dest_list)) { - cmd->cmd_dest_num ++; - } - - query = "SELECT DISTINCT \"VOLUME\".\"CartridgeID\", " - "\"VOLUME\".\"VolumeName\" FROM "; - - if (!mm_add_match_list("VOLUME", &cmd->cmd_source_list)) { - cmd->cmd_source_num ++; - } - - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, strlen(query) + 1); - - if (mm_sql_from_where(cmd, db)) { - mms_trace(MMS_ERR, - "mm_rename_cmd_func: " - "db error creating helper functions"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mm_sql_order(cmd); - mm_sql_number(cmd); - - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - free(volname); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - results = db->mm_db_results; - rows = PQntuples(results); - - /* - * Check for mounted or stale volumes. - */ - for (row = 0; row < rows; row++) { - - if (mm_db_exec(HERE, db, "SELECT \"CartridgeID\"," - "\"VolumeName\" FROM \"MOUNTLOGICAL\" WHERE " - "\"CartridgeID\" = '%s'", - PQgetvalue(results, row, 0)) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&results); - free(volname); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) > 0) { - mm_clear_db(&results); - mm_clear_db(&db->mm_db_results); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(SIMPLE_RESPONSE_ERROR_TEXT) + - strlen(cmd->cmd_task) + strlen(ECLASS_EXIST) + - strlen(EVOLINUSE) + - strlen(PQgetvalue(results, row, 1)) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - SIMPLE_RESPONSE_ERROR_TEXT, - cmd->cmd_task, ECLASS_EXIST, EVOLINUSE, - PQgetvalue(results, row, 1)); - free(volname); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - - if (mm_db_exec(HERE, db, "SELECT \"CartridgeID\"," - "\"VolumeName\" FROM \"STALEHANDLE\" WHERE " - "\"CartridgeID\" = '%s'", - PQgetvalue(results, row, 0)) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&results); - mm_clear_db(&db->mm_db_results); - free(volname); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) > 0) { - mm_clear_db(&results); - mm_clear_db(&db->mm_db_results); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(SIMPLE_RESPONSE_ERROR_TEXT) + - strlen(cmd->cmd_task) + - strlen(ECLASS_EXIST) + - strlen(EVOLINUSE) + - strlen(PQgetvalue(results, row, 1)) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - SIMPLE_RESPONSE_ERROR_TEXT, - cmd->cmd_task, ECLASS_EXIST, EVOLINUSE, - PQgetvalue(results, row, 1)); - free(volname); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - } - - /* - * Rename volumes. - */ - for (row = 0; row < rows; row++) { - /* check for unique volume name in apps namespace. */ - if (mm_db_exec(HERE, db, "SELECT \"VolumeName\" FROM " - "\"VOLUME\" WHERE \"ApplicationName\" = '%s' AND " - "\"VolumeName\" = '%s'", - conn->cci_client, - volname[row]) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&results); - free(volname); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) != 0) { - mm_clear_db(&db->mm_db_results); - mm_clear_db(&results); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(SIMPLE_RESPONSE_ERROR_TEXT) + - strlen(cmd->cmd_task) + - strlen(ECLASS_EXIST) + - strlen(ERENAMEDVOLEXISTS) + - strlen(volname[row]) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - SIMPLE_RESPONSE_ERROR_TEXT, - cmd->cmd_task, ECLASS_EXIST, - ERENAMEDVOLEXISTS, volname[row]); - free(volname); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - - if (mm_db_exec(HERE, db, "UPDATE \"VOLUME\" SET " - "\"VolumeName\" = '%s' WHERE \"CartridgeID\" = '%s'", - volname[row], PQgetvalue(results, row, 0)) != MM_DB_OK) { - mm_clear_db(&results); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + - strlen(cmd->cmd_task) + - strlen(ECLASS_INTERNAL) + - strlen(ETRANSACTIONFAILED) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INTERNAL, ETRANSACTIONFAILED); - free(volname); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - mm_clear_db(&results); - free(volname); - - /* - * Generate report. - */ - mm_path_match_report(cmd, db); - - cmd->cmd_remove = 1; - mm_send_response(mm_wka->mm_wka_conn, cmd); - return (MM_CMD_DONE); - - -no_mem: - MM_ABORT_NO_MEM(); - free(volname); - return (MM_CMD_ERROR); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - free(volname); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); -} - - - - -int -mm_deallocate_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *vol; - mms_par_node_t *arg; - int row; - int rows; - int count; - int index; - char **volname = NULL; - char *report_buf = NULL; - PGresult *results; - mm_db_t *db = &mm_wka->mm_data->mm_db; - cci_t *conn = &mm_wka->wka_conn; - char *query; - char *buf = NULL; - - - mms_trace(MMS_DEVP, "sql trans deallocate cmd"); - /* - * Generate report and save it before the delete. - */ - mms_trace(MMS_DEVP, "report clause"); - - mm_path_match_report(cmd, db); - - - report_buf = cmd->cmd_buf; - cmd->cmd_bufsize = SQL_CMD_BUF_INCR; - if ((cmd->cmd_buf = (char *)malloc(cmd->cmd_bufsize)) == NULL) { - MM_ABORT_NO_MEM(); - free(report_buf); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - /* - * Get volume names from the command. - */ - mms_trace(MMS_DEVP, "volnames"); - count = 0; - if (vol = mms_pn_lookup(cmd->cmd_root, "volname", - MMS_PN_CLAUSE, NULL)) { - mms_list_foreach(&vol->pn_arglist, arg) { - count++; - } - if (count && (volname = (char **) malloc(sizeof (char *) * - count)) == NULL) { - MM_ABORT_NO_MEM(); - free(report_buf); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - index = 0; - mms_list_foreach(&vol->pn_arglist, arg) { - volname[index++] = arg->pn_string; - } - for (index = 0; index < count; index++) { - mms_trace(MMS_DEVP, - "volname[%d] %s", index, volname[index]); - } - } - /* - * Get the volumes cartridge ids. - */ - mms_trace(MMS_DEVP, "partition"); - - mm_clear_source(cmd); - mm_clear_dest(cmd); - mm_clear_const(cmd); - (void) mm_get_dest(mm_wka, cmd); - (void) mm_get_const(mm_wka, cmd); - - /* Add the VOLUME constraint */ - buf = mms_strapp(buf, - "(\"VOLUME\".\"ApplicationName\" = '%s') ", - conn->cci_client); - - if (!mm_add_match_list(buf, &cmd->cmd_const_list)) { - cmd->cmd_const_num ++; - } - - free(buf); - if (!mm_add_match_list("VOLUME", &cmd->cmd_dest_list)) { - cmd->cmd_dest_num ++; - } - - query = "SELECT DISTINCT \"VOLUME\".\"CartridgeID\" " - "FROM "; - - if (!mm_add_match_list("VOLUME", &cmd->cmd_source_list)) { - cmd->cmd_source_num ++; - } - - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, strlen(query) + 1); - - if (mm_sql_from_where(cmd, db)) { - mms_trace(MMS_ERR, - "mm_deallocate_cmd_func: " - "db error creating helper functions"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mm_sql_order(cmd); - mm_sql_number(cmd); - - /* delete volumes, mountlogical foreign key prevents mounted delete */ - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - free(volname); - free(report_buf); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - /* - * Delete volumes. - */ - results = db->mm_db_results; - rows = PQntuples(results); - for (row = 0; row < rows; row++) { - if (mm_db_exec(HERE, db, "DELETE FROM \"VOLUME\" " - "WHERE \"CartridgeID\" = '%s'", - PQgetvalue(results, row, 0)) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&results); - free(volname); - free(report_buf); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (mm_db_exec(HERE, db, "UPDATE \"PARTITION\" SET " - "\"PartitionAllocatable\" = 'true' WHERE " - "\"CartridgeID\" = '%s'", - PQgetvalue(results, row, 0)) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&results); - free(volname); - free(report_buf); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - for (row = 0; row < rows; row++) { - - if (mm_notify_add_volumedelete(mm_wka, - cmd, - PQgetvalue(results, row, 0), - db)) { - mms_trace(MMS_ERR, - "mm_deallocate_cmd_func: " - "error adding volume delete event"); - } - mms_trace(MMS_INFO, - "VOLUME, %s deallocated by %s %s", - PQgetvalue(results, row, 0), - conn->cci_client, - conn->cci_instance); - - } - - - mm_clear_db(&results); - free(volname); - - free(cmd->cmd_buf); - cmd->cmd_buf = NULL; - cmd->cmd_bufsize = 0; - - cmd->cmd_buf = report_buf; - cmd->cmd_bufsize = strlen(report_buf) + 1; - cmd->cmd_remove = 1; - mm_send_response(mm_wka->mm_wka_conn, cmd); - return (MM_CMD_DONE); - -no_mem: - MM_ABORT_NO_MEM(); - free(volname); - free(report_buf); - return (MM_CMD_ERROR); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - free(volname); - free(report_buf); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); -} - - -int -mm_allocate_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *vol; - mms_par_node_t *who; - mms_par_node_t *value; - mms_par_node_t *work; - int row; - int rows; - int count; - int index; - char **volname = NULL; - PGresult *results; - int num; - int i; - mm_db_t *db = &mm_wka->mm_data->mm_db; - cci_t *conn = &mm_wka->wka_conn; - mm_range_t range; - char *query; - char *constraint; - - char *app_name = NULL; - char *ai_name = NULL; - - char *db_buf = NULL; - - - mms_trace(MMS_DEVP, "mm allocate cmd"); - /* Get who clause */ - work = NULL; - - - - /* who clause */ - who = mms_pn_lookup(cmd->cmd_root, "who", - MMS_PN_CLAUSE, NULL); - if (who != NULL) { - - if ((value = mms_pn_lookup(who, - NULL, - MMS_PN_STRING, - &work)) != NULL) { - app_name = value->pn_string; - mms_trace(MMS_DEVP, "Use %s as application name", - app_name); - if (cmd->wka_ptr->wka_privilege == MM_PRIV_STANDARD) { - /* for standard priv, */ - /* check that app_name is the client's */ - if (strcmp(app_name, conn->cci_client) != 0) { - mms_trace(MMS_DEVP, - "appcliation name in who does" - " not match client application"); - mm_response_error(cmd, - ECLASS_LANGUAGE, - "ECLAUSENOPRIVILEGE", - MM_5082_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - } - if ((value = mms_pn_lookup(who, - NULL, - MMS_PN_STRING, - &work)) != NULL) { - ai_name = value->pn_string; - mms_trace(MMS_DEVP, "Use %s as ai name", - ai_name); - if (cmd->wka_ptr->wka_privilege == MM_PRIV_STANDARD) { - /* for standard priv, */ - /* check that app_name is the client's */ - if (strcmp(ai_name, conn->cci_instance) != 0) { - mms_trace(MMS_DEVP, - "instace name in who does" - " not match client instance'"); - mm_response_error(cmd, - ECLASS_LANGUAGE, - "ECLAUSENOPRIVILEGE", - MM_5082_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - } else { - ai_name = NULL; - mms_trace(MMS_DEVP, "'any' instance"); - } - } else { - app_name = conn->cci_client; - ai_name = NULL; - mms_trace(MMS_DEVP, "Use %s as application name, any instance", - app_name); - } - - /* - * Get volume names. - */ - work = NULL; - count = 0; - MMS_PN_LOOKUP(vol, cmd->cmd_root, "newvolname", - MMS_PN_CLAUSE, NULL); - while (mms_pn_lookup(vol, NULL, MMS_PN_STRING, &work) != NULL) { - count++; - } - if ((volname = (char **) malloc(sizeof (char *) * count)) == NULL) { - MM_ABORT_NO_MEM(); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - work = NULL; - index = 0; - for (value = mms_pn_lookup(vol, NULL, MMS_PN_STRING, &work); - value != NULL && index < count; - value = mms_pn_lookup(vol, NULL, MMS_PN_STRING, &work)) { - volname[index++] = value->pn_string; - } - for (index = 0; index < count; index++) { - mms_trace(MMS_DEVP, "newvolname[%d] %s", index, volname[index]); - - /* check command for unique volnames */ - for (i = 0; i < count; i++) { - if (i != index && - strcmp(volname[index], volname[i]) == 0) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, - &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + - strlen(cmd->cmd_task) + - strlen(ECLASS_LANGUAGE) + - strlen(EINVALCLAUSEARG) + 1); - (void) snprintf(cmd->cmd_buf, - cmd->cmd_bufsize, - RESPONSE_ERROR, - cmd->cmd_task, - ECLASS_LANGUAGE, - EINVALCLAUSEARG); - free(volname); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - } - - /* check number-clause and newvolname-clause counts */ - if (mm_get_range(cmd, &range)) { - mms_trace(MMS_DEVP, "number-clause range parse error"); - mm_response_error(cmd, - ECLASS_LANGUAGE, - ESYNTAX, - MM_5083_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if ((range.mm_range_type == MM_RANGE_NUMS && - (range.mm_range_last - range.mm_range_first + 1) != count) || - (range.mm_range_type == MM_RANGE_A_NUM && count != 1)) { - - mms_trace(MMS_DEVP, "number-clause error, " - "type %d range %d %d count %d error", - range.mm_range_type, - range.mm_range_first, - range.mm_range_last, - count); - mm_response_error(cmd, - ECLASS_INVALID, - ENEWVOLNAMECOUNT, - MM_5084_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - /* - * Find distinct suitable volume partitions. - */ - - mms_trace(MMS_DEVP, "Find Partitions"); - - if (mm_get_dest(mm_wka, cmd)) { - /* Command does not have a match/volname clause */ - mms_trace(MMS_DEVP, "No match Clause???"); - } else { - /* TEMP - Trace out our dest info */ - mms_trace(MMS_DEVP, "Dest count is %d", cmd->cmd_dest_num); - mm_print_char_list(&cmd->cmd_dest_list); - } - - if (mm_get_const(mm_wka, cmd)) { - /* Command does not have a match/volname clause */ - mms_trace(MMS_DEVP, "No match Clause???"); - } else { - /* TEMP - Trace out our const info */ - mms_trace(MMS_DEVP, "Const count is %d", cmd->cmd_const_num); - mm_print_char_list(&cmd->cmd_const_list); - } - - if (mm_add_match_list("PARTITION", &cmd->cmd_dest_list)) { - mms_trace(MMS_DEVP, "PARTITION already in dest list"); - } else { - cmd->cmd_dest_num ++; - } - constraint = "(\"PARTITION\".\"PartitionAllocatable\" = 'true')"; - if (mm_add_match_list(constraint, &cmd->cmd_const_list)) { - mms_trace(MMS_DEVP, "PARTITION allocatable " - "already in constraint list"); - } else { - cmd->cmd_const_num ++; - } - - if (cmd->wka_ptr->wka_privilege != MM_PRIV_STANDARD) { - mms_trace(MMS_DEVP, - "Privileged app, skip " - "CARTRIDGEGROUPAPPLICATION constraint"); - } else { - /* if this is not a privilaged app */ - /* Enforce CARTRIDGEGROUPAPPLICATION */ - mms_trace(MMS_DEVP, - "Non-Privileged app, add CARTRIDGEGROUPAPPLICATION"); - - if (mm_add_match_list("CARTRIDGEGROUPAPPLICATION", - &cmd->cmd_dest_list)) { - mms_trace(MMS_DEVP, "CARTRIDGEGROUPAPPLICATION already " - "in dest list"); - } else { - cmd->cmd_dest_num ++; - } - - constraint = mms_strnew("(\"CARTRIDGEGROUPAPPLICATION\"." - "\"ApplicationName\" = '%s')", conn->cci_client); - - if (mm_add_match_list(constraint, &cmd->cmd_const_list)) { - mms_trace(MMS_DEVP, "CARTRIDGEGROUPAPPLICATION appname " - "already in constraint list"); - } else { - cmd->cmd_const_num ++; - } - free(constraint); - } - - - if (mm_add_char("PARTITION", &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_allocate_cmd_func: " - "out of mem creating source list"); - mm_system_error(cmd, - "out of mem creating source list"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - free(volname); - return (MM_CMD_ERROR); - } - - - query = "select distinct \"PARTITION\".\"CartridgeID\"," - "\"PARTITION\".\"SideName\"," - "\"PARTITION\".\"PartitionName\" from "; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, strlen(query) + 1); - (void) strlcpy(cmd->cmd_buf, query, cmd->cmd_bufsize); - cmd->cmd_source_num = 1; - - if (mm_sql_from_where(cmd, db)) { - mms_trace(MMS_ERR, - "mm_allocate_cmd_func: " - "db error creating helper functions"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - free(volname); - return (MM_CMD_ERROR); - } - mm_sql_order(cmd); - - mm_sql_number(cmd); - - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&db->mm_db_results); - free(volname); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - rows = PQntuples(db->mm_db_results); - results = db->mm_db_results; - - /* each volname needs a partition */ - if (rows < count) { - /* general error, this means the resource is already used */ - mms_trace(MMS_DEVP, - "partitions found %d, partitions needed %d", - rows, count); - mm_response_error(cmd, - ECLASS_EXPLICIT, - ENOTENOUGHPARTITIONS, - MM_5085_MSG, - NULL); - mm_clear_db(&results); - free(volname); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - /* - * Allocate one volume per partition. - */ - for (row = 0; row < rows && row < count; row++) { - - /* check for unique volume name in apps namespace. */ - if (mm_db_exec(HERE, db, "SELECT \"VolumeName\" FROM " - "\"VOLUME\" WHERE \"ApplicationName\" = '%s' AND " - "\"VolumeName\" = '%s';", - app_name, - volname[row]) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&results); - free(volname); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if ((num = PQntuples(db->mm_db_results)) != 0) { - mms_trace(MMS_DEVP, "volume count %d", num); - for (i = 0; i < num; i++) { - mms_trace(MMS_DEVP, "volume[%d] %s", i, - PQgetvalue(db->mm_db_results, i, 0)); - } - mm_clear_db(&db->mm_db_results); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(SIMPLE_RESPONSE_ERROR_TEXT) + - strlen(cmd->cmd_task) + strlen(ECLASS_EXIST) + - strlen(ENEWVOLEXISTS) + - strlen(volname[row]) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - SIMPLE_RESPONSE_ERROR_TEXT, - cmd->cmd_task, ECLASS_EXIST, ENEWVOLEXISTS, - volname[row]); - mm_clear_db(&results); - free(volname); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - - - - - if (ai_name == NULL) { - db_buf = mms_strapp(db_buf, - "INSERT INTO \"VOLUME\" " - "(\"ApplicationName\", " - "\"VolumeName\", \"CartridgeID\", " - "\"SideName\", " - "\"PartitionName\") VALUES " - "('%s', '%s', '%s', '%s', '%s')", - app_name, - volname[row], - PQgetvalue(results, row, 0), - PQgetvalue(results, row, 1), - PQgetvalue(results, row, 2)); - } else { - db_buf = mms_strapp(db_buf, - "INSERT INTO \"VOLUME\" " - "(\"ApplicationName\", " - "\"VolumeName\", \"CartridgeID\", " - "\"SideName\", \"PartitionName\", " - "\"AIName\") VALUES " - "('%s', '%s', '%s', '%s', '%s', '%s')", - app_name, - volname[row], - PQgetvalue(results, row, 0), - PQgetvalue(results, row, 1), - PQgetvalue(results, row, 2), - ai_name); - } - if (mm_db_exec(HERE, db, db_buf) != MM_DB_OK) { - free(db_buf); - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&results); - free(volname); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - free(db_buf); - db_buf = NULL; - - if (mm_db_exec(HERE, db, "UPDATE \"PARTITION\" SET " - "\"PartitionAllocatable\" = 'false' WHERE " - "\"CartridgeID\" = '%s' and " - "\"PARTITION\".\"PartitionName\" = '%s';", - PQgetvalue(results, row, 0), - PQgetvalue(results, row, 2)) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&results); - free(volname); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (db->mm_db_count != 1) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(SIMPLE_RESPONSE_ERROR_TEXT) + - strlen(cmd->cmd_task) + - strlen(ECLASS_SUBOP) + - strlen(EPARTITIONSTATECHANGE) + - strlen(PQgetvalue(results, row, 0)) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - SIMPLE_RESPONSE_ERROR_TEXT, - cmd->cmd_task, - ECLASS_SUBOP, - EPARTITIONSTATECHANGE, - PQgetvalue(results, row, 0)); - mm_clear_db(&results); - free(volname); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (mm_db_exec(HERE, db, "UPDATE \"CARTRIDGE\" SET " - "\"ApplicationName\" = '%s' WHERE " - "\"CARTRIDGE\".\"CartridgeID\" = '%s';", - app_name, - PQgetvalue(results, row, 0)) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&results); - free(volname); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (db->mm_db_count != 1) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(SIMPLE_RESPONSE_ERROR_TEXT) + - strlen(cmd->cmd_task) + - strlen(ECLASS_SUBOP) + - strlen(ECARTRIDGESTATECHANGE) + - strlen(PQgetvalue(results, row, 0)) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - SIMPLE_RESPONSE_ERROR_TEXT, - cmd->cmd_task, - ECLASS_SUBOP, - ECARTRIDGESTATECHANGE, - PQgetvalue(results, row, 0)); - mm_clear_db(&results); - free(volname); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - - for (row = 0; row < rows && row < count; row++) { - - if (mm_notify_add_volumeadd(mm_wka, cmd, volname[row], - PQgetvalue(results, row, 0), - db)) { - mms_trace(MMS_ERR, - "mm_allocate_cmd_func: " - "error adding volume add event"); - } - mms_trace(MMS_INFO, - "VOLUME, %s allocated by %s %s", - volname[row], - conn->cci_client, - conn->cci_instance); - - } - mm_clear_db(&results); - free(volname); - - - - /* - * Generate report. - */ - mm_path_match_report(cmd, db); - cmd->cmd_remove = 1; - mm_send_response(mm_wka->mm_wka_conn, cmd); - return (MM_CMD_DONE); - -no_mem: - MM_ABORT_NO_MEM(); - free(volname); - return (MM_CMD_ERROR); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - free(volname); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); -} - -int -mm_privilege_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *arg; - mms_par_node_t *level; - mm_db_t *db = &mm_wka->mm_data->mm_db; - cci_t *conn = &mm_wka->wka_conn; - - - mms_trace(MMS_DEVP, "mm_privilege_cmd_func"); - MMS_PN_LOOKUP(arg, cmd->cmd_root, "level", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(level, arg, NULL, MMS_PN_KEYWORD, NULL); - - if (mm_db_exec(HERE, db, "SELECT \"PrivilegeChangeable\" " - "FROM \"AI\" WHERE \"ApplicationName\" = '%s' AND " - "\"AIName\" = '%s';", conn->cci_client, - conn->cci_instance) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_INTERNAL) + strlen(EDATABASE) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INTERNAL, EDATABASE); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), "t") != 0) { - mm_clear_db(&db->mm_db_results); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_PERMPRIV) + - strlen(EPRIVCHANGEDISALLOWED) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_PERMPRIV, EPRIVCHANGEDISALLOWED); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - - if (strcmp(level->pn_string, SYSTEM_PRIV) == 0) { - /* only mms admin can become system level privileged */ - if (strcmp(mm_wka->wka_conn.cci_client, MM_APP) != 0 && - strcmp(mm_wka->wka_conn.cci_instance, MM_ADMIN) != 0) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + - strlen(cmd->cmd_task) + - strlen(ECLASS_PERMPRIV) + - strlen(EPRIVNOTMMSADMIN) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_PERMPRIV, - EPRIVNOTMMSADMIN); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mm_wka->wka_privilege = MM_PRIV_SYSTEM; - } else if (strcmp(level->pn_string, ADMINISTRATOR) == 0) { - mm_wka->wka_privilege = MM_PRIV_ADMIN; - } else { - mm_wka->wka_privilege = MM_PRIV_STANDARD; - } - mms_trace(MMS_DEVP, "privilege level changed to %s", - level->pn_string); - - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_DONE); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); -} - - -int -mm_locale_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *arg; - mms_par_node_t *lang; - mms_par_node_t *flavor; - mms_par_node_t *value; - mms_par_node_t *work = NULL; - - mms_trace(MMS_DEVP, "sql trans locale cmd"); - MMS_PN_LOOKUP(arg, cmd->cmd_root, "protocol", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(lang, arg, NULL, MMS_PN_STRING, &work); - if (strcmp(lang->pn_string, LANG_EN) != 0) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_INVALID) + - strlen(ELANGNOTSUPPORTED) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INVALID, ELANGNOTSUPPORTED); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if ((flavor = mms_pn_lookup(arg, NULL, - MMS_PN_STRING, &work)) != NULL && - strcmp(flavor->pn_string, LANG_EN_US) != 0) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_INVALID) + - strlen(ELANGNOTSUPPORTED) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INVALID, ELANGNOTSUPPORTED); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - work = NULL; - for (arg = mms_pn_lookup(cmd->cmd_root, "sort", - MMS_PN_CLAUSE, &work); - arg != NULL; - arg = mms_pn_lookup(cmd->cmd_root, "sort", - MMS_PN_CLAUSE, &work)) { - MMS_PN_LOOKUP(value, arg, NULL, MMS_PN_STRING, NULL); - if (strcmp(LANG_EN_US, value->pn_string) != 0) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + - strlen(cmd->cmd_task) + - strlen(ECLASS_INVALID) + - strlen(ESORTNOTSUPPORTED) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INVALID, - ESORTNOTSUPPORTED); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_DONE); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - - - -} - -int -mm_attribute_check_helper(mm_command_t *cmd, char *object, char *attribute) { - char *buf = NULL; - int priv = 0; - char *err_buf = NULL; - mm_attribute_info_t *attr_info; - int i; - - mms_trace(MMS_DEVP, "Check value -> %s.%s", object, attribute); - - attr_info = &cmd->wka_ptr->mm_data->mm_attr_info; - buf = mms_strapp(buf, "%s.%s", object, attribute); - - /* - * Find the prvilege of this client - * system -> priv = 2 - * administrator -> priv = 1 - * standard -> priv = 0 - */ - - if (cmd->wka_ptr->wka_privilege == MM_PRIV_SYSTEM) { - /* level is system */ - priv = 2; - } else if (cmd->wka_ptr->wka_privilege == MM_PRIV_ADMIN) { - /* level is administrator */ - priv = 1; - } else { - /* level is standard */ - priv = 0; - } - - - /* Check Status Objects if not system priv */ - if (priv < 2) { - for (i = 0; i < MM_NUM_STATUS_OBJS; i ++) { - if (strcmp(object, attr_info->status_objs[i]) == 0) { - mms_trace(MMS_ERR, "Cannot modify "\ - "status object, %s", object); - mm_response_error(cmd, - ECLASS_PERMPRIV, - EOBJSYSATTRMODNOPRIV, - MM_5109_MSG, - "object", object, - "attribute", attribute, - NULL); - goto return_error; - } - } - - /* Check Status Attributes if not system priv */ - for (i = 0; i < MM_NUM_STATUS_ATTS; i ++) { - if (strcmp(buf, attr_info->status_atts[i]) == 0) { - mms_trace(MMS_ERR, "Cannot modify "\ - "status attribute, %s", buf); - mm_response_error(cmd, - ECLASS_PERMPRIV, - EOBJSYSATTRMODNOPRIV, - MM_5109_MSG, - "object", object, - "attribute", attribute, - NULL); - goto return_error; - } - } - } - - /* Restrict control attributes if this is non-privileged */ - if (priv < 1) { - if (strcmp(object, "SYSTEM") == 0) { - mms_trace(MMS_ERR, "Standard privilege client " - "may not modify the SYSTEM object"); - mm_response_error(cmd, - ECLASS_PERMPRIV, - EOBJSYSATTRMODNOPRIV, - MM_5108_MSG, - "object", object, - "attribute", attribute, - NULL); - goto return_error; - } - - for (i = 0; i < MM_NUM_CONTROL_ATTS; i ++) { - if (strcmp(buf, attr_info->control_atts[i]) == 0) { - mms_trace(MMS_ERR, "Cannot modify "\ - "control attribute, %s", buf); - mm_response_error(cmd, - ECLASS_PERMPRIV, - EOBJSYSATTRMODNOPRIV, - MM_5108_MSG, - "object", object, - "attribute", attribute, - NULL); - goto return_error; - } - } - } - - - goto return_ok; - - -no_mem: - mms_trace_flush(); - MM_ABORT_NO_MEM(); - return (1); - -return_ok: - - if (err_buf != NULL) - free(err_buf); - if (buf != NULL) - free(buf); - return (0); - - -return_error: - - if (err_buf != NULL) - free(err_buf); - if (buf != NULL) - free(buf); - return (1); - -} - - - - -int -mm_add_set_list(mms_list_t *list, int type, - char *obj, char *attr, char *value) { - cmd_set_t *mm_set_struct; - - mm_set_struct = (cmd_set_t *)calloc(1, sizeof (cmd_set_t)); - if (mm_set_struct == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc cmd_set_t: %s", - strerror(errno)); - return (1); - } - mm_set_struct->cmd_set_type = type; - switch (type) { - case MM_SET: - mm_set_struct->cmd_set_obj = strdup(obj); - mm_set_struct->cmd_set_attr = strdup(attr); - mm_set_struct->cmd_set_value = strdup(value); - break; - case MM_UNSET: - mm_set_struct->cmd_set_obj = strdup(obj); - mm_set_struct->cmd_set_attr = strdup(attr); - mm_set_struct->cmd_set_value = NULL; - break; - } - - mms_list_insert_tail(list, mm_set_struct); - - return (0); -} - -void -mm_print_set_list(mms_list_t *list) { - cmd_set_t *cur_set; - cmd_set_t *next; - - for (cur_set = mms_list_head(list); - cur_set != NULL; - cur_set = next) { - next = mms_list_next(list, cur_set); - switch (cur_set->cmd_set_type) { - case MM_SET: - /* This node is for a set clause */ - mms_trace(MMS_DEBUG, " SET %s.%s = %s", - cur_set->cmd_set_obj, - cur_set->cmd_set_attr, - cur_set->cmd_set_value); - break; - case MM_UNSET: - /* This node is for an unset clause */ - mms_trace(MMS_DEBUG, " UNSET %s.%s", - cur_set->cmd_set_obj, - cur_set->cmd_set_attr); - break; - } - } -} - -int -mm_in_set_list(mms_list_t *list, char *obj, char *attr) { - cmd_set_t *cur_set; - cmd_set_t *next; - for (cur_set = mms_list_head(list); - cur_set != NULL; - cur_set = next) { - next = mms_list_next(list, cur_set); - if ((strcmp(cur_set->cmd_set_obj, obj) == 0) && - (strcmp(cur_set->cmd_set_attr, attr) == 0)) { - return (1); - } - } - return (0); -} - - -int -mm_attribute_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - char *cmd_buf = NULL; - int rc; - int error; - char *info = NULL; - - /* For Set and Unset Lists */ - mms_list_t set_list; - cmd_set_t *cur_set; - cmd_set_t *next; - - /* Char list for OBJECT types */ - mms_list_t obj_list; - mm_char_list_t *cur_obj; - mm_char_list_t *next_obj; - - mms_trace(MMS_DEBUG, "mm_attribute_cmd_func"); - - /* Create the Set and Unset Struct Lists */ - - mms_list_create(&set_list, sizeof (cmd_set_t), - offsetof(cmd_set_t, cmd_set_next)); - mms_list_create(&obj_list, sizeof (mm_char_list_t), - offsetof(mm_char_list_t, mm_char_list_next)); - - /* Build the lists after parsing the clauses */ - - if (mm_get_set_clause(cmd, - &set_list, &obj_list)) { - mms_trace(MMS_ERR, - "mm_attribute_cmd_func: " - "error building structs from set clause"); - mm_system_error(cmd, - "error building structs from set clause"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - - - /* Get Dest Objects */ - if (mm_get_dest(mm_wka, cmd)) { - /* Command does not have a match/volname clause */ - mms_trace(MMS_DEVP, "No match/volname Clause???"); - } else { - /* TEMP - Trace out our dest info */ - mms_trace(MMS_DEVP, "Dest count is %d", cmd->cmd_dest_num); - mm_print_char_list(&cmd->cmd_dest_list); - } - /* Get constraint Objects */ - if (mm_get_const(mm_wka, cmd)) { - /* Command does not have a match/volname clause */ - mms_trace(MMS_DEVP, "No match/volname Clause???"); - } else { - /* TEMP - Trace out our const info */ - mms_trace(MMS_DEVP, "Const count is %d", cmd->cmd_const_num); - mm_print_char_list(&cmd->cmd_const_list); - } - - /* Do attribute check */ - /* Only for MMP clients */ - if (cmd->cmd_language == MM_LANG_MMP) { - /* Check if the creating attribtues is allowed */ - mms_trace(MMS_DEBUG, "Checking objects and attribtues"); - for (cur_set = mms_list_head(&set_list); - cur_set != NULL; - cur_set = next) { - next = mms_list_next(&set_list, cur_set); - /* Check if the attributes may be created */ - if (mm_db_create_attribute(db, - cur_set->cmd_set_obj, - cur_set->cmd_set_attr) != - MM_DB_OK) { - mms_trace(MMS_ERR, "Create attribute check " - "failed for %s.%s", - cur_set->cmd_set_obj, - cur_set->cmd_set_attr); - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - /* Check if the attributes may be modified */ - if (mm_attribute_check_helper(cmd, cur_set->cmd_set_obj, - cur_set->cmd_set_attr)) { - /* check_helper sets the correct error */ - /* Send and remove */ - mms_trace(MMS_ERR, "Attribute check failed"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - } - mms_trace(MMS_DEVP, "Done checking objects and attribtes"); - } else { - mms_trace(MMS_DEBUG, - "Skipping attribute check for non-MMP client"); - } - - /* - * All attributes have passed attribute restricted - * check and creation check - * For each MM object construct the sql command - * to perform the set operation - * unset's are simply a set using DEFAULT as value - */ - - for (cur_obj = mms_list_head(&obj_list); - cur_obj != NULL; - cur_obj = next_obj) { - int first = 1; - next_obj = mms_list_next(&obj_list, cur_obj); - if (cmd_buf) { - free(cmd_buf); - cmd_buf = NULL; - } - mms_trace(MMS_DEVP, "Current object -> %s", cur_obj->text); - /* Clear the source list, and add cur_obj as the only source */ - mm_clear_source(cmd); - - if (mm_add_char(cur_obj->text, &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_attribute_cmd_func: " - "out of mem creating source list"); - mm_system_error(cmd, - "out of mem creating source list"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - - cmd->cmd_source_num = 1; - /* Begin constructin the SQL command */ - cmd_buf = mms_strapp(cmd_buf, "UPDATE \"%s\" SET ", - cur_obj->text); - /* For every set where obj = cur_obj */ - /* add to the sql command */ - for (cur_set = mms_list_head(&set_list); - cur_set != NULL; - cur_set = next) { - next = mms_list_next(&set_list, cur_set); - if (strcmp(cur_obj->text, cur_set->cmd_set_obj) == 0) { - /* Obj matches */ - if (first) { - /* Frist attr doesn't need a comma */ - first = 0; - } else { - /* add a comma */ - cmd_buf = mms_strapp(cmd_buf, ", "); - } - switch (cur_set->cmd_set_type) { - case (MM_SET): - cmd_buf = mms_strapp(cmd_buf, - "\"%s\" = '%s'", - cur_set->cmd_set_attr, - cur_set->cmd_set_value); - break; - case (MM_UNSET): - cmd_buf = mms_strapp(cmd_buf, - "\"%s\" = DEFAULT", - cur_set->cmd_set_attr); - break; - } - } - } - /* Copy local cmd_buf into cmd->cmd_buf */ - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(cmd_buf) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, "%s", cmd_buf); - if (cmd_buf) { - mms_trace(MMS_DEVP, " %s", cmd_buf); - } - if (mm_sql_report_func_attr(cmd)) { - mms_trace(MMS_ERR, - "mm_attribute_cmd_func: " - "error creating helper sql functions"); - mm_system_error(cmd, - "error creating helper sql functions"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - if ((rc = mm_attribute_match(cmd)) != INTRP_OK) { - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - mms_trace(MMS_DEVP, "cmd->cmd_buf constructed"); - - /* Function has been created */ - /* cmd->cmd_buf contains the command */ - /* Send cmd->cmd_buf to the data base */ - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - mms_trace(MMS_DEBUG, "Number of rows modified is %d", - db->mm_db_count); - } - - /* Triggers */ - error = 0; - if (error == 0 && - mm_in_set_list(&set_list, "SYSTEM", "SystemLogFile")) { - if (error = mm_slog_set_fname(db)) { - info = strdup("system log file name"); - } - } - if (error == 0 && - mm_in_set_list(&set_list, "SYSTEM", "SystemSyncLimit")) { - if (error = mm_slog_set_sync(db)) { - info = strdup("system log sync limit"); - } - } - if (error == 0 && - mm_in_set_list(&set_list, "SYSTEM", "SystemLogLevel")) { - if (error = mm_slog_set_level(db)) { - info = strdup("system log level"); - } - } - if (error == 0 && - mm_in_set_list(&set_list, "SYSTEM", "SystemLogFileSize")) { - if (error = mm_slog_set_size(db)) { - info = strdup("system log file size"); - } - } - if (error == 0 && - mm_in_set_list(&set_list, "SYSTEM", "SystemMessageLimit")) { - if (error = mm_msg_set_limit(db)) { - info = strdup("system message limit"); - } - } - if (error == 0 && - mm_in_set_list(&set_list, "SYSTEM", "SystemRequestLimit")) { - if (error = mm_request_history_limit(db)) { - info = strdup("system request history limit"); - } - } - if (error == 0 && - mm_in_set_list(&set_list, "SYSTEM", "AttendanceMode")) { - if (error = mm_change_attendance_mode(mm_wka)) { - info = strdup("system attendance mode"); - } - } - if (error == 0 && - mm_in_set_list(&set_list, "DM", "DMMessageLevel")) { - if (error = mm_msg_set_tracing(mm_wka, cmd, DM)) { - info = strdup("dm messsage level"); - } - } - if (error == 0 && - mm_in_set_list(&set_list, "DM", "TraceLevel")) { - if (error = mm_msg_set_tracing(mm_wka, cmd, DM)) { - info = strdup("dm mms_trace level"); - } - } - if (error == 0 && - mm_in_set_list(&set_list, "DM", "TraceFileSize")) { - if (error = mm_msg_set_tracing(mm_wka, cmd, DM)) { - info = strdup("dm mms_trace file size"); - } - } - if (error == 0 && - mm_in_set_list(&set_list, "LM", "LMMessageLevel")) { - if (error = mm_msg_set_tracing(mm_wka, cmd, LM)) { - info = strdup("lm message level"); - } - } - if (error == 0 && - mm_in_set_list(&set_list, "LM", "TraceLevel")) { - if (error = mm_msg_set_tracing(mm_wka, cmd, LM)) { - info = strdup("lm mms_trace level"); - } - } - if (error == 0 && - mm_in_set_list(&set_list, "LM", "TraceFileSize")) { - if (error = mm_msg_set_tracing(mm_wka, cmd, LM)) { - info = strdup("lm mms_trace file size"); - } - } - if (error == 0 && - mm_in_set_list(&set_list, "SYSTEM", "MessageLevel")) { - if (error = mm_msg_set_tracing(mm_wka, cmd, MM)) { - info = strdup("mm message level"); - } - } - if (error == 0 && - mm_in_set_list(&set_list, "SYSTEM", "TraceLevel")) { - if (error = mm_msg_set_tracing(mm_wka, cmd, MM)) { - info = strdup("mm mms_trace level"); - } - } - if (error == 0 && - mm_in_set_list(&set_list, "SYSTEM", "TraceFileSize")) { - if (error = mm_msg_set_tracing(mm_wka, cmd, MM)) { - info = strdup("mm mms_trace file size"); - } - } - if (error) { - mm_response_error(cmd, - ECLASS_SUBOP, - ESYSTEMCONFIGCHANGE, - MM_5099_MSG, - "info", info, - NULL); - free(info); - info = NULL; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - rc = MM_CMD_ERROR; - goto end; - } - - /* Create the report and send success */ - mm_path_match_report(cmd, db); - cmd->cmd_remove = 1; - mm_send_response(mm_wka->mm_wka_conn, cmd); - rc = MM_CMD_DONE; - goto end; -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -end: - - /* Destroy the lists */ - /* Set List */ - for (cur_set = mms_list_head(&set_list); - cur_set != NULL; - cur_set = next) { - next = mms_list_next(&set_list, cur_set); - if (cur_set->cmd_set_obj) - free(cur_set->cmd_set_obj); - if (cur_set->cmd_set_attr) - free(cur_set->cmd_set_attr); - if (cur_set->cmd_set_value) - free(cur_set->cmd_set_value); - mms_list_remove(&set_list, - cur_set); - free(cur_set); - } - mms_list_destroy(&set_list); - - /* Destroy the Object list */ - for (cur_obj = mms_list_head(&obj_list); - cur_obj != NULL; - cur_obj = next_obj) { - next_obj = mms_list_next(&obj_list, cur_obj); - if (cur_obj->text) - free(cur_obj->text); - mms_list_remove(&obj_list, - cur_obj); - free(cur_obj); - } - if (cmd_buf != NULL) - free(cmd_buf); - if (info != NULL) - free(info); - return (rc); -} - - -char * -mm_return_set_value(mms_list_t *set_list, char *obj, char *attr) { - cmd_set_t *cur_set; - cmd_set_t *next; - for (cur_set = mms_list_head(set_list); - cur_set != NULL; - cur_set = next) { - next = mms_list_next(set_list, cur_set); - if ((strcmp(cur_set->cmd_set_obj, obj) == 0) && - (strcmp(cur_set->cmd_set_attr, attr) == 0)) { - return (cur_set->cmd_set_value); - } - } - return (NULL); -} - -/* - * mm_get_set_clause: - * Parses commands with set/unset clauses - * and creates lists that hold all the relevant information - * Can be used in any command that includes set/unset clauses - * obj_list is the list of MM objects used in the set/unset clauses - */ -int -mm_get_set_clause(mm_command_t *cmd, mms_list_t *set_list, mms_list_t *obj_list) -{ - int rc; - - /* For Set and Unset Lists */ - - - /* For the Parse */ - mms_par_node_t *work = NULL; - mms_par_node_t *set; - mms_par_node_t *unset; - - mms_par_node_t *object; - mms_par_node_t *attr; - mms_par_node_t *value; - - mms_trace(MMS_DEVP, "mm_get_set_clause"); - - /* TEMP create the lists within this function */ - /* and destroy them when we are finished */ - - - work = NULL; - for (set = mms_pn_lookup(cmd->cmd_root, "set", - MMS_PN_CLAUSE, &work); - set != NULL; - set = mms_pn_lookup(cmd->cmd_root, "set", - MMS_PN_CLAUSE, &work)) { - mms_trace(MMS_DEVP, " Set Clause"); - /* Get the Object */ - MMS_PN_LOOKUP(object, set, NULL, MMS_PN_OBJ, NULL); - mms_trace(MMS_DEVP, " Object name-> %s", - object->pn_string); - /* Get the Attribute */ - MMS_PN_LOOKUP(attr, set, NULL, MMS_PN_ATTR, NULL); - mms_trace(MMS_DEVP, " Attribute name-> %s", - attr->pn_string); - /* Get the Value */ - MMS_PN_LOOKUP(value, set, NULL, MMS_PN_STRING, NULL); - if (value->pn_type & MMS_PN_NULLSTR) { - mms_trace(MMS_DEVP, " Value name-> NULL"); - /* Add this to the set list */ - if (mm_add_set_list(set_list, - MM_SET, - object->pn_string, - attr->pn_string, - "DEFAULT")) { - mms_trace(MMS_ERR, - "mm_get_set_clause: " - "unable to allocate " - "memory for this set"); - return (MM_CMD_ERROR); - } - - } else { - mms_trace(MMS_DEVP, " Value name-> %s", - value->pn_string); - /* Add this to the set list */ - - - if (mm_add_set_list(set_list, - MM_SET, - object->pn_string, - attr->pn_string, - value->pn_string)) { - mms_trace(MMS_ERR, - "mm_get_set_clause: " - "unable to allocate " - "memory for this set"); - return (MM_CMD_ERROR); - } - } - - /* Add this to the obj list */ - if (obj_list != NULL) { - (void) mm_add_obj_list(obj_list, - object->pn_string); - } - } - - work = NULL; - for (unset = mms_pn_lookup(cmd->cmd_root, "unset", - MMS_PN_CLAUSE, &work); - unset != NULL; - unset = mms_pn_lookup(cmd->cmd_root, "unset", - MMS_PN_CLAUSE, &work)) { - mms_trace(MMS_DEVP, " Unset Clause"); - /* Get the Object */ - MMS_PN_LOOKUP(object, unset, NULL, MMS_PN_OBJ, NULL); - mms_trace(MMS_DEVP, " Object name-> %s", - object->pn_string); - /* Get the Attribute */ - MMS_PN_LOOKUP(attr, unset, NULL, MMS_PN_ATTR, NULL); - mms_trace(MMS_DEVP, " Attribute name-> %s", - attr->pn_string); - /* Add this to the set list */ - if (mm_add_set_list(set_list, - MM_UNSET, - object->pn_string, - attr->pn_string, - NULL)) { - mms_trace(MMS_ERR, - "mm_get_set_clause: " - "unable to allocate " - "memory for this set"); - return (MM_CMD_ERROR); - } - /* Add this to the obj list */ - if (obj_list != NULL) { - (void) mm_add_obj_list(obj_list, - object->pn_string); - } - - } - - - /* Print both the Set and Unset lists */ - mms_trace(MMS_DEVP, "Printing Set list"); - mm_print_set_list(set_list); - rc = 0; - goto end; - -not_found: - mms_trace(MMS_ERR, "Not found in mm_get_set_clause"); - rc = 1; - goto end; - -end: - - return (rc); - - -} - - - -int -mm_show_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_db_t *db = &cmd->wka_ptr->mm_data->mm_db; - - cmd->cmd_source_num = 0; - cmd->cmd_dest_num = 0; - - mms_trace(MMS_DEVP, "sql trans show cmd"); - - mm_path_match_report(cmd, db); - - cmd->cmd_remove = 1; - mm_send_response(mm_wka->mm_wka_conn, cmd); - return (MM_CMD_DONE); -} - - -int -mm_delete_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - char *objname; - mms_par_node_t *object; - mms_par_node_t *type; - int rc; - int row; - int rows; - int j; - mm_db_t *db = &mm_wka->mm_data->mm_db; - char *notify_obj = NULL; - char *list = NULL; - int match_off; - char *path_buf = NULL; - char *selecttype; - char *errtype; - char *errobj; - char *objlist = NULL; - mm_pkey_t *p_key = NULL; - PGresult *results; - char *source_buf_0; - - mms_trace(MMS_DEVP, "sql trans delete cmd"); - - /* Get Dest and Constraints */ - if (mm_get_dest(mm_wka, cmd)) { - /* Command does not have a match/volname clause */ - mms_trace(MMS_DEVP, "No match/volname Clause???"); - } else { - /* TEMP - Trace out our dest info */ - mms_trace(MMS_DEVP, "Dest count is %d", cmd->cmd_dest_num); - mm_print_char_list(&cmd->cmd_dest_list); - } - - if (mm_get_const(mm_wka, cmd)) { - /* Command does not have a match/volname clause */ - mms_trace(MMS_DEVP, "No match/volname Clause???"); - } else { - /* TEMP - Trace out our const info */ - mms_trace(MMS_DEVP, "Const count is %d", cmd->cmd_const_num); - mm_print_char_list(&cmd->cmd_const_list); - } - - /* Look up the type */ - MMS_PN_LOOKUP(type, cmd->cmd_root, "type", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(object, type, NULL, MMS_PN_OBJ, NULL); - objname = object->pn_string; - - /* Set notify object */ - if (strcmp(objname, "DM") == 0 || strcmp(objname, "LM") == 0) { - notify_obj = objname; - } - - /* Prepare source[0] */ - - if (mm_add_char(objname, - &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_delete_cmd_func: " - "out of mem creating source list"); - mm_system_error(cmd, - "out of mem creating source list"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - - cmd->cmd_source_num = 1; - - /* Clear cmd_buf */ - if (cmd->cmd_buf != NULL) { - free(cmd->cmd_buf); - cmd->cmd_buf = NULL; - cmd->cmd_bufsize = 0; - } - - /* Generate the final report where sql */ - if (mm_sql_from_where(cmd, db)) { - mms_trace(MMS_ERR, - "mm_delete_cmd_func: " - "db error creating helper functions"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - /* Make path sql for delete */ - - source_buf_0 = (char *)mm_return_char(&cmd->cmd_source_list, 0); - - path_buf = mms_strapp(path_buf, "delete from \"%s\" ", - source_buf_0); - match_off = strlen(path_buf); - path_buf = mms_strapp(path_buf, "where"); - - p_key = mm_get_pkey(source_buf_0); - - for (j = 0; j < p_key->mm_att_num; j ++) { - path_buf = mms_strapp(path_buf, - "(\"%s\".\"%s\" in " - "( select \"%s\".\"%s\" from ", - source_buf_0, - p_key->mm_att[j], - source_buf_0, - p_key->mm_att[j]); - path_buf = mms_strapp(path_buf, cmd->cmd_buf); - path_buf = mms_strapp(path_buf, "))"); - if (j + 1 < p_key->mm_att_num) { - path_buf = mms_strapp(path_buf, "and "); - } - } - - SQL_CHK_LEN(&cmd->cmd_buf, NULL, - &cmd->cmd_bufsize, strlen(path_buf) + 1); - (void) strlcpy(cmd->cmd_buf, path_buf, cmd->cmd_bufsize); - - free(path_buf); - path_buf = NULL; - - - - - if (strcmp(objname, "CARTRIDGE") == 0) { - /* Delete SIDE and SLOT before deleteing CARTRIDGE */ - path_buf = mms_strapp(path_buf, "SELECT \"CartridgeID\" " - "FROM \"CARTRIDGE\" %s", - &cmd->cmd_buf[match_off]); - if (mm_db_exec(HERE, db, path_buf) != MM_DB_DATA) { - goto db_error; - } - free(path_buf); - path_buf = NULL; - - rows = PQntuples(db->mm_db_results); - results = db->mm_db_results; - for (row = 0; row < rows; row++) { - path_buf = mms_strapp(path_buf, "DELETE FROM \"SIDE\" " - "WHERE \"CartridgeID\" = '%s'", - PQgetvalue(results, row, 0)); - - if (mm_db_exec(HERE, db, path_buf) != MM_DB_OK) { - if (path_buf) - free(path_buf); - goto db_error; - } - free(path_buf); - path_buf = NULL; - path_buf = mms_strapp(path_buf, "DELETE FROM \"SLOT\" " - "WHERE \"CartridgeID\" = '%s'", - PQgetvalue(results, row, 0)); - - if (mm_db_exec(HERE, db, path_buf) != MM_DB_OK) { - if (path_buf) - free(path_buf); - goto db_error; - } - free(path_buf); - path_buf = NULL; - - } - mm_clear_db(&db->mm_db_results); - } - - - /* Do the notification */ - if (notify_obj) { - mms_trace(MMS_DEVP, "delete %s", notify_obj); - if ((rc = mm_notify_delete(db, cmd, notify_obj, - match_off)) != INTRP_OK) { - mms_trace(MMS_DEVP, "rc %d delete %s", rc, notify_obj); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - if (strcmp(objname, "LIBRARY") == 0) { - path_buf = mms_strapp(path_buf, "SELECT \"LM\".\"LibraryName\" " - "FROM \"LIBRARY\" cross join \"LM\" %s and \"LM\"." - "\"LibraryName\" = \"LIBRARY\".\"LibraryName\" and " - "\"LIBRARY\".\"LibraryOnline\" = 'true'", - &cmd->cmd_buf[match_off]); - if (mm_db_exec(HERE, db, path_buf) != MM_DB_DATA) { - goto db_error; - } - free(path_buf); - path_buf = NULL; - - rows = PQntuples(db->mm_db_results); - results = db->mm_db_results; - if (rows > 0) { - for (row = 0; row < rows; row++) { - mms_trace(MMS_ERR, "mm_delete_cmd_func error:" - "LM %s is online", PQgetvalue(results, row, - 0)); - list = mms_strapp(list, "%s ", - PQgetvalue(results, row, 0)); - } - mm_clear_db(&db->mm_db_results); - mm_response_error(cmd, - ECLASS_STATE, - ELIBRARYONLINE, - MM_5111_MSG, - "liblist", - list, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - free(list); - return (MM_CMD_ERROR); - } - /* Get the lirbarynames for delete before */ - /* the sql is run */ - mm_notify_add_librarydelete(db, mm_wka, - cmd, match_off); - } else if (strcmp(objname, "DRIVE") == 0) { - path_buf = mms_strapp(path_buf, "SELECT \"DriveName\" " - "FROM \"DRIVE\" %s and " - "\"DriveOnline\" = 't'", - &cmd->cmd_buf[match_off]); - if (mm_db_exec(HERE, db, path_buf) != MM_DB_DATA) { - goto db_error; - } - free(path_buf); - path_buf = NULL; - - rows = PQntuples(db->mm_db_results); - results = db->mm_db_results; - if (rows > 0) { - for (row = 0; row < rows; row++) { - mms_trace(MMS_ERR, "mm_delete_cmd_func error:" - "Drive %s is online", - PQgetvalue(results, row, - 0)); - list = mms_strapp(list, "%s ", - PQgetvalue(results, row, 0)); - } - mm_clear_db(&db->mm_db_results); - mm_response_error(cmd, - ECLASS_STATE, - mms_sym_code_to_str(MMS_EDRIVEONLINE), - MM_5114_MSG, - "drvlist", - list, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - free(list); - return (MM_CMD_ERROR); - } - mm_notify_add_drivedelete(db, mm_wka, - cmd, match_off); - } - - /* If deleting an LM or DM, make sure they are not active */ - if (strcmp(objname, "DM") == 0 || strcmp(objname, "LM") == 0) { - if (strcmp(objname, "DM") == 0) { - selecttype = "\"DMName\", \"DriveName\""; - errtype = "EDRIVEONLINE"; - errobj = "drives"; - } else { - selecttype = "\"LMName\", \"LibraryName\""; - errtype = "ELIBRARYONLINE"; - errobj = "libraries"; - } - path_buf = mms_strapp(path_buf, "SELECT %s FROM \"%s\" " - "%s and \"%s\".\"%sStateSoft\" = 'ready'", - selecttype, objname, &cmd->cmd_buf[match_off], objname, - objname); - if (mm_db_exec(HERE, db, path_buf) != MM_DB_DATA) { - goto db_error; - } - free(path_buf); - path_buf = NULL; - - rows = PQntuples(db->mm_db_results); - results = db->mm_db_results; - if (rows > 0) { - for (row = 0; row < rows; row++) { - mms_trace(MMS_ERR, "mm_delete_cmd_func error:" - " %s is online", PQgetvalue(results, row, - 1)); - list = mms_strapp(list, "%s ", - PQgetvalue(results, row, 1)); - objlist = mms_strapp(objlist, "%s ", - PQgetvalue(results, row, 0)); - } - mm_clear_db(&db->mm_db_results); - mm_response_error(cmd, - ECLASS_STATE, - errtype, - MM_5115_MSG, - "objtype", - objname, - "objname", - objlist, - "objects", - errobj, - "objlist", - list, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - free(list); - return (MM_CMD_ERROR); - } - } - - /* do delete in sql */ - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_OK) { - goto db_error; - } - - /* Finish */ - if (strcmp(objname, "MESSAGE") == 0) { - int count; - if (mm_db_exec(HERE, db, "select \"MessageID\" from " - "\"MESSAGE\";") != MM_DB_DATA) { - goto db_error; - } - count = PQntuples(db->mm_db_results); - mm_clear_db(&db->mm_db_results); - if (mm_db_exec(HERE, db, "update \"SYSTEM\" set " - "\"SystemMessageCount\" = '%d';", count) != MM_DB_OK) { - goto db_error; - } - } else if (strcmp(objname, "REQUEST") == 0) { - int count; - if (mm_db_exec(HERE, db, "select \"RequestID\" from " - "\"REQUEST\" where \"RequestState\" = 'responded';") - != MM_DB_DATA) { - goto db_error; - } - count = PQntuples(db->mm_db_results); - mm_clear_db(&db->mm_db_results); - if (mm_db_exec(HERE, db, "update \"SYSTEM\" set " - "\"SystemRequestCount\" = '%d';", count) != MM_DB_OK) { - goto db_error; - } - } - - /* Clear cmd_buf */ - if (cmd->cmd_buf != NULL) { - free(cmd->cmd_buf); - cmd->cmd_buf = NULL; - cmd->cmd_bufsize = 0; - } - - mm_path_match_report(cmd, db); - cmd->cmd_remove = 1; - mm_send_response(mm_wka->mm_wka_conn, cmd); - return (MM_CMD_DONE); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - -db_error: - if ((db->mm_db_rval == 7) && ((strstr(PQerrorMessage(db->mm_db_conn), - "violates foreign key constraint") != NULL) && - (strstr(PQerrorMessage(db->mm_db_conn), "CARTRIDGE") != NULL))) { - mm_response_error(cmd, - ECLASS_STATE, - mms_sym_code_to_str(MMS_EOBJREFERENCES), - MM_5112_MSG, - NULL); - cmd->cmd_remove = 1; - free(path_buf); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if ((db->mm_db_rval == 7) && ((strstr(PQerrorMessage(db->mm_db_conn), - "violates foreign key constraint") != NULL) && - (strstr(PQerrorMessage(db->mm_db_conn), "DRIVE") != NULL))) { - mm_response_error(cmd, - ECLASS_STATE, - mms_sym_code_to_str(MMS_EOBJREFERENCES), - MM_5113_MSG, - NULL); - cmd->cmd_remove = 1; - free(path_buf); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - free(path_buf); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); -} - - - - -/* Check the command's accessmode vs drive capability */ - -int -mm_mount_union(mm_command_t *cmd, char *mode_toks[CMI_NUM_ACCESSMODE], - cmi_mode_list_t *mode) -{ - int count = 0; - int number = 0; - int i; - /* copy accessmodes over */ - number = 0; - for (i = 0; i < mode->cmi_num_accessmode; i ++) { - mode_toks[i] = strdup(mode->cmi_accessmode[i]); - count ++; - number ++; - } - /* append with first mount */ - for (i = 0; i < cmd->cmd_mount_info. - cmi_num_firstmount; i ++) { - mode_toks[count+i] = strdup(cmd->cmd_mount_info. - cmi_firstmount[i]); - number ++; - } - return (number); -} - -char * -/* LINTED: mm_wka may be used in the future */ -mm_check_mode(mm_wka_t *mm_wka, mm_command_t *cmd, - char *drive, cmi_mode_list_t *mode, char *cart_id, - mm_db_t *db) { - - - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - int number_toks = 0; - char *tok_union[CMI_NUM_ACCESSMODE]; - char *send_buf = NULL; - PGresult *default_toks; - int num_default_toks; - int total_toks; - char *check_buf = NULL; - char *tok_group[CMI_NUM_ACCESSMODE]; - int tok_group_count = 0; - int i; - int j; - - char *return_ptr = NULL; - - mms_trace(MMS_DEVP, - "mm_check_mode"); - - if (mode == NULL) { - number_toks = 0; - } else { - number_toks = mm_mount_union(cmd, - tok_union, - mode); - } - total_toks = number_toks; - /* Add the bit format tokens to tok_union */ - /* If the token already exists, skip */ - - if (mm_db_exec(HERE, db, - "select distinct \"DMBITFORMATTOKEN\"." - "\"DMCapabilityToken\" from \"DMBITFORMATTOKEN\" " - "cross join \"DM\" " - "cross join \"PARTITION\" " - "where (" - "(\"DMBITFORMATTOKEN\".\"DriveName\" " - "= \"DM\".\"DriveName\") and " - "(\"DMBITFORMATTOKEN\".\"DMName\" " - "= \"DM\".\"DMName\") and " - "(\"DMBITFORMATTOKEN\".\"DMBitFormatName\" " - "= \"PARTITION\".\"PartitionBitFormat\") and " - "((\"DMBITFORMATTOKEN\".\"DriveName\" = '%s') " - "AND (pg_host_ident(\"DM\".\"DMTargetHost\")" - " = pg_host_ident('%s')) " - "and (\"PARTITION\".\"CartridgeID\" = '%s')));", - drive, - mount_info->cmi_where, - cart_id) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mms_trace(MMS_ERR, "mm_check_mode: " - "error getting tokens from db"); - return_ptr = NULL; - goto end; - } - - for (j = 0; j < PQntuples(db->mm_db_results); j ++) { - int write = 1; - for (i = 0; i < number_toks; i ++) { - if (strcmp(tok_union[i], - PQgetvalue(db->mm_db_results, j, 0)) == 0) { - write = 0; - } - } - if (write) { - tok_union[number_toks] = NULL; - tok_union[number_toks] = - mms_strapp(tok_union[number_toks], - PQgetvalue(db->mm_db_results, j, 0)); - number_toks ++; - total_toks ++; - } - } - mm_clear_db(&db->mm_db_results); - - /* Validate that this drive contains the given tokens */ - - for (i = 0; i < number_toks; i ++) { - check_buf = mms_strapp(check_buf, - "select distinct \"DMCapabilityToken\" " \ - "from good_tok('%s', '%s', '%s');", - drive, tok_union[i], mount_info->cmi_where); - if (mm_db_exec(HERE, db, check_buf) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mms_trace(MMS_ERR, "Error Checking Access mode Tokens"); - return_ptr = NULL; - goto end; - } - if (check_buf) - free(check_buf); - check_buf = NULL; - if (PQntuples(db->mm_db_results) == 0) { - /* Drive doesn't support this token */ - return_ptr = NULL; - mm_clear_db(&db->mm_db_results); - goto end; - } - /* Validate that there are not 2 tokens from the same group */ - mm_clear_db(&db->mm_db_results); - if (mm_db_exec(HERE, db, - "select distinct \"DMCAPABILITYGROUP\"." - "\"DMCapabilityGroupName\" " - "from \"DMCAPABILITYGROUP\" " - "cross join \"DM\" " - "cross join \"DMCAPABILITYGROUPTOKEN\" " - "cross join \"DRIVE\" " - "where ( " - "(\"DMCAPABILITYGROUP\".\"DMName\" = " - "\"DM\".\"DMName\") " - "and " - "(\"DMCAPABILITYGROUP\".\"DriveName\" = " - "\"DMCAPABILITYGROUPTOKEN\".\"DriveName\") " - "and " - "(\"DMCAPABILITYGROUP\".\"DMName\" = " - "\"DMCAPABILITYGROUPTOKEN\".\"DMName\") " - "and " - "(\"DMCAPABILITYGROUP\"." - "\"DMCapabilityGroupName\" = " - "\"DMCAPABILITYGROUPTOKEN\"." - "\"DMCapabilityGroupName\") " - "and " - "(\"DMCAPABILITYGROUP\".\"DMName\" = " - "\"DM\".\"DMName\") " - "and " - "(\"DM\".\"DriveName\" = \"DRIVE\".\"DriveName\") " - "and " - "( " - "(pg_host_ident(\"DM\".\"DMTargetHost\") " - "= pg_host_ident('%s')) " - "AND (\"DMCAPABILITYGROUPTOKEN\"." - "\"DMCapabilityToken\" = '%s') AND " - "(\"DRIVE\".\"DriveName\" = '%s')));", - mount_info->cmi_where, - tok_union[i], - drive) != MM_DB_DATA) { - mms_trace(MMS_ERR, "Error Checking Access mode Tokens"); - mm_sql_db_err_rsp_new(cmd, db); - return_ptr = NULL; - goto end; - } - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_DEBUG, "Couldn't find group for %s", - tok_union[i]); - mm_clear_db(&db->mm_db_results); - goto bad_group; - } - for (j = 0; j < tok_group_count; j ++) { - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), - tok_group[j]) == 0) { - /* already have this group */ - mms_trace(MMS_DEBUG, - "Duplication token %s for group %s", - tok_union[i], - tok_group[j]); - mm_clear_db(&db->mm_db_results); - goto bad_group; - } - } - tok_group[tok_group_count] = NULL; - tok_group[tok_group_count] = - mms_strapp(tok_group[tok_group_count], - PQgetvalue(db->mm_db_results, 0, 0)); - tok_group_count ++; - mm_clear_db(&db->mm_db_results); - } - - for (j = 0; j < tok_group_count; j ++) { - if (tok_group[j]) - free(tok_group[j]); - } - tok_group_count = 0; - - - send_buf = mms_strapp(send_buf, - "select distinct \"DMCapabilityGroupDefaultName\" "\ - "from \"DMCAPABILITYGROUP\" "\ - "where \"DriveName\" = '%s'", - drive); - - - for (i = 0; i < number_toks; i ++) { - send_buf = mms_strapp(send_buf, - "and \"DMCapabilityGroupName\" not in " \ - "(select \"DMCapabilityGroupName\" " \ - "from \"DMCAPABILITYGROUPTOKEN\" " \ - " where \"DriveName\" = '%s' and " \ - "\"DMCapabilityToken\" = '%s')", - drive, tok_union[i]); - } - - send_buf = mms_strapp(send_buf, ";"); - mm_clear_db(&db->mm_db_results); - if (mm_db_exec(HERE, db, send_buf) != MM_DB_DATA) { - /* Error */ - mms_trace(MMS_ERR, "Error Getting Default Tokens"); - mm_sql_db_err_rsp_new(cmd, db); - free(send_buf); - return_ptr = NULL; - goto end; - } - default_toks = db->mm_db_results; - db->mm_db_results = NULL; - num_default_toks = PQntuples(default_toks); - - free(send_buf); - send_buf = NULL; - total_toks = number_toks; - - - for (i = 0; i < num_default_toks; i++) { - tok_union[total_toks] = strdup(PQgetvalue(default_toks, i, 0)); - total_toks ++; - } - - /* Now Check the access mode */ - - send_buf = mms_strapp(send_buf, - "select distinct \"DMCapabilityName\" " - "from \"DMCAPABILITYTOKEN\" " - "where \"DriveName\" " - "in (select \"DriveName\" from \"DM\" where " - "pg_host_ident(\"DMTargetHost\") = " - "pg_host_ident('%s') and \"DriveName\" = '%s') " - "and \"DMCapabilityName\" in ", - mount_info->cmi_where, - drive); - for (i = 0; i < total_toks - 2; i ++) { - send_buf = mms_strapp(send_buf, - "(select \"DMCapabilityName\" "\ - "from \"DMCAPABILITYTOKEN\" " \ - " where \"DMCapabilityName\" in "); - } - send_buf = mms_strapp(send_buf, - "(select \"DMCapabilityName\" "\ - "from \"DMCAPABILITYTOKEN\" where "\ - "\"DMCapabilityToken\" = '%s')", - tok_union[0]); - for (i = 1; i < total_toks - 1; i ++) { - send_buf = mms_strapp(send_buf, - "and \"DMCapabilityToken\" = '%s')", - tok_union[i]); - } - send_buf = mms_strapp(send_buf, - "and \"DMCapabilityToken\" = '%s';", - tok_union[total_toks - 1]); - - if (mm_db_exec(HERE, db, send_buf) != MM_DB_DATA) { - /* Error */ - mms_trace(MMS_ERR, "Error Getting Cap name Tokens"); - mm_sql_db_err_rsp_new(cmd, db); - return_ptr = NULL; - free(send_buf); - mm_clear_db(&default_toks); - goto end; - } - - free(send_buf); - send_buf = NULL; - - if (PQntuples(db->mm_db_results) == 0) { - if (mode == NULL) { - mms_trace(MMS_ERR, - "GET DEFAULT TOKENS FAILED!! " - "BAD/CORRUPT DM CONFIG"); - } - - /* Drive Doesn't support this mode */ - mm_clear_db(&db->mm_db_results); - return_ptr = NULL; - goto end; - } else if (PQntuples(db->mm_db_results) > 1) { - /* Bad DMConfig */ - mm_clear_db(&db->mm_db_results); - return_ptr = NULL; - goto end; - } - /* Set cmid_capability */ - if (mount_info->cmi_capability != NULL) { - free(mount_info->cmi_capability); - mount_info->cmi_capability = NULL; - } - mount_info->cmi_capability = strdup(PQgetvalue(db-> - mm_db_results, 0, 0)); - for (i = 0; i < total_toks; i ++) { - send_buf = mms_strapp(send_buf, "%s:", tok_union[i]); - } - - mms_trace(MMS_DEVP, "cmi_capability is %s, Cap Token string is %s", - mount_info->cmi_capability, send_buf); - mms_trace_flush(); - mm_clear_db(&db->mm_db_results); - mm_clear_db(&default_toks); - return_ptr = send_buf; - goto end; -no_mem: - MM_ABORT_NO_MEM(); - return (NULL); -bad_group: - - for (j = 0; j < tok_group_count; j ++) { - if (tok_group[j]) - free(tok_group[j]); - } - for (int j = 0; j < tok_group_count; j ++) { - if (tok_group[j]) - free(tok_group[j]); - } - return (NULL); -end: - for (int j = 0; j < tok_group_count; j ++) { - if (tok_group[j]) - free(tok_group[j]); - } - for (int j = 0; j < total_toks; j ++) { - if (tok_union[j]) - free(tok_union[j]); - } - return (return_ptr); -} - - -int -mm_goodbye_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_db_t *db = &cmd->wka_ptr->mm_data->mm_db; - mm_command_t *cur_cmd; - PGresult *task_results; - - /* Make sure there are no outstanding commands */ - /* If the command is ablocked mount, cancel the mount */ - /* Delay dispatch of the final success until all commands */ - /* have completed */ - - /* Dont accept any more commands from this wka */ - mm_wka->wka_goodbye = 1; - - /* lock queue and run thorugh the list */ - /* 1st Cancel any outstanding mount/unmounts that are blocked */ - - mms_trace(MMS_DEVP, - "check for blocked mount/unmounts"); - pthread_mutex_lock(&mm_wka->mm_data->mm_queue_mutex); - mms_list_foreach(&mm_wka->mm_data->mm_cmd_queue, cur_cmd) { - if ((cur_cmd->wka_ptr == mm_wka) && - (cur_cmd != cmd) && - (cur_cmd->cmd_remove == 0)) { - /* If this command is a blocked mount, then cancel */ - if ((cur_cmd->cmd_func == mm_mount_cmd_func) || - (cur_cmd->cmd_func == mm_unmount_cmd_func)) { - /* If this unmount/mount */ - /* is blocked, cancel it */ - /* If not, wait for it to finish */ - if (mm_db_exec(HERE, db, - "select \"TaskState\" from \"TASK\" where" - " \"TaskID\" = '%s';", - cur_cmd->cmd_uuid) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "Error determining " - "mount/unmount taskstate"); - mm_sql_db_err_rsp_new(cmd, db); - continue; - } - task_results = db->mm_db_results; - if (PQntuples(task_results) != 1) { - mms_trace(MMS_ERR, - "row mismatch getting task info"); - mm_clear_db(&task_results); - continue; - } - /* If this mount/unmount is blocked */ - /* send a cancel and set this */ - /* command for remove */ - if (strcmp(PQgetvalue(task_results, 0, 0), - "blocked") == 0) { - /* This task is blocked, */ - /* cancel it now */ - mms_trace(MMS_DEVP, - "this task is blocked, " - "sending cancel"); - mm_cancel_cmd_buf(cur_cmd); - mm_send_text(cur_cmd-> - wka_ptr->mm_wka_conn, - cur_cmd->cmd_buf); - cur_cmd->cmd_remove = 1; - if (mm_db_exec(HERE, db, - "delete from \"TASK\" where" - "\"TaskID\" = '%s';", - cur_cmd->cmd_uuid) != MM_DB_OK) { - mms_trace(MMS_ERR, - "Error removing " - "TASK object"); - } - } - mm_clear_db(&task_results); - } - } - } - pthread_mutex_unlock(&mm_wka->mm_data->mm_queue_mutex); - - mms_trace(MMS_DEVP, - "Check outstanding commands"); - /* All mounts/unmounts are cancelled */ - /* lock queue and run thorugh the list */ - pthread_mutex_lock(&mm_wka->mm_data->mm_queue_mutex); - mms_list_foreach(&mm_wka->mm_data->mm_cmd_queue, cur_cmd) { - if ((cur_cmd->wka_ptr == mm_wka) && - (cur_cmd != cmd) && - (cur_cmd->cmd_remove == 0)) { - /* Same wka && */ - /* not this command && */ - /* The command is not being removed */ - mm_add_depend(cur_cmd, cmd); - mms_trace(MMS_DEVP, - "this client has outstanding commands " - "which must finish before goodbye"); - pthread_mutex_unlock(&mm_wka->mm_data->mm_queue_mutex); - return (MM_WORK_TODO); - } - } - pthread_mutex_unlock(&mm_wka->mm_data->mm_queue_mutex); - - - /* Send Success */ - mm_path_match_report(cmd, db); - - cmd->cmd_remove = 1; - mm_wka->wka_remove = 1; - mm_send_response(mm_wka->mm_wka_conn, cmd); - return (MM_CMD_DONE); -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -} - -mm_privilege_t -mm_privileged(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - if (mm_wka->wka_privilege == MM_PRIV_STANDARD) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_PERMPRIV) + - strlen(ECOMMANDNOPRIVILEGE) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_PERMPRIV, ECOMMANDNOPRIVILEGE); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - } - return (mm_wka->wka_privilege); - -no_mem: - MM_ABORT_NO_MEM(); - return (mm_wka->wka_privilege); -} - -int -mm_create_side(mm_wka_t *mm_wka, mm_command_t *cmd, char *cartridge_id) { - mm_db_t *db = &mm_wka->mm_data->mm_db; - char *cartridge_type; - PGresult *results; - int side; - int sides; - - if (cartridge_id == NULL) { - mms_trace(MMS_ERR, - "mm_create_side passed null cartridge_id"); - return (MM_CMD_ERROR); - } - - if (mm_db_exec(HERE, db, "SELECT " - "\"CartridgeTypeName\" FROM "\ - "\"CARTRIDGE\" WHERE " - "\"CartridgeID\" = '%s'", - cartridge_id) != MM_DB_DATA || - PQntuples(db->mm_db_results) != 1 || - (cartridge_type = - strdup(PQgetvalue(db->mm_db_results, 0, 0))) == - NULL) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - if (mm_db_exec(HERE, db, "SELECT " - "\"CartridgeTypeNumberSides\" " - "FROM \"CARTRIDGETYPE\" WHERE "\ - "\"CartridgeTypeName\" = '%s'", - cartridge_type) != MM_DB_DATA || - PQntuples(db->mm_db_results) != 1) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - free(cartridge_type); - return (MM_CMD_ERROR); - } - sides = atoi(PQgetvalue(db->mm_db_results, 0, 0)); - mm_clear_db(&db->mm_db_results); - for (side = 0; side < sides; side++) { - if (mm_db_exec(HERE, db, "SELECT " - "\"Side%dName\" FROM " - "\"CARTRIDGETYPE\" WHERE " - "\"CartridgeTypeName\" = '%s'", - side + 1, cartridge_type) != - MM_DB_DATA && - PQntuples(db->mm_db_results) != 1) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - free(cartridge_type); - return (MM_CMD_ERROR); - } - results = db->mm_db_results; - if (mm_db_exec(HERE, db, "INSERT INTO " - "\"SIDE\" (\"CartridgeID\", " - "\"SideName\") VALUES " - "('%s', '%s')", cartridge_id, - PQgetvalue(results, 0, 0)) != - MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - free(cartridge_type); - return (MM_CMD_ERROR); - } - mm_clear_db(&results); - } - free(cartridge_type); - return (MM_CMD_DONE); - -} - - -int -mm_create_slot_type(mm_wka_t *mm_wka, mm_command_t *cmd, char *library_type) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - - if (mm_db_exec(HERE, db, - "select \"SlotTypeName\" " - "from \"SLOTTYPE\" where " - "\"SlotTypeName\" = '%s';", - library_type) != MM_DB_DATA) { - goto db_error; - } - if (PQntuples(db->mm_db_results) != 0) { - /* A slot type for this library already exists */ - return (MM_CMD_DONE); - } - - if (mm_db_exec(HERE, db, - "insert into \"SLOTTYPE\" " - "(\"SlotTypeName\", " - "\"CartridgeShapeName\") " - "values('%s', '%s%s');", - library_type, - library_type, - "-generic") != MM_DB_OK) { - goto db_error; - } - return (MM_CMD_DONE); - -db_error: - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); -} - -int -mm_update_side(mm_wka_t *mm_wka, mm_command_t *cmd, char *cartridge_type) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - int side; - int sides; - char sidename[20]; - - if (mm_db_exec(HERE, db, - "SELECT \"CartridgeTypeNumberSides\" " \ - "FROM " - "\"CARTRIDGETYPE\" WHERE " \ - "\"CartridgeTypeName\" = '%s'", - cartridge_type) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - sides = atoi(PQgetvalue(db->mm_db_results, 0, 0)); - mm_clear_db(&db->mm_db_results); - for (side = 0; side < sides; side++) { - (void) snprintf(sidename, sizeof (sidename), - "Side%dName", side + 1); - if (mm_db_create_attribute(db, "CARTRIDGETYPE", - sidename) != - MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (mm_db_exec(HERE, db, "UPDATE \"CARTRIDGETYPE\" " - "SET \"%s\" = 'side %d' WHERE " - "\"CartridgeTypeName\" = '%s'", - sidename, - side + 1, cartridge_type) != - MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - return (MM_CMD_DONE); -} - -int -mm_create_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - cci_t *conn = &mm_wka->wka_conn; - char *cmd_buf = NULL; - int rc; - uuid_text_t cartridge_id; - char *part_cart_id = NULL; - - /* Type Clause */ - mms_par_node_t *object; - mms_par_node_t *type; - - /* For Set and Unset Lists */ - mms_list_t set_list; - cmd_set_t *cur_set; - cmd_set_t *next; - - int command_added = 0; - int first = 1; - - - mms_trace(MMS_DEBUG, "mm_create_cmd_func"); - - /* First get the type clause */ - MMS_PN_LOOKUP(type, cmd->cmd_root, "type", - MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(object, type, NULL, MMS_PN_OBJ, NULL); - mms_trace(MMS_DEVP, "type clause, %s", - object->pn_string); - - /* Create the Set and Unset Struct Lists */ - - mms_list_create(&set_list, sizeof (cmd_set_t), - offsetof(cmd_set_t, cmd_set_next)); - /* Build the lists after parsing the clauses */ - - if (mm_get_set_clause(cmd, &set_list, NULL)) { - mms_trace(MMS_ERR, - "mm_create_cmd_func: " - "error building structs from set clause"); - mm_system_error(cmd, - "error building structs from set clause"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - - - /* Check if the creating attribtues is allowed */ - mms_trace(MMS_DEBUG, "Checking objects and attribtues"); - for (cur_set = mms_list_head(&set_list); - cur_set != NULL; - cur_set = next) { - next = mms_list_next(&set_list, cur_set); - /* Check if the attributes may be created */ - if (mm_db_create_attribute(db, - cur_set->cmd_set_obj, - cur_set->cmd_set_attr) != - MM_DB_OK) { - mms_trace(MMS_ERR, "Create attribute check " - "failed for %s.%s", - cur_set->cmd_set_obj, - cur_set->cmd_set_attr); - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - - /* Check if the attributes may be modified */ - if (mm_attribute_check_helper(cmd, cur_set->cmd_set_obj, - cur_set->cmd_set_attr)) { - /* check_helper sets the correct error */ - /* Send and remove */ - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - } - - - /* Do any special permission checks here */ - if ((strcmp(object->pn_string, "PARTITION") == 0)) { - char *LibraryName = NULL; - /* For PARTITION get CartridgeID using libname and pcl */ - - char *CartridgePCL = NULL; - CartridgePCL = mm_return_set_value(&set_list, "PARTITION", - "CartridgePCL"); - if (CartridgePCL == NULL) { - mms_trace(MMS_ERR, "Create PARTITION requires " - "a CartridgePCL"); - mm_response_error(cmd, - "invalid", - "EOBJCREATESYSATTRREQUIRED", - MM_5086_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - LibraryName = mm_return_set_value(&set_list, "PARTITION", - "LibraryName"); - if (LibraryName == NULL) { - mms_trace(MMS_ERR, "Create PARTITION requires " - "a LibraryName"); - mm_response_error(cmd, - "invalid", - "EOBJCREATESYSATTRREQUIRED", - MM_5087_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - if (mm_wka->wka_privilege == MM_PRIV_STANDARD) { - /* For a non-priv client, */ - /* check the user's CARTRIDGEGROUPAPPLICATION */ - if (mm_db_exec(HERE, db, - "select distinct " - "\"CARTRIDGEGROUPAPPLICATION\".* " - "from \"CARTRIDGEGROUPAPPLICATION\" " - "cross join \"CARTRIDGE\" where (" - "(\"CARTRIDGEGROUPAPPLICATION\"." - "\"CartridgeGroupName\" = " - "\"CARTRIDGE\".\"CartridgeGroupName\") " - "and (" - "(\"CARTRIDGE\".\"CartridgePCL\" " - "= '%s') AND " - "(\"CARTRIDGEGROUPAPPLICATION\"." - "\"ApplicationName\" = '%s') AND " - "(\"CARTRIDGE\".\"LibraryName\" = '%s')));", - CartridgePCL, - mm_wka-> - wka_conn.cci_client, - LibraryName) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_ERR, - "Missing a CARTRIDGEGROUPAPPLICATION, " - "%s", - mm_wka-> - wka_conn.cci_client); - mm_response_error(cmd, - "explicit", - "EAPPCARTNOACC", - MM_5088_MSG, - "client", - mm_wka->wka_conn.cci_client, - "pcl", - CartridgePCL, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - mm_clear_db(&db->mm_db_results); - goto end; - } - } - /* Either a priv app, or std app w/cart access */ - /* Get the cartridgeID */ - mm_clear_db(&db->mm_db_results); - if (mm_db_exec(HERE, db, - "select \"CartridgeID\" from " - "\"CARTRIDGE\" where " - "(\"CARTRIDGE\".\"CartridgePCL\" " - " = '%s') and " - "(\"CARTRIDGE\".\"LibraryName\" " - " = '%s');", - CartridgePCL, - LibraryName) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, - "Error getting CartridgeID from DB"); - mm_system_error(cmd, - "Error getting CartridgeID from DB"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - mm_clear_db(&db->mm_db_results); - goto end; - } - part_cart_id = strdup(PQgetvalue(db->mm_db_results, 0, 0)); - mms_trace(MMS_DEVP, "Cartridge ID is %s", part_cart_id); - } - mm_clear_db(&db->mm_db_results); - - mms_trace(MMS_DEVP, "Done checking objects and attribtes"); - - - - - /* Construct the SQL command */ - cmd_buf = mms_strapp(cmd_buf, "INSERT INTO \"%s\" (", - object->pn_string); - - /* List the attributes */ - for (cur_set = mms_list_head(&set_list); - cur_set != NULL; - cur_set = next) { - next = mms_list_next(&set_list, cur_set); - if (first) { - /* Skip comma on first */ - first = 0; - } else { - /* need commma */ - cmd_buf = mms_strapp(cmd_buf, ", "); - } - cmd_buf = mms_strapp(cmd_buf, - "\"%s\"", cur_set->cmd_set_attr); - } - if ((strcmp(object->pn_string, - "CARTRIDGE") == 0) || - (strcmp(object->pn_string, - "PARTITION") == 0)) { - /* Obj is cartridge, add CartridgeID */ - cmd_buf = mms_strapp(cmd_buf, ", \"CartridgeID\""); - } - - /* List the values */ - cmd_buf = mms_strapp(cmd_buf, ") VALUES ("); - first = 1; - for (cur_set = mms_list_head(&set_list); - cur_set != NULL; - cur_set = next) { - next = mms_list_next(&set_list, cur_set); - if (first) { - /* Skip comma on first */ - first = 0; - } else { - /* need commma */ - cmd_buf = mms_strapp(cmd_buf, ", "); - } - cmd_buf = mms_strapp(cmd_buf, - "'%s'", cur_set->cmd_set_value); - } - if (strcmp(object->pn_string, - "CARTRIDGE") == 0) { - /* Obj is cartridge, add CartridgeID */ - mm_get_uuid(cartridge_id); - cmd_buf = mms_strapp(cmd_buf, ", \'%s'", cartridge_id); - } else if (strcmp(object->pn_string, - "PARTITION") == 0) { - /* cartridge_id should be set above */ - if (part_cart_id != NULL) { - cmd_buf = mms_strapp(cmd_buf, - ", \'%s'", part_cart_id); - } else { - mms_trace(MMS_ERR, - "Error finding part_cart_id"); - mm_system_error(cmd, - "Error finding part_cart_id"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - } - - cmd_buf = mms_strapp(cmd_buf, ")"); - - /* Copy local cmd_buf into cmd->cmd_buf */ - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(cmd_buf) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, "%s", cmd_buf); - if (cmd_buf) { - mms_trace(MMS_DEVP, " %s", cmd_buf); - } - /* Send cmd->cmd_buf to the data base */ - - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - } - - - /* Create any additional objects */ - if (strcmp(object->pn_string, "CARTRIDGE") == 0) { - /* New Cartridge */ - if (mm_create_side(mm_wka, cmd, - cartridge_id) == MM_CMD_ERROR) { - rc = MM_CMD_ERROR; - goto end; - } - - } else if (strcmp(object->pn_string, - "CARTRIDGETYPE") == 0) { - char *cartridge_type = NULL; - /* New Cartridge Type */ - cartridge_type = mm_return_set_value(&set_list, "CARTRIDGETYPE", - "CartridgeTypeName"); - if (cartridge_type == NULL) { - mms_trace(MMS_ERR, "Couldn't find CartridgeTypeName"); - rc = MM_CMD_ERROR; - goto end; - } - if (mm_update_side(mm_wka, cmd, - cartridge_type) == MM_CMD_ERROR) { - rc = MM_CMD_ERROR; - goto end; - } - } - - /* Do event notification */ - if (strcmp(object->pn_string, "DM") == 0) { - char *DMTargetHost = NULL; - /* Notification for new DM */ - char *DMName = NULL; - DMName = mm_return_set_value(&set_list, "DM", - "DMName"); - if (DMName == NULL) { - mms_trace(MMS_ERR, "Couldn't find DMName"); - rc = MM_CMD_ERROR; - /* New Error codes for this?? */ - goto not_found; - } - DMTargetHost = mm_return_set_value(&set_list, "DM", - "DMTargetHost"); - if (DMName == NULL) { - mms_trace(MMS_ERR, "Couldn't find DMTargetHost"); - rc = MM_CMD_ERROR; - /* New Error codes for this?? */ - goto not_found; - } - if (mm_notify_add_config(mm_wka, cmd, - EVENT_CFG_NEW, - "DM", - DMName, - DMTargetHost)) { - mms_trace(MMS_ERR, - "mm_create_cmd_func: " - "error adding config event"); - } - - } else if (strcmp(object->pn_string, "LM") == 0) { - char *LMTargetHost = NULL; - /* Notification for new LM */ - char *LMName = NULL; - LMName = mm_return_set_value(&set_list, "LM", - "LMName"); - if (LMName == NULL) { - mms_trace(MMS_ERR, "Couldn't find LMName"); - rc = MM_CMD_ERROR; - /* New Error codes for this?? */ - goto not_found; - } - LMTargetHost = mm_return_set_value(&set_list, "LM", - "LMTargetHost"); - if (LMName == NULL) { - mms_trace(MMS_ERR, "Couldn't find LMTargetHost"); - rc = MM_CMD_ERROR; - /* New Error codes for this?? */ - goto not_found; - } - - if (mm_notify_add_config(mm_wka, cmd, - EVENT_CFG_NEW, - "LM", - LMName, - LMTargetHost)) { - mms_trace(MMS_ERR, - "mm_create_cmd_func: " - "error adding config event"); - } - - } else if (strcmp(object->pn_string, "DRIVE") == 0) { - - char *DriveName = NULL; - char *LibraryName = NULL; - DriveName = mm_return_set_value(&set_list, "DRIVE", - "DriveName"); - if (DriveName == NULL) { - mms_trace(MMS_ERR, "Couldn't find DriveName"); - rc = MM_CMD_ERROR; - /* New Error codes for this?? */ - goto not_found; - } - LibraryName = mm_return_set_value(&set_list, "DRIVE", - "LibraryName"); - if (LibraryName == NULL) { - mms_trace(MMS_ERR, "Couldn't find Library Name"); - rc = MM_CMD_ERROR; - /* New Error codes for this?? */ - goto not_found; - } - /* Notification for new DRIVE */ - mm_notify_add_newdrive(cmd->wka_ptr, - cmd, - DriveName, - LibraryName); - - /* Add LMP scan command for this drive */ - if (mm_add_lmp_scan(mm_wka->mm_data, NULL, DriveName, - NULL, LibraryName)) { - mms_trace(MMS_DEBUG, - "Error adding LMP scan, LM may not be connected"); - } else { - mms_trace(MMS_DEVP, - "Added a LMP scan"); - command_added = 1; - } - - - } else if (strcmp(object->pn_string, "CARTRIDGE") == 0) { - char *CartridgePCL = NULL; - char *LibraryName = NULL; - CartridgePCL = mm_return_set_value(&set_list, "CARTRIDGE", - "CartridgePCL"); - if (CartridgePCL == NULL) { - mms_trace(MMS_ERR, "Couldn't find CartridgePCL"); - rc = MM_CMD_ERROR; - /* New Error codes for this?? */ - goto not_found; - } - LibraryName = mm_return_set_value(&set_list, "CARTRIDGE", - "LibraryName"); - if (LibraryName == NULL) { - mms_trace(MMS_ERR, "Couldn't find Library Name"); - rc = MM_CMD_ERROR; - /* New Error codes for this?? */ - goto not_found; - } - /* Notification for new CARTRIDGE */ - - mm_notify_add_newcartridge(cmd->wka_ptr, - cmd, - CartridgePCL, - LibraryName); - - /* Add LMP scan command for this cartridge */ - if (mm_add_lmp_scan(mm_wka->mm_data, NULL, NULL, - CartridgePCL, LibraryName)) { - mms_trace(MMS_DEBUG, - "Error adding LMP scan"); - } else { - mms_trace(MMS_DEVP, - "Added a LMP scan"); - command_added = 1; - } - } else if (strcmp(object->pn_string, "LIBRARY") == 0) { - char *LibraryName = NULL; - LibraryName = mm_return_set_value(&set_list, "LIBRARY", - "LibraryName"); - if (LibraryName == NULL) { - mms_trace(MMS_ERR, "Couldn't find Library Name"); - rc = MM_CMD_ERROR; - /* New Error codes for this?? */ - goto not_found; - } - mm_notify_add_librarycreate(cmd->wka_ptr, - cmd, - LibraryName); - } - - /* Trace a info summary */ - - mms_trace(MMS_INFO, - "%s created by %s %s", - object->pn_string, - conn->cci_client, - conn->cci_instance); - for (cur_set = mms_list_head(&set_list); - cur_set != NULL; - cur_set = next) { - next = mms_list_next(&set_list, cur_set); - mms_trace(MMS_INFO, " %s.%s=%s", - cur_set->cmd_set_obj, - cur_set->cmd_set_attr, - cur_set->cmd_set_value); - } - - /* Create the report and send success */ - mm_path_match_report(cmd, db); - cmd->cmd_remove = 1; - mm_send_response(mm_wka->mm_wka_conn, cmd); - - if (command_added) { - rc = MM_DISPATCH_AGAIN; - } else { - rc = MM_CMD_DONE; - } - goto end; - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - rc = MM_CMD_ERROR; - goto end; - -end: - /* Destroy the lists */ - /* Set List */ - for (cur_set = mms_list_head(&set_list); - cur_set != NULL; - cur_set = next) { - next = mms_list_next(&set_list, cur_set); - if (cur_set->cmd_set_obj) - free(cur_set->cmd_set_obj); - if (cur_set->cmd_set_attr) - free(cur_set->cmd_set_attr); - if (cur_set->cmd_set_value) - free(cur_set->cmd_set_value); - mms_list_remove(&set_list, - cur_set); - free(cur_set); - } - mms_list_destroy(&set_list); - free(cmd_buf); - - if (part_cart_id != NULL) - free(part_cart_id); - - return (rc); -} - - - -/* - * mm_get_task: - * returns allocated char*, caller must free - */ -char * -mm_get_task(mms_par_node_t *root) -{ - mms_par_node_t *node; - mms_par_node_t *tasknode; - char *task; - - node = mms_pn_lookup(root, "task", MMS_PN_CLAUSE, NULL); - if (node == NULL) { - mms_trace(MMS_DEBUG, - "mm_get_task couldn't find a task clause"); - return (NULL); - } - tasknode = mms_pn_lookup(node, NULL, MMS_PN_STRING, NULL); - if (tasknode == NULL) { - mms_trace(MMS_DEBUG, - "mm_get_task couldn't find the task string"); - return (NULL); - } - if (mms_pn_token(tasknode) == NULL) { - mms_trace(MMS_DEBUG, - "mm_get_task, task sting is null"); - return (NULL); - } - task = strdup(mms_pn_token(tasknode)); - return (task); -} - -int -mm_change_attendance_mode(mm_wka_t *mm_wka) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - PGresult *results; - char *reqid; - int messageid = 1001; - char *text = "unattened"; - char *buf; - int rc; - mm_command_t *cmd_p; - mm_data_t *data = mm_wka->mm_data; - int i; - - mms_trace(MMS_DEVP, "mm_change_attendance_mode"); - - /* - * SYSTEM.AttendanceMode was changed, respond to requests - * if unattended mode. - */ - - /* get mm operator attandance mode */ - if (mm_db_exec(HERE, db, "select \"AttendanceMode\" " - "from \"SYSTEM\";") != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - return (1); - } - if (PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - return (1); - } - rc = strcmp(PQgetvalue(db->mm_db_results, 0, 0), "attended"); - mm_clear_db(&db->mm_db_results); - if (rc == 0) { - mms_trace(MMS_DEVP, "mm is operator attened"); - return (0); - } - - mms_trace(MMS_DEVP, "mm is operator unattened"); - - /* respond to all outstanding requests */ - - if (mm_db_exec(HERE, db, "select \"RequestID\" from \"REQUEST\" " - "where \"RequestState\" != 'responded';") != MM_DB_DATA) { - return (1); - } - if (PQntuples(db->mm_db_results) == 0) { - mm_clear_db(&db->mm_db_results); - return (0); /* zero unfinished requests */ - } - results = db->mm_db_results; - - for (i = 0; i < PQntuples(results); i++) { - reqid = PQgetvalue(results, i, 0); - - /* set requests to responded */ - if (mm_db_exec(HERE, db, "update \"REQUEST\" set " - "\"RequestState\" = 'responded'," - "\"RequestTimeResponded\" = now()," - "\"ResponseManufacturer\" = '%s'," - "\"ResponseModel\" = '%s'," - "\"ResponseNumber\" = '%d'," - "\"ResponseText\" = $$%s$$," - "\"AcceptingClient\" = '%s'," - "\"AcceptingInstance\" = '%s'," - "\"AcceptingSessionID\" = default," - "\"RequestTimeAccepted\" = now() " - "where \"RequestID\" = '%s';", - MESS_MANUFACTURER, MESS_MODEL, messageid, text, - data->mm_cfg.mm_network_cfg.cli_name, - data->mm_cfg.mm_network_cfg.cli_inst, - reqid) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - mm_clear_db(&results); - return (1); - } - - if (db->mm_db_count != 1) { - continue; - } - - /* respond to request commands with unattended */ - pthread_mutex_lock(&data->mm_queue_mutex); - mms_list_foreach(&data->mm_cmd_queue, cmd_p) { - if (strcmp(cmd_p->cmd_reqid, reqid) == 0) { - break; - } - } - if (cmd_p == NULL) { - /* mm will clean this req up at client disconnect */ - pthread_mutex_unlock(&data->mm_queue_mutex); - continue; - } - - buf = mms_strnew("response task[\"%s\"] success " - "text[\"%d\" \"reply\" \"%s\"];", - cmd_p->cmd_task, messageid, text); - SQL_CHK_LEN(&cmd_p->cmd_buf, 0, &cmd_p->cmd_bufsize, - strlen(buf) + 1); - (void) strlcpy(cmd_p->cmd_buf, buf, cmd_p->cmd_bufsize); - free(buf); - - cmd_p->cmd_remove = 1; - if (mm_has_depend(cmd_p)) { - mm_command_t *cur_depend = NULL; - mms_trace(MMS_DEVP, "internal mm request"); - mms_list_foreach(&cmd_p->cmd_depend_list, cur_depend) { - cur_depend->cmd_response = - mm_text_to_par_node(cmd_p->cmd_buf, - mms_mmp_parse); - cur_depend->cmd_flags |= MM_CMD_DISPATCHABLE; - } - - /* - * Command queue tick so cmd_depend is valid. - */ - mms_list_remove(&data->mm_cmd_queue, cmd_p); - mms_list_insert_head(&data->mm_cmd_queue, cmd_p); - rc = 0; - } else { - mms_trace(MMS_DEVP, "device manager request"); - mm_send_text(cmd_p->wka_ptr->mm_wka_conn, - cmd_p->cmd_buf); - } - pthread_mutex_unlock(&data->mm_queue_mutex); - - } - mm_clear_db(&results); - - /* resize request history */ - if (mm_request_history_limit(db)) { - mms_trace(MMS_ERR, "unable to resize history"); - return (1); - } - - return (0); - -no_mem: - MM_ABORT_NO_MEM(); - return (1); -} - -int -mm_attendance_mode_internal(mm_wka_t *mm_wka, mm_command_t *cmd, - mm_command_t *req_cmd) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - int messageid = 1001; - char *text = "unattened"; - char *buf; - int rc; - mm_data_t *data = mm_wka->mm_data; - - mms_trace(MMS_DEVP, "mm_attendance_mode_internal"); - - /* - * Attendance mode for mm request - */ - - /* get mm operator attandance mode */ - if (mm_db_exec(HERE, db, "select \"AttendanceMode\" " - "from \"SYSTEM\";") != MM_DB_DATA) { - mms_trace(MMS_ERR, "unable to get attendance mode"); - mm_sql_db_err_rsp_new(req_cmd, db); - cmd->cmd_response = mm_text_to_par_node(req_cmd->cmd_buf, - mms_mmp_parse); - return (-1); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, "no results in attendance mode query"); - mm_clear_db(&db->mm_db_results); - mm_response_error(cmd, - ECLASS_INTERNAL, - MM_E_INTERNAL, - MM_5021_MSG, - "text", - "no results in attendance mode query", - NULL); - cmd->cmd_response = mm_text_to_par_node(req_cmd->cmd_buf, - mms_mmp_parse); - return (-1); - } - rc = strcmp(PQgetvalue(db->mm_db_results, 0, 0), "attended"); - mm_clear_db(&db->mm_db_results); - if (rc == 0) { - mms_trace(MMS_DEVP, "mm is operator attened"); - return (0); - } - - - mms_trace(MMS_DEVP, "mm is not attended by an operator"); - - /* set request to responded */ - if (mm_db_exec(HERE, db, "update \"REQUEST\" set " - "\"RequestState\" = 'responded'," - "\"RequestTimeResponded\" = now()," - "\"ResponseManufacturer\" = '%s'," - "\"ResponseModel\" = '%s'," - "\"ResponseNumber\" = '%d'," - "\"ResponseText\" = $$%s$$," - "\"AcceptingClient\" = '%s'," - "\"AcceptingInstance\" = '%s'," - "\"AcceptingSessionID\" = default," - "\"RequestTimeAccepted\" = now() " - "where \"RequestID\" = '%s';", - MESS_MANUFACTURER, MESS_MODEL, messageid, text, - data->mm_cfg.mm_network_cfg.cli_name, - data->mm_cfg.mm_network_cfg.cli_inst, - req_cmd->cmd_reqid) != MM_DB_OK) { - mms_trace(MMS_ERR, "failed to set unattended request"); - mm_sql_db_err_rsp_new(req_cmd, db); - mm_clear_db(&db->mm_db_results); - cmd->cmd_response = mm_text_to_par_node(req_cmd->cmd_buf, - mms_mmp_parse); - return (-1); - } - if (db->mm_db_count != 1) { - mms_trace(MMS_ERR, "set request unattended count not 1"); - mm_response_error(cmd, - ECLASS_INTERNAL, - MM_E_INTERNAL, - MM_5021_MSG, - "text", - "set request unattended count not 1", - NULL); - cmd->cmd_response = mm_text_to_par_node(req_cmd->cmd_buf, - mms_mmp_parse); - return (-1); - } - - /* resize request history */ - if (mm_request_history_limit(db)) { - mm_response_error(cmd, - ECLASS_SUBOP, - EREQSTATECHANGEFAILED, - MM_5089_MSG, - NULL); - cmd->cmd_response = mm_text_to_par_node(req_cmd->cmd_buf, - mms_mmp_parse); - return (-1); - } - - /* tell mm we're unattened */ - buf = mms_strnew("response task[\"%s\"] success " - "text[\"%d\" \"reply\" \"%s\"];", - cmd->cmd_task, messageid, text); - SQL_CHK_LEN(&req_cmd->cmd_buf, 0, &req_cmd->cmd_bufsize, - strlen(buf) + 1); - (void) strlcpy(req_cmd->cmd_buf, buf, req_cmd->cmd_bufsize); - free(buf); - cmd->cmd_response = mm_text_to_par_node(req_cmd->cmd_buf, - mms_mmp_parse); - cmd->cmd_flags |= MM_CMD_DISPATCHABLE; - return (1); - -no_mem: - MM_ABORT_NO_MEM(); - return (-1); -} - -int -mm_make_request(mm_wka_t *mm_wka, mm_command_t *cmd, char *task, int priority, - int messageid, ...) -{ - mm_command_t *req_cmd; - uuid_text_t new_task; - va_list args; - char *text; - uuid_text_t reqid_uuid; - mm_db_t *db = &mm_wka->mm_data->mm_db; - char *task_taskid = NULL; - int rows; - int rc; - mm_data_t *data = mm_wka->mm_data; - - mms_trace(MMS_DEVP, "mm_internal_request for %s", - (cmd->cmd_name == NULL ? "??" : cmd->cmd_name)); - - /* - * The mm is requesting operator intervention - */ - - req_cmd = (mm_command_t *)calloc(1, sizeof (mm_command_t)); - req_cmd->wka_ptr = mm_wka; - req_cmd->cmd_mm_data = mm_wka->mm_data; - mm_get_uuid(new_task); - va_start(args, messageid); - text = mms_get_locstr(messageid, args); - va_end(args); - req_cmd->cmd_name = strdup("mm request"); - req_cmd->cmd_textcmd = mms_strnew("internal \"%s\" " - "\"task\" \"%s\" \"priority\" \"%d\" " - "\"messageid\" \"%d\" \"locstr\" \"%s\";", - req_cmd->cmd_name, new_task, priority, messageid, text); - req_cmd->cmd_root = mm_text_to_par_node(req_cmd->cmd_textcmd, - mms_mmp_parse); - req_cmd->cmd_task = strdup(new_task); - mm_add_depend(req_cmd, cmd); - (void) strlcpy(req_cmd->wka_uuid, mm_wka->wka_conn.cci_uuid, - sizeof (req_cmd->wka_uuid)); - - /* get requestid */ - mm_get_uuid(reqid_uuid); - - /* set command reqid */ - strcpy(req_cmd->cmd_reqid, reqid_uuid); - - pthread_mutex_lock(&mm_wka->mm_data->mm_queue_mutex); - mms_list_insert_tail(&mm_wka->mm_data->mm_cmd_queue, req_cmd); - pthread_mutex_unlock(&mm_wka->mm_data->mm_queue_mutex); - - - /* - * Make internal mm request entry - */ - - - /* mm can have but does not need a valid task.taskid */ - if (task == MM_NO_TASK) { - /* no task.taskid */ - task_taskid = strdup("default"); - } else { - /* validate task.taskid */ - if (mm_db_exec(HERE, db, "select * from \"TASK\" " - "where \"TaskID\" = '%s';", cmd->cmd_uuid) != MM_DB_DATA) { - free(text); - mm_sql_db_err_rsp_new(req_cmd, db); - mm_clear_db(&db->mm_db_results); - cmd->cmd_response = - mm_text_to_par_node(req_cmd->cmd_buf, - mms_mmp_parse); - req_cmd->cmd_remove = 1; - return (1); - } - rows = PQntuples(db->mm_db_results); - mm_clear_db(&db->mm_db_results); - if (rows != 1) { - free(text); - if (rows == 0) { - mm_response_error(cmd, - ECLASS_EXPLICIT, - MM_E_NOTASK, - MM_5090_MSG, - NULL); - } else { - mm_response_error(cmd, - ECLASS_EXPLICIT, - MM_E_TOOMANYTASKS, - MM_5091_MSG, - NULL); - } - cmd->cmd_response = - mm_text_to_par_node(req_cmd->cmd_buf, - mms_mmp_parse); - req_cmd->cmd_remove = 1; - return (1); - } - task_taskid = mms_strnew("'%s'", cmd->cmd_uuid); - } - - rc = mm_db_exec(HERE, db, "insert into \"REQUEST\" " - "(\"RequestID\",\"RequestingTaskID\"," - "\"RequestingClient\",\"RequestingInstance\"," - "\"RequestingClientType\",\"RequestPriority\"," - "\"RequestManufacturer\",\"RequestModel\"," - "\"RequestNumber\",\"RequestText\",\"RequestHost\") " - "values ('%s',%s,'%s','%s','%s','%d'," - "'%s','%s','%d',$$%s$$,'%s');", - reqid_uuid, - task_taskid, - data->mm_cfg.mm_network_cfg.cli_name, - data->mm_cfg.mm_network_cfg.cli_inst, - MESS_MM_STR, - priority, - MESS_MANUFACTURER, - MESS_MODEL, - messageid, - text, - data->mm_host_name); - free(task_taskid); - free(text); - if (rc != MM_DB_OK) { - mm_sql_db_err_rsp_new(req_cmd, db); - mm_clear_db(&db->mm_db_results); - cmd->cmd_response = mm_text_to_par_node(req_cmd->cmd_buf, - mms_mmp_parse); - req_cmd->cmd_remove = 1; - return (1); - } - mms_trace(MMS_INFO, "Added internal mm request %s", reqid_uuid); - - /* mm operator attendance mode */ - if ((rc = mm_attendance_mode_internal(mm_wka, cmd, req_cmd)) != 0) { - mms_trace(MMS_DEVP, "failed doing internal attendance mode"); - /* - * Command queue tick so cmd_depend is valid. - */ - pthread_mutex_lock(&data->mm_queue_mutex); - req_cmd->cmd_remove = 1; - mms_list_remove(&data->mm_cmd_queue, req_cmd); - mms_list_insert_head(&data->mm_cmd_queue, req_cmd); - pthread_mutex_unlock(&data->mm_queue_mutex); - if (rc == 1) { - rc = 0; /* unattended */ - } else { - rc = 1; /* error */ - } - return (rc); - } - - return (0); -} - -int -mm_cancel_request(mm_db_t *db, char *reqid) -{ - - if (reqid[0] == (char)0) { - return (0); /* no request */ - } - - if (mm_db_exec(HERE, db, "delete from \"REQUEST\" where " - "\"RequestID\" = '%s' and \"RequestState\" != 'responded';", - reqid) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - return (1); - } - - mms_trace(MMS_DEVP, "deleted request %s - %d", reqid, db->mm_db_count); - - return (0); -} - -int -mm_attendance_mode(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - int messageid = 1001; - char *text = "unattened"; - char *buf; - mm_data_t *data = mm_wka->mm_data; - int rc; - - mms_trace(MMS_DEVP, "mm_attendance_mode"); - - /* - * Attendance mode for device manager request - */ - - /* get mm operator attandance mode */ - if (mm_db_exec(HERE, db, "select \"AttendanceMode\" " - "from \"SYSTEM\";") != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - mm_system_error(cmd, - "too many rows returned " - "getting SYSTEM.AttendanveMode"); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - rc = strcmp(PQgetvalue(db->mm_db_results, 0, 0), "attended"); - mm_clear_db(&db->mm_db_results); - if (rc == 0) { - mms_trace(MMS_DEVP, "mm is operator attened"); - return (MM_WORK_TODO); - } - - - mms_trace(MMS_DEVP, "mm is not attended by an operator"); - - /* set request to responded */ - if (mm_db_exec(HERE, db, "update \"REQUEST\" set " - "\"RequestState\" = 'responded'," - "\"RequestTimeResponded\" = now()," - "\"ResponseManufacturer\" = '%s'," - "\"ResponseModel\" = '%s'," - "\"ResponseNumber\" = '%d'," - "\"ResponseText\" = $$%s$$," - "\"AcceptingClient\" = '%s'," - "\"AcceptingInstance\" = '%s'," - "\"AcceptingSessionID\" = default," - "\"RequestTimeAccepted\" = now() " - "where \"RequestID\" = '%s';", - MESS_MANUFACTURER, MESS_MODEL, messageid, text, - data->mm_cfg.mm_network_cfg.cli_name, - data->mm_cfg.mm_network_cfg.cli_inst, - cmd->cmd_reqid) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - if (db->mm_db_count != 1) { - mm_system_error(cmd, - "failed to correctly " - "update request object"); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - /* resize request history */ - if (mm_request_history_limit(db)) { - mm_response_error(cmd, - ECLASS_SUBOP, - EREQSTATECHANGEFAILED, - MM_5089_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - /* tell device manager we're unattened */ - buf = mms_strnew("response task[\"%s\"] success " - "text[\"%d\" \"reply\" \"%s\"];", - cmd->cmd_task, messageid, text); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, strlen(buf) + 1); - strcpy(cmd->cmd_buf, buf); - free(buf); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_DONE); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -} - -void -mm_request_tasktaskid(mm_command_t *cmd, char *tasktaskid, char **taskid) -{ - mm_db_t *db = &cmd->wka_ptr->mm_data->mm_db; - mm_data_t *data = cmd->cmd_mm_data; - mm_command_t *cmd_p; - mm_command_t *cmd_q; - - mms_trace(MMS_DEVP, "mm_request_tasktaskid %s", tasktaskid); - - *taskid = NULL; - - /* - * taskid is mm command which cause the request, - * find the mm command in the command queue which - * contains the mm task.taskid. - */ - - pthread_mutex_lock(&data->mm_queue_mutex); - mms_list_foreach(&data->mm_cmd_queue, cmd_p) { - - if (cmd_p->wka_ptr == NULL) - continue; - - if (strcmp(tasktaskid, cmd_p->cmd_task) == 0) { - - /* find parent command */ - cmd_q = mm_top_parent(cmd_p); - - /* this maybe be our task.taskid */ - *taskid = strdup(cmd_q->cmd_uuid); - if (*taskid == NULL) { - MM_ABORT_NO_MEM(); - } - break; - } - } - pthread_mutex_unlock(&data->mm_queue_mutex); - - if (*taskid == NULL) { - mms_trace(MMS_DEVP, "taskid not found"); - return; - } - - if (mm_db_exec(HERE, db, "select \"TaskID\" from \"TASK\" where " - "\"TaskID\" = '%s';", *taskid) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - free(*taskid); - *taskid = NULL; - return; - } - if (PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - free(*taskid); - *taskid = NULL; - return; - } - mm_clear_db(&db->mm_db_results); -} - -int -mm_request_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *clause; - mms_par_node_t *name; - mms_par_node_t *value; - mms_par_node_t *arg; - int priority; - char *obj; - char *attr; - int rc; - uuid_text_t reqid_uuid; - mm_db_t *db = &mm_wka->mm_data->mm_db; - char *taskid = NULL; - char taskid_buf[UUID_PRINTF_SIZE+3]; - - mms_trace(MMS_DEVP, "mm_request_cmd_func"); - - /* - * Device manager or mmp client is requesting operator intervention - */ - - MMS_PN_LOOKUP(arg, cmd->cmd_root, "type", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, arg, NULL, MMS_PN_OBJ, NULL); - - - MMS_PN_LOOKUP(clause, cmd->cmd_root, "priority", - MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, clause, NULL, MMS_PN_STRING, NULL); - priority = atoi(value->pn_string); - - /* - * find optional task.taskid for device manager - */ - - if (mm_msg_parse(cmd, cmd->cmd_root)) { - free(taskid); - mm_response_error(cmd, - ECLASS_INTERNAL, MM_E_CMDARGS, - MM_5067_MSG, - "text", - "mission task.taskid for device manager", - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - /* optional - find task by mm dmp/lmp command taskid */ - if (cmd->cmd_msg.msg_args) { - - mms_trace(MMS_DEVP, - "find task.taskid by message-clause argument"); - - /* - * reserved request message-clause arg-key word: - * tasktaskid - mm command taskid - */ - - mms_list_pair_foreach(cmd->cmd_msg.msg_args, name, value) { - - if (strcmp(mms_pn_token(name), "tasktaskid") == 0) { - mm_request_tasktaskid(cmd, - mms_pn_token(value), - &taskid); - break; - } - } - } - - if (taskid == NULL && mm_wka->mm_wka_mm_lang != MM_LANG_MMP) { - - /* - * If one and only one task for a device manager exists then - * assign it to the request object. - */ - - if (mm_wka->mm_wka_mm_lang == MM_LANG_DMP) { - obj = "TASKDRIVE"; - attr = "DriveName"; - } else { - obj = "TASKLIBRARY"; - attr = "LibraryName"; - } - - if (mm_db_exec(HERE, db, "select \"TASK\".\"TaskID\" " - "from \"TASK\",\"%s\" where " - "\"TASK\".\"TaskID\" = \"%s\".\"TaskID\" and " - "\"%s\".\"%s\" = '%s';", obj, obj, obj, attr, - cmd->wka_ptr->wka_conn.cci_client) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) == 1) { - taskid = strdup(PQgetvalue(db->mm_db_results, 0, 0)); - if (taskid == NULL) { - MM_ABORT_NO_MEM(); - } - } - mm_clear_db(&db->mm_db_results); - } - - if (taskid) { - mms_trace(MMS_DEVP, "taskid %s found", taskid); - (void) snprintf(taskid_buf, sizeof (taskid_buf), - "'%s'", taskid); - free(taskid); - } else { - mms_trace(MMS_DEVP, "taskid not found"); - (void) strlcpy(taskid_buf, "default", sizeof (taskid_buf)); - } - - /* - * Make request entry - */ - - mm_get_uuid(reqid_uuid); - - rc = mm_db_exec(HERE, db, "insert into \"REQUEST\" " - "(\"RequestID\",\"RequestingTaskID\"," - "\"RequestingClient\",\"RequestingInstance\"," - "\"RequestingConnectionID\",\"RequestingClientType\"," - "\"RequestPriority\",\"RequestManufacturer\"," - "\"RequestModel\",\"RequestNumber\"," - "\"RequestText\",\"RequestHost\") " - "values ('%s',%s,'%s','%s','%s','%s','%d'," - "'%s','%s','%d',$$%s$$,'%s');", - reqid_uuid, - taskid_buf, - cmd->wka_ptr->wka_conn.cci_client, - cmd->wka_ptr->wka_conn.cci_instance, - cmd->wka_ptr->wka_conn.cci_uuid, - mm_msg_lang2component(cmd->wka_ptr->mm_wka_mm_lang), - priority, - cmd->cmd_msg.msg_manufacturer, - cmd->cmd_msg.msg_model, - cmd->cmd_msg.msg_messageid, - cmd->cmd_msg.msg_localized, - cmd->wka_ptr->wka_conn.cci_host); - if (rc != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&db->mm_db_results); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - - /* set command reqid */ - strcpy(cmd->cmd_reqid, reqid_uuid); - - mms_trace(MMS_INFO, "Added request"); - - /* mm operator attendance mode */ - if ((rc = mm_attendance_mode(mm_wka, cmd)) != MM_WORK_TODO) { - mms_trace(MMS_DEVP, "unattened or error"); - return (rc); - } - - mms_trace(MMS_DEVP, "operator has request"); - return (MM_WORK_TODO); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -} - -int -mm_request_disconnect(mm_db_t *db, mm_wka_t *mm_wka) -{ - /* - * Cleanup disconnected client requests - */ - - if (mm_wka->mm_wka_mm_lang == MM_LANG_MMP) { - - /* - * Release all requests accepted by this operator - */ - if (mm_db_exec(HERE, db, "update \"REQUEST\" set " - "\"AcceptingClient\" = default," - "\"AcceptingInstance\" = default," - "\"AcceptingSessionID\" = default," - "\"RequestTimeAccepted\" = default," - "\"RequestState\" = 'pending' " - "where \"AcceptingSessionID\" = '%s' " - "and \"RequestState\" != 'responded';", - mm_wka->session_uuid) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - return (1); - } - - } - - /* - * Remove all requests generated by this device manager - * or mmp client. - */ - if (mm_db_exec(HERE, db, "delete from \"REQUEST\" where " - "\"RequestingClient\" = '%s' and " - "\"RequestingInstance\" = '%s' and " - "\"RequestState\" != 'responded' and " - "\"RequestingConnectionID\" = '%s';", - mm_wka->wka_conn.cci_client, - mm_wka->wka_conn.cci_instance, - mm_wka->wka_conn.cci_uuid) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - return (1); - } - - return (0); -} - -int -mm_get_requests(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_db_t *db = &cmd->wka_ptr->mm_data->mm_db; - mms_par_node_t *reqid; - mms_par_node_t *arg; - char *buf; - const char *query; - - mms_trace(MMS_DEVP, "mm_get_requests"); - - /* - * Find requests state info for the accept and release commands - */ - - /* get requests */ - if (mms_pn_lookup(cmd->cmd_root, "match", MMS_PN_CLAUSE, NULL)) { - (void) mm_get_dest(mm_wka, cmd); - (void) mm_get_const(mm_wka, cmd); /* constraints */ - if (mm_add_char("REQUEST", &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_get_requests: " - "out of mem creating source list"); - mm_system_error(cmd, - "out of mem creating source list"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - cmd->cmd_source_num = 1; - query = "select \"REQUEST\".\"RequestID\"," - "\"REQUEST\".\"RequestState\"," - "\"REQUEST\".\"AcceptingSessionID\" from "; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(query) + 1); - strcpy(cmd->cmd_buf, query); - if (mm_sql_from_where(cmd, db)) { - mms_trace(MMS_ERR, - "mm_get_requests: " - "db error creating helper functions"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - - } else if (reqid = mms_pn_lookup(cmd->cmd_root, "reqid", - MMS_PN_CLAUSE, NULL)) { - buf = NULL; - query = "(\"REQUEST\".\"RequestID\" = '%s')"; - mms_list_foreach(&reqid->pn_arglist, arg) { - buf = mms_strapp(buf, query, arg->pn_string); - if (arg != mms_list_tail(&reqid->pn_arglist)) { - buf = mms_strapp(buf, " or "); - } - } - query = "select \"REQUEST\".\"RequestID\"," - "\"REQUEST\".\"RequestState\"," - "\"REQUEST\".\"AcceptingSessionID\" from " - "\"REQUEST\" where (%s) "; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(query) + strlen(buf) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, query, buf); - free(buf); - } else { - mm_response_error(cmd, - ECLASS_EXIST, ENOMATCH, - MM_5092_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - mm_sql_order(cmd); - mm_sql_number(cmd); - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - /* check request count */ - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_DEVP, "no requests selected"); - mm_clear_db(&db->mm_db_results); - if (mms_pn_lookup(cmd->cmd_root, "match", - MMS_PN_CLAUSE, NULL)) { - mm_response_error(cmd, - ECLASS_EXIST, ENOMATCH, - MM_5092_MSG, - NULL); - } else { - mm_response_error(cmd, - ECLASS_EXIST, ENOSUCHREQ, - MM_5093_MSG, - NULL); - } - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - /* caller frees tuples */ - return (0); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -} - -int -mm_accept_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_db_t *db = &cmd->wka_ptr->mm_data->mm_db; - int rc; - int error; - int i; - char *state; - char *buf; - char *more; - - mms_trace(MMS_DEVP, "mm_accept_cmd_func"); - - if (mm_privileged(mm_wka, cmd) == MM_PRIV_STANDARD) { - return (MM_CMD_ERROR); - } - - /* - * Operator wants to work on device manager or mm requests - */ - - if (rc = mm_get_requests(mm_wka, cmd)) { - return (rc); - } - - /* check for pending requests */ - error = 0; - for (i = 0; i < PQntuples(db->mm_db_results); i++) { - PQgetvalue(db->mm_db_results, i, 0); - state = PQgetvalue(db->mm_db_results, i, 1); - if (strcmp(state, "accepted") == 0) { - mm_set_cmd_err_buf(cmd, - ECLASS_INVALID, - EREQUESTALREADYACCEPTED); - error = 1; - } else if (strcmp(state, "responded") == 0) { - mm_set_cmd_err_buf(cmd, - ECLASS_INVALID, - EREQUESTALREADYSATISFIED); - error = 1; - } - if (error) { - mm_clear_db(&db->mm_db_results); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - } - - /* accept selected requests */ - buf = mms_strnew("update \"REQUEST\" set " - "\"AcceptingClient\" = '%s'," - "\"AcceptingInstance\" = '%s'," - "\"AcceptingSessionID\" = '%s'," - "\"RequestState\" = 'accepted'," - "\"RequestTimeAccepted\" = now() where ", - cmd->wka_ptr->wka_conn.cci_client, - cmd->wka_ptr->wka_conn.cci_instance, - cmd->wka_ptr->session_uuid); - more = "or "; - for (i = 0; i < PQntuples(db->mm_db_results); i++) { - mms_trace(MMS_DEVP, "selected request id -> %s", - PQgetvalue(db->mm_db_results, i, 0)); - if (i + 1 >= PQntuples(db->mm_db_results)) { - more = ";"; - } - buf = mms_strapp(buf, "(\"RequestID\" = '%s') %s", - PQgetvalue(db->mm_db_results, i, 0), more); - } - rc = mm_db_exec(HERE, db, buf); - free(buf); - if (rc != MM_DB_OK) { - mm_response_error(cmd, - ECLASS_SUBOP, - EREQSTATECHANGEFAILED, - MM_5089_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - /* get report */ - mm_path_match_report(cmd, db); - mm_send_response(mm_wka->mm_wka_conn, cmd); - cmd->cmd_remove = 1; - return (MM_CMD_DONE); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -} - -int -mm_respond_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_db_t *db = &cmd->wka_ptr->mm_data->mm_db; - mm_data_t *data = mm_wka->mm_data; - mms_par_node_t *clause; - mms_par_node_t *value; - char *reqid; - mm_command_t *cmd_p; - char *state; - char *session; - int messageid = 1000; - char *buf; - - mms_trace(MMS_DEVP, "mm_respond_cmd_func"); - - /* - * Operator finished device manager, mm or app request - */ - - MMS_PN_LOOKUP(clause, cmd->cmd_root, "reqid", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, clause, NULL, MMS_PN_STRING, NULL); - reqid = value->pn_string; - - /* get request response message */ - if (mm_msg_parse(cmd, cmd->cmd_root)) { - mm_system_error(cmd, - "failed to parse request response"); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - mms_trace(MMS_DEVP, "reply message info: %d %s %s - %s", - cmd->cmd_msg.msg_messageid, - cmd->cmd_msg.msg_manufacturer, - cmd->cmd_msg.msg_model, - cmd->cmd_msg.msg_localized); - - /* validate client request response */ - if (mm_db_exec(HERE, db, "select \"RequestState\"," - "\"AcceptingSessionID\" from \"REQUEST\" where " - "\"RequestID\" = '%s';", reqid) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - state = PQgetvalue(db->mm_db_results, 0, 0); - session = PQgetvalue(db->mm_db_results, 0, 1); - if (PQntuples(db->mm_db_results) == 0) { - mm_clear_db(&db->mm_db_results); - mm_response_error(cmd, - ECLASS_EXIST, ENOSUCHREQ, - MM_5093_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - if (strcmp(state, "pending") == 0) { - mm_clear_db(&db->mm_db_results); - mm_set_cmd_err_buf(cmd, ECLASS_INVALID, EREQUESTNOTACCEPTED); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - if (strcmp(state, "responded") == 0) { - mm_clear_db(&db->mm_db_results); - mm_set_cmd_err_buf(cmd, - ECLASS_INVALID, - EREQUESTALREADYSATISFIED); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - if (strcmp(session, mm_wka->session_uuid) != 0) { - mm_clear_db(&db->mm_db_results); - mm_set_cmd_err_buf(cmd, ECLASS_INVALID, EREQACCEPTEDBYDIFFSESS); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - - /* set request to responded */ - if (mm_db_exec(HERE, db, "update \"REQUEST\" set " - "\"RequestState\" = 'responded'," - "\"RequestTimeResponded\" = now()," - "\"ResponseManufacturer\" = '%s'," - "\"ResponseModel\" = '%s'," - "\"ResponseNumber\" = '%d'," - "\"ResponseText\" = $$%s$$," - "\"AcceptingSessionID\" = default where " - "\"RequestID\" = '%s' and " - "\"AcceptingSessionID\" = '%s';", - cmd->cmd_msg.msg_manufacturer, - cmd->cmd_msg.msg_model, - cmd->cmd_msg.msg_messageid, - cmd->cmd_msg.msg_localized, - reqid, mm_wka->session_uuid) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - mm_response_error(cmd, - ECLASS_SUBOP, - EREQSTATECHANGEFAILED, - MM_5089_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - /* resize request history */ - if (mm_request_history_limit(db)) { - mm_response_error(cmd, - ECLASS_SUBOP, - EREQSTATECHANGEFAILED, - MM_5089_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - /* find device manager command that generated request */ - pthread_mutex_lock(&data->mm_queue_mutex); - mms_list_foreach(&data->mm_cmd_queue, cmd_p) { - if (strcmp(cmd_p->cmd_reqid, reqid) == 0) { - break; - } - } - if (cmd_p) { - /* send device manager, mm or app request response */ - buf = mms_strnew("response task[\"%s\"] success " - "text[\"%d\" \"reply\" \"%s\"];", - cmd_p->cmd_task, messageid, - cmd->cmd_msg.msg_localized); - SQL_CHK_LEN(&cmd_p->cmd_buf, 0, &cmd_p->cmd_bufsize, - strlen(buf) + 1); - strcpy(cmd_p->cmd_buf, buf); - free(buf); - cmd_p->cmd_remove = 1; - if (mm_has_depend(cmd_p)) { - mm_command_t *cur_depend = NULL; - mms_trace(MMS_DEVP, "internal mm request"); - mms_list_foreach(&cmd_p->cmd_depend_list, cur_depend) { - cur_depend->cmd_response = - mm_text_to_par_node(cmd_p->cmd_buf, - mms_mmp_parse); - cur_depend->cmd_flags |= MM_CMD_DISPATCHABLE; - } - mms_list_remove(&data->mm_cmd_queue, cmd_p); - mms_list_insert_head(&data->mm_cmd_queue, cmd_p); - } else { - mms_trace(MMS_DEVP, "device manager request"); - mm_send_text(cmd_p->wka_ptr->mm_wka_conn, - cmd_p->cmd_buf); - } - } - pthread_mutex_unlock(&data->mm_queue_mutex); - if (cmd_p == NULL) { - mm_response_error(cmd, - ECLASS_EXIST, ENOSUCHREQ, - MM_5093_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_DONE); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -} - -/* Change request history size and do repairs if required. */ -int -mm_request_history_limit(mm_db_t *db) -{ - int limit; - int count; - int actual_count; - - mms_trace(MMS_DEVP, "mm_request_history_limit"); - - if (mm_db_exec(HERE, db, "select \"SystemRequestLimit\"," - "\"SystemRequestCount\" from \"SYSTEM\";") != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - return (1); - } - limit = atoi(PQgetvalue(db->mm_db_results, 0, 0)); - count = atoi(PQgetvalue(db->mm_db_results, 0, 1)); - mm_clear_db(&db->mm_db_results); - - if (mm_db_exec(HERE, db, "select \"RequestID\" " - "from \"REQUEST\" " - "where \"RequestState\" = 'responded';") != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - return (1); - } - actual_count = PQntuples(db->mm_db_results); - mm_clear_db(&db->mm_db_results); - - if (count != actual_count) { - count = actual_count; - } - - /* limit could be zero which means the request history is off */ - while (count > limit) { - /* delete oldest responded to request from request history */ - if (mm_db_exec(HERE, db, "delete from \"REQUEST\" " - "where \"RequestID\" = (select \"RequestID\" " - "from \"REQUEST\" where \"RequestState\" = 'responded' " - "order by \"RequestTimeResponded\" " - "limit 1);") != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - return (1); - } - if (db->mm_db_count != 1) { - return (1); - } - count--; - } - - if (count < 0) { - count = 0; - } - - if (mm_db_exec(HERE, db, "update \"SYSTEM\" set " - "\"SystemRequestCount\" = '%d';", count) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - return (1); - } - - return (0); -} - -int -mm_release_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_db_t *db = &cmd->wka_ptr->mm_data->mm_db; - int rc; - int error; - int i; - char *state; - char *session; - char *buf; - char *more; - - mms_trace(MMS_DEVP, "mm_release_cmd_func"); - - /* - * Release requests accepted by this operator - */ - - if (rc = mm_get_requests(mm_wka, cmd)) { - return (rc); - } - - /* check for this session's accepted requests */ - error = 0; - for (i = 0; i < PQntuples(db->mm_db_results); i++) { - PQgetvalue(db->mm_db_results, i, 0); - state = PQgetvalue(db->mm_db_results, i, 1); - session = PQgetvalue(db->mm_db_results, i, 2); - if (strcmp(state, "accepted") == 0) { - /* - * A system privileged client can release any - * request accepted by any client. - */ - if (mm_privileged(mm_wka, cmd) != MM_PRIV_SYSTEM) { - /* - * An admin privileged client can only - * release their accepeted requests. - */ - if (strcmp(cmd->wka_ptr->session_uuid, - session) != 0) { - mm_set_cmd_err_buf(cmd, - ECLASS_INVALID, - EREQACCEPTEDBYDIFFSESS); - error = 1; - } - } - } else { - mm_set_cmd_err_buf(cmd, - ECLASS_INVALID, - EREQUESTNOTACCEPTED); - error = 1; - } - if (error) { - mm_clear_db(&db->mm_db_results); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - } - - /* set request state to pending */ - buf = mms_strnew("update \"REQUEST\" set " - "\"AcceptingClient\" = default," - "\"AcceptingInstance\" = default," - "\"AcceptingSessionID\" = default," - "\"RequestState\" = 'pending'," - "\"RequestTimeAccepted\" = default where "); - more = "or "; - for (i = 0; i < PQntuples(db->mm_db_results); i++) { - mms_trace(MMS_DEVP, "selected request id -> %s", - PQgetvalue(db->mm_db_results, i, 0)); - if (i + 1 >= PQntuples(db->mm_db_results)) { - more = ";"; - } - buf = mms_strapp(buf, "(\"RequestID\" = '%s') %s", - PQgetvalue(db->mm_db_results, i, 0), more); - } - mm_clear_db(&db->mm_db_results); - rc = mm_db_exec(HERE, db, buf); - free(buf); - mm_clear_db(&db->mm_db_results); - if (rc != MM_DB_OK) { - mm_response_error(cmd, - ECLASS_SUBOP, - EREQSTATECHANGEFAILED, - MM_5089_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - /* get report */ - mm_path_match_report(cmd, db); - mm_send_response(mm_wka->mm_wka_conn, cmd); - cmd->cmd_remove = 1; - return (MM_CMD_DONE); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -} - -int -mm_cancel_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_data_t *data = mm_wka->mm_data; - mm_db_t *db = &mm_wka->mm_data->mm_db; - mm_command_t *cmd_p; - mm_command_t *cmd_q; - char *cmd_name = NULL; - char *reqid; - char *req_cid; - char *reqstate; - PGresult *results; - char *query; - char *constraint; - - mms_trace(MMS_DEVP, "mm_cancel_cmd_func"); - - (void) mm_get_dest(mm_wka, cmd); - (void) mm_get_const(mm_wka, cmd); - if (mm_add_char("REQUEST", &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_cancel_cmd_func: " - "out of mem creating source list"); - mm_system_error(cmd, - "out of mem creating source list"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - cmd->cmd_source_num = 1; - query = "select distinct \"REQUEST\".\"RequestID\"," - "\"REQUEST\".\"RequestingConnectionID\"," - "\"REQUEST\".\"RequestState\" from "; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(query) + 1); - strcpy(cmd->cmd_buf, query); - if (mm_sql_from_where(cmd, db)) { - mms_trace(MMS_ERR, - "mm_cancel_cmd_func: " - "db error creating helper functions"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, - cmd->cmd_buf); - return (MM_CMD_ERROR); - } - constraint = "and (\"REQUEST\".\"RequestingClientType\" = 'AI')"; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(constraint) + 1); - strcat(cmd->cmd_buf, constraint); - mm_sql_order(cmd); - mm_sql_number(cmd); - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) == 0) { - mm_set_cmd_err_buf(cmd, ECLASS_EXPLICIT, ENOMATCH); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } else if (PQntuples(db->mm_db_results) > 1) { - mm_set_cmd_err_buf(cmd, ECLASS_EXPLICIT, ETOOMANY); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - reqid = PQgetvalue(db->mm_db_results, 0, 0); - req_cid = PQgetvalue(db->mm_db_results, 0, 1); - reqstate = PQgetvalue(db->mm_db_results, 0, 2); - results = db->mm_db_results; - - if (strcmp(reqstate, "responded") == 0) { - mm_clear_db(&results); - mm_set_cmd_err_buf(cmd, ECLASS_EXIST, ENOCANCELLABLETASKS); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } else if (strcmp(req_cid, mm_wka->wka_conn.cci_uuid) != 0) { - if (mm_privileged(mm_wka, cmd) == MM_PRIV_STANDARD) { - mm_clear_db(&results); - return (MM_CMD_ERROR); - } - } - - pthread_mutex_lock(&data->mm_queue_mutex); - mms_list_foreach(&data->mm_cmd_queue, cmd_p) { - if (strcmp(reqid, cmd_p->cmd_reqid) == 0) { - - /* is this a command we know how to cancel */ - if (strcmp(mms_pn_token(cmd_p->cmd_root), - "request") == 0) { - cmd_name = strdup("request"); - } - break; - } - } - pthread_mutex_unlock(&data->mm_queue_mutex); - - /* command not found */ - if (cmd_p == NULL) { - mm_clear_db(&results); - mm_set_cmd_err_buf(cmd, ECLASS_EXIST, ENOCANCELLABLETASKS); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - /* cancel command */ - if (strcmp(cmd_name, "request") == 0) { - free(cmd_name); - if (mm_cancel_request(db, reqid)) { - mm_clear_db(&results); - mm_set_cmd_err_buf(cmd, ECLASS_INTERNAL, EDATABASE); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - } else { - free(cmd_name); - mm_clear_db(&results); - mm_set_cmd_err_buf(cmd, ECLASS_EXIST, ENOCANCELLABLETASKS); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - mm_clear_db(&results); - - /* send cancelled command's final-command response */ - pthread_mutex_lock(&data->mm_queue_mutex); - mms_list_foreach(&data->mm_cmd_queue, cmd_q) { - if (cmd_q == cmd_p) { - /* send cancelled command response */ - SQL_CHK_LEN(&cmd_p->cmd_buf, 0, &cmd_p->cmd_bufsize, - strlen(RESPONSE_CANCELLED) + - strlen(cmd_p->cmd_task) + 1); - (void) snprintf(cmd_p->cmd_buf, cmd->cmd_bufsize, - RESPONSE_CANCELLED, cmd_p->cmd_task); - mm_send_text(cmd_p->wka_ptr->mm_wka_conn, - cmd_p->cmd_buf); - cmd_p->cmd_remove = 1; - break; - } - } - pthread_mutex_unlock(&data->mm_queue_mutex); - - /* same command not found or error sending cancelled response */ - if (cmd_q == NULL) { - mm_system_error(cmd, - "same command not found or " - "error sending cancelled response"); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_DONE); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -} - -int -mm_identity_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - const char *response; - - mms_trace(MMS_DEVP, "mm_identity_cmd_func"); - - response = "response task[\"%s\"] success " - "text [\"ConnectionID\" \"%s\" " - "\"SessionID\" \"%s\"];"; - - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(response) + strlen(cmd->cmd_task) + - strlen(mm_wka->wka_conn.cci_uuid) + - strlen(mm_wka->session_uuid) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, response, - cmd->cmd_task, mm_wka->wka_conn.cci_uuid, mm_wka->session_uuid); - - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_DONE); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -} - -int -mm_direct_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *clause; - mms_par_node_t *value; - mms_par_node_t *tw; - char *to; - char *event = NULL; - mm_data_t *data = mm_wka->mm_data; - mm_wka_t *wka; - - mms_trace(MMS_DEVP, "mm_direct_cmd_func"); - - MMS_PN_LOOKUP(clause, cmd->cmd_root, "to", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, clause, NULL, MMS_PN_STRING, NULL); - to = mms_pn_token(value); - - tw = NULL; - MMS_PN_LOOKUP(clause, cmd->cmd_root, "data", MMS_PN_CLAUSE, NULL); - event = mms_strnew("event direct['%s' ", mm_wka->wka_conn.cci_uuid); - while ((value = mms_pn_lookup(clause, NULL, - MMS_PN_STRING, &tw)) != NULL) { - event = mms_strapp(event, "'%s' ", mms_pn_token(value)); - } - event = mms_strapp(event, "];"); - - mms_list_foreach(&data->mm_wka_list, wka) { - if (strcmp(wka->wka_conn.cci_uuid, to) == 0) { - /* to wka found */ - break; - } - } - if (wka == NULL) { - free(event); - mm_response_error(cmd, - ECLASS_EXIST, - ENOTCONNECTED, - MM_5100_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - mms_trace(MMS_DEVP, "direct command\n" - " from %s - %s %s\n" - " to %s - %s %s", - mm_wka->wka_conn.cci_uuid, - mm_wka->wka_conn.cci_client, - mm_wka->wka_conn.cci_instance, - wka->wka_conn.cci_uuid, - wka->wka_conn.cci_client, - wka->wka_conn.cci_instance); - - mm_send_text(wka->mm_wka_conn, event); - free(event); - - - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_DONE); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -} - -int -mm_setpassword_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *clause; - mms_par_node_t *value; - char *password = NULL; - char *oldpassword = NULL; - char *clientname = NULL; - mm_db_t *db = &mm_wka->mm_data->mm_db; - PGresult *results; - char *pass; - int error; - - mms_trace(MMS_DEVP, "mm_setpassword_cmd_func"); - - MMS_PN_LOOKUP(clause, cmd->cmd_root, "password", - MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, clause, NULL, MMS_PN_STRING, NULL); - password = mms_pn_token(value); - - if (clause = mms_pn_lookup(cmd->cmd_root, "oldpassword", - MMS_PN_CLAUSE, NULL)) { - - mms_trace(MMS_DEBUG, "client changing own password"); - - MMS_PN_LOOKUP(value, clause, NULL, MMS_PN_STRING, NULL); - oldpassword = mms_pn_token(value); - - clientname = mm_wka->wka_conn.cci_client; - - if (mm_db_exec_si(HERE, db, - "select \"Password\" from \"MMPASSWORD\" where " - "\"ApplicationName\" = '%s';", - clientname) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + - strlen(cmd->cmd_task) + - strlen(ECLASS_INTERNAL) + - strlen(EDATABASE) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INTERNAL, EDATABASE); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - results = db->mm_db_results; - if (mm_db_exec_si(HERE, db, - "select mm_func_getpassword('%s');", - oldpassword) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&results); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - mm_clear_db(&results); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + - strlen(cmd->cmd_task) + - strlen(ECLASS_INTERNAL) + - strlen(EDATABASE) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INTERNAL, EDATABASE); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - /* compare password hashes */ - if (strcmp(PQgetvalue(results, 0, 0), - PQgetvalue(db->mm_db_results, 0, 0)) != 0) { - mm_clear_db(&db->mm_db_results); - mm_clear_db(&results); - mm_response_error(cmd, - ECLASS_INVALID, - ENOMATCH, - MM_5106_MSG, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - mm_clear_db(&results); - - } else if (clause = mms_pn_lookup(cmd->cmd_root, "name", - MMS_PN_CLAUSE, NULL)) { - - mms_trace(MMS_DEBUG, "admin changing client password"); - - MMS_PN_LOOKUP(value, clause, NULL, MMS_PN_STRING, NULL); - clientname = mms_pn_token(value); - - mms_trace(MMS_DEBUG, "client %s", clientname); - - if (mm_privileged(mm_wka, cmd) == MM_PRIV_STANDARD) { - return (MM_CMD_ERROR); - } - } else { - goto not_found; - } - - if (mm_db_exec_si(HERE, db, - "update \"MMPASSWORD\" set \"Password\" = '%s' " - "where \"ApplicationName\" = '%s';", - password, clientname) != MM_DB_OK) { - mm_sql_db_err_rsp_new(cmd, db); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - if (db->mm_db_count != 1) { - mm_clear_db(&db->mm_db_results); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + - strlen(cmd->cmd_task) + - strlen(ECLASS_INTERNAL) + - strlen(EDATABASE) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INTERNAL, EDATABASE); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - - if (strcmp(clientname, MM_APP) == 0) { - mms_trace(MMS_DEBUG, "update file %s", MMS_NET_CFG_HELLO_FILE); - - error = 0; - pass = mms_net_cfg_read_pass_file(MMS_NET_CFG_HELLO_FILE); - if (pass == NULL) { - mms_trace(MMS_ERR, "read failed"); - error = 1; - } else if (strcmp(pass, password) != 0) { - if (mms_net_cfg_write_pass_file(MMS_NET_CFG_HELLO_FILE, - password)) { - mms_trace(MMS_ERR, "write failed"); - error = 1; - } else { - mms_trace(MMS_DEBUG, "refresh watcher"); - (void) smf_refresh_instance(MMS_CFG_WCR_INST); - } - } - if (pass) - free(pass); - if (error) { - mm_response_error(cmd, - ECLASS_INTERNAL, - MM_E_INTERNAL, - MM_5107_MSG, - "file", MMS_NET_CFG_HELLO_FILE, - NULL); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (MM_CMD_ERROR); - } - } - - mms_trace(MMS_DEBUG, "updated password"); - - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_DONE); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -} diff --git a/usr/src/cmd/mms/mm/common/mm_msg.c b/usr/src/cmd/mms/mm/common/mm_msg.c deleted file mode 100644 index 1624df481d..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_msg.c +++ /dev/null @@ -1,1535 +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 <mms_list.h> -#include <mms_parser.h> -#include <libpq-fe.h> -#include <string.h> -#include <stdlib.h> -#include <sys/time.h> -#include <pthread.h> -#include <errno.h> -#include <unistd.h> -#include <syslog.h> -#include <fcntl.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <sys/stat.h> -#include <libintl.h> -#include <locale.h> -#include <ctype.h> -#include <mms_trace.h> -#include <mms_strapp.h> -#include <msg_sub.h> -#include <mms_cat.h> -#include "mm_db.h" -#include "mm.h" -#include "mm_util.h" -#include "mm_commands.h" -#include "mm_sql.h" -#include "mm_sql_impl.h" - -static char *_SrcFile = __FILE__; -#define NOT_FOUND() goto not_found - -#define MESS_EMERG_STR "emergency" -#define MESS_ALERT_STR "alert" -#define MESS_CRIT_STR "critical" -#define MESS_ERROR_STR "error" -#define MESS_WARN_STR "warning" -#define MESS_NOTICE_STR "notice" -#define MESS_INFO_STR "information" -#define MESS_DEBUG_STR "debug" -#define MESS_DEVP_STR "developer" - -#define MESS_OPER_STR "operator" -#define MESS_ADMIN_STR "administrator" -#define MESS_LOG_STR "log" - -typedef struct { - char *msg_client; - char *msg_instance; - char *msg_host; - - int slog_fd; - char slog_fname[PATH_MAX]; - uint64_t slog_size; - int slog_sync; - int slog_count; - mm_msg_sev_t slog_level; - uint64_t slog_rot_size; - pthread_mutex_t slog_mutex; -} mm_msg_data_t; - -/* message */ -static int mm_msg_add_private(mm_wka_t *mm_wka, char *client, char *inst); -static int mm_msg_avail(mm_command_t *cmd); -static int mm_msg_fifo(mm_db_t *db, mm_msg_t *mess); - -/* system log file */ -static int mm_slog_open(mm_db_t *db); -static void mm_slog_close(void); -static void mm_slog_flush(void); -static int mm_slog(mm_msg_t *mess); - -/* utility */ -static char *mm_msg_sev2str(mm_msg_sev_t severity); -static mm_msg_sev_t mm_msg_str2sev(char *serverity); -static char *mm_msg_who2str(mm_msg_who_t who); -static mm_msg_who_t mm_msg_str2who(char *who); -static void mm_get_timestamp(mm_db_t *db, char *timestamp); - -static mm_msg_data_t mm_msg_data; - -int -mm_message_init(mm_db_t *db, mm_data_t *data) -{ - mms_cat_open(); - (void) setlocale(LC_MESSAGES, ""); - - memset(&mm_msg_data, 0, sizeof (mm_msg_data_t)); - mm_msg_data.msg_client = data->mm_cfg.mm_network_cfg.cli_name; - mm_msg_data.msg_instance = data->mm_cfg.mm_network_cfg.cli_inst; - mm_msg_data.msg_host = data->mm_host_name; - pthread_mutex_init(&mm_msg_data.slog_mutex, NULL); - if (mm_slog_open(db)) { - mms_trace(MMS_ERR, "unable to open system log file"); - return (1); - } - return (0); -} - -void -mm_message_close(void) -{ - mm_slog_close(); - pthread_mutex_destroy(&mm_msg_data.slog_mutex); - memset(&mm_msg_data, 0, sizeof (mm_msg_data_t)); - mm_msg_data.slog_fd = -1; -} - -int -mm_msg_tracing_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_response_t response; - - mms_trace(MMS_DEVP, - "mm_msg_tracing_cmd_func, state %d", cmd->cmd_state); - - /* - * Handle device manager change tracing private command - */ - - if (cmd->cmd_state == 0) { - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_textcmd); - mms_trace(MMS_DEVP, "set tracing sent"); - cmd->cmd_flags |= MM_CMD_NEED_ACCEPT; - cmd->cmd_state = 1; - return (MM_ACCEPT_NEEDED); - } else if (cmd->cmd_state == 1) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_ACCEPTED) { - mms_trace(MMS_DEVP, "set tracing accepted"); - cmd->cmd_flags &= ~MM_CMD_NEED_ACCEPT; - cmd->cmd_flags |= MM_CMD_ACCEPTED; - cmd->cmd_state = 2; - return (MM_NO_DISPATCH); - } - } else if (cmd->cmd_state == 2) { - if (mm_parse_response(cmd->cmd_response, &response) == 0 && - response.response_type == MM_RESPONSE_SUCCESS) { - mms_trace(MMS_DEVP, "set tracing success"); - cmd->cmd_remove = 1; - if (mm_has_depend(cmd)) { - return (MM_DEPEND_DONE); - } - return (MM_CMD_DONE); - } - mms_trace(MMS_DEVP, "set tracing failed"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - mms_trace(MMS_DEVP, "set tracing state"); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); -} - -int -mm_msg_send_tracing(mm_wka_t *mm_wka) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - cci_t *conn = &mm_wka->wka_conn; - uuid_text_t task; - char *buf; - mm_command_t *pvt_cmd; - - /* - * Add change tracing private command to command queue - */ - - if (mm_wka->mm_wka_mm_lang == MM_LANG_LMP) { - - mms_trace(MMS_DEVP, "Set lmp tracing"); - - if (mm_db_exec(HERE, db, "select \"LMMessageLevel\"," - "\"TraceLevel\",\"TraceFileSize\" from \"LM\" where " - "\"LMName\" = '%s';", conn->cci_instance) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - return (1); - } - if (PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - return (1); - } - - mm_get_uuid(task); - - buf = mms_strnew("private task[\"%s\"] " - "set[\"LMMessageLevel\" \"%s\" " - "\"TraceLevel\" \"%s\" " - "\"TraceFileSize\" \"%s\"];", - task, - PQgetvalue(db->mm_db_results, 0, 0), - PQgetvalue(db->mm_db_results, 0, 1), - PQgetvalue(db->mm_db_results, 0, 2)); - - mm_clear_db(&db->mm_db_results); - pvt_cmd = mm_alloc_cmd(mm_wka); - pvt_cmd->cmd_textcmd = buf; - pvt_cmd->cmd_root = mm_text_to_par_node(pvt_cmd->cmd_textcmd, - mms_lmpm_parse); - pvt_cmd->cmd_task = mm_get_task(pvt_cmd->cmd_root); - pvt_cmd->wka_ptr = mm_wka; - pvt_cmd->cmd_func = mm_msg_tracing_cmd_func; - pvt_cmd->cmd_flags = MM_CMD_DISPATCHABLE; - pvt_cmd->cmd_language = MM_LANG_LMP; - pvt_cmd->cmd_name = strdup("lmp tracing"); - - pthread_mutex_lock(&mm_wka->mm_data->mm_queue_mutex); - mms_list_insert_tail(&mm_wka->mm_data->mm_cmd_queue, pvt_cmd); - pthread_mutex_unlock(&mm_wka->mm_data->mm_queue_mutex); - - mms_trace(MMS_DEVP, "Added set lmp tracing"); - - } else if (mm_wka->mm_wka_mm_lang == MM_LANG_DMP) { - - mms_trace(MMS_DEVP, "Set dmp tracing"); - - if (mm_db_exec(HERE, db, "select \"DMMessageLevel\"," - "\"TraceLevel\",\"TraceFileSize\" from \"DM\" where " - "\"DMName\" = '%s';", conn->cci_instance) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - return (1); - } - if (PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - return (1); - } - - mm_get_uuid(task); - - buf = mms_strnew("private task[\"%s\"] " - "set[\"DMMessageLevel\" \"%s\" " - "\"TraceLevel\" \"%s\" " - "\"TraceFileSize\" \"%s\"];", - task, - PQgetvalue(db->mm_db_results, 0, 0), - PQgetvalue(db->mm_db_results, 0, 1), - PQgetvalue(db->mm_db_results, 0, 2)); - - mm_clear_db(&db->mm_db_results); - - - pvt_cmd = mm_alloc_cmd(mm_wka); - pvt_cmd->cmd_textcmd = buf; - pvt_cmd->cmd_root = mm_text_to_par_node(pvt_cmd->cmd_textcmd, - mms_dmpm_parse); - pvt_cmd->cmd_task = mm_get_task(pvt_cmd->cmd_root); - pvt_cmd->wka_ptr = mm_wka; - pvt_cmd->cmd_func = mm_msg_tracing_cmd_func; - pvt_cmd->cmd_flags = MM_CMD_DISPATCHABLE; - pvt_cmd->cmd_language = MM_LANG_DMP; - pvt_cmd->cmd_name = strdup("dmp tracing"); - - pthread_mutex_lock(&mm_wka->mm_data->mm_queue_mutex); - mms_list_insert_tail(&mm_wka->mm_data->mm_cmd_queue, pvt_cmd); - pthread_mutex_unlock(&mm_wka->mm_data->mm_queue_mutex); - - mms_trace(MMS_DEVP, "Added set dmp tracing"); - } - - return (0); -} - -static int -mm_msg_add_private(mm_wka_t *mm_wka, char *client, char *inst) -{ - mm_wka_t *cli_wka; - int rc = 0; - - /* find client work area */ - mms_list_foreach(&mm_wka->mm_data->mm_wka_list, cli_wka) { - - /* only connected clients have work areas */ - if (strcmp(cli_wka->wka_conn.cci_client, client) == 0 && - strcmp(cli_wka->wka_conn.cci_instance, inst) == 0) { - - /* send private command to change tracing */ - if (rc = mm_msg_send_tracing(cli_wka)) { - break; - } - } - } - return (rc); -} - -int -mm_msg_set_tracing(mm_wka_t *mm_wka, mm_command_t *cmd, int id) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - PGresult *results; - char *query; - int row; - char *client; - char *inst; - char *level; - char *fsize; - int num; - - /* - * Change mm or device manager tracing - */ - - if (id == LM) { - - /* clear path matching */ - mm_clear_source(cmd); - mm_clear_dest(cmd); - mm_clear_const(cmd); - - /* sql command */ - (void) mm_get_dest(mm_wka, cmd); - (void) mm_get_const(mm_wka, cmd); - (void) mm_add_match_list("LM", &cmd->cmd_source_list); - if (mm_add_char("LM", &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_msg_set_tracing: " - "out of mem creating source list"); - return (1); - } - - cmd->cmd_source_num = 1; - - query = "select distinct \"LM\".\"LibraryName\"," - "\"LM\".\"LMName\" from "; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(query) + 1); - strcpy(cmd->cmd_buf, query); - - if (mm_sql_from_where(cmd, db)) { - mms_trace(MMS_ERR, - "mm_msg_set_tracing: " - "db error creating helper functions"); - return (1); - } - mm_sql_order(cmd); - mm_sql_number(cmd); - - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_DATA) { - mms_trace(MMS_ERR, "lm tracing"); - mm_clear_db(&db->mm_db_results); - return (1); - } - if (PQntuples(db->mm_db_results) < 1) { - mms_trace(MMS_ERR, "lm tracing results"); - mm_clear_db(&db->mm_db_results); - /* see if any lms are configed */ - if (mm_db_exec(HERE, db, "select \"LM\".\"LMName\" " - "from \"LM\" limit 1;") != MM_DB_DATA) { - mms_trace(MMS_ERR, "lms configed"); - mm_clear_db(&db->mm_db_results); - return (1); - } - num = PQntuples(db->mm_db_results); - PQntuples(db->mm_db_results); - if (num == 0 && cmd->cmd_dest_num == 0) { - /* no lms configured or specified */ - return (0); - } - /* lm not found */ - return (1); - } - results = db->mm_db_results; - for (row = 0; row < PQntuples(results); row++) { - client = PQgetvalue(results, row, 0); - inst = PQgetvalue(results, row, 1); - - mms_trace(MMS_DEVP, "%d of %d - %s %s", - row, - PQntuples(results), - client, - inst); - - if (mm_msg_add_private(mm_wka, client, inst)) { - mm_clear_db(&results); - return (1); - } - } - mm_clear_db(&results); - - } else if (id == DM) { - - /* clear path matching */ - mm_clear_source(cmd); - mm_clear_dest(cmd); - mm_clear_const(cmd); - - /* sql command */ - (void) mm_get_dest(mm_wka, cmd); - (void) mm_get_const(mm_wka, cmd); - (void) mm_add_match_list("DM", &cmd->cmd_source_list); - if (mm_add_char("DM", &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, - "mm_msg_set_tracing: " - "out of mem creating source list"); - return (1); - } - cmd->cmd_source_num = 1; - - query = "select distinct \"DM\".\"DriveName\"," - "\"DM\".\"DMName\" from "; - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(query) + 1); - strcpy(cmd->cmd_buf, query); - - - if (mm_sql_from_where(cmd, db)) { - mms_trace(MMS_ERR, - "mm_msg_set_tracing: " - "db error creating helper functions"); - return (1); - } - mm_sql_order(cmd); - mm_sql_number(cmd); - - if (mm_db_exec(HERE, db, cmd->cmd_buf) != MM_DB_DATA) { - mms_trace(MMS_ERR, "dm tracing"); - mm_clear_db(&db->mm_db_results); - return (1); - } - if (PQntuples(db->mm_db_results) < 1) { - mms_trace(MMS_ERR, "dm tracing results"); - mm_clear_db(&db->mm_db_results); - /* see if any dms are configed */ - if (mm_db_exec(HERE, db, "select \"DM\".\"DMName\" " - "from \"DM\" limit 1;") != MM_DB_DATA) { - mms_trace(MMS_ERR, "dms configed"); - mm_clear_db(&db->mm_db_results); - return (1); - } - num = PQntuples(db->mm_db_results); - PQntuples(db->mm_db_results); - if (num == 0 && cmd->cmd_dest_num == 0) { - /* no dms configed or specified */ - return (0); - } - /* dm not found */ - return (1); - } - results = db->mm_db_results; - for (row = 0; row < PQntuples(results); row++) { - client = PQgetvalue(results, row, 0); - inst = PQgetvalue(results, row, 1); - - mms_trace(MMS_DEVP, "%d of %d - %s %s", - row, - PQntuples(results), - client, - inst); - - if (mm_msg_add_private(mm_wka, client, inst)) { - mm_clear_db(&results); - return (1); - } - } - mm_clear_db(&results); - - } else if (id == MM) { - - if (mm_db_exec(HERE, db, "select \"MessageLevel\", " - "\"TraceLevel\",\"TraceFileSize\" from \"SYSTEM\";") - != MM_DB_DATA) { - mms_trace(MMS_ERR, "mm tracing"); - mm_clear_db(&db->mm_db_results); - return (1); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, "mm tracing results"); - mm_clear_db(&db->mm_db_results); - return (1); - } - level = PQgetvalue(db->mm_db_results, 0, 1); - fsize = PQgetvalue(db->mm_db_results, 0, 2); - - if (mms_trace_set_fsize(fsize)) { - mms_trace(MMS_ERR, "invalid mms_trace fsize %s", fsize); - return (1); - } - if (mms_trace_str_filter(level)) { - mms_trace(MMS_ERR, - "invalid mms_trace filter %s", level); - return (1); - } - mm_write_trace_level(mms_trace_get_severity()); - mm_clear_db(&db->mm_db_results); - - } else { - mms_trace(MMS_ERR, "invalid id %d", id); - return (1); - } - - return (0); - -no_mem: - MM_ABORT_NO_MEM(); - return (1); -} - -int -mm_message_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mm_db_t *db = &mm_wka->mm_data->mm_db; - mms_par_node_t *clause; - mms_par_node_t *value; - - mms_trace(MMS_DEVP, "mm_message_cmd_func"); - - /* - * Device manager message command - */ - - cmd->cmd_msg.msg_flags |= MESS_FLAG_HANDLED; - - /* message command */ - MMS_PN_LOOKUP(clause, cmd->cmd_root, "who", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, clause, NULL, MMS_PN_KEYWORD, NULL); - cmd->cmd_msg.msg_who = mm_msg_str2who(mms_pn_token(value)); - - MMS_PN_LOOKUP(clause, cmd->cmd_root, "severity", - MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, clause, NULL, MMS_PN_KEYWORD, NULL); - cmd->cmd_msg.msg_severity = mm_msg_str2sev(mms_pn_token(value)); - - if (mm_msg_parse(cmd, cmd->cmd_root)) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_INTERNAL) + strlen(MM_E_CMDARGS) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INTERNAL, MM_E_CMDARGS); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - mm_get_timestamp(db, cmd->cmd_msg.msg_timestamp); - - cmd->cmd_msg.msg_client_uuid = cmd->wka_ptr->wka_conn.cci_uuid; - mm_get_uuid(cmd->cmd_msg.msg_uuid); - cmd->cmd_msg.msg_type = mm_msg_lang2component(mm_wka->mm_wka_mm_lang); - cmd->cmd_msg.msg_client = cmd->wka_ptr->wka_conn.cci_client; - cmd->cmd_msg.msg_instance = cmd->wka_ptr->wka_conn.cci_instance; - cmd->cmd_msg.msg_cid = cmd->wka_ptr->wka_conn.cci_uuid; - cmd->cmd_msg.msg_host = cmd->wka_ptr->wka_conn.cci_host; - - /* add message to system log file */ - if (mm_slog(&cmd->cmd_msg)) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_INTERNAL) + strlen(MM_E_INTERNAL) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INTERNAL, MM_E_INTERNAL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - /* add message to message fifo */ - if (mm_msg_fifo(db, &cmd->cmd_msg)) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_INTERNAL) + strlen(MM_E_INTERNAL) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INTERNAL, MM_E_INTERNAL); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - } - - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_DONE); - -not_found: - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_INTERNAL) + strlen(MM_E_CMDARGS) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INTERNAL, MM_E_CMDARGS); - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - cmd->cmd_remove = 1; - return (MM_CMD_ERROR); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -} - -static int -mm_msg_avail(mm_command_t *cmd) -{ - /* - * Tell caller if command contains message-clause - */ - - if (mms_pn_lookup(cmd->cmd_root, "message", MMS_PN_CLAUSE, NULL)) { - return (1); /* command has message-clause */ - } - return (0); -} - -int -mm_message_command(mm_command_t *cmd) -{ - mm_db_t *db = &cmd->wka_ptr->mm_data->mm_db; - mm_response_t response; - int rc; - - mms_trace(MMS_DEVP, "mm_msg_command"); - - /* - * Handle message in non-message command - */ - - if (cmd->cmd_msg.msg_flags & MESS_FLAG_HANDLED) { - return (0); /* already handled this command's message */ - } - cmd->cmd_msg.msg_flags |= MESS_FLAG_HANDLED; - - if (cmd->wka_ptr->mm_wka_mm_lang == MM_LANG_MMP) { - return (0); /* ignore messages in mmp commands */ - } - - if (mm_msg_avail(cmd) == 0) - return (0); /* command does not have a message */ - - if (mm_msg_parse(cmd, cmd->cmd_root)) - return (0); /* failed to parse command message */ - - if (mm_parse_response(cmd->cmd_root, &response) == 0) { - /* command response */ - switch (response.response_type) { - case MM_RESPONSE_ERROR: - cmd->cmd_msg.msg_severity = MESS_ERROR; - break; - - case MM_RESPONSE_ACCEPTED: - case MM_RESPONSE_UNACCEPTABLE: - case MM_RESPONSE_SUCCESS: - case MM_RESPONSE_CANCELLED: - default: - cmd->cmd_msg.msg_severity = MESS_INFO; - break; - } - } else { - /* not command response */ - cmd->cmd_msg.msg_severity = MESS_INFO; - } - - mm_get_timestamp(db, cmd->cmd_msg.msg_timestamp); - - cmd->cmd_msg.msg_client_uuid = cmd->wka_ptr->wka_conn.cci_uuid; - mm_get_uuid(cmd->cmd_msg.msg_uuid); - cmd->cmd_msg.msg_type = - mm_msg_lang2component(cmd->wka_ptr->mm_wka_mm_lang); - cmd->cmd_msg.msg_client = cmd->wka_ptr->wka_conn.cci_client, - cmd->cmd_msg.msg_instance = cmd->wka_ptr->wka_conn.cci_instance, - cmd->cmd_msg.msg_cid = cmd->wka_ptr->wka_conn.cci_uuid; - cmd->cmd_msg.msg_host = cmd->wka_ptr->wka_conn.cci_host, - cmd->cmd_msg.msg_who = MESS_LOG; - - if ((rc = mm_slog(&cmd->cmd_msg)) == 0) { - rc = mm_msg_fifo(db, &cmd->cmd_msg); - } - - return (rc); -} - -int -mm_message(mm_db_t *db, mm_msg_who_t who, mm_msg_sev_t severity, - int messageid, ...) -{ - mm_msg_t mess; - va_list args; - int rc; - - mms_trace(MMS_DEVP, "mm_message: %s %s %d", - mm_msg_who2str(who), mm_msg_sev2str(severity), messageid); - - memset(&mess, 0, sizeof (mm_msg_t)); - - mm_get_timestamp(db, mess.msg_timestamp); - - mess.msg_client_uuid = NULL; - mm_get_uuid(mess.msg_uuid); - mess.msg_type = MESS_MM_STR; - mess.msg_client = mm_msg_data.msg_client; - mess.msg_instance = mm_msg_data.msg_instance; - mess.msg_host = mm_msg_data.msg_host; - mess.msg_who = who; - mess.msg_severity = severity; - mess.msg_manufacturer = MESS_MANUFACTURER; - mess.msg_model = MESS_MODEL; - mess.msg_messageid = messageid; - mess.msg_lang = MESS_LANG; - va_start(args, messageid); - mess.msg_localized = mms_get_locstr(messageid, args); - va_end(args); - - if ((rc = mm_slog(&mess)) == 0) { - rc = mm_msg_fifo(db, &mess); - } - - free(mess.msg_localized); - - return (rc); -} - -int -mm_msg_exists(int message_id) -{ - char *fmt; - - fmt = mms_get_cat_msg(message_id); - if (fmt == NULL || fmt[0] == '\0') { - return (0); - } - return (1); -} - -int -mm_msg_parse(mm_command_t *cmd, mms_par_node_t *root) -{ - mms_par_node_t *arg; - mms_par_node_t *name; - mms_par_node_t *value; - mms_par_node_t *count; - mms_par_node_t *work; - char *p; - char *fmt; - - mms_trace(MMS_DEVP, "mm_msg_parse"); - - /* - * Parse and localize command's message-clause - */ - - /* message-clause */ - MMS_PN_LOOKUP(arg, root, "message", MMS_PN_CLAUSE, NULL); - - MMS_PN_LOOKUP(arg, root, "id", MMS_PN_CLAUSE, NULL); - work = NULL; - MMS_PN_LOOKUP(value, arg, NULL, MMS_PN_STRING, &work); - cmd->cmd_msg.msg_manufacturer = value->pn_string; - - MMS_PN_LOOKUP(value, arg, NULL, MMS_PN_STRING, &work); - cmd->cmd_msg.msg_model = value->pn_string; - - MMS_PN_LOOKUP(value, arg, NULL, MMS_PN_STRING, &work); - cmd->cmd_msg.msg_messageid = atoi(value->pn_string); - - /* locale-text-clause */ - count = NULL; - while (arg = mms_pn_lookup(root, "loctext", - MMS_PN_CLAUSE, &count)) { - - work = NULL; - value = mms_pn_lookup(arg, NULL, MMS_PN_STRING, &work); - if (value == NULL) - NOT_FOUND(); - cmd->cmd_msg.msg_lang = value->pn_string; - - value = mms_pn_lookup(arg, NULL, MMS_PN_STRING, &work); - if (value == NULL) - NOT_FOUND(); - cmd->cmd_msg.msg_text = value->pn_string; - } - - /* lookup localized message */ - fmt = mms_get_cat_msg(cmd->cmd_msg.msg_messageid); - if (fmt == NULL || fmt[0] == '\0') { - /* no catalog message found so use default if it exists */ - mms_trace(MMS_DEVP, "catalog messageid %d not found", - cmd->cmd_msg.msg_messageid); - if (cmd->cmd_msg.msg_text) { - fmt = cmd->cmd_msg.msg_text; - } - if (fmt == NULL) { - fmt = "\0"; - } - } - - /* copy localized message */ - if (cmd->cmd_msg.msg_localized) - free(cmd->cmd_msg.msg_localized); - cmd->cmd_msg.msg_localized = strdup(fmt); - - /* arg-clause */ - if (arg = mms_pn_lookup(root, "arguments", - MMS_PN_CLAUSE, NULL)) { - - /* save arguments list */ - cmd->cmd_msg.msg_args = &arg->pn_arglist; - - /* substitue each text argument with value */ - mms_list_pair_foreach(&arg->pn_arglist, name, value) { - - if (name == NULL || value == NULL) { - NOT_FOUND(); - } - - if ((p = mms_msg_sub(cmd->cmd_msg.msg_localized, - name->pn_string, - value->pn_string)) == NULL) { - MM_ABORT_NO_MEM(); - return (1); - } - free(cmd->cmd_msg.msg_localized); - cmd->cmd_msg.msg_localized = p; - } - } - - mms_trace(MMS_DEVP, "parsed message: %s %s %d - %s", - cmd->cmd_msg.msg_manufacturer, - cmd->cmd_msg.msg_model, - cmd->cmd_msg.msg_messageid, - cmd->cmd_msg.msg_localized); - - return (0); - -not_found: - mms_trace(MMS_DEVP, "parse message: not found"); - return (1); - -no_mem: - MM_ABORT_NO_MEM(); - return (1); -} - -static int -mm_msg_fifo(mm_db_t *db, mm_msg_t *mess) -{ - mm_msg_sev_t sys_acc_level; - int sys_msg_limit; - int sys_msg_count; - char cid[UUID_PRINTF_SIZE + 3]; - char *localized; - - mms_trace(MMS_DEVP, "mm_msg_fifo"); - - /* - * Add message to mm's message fifo - */ - - if (mm_db_exec(HERE, db, "select \"SystemAcceptLevel\"," - "\"SystemMessageLimit\",\"SystemMessageCount\" from " - "\"SYSTEM\";") != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - return (1); - } - if (PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - return (1); - } - sys_acc_level = mm_msg_str2sev(PQgetvalue(db->mm_db_results, 0, 0)); - sys_msg_limit = atoi(PQgetvalue(db->mm_db_results, 0, 1)); - sys_msg_count = atoi(PQgetvalue(db->mm_db_results, 0, 2)); - mm_clear_db(&db->mm_db_results); - - if (mess->msg_severity < sys_acc_level) { - return (0); - } - - if (sys_msg_limit == 0) { - return (0); - } - - if (mess->msg_cid == NULL) { - (void) strlcpy(cid, "NULL", sizeof (cid)); - } else { - (void) snprintf(cid, sizeof (cid), "'%s'", mess->msg_cid); - } - - if ((localized = mm_db_escape_string(mess-> - msg_localized)) == NULL) { - mms_trace(MMS_ERR, "db mms_escape string - %s", - mess->msg_localized); - mm_clear_db(&db->mm_db_results); - return (1); - } - - if (sys_msg_count < sys_msg_limit) { - - if (mm_db_exec(HERE, db, "insert into \"MESSAGE\" " - "(\"MessageID\"," - "\"MessageSenderType\"," - "\"MessageSenderName\"," - "\"MessageSenderInstance\"," - "\"MessageConnectionID\"," - "\"MessageLevel\"," - "\"MessageManufacturer\"," - "\"MessageModel\"," - "\"MessageNumber\"," - "\"MessageText\"," - "\"MessageTimeCreated\"," - "\"MessageHost\") " - "values ('%s','%s','%s','%s',%s," - "'%s','%s','%s','%d','%s','%s','%s');", - mess->msg_uuid, - mess->msg_type, - mess->msg_client, - mess->msg_instance, - cid, - mm_msg_sev2str(mess->msg_severity), - mess->msg_manufacturer, - mess->msg_model, - mess->msg_messageid, - localized, - mess->msg_timestamp, - mess->msg_host) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - free(localized); - return (1); - } - free(localized); - - if (mm_db_exec(HERE, db, "update \"SYSTEM\" set " - "\"SystemMessageCount\" = '%d';", - sys_msg_count + 1) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - return (1); - } - - if (db->mm_db_count != 1) { - return (1); - } - - } else { - - if (mm_db_exec(HERE, db, "update \"MESSAGE\" set " - "\"MessageID\" = '%s'," - "\"MessageSenderType\" = '%s'," - "\"MessageSenderName\" = '%s'," - "\"MessageSenderInstance\" = '%s'," - "\"MessageConnectionID\" = %s," - "\"MessageLevel\" = '%s'," - "\"MessageManufacturer\" = '%s'," - "\"MessageModel\" = '%s'," - "\"MessageNumber\" = '%d'," - "\"MessageText\" = '%s'," - "\"MessageTimeCreated\" = '%s'," - "\"MessageHost\" = '%s' " - "where \"MessageID\" = (select \"MessageID\" from " - "\"MESSAGE\" order by \"MessageTimeCreated\" limit 1);", - mess->msg_uuid, - mess->msg_type, - mess->msg_client, - mess->msg_instance, - cid, - mm_msg_sev2str(mess->msg_severity), - mess->msg_manufacturer, - mess->msg_model, - mess->msg_messageid, - localized, - mess->msg_timestamp, - mess->msg_host) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - free(localized); - return (1); - } - free(localized); - - if (db->mm_db_count != 1) { - return (1); - } - } - - mess->msg_flags |= MESS_FLAG_FIFO; - mms_trace(MMS_DEVP, "message added to fifo"); - - return (0); -} - -int -mm_msg_set_limit(mm_db_t *db) -{ - int limit; - int count; - int actual_count; - - mms_trace(MMS_DEVP, "mm_msg_set_limit"); - - /* - * Change message fifo size. - */ - - if (mm_db_exec(HERE, db, "select \"SystemMessageLimit\"," - "\"SystemMessageCount\" from \"SYSTEM\";") != MM_DB_DATA) { - return (1); - } - limit = atoi(PQgetvalue(db->mm_db_results, 0, 0)); - count = atoi(PQgetvalue(db->mm_db_results, 0, 1)); - mm_clear_db(&db->mm_db_results); - - if (mm_db_exec(HERE, db, "select \"MessageID\" " - "from \"MESSAGE\";") != MM_DB_DATA) { - return (1); - } - actual_count = PQntuples(db->mm_db_results); - mm_clear_db(&db->mm_db_results); - - if (count != actual_count) { - count = actual_count; - } - - /* remove excess messages from message fifo */ - while (count > limit) { - /* remove oldest message */ - if (mm_db_exec(HERE, db, "delete from \"MESSAGE\" " - "where \"MessageID\" = (select \"MessageID\" " - "from \"MESSAGE\" " - "order by \"MessageTimeCreated\" " - "limit 1);") != MM_DB_OK) { - return (1); - } - if (db->mm_db_count != 1) { - return (1); - } - count--; - } - - if (count < 0) { - count = 0; - } - - if (mm_db_exec(HERE, db, "update \"SYSTEM\" set " - "\"SystemMessageCount\" = '%d';", count) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - return (1); - } - - return (0); -} - -/* - * System Log File - */ - -static int -mm_slog_open(mm_db_t *db) -{ - int oflags = O_CREAT | O_RDWR | O_APPEND; - struct stat buf; - - mms_trace(MMS_DEVP, "mm_slog_open"); - - if (mm_db_exec(HERE, db, "select \"SystemLogFile\" from " - "\"SYSTEM\";") != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - mms_trace(MMS_ERR, "query system log file name"); - return (1); - } - if (PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - mms_trace(MMS_ERR, "missing system log file name"); - return (1); - } - snprintf(mm_msg_data.slog_fname, PATH_MAX, - "%s", PQgetvalue(db->mm_db_results, 0, 0)); - mm_clear_db(&db->mm_db_results); - - if (mm_slog_set_sync(db)) { - mms_trace(MMS_ERR, "system log file sync"); - return (1); - } - - if (mm_slog_set_level(db)) { - mms_trace(MMS_ERR, "system log file level"); - return (1); - } - - if (mm_slog_set_size(db)) { - mms_trace(MMS_ERR, "system log file size"); - return (1); - } - - mm_msg_data.slog_fd = open(mm_msg_data.slog_fname, oflags, 0644); - if (mm_msg_data.slog_fd < 0) { - mms_trace(MMS_ERR, "open %s %s", mm_msg_data.slog_fname, - strerror(errno)); - return (1); - } - - if (fstat(mm_msg_data.slog_fd, &buf) != 0) { - mms_trace(MMS_ERR, "fstat %s %s", mm_msg_data.slog_fname, - strerror(errno)); - close(mm_msg_data.slog_fd); - mm_msg_data.slog_fd = -1; - return (1); - } - - mm_msg_data.slog_size = buf.st_size; - - return (0); -} - -static void -mm_slog_close(void) -{ - mms_trace(MMS_DEVP, "mm_slog_close"); - close(mm_msg_data.slog_fd); - mm_msg_data.slog_fd = -1; -} - -static void -mm_slog_flush(void) -{ - (void) fsync(mm_msg_data.slog_fd); -} - -static int -mm_slog(mm_msg_t *mess) -{ - char *buf; - int len; - int oflags = O_CREAT | O_RDWR | O_APPEND; - char *localized; - pid_t shpid; - char size[20]; - - /* - * Write message to system log file. - */ - - if (mess->msg_severity > MESS_EMERG || - mess->msg_severity < MESS_DEVP) { - mms_trace(MMS_ERR, "invalid severity %d", mess->msg_severity); - return (1); /* invalid severity */ - } - - if (mess->msg_severity < mm_msg_data.slog_level) { - return (0); /* not logging this severity */ - } - - localized = mms_strpar_undo_escape_sequence(mess->msg_localized); - if (localized == NULL) { - mms_trace(MMS_ERR, "unable to localized message"); - return (1); /* mms_escape sequence removal failed */ - } - - if ((buf = mms_strnew( - "%s %s %.2s %s %s %s %d %s\n", - mess->msg_timestamp, - mess->msg_host, - mess->msg_type, - mess->msg_client, - mess->msg_instance, - mm_msg_sev2str(mess->msg_severity), - mess->msg_messageid, - localized)) == NULL) { - mms_trace(MMS_ERR, "message allocation failed"); - free(localized); - return (1); - } - free(localized); - - len = strlen(buf); - - pthread_mutex_lock(&mm_msg_data.slog_mutex); - if (write(mm_msg_data.slog_fd, buf, len) == len) { - mess->msg_flags |= MESS_FLAG_SLOG; - } - free(buf); - mm_msg_data.slog_size += len; - mm_msg_data.slog_count++; - - /* flush system log file to disk */ - if (mm_msg_data.slog_count > mm_msg_data.slog_sync) { - mm_slog_flush(); - mm_msg_data.slog_count = 0; - } - if (mm_msg_data.slog_size > mm_msg_data.slog_rot_size) { - mm_slog_flush(); - (void) close(mm_msg_data.slog_fd); - if ((shpid = fork()) < 0) { - mms_trace(MMS_DEBUG, - "mm_slog: fork failed"); - return (-1); - } else if (shpid == 0) { /* child */ - (void) snprintf(size, sizeof (size), "%lldb", - mm_msg_data.slog_size); - (void) execl(MMS_LOGADM, MMS_LOGADM, - "-f", MMS_LOGADM_CONF, - "-s", size, - mm_msg_data.slog_fname, - (char *)0); - exit(1); - } - if (waitpid(shpid, NULL, 0) < 0) /* parent */ - mms_trace(MMS_DEBUG, - "mm_slog: wait failed"); - - mm_msg_data.slog_size = 0; - mm_msg_data.slog_fd = - open(mm_msg_data.slog_fname, oflags, 0644); - } - pthread_mutex_unlock(&mm_msg_data.slog_mutex); - return (0); -} - -int -mm_slog_set_fname(mm_db_t *db) -{ - int rc; - - mms_trace(MMS_DEVP, "mm_slog_set_fname"); - - pthread_mutex_lock(&mm_msg_data.slog_mutex); - mm_slog_close(); - rc = mm_slog_open(db); - pthread_mutex_unlock(&mm_msg_data.slog_mutex); - return (rc); -} - -int -mm_slog_set_sync(mm_db_t *db) -{ - mms_trace(MMS_DEVP, "mm_slog_set_sync"); - - if (mm_db_exec(HERE, db, "select \"SystemSyncLimit\" from " - "\"SYSTEM\";") != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - return (1); - } - if (PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - return (1); - } - mm_msg_data.slog_sync = atoi(PQgetvalue(db->mm_db_results, 0, 0)); - mm_clear_db(&db->mm_db_results); - return (0); -} - -int -mm_slog_set_level(mm_db_t *db) -{ - char *level; - - mms_trace(MMS_DEVP, "mm_slog_set_level"); - - if (mm_db_exec(HERE, db, "select \"SystemLogLevel\" from " - "\"SYSTEM\";") != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - return (1); - } - if (PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - return (1); - } - level = PQgetvalue(db->mm_db_results, 0, 0); - mm_msg_data.slog_level = mm_msg_str2sev(level); - mm_clear_db(&db->mm_db_results); - return (0); -} - -int -mm_slog_set_size(mm_db_t *db) -{ - uint64_t value; - int rc; - char *size; - - mms_trace(MMS_DEVP, "mm_slog_set_size"); - - if (mm_db_exec(HERE, db, "select \"SystemLogFileSize\" from " - "\"SYSTEM\";") != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - return (1); - } - if (PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - return (1); - } - size = PQgetvalue(db->mm_db_results, 0, 0); - if ((rc = mms_trace_str_to_fsize(size, &value)) == 0) { - mm_msg_data.slog_rot_size = value; - } - mm_clear_db(&db->mm_db_results); - return (rc); -} - -/* - * Get message-clause strings - */ - -void -mm_response_error(mm_command_t *cmd, char *eclass, char *ecode, - int messageid, ...) -{ - va_list args; - char *buf; - char *text; - - mm_cmd_err_t *err = NULL; - - - mms_trace(MMS_ERR, "mm_response_error"); - mms_trace(MMS_ERR, "Class:: %s", - eclass); - mms_trace(MMS_ERR, "Token:: %s", - ecode); - mms_trace(MMS_ERR, "ID:: %d", - messageid); - - /* - * Get final-command response error with message-clause - */ - - if (cmd->cmd_eclass != NULL) { - free(cmd->cmd_eclass); - cmd->cmd_eclass = NULL; - } - cmd->cmd_eclass = strdup(eclass); - - if (cmd->cmd_ecode != NULL) { - free(cmd->cmd_ecode); - cmd->cmd_ecode = NULL; - } - cmd->cmd_ecode = strdup(ecode); - - va_start(args, messageid); - text = mms_bld_msgcl(messageid, args); - va_end(args); - - buf = mms_strnew("response task[\"%s\"] error[%s %s] %s;", - cmd->cmd_task, eclass, ecode, text); - free(text); - - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, strlen(buf) + 1); - strcpy(cmd->cmd_buf, buf); - free(buf); - - /* insert this error into the cmd's err_list */ - if ((err = mm_alloc_err()) == NULL) { - mms_trace(MMS_ERR, - "mm_response_error: " - "could not allocate err struct"); - return; - } - err->eclass = strdup(eclass); - err->ecode = strdup(ecode); - err->err_bufsize = cmd->cmd_bufsize; - err->err_buf = strdup(cmd->cmd_buf); - err->retry_drive = NULL; - err->retry_cart = NULL; - err->retry_lib = NULL; - mms_list_insert_tail(&cmd->cmd_err_list, err); - - return; - -no_mem: - MM_ABORT_NO_MEM(); -} - -static mm_msg_sev_t -mm_msg_str2sev(char *serverity) -{ - mm_msg_sev_t rc; - - /* convert mms severity string to enum. */ - if (strcmp(serverity, MESS_EMERG_STR) == 0) { - rc = MESS_EMERG; - } else if (strcmp(serverity, MESS_ALERT_STR) == 0) { - rc = MESS_ALERT; - } else if (strcmp(serverity, MESS_CRIT_STR) == 0) { - rc = MESS_CRIT; - } else if (strcmp(serverity, MESS_ERROR_STR) == 0) { - rc = MESS_ERROR; - } else if (strcmp(serverity, MESS_WARN_STR) == 0) { - rc = MESS_WARN; - } else if (strcmp(serverity, MESS_NOTICE_STR) == 0) { - rc = MESS_NOTICE; - } else if (strcmp(serverity, MESS_INFO_STR) == 0) { - rc = MESS_INFO; - } else if (strcmp(serverity, MESS_DEBUG_STR) == 0) { - rc = MESS_DEBUG; - } else { - rc = MESS_DEVP; - } - return (rc); -} - -/* Convert mms severity enum to string. */ -char * -mm_msg_sev2str(mm_msg_sev_t severity) -{ - char *rc; - - if (severity == MESS_EMERG) { - rc = MESS_EMERG_STR; - } else if (severity == MESS_ALERT) { - rc = MESS_ALERT_STR; - } else if (severity == MESS_CRIT) { - rc = MESS_CRIT_STR; - } else if (severity == MESS_ERROR) { - rc = MESS_ERROR_STR; - } else if (severity == MESS_WARN) { - rc = MESS_WARN_STR; - } else if (severity == MESS_NOTICE) { - rc = MESS_NOTICE_STR; - } else if (severity == MESS_INFO) { - rc = MESS_INFO_STR; - } else if (severity == MESS_DEBUG) { - rc = MESS_DEBUG_STR; - } else { - rc = MESS_DEVP_STR; - } - return (rc); -} - -/* Convert message cmd who enum to string. */ -static char * -mm_msg_who2str(mm_msg_who_t who) -{ - char *rc; - - if (who == MESS_OPER) { - rc = MESS_OPER_STR; - } else if (who == MESS_ADMIN) { - rc = MESS_ADMIN_STR; - } else { - rc = MESS_LOG_STR; - } - return (rc); -} - -static mm_msg_who_t -mm_msg_str2who(char *who) -{ - mm_msg_who_t rc; - - if (strcmp(who, MESS_OPER_STR) == 0) { - rc = MESS_OPER; - } else if (strcmp(who, MESS_ADMIN_STR) == 0) { - rc = MESS_ADMIN; - } else { - rc = MESS_LOG; - } - return (rc); -} - -/* Convert mms protocol language enum to message component string. */ -char * -mm_msg_lang2component(mm_lang_t lang) -{ - char *rc; - - if (lang == MM_LANG_DMP) { - rc = MESS_DM_STR; - } else if (lang == MM_LANG_LMP) { - rc = MESS_LM_STR; - } else { - rc = MESS_AI_STR; - } - return (rc); -} - -static void -mm_get_timestamp(mm_db_t *db, char *timestamp) -{ - int rc = 1; - char date[100]; - time_t tm; - struct tm ltime; - int i; - char *p; - - /* - * Get timestamp with 3 digit millisecond - */ - - if (db != NULL) { - if (mm_db_exec(HERE, db, "select cast(current_timestamp as " - "timestamp(3)) as ts;") != MM_DB_DATA) { - rc = 1; - } else if (PQntuples(db->mm_db_results) != 1) { - rc = 1; - } else { - memset(timestamp, 0, MM_TIMESTAMP); - snprintf(timestamp, MM_TIMESTAMP, "%s", - PQgetvalue(db->mm_db_results, 0, 0)); - - /* pad milliseconds with zeros */ - if (p = strrchr(timestamp, '.')) { - for (i = 1; i <= 3; i++) { - if (!isdigit(*(p+i))) { - *(p+i) = '0'; - } - } - } else { - /* zero milliseconds */ - strlcat(timestamp, ".000", MM_TIMESTAMP); - } - rc = 0; - } - mm_clear_db(&db->mm_db_results); - } - - if (rc) { - /* failed to get time from db so use system time */ - (void) time(&tm); - (void) localtime_r(&tm, <ime); - (void) strftime(date, 100, "%Y-%m-%d %H:%M:%S.000", <ime); - strlcpy(timestamp, date, MM_TIMESTAMP); - } -} diff --git a/usr/src/cmd/mms/mm/common/mm_notify.c b/usr/src/cmd/mms/mm/common/mm_notify.c deleted file mode 100644 index 1d3eadd39e..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_notify.c +++ /dev/null @@ -1,2657 +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 <mms_list.h> -#include <mms_parser.h> -#include <libpq-fe.h> -#include <string.h> -#include <stdlib.h> -#include <sys/time.h> -#include <pthread.h> -#include <errno.h> -#include <unistd.h> -#include <mms_trace.h> -#include <mms_strapp.h> -#include "mm_db.h" -#include "mm.h" -#include "mm_util.h" -#include "mm_sql.h" -#include "mm_commands.h" -#include "mm_sql.h" - -static char *_SrcFile = __FILE__; - -/* Event table notification types */ -#define ETABLE_STATUS 0 -#define ETABLE_REQUEST 1 -#define ETABLE_MESSAGE 2 -#define ETABLE_CARTRIDGE 3 -#define ETABLE_VOLUME 4 - - -/* All possible Notification Levels */ -#define NOTIFY_OFF 0 -#define NOTIFY_GLOBAL 1 -#define NOTIFY_APPLICATION 2 -#define NOTIFY_INSTANCE 3 -#define NOTIFY_SESSION 4 -#define NOTIFY_HOST 5 - -typedef struct notify notify_t; /* sql table notify object as a structure */ -struct notify { - char *n_uuid; - char *n_client; - char *n_inst; - char *n_cfgchg; - char *n_newdrive; - char *n_newcartridge; - char *n_volumeinject; - char *n_volumeeject; - char *n_volumeadd; - char *n_volumedelete; - char *n_dmup; - char *n_dmdown; - char *n_driveonline; - char *n_driveoffline; - char *n_lmup; - char *n_lmdown; - char *n_librarycreate; - char *n_librarydelete; - char *n_drivedelete; -}; - - -static pthread_mutex_t notify_lock; -static mm_db_t notify_db; -static mms_list_t notify_list; -static mm_data_t *notify_data; - - -static void notify_results(PGresult *results, int row, notify_t *notify); -static void notify_client(mm_wka_t *mm_wka, notify_t *notify, - notify_cmd_t *event); -static int notify_etable(int etable); - - - - -/* Initialize notify. */ -int -mm_notify_init(mm_data_t *data) -{ - mms_trace(MMS_DEVP, "mm_notify_init"); - - mms_list_create(¬ify_list, sizeof (notify_cmd_t), - offsetof(notify_cmd_t, evt_next)); - notify_data = data; - memset(¬ify_db, 0, sizeof (mm_db_t)); - notify_db.mm_db_cfg = data->mm_db.mm_db_cfg; - notify_db.mm_db_has_list = 0; - notify_db.mm_db_resending = 0; - if (mm_db_connect(¬ify_db) != MM_DB_OK) { - mms_trace(MMS_ERR, "notify db connection failed"); - return (1); - } - mms_list_create(¬ify_db.mm_db_cmds, sizeof (mm_char_list_t), - offsetof(mm_char_list_t, mm_char_list_next)); - notify_db.mm_db_has_list = 1; - - pthread_mutex_init(¬ify_lock, NULL); - data->mm_notify_list_mutex = ¬ify_lock; - data->mm_notify_list_ptr = ¬ify_list; - - return (0); -} - -/* Close notify. */ -void -mm_notify_close(void) -{ - mms_trace(MMS_DEVP, "mm_notify_close"); - - mm_db_disconnect(¬ify_db); -} -void -notify_set_cli_uuid(notify_cmd_t *event, uuid_text_t uuid) { - strncpy(event->evt_cli_uuid, - uuid, - UUID_PRINTF_SIZE); -} - -void -notify_set_session_uuid(notify_cmd_t *event, uuid_text_t uuid) { - strncpy(event->evt_session_uuid, - uuid, - UUID_PRINTF_SIZE); -} -void -notify_set_cmd_uuid(notify_cmd_t *event, uuid_text_t uuid) { - strncpy(event->evt_cmd_uuid, - uuid, - UUID_PRINTF_SIZE); -} -void -notify_set_cli_name(notify_cmd_t *event, char *name) { - event->evt_cli_name = mms_strapp(event->evt_cli_name, - name); -} -void -notify_set_cli_instance(notify_cmd_t *event, char *instance) { - event->evt_cli_instance = mms_strapp(event->evt_cli_instance, - instance); -} -void -notify_set_evt_obj_name(notify_cmd_t *event, char *name) { - event->evt_obj_name = mms_strapp(event->evt_obj_name, - name); -} -void -notify_set_evt_obj_instance(notify_cmd_t *event, char *instance) { - event->evt_obj_instance = mms_strapp(event->evt_obj_instance, - instance); -} -void -notify_set_evt_obj_host(notify_cmd_t *event, char *host) { - event->evt_obj_host = mms_strapp(event->evt_obj_host, - host); -} -void -notify_set_evt_obj_library(notify_cmd_t *event, char *library) { - event->evt_obj_library = mms_strapp(event->evt_obj_library, - library); -} -void -notify_set_evt_obj_cartid(notify_cmd_t *event, char *cartid) { - event->evt_obj_cartid = mms_strapp(event->evt_obj_cartid, - cartid); -} -void -notify_set_evt_obj_drive(notify_cmd_t *event, char *drive) { - event->evt_obj_drive = mms_strapp(event->evt_obj_drive, - drive); -} - - -void -mm_notify_send_status(mm_wka_t *notify_wka, PGresult *results) { - - char *event_buf = NULL; - int num_events = PQntuples(results); - char *obj_name; - cci_t *conn = ¬ify_wka->wka_conn; - char *info1; - char *info2; - char *info3; - int i; - - for (i = 0; i < num_events; i++) { - obj_name = PQgetvalue(results, i, 0); - info1 = NULL; - - /* This ordering depends on the */ - /* select statement in the funtion below */ - if (strcmp(obj_name, "LIBRARY") == 0) { - /* library event */ - info1 = PQgetvalue(results, i, 1); - } else if (strcmp(obj_name, "DRIVE") == 0) { - /* drive event */ - info1 = PQgetvalue(results, i, 1); - } if (strcmp(obj_name, "DM") == 0) { - /* dm event */ - info1 = PQgetvalue(results, i, 1); - } else if (strcmp(obj_name, "LM") == 0) { - /* lm event */ - info1 = PQgetvalue(results, i, 1); - } else if (strcmp(obj_name, "REQUEST") == 0) { - /* request event */ - info1 = PQgetvalue(results, i, 1); - info2 = PQgetvalue(results, i, 2); - info3 = PQgetvalue(results, i, 3); - if (info1 == NULL || info2 == NULL || info3 == NULL) { - info1 = NULL; - } - } else if (strcmp(obj_name, "MESSAGE") == 0) { - /* message event */ - info1 = PQgetvalue(results, i, 1); - info2 = PQgetvalue(results, i, 2); - info3 = PQgetvalue(results, i, 3); - if (info1 == NULL || info2 == NULL || info3 == NULL) { - info1 = NULL; - } - } else if (strcmp(obj_name, "CARTRIDGE") == 0) { - /* cartridge event */ - info1 = PQgetvalue(results, i, 1); - info2 = PQgetvalue(results, i, 2); - if (info1 == NULL || info2 == NULL) { - info1 = NULL; - } - } else if (strcmp(obj_name, "VOLUME") == 0) { - /* message event */ - info1 = PQgetvalue(results, i, 1); - info2 = PQgetvalue(results, i, 2); - info3 = PQgetvalue(results, i, 3); - if (info1 == NULL || info2 == NULL || info3 == NULL) { - info1 = NULL; - } - } - if (info1 != NULL) { - if (strcmp(obj_name, "REQUEST") == 0) { - event_buf = mms_strapp(event_buf, - "event request[\"%s\" \"%s\" \"%s\"];", - info1, - info2, - info3); - } else if (strcmp(obj_name, "MESSAGE") == 0) { - event_buf = mms_strapp(event_buf, - "event message[\"%s\" \"%s\" \"%s\"];", - info1, - info2, - info3); - } else if (strcmp(obj_name, "CARTRIDGE") == 0) { - event_buf = mms_strapp(event_buf, - "event cartridge[\"%s\" \"%s\"];", - info1, - info2); - } else if (strcmp(obj_name, "VOLUME") == 0) { - event_buf = mms_strapp(event_buf, - "event volume[\"%s\" \"%s\" \"%s\"];", - info1, - info2, - info3); - } else { - event_buf = mms_strapp(event_buf, - "event status[\"%s\" \"%s\"];", - obj_name, - info1); - } - mms_trace(MMS_INFO, - "Send event to %s %s, %s", - conn->cci_client, - conn->cci_instance, - event_buf); - mm_send_text(notify_wka->mm_wka_conn, - event_buf); - - } else { - mms_trace(MMS_ERR, - "bad status event"); - } - if (event_buf) { - free(event_buf); - event_buf = NULL; - } - } - - -} - -char * -mm_write_event(char *notify_obj, PGresult *notify_results, - PGresult *event_results, int i) { - char *event_buf = NULL; - int wrote_data = 0; - int j; - - /* same wka */ - event_buf = mms_strapp(event_buf, - "event tag[\"%s\"] " - "object[%s]", - PQgetvalue(notify_results, 0, 1), - notify_obj); - for (j = 2; j < 7; j++) { - if (j == 2 && - strcmp(PQgetvalue(event_results, - i, j), "") == 0) { - continue; - } else if (j == 2) { - wrote_data = 1; - event_buf = mms_strapp(event_buf, - "data[\"%s\" ", - PQgetvalue(event_results, - i, j)); - } else if (strcmp(PQgetvalue(event_results, - i, j), "") != 0) { - event_buf = mms_strapp(event_buf, - "\"%s\" ", - PQgetvalue(event_results, - i, j)); - } - } - if (wrote_data) { - event_buf = mms_strapp(event_buf, "]"); - } - event_buf = mms_strapp(event_buf, ";"); - return (event_buf); - -} - - -int -/* LINTED:mm_data may be needed in the future */ -mm_notify_event_rules(mm_data_t *mm_data) { - mm_db_t *db = ¬ify_db; - - PGresult *event_results; - int num_events = 0; - - PGresult *notify_results; - - int i; - - char *notify_id; - char *notify_obj; - - char *event_buf = NULL; - - mm_wka_t *notify_wka; - mm_wka_t *next_notify_wka; - - /* Send all events in rule table */ - if (mm_db_exec(HERE, db, - "select distinct \"NotifyID\",\"NotifyObject\"," - "\"Data1\",\"Data2\",\"Data3\",\"Data4\",\"Data5\" " - " from \"EVENTRULES\";") != MM_DB_DATA) { - mms_trace(MMS_ERR, - "error getting events " - "from EVENTRULES"); - return (1); - } - event_results = db->mm_db_results; - num_events = PQntuples(event_results); - mms_trace(MMS_DEVP, - "%d events found", - num_events); - - if (num_events == 0) { - mm_clear_db(&event_results); - return (0); - } - - for (i = 0; i < num_events; i ++) { - notify_id = PQgetvalue(event_results, i, 0); - notify_obj = PQgetvalue(event_results, i, 1); - if (mm_db_exec(HERE, db, - "select \"ConnectionID\",\"NotifyTag\"" - " from \"NOTIFYRULES\" where \"NotifyID\" = '%s';", - notify_id) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "error getting results " - "from NOTIFYRULES"); - mm_clear_db(&event_results); - return (1); - } - notify_results = db->mm_db_results; - if (PQntuples(notify_results) == 0) { - /* no notify row for this */ - char *savepoint = NULL; - savepoint = mms_strnew("\"%s\"", notify_id); - if (mm_db_txn_savepoint(db, - savepoint) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_notify_event_rules: " - "db error setting savepoint"); - } - if (mm_db_exec(HERE, db, - "drop rule \"%s\" on \"%s\";", notify_id, - notify_obj) != - MM_DB_OK) { - if (mm_db_txn_savepoint_rollback(db, - savepoint) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_notify_event_rules: " - "db error rollingback savepoint"); - } - } - if (mm_db_txn_release_savepoint(db, - savepoint) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_notify_event_rules: " - "db error releaseing savepoint"); - } - free(savepoint); - } else { - mms_trace(MMS_DEVP, - "send event to %s, %s", - PQgetvalue(notify_results, 0, 0), - PQgetvalue(notify_results, 0, 1)); - - - pthread_mutex_lock(¬ify_data->mm_wka_mutex); - for (notify_wka = - mms_list_head(¬ify_data->mm_wka_list); - notify_wka != NULL; - notify_wka = next_notify_wka) { - pthread_mutex_lock(¬ify_wka->wka_local_lock); - if (strcmp(notify_wka->wka_conn.cci_uuid, - PQgetvalue(notify_results, 0, 0)) == 0) { - - /* same wka */ - if ((event_buf = - mm_write_event(notify_obj, - notify_results, - event_results, i)) == NULL) { - mms_trace(MMS_ERR, - "error writing " - "event buffer"); - } else { - mm_send_text(notify_wka-> - mm_wka_conn, - event_buf); - free(event_buf); - event_buf = NULL; - } - } - next_notify_wka = - mms_list_next(¬ify_data->mm_wka_list, - notify_wka); - pthread_mutex_unlock(¬ify_wka-> - wka_local_lock); - } - pthread_mutex_unlock(¬ify_data->mm_wka_mutex); - } - - if (mm_db_exec(HERE, db, - "delete from \"EVENTRULES\"" - " where \"NotifyID\" = '%s';", - notify_id) != MM_DB_OK) { - mms_trace(MMS_ERR, - "error deleting " - "from NOTIFYRULES"); - mm_clear_db(&event_results); - mm_clear_db(¬ify_results); - return (1); - } - } - mm_clear_db(&event_results); - mm_clear_db(¬ify_results); - return (0); -} - -int -/* LINTED:mm_data maybe used in the future */ -mm_notify_event_table(mm_data_t *mm_data) { - mm_db_t *db = ¬ify_db; - int rc; - - rc = notify_etable(ETABLE_STATUS); - if (rc == 0) { - rc = notify_etable(ETABLE_REQUEST); - } - if (rc == 0) { - rc = notify_etable(ETABLE_MESSAGE); - } - if (rc == 0) { - rc = notify_etable(ETABLE_CARTRIDGE); - } - if (rc == 0) { - rc = notify_etable(ETABLE_VOLUME); - } - mms_trace(MMS_DEVP, - "clear event table of processed events"); - if (mm_db_exec(HERE, db, "delete from \"EVENT\" " - "where \"Seen\" = 't';") != MM_DB_OK) { - mms_trace(MMS_ERR, "clear event table"); - rc = 1; - } - return (rc); -} - -static int -notify_etable(int etable) { - mm_db_t *db = ¬ify_db; - - /* Event results */ - PGresult *event_results; - int num_events = 0; - - /* Client results */ - PGresult *client_results; - int num_clients = 0; - int i; - - /* Wka lookup */ - mm_wka_t *notify_wka; - mm_wka_t *next_notify_wka; - char *cur_uuid = NULL; - - /* Event specific */ - char *where; - char *what; - - switch (etable) { - case ETABLE_STATUS: - where = "where (\"ObjectName\" = 'LIBRARY' or " - "\"ObjectName\" = 'LM' or " - "\"ObjectName\" = 'DRIVE' or " - "\"ObjectName\" = 'DM')"; - what = "NotifyStatus"; - break; - case ETABLE_REQUEST: - where = "where (\"ObjectName\" = 'REQUEST')"; - what = "NotifyRequest"; - break; - case ETABLE_MESSAGE: - where = "where (\"ObjectName\" = 'MESSAGE')"; - what = "NotifyMessage"; - break; - case ETABLE_CARTRIDGE: - where = "where (\"ObjectName\" = 'CARTRIDGE')"; - what = "NotifyCartridge"; - break; - case ETABLE_VOLUME: - where = "where (\"ObjectName\" = 'VOLUME')"; - what = "NotifyVolume"; - break; - default: - mms_trace(MMS_ERR, - "unknown event table type %d", etable); - return (1); - } - - /* flag events we're going to process */ - if (mm_db_exec(HERE, db, - "update \"EVENT\" set \"Seen\" = 't' %s;", - where) != MM_DB_OK) { - mms_trace(MMS_ERR, - "error setting event seen"); - return (1); - } - - /* Get all the events */ - /* send_status_event is dependent */ - /* on the ordering of the */ - /* attributes in this select */ - if (mm_db_exec(HERE, db, - "select distinct \"ObjectName\"," - "\"Info1\",\"Info2\",\"Info3\",\"Info4\" from " - "\"EVENT\" %s and (\"Seen\" = 't');", - where) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "error getting event data from db"); - mm_clear_db(&db->mm_db_results); - return (1); - } - event_results = db->mm_db_results; - num_events = PQntuples(event_results); - if (num_events == 0) { - mms_trace(MMS_DEVP, - "No events found in event table"); - mm_clear_db(&event_results); - return (0); - } - mms_trace(MMS_DEVP, "num status events %d", num_events); - /* Get all the subscribers */ - if (mm_db_exec(HERE, db, - "select \"ConnectionID\" from " - "\"NOTIFY\" where " - "\"%s\" != " - "'off';", what) != MM_DB_DATA) { - mm_clear_db(&event_results); - mms_trace(MMS_ERR, - "error getting client data from db"); - return (1); - } - client_results = db->mm_db_results; - num_clients = PQntuples(client_results); - if (num_clients == 0) { - mms_trace(MMS_DEVP, - "No clients subscribed to status events"); - mm_clear_db(&event_results); - mm_clear_db(&client_results); - return (0); - } - mms_trace(MMS_DEVP, "num subscribed clients %d", num_clients); - /* Send the events to the subscribers */ - pthread_mutex_lock(¬ify_data->mm_wka_mutex); - for (notify_wka = mms_list_head(¬ify_data->mm_wka_list); - notify_wka != NULL; - notify_wka = next_notify_wka) { - pthread_mutex_lock(¬ify_wka->wka_local_lock); - - for (i = 0; i < num_clients; i ++) { - cur_uuid = PQgetvalue(client_results, i, 0); - if (strcmp(notify_wka->wka_conn.cci_uuid, - cur_uuid) == 0) { - /* This client needs the events */ - mm_notify_send_status(notify_wka, - event_results); - } - } - next_notify_wka = mms_list_next(¬ify_data->mm_wka_list, - notify_wka); - pthread_mutex_unlock(¬ify_wka->wka_local_lock); - } - pthread_mutex_unlock(¬ify_data->mm_wka_mutex); - mm_clear_db(&event_results); - mm_clear_db(&client_results); - return (0); -} - - - -int -mm_notify_add_driveonline(mm_wka_t *mm_wka, mm_command_t *cmd, - char *drivename) { - notify_cmd_t *event = NULL; - - if (drivename == NULL) { - mms_trace(MMS_ERR, - "drivename cannot be NULL, " - "mm_notify_add_driveonline"); - return (1); - } - - if ((event = mm_notify_add("event driveonline[\"%s\"];", - drivename)) == NULL) { - mms_trace(MMS_ERR, "Error adding notify event"); - return (1); - } else { - mms_trace(MMS_DEBUG, "Added notify event event"); - notify_set_cli_uuid(event, - mm_wka->wka_conn.cci_uuid); - notify_set_cli_name(event, - mm_wka->wka_conn.cci_client); - notify_set_cli_instance(event, - mm_wka->wka_conn.cci_instance); - notify_set_evt_obj_name(event, "DRIVE"); - notify_set_evt_obj_instance(event, drivename); - notify_set_cmd_uuid(event, cmd->cmd_uuid); - } - return (0); -} - -int -mm_notify_add_driveoffline(mm_wka_t *mm_wka, mm_command_t *cmd, - char *drivename) { - notify_cmd_t *event = NULL; - - if (drivename == NULL) { - mms_trace(MMS_ERR, - "drivename cannot be NULL, " - "mm_notify_add_driveoffline"); - return (1); - } - - if ((event = mm_notify_add("event driveoffline[\"%s\"];", - drivename)) == NULL) { - mms_trace(MMS_ERR, "Error adding notify event"); - return (1); - } else { - mms_trace(MMS_DEBUG, "Added notify event event"); - notify_set_cli_uuid(event, - mm_wka->wka_conn.cci_uuid); - notify_set_cli_name(event, - mm_wka->wka_conn.cci_client); - notify_set_cli_instance(event, - mm_wka->wka_conn.cci_instance); - notify_set_evt_obj_name(event, "DRIVE"); - notify_set_evt_obj_instance(event, drivename); - notify_set_cmd_uuid(event, cmd->cmd_uuid); - } - return (0); - - -} - -void -mm_notify_add_dmdown(mm_wka_t *dm_wka, mm_command_t *cmd) { - - notify_cmd_t *event = NULL; - - char *drivename = dm_wka->wka_conn.cci_client; - char *dmhost = dm_wka->wka_conn.cci_host; - char *dmname = dm_wka->wka_conn.cci_instance; - - if ((event = mm_notify_add("event dmdown[\"%s\" \"%s\" \"%s\"];", - dmname, - drivename, - dmhost)) == NULL) { - mms_trace(MMS_ERR, "Error adding notify event"); - } else { - mms_trace(MMS_DEBUG, "Added notify event event"); - notify_set_cli_uuid(event, - dm_wka->wka_conn.cci_uuid); - notify_set_cli_name(event, - dm_wka->wka_conn.cci_client); - notify_set_cli_instance(event, - dm_wka->wka_conn.cci_instance); - - notify_set_evt_obj_name(event, "DM"); - notify_set_evt_obj_instance(event, dmname); - notify_set_evt_obj_host(event, dmhost); - notify_set_evt_obj_drive(event, drivename); - if (cmd != NULL) { - notify_set_cmd_uuid(event, cmd->cmd_uuid); - } else { - event->evt_can_dispatch = 1; - } - } -} - - -int -mm_notify_add_dmdown_dc(mm_wka_t *dm_wka, mm_db_t *db) { - /* This function is called by the main thread, not the worker */ - /* So it will need to use the main thread's db connection */ - - /* If dm is in a ready state, add an event */ - if (mm_db_exec(HERE, db, - "select \"DMName\" from " - "\"DMCAPABILITYGROUP\" where " - "\"DMName\" = '%s';", - dm_wka->wka_conn.cci_instance) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error, mm_notify_add_dmdown_dc"); - mm_clear_db(&db->mm_db_results); - return (1); - } - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_ERR, - "rows != 1, mm_notify_add_dmdown_dc"); - mm_clear_db(&db->mm_db_results); - return (1); - } - mm_notify_add_dmdown(dm_wka, NULL); - mm_clear_db(&db->mm_db_results); - return (0); - -} - - - - -void -mm_notify_add_dmup(mm_wka_t *dm_wka, mm_command_t *cmd) { - notify_cmd_t *event = NULL; - - char *drivename = dm_wka->wka_conn.cci_client; - char *dmhost = dm_wka->wka_conn.cci_host; - char *dmname = dm_wka->wka_conn.cci_instance; - - /* Get DMTargetHost and DriveName */ - - if ((event = mm_notify_add("event dmup[\"%s\" \"%s\" \"%s\"];", - dmname, - drivename, - dmhost)) == NULL) { - mms_trace(MMS_ERR, "Error adding notify event"); - } else { - mms_trace(MMS_DEBUG, "Added notify event event"); - notify_set_cli_uuid(event, - dm_wka->wka_conn.cci_uuid); - notify_set_cli_name(event, - dm_wka->wka_conn.cci_client); - notify_set_cli_instance(event, - dm_wka->wka_conn.cci_instance); - - notify_set_evt_obj_name(event, "DM"); - notify_set_evt_obj_instance(event, dmname); - notify_set_evt_obj_host(event, dmhost); - notify_set_evt_obj_drive(event, drivename); - notify_set_cmd_uuid(event, cmd->cmd_uuid); - } -} - -void -mm_notify_add_librarycreate(mm_wka_t *mm_wka, mm_command_t *cmd, - char *libraryname) { - notify_cmd_t *event = NULL; - if ((event = mm_notify_add("event librarycreate[\"%s\"];", - libraryname)) == NULL) { - mms_trace(MMS_ERR, "Error adding notify event"); - } else { - mms_trace(MMS_DEBUG, "Added notify event event"); - notify_set_cli_uuid(event, - mm_wka->wka_conn.cci_uuid); - notify_set_cli_name(event, - mm_wka->wka_conn.cci_client); - notify_set_cli_instance(event, - mm_wka->wka_conn.cci_instance); - notify_set_evt_obj_name(event, "LIBRARY"); - notify_set_evt_obj_library(event, libraryname); - notify_set_cmd_uuid(event, cmd->cmd_uuid); - } -} - -void -mm_notify_add_librarydelete(mm_db_t *db, mm_wka_t *mm_wka, - mm_command_t *cmd, int match_off) { - - notify_cmd_t *event = NULL; - PGresult *results; - int rows; - int row; - char *libraryname = NULL; - if (mm_db_exec(HERE, db, "SELECT \"LibraryName\"" - " FROM \"LIBRARY\" %s", - &cmd->cmd_buf[match_off]) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "data base error getting library name"); - return; - } - results = db->mm_db_results; - rows = PQntuples(results); - if (rows == 0) { - mms_trace(MMS_DEVP, "Didn't match any library for delete"); - mm_clear_db(&results); - return; - } - - for (row = 0; row < rows; row ++) { - event = NULL; - libraryname = PQgetvalue(results, row, 0); - - if ((event = mm_notify_add("event librarydelete[\"%s\"];", - libraryname)) == NULL) { - mms_trace(MMS_ERR, "Error adding notify event"); - } else { - mms_trace(MMS_DEBUG, "Added librarydelete event for %s", - libraryname); - notify_set_cli_uuid(event, - mm_wka->wka_conn.cci_uuid); - notify_set_cli_name(event, - mm_wka->wka_conn.cci_client); - notify_set_cli_instance(event, - mm_wka->wka_conn.cci_instance); - notify_set_evt_obj_name(event, "LIBRARY"); - notify_set_evt_obj_library(event, libraryname); - notify_set_cmd_uuid(event, cmd->cmd_uuid); - } - } - mm_clear_db(&results); -} - - -void -mm_notify_add_drivedelete(mm_db_t *db, mm_wka_t *mm_wka, - mm_command_t *cmd, int match_off) { - - notify_cmd_t *event = NULL; - PGresult *results; - int rows; - int row; - char *drivename = NULL; - if (mm_db_exec(HERE, db, "SELECT \"DriveName\"" - " FROM \"DRIVE\" %s", - &cmd->cmd_buf[match_off]) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "data base error getting drive name"); - return; - } - results = db->mm_db_results; - rows = PQntuples(results); - if (rows == 0) { - mms_trace(MMS_DEVP, "Didn't match any drive for delete"); - mm_clear_db(&results); - return; - } - - for (row = 0; row < rows; row ++) { - event = NULL; - drivename = PQgetvalue(results, row, 0); - - if ((event = mm_notify_add("event drivedelete[\"%s\"];", - drivename)) == NULL) { - mms_trace(MMS_ERR, "Error adding notify event"); - } else { - mms_trace(MMS_DEBUG, "Added drivedelete event for %s", - drivename); - notify_set_cli_uuid(event, - mm_wka->wka_conn.cci_uuid); - notify_set_cli_name(event, - mm_wka->wka_conn.cci_client); - notify_set_cli_instance(event, - mm_wka->wka_conn.cci_instance); - notify_set_evt_obj_name(event, "DRIVE"); - notify_set_cmd_uuid(event, cmd->cmd_uuid); - } - } - mm_clear_db(&results); -} - - -void -mm_notify_add_newcartridge(mm_wka_t *mm_wka, mm_command_t *cmd, - char *cartridgepcl, - char *libraryname) { - notify_cmd_t *event = NULL; - if ((event = mm_notify_add("event newcartridge[\"%s\" \"%s\"];", - cartridgepcl, - libraryname)) == NULL) { - mms_trace(MMS_ERR, "Error adding notify event"); - } else { - mms_trace(MMS_DEBUG, "Added notify event event"); - notify_set_cli_uuid(event, - mm_wka->wka_conn.cci_uuid); - notify_set_cli_name(event, - mm_wka->wka_conn.cci_client); - notify_set_cli_instance(event, - mm_wka->wka_conn.cci_instance); - notify_set_evt_obj_name(event, "CARTRIDGE"); - notify_set_evt_obj_instance(event, cartridgepcl); - notify_set_evt_obj_library(event, libraryname); - notify_set_cmd_uuid(event, cmd->cmd_uuid); - } -} - -void -mm_notify_add_newdrive(mm_wka_t *mm_wka, mm_command_t *cmd, - char *drivename, char *libraryname) { - notify_cmd_t *event = NULL; - if ((event = mm_notify_add("event newdrive[\"%s\" \"%s\"];", - drivename, - libraryname)) == NULL) { - mms_trace(MMS_ERR, "Error adding newdrive event"); - } else { - mms_trace(MMS_DEBUG, "Added newdrive event"); - notify_set_cli_uuid(event, - mm_wka->wka_conn.cci_uuid); - notify_set_cli_name(event, - mm_wka->wka_conn.cci_client); - notify_set_cli_instance(event, - mm_wka->wka_conn.cci_instance); - notify_set_evt_obj_name(event, "DRIVE"); - notify_set_evt_obj_instance(event, drivename); - notify_set_evt_obj_library(event, libraryname); - notify_set_cmd_uuid(event, cmd->cmd_uuid); - } -} - -int -mm_notify_add_volumedelete(mm_wka_t *mm_wka, mm_command_t *cmd, - char *cartid, mm_db_t *db) { - - notify_cmd_t *event = NULL; - - - if (cartid == NULL) { - mms_trace(MMS_ERR, - "cannot have null cartid" - ", mm_notify_add_volumedelete"); - return (1); - } - - /* First find this cartridge type */ - - if (mm_db_exec(HERE, db, - "select " - "\"CARTRIDGE\".\"CartridgeTypeName\"," - "\"VOLUME\".\"VolumeName\" from " - "\"CARTRIDGE\",\"VOLUME\" where " - "\"VOLUME\".\"CartridgeID\" =" - "\"CARTRIDGE\".\"CartridgeID\" and " - "\"VOLUME\".\"CartridgeID\" = '%s';", - cartid) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - mms_trace(MMS_ERR, - "db error getting cartridge " - "type for %s, volumedelete event", - cartid); - return (1); - } - if (PQntuples(db->mm_db_results) != 1) { - - mms_trace(MMS_ERR, - "db error getting cartridge type, " - "%d rows returned, volumedelete event", - PQntuples(db->mm_db_results)); - mm_clear_db(&db->mm_db_results); - return (1); - } - - if ((event = mm_notify_add("event " - "volumedelete[\"%s\" \"%s\"];", - PQgetvalue(db->mm_db_results, 0, 1), - PQgetvalue(db->mm_db_results, 0, 0))) == NULL) { - mms_trace(MMS_ERR, "Error adding volumedelete event"); - mm_clear_db(&db->mm_db_results); - return (1); - } else { - - mms_trace(MMS_DEBUG, "Added volumedelete event event"); - notify_set_cli_uuid(event, - mm_wka->wka_conn.cci_uuid); - notify_set_cli_name(event, - mm_wka->wka_conn.cci_client); - notify_set_cli_instance(event, - mm_wka->wka_conn.cci_instance); - notify_set_evt_obj_name(event, "VOLUME"); - notify_set_evt_obj_instance(event, - PQgetvalue(db->mm_db_results, 0, 1)); - notify_set_evt_obj_cartid(event, - cartid); - notify_set_cmd_uuid(event, cmd->cmd_uuid); - mm_clear_db(&db->mm_db_results); - - } - return (0); - -} - - -int -mm_notify_add_volumeeject(mm_wka_t *lm_wka, mm_command_t *cmd, - char *pcl, mm_db_t *db) { - notify_cmd_t *event = NULL; - - char *library_name = lm_wka->wka_conn.cci_client; - char *volname = NULL; - char *carttype = NULL; - char *cartid = NULL; - int num_vols = 0; - int i; - - if (mm_db_exec(HERE, db, - "select " - "\"CARTRIDGE\".\"CartridgeTypeName\"," - "\"VOLUME\".\"VolumeName\", " - "\"CARTRIDGE\".\"CartridgeID\" " - "from " - "\"CARTRIDGE\",\"VOLUME\" " - "where ( " - "(\"VOLUME\".\"CartridgeID\" = " - "\"CARTRIDGE\".\"CartridgeID\") " - "and " - "(\"CARTRIDGE\".\"LibraryName\" = '%s') " - "and " - "(\"CARTRIDGE\".\"CartridgePCL\" = '%s'));", - library_name, - pcl) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - mms_trace(MMS_ERR, - "db error getting cartridge " - "type for %s, volumeeject event", - pcl); - return (1); - } - - num_vols = PQntuples(db->mm_db_results); - - mms_trace(MMS_DEBUG, - "%d volume(s) for cart, %s %s", - num_vols, - pcl, - library_name); - - for (i = 0; i < num_vols; i ++) { - carttype = PQgetvalue(db->mm_db_results, i, 0); - volname = PQgetvalue(db->mm_db_results, i, 1); - cartid = PQgetvalue(db->mm_db_results, i, 2); - event = NULL; - if ((event = mm_notify_add("event " - "volumeeject[\"%s\" \"%s\"];", - volname, - carttype)) == NULL) { - mms_trace(MMS_ERR, "Error adding volumeeject event"); - mm_clear_db(&db->mm_db_results); - return (1); - } else { - mms_trace(MMS_DEBUG, "Added volumeeject event event"); - notify_set_cli_uuid(event, - lm_wka->wka_conn.cci_uuid); - notify_set_cli_name(event, - lm_wka->wka_conn.cci_client); - notify_set_cli_instance(event, - lm_wka->wka_conn.cci_instance); - notify_set_evt_obj_name(event, "VOLUME"); - notify_set_evt_obj_cartid(event, - cartid); - notify_set_evt_obj_instance(event, - volname); - notify_set_cmd_uuid(event, cmd->cmd_uuid); - } - } - mm_clear_db(&db->mm_db_results); - return (0); - -} -int -mm_notify_add_volumeinject(mm_wka_t *lm_wka, mm_command_t *cmd, - char *pcl, mm_db_t *db) { - notify_cmd_t *event = NULL; - - char *library_name = lm_wka->wka_conn.cci_client; - char *volname = NULL; - char *carttype = NULL; - char *cartid = NULL; - int num_vols = 0; - int i; - - if (mm_db_exec(HERE, db, - "select " - "\"CARTRIDGE\".\"CartridgeTypeName\"," - "\"VOLUME\".\"VolumeName\", " - "\"CARTRIDGE\".\"CartridgeID\" " - "from " - "\"CARTRIDGE\",\"VOLUME\" " - "where ( " - "(\"VOLUME\".\"CartridgeID\" = " - "\"CARTRIDGE\".\"CartridgeID\") " - "and " - "(\"CARTRIDGE\".\"LibraryName\" = '%s') " - "and " - "(\"CARTRIDGE\".\"CartridgePCL\" = '%s'));", - library_name, - pcl) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - mms_trace(MMS_ERR, - "db error getting cartridge " - "type for %s, volumeinject event", - pcl); - return (1); - } - - num_vols = PQntuples(db->mm_db_results); - - mms_trace(MMS_DEBUG, - "%d volume(s) for cart, %s %s", - num_vols, - pcl, - library_name); - - for (i = 0; i < num_vols; i ++) { - carttype = PQgetvalue(db->mm_db_results, i, 0); - volname = PQgetvalue(db->mm_db_results, i, 1); - cartid = PQgetvalue(db->mm_db_results, i, 2); - event = NULL; - if ((event = mm_notify_add("event " - "volumeinject[\"%s\" \"%s\"];", - volname, - carttype)) == NULL) { - mms_trace(MMS_ERR, "Error adding volumeinject event"); - mm_clear_db(&db->mm_db_results); - return (1); - } else { - mms_trace(MMS_DEBUG, "Added volumeinject event event"); - notify_set_cli_uuid(event, - lm_wka->wka_conn.cci_uuid); - notify_set_cli_name(event, - lm_wka->wka_conn.cci_client); - notify_set_cli_instance(event, - lm_wka->wka_conn.cci_instance); - notify_set_evt_obj_name(event, "VOLUME"); - notify_set_evt_obj_cartid(event, - cartid); - notify_set_evt_obj_instance(event, - volname); - notify_set_cmd_uuid(event, cmd->cmd_uuid); - } - } - - mm_clear_db(&db->mm_db_results); - return (0); - -} - - - - -int -mm_notify_add_volumeadd(mm_wka_t *mm_wka, mm_command_t *cmd, - char *volumename, char *cartid, mm_db_t *db) { - - notify_cmd_t *event = NULL; - - if (volumename == NULL) { - mms_trace(MMS_ERR, - "cannot have null volumename" - ", mm_notify_add_volumeadd"); - return (1); - } - if (cartid == NULL) { - mms_trace(MMS_ERR, - "cannot have null cartid" - ", mm_notify_add_volumeadd"); - return (1); - } - - /* First find this cartridge type */ - - if (mm_db_exec(HERE, db, - "select " - "\"CARTRIDGE\".\"CartridgeTypeName\" " - "from \"CARTRIDGE\" " - "where " - "\"CARTRIDGE\".\"CartridgeID\" = '%s';", - cartid) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - mms_trace(MMS_ERR, - "db error getting cartridge " - "type for %s, volumeadd event", - volumename); - return (1); - } - if (PQntuples(db->mm_db_results) != 1) { - - mms_trace(MMS_ERR, - "db error getting cartridge type, " - "%d rows returned, volumeadd event", - PQntuples(db->mm_db_results)); - mm_clear_db(&db->mm_db_results); - return (1); - } - - if ((event = mm_notify_add("event " - "volumeadd[\"%s\" \"%s\"];", - volumename, - PQgetvalue(db->mm_db_results, 0, 0))) == NULL) { - mms_trace(MMS_ERR, "Error adding volumeadd event"); - mm_clear_db(&db->mm_db_results); - return (1); - } else { - mm_clear_db(&db->mm_db_results); - mms_trace(MMS_DEBUG, "Added volumeadd event event"); - notify_set_cli_uuid(event, - mm_wka->wka_conn.cci_uuid); - notify_set_cli_name(event, - mm_wka->wka_conn.cci_client); - notify_set_cli_instance(event, - mm_wka->wka_conn.cci_instance); - notify_set_evt_obj_name(event, "VOLUME"); - notify_set_evt_obj_instance(event, - volumename); - notify_set_evt_obj_cartid(event, - cartid); - notify_set_cmd_uuid(event, cmd->cmd_uuid); - - } - return (0); - -} - -int -mm_notify_add_lmup(mm_wka_t *lm_wka, mm_command_t *cmd) { - /* This adds an lmready event to the event queue */ - /* lm_wka should be the wka of the lm who is ready */ - - /* Library Ready event */ - notify_cmd_t *event = NULL; - if ((event = mm_notify_add("event " - "lmup[\"%s\" \"%s\"];", - lm_wka->wka_conn.cci_instance, - lm_wka->wka_conn.cci_client)) == NULL) { - mms_trace(MMS_ERR, "Error adding lmready event"); - return (1); - } else { - mms_trace(MMS_DEBUG, "Added lmup event event"); - notify_set_cli_uuid(event, - lm_wka->wka_conn.cci_uuid); - notify_set_cli_name(event, - lm_wka->wka_conn.cci_client); - notify_set_cli_instance(event, - lm_wka->wka_conn.cci_instance); - notify_set_evt_obj_name(event, "LM"); - notify_set_evt_obj_instance(event, - lm_wka->wka_conn.cci_instance); - notify_set_evt_obj_library(event, - lm_wka->wka_conn.cci_client); - notify_set_cmd_uuid(event, cmd->cmd_uuid); - } - return (0); -} -int -mm_notify_add_lmdown_dc(mm_wka_t *lm_wka, mm_db_t *db) { - /* This function is called by the main thread, not the worker */ - /* So it will need to use the main thread's db connection */ - - /* If lm is in a ready state, add an event */ - if (mm_db_exec(HERE, db, - "select \"LMStateSoft\" " - "from \"LM\" where " - "\"LMName\" = '%s';", - lm_wka->wka_conn.cci_instance) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error, mm_notify_add_lmdown_dc"); - mm_clear_db(&db->mm_db_results); - return (1); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, - "rows != 1, mm_notify_add_lmdown_dc"); - mm_clear_db(&db->mm_db_results); - return (1); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), - "ready") == 0) { - mms_trace(MMS_DEBUG, - "lm dissconnected in ready state, add event"); - if (mm_notify_add_lmdown(lm_wka, NULL)) { - mms_trace(MMS_ERR, - "mm_notify_add_lmdown_dc: " - "error adding lm down event"); - } - } - mm_clear_db(&db->mm_db_results); - return (0); - -} - -int -mm_notify_add_lmdown(mm_wka_t *lm_wka, mm_command_t *cmd) { - /* This adds an lmready event to the event queue */ - /* lm_wka should be the wka of the lm who is ready */ - - /* Library Ready event */ - notify_cmd_t *event = NULL; - if ((event = mm_notify_add("event " - "lmdown[\"%s\" \"%s\"];", - lm_wka->wka_conn.cci_instance, - lm_wka->wka_conn.cci_client)) == NULL) { - mms_trace(MMS_ERR, "Error adding lmready event"); - return (1); - } else { - mms_trace(MMS_DEBUG, "Added lmup event event"); - notify_set_cli_uuid(event, - lm_wka->wka_conn.cci_uuid); - notify_set_cli_name(event, - lm_wka->wka_conn.cci_client); - notify_set_cli_instance(event, - lm_wka->wka_conn.cci_instance); - notify_set_evt_obj_name(event, "LM"); - notify_set_evt_obj_instance(event, - lm_wka->wka_conn.cci_instance); - notify_set_evt_obj_library(event, - lm_wka->wka_conn.cci_client); - if (cmd != NULL) { - notify_set_cmd_uuid(event, cmd->cmd_uuid); - } else { - event->evt_can_dispatch = 1; - } - } - return (0); - -} - - -int -mm_notify_add_config(mm_wka_t *mm_wka, mm_command_t *cmd, - char *type, char *name, char *instance, - char *host) { - notify_cmd_t *event = NULL; - - if (strcmp(type, "change") == 0) { - if ((event = mm_notify_add(NOTIFY_EVENT_CFG_CHG, - name, - instance, - instance)) == NULL) { - mms_trace(MMS_ERR, "Error adding config event"); - return (1); - } - } else { - if ((event = mm_notify_add(NOTIFY_EVENT_CFG, name, - type, instance)) == NULL) { - mms_trace(MMS_ERR, "Error adding config event"); - return (1); - } - } - mms_trace(MMS_DEBUG, "Added config event"); - notify_set_cli_uuid(event, - mm_wka->wka_conn.cci_uuid); - notify_set_cli_name(event, - mm_wka->wka_conn.cci_client); - notify_set_cli_instance(event, - mm_wka->wka_conn.cci_instance); - notify_set_evt_obj_name(event, name); - notify_set_evt_obj_instance(event, instance); - notify_set_evt_obj_host(event, host); - notify_set_cmd_uuid(event, cmd->cmd_uuid); - - return (0); -} - - -/* Add event to pending event list for client. */ -notify_cmd_t * -mm_notify_add(char *event_fmt, ...) -{ - va_list args; - - notify_cmd_t *event = NULL; - - - mms_trace(MMS_DEVP, "mm_notify_add"); - - if ((event = (notify_cmd_t *)calloc(1, - sizeof (notify_cmd_t))) == NULL) { - return (NULL); - } - - va_start(args, event_fmt); - event->evt_cmd = mms_vstrapp(NULL, event_fmt, args); - va_end(args); - if (event->evt_cmd == NULL) { - free(event); - return (NULL); - } - event->evt_can_dispatch = 0; - event->evt_cli_name = NULL; - event->evt_cli_instance = NULL; - event->evt_obj_name = NULL; - event->evt_obj_host = NULL; - event->evt_obj_library = NULL; - event->evt_obj_cartid = NULL; - event->evt_obj_drive = NULL; - event->evt_obj_app = NULL; - event->evt_obj_appinst = NULL; - - mms_trace(MMS_DEBUG, - "Added event, %s", - event->evt_cmd); - pthread_mutex_lock(¬ify_lock); - mms_list_insert_tail(¬ify_list, event); - pthread_mutex_unlock(¬ify_lock); - - return (event); -} - -void -mm_notify_destroy(notify_cmd_t *event) { - /* clean up the event */ - if (event->evt_cmd != NULL) - free(event->evt_cmd); - if (event->evt_cli_name != NULL) - free(event->evt_cli_name); - if (event->evt_obj_name != NULL) - free(event->evt_obj_name); - if (event->evt_obj_instance != NULL) - free(event->evt_obj_instance); - if (event->evt_obj_host != NULL) - free(event->evt_obj_host); - if (event->evt_obj_library != NULL) - free(event->evt_obj_library); - if (event->evt_obj_cartid != NULL) - free(event->evt_obj_cartid); - if (event->evt_obj_drive != NULL) - free(event->evt_obj_drive); - if (event->evt_obj_app != NULL) - free(event->evt_obj_app); - if (event->evt_obj_appinst != NULL) - free(event->evt_obj_appinst); - if (event->evt_cli_instance != NULL) - free(event->evt_cli_instance); - free(event); -} - - - -/* Command or action was successful, send client events. */ - -void -mm_notify_commit(char *cmd_uuid) { - notify_cmd_t *event; - - mms_trace(MMS_DEVP, - "mm_notify_commit"); - - - pthread_mutex_lock(¬ify_lock); - mms_list_foreach(¬ify_list, event) { - if (strcmp(event->evt_cmd_uuid, cmd_uuid) == 0) { - mms_trace(MMS_DEVP, - "commit event %s", - event->evt_cmd); - event->evt_can_dispatch = 1; - } - - } - pthread_mutex_unlock(¬ify_lock); -} - - - - -void -mm_notify_rollback(char *cmd_uuid) { - notify_cmd_t *event; - notify_cmd_t *next_event; - - mms_trace(MMS_DEVP, - "mm_notify_rollback"); - pthread_mutex_lock(¬ify_lock); - for (event = mms_list_head(¬ify_list); - event != NULL; - event = next_event) { - next_event = mms_list_next(¬ify_list, event); - if (strcmp(event->evt_cmd_uuid, cmd_uuid) == 0) { - mms_list_remove(¬ify_list, event); - - mms_trace(MMS_DEVP, "remove event, %s", - event->evt_cmd); - mm_notify_destroy(event); - } - } - pthread_mutex_unlock(¬ify_lock); -} - - - -/* Send event now. */ -int -mm_notify_now(char *cli_uuid, char *event_fmt, ...) -{ - va_list args; - notify_cmd_t *event; - - mms_trace(MMS_DEVP, "mm_notify_now"); - - if ((event = (notify_cmd_t *)calloc(1, - sizeof (notify_cmd_t))) == NULL) { - return (1); - } - - va_start(args, event_fmt); - event->evt_cmd = mms_vstrapp(NULL, event_fmt, args); - va_end(args); - if (event->evt_cmd == NULL) { - free(event); - return (1); - } - if (cli_uuid) { - /* not mm event */ - strncpy(event->evt_cli_uuid, cli_uuid, UUID_PRINTF_SIZE); - /* Find session, application and instance for this client */ - } - - event->evt_can_dispatch = 1; - mms_trace(MMS_DEVP, - "adding event for immediate dispatch, %s", - event->evt_cmd); - pthread_mutex_lock(¬ify_lock); - mms_list_insert_tail(¬ify_list, event); - pthread_mutex_unlock(¬ify_lock); - return (0); -} - -int -notify_send(notify_cmd_t *event) -{ - notify_t notify; - int rows; - mm_wka_t *notify_wka; - mm_wka_t *next_notify_wka; - int print_message = 0; - mm_db_t *db = ¬ify_db; - - char *cli_name = event->evt_cli_name; - char *cli_instance = event->evt_cli_instance; - char *obj_name = event->evt_obj_name; - char *obj_instance = event->evt_obj_instance; - char *obj_host = event->evt_obj_host; - char *obj_library = event->evt_obj_library; - char *obj_cartid = event->evt_obj_cartid; - char *obj_drive = event->evt_obj_drive; - PGresult *results; - - mms_trace(MMS_DEBUG, - "notify_send"); - mms_trace(MMS_DEBUG, - "send event %s", - event->evt_cmd); - if (cli_name) - mms_trace(MMS_DEBUG, - " client name, %s", - cli_name); - if (cli_instance) - mms_trace(MMS_DEBUG, - " client instance, %s", - cli_instance); - if (obj_name) - mms_trace(MMS_DEBUG, - " object name, %s", - obj_name); - if (obj_instance) - mms_trace(MMS_DEBUG, - " object instance, %s", - obj_instance); - if (obj_host) - mms_trace(MMS_DEBUG, - " object host, %s", - obj_host); - if (obj_library) - mms_trace(MMS_DEBUG, - " object library, %s", - obj_library); - if (obj_cartid) - mms_trace(MMS_DEBUG, - " object cartid, %s", - obj_cartid); - if (obj_drive) - mms_trace(MMS_DEBUG, - " object drive, %s", - obj_drive); - - /* - * Send event to mm subsribers. - */ - - pthread_mutex_lock(¬ify_data->mm_wka_mutex); - for (notify_wka = mms_list_head(¬ify_data->mm_wka_list); - notify_wka != NULL; - notify_wka = next_notify_wka) { - - pthread_mutex_lock(¬ify_wka->wka_local_lock); - - if (print_message) - mms_trace(MMS_INFO, "examining a client, %s", - notify_wka->wka_conn.cci_uuid); - - if (mm_db_exec(HERE, db, "SELECT \"ConnectionID\"," - "\"ConnectionClientName\"," - "\"ConnectionClientInstance\"," - "\"NotifyConfigChange\"," - "\"NotifyNewDrive\", " - "\"NotifyNewCartridge\", " - "\"NotifyVolumeAdd\", " - "\"NotifyVolumeDelete\", " - "\"NotifyDMUp\", " - "\"NotifyDMDown\", " - "\"NotifyDriveOnline\", " - "\"NotifyDriveOffline\", " - "\"NotifyLMUp\", " - "\"NotifyLMDown\", " - "\"NotifyVolumeInject\", " - "\"NotifyVolumeEject\", " - "\"NotifyLibraryCreate\", " - "\"NotifyLibraryDelete\", " - "\"NotifyDriveDelete\" " - "FROM \"NOTIFY\"" - "where \"ConnectionID\" = '%s';", - notify_wka->wka_conn.cci_uuid) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - mms_trace(MMS_DEBUG, "notify db select failed"); - return (1); - } - rows = PQntuples(db->mm_db_results); - results = db->mm_db_results; - if (rows != 0) { - mms_trace(MMS_DEVP, - "notify a client"); - /* NOTIFY entry for this connection */ - /* Set up the notify struct */ - notify_results(results, 0, ¬ify); - /* Notify the client */ - notify_client(notify_wka, ¬ify, - event); - } else { - mms_trace(MMS_DEVP, - "client has no notification settings"); - } - next_notify_wka = mms_list_next(¬ify_data->mm_wka_list, - notify_wka); - pthread_mutex_unlock(¬ify_wka->wka_local_lock); - mm_clear_db(&results); - } - pthread_mutex_unlock(¬ify_data->mm_wka_mutex); - return (0); -} - -static void -notify_results(PGresult *results, int row, notify_t *notify) -{ - notify->n_uuid = PQgetvalue(results, row, 0); - notify->n_client = PQgetvalue(results, row, 1); - notify->n_inst = PQgetvalue(results, row, 2); - notify->n_cfgchg = PQgetvalue(results, row, 3); - notify->n_newdrive = PQgetvalue(results, row, 4); - notify->n_newcartridge = PQgetvalue(results, row, 5); - notify->n_volumeadd = PQgetvalue(results, row, 6); - notify->n_volumedelete = PQgetvalue(results, row, 7); - notify->n_dmup = PQgetvalue(results, row, 8); - notify->n_dmdown = PQgetvalue(results, row, 9); - notify->n_driveonline = PQgetvalue(results, row, 10); - notify->n_driveoffline = PQgetvalue(results, row, 11); - notify->n_lmup = PQgetvalue(results, row, 12); - notify->n_lmdown = PQgetvalue(results, row, 13); - notify->n_volumeinject = PQgetvalue(results, row, 14); - notify->n_volumeeject = PQgetvalue(results, row, 15); - notify->n_librarycreate = PQgetvalue(results, row, 16); - notify->n_librarydelete = PQgetvalue(results, row, 17); - notify->n_drivedelete = PQgetvalue(results, row, 18); -} - - -int -notify_return_scope(char *scope) { - if (scope == NULL) { - mms_trace(MMS_ERR, "notify_return_scope " - "passed a NULL scope"); - return (NOTIFY_OFF); - } - if (strcmp(scope, "off") == 0) { - mms_trace(MMS_DEVP, " off scope"); - return (NOTIFY_OFF); - } else if (strcmp(scope, "global") == 0) { - mms_trace(MMS_DEVP, " global scope"); - return (NOTIFY_GLOBAL); - } else if (strcmp(scope, "application") == 0) { - mms_trace(MMS_DEVP, " application scope"); - return (NOTIFY_APPLICATION); - } else if (strcmp(scope, "instance") == 0) { - mms_trace(MMS_DEVP, " instance scope"); - return (NOTIFY_INSTANCE); - } else if (strcmp(scope, "session") == 0) { - mms_trace(MMS_DEVP, " session scope"); - return (NOTIFY_SESSION); - } else if (strcmp(scope, "host") == 0) { - mms_trace(MMS_DEVP, " host scope"); - return (NOTIFY_HOST); - } else { - mms_trace(MMS_ERR, "notify_return_scope " - "passed an unknown scope, %s", - scope); - return (NOTIFY_OFF); - } -} -int -/* LINTED: notify may be needed in the future */ -notify_check_session_event(mm_wka_t *mm_wka, notify_t *notify, - notify_cmd_t *event_cmd, - int event_scope) { - - cci_t *conn = &mm_wka->wka_conn; - char *event_text = event_cmd->evt_cmd; - - mms_trace(MMS_DEBUG, - "notify_check_session_event"); - - mms_trace(MMS_DEVP, - "%s", - event_text); - - /* Use this check for any event of this type */ - - /* Allowed scope values for a session event */ - /* Global- all */ - /* Application- application == client app */ - /* Instance- app and inst == client app, inst */ - /* Session- session id == client session */ - - - /* Client does not have this event 'off' */ - /* Check scope */ - if (event_scope == NOTIFY_GLOBAL) { - mms_trace(MMS_DEVP, " global scope"); - } else if ((event_scope == NOTIFY_APPLICATION) && - (event_cmd->evt_cli_name != NULL)) { - mms_trace(MMS_DEVP, " application scope"); - mms_trace(MMS_DEVP, " event app is %s, " - "client app is %s", - event_cmd->evt_cli_name, - conn->cci_client); - if (strcmp(event_cmd->evt_cli_name, - conn->cci_client) == 0) { - /* App name matches */ - mms_trace(MMS_DEVP, "App name matches"); - } else { - mms_trace(MMS_DEVP, " skip event"); - return (0); - } - } else if ((event_scope == NOTIFY_INSTANCE) && - (event_cmd->evt_cli_name != NULL) && - (event_cmd->evt_cli_instance != NULL)) { - mms_trace(MMS_DEVP, " instance scope"); - mms_trace(MMS_DEVP, " event app is %s %s, " - "client app is %s %s", - event_cmd->evt_cli_name, - event_cmd->evt_cli_instance, - conn->cci_client, - conn->cci_instance); - if ((strcmp(event_cmd->evt_cli_name, - conn->cci_client) == 0) && - (strcmp(event_cmd->evt_cli_instance, - conn->cci_instance) == 0)) { - /* App and instance match */ - mms_trace(MMS_DEVP, "App and instance match"); - } else { - mms_trace(MMS_DEVP, " skip event"); - return (0); - } - - - } else if ((event_scope == NOTIFY_SESSION) && - (event_cmd->evt_session_uuid != NULL)) { - mms_trace(MMS_DEVP, " session scope"); - mms_trace(MMS_DEVP, - " event session is %s, ", - event_cmd->evt_session_uuid); - mms_trace(MMS_DEVP, - " client session is %s", - mm_wka->session_uuid); - if (strcmp(event_cmd->evt_session_uuid, - mm_wka->session_uuid) != 0) { - /* Session ID does not match */ - mms_trace(MMS_DEVP, " skip event"); - return (0); - } - /* Session ID matches */ - } else { - mms_trace(MMS_ERR, - "Passed an unsupported event " - "scope for this event type"); - mms_trace(MMS_DEVP, " skip event"); - return (0); - } - - - return (1); - - -} - - -int -/* LINTED: notify may be needed in the future */ -notify_check_dmup(mm_wka_t *mm_wka, notify_t *notify, - notify_cmd_t *event_cmd, - int event_scope) { - - cci_t *conn = &mm_wka->wka_conn; - mm_db_t *db = ¬ify_db; - - char *dmhost = event_cmd->evt_obj_host; - - /* Event has global and host scope */ - if (event_scope == NOTIFY_GLOBAL) { - return (1); - } else if (event_scope == NOTIFY_HOST) { - /* Confirm hosts are the same */ - - if (mm_db_exec(HERE, db, - "select * from " - "pg_host_ident('%s') " - "where pg_host_ident('%s') = " - "pg_host_ident('%s');", - dmhost, - dmhost, - conn->cci_host) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error, notify_check_dmup"); - mm_clear_db(&db->mm_db_results); - return (0); - } - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_DEVP, - "client host != dm host"); - mm_clear_db(&db->mm_db_results); - return (0); - } - mm_clear_db(&db->mm_db_results); - return (1); - - } else { - mms_trace(MMS_ERR, - "unknown scope for dmup event"); - return (0); - } -} -int -/* LINTED: notify may be needed in the future */ -notify_check_dmdown(mm_wka_t *mm_wka, notify_t *notify, - notify_cmd_t *event_cmd, - int event_scope) { - - cci_t *conn = &mm_wka->wka_conn; - mm_db_t *db = ¬ify_db; - - char *dmhost = event_cmd->evt_obj_host; - - /* Event has global and host scope */ - if (event_scope == NOTIFY_GLOBAL) { - return (1); - } else if (event_scope == NOTIFY_HOST) { - /* Confirm hosts are the same */ - - if (mm_db_exec(HERE, db, - "select * from " - "pg_host_ident('%s') " - "where pg_host_ident('%s') = " - "pg_host_ident('%s');", - dmhost, - dmhost, - conn->cci_host) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error, notify_check_dmup"); - mm_clear_db(&db->mm_db_results); - return (0); - } - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_DEVP, - "client host != dm host"); - mm_clear_db(&db->mm_db_results); - return (0); - } - mm_clear_db(&db->mm_db_results); - return (1); - - } else { - mms_trace(MMS_ERR, - "unknown scope for dmup event"); - return (0); - } -} - -int -/* LINTED: notify may be needed in the future */ -notify_check_driveonline(mm_wka_t *mm_wka, notify_t *notify, - notify_cmd_t *event_cmd, - int event_scope) { - - cci_t *conn = &mm_wka->wka_conn; - mm_db_t *db = ¬ify_db; - - char *drivename = event_cmd->evt_obj_instance; - - /* driveonline event */ - /* global -all */ - /* application - client has DRIVEGROUP access */ - if (event_scope == NOTIFY_GLOBAL) { - return (1); - } else if (event_scope == NOTIFY_APPLICATION) { - /* Check this client and drive group */ - if (mm_db_exec(HERE, db, - "select distinct \"DRIVE\".* from \"DRIVE\" " - "cross join \"DRIVEGROUPAPPLICATION\" " - "where " - "(\"DRIVE\".\"DriveGroupName\" = " - "\"DRIVEGROUPAPPLICATION\".\"DriveGroupName\") " - "and " - "(\"DRIVE\".\"DriveName\" = '%s') AND " - "(\"DRIVEGROUPAPPLICATION\"." - "\"ApplicationName\" = '%s');", - drivename, - conn->cci_client) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error, notify_check_driveonline"); - mm_clear_db(&db->mm_db_results); - return (0); - } - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_DEVP, - "client does not have drive access"); - mm_clear_db(&db->mm_db_results); - return (0); - } - mm_clear_db(&db->mm_db_results); - return (1); - } else { - mms_trace(MMS_ERR, - "unknown scope for driveonline event"); - return (0); - } -} - -int -/* LINTED: notify may be needed in the future */ -notify_check_driveoffline(mm_wka_t *mm_wka, notify_t *notify, - notify_cmd_t *event_cmd, - int event_scope) { - - cci_t *conn = &mm_wka->wka_conn; - mm_db_t *db = ¬ify_db; - char *drivename = event_cmd->evt_obj_instance; - - /* driveoffline event */ - /* global -all */ - /* application - client has DRIVEGROUP access */ - if (event_scope == NOTIFY_GLOBAL) { - return (1); - } else if (event_scope == NOTIFY_APPLICATION) { - /* Check this client and drive group */ - if (mm_db_exec(HERE, db, - "select distinct \"DRIVE\".* from \"DRIVE\" " - "cross join \"DRIVEGROUPAPPLICATION\" " - "where " - "(\"DRIVE\".\"DriveGroupName\" = " - "\"DRIVEGROUPAPPLICATION\".\"DriveGroupName\") " - "and " - "(\"DRIVE\".\"DriveName\" = '%s') AND " - "(\"DRIVEGROUPAPPLICATION\"." - "\"ApplicationName\" = '%s');", - drivename, - conn->cci_client) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error, notify_check_driveoffline"); - mm_clear_db(&db->mm_db_results); - return (0); - } - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_DEVP, - "client does not have drive access"); - mm_clear_db(&db->mm_db_results); - return (0); - } - mm_clear_db(&db->mm_db_results); - return (1); - } else { - mms_trace(MMS_ERR, - "unknown scope for driveoffline event"); - return (0); - } -} - - -int -/* LINTED: notify may be needed in the future */ -notify_check_volumeevent(mm_wka_t *mm_wka, notify_t *notify, - notify_cmd_t *event_cmd, - int event_scope) { - - cci_t *conn = &mm_wka->wka_conn; - char *event_text = event_cmd->evt_cmd; - - - mm_db_t *db = ¬ify_db; - - char *volumename = event_cmd->evt_obj_instance; - char *cartid = event_cmd->evt_obj_cartid; - - int app_ok = 0; - int instance_ok = 0; - mms_trace(MMS_DEBUG, - "notify_check_volumeevent"); - - mms_trace(MMS_DEVP, - "%s", - event_text); - - /* Allowed scope values for SIA volume event */ - /* Global - all */ - /* Application - VOLUME.AppName = cci_client */ - /* Instance - VOLUME.AIName = cci_instance */ - if (event_scope == NOTIFY_GLOBAL) { - mms_trace(MMS_DEVP, " global scope"); - } else if ((event_scope == NOTIFY_APPLICATION) || - (event_scope == NOTIFY_INSTANCE)) { - mms_trace(MMS_DEVP, " application or instance scope"); - /* This volume's application should match the clients app */ - - if (mm_db_exec(HERE, db, - "select " - "\"VOLUME\".\"ApplicationName\", " - "\"VOLUME\".\"AIName\" " - "from \"VOLUME\" where " - "\"CartridgeID\" = '%s'", - cartid) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error getting app name for %s, " - "notify_check_volumeevent", - volumename); - mm_clear_db(&db->mm_db_results); - return (0); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, - "db returned %d rows != 1 " - "notify_check_volumeevent", - PQntuples(db->mm_db_results)); - mm_clear_db(&db->mm_db_results); - return (0); - } - /* compare the apps */ - if (strcmp(conn->cci_client, - PQgetvalue(db->mm_db_results, 0, 0)) == 0) { - mms_trace(MMS_DEVP, - "app name matches"); - app_ok = 1; - } else { - mms_trace(MMS_DEVP, - "app name does not match"); - } - /* compare the instance */ - if (strcmp(conn->cci_instance, - PQgetvalue(db->mm_db_results, 0, 1)) == 0) { - mms_trace(MMS_DEVP, - "instance matches"); - instance_ok = 1; - } else { - mms_trace(MMS_DEVP, - "instance does not match"); - } - mm_clear_db(&db->mm_db_results); - } else { - mms_trace(MMS_ERR, - "Passed an unsupported event " - "scope for volumeevent"); - mms_trace(MMS_DEVP, " skip event"); - return (0); - } - if (event_scope == NOTIFY_APPLICATION) { - if (app_ok) { - return (1); - } else { - return (0); - } - } - if (event_scope == NOTIFY_INSTANCE) { - if (app_ok && instance_ok) { - return (1); - } else { - return (0); - } - } - return (1); -} - - - -int -/* LINTED: notify may be needed in the future */ -notify_check_lmup(mm_wka_t *mm_wka, notify_t *notify, - notify_cmd_t *event_cmd, - int event_scope) { - - char *event_text = event_cmd->evt_cmd; - - /* Allowed scope for lmready */ - /* Global- all */ - - mms_trace(MMS_DEBUG, - "notify_check_lmup"); - mms_trace(MMS_DEVP, - "%s", - event_text); - if (event_scope == NOTIFY_GLOBAL) { - /* Global is the only scope currently implemeneted, */ - return (1); - } else { - mms_trace(MMS_ERR, - "unknown scope, notify_check_lmup"); - return (0); - } -} -int -/* LINTED: notify may be needed in the future */ -notify_check_lmdown(mm_wka_t *mm_wka, notify_t *notify, - notify_cmd_t *event_cmd, - int event_scope) { - char *event_text = event_cmd->evt_cmd; - - /* Allowed scope for lmready */ - /* Global- all */ - - mms_trace(MMS_DEBUG, - "notify_check_lmdown"); - mms_trace(MMS_DEVP, - "%s", - event_text); - /* Global is the only scope currently implemeneted, */ - if (event_scope == NOTIFY_GLOBAL) { - /* Global is the only scope currently implemeneted, */ - return (1); - } else { - mms_trace(MMS_ERR, - "unknown scope, notify_check_lmdown"); - return (0); - } -} - - -int -/* LINTED: notify may be needed in the future */ -notify_check_newdrive(mm_wka_t *mm_wka, notify_t *notify, - notify_cmd_t *event_cmd, - int event_scope) { - - cci_t *conn = &mm_wka->wka_conn; - char *event_text = event_cmd->evt_cmd; - - char *db_buf = NULL; - mm_db_t *db = ¬ify_db; - - char *drivename = event_cmd->evt_obj_instance; - char *libraryname = event_cmd->evt_obj_library; - - mms_trace(MMS_DEBUG, - "notify_check_newdrive"); - - mms_trace(MMS_DEVP, - "%s", - event_text); - - if ((drivename == NULL) || (libraryname == NULL)) { - mms_trace(MMS_ERR, - "bad drivename or libraryname in event struct"); - return (0); - } - - /* Allowed scope values for a config change event */ - /* Global- all */ - /* Application- client application has DRIVEGROUPAPPLICATION */ - if (event_scope == NOTIFY_GLOBAL) { - mms_trace(MMS_DEVP, " global scope"); - } else if (event_scope == NOTIFY_APPLICATION) { - - db_buf = mms_strapp(db_buf, - "select distinct " - "\"DRIVEGROUPAPPLICATION\".* from " - "\"DRIVEGROUPAPPLICATION\" " - "cross join \"DRIVE\" where ( " - "(\"DRIVEGROUPAPPLICATION\"." - "\"DriveGroupName\" = " - "\"DRIVE\".\"DriveGroupName\") " - "and ((\"DRIVE\".\"DriveName\" = " - "'%s') AND " - "(\"DRIVE\".\"LibraryName\" = '%s') AND " - "(\"DRIVEGROUPAPPLICATION\"." - "\"ApplicationName\" = '%s')) " - ");", - drivename, - libraryname, - conn->cci_client); - if (mm_db_exec(HERE, db, db_buf) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - free(db_buf); - mms_trace(MMS_ERR, - "error getting db info"); - return (0); - } - free(db_buf); - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_DEVP, - "%s has no access to %s, skip event", - conn->cci_client, - drivename); - mm_clear_db(&db->mm_db_results); - return (0); - } - mm_clear_db(&db->mm_db_results); - - } else { - mms_trace(MMS_ERR, - "Passed an unsupported event " - "scope for this event type"); - mms_trace(MMS_DEVP, " skip event"); - return (0); - } - return (1); - - - - -} - -int -/* LINTED: notify may be needed in the future */ -notify_check_newcartridge(mm_wka_t *mm_wka, notify_t *notify, - notify_cmd_t *event_cmd, - int event_scope) { - - cci_t *conn = &mm_wka->wka_conn; - char *event_text = event_cmd->evt_cmd; - - char *db_buf = NULL; - - mm_db_t *db = ¬ify_db; - char *pcl = event_cmd->evt_obj_instance; - char *library = event_cmd->evt_obj_library; - - - mms_trace(MMS_DEBUG, - "notify_check_newcartridge"); - - mms_trace(MMS_DEVP, - "%s", - event_text); - - if ((pcl == NULL) || (library == NULL)) { - mms_trace(MMS_ERR, - "bad pcl or library name in event struct"); - return (0); - } - - - /* Allowed scope values for a config change event */ - /* Global- all */ - /* Application- client application has CARTRIDGEGROUPAPPLICATION */ - - if (event_scope == NOTIFY_GLOBAL) { - mms_trace(MMS_DEVP, " global scope"); - } else if (event_scope == NOTIFY_APPLICATION) { - - db_buf = mms_strapp(db_buf, - "select distinct " - "\"CARTRIDGEGROUPAPPLICATION\".* from " - "\"CARTRIDGEGROUPAPPLICATION\" " - "cross join \"CARTRIDGE\" where ( " - "(\"CARTRIDGEGROUPAPPLICATION\"." - "\"CartridgeGroupName\" = " - "\"CARTRIDGE\".\"CartridgeGroupName\") " - "and ((\"CARTRIDGE\".\"CartridgePCL\" = " - "'%s') AND " - "(\"CARTRIDGE\".\"LibraryName\" = '%s') AND " - "(\"CARTRIDGEGROUPAPPLICATION\"." - "\"ApplicationName\" = '%s')) " - ");", - pcl, - library, - conn->cci_client); - if (mm_db_exec(HERE, db, db_buf) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - free(db_buf); - mms_trace(MMS_ERR, - "error getting db info"); - return (0); - } - free(db_buf); - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_DEVP, - "%s has no access to %s, skip event", - conn->cci_client, - pcl); - mm_clear_db(&db->mm_db_results); - return (0); - } - mm_clear_db(&db->mm_db_results); - - - } else { - mms_trace(MMS_ERR, - "Passed an unsupported event " - "scope for this event type"); - mms_trace(MMS_DEVP, " skip event"); - return (0); - } - return (1); - -} - -int -/* LINTED: notify may be needed in the future */ -notify_check_cfgchg(mm_wka_t *mm_wka, notify_t *notify, notify_cmd_t *event_cmd, - int event_scope) { - - cci_t *conn = &mm_wka->wka_conn; - char *event_text = event_cmd->evt_cmd; - - char *db_buf = NULL; - mm_db_t *db = ¬ify_db; - - mms_trace(MMS_DEBUG, - "notify_check_cfgchg"); - - mms_trace(MMS_DEVP, - "%s", - event_text); - - /* Allowed scope values for a config change event */ - /* Global- all */ - /* Host- client host == DM/LM host */ - - if (event_scope == NOTIFY_GLOBAL) { - mms_trace(MMS_DEVP, " global scope"); - } else if (event_scope == NOTIFY_HOST) { - mms_trace(MMS_DEVP, " host scope"); - /* Check that our event has the proper struct */ - if (event_cmd->evt_obj_name == NULL) { - /* This would be LM or DM */ - mms_trace(MMS_ERR, - "bad evt_obj_name " - "in notify_check_cfgchg"); - return (0); - } - if (event_cmd->evt_obj_instance == NULL) { - /* This is the LM/DM's name */ - mms_trace(MMS_ERR, - "bad evt_obj_instance " - "in notify_check_cfgchg"); - return (0); - } - if (event_cmd->evt_obj_host == NULL) { - /* This is the LM/DM's host */ - mms_trace(MMS_ERR, - "bad evt_obj_host " - "in notify_check_cfgchg"); - return (0); - } - - if (conn->cci_host == NULL) { - /* Host of client we are */ - /* sending event to */ - mms_trace(MMS_ERR, - "bad cci_host " - "in notify_check_cfgchg"); - return (0); - } - - - /* For this event the LM/LM name */ - /* is stored in event client instance */ - /* Event type is in client name */ - db_buf = mms_strapp(db_buf, - "select * from " - "pg_host_ident('%s') " - "where pg_host_ident('%s') = " - "pg_host_ident('%s')", - conn->cci_host, - event_cmd->evt_obj_host, - conn->cci_host); - - if (mm_db_exec(HERE, db, db_buf) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - free(db_buf); - mms_trace(MMS_ERR, - "error getting db info"); - return (0); - } - free(db_buf); - - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_DEVP, - "%s %s not configured of %s, skip event", - event_cmd->evt_obj_name, - event_cmd->evt_obj_instance, - conn->cci_host); - mm_clear_db(&db->mm_db_results); - return (0); - } - mm_clear_db(&db->mm_db_results); - } else { - mms_trace(MMS_ERR, - "Passed an unsupported event " - "scope for this event type"); - mms_trace(MMS_DEVP, " skip event"); - return (0); - } - return (1); -} - -static void -notify_client(mm_wka_t *mm_wka, notify_t *notify, notify_cmd_t *event_cmd) -{ - int do_notify = 0; - mms_par_node_t *event; - cci_t *conn = &mm_wka->wka_conn; - char *event_text = event_cmd->evt_cmd; - - int event_scope = 0; - - mms_trace(MMS_DEVP, "notify_client %s %s", - conn->cci_client, - conn->cci_instance); - - - if ((event = mm_text_to_par_node(event_text, - mms_mmp_parse)) == NULL) { - if (event_text != NULL) { - mms_trace(MMS_ERR, "cannot parse event, %s", - event_text); - } else { - mms_trace(MMS_ERR, - "event_text was NULL, cannot parse"); - } - return; - } - - - - /* Match the event up with this connection's notify setting */ - /* All working events must be listed here */ - - if (mms_pn_lookup(event, "driveoffline", MMS_PN_CLAUSE, 0) && - ((event_scope = - notify_return_scope(notify->n_driveoffline)) != 0)) { - mms_trace(MMS_DEVP, "Check scope for driveoffline event"); - if (notify_check_driveoffline(mm_wka, notify, - event_cmd, event_scope)) { - do_notify = 1; - } - } else if (mms_pn_lookup(event, "driveonline", MMS_PN_CLAUSE, 0) && - ((event_scope = - notify_return_scope(notify->n_driveonline)) != 0)) { - mms_trace(MMS_DEVP, "Check scope for driveonline event"); - if (notify_check_driveonline(mm_wka, notify, - event_cmd, event_scope)) { - do_notify = 1; - } - } else if (mms_pn_lookup(event, "dmdown", MMS_PN_CLAUSE, 0) && - ((event_scope = - notify_return_scope(notify->n_dmdown)) != 0)) { - mms_trace(MMS_DEVP, "Check scope for dmdown event"); - if (notify_check_dmdown(mm_wka, notify, - event_cmd, event_scope)) { - do_notify = 1; - } - } else if (mms_pn_lookup(event, "dmup", MMS_PN_CLAUSE, 0) && - ((event_scope = - notify_return_scope(notify->n_dmup)) != 0)) { - mms_trace(MMS_DEVP, "Check scope for dmup event"); - if (notify_check_dmup(mm_wka, notify, - event_cmd, event_scope)) { - do_notify = 1; - } - } else if (mms_pn_lookup(event, "volumedelete", MMS_PN_CLAUSE, 0) && - ((event_scope = - notify_return_scope(notify->n_volumedelete)) != 0)) { - mms_trace(MMS_DEVP, "Check scope for volumedelete event"); - if (notify_check_volumeevent(mm_wka, notify, - event_cmd, event_scope)) { - do_notify = 1; - } - } else if (mms_pn_lookup(event, "volumeadd", MMS_PN_CLAUSE, 0) && - ((event_scope = - notify_return_scope(notify->n_volumeadd)) != 0)) { - mms_trace(MMS_DEVP, "Check scope for volumeadd event"); - if (notify_check_volumeevent(mm_wka, notify, - event_cmd, event_scope)) { - do_notify = 1; - } - } else if (mms_pn_lookup(event, "volumeinject", MMS_PN_CLAUSE, 0) && - ((event_scope = - notify_return_scope(notify->n_volumeinject)) != 0)) { - mms_trace(MMS_DEVP, "Check scope for volumeinject event"); - if (notify_check_volumeevent(mm_wka, notify, - event_cmd, event_scope)) { - do_notify = 1; - } - } else if (mms_pn_lookup(event, "volumeeject", MMS_PN_CLAUSE, 0) && - ((event_scope = - notify_return_scope(notify->n_volumeeject)) != 0)) { - mms_trace(MMS_DEVP, "Check scope for volumeeject event"); - if (notify_check_volumeevent(mm_wka, notify, - event_cmd, event_scope)) { - do_notify = 1; - } - } else if (mms_pn_lookup(event, "lmup", MMS_PN_CLAUSE, 0) && - ((event_scope = - notify_return_scope(notify->n_lmup)) != 0)) { - mms_trace(MMS_DEVP, "Check scope for lmup event"); - if (notify_check_lmup(mm_wka, notify, - event_cmd, event_scope)) { - do_notify = 1; - } - } else if (mms_pn_lookup(event, "lmdown", MMS_PN_CLAUSE, 0) && - ((event_scope = - notify_return_scope(notify->n_lmdown)) != 0)) { - mms_trace(MMS_DEVP, "Check scope for lmdown event"); - if (notify_check_lmdown(mm_wka, notify, - event_cmd, event_scope)) { - do_notify = 1; - } - } else if (mms_pn_lookup(event, "newdrive", MMS_PN_CLAUSE, NULL) && - ((event_scope = - notify_return_scope(notify->n_newdrive)) != 0)) { - mms_trace(MMS_DEVP, "Check scope for newdrive event"); - if (notify_check_newdrive(mm_wka, notify, - event_cmd, event_scope)) { - do_notify = 1; - } - } else if (mms_pn_lookup(event, "newcartridge", MMS_PN_CLAUSE, - NULL) && - ((event_scope = - notify_return_scope(notify->n_newcartridge)) != 0)) { - mms_trace(MMS_DEVP, "Check scope for newcartridge event"); - if (notify_check_newcartridge(mm_wka, notify, - event_cmd, event_scope)) { - do_notify = 1; - } - } else if (mms_pn_lookup(event, "config", MMS_PN_CLAUSE, NULL) && - ((event_scope = - notify_return_scope(notify->n_cfgchg)) != 0)) { - mms_trace(MMS_DEVP, "Check scope for config event"); - if (notify_check_cfgchg(mm_wka, notify, - event_cmd, event_scope)) { - do_notify = 1; - } - } else if (mms_pn_lookup(event, "librarycreate", - MMS_PN_CLAUSE, NULL) && - ((event_scope = - notify_return_scope(notify->n_librarycreate)) != 0)) { - mms_trace(MMS_DEVP, "Global scope for library create event"); - do_notify = 1; - } else if (mms_pn_lookup(event, "librarydelete", - MMS_PN_CLAUSE, NULL) && - ((event_scope = - notify_return_scope(notify->n_librarydelete)) != 0)) { - mms_trace(MMS_DEVP, "Global scope for library delete event"); - do_notify = 1; - } else if (mms_pn_lookup(event, "drivedelete", - MMS_PN_CLAUSE, NULL) && - ((event_scope = - notify_return_scope(notify->n_drivedelete)) != 0)) { - mms_trace(MMS_DEVP, "Global scope for drive delete event"); - do_notify = 1; - } - - if (do_notify) { - /* - * Forward event to client. - */ - mms_trace(MMS_INFO, - "Send event to %s %s, %s", - conn->cci_client, - conn->cci_instance, - event_text); - mm_send_text(mm_wka->mm_wka_conn, event_text); - } else { - mms_trace(MMS_DEVP, "skip event %s %s, %s", - conn->cci_client, - conn->cci_instance, - event_text); - } - -not_found: - mms_pn_destroy(event); -} diff --git a/usr/src/cmd/mms/mm/common/mm_path.c b/usr/src/cmd/mms/mm/common/mm_path.c deleted file mode 100644 index ecef674045..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_path.c +++ /dev/null @@ -1,629 +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 <stdlib.h> -#include <string.h> -#include <errno.h> -#include <libxml/parser.h> -#include "mms_strapp.h" -#include "mms_trace.h" -#include "mm_path.h" - -static char *_SrcFile = __FILE__; - -typedef struct mm_name mm_name_t; -struct mm_name { - char **mm_name; - int mm_name_num; -}; - -typedef struct mm_pkey_list mm_pkey_list_t; -struct mm_pkey_list { - mm_pkey_t **mm_pkey; - int mm_pkey_num; -}; - -typedef struct mm_path_list mm_path_list_t; -struct mm_path_list { - mm_path_t **mm_path; - int mm_path_num; -}; - -typedef struct mm_user_data mm_user_data_t; -struct mm_user_data { - int mm_once; - int mm_error; - int mm_level; - int mm_scan; - mm_pkey_t *mm_pkey; - int mm_path_num; - int mm_path_index; - int mm_node_index; - int mm_att_index; -}; - -static mm_name_t mm_obj; /* object name list */ -static mm_name_t mm_att; /* attribute name list */ -static mm_pkey_list_t mm_pkey_list; /* object primary key list */ -static mm_path_list_t mm_path_list; /* object path list */ - - - -static int mm_parse_paths(mm_user_data_t *user_data, char *fn); -static void mm_parse_start_elements(void *xml_user_data, - const xmlChar *xml_name, const xmlChar **xml_atts); -static void mm_parse_end_elements(void *xml_user_data, - const xmlChar *xml_name); - -static void mm_name_add(mm_name_t *name, char *token); -static char *mm_get_obj_ptr(char **obj); -static char *mm_get_att_ptr(char **att); -static int mm_name_cmp(const void *p1, const void *p2); -static int mm_pkey_cmp(const void *p1, const void *p2); -static int mm_path_cmp(const void *p1, const void *p2); - - - -int -mm_init_paths(char *fn) -{ - int i; - mm_user_data_t user_data; - - - mms_trace(MMS_DEVP, "path init %s", fn); - - /* - * Zero data - */ - memset(&mm_obj, 0, sizeof (mm_name_t)); - memset(&mm_att, 0, sizeof (mm_name_t)); - memset(&mm_pkey_list, 0, sizeof (mm_pkey_list_t)); - memset(&mm_path_list, 0, sizeof (mm_path_list_t)); - - /* - * Allocate unique object and attribute strings - */ - memset(&user_data, 0, sizeof (mm_user_data_t)); - user_data.mm_scan = 1; - if (mm_parse_paths(&user_data, fn)) { - return (1); - } - - /* Sort unique object and attribute names */ - qsort(mm_obj.mm_name, mm_obj.mm_name_num, sizeof (char *), - mm_name_cmp); - qsort(mm_att.mm_name, mm_att.mm_name_num, sizeof (char *), - mm_name_cmp); - - /* Pre-allocate object pkey array */ - mm_pkey_list.mm_pkey_num = mm_obj.mm_name_num; - if ((mm_pkey_list.mm_pkey = (mm_pkey_t **)malloc(sizeof (mm_pkey_t *) * - mm_pkey_list.mm_pkey_num)) == NULL) { - return (1); - } - for (i = 0; i < mm_pkey_list.mm_pkey_num; i++) { - mm_pkey_list.mm_pkey[i] = - (mm_pkey_t *)calloc(1, sizeof (mm_pkey_t)); - mm_pkey_list.mm_pkey[i]->mm_obj = mm_obj.mm_name[i]; - } - - /* Pre-allocate paths array */ - mms_trace(MMS_DEVP, "number of paths %d", user_data.mm_path_num); - mm_path_list.mm_path_num = user_data.mm_path_num; - if ((mm_path_list.mm_path = (mm_path_t **)malloc(sizeof (mm_path_t *) * - mm_path_list.mm_path_num)) == NULL) { - return (1); - } - for (i = 0; i < mm_path_list.mm_path_num; i++) { - mm_path_list.mm_path[i] = (mm_path_t *)calloc(1, - sizeof (mm_path_t)); - } - - /* - * Build primary keys and paths using pre-allocated strings and arrays - */ - memset(&user_data, 0, sizeof (mm_user_data_t)); - if (mm_parse_paths(&user_data, fn)) { - return (1); - } - - /* Sort paths */ - qsort(mm_path_list.mm_path, mm_path_list.mm_path_num, - sizeof (mm_path_t *), mm_path_cmp); - - mms_trace(MMS_DEVP, "paths done"); - return (user_data.mm_error); -} - -mm_path_t * -mm_get_path(char *obj_1, char *obj_2) -{ - mm_path_t **path; - mm_path_t key_data; - mm_path_t *key = &key_data; - - /* - * Get path between object 1 and object 2 - */ - - if (obj_1 == NULL) { - mms_trace(MMS_DEVP, "obj_1 is null"); - return (NULL); - } - - if (obj_2 == NULL) { - mms_trace(MMS_DEVP, "obj_2 is null"); - return (NULL); - } - - if ((key_data.mm_id = mms_strnew("%s%s", obj_1, obj_2)) == NULL) { - mms_trace(MMS_DEVP, "no mem"); - return (NULL); - } - - path = bsearch(&key, - mm_path_list.mm_path, - mm_path_list.mm_path_num, - sizeof (mm_path_t **), - mm_path_cmp); - - free(key_data.mm_id); - - if (path == NULL) { - return (NULL); - } - return (*path); -} - -void -mm_print_path(mm_path_t *path) -{ - int i, j; - char *buf; - - if (path == NULL) { - mms_trace(MMS_DEVP, "path is null"); - return; - } - - mms_trace(MMS_DEVP, "path id %s", path->mm_id); - for (i = 0; i < path->mm_node_num; i++) { - mms_trace(MMS_DEVP, - "node from %s to %s", path->mm_node[i]->mm_obj, - path->mm_node[i]->mm_ref_obj); - - buf = mms_strnew("pkey %s (", path->mm_node[i]->mm_obj); - for (j = 0; j < path->mm_node[i]->mm_pkey->mm_att_num; j++) { - buf = mms_strapp(buf, "%s ", - path->mm_node[i]->mm_pkey->mm_att[j]); - } - if (path->mm_node[i]->mm_pkey->mm_att_num) { - buf[strlen(buf)-1] = '\0'; - } - mms_trace(MMS_DEVP, "%s)", buf); - free(buf); - - buf = mms_strnew("edge ("); - for (j = 0; j < path->mm_node[i]->mm_edge_num; j++) { - if (path->mm_node[i]->mm_edge[j]->mm_ref_att == NULL) { - buf = mms_strapp(buf, "%s, ", - path->mm_node[i]->mm_edge[j]->mm_att); - } else { - buf = mms_strapp(buf, "%s %s, ", - path->mm_node[i]->mm_edge[j]->mm_att, - path->mm_node[i]->mm_edge[j]->mm_ref_att); - } - } - if (path->mm_node[i]->mm_edge_num) { - buf[strlen(buf)-2] = '\0'; - } - mms_trace(MMS_DEVP, "%s)", buf); - free(buf); - } -} - -static int -mm_parse_paths(mm_user_data_t *user_data, char *fn) -{ - xmlSAXHandler handler; - - memset(&handler, 0, sizeof (xmlSAXHandler)); - handler.startElement = mm_parse_start_elements; - handler.endElement = mm_parse_end_elements; - xmlDefaultSAXHandlerInit(); - xmlSAXUserParseFile(&handler, user_data, fn); - if (user_data->mm_once == 0) { - user_data->mm_error = __LINE__; - } - if (user_data->mm_error) { - mms_trace(MMS_ERR, "%s parse - scan %d error %d level %d", - fn, - user_data->mm_scan, - user_data->mm_error, - user_data->mm_level); - } - return (user_data->mm_error); -} - -static void -mm_parse_start_elements(void *xml_user_data, const xmlChar *xml_name, - const xmlChar **xml_atts) -{ - int i; - mm_user_data_t *user_data = (mm_user_data_t *)xml_user_data; - char *name = (char *)xml_name; - char **atts = (char **)xml_atts; - int num; - char *str; - char *from; - char *to; - int index; - int nindex; - char *value; - char *to_value; - - if (user_data->mm_error) { - return; - } - - if (user_data->mm_once == 0) { - user_data->mm_once = 1; - } - - if (user_data->mm_level == 0 && strcmp(name, "mm_paths") == 0) { - user_data->mm_level = 1; - return; - } - - if (user_data->mm_level == 1 && strcmp(name, "primary_keys") == 0) { - user_data->mm_level = 2; - return; - } - - if (user_data->mm_level == 2 && strcmp(name, "paths") == 0) { - user_data->mm_level = 3; - return; - } - - if (user_data->mm_level == 2 && strcmp(name, "object") == 0) { - if (atts[0] == NULL || strcmp(atts[0], "name") != 0) { - user_data->mm_error = __LINE__; - } else if (user_data->mm_scan) { - mm_name_add(&mm_obj, atts[1]); - } else if ((user_data->mm_pkey = - mm_get_pkey(atts[1])) == NULL) { - user_data->mm_error = __LINE__; - } - user_data->mm_level = 3; - return; - } - - if (user_data->mm_level == 3 && strcmp(name, "pkey") == 0) { - if (atts[0] == NULL || strcmp(atts[0], "value") != 0) { - user_data->mm_error = __LINE__; - } else if (user_data->mm_scan) { - mm_name_add(&mm_att, atts[1]); - } else { - num = user_data->mm_pkey->mm_att_num; - if ((str = mm_get_att_ptr(&atts[1])) == NULL) { - user_data->mm_error = __LINE__; - } else if ((user_data->mm_pkey->mm_att = - (char **)realloc(user_data->mm_pkey->mm_att, - sizeof (char *) * (num + 1))) == NULL) { - user_data->mm_error = __LINE__; - } else { - user_data->mm_pkey->mm_att[num++] = str; - user_data->mm_pkey->mm_att_num = num; - } - } - return; - } - - if (user_data->mm_level == 3 && strcmp(name, "path") == 0) { - for (i = 0; atts[i] != NULL; i += 2) { - if (strcmp(atts[i], "from") == 0) { - from = atts[i+1]; - if (user_data->mm_scan) { - mm_name_add(&mm_obj, from); - } - } else if (strcmp(atts[i], "to") == 0) { - to = atts[i+1]; - if (user_data->mm_scan) { - mm_name_add(&mm_obj, to); - } - } else { - user_data->mm_error = __LINE__; - return; - } - } - if (user_data->mm_scan) { - user_data->mm_path_num++; - } else { - num = user_data->mm_path_index; - if ((mm_path_list.mm_path[num]->mm_id = - mms_strnew("%s%s", from, to)) == NULL) { - user_data->mm_error = __LINE__; - } - user_data->mm_node_index = 0; - } - return; - } - - if (user_data->mm_level == 3 && strcmp(name, "node") == 0) { - for (i = 0; atts[i] != NULL; i += 2) { - if (strcmp(atts[i], "from") == 0) { - from = atts[i+1]; - if (user_data->mm_scan) { - mm_name_add(&mm_obj, from); - } - } else if (strcmp(atts[i], "to") == 0) { - to = atts[i+1]; - if (user_data->mm_scan) { - mm_name_add(&mm_obj, to); - } - } else { - user_data->mm_error = __LINE__; - return; - } - } - if (user_data->mm_scan == 0) { - mm_node_t **p; - mm_node_t **q; - mm_pkey_t *pkey; - - index = user_data->mm_path_index; - q = mm_path_list.mm_path[index]->mm_node; - num = mm_path_list.mm_path[index]->mm_node_num; - - if ((p = (mm_node_t **)realloc(q, - sizeof (mm_node_t **)*(num + 1))) == NULL) { - user_data->mm_error = __LINE__; - return; - } - mm_path_list.mm_path[index]->mm_node = p; - if ((mm_path_list.mm_path[index]->mm_node[num] = - (mm_node_t *)calloc(1, - sizeof (mm_node_t))) == NULL) { - user_data->mm_error = __LINE__; - return; - } - if ((pkey = mm_get_pkey(from)) == NULL) { - user_data->mm_error = __LINE__; - return; - } - if ((str = mm_get_obj_ptr(&to)) == NULL) { - user_data->mm_error = __LINE__; - return; - } - mm_path_list.mm_path[index]-> - mm_node[num]->mm_obj = pkey->mm_obj; - mm_path_list.mm_path[index]-> - mm_node[num]->mm_pkey = pkey; - mm_path_list.mm_path[index]-> - mm_node[num]->mm_ref_obj = str; - mm_path_list.mm_path[index]->mm_node_num++; - - user_data->mm_att_index = 0; - } - return; - } - - if (user_data->mm_level == 3 && strcmp(name, "att") == 0) { - to_value = NULL; - for (i = 0; atts[i] != NULL; i += 2) { - if (strcmp(atts[i], "value") == 0) { - value = atts[i+1]; - if (user_data->mm_scan) { - mm_name_add(&mm_att, value); - } - } else if (strcmp(atts[i], "to_value") == 0) { - to_value = atts[i+1]; - if (user_data->mm_scan) { - mm_name_add(&mm_att, to_value); - } - } else { - user_data->mm_error = __LINE__; - return; - } - } - if (user_data->mm_scan == 0) { - mm_att_t **p; - mm_att_t **q; - - index = user_data->mm_path_index; - nindex = user_data->mm_node_index; - q = mm_path_list.mm_path[index]-> - mm_node[nindex]->mm_edge; - num = mm_path_list.mm_path[index]-> - mm_node[nindex]->mm_edge_num; - - if ((p = (mm_att_t **)realloc(q, - sizeof (mm_att_t **)*(num + 1))) == NULL) { - user_data->mm_error = __LINE__; - return; - } - mm_path_list.mm_path[index]-> - mm_node[nindex]->mm_edge = p; - if ((mm_path_list.mm_path[index]->mm_node[nindex]-> - mm_edge[num] = (mm_att_t *)calloc(1, - sizeof (mm_att_t))) == NULL) { - user_data->mm_error = __LINE__; - return; - } - - if ((str = mm_get_att_ptr(&value)) == NULL) { - user_data->mm_error = __LINE__; - return; - } - mm_path_list.mm_path[index]-> - mm_node[nindex]->mm_edge[num]->mm_att = str; - - if (to_value) { - if ((str = mm_get_att_ptr(&to_value)) == NULL) { - user_data->mm_error = __LINE__; - return; - } - mm_path_list.mm_path[index]->mm_node[nindex]-> - mm_edge[num]->mm_ref_att = str; - } - mm_path_list.mm_path[index]-> - mm_node[nindex]->mm_edge_num++; - } - return; - } - - user_data->mm_error = __LINE__; -} - -static void -mm_parse_end_elements(void *xml_user_data, const xmlChar *xml_name) -{ - mm_user_data_t *user_data = (mm_user_data_t *)xml_user_data; - char *name = (char *)xml_name; - - if (user_data->mm_error) { - return; - } - - if (user_data->mm_level == 3 && strcmp(name, "object") == 0) { - user_data->mm_level = 2; - return; - } - - if (user_data->mm_level == 3 && strcmp(name, "path") == 0) { - user_data->mm_path_index++; - return; - } - - if (user_data->mm_level == 3 && strcmp(name, "node") == 0) { - user_data->mm_node_index++; - return; - } - - if (user_data->mm_level == 3 && strcmp(name, "att") == 0) { - user_data->mm_att_index++; - return; - } -} - -static void -mm_name_add(mm_name_t *name, char *token) -{ - int i; - int found; - char **p; - - found = 0; - for (i = 0; !found && i < name->mm_name_num; i++) { - if (strcmp(token, name->mm_name[i]) == 0) { - found = 1; - } - } - if (!found) { - if ((p = (char **)realloc(name->mm_name, - sizeof (char **)*(name->mm_name_num + 1))) == NULL) { - return; - } - name->mm_name = p; - name->mm_name[name->mm_name_num] = strdup(token); - if (name->mm_name[name->mm_name_num] == NULL) { - return; - } - name->mm_name_num++; - } -} - -static int -mm_name_cmp(const void *p1, const void *p2) -{ - char *name_1 = *((char **)p1); - char *name_2 = *((char **)p2); - - return (strcmp(name_1, name_2)); -} - -static char * -mm_get_obj_ptr(char **obj) -{ - char **objname; - - if ((objname = bsearch(obj, mm_obj.mm_name, mm_obj.mm_name_num, - sizeof (char **), mm_name_cmp)) == NULL) { - return (NULL); - } - return (*objname); -} - -static char * -mm_get_att_ptr(char **att) -{ - char **attname; - - if ((attname = bsearch(att, mm_att.mm_name, mm_att.mm_name_num, - sizeof (char **), mm_name_cmp)) == NULL) { - return (NULL); - } - return (*attname); -} - -static int -mm_path_cmp(const void *p1, const void *p2) -{ - mm_path_t *path_1 = *((mm_path_t **)p1); - mm_path_t *path_2 = *((mm_path_t **)p2); - - return (strcmp(path_1->mm_id, path_2->mm_id)); -} - -static int -mm_pkey_cmp(const void *p1, const void *p2) -{ - mm_pkey_t *pkey_1 = *((mm_pkey_t **)p1); - mm_pkey_t *pkey_2 = *((mm_pkey_t **)p2); - - return (strcmp(pkey_1->mm_obj, pkey_2->mm_obj)); -} - -mm_pkey_t * -mm_get_pkey(char *obj) -{ - mm_pkey_t data; - mm_pkey_t *key = &data; - mm_pkey_t **pkey; - - if (obj == NULL) { - return (NULL); - } - - data.mm_obj = obj; - if ((pkey = (mm_pkey_t **)bsearch(&key, mm_pkey_list.mm_pkey, - mm_pkey_list.mm_pkey_num, sizeof (mm_pkey_t **), - mm_pkey_cmp)) == NULL) { - return (NULL); - } - return (*pkey); -} diff --git a/usr/src/cmd/mms/mm/common/mm_path.h b/usr/src/cmd/mms/mm/common/mm_path.h deleted file mode 100644 index d4bd6f2998..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_path.h +++ /dev/null @@ -1,73 +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 _MM_PATH_H -#define _MM_PATH_H - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct mm_pkey mm_pkey_t; -struct mm_pkey { - char *mm_obj; - char **mm_att; - int mm_att_num; -}; - -typedef struct mm_att mm_att_t; -struct mm_att { - char *mm_att; - char *mm_ref_att; -}; - -typedef struct mm_node mm_node_t; -struct mm_node { - char *mm_obj; - mm_pkey_t *mm_pkey; - - mm_att_t **mm_edge; - int mm_edge_num; - - char *mm_ref_obj; -}; - -typedef struct mm_path mm_path_t; -struct mm_path { - char *mm_id; - mm_node_t **mm_node; - int mm_node_num; -}; - -int mm_init_paths(char *fn); -mm_path_t *mm_get_path(char *obj_1, char *obj_2); -void mm_print_path(mm_path_t *path); -mm_pkey_t *mm_get_pkey(char *obj_1); - -#ifdef __cplusplus -} -#endif - -#endif /* _MM_PATH_H */ diff --git a/usr/src/cmd/mms/mm/common/mm_paths.xml b/usr/src/cmd/mms/mm/common/mm_paths.xml deleted file mode 100644 index a86efedb1a..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_paths.xml +++ /dev/null @@ -1,18186 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE mm_paths SYSTEM "/etc/mms/config/mm_paths.dtd"> -<!-- - 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. ---> - -<mm_paths> - <primary_keys> - <object name="APPLICATION"> - <pkey value="ApplicationName"/> - </object> - <object name="AI"> - <pkey value="AIName"/> - <pkey value="ApplicationName"/> - </object> - <object name="LIBRARY"> - <pkey value="LibraryName"/> - </object> - <object name="LIBRARYACCESS"> - <pkey value="LibraryName"/> - </object> - <object name="LM"> - <pkey value="LMName"/> - <pkey value="LibraryName"/> - </object> - <object name="BAY"> - <pkey value="BayName"/> - <pkey value="LMName"/> - <pkey value="LibraryName"/> - </object> - <object name="SLOT"> - <pkey value="SlotName"/> - <pkey value="LibraryName"/> - <pkey value="LMName"/> - <pkey value="BayName"/> - </object> - <object name="SLOTGROUP"> - <pkey value="SlotGroupName"/> - <pkey value="LibraryName"/> - <pkey value="LMName"/> - <pkey value="BayName"/> - </object> - <object name="SLOTCONFIG"> - <pkey value="SlotTypeName"/> - <pkey value="LibraryName"/> - <pkey value="LMName"/> - <pkey value="BayName"/> - </object> - <object name="SLOTTYPE"> - <pkey value="SlotTypeName"/> - <pkey value="CartridgeShapeName"/> - </object> - <object name="DRIVE"> - <pkey value="DriveName"/> - </object> - <object name="DRIVEGROUP"> - <pkey value="DriveGroupName"/> - </object> - <object name="DRIVEGROUPAPPLICATION"> - <pkey value="DriveGroupName"/> - <pkey value="ApplicationName"/> - </object> - <object name="DM"> - <pkey value="DriveName"/> - <pkey value="DMName"/> - </object> - <object name="DMBITFORMAT"> - <pkey value="DMBitFormatName"/> - <pkey value="DriveName"/> - <pkey value="DMName"/> - </object> - <object name="DMBITFORMATTOKEN"> - <pkey value="DMBitFormatName"/> - <pkey value="DriveName"/> - <pkey value="DMName"/> - </object> - <object name="DMCAPABILITY"> - <pkey value="DMCapabilityName"/> - <pkey value="DriveName"/> - <pkey value="DMName"/> - </object> - <object name="DMCAPABILITYTOKEN"> - <pkey value="DriveName"/> - <pkey value="DMName"/> - <pkey value="DMCapabilityName"/> - <pkey value="DMCapabilityToken"/> - </object> - <object name="DMCAPABILITYDEFAULTTOKEN"> - <pkey value="DriveName"/> - <pkey value="DMName"/> - </object> - <object name="DMCAPABILITYGROUP"> - <pkey value="DMCapabilityGroupName"/> - <pkey value="DriveName"/> - <pkey value="DMName"/> - </object> - <object name="DMCAPABILITYGROUPTOKEN"> - <pkey value="DMCapabilityGroupName"/> - <pkey value="DriveName"/> - <pkey value="DMName"/> - <pkey value="DMCapabilityToken"/> - </object> - <object name="CARTRIDGE"> - <pkey value="CartridgeID"/> - </object> - <object name="CARTRIDGEGROUP"> - <pkey value="CartridgeGroupName"/> - </object> - <object name="CARTRIDGEGROUPAPPLICATION"> - <pkey value="CartridgeGroupName"/> - <pkey value="ApplicationName"/> - </object> - <object name="CARTRIDGETYPE"> - <pkey value="CartridgeTypeName"/> - <pkey value="CartridgeShapeName"/> - </object> - <object name="SIDE"> - <pkey value="SideName"/> - <pkey value="CartridgeID"/> - </object> - <object name="PARTITION"> - <pkey value="PartitionName"/> - <pkey value="SideName"/> - <pkey value="CartridgeID"/> - </object> - <object name="VOLUME"> - <pkey value="VolumeName"/> - <pkey value="ApplicationName"/> - </object> - <object name="MOUNTLOGICAL"> - <pkey value="CartridgeID"/> - </object> - <object name="MOUNTPHYSICAL"> - <pkey value="CartridgeID"/> - </object> - <object name="DRIVECARTRIDGEACCESS"> - <pkey value="DriveName"/> - <pkey value="CartridgeID"/> - <pkey value="DriveCartridgeAccessTimeUnmount"/> - </object> - <object name="DRIVECARTRIDGEERROR"> - <pkey value="DriveName"/> - <pkey value="CartridgeID"/> - <pkey value="TimeStamp"/> - </object> - <object name="CONNECTION"> - <pkey value="ConnectionID"/> - </object> - <object name="SESSION"> - <pkey value="SessionID"/> - <pkey value="ConnectionID"/> - </object> - <object name="NOTIFY"> - <pkey value="ConnectionID"/> - </object> - <object name="TASK"> - <pkey value="TaskID"/> - </object> - <object name="TASKCARTRIDGE"> - <pkey value="TaskID"/> - </object> - <object name="TASKDRIVE"> - <pkey value="TaskID"/> - </object> - <object name="TASKLIBRARY"> - <pkey value="TaskID"/> - </object> - <object name="MESSAGE"> - <pkey value="MessageID"/> - </object> - <object name="REQUEST"> - <pkey value="RequestID"/> - </object> - <object name="STALEHANDLE"> - <pkey value="CartridgeID"/> - </object> - <object name="SYSTEM"> - <pkey value="Administrator"/> - </object> - <object name="LIBRARYLIST"> - <pkey value="LibraryString"/> - </object> - <object name="DRIVELIST"> - <pkey value="DriveString"/> - </object> - <object name="CARTRIDGELIST"> - <pkey value="CartridgeString"/> - </object> - </primary_keys> - <paths> - <path from="APPLICATION" to="AI"> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="APPLICATION" to="LIBRARY"> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="APPLICATION" to="LIBRARYACCESS"> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="APPLICATION" to="LM"> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="APPLICATION" to="BAY"> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="APPLICATION" to="SLOT"> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="APPLICATION" to="SLOTGROUP"> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTGROUP"> - <att value="SlotGroupName"/> - </node> - </path> - <path from="APPLICATION" to="SLOTCONFIG"> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="APPLICATION" to="SLOTTYPE"> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="APPLICATION" to="DRIVECARTRIDGEACCESS"> - <node from="APPLICATION" to="DRIVECARTRIDGEACCESS"> - <att value="ApplicationName"/> - </node> - </path> - <path from="APPLICATION" to="DRIVECARTRIDGEERROR"> - <node from="APPLICATION" to="DRIVECARTRIDGEERROR"> - <att value="ApplicationName"/> - </node> - </path> - <path from="APPLICATION" to="DRIVE"> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="APPLICATION" to="DRIVEGROUP"> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="APPLICATION" to="DM"> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="APPLICATION" to="DMBITFORMAT"> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMBITFORMAT"> - <att value="DriveName"/> - </node> - </path> - <path from="APPLICATION" to="DMBITFORMATTOKEN"> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMBITFORMAT"> - <att value="DriveName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="APPLICATION" to="DMCAPABILITY"> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="APPLICATION" to="DMCAPABILITYTOKEN"> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="APPLICATION" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="APPLICATION" to="DMCAPABILITYGROUP"> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - </node> - </path> - <path from="APPLICATION" to="DMCAPABILITYGROUPTOKEN"> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="APPLICATION" to="CARTRIDGE"> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="APPLICATION" to="CARTRIDGEGROUP"> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="APPLICATION" to="CARTRIDGETYPE"> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="APPLICATION" to="SIDE"> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="APPLICATION" to="PARTITION"> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="APPLICATION" to="VOLUME"> - <node from="APPLICATION" to="VOLUME"> - <att value="ApplicationName"/> - </node> - </path> - <path from="APPLICATION" to="MOUNTLOGICAL"> - <node from="APPLICATION" to="MOUNTLOGICAL"> - <att value="ApplicationName"/> - </node> - </path> - <path from="APPLICATION" to="MOUNTPHYSICAL"> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="APPLICATION" to="CONNECTION"> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - </path> - <path from="APPLICATION" to="SESSION"> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="APPLICATION" to="NOTIFY"> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="APPLICATION" to="TASK"> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="APPLICATION" to="TASKCARTRIDGE"> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="APPLICATION" to="TASKDRIVE"> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKDRIVE"> - <att value="TaskID"/> - </node> - </path> - <path from="APPLICATION" to="TASKLIBRARY"> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="APPLICATION" to="REQUEST"> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="AI" to="APPLICATION"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="AI" to="LIBRARY"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="AI" to="LIBRARYACCESS"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="AI" to="LM"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="AI" to="BAY"> - <node from="AI" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="BAY"> - <att value="LibraryName"/> - </node> - </path> - <path from="AI" to="SLOT"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="AI" to="SLOTGROUP"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTGROUP"> - <att value="SlotGroupName"/> - </node> - </path> - <path from="AI" to="SLOTCONFIG"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="AI" to="SLOTTYPE"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="AI" to="DRIVECARTRIDGEACCESS"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVECARTRIDGEACCESS"> - <att value="ApplicationName"/> - </node> - </path> - <path from="AI" to="DRIVECARTRIDGEERROR"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVECARTRIDGEERROR"> - <att value="ApplicationName"/> - </node> - </path> - <path from="AI" to="DRIVE"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="AI" to="DRIVEGROUP"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="AI" to="DRIVEGROUPAPPLICATION"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="AI" to="DM"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="AI" to="DMBITFORMAT"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="AI" to="DMBITFORMATTOKEN"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="AI" to="DMCAPABILITY"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="AI" to="DMCAPABILITYTOKEN"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="AI" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="AI" to="DMCAPABILITYGROUP"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - </node> - </path> - <path from="AI" to="DMCAPABILITYGROUPTOKEN"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="AI" to="CARTRIDGE"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="AI" to="CARTRIDGEGROUP"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="AI" to="CARTRIDGEGROUPAPPLICATION"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="AI" to="CARTRIDGETYPE"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="AI" to="SIDE"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="AI" to="PARTITION"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="AI" to="VOLUME"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="VOLUME"> - <att value="ApplicationName"/> - </node> - </path> - <path from="AI" to="MOUNTLOGICAL"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="MOUNTLOGICAL"> - <att value="ApplicationName"/> - </node> - </path> - <path from="AI" to="MOUNTPHYSICAL"> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="AI" to="CONNECTION"> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - </path> - <path from="AI" to="SESSION"> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="AI" to="NOTIFY"> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="AI" to="TASK"> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="AI" to="TASKCARTRIDGE"> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKCARTRIDGE"> - <att value="TaskID"/> - </node> - </path> - <path from="AI" to="TASKDRIVE"> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKDRIVE"> - <att value="TaskID"/> - </node> - </path> - <path from="AI" to="TASKLIBRARY"> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="AI" to="REQUEST"> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="LIBRARY" to="APPLICATION"> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="LIBRARY" to="AI"> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="LIBRARY" to="LIBRARYACCESS"> - <node from="LIBRARY" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="LIBRARY" to="LM"> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="LIBRARY" to="BAY"> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="LIBRARY" to="SLOT"> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="LIBRARY" to="SLOTGROUP"> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="LIBRARY" to="SLOTCONFIG"> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="LIBRARY" to="SLOTTYPE"> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="LIBRARY" to="DRIVECARTRIDGEACCESS"> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVECARTRIDGEACCESS"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="LIBRARY" to="DRIVECARTRIDGEERROR"> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVECARTRIDGEERROR"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="LIBRARY" to="DRIVE"> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - </path> - <path from="LIBRARY" to="DRIVEGROUP"> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="LIBRARY" to="DRIVEGROUPAPPLICATION"> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="LIBRARY" to="DM"> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="LIBRARY" to="DMBITFORMAT"> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="LIBRARY" to="DMBITFORMATTOKEN"> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="LIBRARY" to="DMCAPABILITY"> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="LIBRARY" to="DMCAPABILITYTOKEN"> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="LIBRARY" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="LIBRARY" to="DMCAPABILITYGROUP"> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="LIBRARY" to="DMCAPABILITYGROUPTOKEN"> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="LIBRARY" to="CARTRIDGE"> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - </path> - <path from="LIBRARY" to="CARTRIDGEGROUP"> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="LIBRARY" to="CARTRIDGEGROUPAPPLICATION"> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="LIBRARY" to="CARTRIDGETYPE"> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="LIBRARY" to="SIDE"> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="LIBRARY" to="PARTITION"> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="LIBRARY" to="VOLUME"> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="LIBRARY" to="MOUNTLOGICAL"> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="MOUNTLOGICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="LIBRARY" to="MOUNTPHYSICAL"> - <node from="LIBRARY" to="MOUNTPHYSICAL"> - <att value="LibraryName"/> - </node> - </path> - <path from="LIBRARY" to="CONNECTION"> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - </path> - <path from="LIBRARY" to="SESSION"> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="LIBRARY" to="NOTIFY"> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="LIBRARY" to="TASK"> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="LIBRARY" to="TASKCARTRIDGE"> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="LIBRARY" to="TASKDRIVE"> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="LIBRARY" to="TASKLIBRARY"> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="LIBRARY" to="REQUEST"> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="LIBRARYACCESS" to="AI"> - <node from="LIBRARYACCESS" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="LIBRARY"> - <node from="LIBRARYACCESS" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="LM"> - <node from="LIBRARYACCESS" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="BAY"> - <node from="LIBRARYACCESS" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="SLOT"> - <node from="LIBRARYACCESS" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="SLOTGROUP"> - <node from="LIBRARYACCESS" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="SLOTCONFIG"> - <node from="LIBRARYACCESS" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="SLOTTYPE"> - <node from="LIBRARYACCESS" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="DRIVECARTRIDGEACCESS"> - <node from="LIBRARYACCESS" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVECARTRIDGEACCESS"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="LIBRARYACCESS" to="DRIVECARTRIDGEERROR"> - <node from="LIBRARYACCESS" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVECARTRIDGEERROR"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="LIBRARYACCESS" to="DRIVE"> - <node from="LIBRARYACCESS" to="DRIVE"> - <att value="LibraryName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="DRIVEGROUP"> - <node from="LIBRARYACCESS" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="DRIVEGROUPAPPLICATION"> - <node from="LIBRARYACCESS" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="DM"> - <node from="LIBRARYACCESS" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="DMBITFORMAT"> - <node from="LIBRARYACCESS" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="DMBITFORMATTOKEN"> - <node from="LIBRARYACCESS" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="DMCAPABILITY"> - <node from="LIBRARYACCESS" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="DMCAPABILITYTOKEN"> - <node from="LIBRARYACCESS" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="LIBRARYACCESS" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="DMCAPABILITYGROUP"> - <node from="LIBRARYACCESS" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="DMCAPABILITYGROUPTOKEN"> - <node from="LIBRARYACCESS" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="CARTRIDGE"> - <node from="LIBRARYACCESS" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="CARTRIDGEGROUP"> - <node from="LIBRARYACCESS" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="CARTRIDGEGROUPAPPLICATION"> - <node from="LIBRARYACCESS" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="CARTRIDGETYPE"> - <node from="LIBRARYACCESS" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="SIDE"> - <node from="LIBRARYACCESS" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="LIBRARYACCESS" to="PARTITION"> - <node from="LIBRARYACCESS" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="LIBRARYACCESS" to="VOLUME"> - <node from="LIBRARYACCESS" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="LIBRARYACCESS" to="MOUNTLOGICAL"> - <node from="LIBRARYACCESS" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="MOUNTLOGICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="MOUNTPHYSICAL"> - <node from="LIBRARYACCESS" to="MOUNTPHYSICAL"> - <att value="LibraryName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="CONNECTION"> - <node from="LIBRARYACCESS" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - </path> - <path from="LIBRARYACCESS" to="SESSION"> - <node from="LIBRARYACCESS" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="LIBRARYACCESS" to="NOTIFY"> - <node from="LIBRARYACCESS" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="LIBRARYACCESS" to="TASK"> - <node from="LIBRARYACCESS" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="LIBRARYACCESS" to="TASKCARTRIDGE"> - <node from="LIBRARYACCESS" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="LIBRARYACCESS" to="TASKDRIVE"> - <node from="LIBRARYACCESS" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="LIBRARYACCESS" to="TASKLIBRARY"> - <node from="LIBRARYACCESS" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="LIBRARYACCESS" to="REQUEST"> - <node from="LIBRARYACCESS" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="LM" to="APPLICATION"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="LM" to="AI"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="LM" to="LIBRARY"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="LM" to="LIBRARYACCESS"> - <node from="LM" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="LM" to="BAY"> - <node from="LM" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="LM" to="SLOT"> - <node from="LM" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="LM" to="SLOTGROUP"> - <node from="LM" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="LM" to="SLOTCONFIG"> - <node from="LM" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="LM" to="SLOTTYPE"> - <node from="LM" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="LM" to="DRIVECARTRIDGEACCESS"> - <node from="LM" to="LIBRARY"> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVECARTRIDGEACCESS"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="LM" to="DRIVECARTRIDGEERROR"> - <node from="LM" to="LIBRARY"> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVECARTRIDGEERROR"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="LM" to="DRIVE"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - </path> - <path from="LM" to="DRIVEGROUP"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="LM" to="DRIVEGROUPAPPLICATION"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="LM" to="DM"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="LM" to="DMBITFORMAT"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMBITFORMAT"> - <att value="DriveName"/> - </node> - </path> - <path from="LM" to="DMBITFORMATTOKEN"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="LM" to="DMCAPABILITY"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="LM" to="DMCAPABILITYTOKEN"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="LM" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="LM" to="DMCAPABILITYGROUP"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - </node> - </path> - <path from="LM" to="DMCAPABILITYGROUPTOKEN"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="LM" to="CARTRIDGE"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - </path> - <path from="LM" to="CARTRIDGEGROUP"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="LM" to="CARTRIDGEGROUPAPPLICATION"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="LM" to="CARTRIDGETYPE"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="LM" to="SIDE"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="LM" to="PARTITION"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="LM" to="VOLUME"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="LM" to="MOUNTLOGICAL"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="MOUNTLOGICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="LM" to="MOUNTPHYSICAL"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="MOUNTPHYSICAL"> - <att value="LibraryName"/> - </node> - </path> - <path from="LM" to="CONNECTION"> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - </path> - <path from="LM" to="SESSION"> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="LM" to="NOTIFY"> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="LM" to="TASK"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="TASKLIBRARY"> - <att value="LibraryName"/> - </node> - <node from="TASKLIBRARY" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="LM" to="TASKCARTRIDGE"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="LM" to="TASKDRIVE"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="LM" to="TASKLIBRARY"> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="TASKLIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="LM" to="REQUEST"> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="BAY" to="APPLICATION"> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="BAY" to="AI"> - <node from="BAY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="BAY" to="LIBRARY"> - <node from="BAY" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="BAY" to="LIBRARYACCESS"> - <node from="BAY" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="BAY" to="LM"> - <node from="BAY" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="BAY" to="SLOT"> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="BAY" to="SLOTGROUP"> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="BAY" to="SLOTCONFIG"> - <node from="BAY" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="BAY" to="SLOTTYPE"> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="BAY" to="DRIVECARTRIDGEACCESS"> - <node from="BAY" to="DRIVE"> - <att value="BayName"/> - </node> - <node from="DRIVE" to="DRIVECARTRIDGEACCESS"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="BAY" to="DRIVECARTRIDGEERROR"> - <node from="BAY" to="DRIVE"> - <att value="BayName"/> - </node> - <node from="DRIVE" to="DRIVECARTRIDGEERROR"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="BAY" to="DRIVE"> - <node from="BAY" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - </path> - <path from="BAY" to="DRIVEGROUP"> - <node from="BAY" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="BAY" to="DRIVEGROUPAPPLICATION"> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="BAY" to="DM"> - <node from="BAY" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - </path> - <path from="BAY" to="DMBITFORMAT"> - <node from="BAY" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="BAY" to="DMBITFORMATTOKEN"> - <node from="BAY" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="BAY" to="DMCAPABILITY"> - <node from="BAY" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="BAY" to="DMCAPABILITYTOKEN"> - <node from="BAY" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="BAY" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="BAY" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="BAY" to="DMCAPABILITYGROUP"> - <node from="BAY" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="BAY" to="DMCAPABILITYGROUPTOKEN"> - <node from="BAY" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="BAY" to="CARTRIDGE"> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="BAY" to="CARTRIDGEGROUP"> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="BAY" to="CARTRIDGEGROUPAPPLICATION"> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="BAY" to="CARTRIDGETYPE"> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - <node from="SLOTTYPE" to="CARTRIDGETYPE"> - <att value="CartridgeShapeName"/> - </node> - </path> - <path from="BAY" to="SIDE"> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="BAY" to="PARTITION"> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="BAY" to="VOLUME"> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="BAY" to="MOUNTLOGICAL"> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="MOUNTLOGICAL"> - <att value="CartridgeID"/> - </node> - </path> - <path from="BAY" to="MOUNTPHYSICAL"> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="MOUNTPHYSICAL"> - <att value="SlotName"/> - </node> - </path> - <path from="BAY" to="CONNECTION"> - <node from="BAY" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - </path> - <path from="BAY" to="SESSION"> - <node from="BAY" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="BAY" to="NOTIFY"> - <node from="BAY" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="BAY" to="TASK"> - <node from="BAY" to="DRIVE"> - <att value="BayName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="BAY" to="TASKCARTRIDGE"> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="BAY" to="TASKDRIVE"> - <node from="BAY" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="BAY" to="TASKLIBRARY"> - <node from="BAY" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="BAY" to="REQUEST"> - <node from="BAY" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="SLOT" to="APPLICATION"> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="SLOT" to="AI"> - <node from="SLOT" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - </path> - <path from="SLOT" to="LIBRARY"> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="SLOT" to="LIBRARYACCESS"> - <node from="SLOT" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="SLOT" to="LM"> - <node from="SLOT" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="SLOT" to="BAY"> - <node from="SLOT" to="BAY"> - <att value="BayName"/> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="SLOT" to="SLOTGROUP"> - <node from="SLOT" to="SLOTGROUP"> - <att value="SlotGroupName"/> - </node> - </path> - <path from="SLOT" to="SLOTCONFIG"> - <node from="SLOT" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="SLOT" to="SLOTTYPE"> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="SLOT" to="DRIVECARTRIDGEACCESS"> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="DRIVECARTRIDGEACCESS"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOT" to="DRIVECARTRIDGEERROR"> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="DRIVECARTRIDGEERROR"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOT" to="DRIVE"> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - </path> - <path from="SLOT" to="DRIVEGROUP"> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="SLOT" to="DRIVEGROUPAPPLICATION"> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="SLOT" to="DM"> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOT" to="DMBITFORMAT"> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - </path> - <path from="SLOT" to="DMBITFORMATTOKEN"> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="SLOT" to="DMCAPABILITY"> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOT" to="DMCAPABILITYTOKEN"> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOT" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOT" to="DMCAPABILITYGROUP"> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="SLOT" to="DMCAPABILITYGROUPTOKEN"> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="SLOT" to="CARTRIDGE"> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="SLOT" to="CARTRIDGEGROUP"> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="SLOT" to="CARTRIDGEGROUPAPPLICATION"> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="SLOT" to="CARTRIDGETYPE"> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - <node from="SLOTTYPE" to="CARTRIDGETYPE"> - <att value="CartridgeShapeName"/> - </node> - </path> - <path from="SLOT" to="SIDE"> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOT" to="PARTITION"> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOT" to="VOLUME"> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOT" to="MOUNTLOGICAL"> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="MOUNTLOGICAL"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOT" to="MOUNTPHYSICAL"> - <node from="SLOT" to="MOUNTPHYSICAL"> - <att value="SlotName"/> - </node> - </path> - <path from="SLOT" to="CONNECTION"> - <node from="SLOT" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - </path> - <path from="SLOT" to="SESSION"> - <node from="SLOT" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="SLOT" to="NOTIFY"> - <node from="SLOT" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="SLOT" to="TASK"> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="SLOT" to="TASKCARTRIDGE"> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOT" to="TASKDRIVE"> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOT" to="TASKLIBRARY"> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="SLOT" to="REQUEST"> - <node from="SLOT" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="SLOTGROUP" to="APPLICATION"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="SLOTGROUP" to="AI"> - <node from="SLOTGROUP" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - </path> - <path from="SLOTGROUP" to="LIBRARY"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="SLOTGROUP" to="LIBRARYACCESS"> - <node from="SLOTGROUP" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="SLOTGROUP" to="LM"> - <node from="SLOTGROUP" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="SLOTGROUP" to="BAY"> - <node from="SLOTGROUP" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="SLOTGROUP" to="SLOT"> - <node from="SLOTGROUP" to="SLOT"> - <att value="SlotGroupName"/> - </node> - </path> - <path from="SLOTGROUP" to="SLOTCONFIG"> - <node from="SLOTGROUP" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="SLOTGROUP" to="SLOTTYPE"> - <node from="SLOTGROUP" to="SLOT"> - <att value="SlotGroupName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="SLOTGROUP" to="DRIVECARTRIDGEACCESS"> - <node from="SLOTGROUP" to="SLOT"> - <att value="SlotGroupName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="DRIVECARTRIDGEACCESS"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOTGROUP" to="DRIVECARTRIDGEERROR"> - <node from="SLOTGROUP" to="SLOT"> - <att value="SlotGroupName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="DRIVECARTRIDGEERROR"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOTGROUP" to="DRIVE"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - </path> - <path from="SLOTGROUP" to="DRIVEGROUP"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="SLOTGROUP" to="DRIVEGROUPAPPLICATION"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="SLOTGROUP" to="DM"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOTGROUP" to="DMBITFORMAT"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="SLOTGROUP" to="DMBITFORMATTOKEN"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="SLOTGROUP" to="DMCAPABILITY"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOTGROUP" to="DMCAPABILITYTOKEN"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOTGROUP" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOTGROUP" to="DMCAPABILITYGROUP"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="SLOTGROUP" to="DMCAPABILITYGROUPTOKEN"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="SLOTGROUP" to="CARTRIDGE"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - </path> - <path from="SLOTGROUP" to="CARTRIDGEGROUP"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="SLOTGROUP" to="CARTRIDGEGROUPAPPLICATION"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="SLOTGROUP" to="CARTRIDGETYPE"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="SLOTGROUP" to="SIDE"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOTGROUP" to="PARTITION"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOTGROUP" to="VOLUME"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOTGROUP" to="MOUNTLOGICAL"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="MOUNTLOGICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOTGROUP" to="MOUNTPHYSICAL"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="MOUNTPHYSICAL"> - <att value="LibraryName"/> - </node> - </path> - <path from="SLOTGROUP" to="CONNECTION"> - <node from="SLOTGROUP" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - </path> - <path from="SLOTGROUP" to="SESSION"> - <node from="SLOTGROUP" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="SLOTGROUP" to="NOTIFY"> - <node from="SLOTGROUP" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="SLOTGROUP" to="TASK"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="SLOTGROUP" to="TASKCARTRIDGE"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOTGROUP" to="TASKDRIVE"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOTGROUP" to="TASKLIBRARY"> - <node from="SLOTGROUP" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="SLOTGROUP" to="REQUEST"> - <node from="SLOTGROUP" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="SLOTCONFIG" to="APPLICATION"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="SLOTCONFIG" to="AI"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - </path> - <path from="SLOTCONFIG" to="LIBRARY"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="SLOTCONFIG" to="LM"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="SLOTCONFIG" to="BAY"> - <node from="SLOTCONFIG" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="SLOTCONFIG" to="SLOT"> - <node from="SLOTCONFIG" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="SLOTCONFIG" to="SLOTGROUP"> - <node from="SLOTCONFIG" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="SLOTCONFIG" to="SLOTTYPE"> - <node from="SLOTCONFIG" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="SLOTCONFIG" to="DRIVECARTRIDGEACCESS"> - <node from="SLOTCONFIG" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="BAY" to="DRIVE"> - <att value="BayName"/> - </node> - <node from="DRIVE" to="DRIVECARTRIDGEACCESS"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="SLOTCONFIG" to="DRIVECARTRIDGEERROR"> - <node from="SLOTCONFIG" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="BAY" to="DRIVE"> - <att value="BayName"/> - </node> - <node from="DRIVE" to="DRIVECARTRIDGEERROR"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="SLOTCONFIG" to="DRIVE"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - </path> - <path from="SLOTCONFIG" to="DRIVEGROUP"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="SLOTCONFIG" to="DRIVEGROUPAPPLICATION"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="SLOTCONFIG" to="DM"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOTCONFIG" to="DMBITFORMAT"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="SLOTCONFIG" to="DMBITFORMATTOKEN"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="SLOTCONFIG" to="DMCAPABILITY"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOTCONFIG" to="DMCAPABILITYTOKEN"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOTCONFIG" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOTCONFIG" to="DMCAPABILITYGROUP"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="SLOTCONFIG" to="DMCAPABILITYGROUPTOKEN"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="SLOTCONFIG" to="CARTRIDGE"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - </path> - <path from="SLOTCONFIG" to="CARTRIDGEGROUP"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="SLOTCONFIG" to="CARTRIDGEGROUPAPPLICATION"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="SLOTCONFIG" to="CARTRIDGETYPE"> - <node from="SLOTCONFIG" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - <node from="SLOTTYPE" to="CARTRIDGETYPE"> - <att value="CartridgeShapeName"/> - </node> - </path> - <path from="SLOTCONFIG" to="SIDE"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOTCONFIG" to="PARTITION"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOTCONFIG" to="VOLUME"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOTCONFIG" to="MOUNTLOGICAL"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="MOUNTLOGICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOTCONFIG" to="MOUNTPHYSICAL"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="MOUNTPHYSICAL"> - <att value="LibraryName"/> - </node> - </path> - <path from="SLOTCONFIG" to="CONNECTION"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - </path> - <path from="SLOTCONFIG" to="SESSION"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="SLOTCONFIG" to="NOTIFY"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="SLOTCONFIG" to="TASK"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="SLOTCONFIG" to="TASKCARTRIDGE"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOTCONFIG" to="TASKDRIVE"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOTCONFIG" to="TASKLIBRARY"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="SLOTCONFIG" to="REQUEST"> - <node from="SLOTCONFIG" to="LIBRARY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="SLOTTYPE" to="APPLICATION"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="SLOTTYPE" to="AI"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - </path> - <path from="SLOTTYPE" to="LIBRARY"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="SLOTTYPE" to="LIBRARYACCESS"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="SLOTTYPE" to="LM"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="SLOTTYPE" to="BAY"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="BAY"> - <att value="BayName"/> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="SLOTTYPE" to="SLOT"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="SLOTTYPE" to="SLOTGROUP"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="SLOTGROUP"> - <att value="SlotGroupName"/> - </node> - </path> - <path from="SLOTTYPE" to="SLOTCONFIG"> - <node from="SLOTTYPE" to="SLOTCONFIG"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="SLOTTYPE" to="DRIVECARTRIDGEACCESS"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="DRIVECARTRIDGEACCESS"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOTTYPE" to="DRIVECARTRIDGEERROR"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="DRIVECARTRIDGEERROR"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOTTYPE" to="DRIVE"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - </path> - <path from="SLOTTYPE" to="DRIVEGROUP"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="SLOTTYPE" to="DRIVEGROUPAPPLICATION"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="SLOTTYPE" to="DM"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOTTYPE" to="DMBITFORMAT"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - </path> - <path from="SLOTTYPE" to="DMBITFORMATTOKEN"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="SLOTTYPE" to="DMCAPABILITY"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOTTYPE" to="DMCAPABILITYTOKEN"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOTTYPE" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOTTYPE" to="DMCAPABILITYGROUP"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="SLOTTYPE" to="DMCAPABILITYGROUPTOKEN"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="SLOTTYPE" to="CARTRIDGE"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="SLOTTYPE" to="CARTRIDGEGROUP"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="SLOTTYPE" to="CARTRIDGEGROUPAPPLICATION"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="SLOTTYPE" to="CARTRIDGETYPE"> - <node from="SLOTTYPE" to="CARTRIDGETYPE"> - <att value="CartridgeShapeName"/> - </node> - </path> - <path from="SLOTTYPE" to="SIDE"> - <node from="SLOTTYPE" to="CARTRIDGETYPE"> - <att value="CartridgeShapeName"/> - </node> - <node from="CARTRIDGETYPE" to="SIDE"> - <att value="Side1Name"/> - </node> - </path> - <path from="SLOTTYPE" to="PARTITION"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOTTYPE" to="VOLUME"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOTTYPE" to="MOUNTLOGICAL"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="MOUNTLOGICAL"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOTTYPE" to="MOUNTPHYSICAL"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="MOUNTPHYSICAL"> - <att value="SlotName"/> - </node> - </path> - <path from="SLOTTYPE" to="CONNECTION"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - </path> - <path from="SLOTTYPE" to="SESSION"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="SLOTTYPE" to="NOTIFY"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="SLOTTYPE" to="TASK"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="SLOTTYPE" to="TASKCARTRIDGE"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SLOTTYPE" to="TASKDRIVE"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="SLOTTYPE" to="TASKLIBRARY"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="SLOTTYPE" to="REQUEST"> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="DRIVE" to="APPLICATION"> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVE" to="AI"> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - </path> - <path from="DRIVE" to="LIBRARY"> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="DRIVE" to="LIBRARYACCESS"> - <node from="DRIVE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="DRIVE" to="LM"> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="DRIVE" to="BAY"> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="DRIVE" to="SLOT"> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DRIVE" to="SLOTGROUP"> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="DRIVE" to="SLOTCONFIG"> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DRIVE" to="SLOTTYPE"> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="DRIVE" to="DRIVEGROUP"> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DRIVE" to="DRIVEGROUPAPPLICATION"> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DRIVE" to="DM"> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVE" to="DMBITFORMAT"> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="DRIVE" to="DMBITFORMATTOKEN"> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="DRIVE" to="DMCAPABILITY"> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVE" to="DMCAPABILITYTOKEN"> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVE" to="DMCAPABILITYGROUP"> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="DRIVE" to="DMCAPABILITYGROUPTOKEN"> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="DRIVE" to="CARTRIDGE"> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - </path> - <path from="DRIVE" to="CARTRIDGEGROUP"> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DRIVE" to="CARTRIDGEGROUPAPPLICATION"> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DRIVE" to="CARTRIDGETYPE"> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="DRIVE" to="SIDE"> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DRIVE" to="PARTITION"> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DRIVE" to="VOLUME"> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DRIVE" to="MOUNTLOGICAL"> - <node from="DRIVE" to="MOUNTLOGICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVE" to="MOUNTPHYSICAL"> - <node from="DRIVE" to="MOUNTPHYSICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVE" to="CONNECTION"> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - </path> - <path from="DRIVE" to="SESSION"> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DRIVE" to="NOTIFY"> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DRIVE" to="TASK"> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="DRIVE" to="TASKCARTRIDGE"> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DRIVE" to="TASKDRIVE"> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVE" to="TASKLIBRARY"> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="DRIVE" to="REQUEST"> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - </path> - <path from="DRIVE" to="DRIVECARTRIDGEERROR"> - <node from="DRIVE" to="DRIVECARTRIDGEERROR"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="DRIVEGROUP" to="APPLICATION"> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVEGROUP" to="AI"> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVEGROUP" to="LIBRARY"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="DRIVEGROUP" to="LIBRARYACCESS"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="DRIVEGROUP" to="LM"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="DRIVEGROUP" to="BAY"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="DRIVEGROUP" to="SLOT"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DRIVEGROUP" to="SLOTGROUP"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="DRIVEGROUP" to="SLOTCONFIG"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DRIVEGROUP" to="SLOTTYPE"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="DRIVEGROUP" to="DRIVECARTRIDGEACCESS"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DRIVECARTRIDGEACCESS"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="DRIVEGROUP" to="DRIVECARTRIDGEERROR"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DRIVECARTRIDGEERROR"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="DRIVEGROUP" to="DRIVE"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DRIVEGROUP" to="DM"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVEGROUP" to="DMBITFORMAT"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="DRIVEGROUP" to="DMBITFORMATTOKEN"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="DRIVEGROUP" to="DMCAPABILITY"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVEGROUP" to="DMCAPABILITYTOKEN"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVEGROUP" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVEGROUP" to="DMCAPABILITYGROUP"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="DRIVEGROUP" to="DMCAPABILITYGROUPTOKEN"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="DRIVEGROUP" to="CARTRIDGE"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - </path> - <path from="DRIVEGROUP" to="CARTRIDGEGROUP"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DRIVEGROUP" to="CARTRIDGEGROUPAPPLICATION"> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVEGROUP" to="CARTRIDGETYPE"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="DRIVEGROUP" to="SIDE"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DRIVEGROUP" to="PARTITION"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DRIVEGROUP" to="VOLUME"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DRIVEGROUP" to="MOUNTLOGICAL"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="MOUNTLOGICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVEGROUP" to="MOUNTPHYSICAL"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="MOUNTPHYSICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVEGROUP" to="CONNECTION"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - </path> - <path from="DRIVEGROUP" to="SESSION"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DRIVEGROUP" to="NOTIFY"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DRIVEGROUP" to="TASK"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="DRIVEGROUP" to="TASKCARTRIDGE"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DRIVEGROUP" to="TASKDRIVE"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVEGROUP" to="TASKLIBRARY"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="DRIVEGROUP" to="REQUEST"> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="AI"> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="LIBRARY"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="LIBRARYACCESS"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="LM"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="BAY"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="SLOT"> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="SLOTGROUP"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="SLOTCONFIG"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="SLOTTYPE"> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="DRIVECARTRIDGEACCESS"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DRIVECARTRIDGEACCESS"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="DRIVECARTRIDGEERROR"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DRIVECARTRIDGEERROR"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="DRIVEGROUP"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="DM"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="DMBITFORMAT"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="DMBITFORMATTOKEN"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="DMCAPABILITY"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="DMCAPABILITYTOKEN"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="DMCAPABILITYGROUP"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="DMCAPABILITYGROUPTOKEN"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="CARTRIDGE"> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="CARTRIDGEGROUP"> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="CARTRIDGETYPE"> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="SIDE"> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="PARTITION"> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="VOLUME"> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="VOLUME"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="MOUNTLOGICAL"> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="MOUNTLOGICAL"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="MOUNTPHYSICAL"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="MOUNTPHYSICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="CONNECTION"> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="SESSION"> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="NOTIFY"> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="TASK"> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="TASKCARTRIDGE"> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="TASKDRIVE"> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="TASKLIBRARY"> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="DRIVEGROUPAPPLICATION" to="REQUEST"> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="DM" to="APPLICATION"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DM" to="AI"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DM" to="LIBRARY"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="DM" to="LIBRARYACCESS"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="DM" to="LM"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LMName"/> - <att value="LibraryName"/> - </node> - </path> - <path from="DM" to="BAY"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="DM" to="SLOT"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DM" to="SLOTGROUP"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="DM" to="SLOTCONFIG"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DM" to="SLOTTYPE"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="DM" to="DRIVECARTRIDGEACCESS"> - <node from="DM" to="DRIVECARTRIDGEACCESS"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DM" to="DRIVECARTRIDGEERROR"> - <node from="DM" to="DRIVECARTRIDGEERROR"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DM" to="DRIVE"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DM" to="DRIVEGROUP"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DM" to="DRIVEGROUPAPPLICATION"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DM" to="DMBITFORMAT"> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="DM" to="DMBITFORMATTOKEN"> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="DM" to="DMCAPABILITY"> - <node from="DM" to="DMCAPABILITY"> - <att value="DMName"/> - </node> - </path> - <path from="DM" to="DMCAPABILITYTOKEN"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="DM" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="DM" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="DM" to="DMCAPABILITYGROUP"> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="DM" to="DMCAPABILITYGROUPTOKEN"> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="DM" to="CARTRIDGE"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - </path> - <path from="DM" to="CARTRIDGEGROUP"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DM" to="CARTRIDGEGROUPAPPLICATION"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DM" to="CARTRIDGETYPE"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="DM" to="SIDE"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DM" to="PARTITION"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DM" to="VOLUME"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DM" to="MOUNTLOGICAL"> - <node from="DM" to="MOUNTLOGICAL"> - <att value="DMName"/> - </node> - </path> - <path from="DM" to="MOUNTPHYSICAL"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="MOUNTPHYSICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="DM" to="CONNECTION"> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - </path> - <path from="DM" to="SESSION"> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DM" to="NOTIFY"> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DM" to="TASK"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="DM" to="TASKCARTRIDGE"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DM" to="TASKDRIVE"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DM" to="TASKLIBRARY"> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="DM" to="REQUEST"> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="DMBITFORMAT" to="APPLICATION"> - <node from="DMBITFORMAT" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DMBITFORMAT" to="AI"> - <node from="DMBITFORMAT" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DMBITFORMAT" to="LIBRARY"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMBITFORMAT" to="LIBRARYACCESS"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMBITFORMAT" to="LM"> - <node from="DMBITFORMAT" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMBITFORMAT" to="BAY"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="DMBITFORMAT" to="SLOT"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DMBITFORMAT" to="SLOTGROUP"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="DMBITFORMAT" to="SLOTCONFIG"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DMBITFORMAT" to="SLOTTYPE"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="DMBITFORMAT" to="DRIVECARTRIDGEACCESS"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVECARTRIDGEACCESS"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DMBITFORMAT" to="DRIVECARTRIDGEERROR"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVECARTRIDGEERROR"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DMBITFORMAT" to="DRIVE"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DMBITFORMAT" to="DRIVEGROUP"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DMBITFORMAT" to="DRIVEGROUPAPPLICATION"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DMBITFORMAT" to="DM"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - </path> - <path from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="DMBITFORMAT" to="DMCAPABILITY"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITY"> - <att value="DMName"/> - </node> - </path> - <path from="DMBITFORMAT" to="DMCAPABILITYTOKEN"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="DMBITFORMAT" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="DMBITFORMAT" to="DMCAPABILITYGROUP"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="DMBITFORMAT" to="DMCAPABILITYGROUPTOKEN"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="DMBITFORMAT" to="CARTRIDGE"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMBITFORMAT" to="CARTRIDGEGROUP"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DMBITFORMAT" to="CARTRIDGEGROUPAPPLICATION"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DMBITFORMAT" to="CARTRIDGETYPE"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="DMBITFORMAT" to="SIDE"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMBITFORMAT" to="PARTITION"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMBITFORMAT" to="VOLUME"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMBITFORMAT" to="MOUNTLOGICAL"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="MOUNTLOGICAL"> - <att value="DMName"/> - </node> - </path> - <path from="DMBITFORMAT" to="MOUNTPHYSICAL"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="MOUNTPHYSICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="DMBITFORMAT" to="CONNECTION"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - </path> - <path from="DMBITFORMAT" to="SESSION"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DMBITFORMAT" to="NOTIFY"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DMBITFORMAT" to="TASK"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="DMBITFORMAT" to="TASKCARTRIDGE"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMBITFORMAT" to="TASKDRIVE"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DMBITFORMAT" to="TASKLIBRARY"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="DMBITFORMAT" to="REQUEST"> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="APPLICATION"> - <node from="DMBITFORMATTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="AI"> - <node from="DMBITFORMATTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="LIBRARY"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="LIBRARYACCESS"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="LM"> - <node from="DMBITFORMATTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="BAY"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="SLOT"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="SLOTGROUP"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="SLOTCONFIG"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="SLOTTYPE"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="DRIVECARTRIDGEACCESS"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVECARTRIDGEACCESS"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="DRIVECARTRIDGEERROR"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVECARTRIDGEERROR"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="DRIVE"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="DRIVEGROUP"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="DRIVEGROUPAPPLICATION"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="DM"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="DMCAPABILITY"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITY"> - <att value="DMName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="DMCAPABILITYTOKEN"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="DMCAPABILITYGROUP"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="DMCAPABILITYGROUPTOKEN"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="CARTRIDGE"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="CARTRIDGEGROUP"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="CARTRIDGEGROUPAPPLICATION"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="CARTRIDGETYPE"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="SIDE"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="PARTITION"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="VOLUME"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="MOUNTLOGICAL"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="MOUNTLOGICAL"> - <att value="DMName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="MOUNTPHYSICAL"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="MOUNTPHYSICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="CONNECTION"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="SESSION"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="NOTIFY"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="TASK"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="TASKCARTRIDGE"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="TASKDRIVE"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="TASKLIBRARY"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="DMBITFORMATTOKEN" to="REQUEST"> - <node from="DMBITFORMATTOKEN" to="DMBITFORMAT"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="DMCAPABILITY" to="APPLICATION"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DMCAPABILITY" to="AI"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DMCAPABILITY" to="LIBRARY"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITY" to="LIBRARYACCESS"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITY" to="LM"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITY" to="BAY"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITY" to="SLOT"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITY" to="SLOTGROUP"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITY" to="SLOTCONFIG"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITY" to="SLOTTYPE"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="DMCAPABILITY" to="DRIVECARTRIDGEACCESS"> - <node from="DMCAPABILITY" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVECARTRIDGEACCESS"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITY" to="DRIVECARTRIDGEERROR"> - <node from="DMCAPABILITY" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVECARTRIDGEERROR"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITY" to="DRIVE"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITY" to="DRIVEGROUP"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DMCAPABILITY" to="DRIVEGROUPAPPLICATION"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DMCAPABILITY" to="DM"> - <node from="DMCAPABILITY" to="DM"> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITY" to="DMBITFORMAT"> - <node from="DMCAPABILITY" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITY" to="DMBITFORMATTOKEN"> - <node from="DMCAPABILITY" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="DMCAPABILITY" to="DMCAPABILITYTOKEN"> - <node from="DMCAPABILITY" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityName"/> - </node> - </path> - <path from="DMCAPABILITY" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITY" to="DMCAPABILITYGROUP"> - <node from="DMCAPABILITY" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITY" to="DMCAPABILITYGROUPTOKEN"> - <node from="DMCAPABILITY" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="DMCAPABILITY" to="CARTRIDGE"> - <node from="DMCAPABILITY" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITY" to="CARTRIDGEGROUP"> - <node from="DMCAPABILITY" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DMCAPABILITY" to="CARTRIDGEGROUPAPPLICATION"> - <node from="DMCAPABILITY" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DMCAPABILITY" to="CARTRIDGETYPE"> - <node from="DMCAPABILITY" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="DMCAPABILITY" to="SIDE"> - <node from="DMCAPABILITY" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITY" to="PARTITION"> - <node from="DMCAPABILITY" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITY" to="VOLUME"> - <node from="DMCAPABILITY" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITY" to="MOUNTLOGICAL"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="MOUNTLOGICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITY" to="MOUNTPHYSICAL"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="MOUNTPHYSICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITY" to="CONNECTION"> - <node from="DMCAPABILITY" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - </path> - <path from="DMCAPABILITY" to="SESSION"> - <node from="DMCAPABILITY" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DMCAPABILITY" to="NOTIFY"> - <node from="DMCAPABILITY" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DMCAPABILITY" to="TASK"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="DMCAPABILITY" to="TASKCARTRIDGE"> - <node from="DMCAPABILITY" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITY" to="TASKDRIVE"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITY" to="TASKLIBRARY"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="DMCAPABILITY" to="REQUEST"> - <node from="DMCAPABILITY" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="APPLICATION"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="AI"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="LIBRARY"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="LIBRARYACCESS"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="LM"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="BAY"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="SLOT"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="SLOTGROUP"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="SLOTCONFIG"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="SLOTTYPE"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="DRIVECARTRIDGEACCESS"> - <node from="DMCAPABILITYTOKEN" to="DRIVECARTRIDGEACCESS"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="DRIVECARTRIDGEERROR"> - <node from="DMCAPABILITYTOKEN" to="DRIVECARTRIDGEERROR"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="DRIVE"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="DRIVEGROUP"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="DRIVEGROUPAPPLICATION"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="DM"> - <node from="DMCAPABILITYTOKEN" to="DM"> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="DMBITFORMAT"> - <node from="DMCAPABILITYTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="DMBITFORMATTOKEN"> - <node from="DMCAPABILITYTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="DMCAPABILITY"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="DMCAPABILITYGROUP"> - <node from="DMCAPABILITYTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="DMCAPABILITYGROUPTOKEN"> - <node from="DMCAPABILITYTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="CARTRIDGE"> - <node from="DMCAPABILITYTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="CARTRIDGEGROUP"> - <node from="DMCAPABILITYTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="CARTRIDGEGROUPAPPLICATION"> - <node from="DMCAPABILITYTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="CARTRIDGETYPE"> - <node from="DMCAPABILITYTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="SIDE"> - <node from="DMCAPABILITYTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="PARTITION"> - <node from="DMCAPABILITYTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="VOLUME"> - <node from="DMCAPABILITYTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="MOUNTLOGICAL"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="MOUNTLOGICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="MOUNTPHYSICAL"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="MOUNTPHYSICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="CONNECTION"> - <node from="DMCAPABILITYTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="SESSION"> - <node from="DMCAPABILITYTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="NOTIFY"> - <node from="DMCAPABILITYTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="TASK"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="TASKCARTRIDGE"> - <node from="DMCAPABILITYTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="TASKDRIVE"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="TASKLIBRARY"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="DMCAPABILITYTOKEN" to="REQUEST"> - <node from="DMCAPABILITYTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="APPLICATION"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="AI"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="LIBRARY"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="LIBRARYACCESS"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="LM"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="BAY"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="SLOT"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="SLOTGROUP"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="SLOTCONFIG"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="SLOTTYPE"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="DRIVECARTRIDGEACCESS"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVECARTRIDGEACCESS"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="DRIVECARTRIDGEERROR"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVECARTRIDGEERROR"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="DRIVEGROUP"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="DRIVEGROUPAPPLICATION"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="DM"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DM"> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="DMBITFORMAT"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="DMBITFORMATTOKEN"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="DMCAPABILITY"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="DMCAPABILITYTOKEN"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="DMCAPABILITYGROUP"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="DMCAPABILITYGROUPTOKEN"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="CARTRIDGE"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="CARTRIDGEGROUP"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="CARTRIDGEGROUPAPPLICATION"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="CARTRIDGETYPE"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="SIDE"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="PARTITION"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="VOLUME"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="MOUNTLOGICAL"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="MOUNTLOGICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="MOUNTPHYSICAL"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="MOUNTPHYSICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="CONNECTION"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="SESSION"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="NOTIFY"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="TASK"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="TASKCARTRIDGE"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="TASKDRIVE"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="TASKLIBRARY"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="DMCAPABILITYDEFAULTTOKEN" to="REQUEST"> - <node from="DMCAPABILITYDEFAULTTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="APPLICATION"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="AI"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="LIBRARY"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="LIBRARYACCESS"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="LM"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="BAY"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="SLOT"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="SLOTGROUP"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="SLOTCONFIG"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="SLOTTYPE"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="DRIVECARTRIDGEACCESS"> - <node from="DMCAPABILITYGROUP" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVECARTRIDGEACCESS"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="DRIVECARTRIDGEERROR"> - <node from="DMCAPABILITYGROUP" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVECARTRIDGEERROR"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="DRIVE"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="DRIVEGROUP"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="DRIVEGROUPAPPLICATION"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="DM"> - <node from="DMCAPABILITYGROUP" to="DM"> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="DMBITFORMAT"> - <node from="DMCAPABILITYGROUP" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="DMBITFORMATTOKEN"> - <node from="DMCAPABILITYGROUP" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="DMCAPABILITY"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="DMCAPABILITYTOKEN"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="CARTRIDGE"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="CARTRIDGEGROUP"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="CARTRIDGEGROUPAPPLICATION"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="CARTRIDGETYPE"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="SIDE"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="PARTITION"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="VOLUME"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="MOUNTLOGICAL"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="MOUNTLOGICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="MOUNTPHYSICAL"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="MOUNTPHYSICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="CONNECTION"> - <node from="DMCAPABILITYGROUP" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="SESSION"> - <node from="DMCAPABILITYGROUP" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="NOTIFY"> - <node from="DMCAPABILITYGROUP" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="TASK"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="TASKCARTRIDGE"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="TASKDRIVE"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="TASKLIBRARY"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="DMCAPABILITYGROUP" to="REQUEST"> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="APPLICATION"> - <node from="DMCAPABILITYGROUPTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="AI"> - <node from="DMCAPABILITYGROUPTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="LIBRARY"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="LIBRARYACCESS"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="LM"> - <node from="DMCAPABILITYGROUPTOKEN" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="BAY"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="SLOT"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="SLOTGROUP"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="SLOTCONFIG"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="SLOTTYPE"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="DRIVECARTRIDGEACCESS"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVECARTRIDGEACCESS"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="DRIVECARTRIDGEERROR"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVECARTRIDGEERROR"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="DRIVE"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="DRIVEGROUP"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="DRIVEGROUPAPPLICATION"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="DM"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DM"> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="DMBITFORMAT"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="DMBITFORMATTOKEN"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITY"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYTOKEN"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="CARTRIDGE"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="CARTRIDGEGROUP"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="CARTRIDGEGROUPAPPLICATION"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="CARTRIDGETYPE"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="SIDE"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="PARTITION"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="VOLUME"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="MOUNTLOGICAL"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="MOUNTLOGICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="MOUNTPHYSICAL"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="MOUNTPHYSICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="CONNECTION"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="SESSION"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="NOTIFY"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="TASK"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="TASKCARTRIDGE"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="TASKDRIVE"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="TASKLIBRARY"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="DMCAPABILITYGROUPTOKEN" to="REQUEST"> - <node from="DMCAPABILITYGROUPTOKEN" to="DMCAPABILITYGROUP"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - </path> - <path from="CARTRIDGE" to="APPLICATION"> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="CARTRIDGE" to="AI"> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="CARTRIDGE" to="LIBRARY"> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="CARTRIDGE" to="LIBRARYACCESS"> - <node from="CARTRIDGE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="CARTRIDGE" to="LM"> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="CARTRIDGE" to="BAY"> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="BAY"> - <att value="BayName"/> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="CARTRIDGE" to="SLOT"> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="CARTRIDGE" to="SLOTGROUP"> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTGROUP"> - <att value="SlotGroupName"/> - </node> - </path> - <path from="CARTRIDGE" to="SLOTCONFIG"> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="CARTRIDGE" to="SLOTTYPE"> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="CARTRIDGE" to="DRIVECARTRIDGEACCESS"> - <node from="CARTRIDGE" to="DRIVECARTRIDGEACCESS"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGE" to="DRIVECARTRIDGEERROR"> - <node from="CARTRIDGE" to="DRIVECARTRIDGEERROR"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGE" to="DRIVE"> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - </path> - <path from="CARTRIDGE" to="DRIVEGROUP"> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="CARTRIDGE" to="DRIVEGROUPAPPLICATION"> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="CARTRIDGE" to="DM"> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="CARTRIDGE" to="DMBITFORMAT"> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - </path> - <path from="CARTRIDGE" to="DMBITFORMATTOKEN"> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="CARTRIDGE" to="DMCAPABILITY"> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITY"> - <att value="DMName"/> - </node> - </path> - <path from="CARTRIDGE" to="DMCAPABILITYTOKEN"> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="CARTRIDGE" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="CARTRIDGE" to="DMCAPABILITYGROUP"> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="CARTRIDGE" to="DMCAPABILITYGROUPTOKEN"> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="CARTRIDGE" to="CARTRIDGEGROUP"> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="CARTRIDGE" to="CARTRIDGETYPE"> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="CARTRIDGE" to="SIDE"> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGE" to="PARTITION"> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGE" to="VOLUME"> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGE" to="MOUNTLOGICAL"> - <node from="CARTRIDGE" to="MOUNTLOGICAL"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGE" to="MOUNTPHYSICAL"> - <node from="CARTRIDGE" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="CARTRIDGE" to="CONNECTION"> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - </path> - <path from="CARTRIDGE" to="SESSION"> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="CARTRIDGE" to="NOTIFY"> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="CARTRIDGE" to="TASK"> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="CARTRIDGE" to="TASKCARTRIDGE"> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGE" to="TASKDRIVE"> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="CARTRIDGE" to="TASKLIBRARY"> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="CARTRIDGE" to="REQUEST"> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="APPLICATION"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="AI"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="LIBRARY"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="LIBRARYACCESS"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="LM"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="BAY"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="BAY"> - <att value="BayName"/> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="SLOT"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="SLOTGROUP"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTGROUP"> - <att value="SlotGroupName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="SLOTCONFIG"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="SLOTTYPE"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="DRIVECARTRIDGEACCESS"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="DRIVECARTRIDGEACCESS"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="DRIVECARTRIDGEERROR"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="DRIVECARTRIDGEERROR"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="DRIVE"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="DRIVEGROUP"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="DRIVEGROUPAPPLICATION"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="DM"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="DMBITFORMAT"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="DMBITFORMATTOKEN"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="DMCAPABILITY"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITY"> - <att value="DMName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="DMCAPABILITYTOKEN"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="DMCAPABILITYGROUP"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="DMCAPABILITYGROUPTOKEN"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="CARTRIDGE"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="CARTRIDGEGROUPAPPLICATION"> - <node from="CARTRIDGEGROUP" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="CARTRIDGETYPE"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="SIDE"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="PARTITION"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="VOLUME"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="MOUNTLOGICAL"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="MOUNTLOGICAL"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="MOUNTPHYSICAL"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="CONNECTION"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="SESSION"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="NOTIFY"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="TASK"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="TASKCARTRIDGE"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="TASKDRIVE"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="TASKLIBRARY"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="CARTRIDGEGROUP" to="REQUEST"> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="AI"> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="LIBRARY"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="LIBRARYACCESS"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="LM"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="BAY"> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="SLOT"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="SLOTGROUP"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTGROUP"> - <att value="SlotGroupName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="SLOTCONFIG"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="SLOTTYPE"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="DRIVECARTRIDGEACCESS"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="DRIVECARTRIDGEACCESS"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="DRIVECARTRIDGEERROR"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="DRIVECARTRIDGEERROR"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="DRIVE"> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="DRIVEGROUP"> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="DRIVEGROUPAPPLICATION"> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="DM"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="DMBITFORMAT"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="DMBITFORMATTOKEN"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="DMCAPABILITY"> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="MOUNTLOGICAL"> - <att value="ApplicationName"/> - </node> - <node from="MOUNTLOGICAL" to="DMCAPABILITY"> - <att value="DMCapabilityName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="DMCAPABILITYTOKEN"> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="DMCAPABILITYGROUP"> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="MOUNTLOGICAL"> - <att value="ApplicationName"/> - </node> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="DMCAPABILITYGROUPTOKEN"> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="MOUNTLOGICAL"> - <att value="ApplicationName"/> - </node> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGEGROUP"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGETYPE"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="SIDE"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="PARTITION"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="VOLUME"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUP" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="MOUNTLOGICAL"> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="MOUNTLOGICAL"> - <att value="ApplicationName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="MOUNTPHYSICAL"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="CONNECTION"> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="SESSION"> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="NOTIFY"> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="TASK"> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="TASKCARTRIDGE"> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="TASKDRIVE"> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKDRIVE"> - <att value="TaskID"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="TASKLIBRARY"> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="CARTRIDGEGROUPAPPLICATION" to="REQUEST"> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="APPLICATION"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="AI"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="LIBRARY"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="LIBRARYACCESS"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="LM"> - <node from="CARTRIDGETYPE" to="SLOTTYPE"> - <att value="CartridgeShapeName"/> - </node> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="BAY"> - <node from="CARTRIDGETYPE" to="SLOTTYPE"> - <att value="CartridgeShapeName"/> - </node> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="BAY"> - <att value="BayName"/> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="SLOT"> - <node from="CARTRIDGETYPE" to="SLOTTYPE"> - <att value="CartridgeShapeName"/> - </node> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="SLOTGROUP"> - <node from="CARTRIDGETYPE" to="SLOTTYPE"> - <att value="CartridgeShapeName"/> - </node> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="SLOTGROUP"> - <att value="SlotGroupName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="SLOTCONFIG"> - <node from="CARTRIDGETYPE" to="SLOTTYPE"> - <att value="CartridgeShapeName"/> - </node> - <node from="SLOTTYPE" to="SLOTCONFIG"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="SLOTTYPE"> - <node from="CARTRIDGETYPE" to="SLOTTYPE"> - <att value="CartridgeShapeName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="DRIVECARTRIDGEACCESS"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="DRIVECARTRIDGEACCESS"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="DRIVECARTRIDGEERROR"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="DRIVECARTRIDGEERROR"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="DRIVE"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="DRIVEGROUP"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="DRIVEGROUPAPPLICATION"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="DM"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="DMBITFORMAT"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="DMBITFORMATTOKEN"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="DMCAPABILITY"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITY"> - <att value="DMName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="DMCAPABILITYTOKEN"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="DMCAPABILITYGROUP"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="DMCAPABILITYGROUPTOKEN"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="CARTRIDGE"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="CARTRIDGEGROUP"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="CARTRIDGEGROUPAPPLICATION"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="SIDE"> - <node from="CARTRIDGETYPE" to="SIDE"> - <att value="Side1Name"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="PARTITION"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="VOLUME"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="MOUNTLOGICAL"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="MOUNTLOGICAL"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="MOUNTPHYSICAL"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="CONNECTION"> - <node from="CARTRIDGETYPE" to="SLOTTYPE"> - <att value="CartridgeShapeName"/> - </node> - <node from="SLOTTYPE" to="SLOT"> - <att value="SlotTypeName"/> - </node> - <node from="SLOT" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="SESSION"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="NOTIFY"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="TASK"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="TASKCARTRIDGE"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="TASKDRIVE"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="TASKLIBRARY"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="CARTRIDGETYPE" to="REQUEST"> - <node from="CARTRIDGETYPE" to="CARTRIDGE"> - <att value="CartridgeTypeName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - </path> - <path from="SIDE" to="APPLICATION"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="SIDE" to="AI"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="SIDE" to="LIBRARY"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="SIDE" to="LIBRARYACCESS"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="SIDE" to="LM"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="SIDE" to="BAY"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="BAY"> - <att value="BayName"/> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="SIDE" to="SLOT"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="SIDE" to="SLOTGROUP"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTGROUP"> - <att value="SlotGroupName"/> - </node> - </path> - <path from="SIDE" to="SLOTCONFIG"> - <node from="SIDE" to="CARTRIDGETYPE"> - <att value="Side1Name"/> - </node> - <node from="CARTRIDGETYPE" to="SLOTTYPE"> - <att value="CartridgeShapeName"/> - </node> - <node from="SLOTTYPE" to="SLOTCONFIG"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="SIDE" to="SLOTTYPE"> - <node from="SIDE" to="CARTRIDGETYPE"> - <att value="Side1Name"/> - </node> - <node from="CARTRIDGETYPE" to="SLOTTYPE"> - <att value="CartridgeShapeName"/> - </node> - </path> - <path from="SIDE" to="DRIVECARTRIDGEACCESS"> - <node from="SIDE" to="PARTITION"> - <att value="SideName"/> - </node> - <node from="PARTITION" to="DRIVECARTRIDGEACCESS"> - <att value="CartridgeID"/> - <att value="SideName"/> - <att value="PartitionName"/> - </node> - </path> - <path from="SIDE" to="DRIVECARTRIDGEERROR"> - <node from="SIDE" to="PARTITION"> - <att value="SideName"/> - </node> - <node from="PARTITION" to="DRIVECARTRIDGEERROR"> - <att value="CartridgeID"/> - <att value="SideName"/> - <att value="PartitionName"/> - </node> - </path> - <path from="SIDE" to="DRIVE"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - </path> - <path from="SIDE" to="DRIVEGROUP"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="SIDE" to="DRIVEGROUPAPPLICATION"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="SIDE" to="DM"> - <node from="SIDE" to="MOUNTLOGICAL"> - <att value="SideName"/> - </node> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="SIDE" to="DMBITFORMAT"> - <node from="SIDE" to="PARTITION"> - <att value="SideName"/> - </node> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - </path> - <path from="SIDE" to="DMBITFORMATTOKEN"> - <node from="SIDE" to="PARTITION"> - <att value="SideName"/> - </node> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="SIDE" to="DMCAPABILITY"> - <node from="SIDE" to="MOUNTLOGICAL"> - <att value="SideName"/> - </node> - <node from="MOUNTLOGICAL" to="DMCAPABILITY"> - <att value="DMCapabilityName"/> - </node> - </path> - <path from="SIDE" to="DMCAPABILITYTOKEN"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="SIDE" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="SIDE" to="DMCAPABILITYGROUP"> - <node from="SIDE" to="MOUNTLOGICAL"> - <att value="SideName"/> - </node> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="SIDE" to="DMCAPABILITYGROUPTOKEN"> - <node from="SIDE" to="MOUNTLOGICAL"> - <att value="SideName"/> - </node> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="SIDE" to="CARTRIDGE"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SIDE" to="CARTRIDGEGROUP"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="SIDE" to="CARTRIDGEGROUPAPPLICATION"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="SIDE" to="CARTRIDGETYPE"> - <node from="SIDE" to="CARTRIDGETYPE"> - <att value="Side1Name"/> - </node> - </path> - <path from="SIDE" to="PARTITION"> - <node from="SIDE" to="PARTITION"> - <att value="SideName"/> - </node> - </path> - <path from="SIDE" to="VOLUME"> - <node from="SIDE" to="VOLUME"> - <att value="SideName"/> - </node> - </path> - <path from="SIDE" to="MOUNTLOGICAL"> - <node from="SIDE" to="MOUNTLOGICAL"> - <att value="SideName"/> - </node> - </path> - <path from="SIDE" to="MOUNTPHYSICAL"> - <node from="SIDE" to="MOUNTPHYSICAL"> - <att value="SideName"/> - </node> - </path> - <path from="SIDE" to="CONNECTION"> - <node from="SIDE" to="MOUNTLOGICAL"> - <att value="SideName"/> - </node> - <node from="MOUNTLOGICAL" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - </node> - <node from="MOUNTPHYSICAL" to="SESSION"> - <att value="SessionID"/> - </node> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="SIDE" to="SESSION"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="SIDE" to="NOTIFY"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="SIDE" to="TASK"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="SIDE" to="TASKCARTRIDGE"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SIDE" to="TASKDRIVE"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="SIDE" to="TASKLIBRARY"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="SIDE" to="REQUEST"> - <node from="SIDE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - </path> - <path from="PARTITION" to="APPLICATION"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="PARTITION" to="AI"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="PARTITION" to="LIBRARY"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="PARTITION" to="LIBRARYACCESS"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="PARTITION" to="LM"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="PARTITION" to="BAY"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="BAY"> - <att value="BayName"/> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="PARTITION" to="SLOT"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="PARTITION" to="SLOTGROUP"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTGROUP"> - <att value="SlotGroupName"/> - </node> - </path> - <path from="PARTITION" to="SLOTCONFIG"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="PARTITION" to="SLOTTYPE"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="PARTITION" to="DRIVECARTRIDGEACCESS"> - <node from="PARTITION" to="DRIVECARTRIDGEACCESS"> - <att value="CartridgeID"/> - <att value="SideName"/> - <att value="PartitionName"/> - </node> - </path> - <path from="PARTITION" to="DRIVECARTRIDGEERROR"> - <node from="PARTITION" to="DRIVECARTRIDGEERROR"> - <att value="CartridgeID"/> - <att value="SideName"/> - <att value="PartitionName"/> - </node> - </path> - <path from="PARTITION" to="DRIVE"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - </path> - <path from="PARTITION" to="DRIVEGROUP"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="PARTITION" to="DRIVEGROUPAPPLICATION"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="PARTITION" to="DM"> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - </path> - <path from="PARTITION" to="DMBITFORMAT"> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - </path> - <path from="PARTITION" to="DMBITFORMATTOKEN"> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="PARTITION" to="DMCAPABILITY"> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITY"> - <att value="DMName"/> - </node> - </path> - <path from="PARTITION" to="DMCAPABILITYTOKEN"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="PARTITION" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="PARTITION" to="DMCAPABILITYGROUP"> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="PARTITION" to="DMCAPABILITYGROUPTOKEN"> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="PARTITION" to="CARTRIDGE"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="PARTITION" to="CARTRIDGEGROUP"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="PARTITION" to="CARTRIDGEGROUPAPPLICATION"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="PARTITION" to="CARTRIDGETYPE"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="PARTITION" to="SIDE"> - <node from="PARTITION" to="SIDE"> - <att value="SideName"/> - </node> - </path> - <path from="PARTITION" to="VOLUME"> - <node from="PARTITION" to="VOLUME"> - <att value="CartridgeID"/> - <att value="SideName"/> - <att value="PartitionName"/> - </node> - </path> - <path from="PARTITION" to="MOUNTLOGICAL"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="MOUNTLOGICAL"> - <att value="CartridgeID"/> - </node> - </path> - <path from="PARTITION" to="MOUNTPHYSICAL"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="PARTITION" to="CONNECTION"> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - </path> - <path from="PARTITION" to="SESSION"> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="PARTITION" to="NOTIFY"> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="PARTITION" to="TASK"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="PARTITION" to="TASKCARTRIDGE"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="PARTITION" to="TASKDRIVE"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="PARTITION" to="TASKLIBRARY"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="PARTITION" to="REQUEST"> - <node from="PARTITION" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - </path> - <path from="VOLUME" to="APPLICATION"> - <node from="VOLUME" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="VOLUME" to="AI"> - <node from="VOLUME" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="VOLUME" to="LIBRARY"> - <node from="VOLUME" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="VOLUME" to="LIBRARYACCESS"> - <node from="VOLUME" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="VOLUME" to="LM"> - <node from="VOLUME" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="VOLUME" to="BAY"> - <node from="VOLUME" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - </node> - <node from="MOUNTPHYSICAL" to="SLOT"> - <att value="SlotName"/> - </node> - <node from="SLOT" to="BAY"> - <att value="BayName"/> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="VOLUME" to="SLOT"> - <node from="VOLUME" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - </node> - <node from="MOUNTPHYSICAL" to="SLOT"> - <att value="SlotName"/> - </node> - </path> - <path from="VOLUME" to="SLOTGROUP"> - <node from="VOLUME" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - </node> - <node from="MOUNTPHYSICAL" to="SLOT"> - <att value="SlotName"/> - </node> - <node from="SLOT" to="SLOTGROUP"> - <att value="SlotGroupName"/> - </node> - </path> - <path from="VOLUME" to="SLOTCONFIG"> - <node from="VOLUME" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - </node> - <node from="MOUNTPHYSICAL" to="SLOT"> - <att value="SlotName"/> - </node> - <node from="SLOT" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="VOLUME" to="SLOTTYPE"> - <node from="VOLUME" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - </node> - <node from="MOUNTPHYSICAL" to="SLOT"> - <att value="SlotName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="VOLUME" to="DRIVECARTRIDGEACCESS"> - <node from="VOLUME" to="DRIVECARTRIDGEACCESS"> - <att value="CartridgeID"/> - </node> - </path> - <path from="VOLUME" to="DRIVECARTRIDGEERROR"> - <node from="VOLUME" to="DRIVECARTRIDGEERROR"> - <att value="CartridgeID"/> - </node> - </path> - <path from="VOLUME" to="DRIVE"> - <node from="VOLUME" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - </path> - <path from="VOLUME" to="DRIVEGROUP"> - <node from="VOLUME" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="VOLUME" to="DRIVEGROUPAPPLICATION"> - <node from="VOLUME" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="VOLUME" to="DM"> - <node from="VOLUME" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="VOLUME" to="DMBITFORMAT"> - <node from="VOLUME" to="PARTITION"> - <att value="CartridgeID"/> - <att value="SideName"/> - <att value="PartitionName"/> - </node> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - </path> - <path from="VOLUME" to="DMBITFORMATTOKEN"> - <node from="VOLUME" to="PARTITION"> - <att value="CartridgeID"/> - <att value="SideName"/> - <att value="PartitionName"/> - </node> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="VOLUME" to="DMCAPABILITY"> - <node from="VOLUME" to="MOUNTLOGICAL"> - <att value="ApplicationName"/> - <att value="VolumeName"/> - </node> - <node from="MOUNTLOGICAL" to="DMCAPABILITY"> - <att value="DMCapabilityName"/> - </node> - </path> - <path from="VOLUME" to="DMCAPABILITYTOKEN"> - <node from="VOLUME" to="MOUNTLOGICAL"> - <att value="ApplicationName"/> - <att value="VolumeName"/> - </node> - <node from="MOUNTLOGICAL" to="DMCAPABILITY"> - <att value="DMCapabilityName"/> - </node> - <node from="DMCAPABILITY" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityName"/> - </node> - </path> - <path from="VOLUME" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="VOLUME" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="VOLUME" to="DMCAPABILITYGROUP"> - <node from="VOLUME" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="VOLUME" to="DMCAPABILITYGROUPTOKEN"> - <node from="VOLUME" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="VOLUME" to="CARTRIDGE"> - <node from="VOLUME" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="VOLUME" to="CARTRIDGEGROUP"> - <node from="VOLUME" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="VOLUME" to="CARTRIDGEGROUPAPPLICATION"> - <node from="VOLUME" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUP" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="VOLUME" to="CARTRIDGETYPE"> - <node from="VOLUME" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="VOLUME" to="SIDE"> - <node from="VOLUME" to="PARTITION"> - <att value="CartridgeID"/> - <att value="SideName"/> - <att value="PartitionName"/> - </node> - <node from="PARTITION" to="SIDE"> - <att value="SideName"/> - </node> - </path> - <path from="VOLUME" to="PARTITION"> - <node from="VOLUME" to="PARTITION"> - <att value="CartridgeID"/> - <att value="SideName"/> - <att value="PartitionName"/> - </node> - </path> - <path from="VOLUME" to="MOUNTLOGICAL"> - <node from="VOLUME" to="MOUNTLOGICAL"> - <att value="ApplicationName"/> - <att value="VolumeName"/> - </node> - </path> - <path from="VOLUME" to="MOUNTPHYSICAL"> - <node from="VOLUME" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - </node> - </path> - <path from="VOLUME" to="CONNECTION"> - <node from="VOLUME" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - </path> - <path from="VOLUME" to="SESSION"> - <node from="VOLUME" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="VOLUME" to="NOTIFY"> - <node from="VOLUME" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="VOLUME" to="TASK"> - <node from="VOLUME" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="VOLUME" to="TASKCARTRIDGE"> - <node from="VOLUME" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="VOLUME" to="TASKDRIVE"> - <node from="VOLUME" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="VOLUME" to="TASKLIBRARY"> - <node from="VOLUME" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="VOLUME" to="REQUEST"> - <node from="VOLUME" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="APPLICATION"> - <node from="MOUNTLOGICAL" to="VOLUME"> - <att value="ApplicationName"/> - <att value="VolumeName"/> - </node> - <node from="VOLUME" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="AI"> - <node from="MOUNTLOGICAL" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - </node> - <node from="MOUNTPHYSICAL" to="SESSION"> - <att value="SessionID"/> - </node> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="LIBRARY"> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="LIBRARYACCESS"> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="LM"> - <node from="MOUNTLOGICAL" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - </node> - <node from="MOUNTPHYSICAL" to="SESSION"> - <att value="SessionID"/> - </node> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="BAY"> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="SLOT"> - <node from="MOUNTLOGICAL" to="VOLUME"> - <att value="ApplicationName"/> - <att value="VolumeName"/> - </node> - <node from="VOLUME" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - </node> - <node from="MOUNTPHYSICAL" to="SLOT"> - <att value="SlotName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="SLOTGROUP"> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="SLOTCONFIG"> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="SLOTTYPE"> - <node from="MOUNTLOGICAL" to="VOLUME"> - <att value="ApplicationName"/> - <att value="VolumeName"/> - </node> - <node from="VOLUME" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - </node> - <node from="MOUNTPHYSICAL" to="SLOT"> - <att value="SlotName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="DRIVECARTRIDGEACCESS"> - <node from="MOUNTLOGICAL" to="DRIVECARTRIDGEACCESS"> - <att value="ApplicationName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="DRIVECARTRIDGEERROR"> - <node from="MOUNTLOGICAL" to="DRIVECARTRIDGEERROR"> - <att value="ApplicationName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="DRIVE"> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="DRIVEGROUP"> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="DRIVEGROUPAPPLICATION"> - <node from="MOUNTLOGICAL" to="VOLUME"> - <att value="ApplicationName"/> - <att value="VolumeName"/> - </node> - <node from="VOLUME" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="DM"> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="DMBITFORMAT"> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="DMBITFORMATTOKEN"> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="DMCAPABILITY"> - <node from="MOUNTLOGICAL" to="DMCAPABILITY"> - <att value="DMCapabilityName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="DMCAPABILITYTOKEN"> - <node from="MOUNTLOGICAL" to="DMCAPABILITY"> - <att value="DMCapabilityName"/> - </node> - <node from="DMCAPABILITY" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="DMCAPABILITYGROUP"> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="DMCAPABILITYGROUPTOKEN"> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="CARTRIDGE"> - <node from="MOUNTLOGICAL" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="CARTRIDGEGROUP"> - <node from="MOUNTLOGICAL" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="CARTRIDGEGROUPAPPLICATION"> - <node from="MOUNTLOGICAL" to="VOLUME"> - <att value="ApplicationName"/> - <att value="VolumeName"/> - </node> - <node from="VOLUME" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="CARTRIDGETYPE"> - <node from="MOUNTLOGICAL" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="SIDE"> - <node from="MOUNTLOGICAL" to="VOLUME"> - <att value="ApplicationName"/> - <att value="VolumeName"/> - </node> - <node from="VOLUME" to="PARTITION"> - <att value="CartridgeID"/> - <att value="SideName"/> - <att value="PartitionName"/> - </node> - <node from="PARTITION" to="SIDE"> - <att value="SideName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="PARTITION"> - <node from="MOUNTLOGICAL" to="VOLUME"> - <att value="ApplicationName"/> - <att value="VolumeName"/> - </node> - <node from="VOLUME" to="PARTITION"> - <att value="CartridgeID"/> - <att value="SideName"/> - <att value="PartitionName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="VOLUME"> - <node from="MOUNTLOGICAL" to="VOLUME"> - <att value="ApplicationName"/> - <att value="VolumeName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="MOUNTPHYSICAL"> - <node from="MOUNTLOGICAL" to="VOLUME"> - <att value="ApplicationName"/> - <att value="VolumeName"/> - </node> - <node from="VOLUME" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="CONNECTION"> - <node from="MOUNTLOGICAL" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - </node> - <node from="MOUNTPHYSICAL" to="SESSION"> - <att value="SessionID"/> - </node> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="SESSION"> - <node from="MOUNTLOGICAL" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - </node> - <node from="MOUNTPHYSICAL" to="SESSION"> - <att value="SessionID"/> - </node> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="NOTIFY"> - <node from="MOUNTLOGICAL" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - </node> - <node from="MOUNTPHYSICAL" to="SESSION"> - <att value="SessionID"/> - </node> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="TASK"> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="TASKCARTRIDGE"> - <node from="MOUNTLOGICAL" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="TASKDRIVE"> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="TASKLIBRARY"> - <node from="MOUNTLOGICAL" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="MOUNTLOGICAL" to="REQUEST"> - <node from="MOUNTLOGICAL" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - </node> - <node from="MOUNTPHYSICAL" to="SESSION"> - <att value="SessionID"/> - </node> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="APPLICATION"> - <node from="MOUNTPHYSICAL" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="AI"> - <node from="MOUNTPHYSICAL" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="LIBRARY"> - <node from="MOUNTPHYSICAL" to="SLOT"> - <att value="SlotName"/> - </node> - <node from="SLOT" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="LIBRARYACCESS"> - <node from="MOUNTPHYSICAL" to="SLOT"> - <att value="SlotName"/> - </node> - <node from="SLOT" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="LM"> - <node from="MOUNTPHYSICAL" to="SLOT"> - <att value="SlotName"/> - </node> - <node from="SLOT" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="BAY"> - <node from="MOUNTPHYSICAL" to="SLOT"> - <att value="SlotName"/> - </node> - <node from="SLOT" to="BAY"> - <att value="BayName"/> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="SLOT"> - <node from="MOUNTPHYSICAL" to="SLOT"> - <att value="SlotName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="SLOTGROUP"> - <node from="MOUNTPHYSICAL" to="SLOT"> - <att value="SlotName"/> - </node> - <node from="SLOT" to="SLOTGROUP"> - <att value="SlotGroupName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="SLOTCONFIG"> - <node from="MOUNTPHYSICAL" to="SLOT"> - <att value="SlotName"/> - </node> - <node from="SLOT" to="LM"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="LM" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="SLOTTYPE"> - <node from="MOUNTPHYSICAL" to="SLOT"> - <att value="SlotName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="DRIVECARTRIDGEACCESS"> - <node from="MOUNTPHYSICAL" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="DRIVECARTRIDGEACCESS"> - <att value="CartridgeID"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="DRIVECARTRIDGEERROR"> - <node from="MOUNTPHYSICAL" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="DRIVECARTRIDGEERROR"> - <att value="CartridgeID"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="DRIVE"> - <node from="MOUNTPHYSICAL" to="DRIVE"> - <att value="DriveName"/> - <att value="LibraryName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="DRIVEGROUP"> - <node from="MOUNTPHYSICAL" to="DRIVE"> - <att value="DriveName"/> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="DRIVEGROUPAPPLICATION"> - <node from="MOUNTPHYSICAL" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="DM"> - <node from="MOUNTPHYSICAL" to="DRIVE"> - <att value="DriveName"/> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="DMBITFORMAT"> - <node from="MOUNTPHYSICAL" to="DRIVE"> - <att value="DriveName"/> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="DMBITFORMATTOKEN"> - <node from="MOUNTPHYSICAL" to="DRIVE"> - <att value="DriveName"/> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="DMCAPABILITY"> - <node from="MOUNTPHYSICAL" to="DRIVE"> - <att value="DriveName"/> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="DMCAPABILITYTOKEN"> - <node from="MOUNTPHYSICAL" to="DRIVE"> - <att value="DriveName"/> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="MOUNTPHYSICAL" to="DRIVE"> - <att value="DriveName"/> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="DMCAPABILITYGROUP"> - <node from="MOUNTPHYSICAL" to="DRIVE"> - <att value="DriveName"/> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="DMCAPABILITYGROUPTOKEN"> - <node from="MOUNTPHYSICAL" to="DRIVE"> - <att value="DriveName"/> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="CARTRIDGE"> - <node from="MOUNTPHYSICAL" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="CARTRIDGEGROUP"> - <node from="MOUNTPHYSICAL" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="CARTRIDGEGROUPAPPLICATION"> - <node from="MOUNTPHYSICAL" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="CARTRIDGETYPE"> - <node from="MOUNTPHYSICAL" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="SIDE"> - <node from="MOUNTPHYSICAL" to="SIDE"> - <att value="SideName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="PARTITION"> - <node from="MOUNTPHYSICAL" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="VOLUME"> - <node from="MOUNTPHYSICAL" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="VOLUME"> - <att value="ApplicationName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="MOUNTLOGICAL"> - <node from="MOUNTPHYSICAL" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="MOUNTLOGICAL"> - <att value="ApplicationName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="CONNECTION"> - <node from="MOUNTPHYSICAL" to="SESSION"> - <att value="SessionID"/> - </node> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="SESSION"> - <node from="MOUNTPHYSICAL" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="NOTIFY"> - <node from="MOUNTPHYSICAL" to="SESSION"> - <att value="SessionID"/> - </node> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="TASK"> - <node from="MOUNTPHYSICAL" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="TASKCARTRIDGE"> - <node from="MOUNTPHYSICAL" to="CARTRIDGE"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="TASKDRIVE"> - <node from="MOUNTPHYSICAL" to="DRIVE"> - <att value="DriveName"/> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="TASKLIBRARY"> - <node from="MOUNTPHYSICAL" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="MOUNTPHYSICAL" to="REQUEST"> - <node from="MOUNTPHYSICAL" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="APPLICATION"> - <node from="DRIVECARTRIDGEERROR" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="AI"> - <node from="DRIVECARTRIDGEERROR" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="LIBRARY"> - <node from="DRIVECARTRIDGEERROR" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="LIBRARYACCESS"> - <node from="DRIVECARTRIDGEERROR" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - <node from="DRIVE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="LM"> - <node from="DRIVECARTRIDGEERROR" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LMName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="BAY"> - <node from="DRIVECARTRIDGEERROR" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="SLOT"> - <node from="DRIVECARTRIDGEERROR" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="SLOTGROUP"> - <node from="DRIVECARTRIDGEERROR" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTGROUP"> - <att value="SlotGroupName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="SLOTCONFIG"> - <node from="DRIVECARTRIDGEERROR" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="SLOTTYPE"> - <node from="DRIVECARTRIDGEERROR" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="DRIVE"> - <node from="DRIVECARTRIDGEERROR" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="DRIVEGROUP"> - <node from="DRIVECARTRIDGEERROR" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="DRIVEGROUPAPPLICATION"> - <node from="DRIVECARTRIDGEERROR" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="DM"> - <node from="DRIVECARTRIDGEERROR" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="DMBITFORMAT"> - <node from="DRIVECARTRIDGEERROR" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="DMBITFORMATTOKEN"> - <node from="DRIVECARTRIDGEERROR" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="DMCAPABILITY"> - <node from="DRIVECARTRIDGEERROR" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITY"> - <att value="DMName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="DMCAPABILITYTOKEN"> - <node from="DRIVECARTRIDGEERROR" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="DRIVECARTRIDGEERROR" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="DMCAPABILITYGROUP"> - <node from="DRIVECARTRIDGEERROR" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="DMCAPABILITYGROUPTOKEN"> - <node from="DRIVECARTRIDGEERROR" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="CARTRIDGE"> - <node from="DRIVECARTRIDGEERROR" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="CARTRIDGEGROUP"> - <node from="DRIVECARTRIDGEERROR" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="CARTRIDGEGROUPAPPLICATION"> - <node from="DRIVECARTRIDGEERROR" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUP" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="CARTRIDGETYPE"> - <node from="DRIVECARTRIDGEERROR" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="SIDE"> - <node from="DRIVECARTRIDGEERROR" to="PARTITION"> - <att value="CartridgeID"/> - <att value="SideName"/> - <att value="PartitionName"/> - </node> - <node from="PARTITION" to="SIDE"> - <att value="SideName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="PARTITION"> - <node from="DRIVECARTRIDGEERROR" to="PARTITION"> - <att value="CartridgeID"/> - <att value="SideName"/> - <att value="PartitionName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="VOLUME"> - <node from="DRIVECARTRIDGEERROR" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="MOUNTLOGICAL"> - <node from="DRIVECARTRIDGEERROR" to="MOUNTLOGICAL"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="MOUNTPHYSICAL"> - <node from="DRIVECARTRIDGEERROR" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="CONNECTION"> - <node from="DRIVECARTRIDGEERROR" to="CONNNECTION"> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="SESSION"> - <node from="DRIVECARTRIDGEERROR" to="SESSION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="NOTIFY"> - <node from="DRIVECARTRIDGEERROR" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="TASK"> - <node from="DRIVECARTRIDGEERROR" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="TASKCARTRIDGE"> - <node from="DRIVECARTRIDGEERROR" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="TASKDRIVE"> - <node from="DRIVECARTRIDGEERROR" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="TASKLIBRARY"> - <node from="DRIVECARTRIDGEERROR" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - <node from="DRIVE" to="TASKLIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="REQUEST"> - <node from="DRIVECARTRIDGEERROR" to="SESSION"> - <att value="ApplicationName"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="DRIVECARTRIDGEERROR" to="DRIVECARTRIDGEACCESS"> - <node from="DRIVECARTRIDGEERROR" to="DRIVECARTRIDGEACCESS"> - <att value="CartridgeID"/> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="APPLICATION"> - <node from="DRIVECARTRIDGEACCESS" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="AI"> - <node from="DRIVECARTRIDGEACCESS" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="LIBRARY"> - <node from="DRIVECARTRIDGEACCESS" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="LIBRARYACCESS"> - <node from="DRIVECARTRIDGEACCESS" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - <node from="DRIVE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="LM"> - <node from="DRIVECARTRIDGEACCESS" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LMName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="BAY"> - <node from="DRIVECARTRIDGEACCESS" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="SLOT"> - <node from="DRIVECARTRIDGEACCESS" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="SLOTGROUP"> - <node from="DRIVECARTRIDGEACCESS" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTGROUP"> - <att value="SlotGroupName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="SLOTCONFIG"> - <node from="DRIVECARTRIDGEACCESS" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="SLOTTYPE"> - <node from="DRIVECARTRIDGEACCESS" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="DRIVE"> - <node from="DRIVECARTRIDGEACCESS" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="DRIVEGROUP"> - <node from="DRIVECARTRIDGEACCESS" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="DRIVEGROUPAPPLICATION"> - <node from="DRIVECARTRIDGEACCESS" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="DM"> - <node from="DRIVECARTRIDGEACCESS" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="DMBITFORMAT"> - <node from="DRIVECARTRIDGEACCESS" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="DMBITFORMATTOKEN"> - <node from="DRIVECARTRIDGEACCESS" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="DMCAPABILITY"> - <node from="DRIVECARTRIDGEACCESS" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITY"> - <att value="DMName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="DMCAPABILITYTOKEN"> - <node from="DRIVECARTRIDGEACCESS" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="DRIVECARTRIDGEACCESS" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="DMCAPABILITYGROUP"> - <node from="DRIVECARTRIDGEACCESS" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="DMCAPABILITYGROUPTOKEN"> - <node from="DRIVECARTRIDGEACCESS" to="DM"> - <att value="DriveName"/> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="CARTRIDGE"> - <node from="DRIVECARTRIDGEACCESS" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="CARTRIDGEGROUP"> - <node from="DRIVECARTRIDGEACCESS" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="CARTRIDGEGROUPAPPLICATION"> - <node from="DRIVECARTRIDGEACCESS" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUP" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="CARTRIDGETYPE"> - <node from="DRIVECARTRIDGEACCESS" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="SIDE"> - <node from="DRIVECARTRIDGEACCESS" to="PARTITION"> - <att value="CartridgeID"/> - <att value="SideName"/> - <att value="PartitionName"/> - </node> - <node from="PARTITION" to="SIDE"> - <att value="SideName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="PARTITION"> - <node from="DRIVECARTRIDGEACCESS" to="PARTITION"> - <att value="CartridgeID"/> - <att value="SideName"/> - <att value="PartitionName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="VOLUME"> - <node from="DRIVECARTRIDGEACCESS" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="MOUNTLOGICAL"> - <node from="DRIVECARTRIDGEACCESS" to="MOUNTLOGICAL"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="MOUNTPHYSICAL"> - <node from="DRIVECARTRIDGEACCESS" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="CONNECTION"> - <node from="DRIVECARTRIDGEACCESS" to="CONNNECTION"> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="SESSION"> - <node from="DRIVECARTRIDGEACCESS" to="SESSION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="NOTIFY"> - <node from="DRIVECARTRIDGEACCESS" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="TASK"> - <node from="DRIVECARTRIDGEACCESS" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="TASKCARTRIDGE"> - <node from="DRIVECARTRIDGEACCESS" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="TASKDRIVE"> - <node from="DRIVECARTRIDGEACCESS" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="TASKLIBRARY"> - <node from="DRIVECARTRIDGEACCESS" to="DRIVE"> - <att value="DriveSerialNum"/> - </node> - <node from="DRIVE" to="TASKLIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="REQUEST"> - <node from="DRIVECARTRIDGEACCESS" to="SESSION"> - <att value="ApplicationName"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="DRIVECARTRIDGEACCESS" to="DRIVECARTRIDGEERR0R"> - <node from="DRIVECARTRIDGEACCESS" to="DRIVECARTRIDGEERROR"> - <att value="CartridgeID"/> - <att value="DriveName"/> - </node> - </path> - <path from="CONNECTION" to="APPLICATION"> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="CONNECTION" to="AI"> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - </path> - <path from="CONNECTION" to="LIBRARY"> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="CONNECTION" to="LIBRARYACCESS"> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - <node from="LM" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="CONNECTION" to="LM"> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - </path> - <path from="CONNECTION" to="BAY"> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - <node from="LM" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="CONNECTION" to="SLOT"> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - <node from="LM" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="CONNECTION" to="SLOTGROUP"> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - <node from="LM" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="CONNECTION" to="SLOTCONFIG"> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - <node from="LM" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="CONNECTION" to="SLOTTYPE"> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - <node from="LM" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="CONNECTION" to="DRIVECARTRIDGEACCESS"> - <node from="CONNNECTION" to="DRIVECARTRIDGEACCESS"> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - </path> - <path from="CONNECTION" to="DRIVECARTRIDGEERROR"> - <node from="CONNNECTION" to="DRIVECARTRIDGEERROR"> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - </path> - <path from="CONNECTION" to="DRIVE"> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="CONNECTION" to="DRIVEGROUP"> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="CONNECTION" to="DRIVEGROUPAPPLICATION"> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="CONNECTION" to="DM"> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - </path> - <path from="CONNECTION" to="DMBITFORMAT"> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="CONNECTION" to="DMBITFORMATTOKEN"> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="CONNECTION" to="DMCAPABILITY"> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITY"> - <att value="DMName"/> - </node> - </path> - <path from="CONNECTION" to="DMCAPABILITYTOKEN"> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="CONNECTION" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="CONNECTION" to="DMCAPABILITYGROUP"> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="CONNECTION" to="DMCAPABILITYGROUPTOKEN"> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="CONNECTION" to="CARTRIDGE"> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="CONNECTION" to="CARTRIDGEGROUP"> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="CONNECTION" to="CARTRIDGEGROUPAPPLICATION"> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="CONNECTION" to="CARTRIDGETYPE"> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="CONNECTION" to="SIDE"> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CONNECTION" to="PARTITION"> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CONNECTION" to="VOLUME"> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="VOLUME"> - <att value="ApplicationName"/> - </node> - </path> - <path from="CONNECTION" to="MOUNTLOGICAL"> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - <node from="SESSION" to="MOUNTPHYSICAL"> - <att value="SessionID"/> - </node> - <node from="MOUNTPHYSICAL" to="MOUNTLOGICAL"> - <att value="CartridgeID"/> - </node> - </path> - <path from="CONNECTION" to="MOUNTPHYSICAL"> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - <node from="SESSION" to="MOUNTPHYSICAL"> - <att value="SessionID"/> - </node> - </path> - <path from="CONNECTION" to="SESSION"> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="CONNECTION" to="NOTIFY"> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="CONNECTION" to="TASK"> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="CONNECTION" to="TASKCARTRIDGE"> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKCARTRIDGE"> - <att value="TaskID"/> - </node> - </path> - <path from="CONNECTION" to="TASKDRIVE"> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKDRIVE"> - <att value="TaskID"/> - </node> - </path> - <path from="CONNECTION" to="TASKLIBRARY"> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="CONNECTION" to="REQUEST"> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="CONNECTION" to="STALEHANDLE"> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - <node from="SESSION" to="MOUNTPHYSICAL"> - <att value="SessionID"/> - </node> - <node from="MOUNTPHYSICAL" to="STALEHANDLE"> - <att value="CartridgeID"/> - </node> - - </path> - <path from="SESSION" to="APPLICATION"> - <node from="SESSION" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="SESSION" to="AI"> - <node from="SESSION" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="SESSION" to="LIBRARY"> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="SESSION" to="LIBRARYACCESS"> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - <node from="LM" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="SESSION" to="LM"> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - </path> - <path from="SESSION" to="BAY"> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - <node from="LM" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="SESSION" to="SLOT"> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - <node from="LM" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="SESSION" to="SLOTGROUP"> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - <node from="LM" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="SESSION" to="SLOTCONFIG"> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - <node from="LM" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="SESSION" to="SLOTTYPE"> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - <node from="LM" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="SESSION" to="DRIVECARTRIDGEACCESS"> - <node from="SESSION" to="DRIVECARTRIDGEACCESS"> - <att value="ApplicationName"/> - </node> - </path> - <path from="SESSION" to="DRIVECARTRIDGEERROR"> - <node from="SESSION" to="DRIVECARTRIDGEERROR"> - <att value="ApplicationName"/> - </node> - </path> - <path from="SESSION" to="DRIVE"> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="SESSION" to="DRIVEGROUP"> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="SESSION" to="DRIVEGROUPAPPLICATION"> - <node from="SESSION" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="SESSION" to="DM"> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - </path> - <path from="SESSION" to="DMBITFORMAT"> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="SESSION" to="DMBITFORMATTOKEN"> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="SESSION" to="DMCAPABILITY"> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITY"> - <att value="DMName"/> - </node> - </path> - <path from="SESSION" to="DMCAPABILITYTOKEN"> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="SESSION" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="SESSION" to="DMCAPABILITYGROUP"> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="SESSION" to="DMCAPABILITYGROUPTOKEN"> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="SESSION" to="CARTRIDGE"> - <node from="SESSION" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="SESSION" to="CARTRIDGEGROUP"> - <node from="SESSION" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="SESSION" to="CARTRIDGEGROUPAPPLICATION"> - <node from="SESSION" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="SESSION" to="CARTRIDGETYPE"> - <node from="SESSION" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="SESSION" to="SIDE"> - <node from="SESSION" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SESSION" to="PARTITION"> - <node from="SESSION" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="SESSION" to="VOLUME"> - <node from="SESSION" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="VOLUME"> - <att value="ApplicationName"/> - </node> - </path> - <path from="SESSION" to="MOUNTLOGICAL"> - <node from="SESSION" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="MOUNTLOGICAL"> - <att value="ApplicationName"/> - </node> - </path> - <path from="SESSION" to="MOUNTPHYSICAL"> - <node from="SESSION" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="SESSION" to="CONNECTION"> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="SESSION" to="NOTIFY"> - <node from="SESSION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="SESSION" to="TASK"> - <node from="SESSION" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="SESSION" to="TASKCARTRIDGE"> - <node from="SESSION" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKCARTRIDGE"> - <att value="TaskID"/> - </node> - </path> - <path from="SESSION" to="TASKDRIVE"> - <node from="SESSION" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKDRIVE"> - <att value="TaskID"/> - </node> - </path> - <path from="SESSION" to="TASKLIBRARY"> - <node from="SESSION" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="SESSION" to="REQUEST"> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="NOTIFY" to="APPLICATION"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="NOTIFY" to="AI"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - </path> - <path from="NOTIFY" to="LIBRARY"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="NOTIFY" to="LIBRARYACCESS"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="NOTIFY" to="LM"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - </path> - <path from="NOTIFY" to="BAY"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - <node from="LM" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="NOTIFY" to="SLOT"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="NOTIFY" to="SLOTGROUP"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTGROUP"> - <att value="SlotGroupName"/> - </node> - </path> - <path from="NOTIFY" to="SLOTCONFIG"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="LM"> - <att value="ConnectionClientInstance" to_value="LMName"/> - <att value="ConnectionClientName" to_value="LibraryName"/> - </node> - <node from="LM" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="NOTIFY" to="SLOTTYPE"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="NOTIFY" to="DRIVECARTRIDGEACCESS"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVECARTRIDGEACCESS"> - <att value="ApplicationName"/> - </node> - </path> - <path from="NOTIFY" to="DRIVECARTRIDGEERROR"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVECARTRIDGEERROR"> - <att value="ApplicationName"/> - </node> - </path> - <path from="NOTIFY" to="DRIVE"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="NOTIFY" to="DRIVEGROUP"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="NOTIFY" to="DRIVEGROUPAPPLICATION"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="NOTIFY" to="DM"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - </path> - <path from="NOTIFY" to="DMBITFORMAT"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="NOTIFY" to="DMBITFORMATTOKEN"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="NOTIFY" to="DMCAPABILITY"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="MOUNTLOGICAL"> - <att value="ApplicationName"/> - </node> - <node from="MOUNTLOGICAL" to="DMCAPABILITY"> - <att value="DMCapabilityName"/> - </node> - </path> - <path from="NOTIFY" to="DMCAPABILITYTOKEN"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="DRIVEGROUPAPPLICATION" to="DRIVE"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="NOTIFY" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="NOTIFY" to="DMCAPABILITYGROUP"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="NOTIFY" to="DMCAPABILITYGROUPTOKEN"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="DM"> - <att value="ConnectionClientInstance" to_value="DMName"/> - <att value="ConnectionClientName" to_value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="NOTIFY" to="CARTRIDGE"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="NOTIFY" to="CARTRIDGEGROUP"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="NOTIFY" to="CARTRIDGEGROUPAPPLICATION"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="NOTIFY" to="CARTRIDGETYPE"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="NOTIFY" to="SIDE"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="NOTIFY" to="PARTITION"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="NOTIFY" to="VOLUME"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="VOLUME"> - <att value="ApplicationName"/> - </node> - </path> - <path from="NOTIFY" to="MOUNTLOGICAL"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="MOUNTLOGICAL"> - <att value="ApplicationName"/> - </node> - </path> - <path from="NOTIFY" to="MOUNTPHYSICAL"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="NOTIFY" to="CONNECTION"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="NOTIFY" to="SESSION"> - <node from="NOTIFY" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="NOTIFY" to="TASK"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="NOTIFY" to="TASKCARTRIDGE"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="CARTRIDGE"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="NOTIFY" to="TASKDRIVE"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKDRIVE"> - <att value="TaskID"/> - </node> - </path> - <path from="NOTIFY" to="TASKLIBRARY"> - <node from="NOTIFY" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="NOTIFY" to="REQUEST"> - <node from="NOTIFY" to="SESSION"> - <att value="ConnectionID"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="TASK" to="APPLICATION"> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="TASK" to="AI"> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="TASK" to="LIBRARY"> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="TASK" to="LIBRARYACCESS"> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - <node from="TASKLIBRARY" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="TASK" to="LM"> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="TASK" to="BAY"> - <node from="TASK" to="TASKDRIVE"> - <att value="TaskID"/> - </node> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="TASK" to="SLOT"> - <node from="TASK" to="TASKCARTRIDGE"> - <att value="TaskID"/> - </node> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="TASK" to="SLOTGROUP"> - <node from="TASK" to="TASKCARTRIDGE"> - <att value="TaskID"/> - </node> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTGROUP"> - <att value="SlotGroupName"/> - </node> - </path> - <path from="TASK" to="SLOTCONFIG"> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - <node from="REQUEST" to="LM"> - <att value="RequestingClient" to_value="LibraryName"/> - <att value="RequestingInstance" to_value="LMName"/> - </node> - <node from="LM" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="TASK" to="SLOTTYPE"> - <node from="TASK" to="TASKCARTRIDGE"> - <att value="TaskID"/> - </node> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="TASK" to="DRIVECARTRIDGEACCESS"> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVECARTRIDGEACCESS"> - <att value="ApplicationName"/> - </node> - </path> - <path from="TASK" to="DRIVECARTRIDGEERROR"> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVECARTRIDGEERROR"> - <att value="ApplicationName"/> - </node> - </path> - <path from="TASK" to="DRIVE"> - <node from="TASK" to="TASKDRIVE"> - <att value="TaskID"/> - </node> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="TASK" to="DRIVEGROUP"> - <node from="TASK" to="TASKDRIVE"> - <att value="TaskID"/> - </node> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="TASK" to="DRIVEGROUPAPPLICATION"> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="TASK" to="DM"> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - <node from="REQUEST" to="DM"> - <att value="RequestingClient" to_value="DriveName"/> - <att value="RequestingInstance" to_value="DMName"/> - </node> - </path> - <path from="TASK" to="DMBITFORMAT"> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - <node from="REQUEST" to="DM"> - <att value="RequestingClient" to_value="DriveName"/> - <att value="RequestingInstance" to_value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="TASK" to="DMBITFORMATTOKEN"> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - <node from="REQUEST" to="DM"> - <att value="RequestingClient" to_value="DriveName"/> - <att value="RequestingInstance" to_value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="TASK" to="DMCAPABILITY"> - <node from="TASK" to="TASKDRIVE"> - <att value="TaskID"/> - </node> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="TASK" to="DMCAPABILITYTOKEN"> - <node from="TASK" to="TASKDRIVE"> - <att value="TaskID"/> - </node> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="TASK" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="TASK" to="TASKDRIVE"> - <att value="TaskID"/> - </node> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="TASK" to="DMCAPABILITYGROUP"> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - <node from="REQUEST" to="DM"> - <att value="RequestingClient" to_value="DriveName"/> - <att value="RequestingInstance" to_value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="TASK" to="DMCAPABILITYGROUPTOKEN"> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - <node from="REQUEST" to="DM"> - <att value="RequestingClient" to_value="DriveName"/> - <att value="RequestingInstance" to_value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="TASK" to="CARTRIDGE"> - <node from="TASK" to="TASKCARTRIDGE"> - <att value="TaskID"/> - </node> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="TASK" to="CARTRIDGEGROUP"> - <node from="TASK" to="TASKCARTRIDGE"> - <att value="TaskID"/> - </node> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="TASK" to="CARTRIDGEGROUPAPPLICATION"> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="TASK" to="CARTRIDGETYPE"> - <node from="TASK" to="TASKCARTRIDGE"> - <att value="TaskID"/> - </node> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="TASK" to="SIDE"> - <node from="TASK" to="TASKCARTRIDGE"> - <att value="TaskID"/> - </node> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="TASK" to="PARTITION"> - <node from="TASK" to="TASKCARTRIDGE"> - <att value="TaskID"/> - </node> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="TASK" to="VOLUME"> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="VOLUME"> - <att value="ApplicationName"/> - </node> - </path> - <path from="TASK" to="MOUNTLOGICAL"> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="MOUNTLOGICAL"> - <att value="ApplicationName"/> - </node> - </path> - <path from="TASK" to="MOUNTPHYSICAL"> - <node from="TASK" to="TASKCARTRIDGE"> - <att value="TaskID"/> - </node> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="TASK" to="CONNECTION"> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - </path> - <path from="TASK" to="SESSION"> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="TASK" to="NOTIFY"> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="TASK" to="TASKCARTRIDGE"> - <node from="TASK" to="TASKCARTRIDGE"> - <att value="TaskID"/> - </node> - </path> - <path from="TASK" to="TASKDRIVE"> - <node from="TASK" to="TASKDRIVE"> - <att value="TaskID"/> - </node> - </path> - <path from="TASK" to="TASKLIBRARY"> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="TASK" to="REQUEST"> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="APPLICATION"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="AI"> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="LIBRARY"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="LIBRARYACCESS"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="LM"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="BAY"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="BAY"> - <att value="BayName"/> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="SLOT"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="SLOTGROUP"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTGROUP"> - <att value="SlotGroupName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="SLOTCONFIG"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="SLOTTYPE"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="DRIVECARTRIDGEACCESS"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVECARTRIDGEACCESS"> - <att value="CartridgeID"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="DRIVECARTRIDGEERROR"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVECARTRIDGEERROR"> - <att value="CartridgeID"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="DRIVE"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="DRIVEGROUP"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="DRIVEGROUPAPPLICATION"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="DM"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="DMBITFORMAT"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="DMBITFORMATTOKEN"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - <node from="PARTITION" to="DMBITFORMAT"> - <att value="PartitionBitFormat" to_value="DMBitFormatName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="DMCAPABILITY"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITY"> - <att value="DMName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="DMCAPABILITYTOKEN"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="DMCAPABILITYGROUP"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="DMCAPABILITYGROUPTOKEN"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="CARTRIDGE"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="CARTRIDGEGROUP"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="CARTRIDGETYPE"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="SIDE"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="PARTITION"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="VOLUME"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="MOUNTLOGICAL"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="MOUNTLOGICAL"> - <att value="CartridgeID"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="MOUNTPHYSICAL"> - <node from="TASKCARTRIDGE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="CONNECTION"> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="SESSION"> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="NOTIFY"> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="TASK"> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="TASKDRIVE"> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKDRIVE"> - <att value="TaskID"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="TASKLIBRARY"> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="TASKCARTRIDGE" to="REQUEST"> - <node from="TASKCARTRIDGE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - </path> - <path from="TASKDRIVE" to="APPLICATION"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="TASKDRIVE" to="AI"> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="TASKDRIVE" to="LIBRARY"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="TASKDRIVE" to="LIBRARYACCESS"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="TASKDRIVE" to="LM"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="TASKDRIVE" to="BAY"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="TASKDRIVE" to="SLOT"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="TASKDRIVE" to="SLOTGROUP"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="TASKDRIVE" to="SLOTCONFIG"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="TASKDRIVE" to="SLOTTYPE"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="TASKDRIVE" to="DRIVECARTRIDGEACCESS"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVECARTRIDGEACCESS"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="TASKDRIVE" to="DRIVECARTRIDGEERROR"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVECARTRIDGEERROR"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="TASKDRIVE" to="DRIVE"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="TASKDRIVE" to="DRIVEGROUP"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="TASKDRIVE" to="DRIVEGROUPAPPLICATION"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="TASKDRIVE" to="DM"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="TASKDRIVE" to="DMBITFORMAT"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="TASKDRIVE" to="DMBITFORMATTOKEN"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="TASKDRIVE" to="DMCAPABILITY"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="TASKDRIVE" to="DMCAPABILITYTOKEN"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="TASKDRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="TASKDRIVE" to="DMCAPABILITYGROUP"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="TASKDRIVE" to="DMCAPABILITYGROUPTOKEN"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="TASKDRIVE" to="CARTRIDGE"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - </path> - <path from="TASKDRIVE" to="CARTRIDGEGROUP"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="TASKDRIVE" to="CARTRIDGEGROUPAPPLICATION"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="TASKDRIVE" to="CARTRIDGETYPE"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="TASKDRIVE" to="SIDE"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="TASKDRIVE" to="PARTITION"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="TASKDRIVE" to="VOLUME"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="TASKDRIVE" to="MOUNTLOGICAL"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="MOUNTLOGICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="TASKDRIVE" to="MOUNTPHYSICAL"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="MOUNTPHYSICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="TASKDRIVE" to="CONNECTION"> - <node from="TASKDRIVE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="CONNECTION"> - <att value="DMHost" to_value="ConnectionClientHost"/> - </node> - </path> - <path from="TASKDRIVE" to="SESSION"> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="TASKDRIVE" to="NOTIFY"> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="TASKDRIVE" to="TASK"> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="TASKDRIVE" to="TASKCARTRIDGE"> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKCARTRIDGE"> - <att value="TaskID"/> - </node> - </path> - <path from="TASKDRIVE" to="TASKLIBRARY"> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="TASKDRIVE" to="REQUEST"> - <node from="TASKDRIVE" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - </path> - <path from="TASKLIBRARY" to="APPLICATION"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="TASKLIBRARY" to="AI"> - <node from="TASKLIBRARY" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="TASKLIBRARY" to="LIBRARY"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="TASKLIBRARY" to="LIBRARYACCESS"> - <node from="TASKLIBRARY" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="TASKLIBRARY" to="LM"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="TASKLIBRARY" to="BAY"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="TASKLIBRARY" to="SLOT"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="TASKLIBRARY" to="SLOTGROUP"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="TASKLIBRARY" to="SLOTCONFIG"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="TASKLIBRARY" to="SLOTTYPE"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="TASKLIBRARY" to="DRIVECARTRIDGEACCESS"> - <node from="TASKLIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVECARTRIDGEACCESS"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="TASKLIBRARY" to="DRIVECARTRIDGEERROR"> - <node from="TASKLIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVECARTRIDGEERROR"> - <att value="DriveSerialNum"/> - </node> - </path> - <path from="TASKLIBRARY" to="DRIVE"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - </path> - <path from="TASKLIBRARY" to="DRIVEGROUP"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="TASKLIBRARY" to="DRIVEGROUPAPPLICATION"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="TASKLIBRARY" to="DM"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - </path> - <path from="TASKLIBRARY" to="DMBITFORMAT"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="TASKLIBRARY" to="DMBITFORMATTOKEN"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="TASKLIBRARY" to="DMCAPABILITY"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="TASKLIBRARY" to="DMCAPABILITYTOKEN"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="TASKLIBRARY" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="TASKLIBRARY" to="DMCAPABILITYGROUP"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="TASKLIBRARY" to="DMCAPABILITYGROUPTOKEN"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="DM"> - <att value="DriveName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="TASKLIBRARY" to="CARTRIDGE"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - </path> - <path from="TASKLIBRARY" to="CARTRIDGEGROUP"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="TASKLIBRARY" to="CARTRIDGEGROUPAPPLICATION"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="TASKLIBRARY" to="CARTRIDGETYPE"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="TASKLIBRARY" to="SIDE"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="TASKLIBRARY" to="PARTITION"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="TASKLIBRARY" to="VOLUME"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="TASKLIBRARY" to="MOUNTLOGICAL"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="DRIVE"> - <att value="LibraryName"/> - </node> - <node from="DRIVE" to="MOUNTLOGICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="TASKLIBRARY" to="MOUNTPHYSICAL"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="MOUNTPHYSICAL"> - <att value="LibraryName"/> - </node> - </path> - <path from="TASKLIBRARY" to="CONNECTION"> - <node from="TASKLIBRARY" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - </path> - <path from="TASKLIBRARY" to="SESSION"> - <node from="TASKLIBRARY" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="TASKLIBRARY" to="NOTIFY"> - <node from="TASKLIBRARY" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="TASKLIBRARY" to="TASK"> - <node from="TASKLIBRARY" to="TASK"> - <att value="TaskID"/> - </node> - </path> - <path from="TASKLIBRARY" to="TASKCARTRIDGE"> - <node from="TASKLIBRARY" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKCARTRIDGE"> - <att value="TaskID"/> - </node> - </path> - <path from="TASKLIBRARY" to="TASKDRIVE"> - <node from="TASKLIBRARY" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="TASKDRIVE"> - <att value="TaskID"/> - </node> - </path> - <path from="TASKLIBRARY" to="REQUEST"> - <node from="TASKLIBRARY" to="TASK"> - <att value="TaskID"/> - </node> - <node from="TASK" to="REQUEST"> - <att value="TaskID" to_value="RequestID"/> - </node> - </path> - <path from="MESSAGE" to="APPLICATION"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - <node from="CARTRIDGEGROUPAPPLICATION" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="MESSAGE" to="AI"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - </path> - <path from="MESSAGE" to="LIBRARY"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="MESSAGE" to="LIBRARYACCESS"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="MESSAGE" to="LM"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - </path> - <path from="MESSAGE" to="BAY"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="MESSAGE" to="SLOT"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="MESSAGE" to="SLOTGROUP"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="MESSAGE" to="SLOTCONFIG"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="MESSAGE" to="SLOTTYPE"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="MESSAGE" to="DRIVE"> - <node from="MESSAGE" to="DM"> - <att value="MessageSenderName" to_value="DriveName"/> - <att value="MessageSenderInstance" to_value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="MESSAGE" to="DRIVEGROUP"> - <node from="MESSAGE" to="DM"> - <att value="MessageSenderName" to_value="DriveName"/> - <att value="MessageSenderInstance" to_value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="MESSAGE" to="DRIVEGROUPAPPLICATION"> - <node from="MESSAGE" to="DM"> - <att value="MessageSenderName" to_value="DriveName"/> - <att value="MessageSenderInstance" to_value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="MESSAGE" to="DM"> - <node from="MESSAGE" to="DM"> - <att value="MessageSenderName" to_value="DriveName"/> - <att value="MessageSenderInstance" to_value="DMName"/> - </node> - </path> - <path from="MESSAGE" to="DMBITFORMAT"> - <node from="MESSAGE" to="DM"> - <att value="MessageSenderName" to_value="DriveName"/> - <att value="MessageSenderInstance" to_value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="MESSAGE" to="DMBITFORMATTOKEN"> - <node from="MESSAGE" to="DM"> - <att value="MessageSenderName" to_value="DriveName"/> - <att value="MessageSenderInstance" to_value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="MESSAGE" to="DMCAPABILITY"> - <node from="MESSAGE" to="DM"> - <att value="MessageSenderName" to_value="DriveName"/> - <att value="MessageSenderInstance" to_value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITY"> - <att value="DMName"/> - </node> - </path> - <path from="MESSAGE" to="DMCAPABILITYTOKEN"> - <node from="MESSAGE" to="DM"> - <att value="MessageSenderName" to_value="DriveName"/> - <att value="MessageSenderInstance" to_value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="MESSAGE" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="MESSAGE" to="DM"> - <att value="MessageSenderName" to_value="DriveName"/> - <att value="MessageSenderInstance" to_value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="MESSAGE" to="DMCAPABILITYGROUP"> - <node from="MESSAGE" to="DM"> - <att value="MessageSenderName" to_value="DriveName"/> - <att value="MessageSenderInstance" to_value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="MESSAGE" to="DMCAPABILITYGROUPTOKEN"> - <node from="MESSAGE" to="DM"> - <att value="MessageSenderName" to_value="DriveName"/> - <att value="MessageSenderInstance" to_value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="MESSAGE" to="CARTRIDGE"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - </path> - <path from="MESSAGE" to="CARTRIDGEGROUP"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="MESSAGE" to="CARTRIDGEGROUPAPPLICATION"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUPAPPLICATION"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="MESSAGE" to="CARTRIDGETYPE"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="MESSAGE" to="SIDE"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="MESSAGE" to="PARTITION"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="MESSAGE" to="VOLUME"> - <node from="MESSAGE" to="DM"> - <att value="MessageSenderName" to_value="DriveName"/> - <att value="MessageSenderInstance" to_value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="MESSAGE" to="MOUNTLOGICAL"> - <node from="MESSAGE" to="DM"> - <att value="MessageSenderName" to_value="DriveName"/> - <att value="MessageSenderInstance" to_value="DMName"/> - </node> - <node from="DM" to="MOUNTLOGICAL"> - <att value="DMName"/> - </node> - </path> - <path from="MESSAGE" to="MOUNTPHYSICAL"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="MOUNTPHYSICAL"> - <att value="LibraryName"/> - </node> - </path> - <path from="MESSAGE" to="CONNECTION"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - </path> - <path from="MESSAGE" to="SESSION"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="MESSAGE" to="NOTIFY"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="MESSAGE" to="TASK"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="MESSAGE" to="TASKCARTRIDGE"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="MESSAGE" to="TASKDRIVE"> - <node from="MESSAGE" to="DM"> - <att value="MessageSenderName" to_value="DriveName"/> - <att value="MessageSenderInstance" to_value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="MESSAGE" to="TASKLIBRARY"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="AI"> - <att value="ConnectionClientInstance" to_value="AIName"/> - <att value="ConnectionClientName" to_value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="MESSAGE" to="REQUEST"> - <node from="MESSAGE" to="LM"> - <att value="MessageSenderName" to_value="LibraryName"/> - <att value="MessageSenderInstance" to_value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - <node from="CONNECTION" to="SESSION"> - <att value="ConnectionID"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - <path from="REQUEST" to="APPLICATION"> - <node from="REQUEST" to="SESSION"> - <att value="AcceptingSessionID" to_value="SessionID"/> - </node> - <node from="SESSION" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="REQUEST" to="AI"> - <node from="REQUEST" to="SESSION"> - <att value="AcceptingSessionID" to_value="SessionID"/> - </node> - <node from="SESSION" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="REQUEST" to="LIBRARY"> - <node from="REQUEST" to="LM"> - <att value="RequestingClient" to_value="LibraryName"/> - <att value="RequestingInstance" to_value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="REQUEST" to="LIBRARYACCESS"> - <node from="REQUEST" to="LM"> - <att value="RequestingClient" to_value="LibraryName"/> - <att value="RequestingInstance" to_value="LMName"/> - </node> - <node from="LM" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="REQUEST" to="LM"> - <node from="REQUEST" to="LM"> - <att value="RequestingClient" to_value="LibraryName"/> - <att value="RequestingInstance" to_value="LMName"/> - </node> - </path> - <path from="REQUEST" to="BAY"> - <node from="REQUEST" to="LM"> - <att value="RequestingClient" to_value="LibraryName"/> - <att value="RequestingInstance" to_value="LMName"/> - </node> - <node from="LM" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="REQUEST" to="SLOT"> - <node from="REQUEST" to="LM"> - <att value="RequestingClient" to_value="LibraryName"/> - <att value="RequestingInstance" to_value="LMName"/> - </node> - <node from="LM" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="REQUEST" to="SLOTGROUP"> - <node from="REQUEST" to="LM"> - <att value="RequestingClient" to_value="LibraryName"/> - <att value="RequestingInstance" to_value="LMName"/> - </node> - <node from="LM" to="BAY"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="REQUEST" to="SLOTCONFIG"> - <node from="REQUEST" to="LM"> - <att value="RequestingClient" to_value="LibraryName"/> - <att value="RequestingInstance" to_value="LMName"/> - </node> - <node from="LM" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - </path> - <path from="REQUEST" to="SLOTTYPE"> - <node from="REQUEST" to="LM"> - <att value="RequestingClient" to_value="LibraryName"/> - <att value="RequestingInstance" to_value="LMName"/> - </node> - <node from="LM" to="SLOT"> - <att value="LibraryName"/> - <att value="LMName"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="REQUEST" to="DRIVECARTRIDGEACCESS"> - <node from="REQUEST" to="SESSION"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - <node from="SESSION" to="DRIVECARTRIDGEACCESS"> - <att value="ApplicationName"/> - </node> - </path> - <path from="REQUEST" to="DRIVECARTRIDGEERROR"> - <node from="REQUEST" to="SESSION"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - <node from="SESSION" to="DRIVECARTRIDGEERROR"> - <att value="ApplicationName"/> - </node> - </path> - <path from="REQUEST" to="DRIVE"> - <node from="REQUEST" to="DM"> - <att value="RequestingClient" to_value="DriveName"/> - <att value="RequestingInstance" to_value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="REQUEST" to="DRIVEGROUP"> - <node from="REQUEST" to="DM"> - <att value="RequestingClient" to_value="DriveName"/> - <att value="RequestingInstance" to_value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="REQUEST" to="DRIVEGROUPAPPLICATION"> - <node from="REQUEST" to="DM"> - <att value="RequestingClient" to_value="DriveName"/> - <att value="RequestingInstance" to_value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - <node from="DRIVEGROUP" to="DRIVEGROUPAPPLICATION"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="REQUEST" to="DM"> - <node from="REQUEST" to="DM"> - <att value="RequestingClient" to_value="DriveName"/> - <att value="RequestingInstance" to_value="DMName"/> - </node> - </path> - <path from="REQUEST" to="DMBITFORMAT"> - <node from="REQUEST" to="DM"> - <att value="RequestingClient" to_value="DriveName"/> - <att value="RequestingInstance" to_value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="REQUEST" to="DMBITFORMATTOKEN"> - <node from="REQUEST" to="DM"> - <att value="RequestingClient" to_value="DriveName"/> - <att value="RequestingInstance" to_value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="REQUEST" to="DMCAPABILITY"> - <node from="REQUEST" to="DM"> - <att value="RequestingClient" to_value="DriveName"/> - <att value="RequestingInstance" to_value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITY"> - <att value="DMName"/> - </node> - </path> - <path from="REQUEST" to="DMCAPABILITYTOKEN"> - <node from="REQUEST" to="DM"> - <att value="RequestingClient" to_value="DriveName"/> - <att value="RequestingInstance" to_value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="REQUEST" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="REQUEST" to="DM"> - <att value="RequestingClient" to_value="DriveName"/> - <att value="RequestingInstance" to_value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DMName"/> - </node> - </path> - <path from="REQUEST" to="DMCAPABILITYGROUP"> - <node from="REQUEST" to="DM"> - <att value="RequestingClient" to_value="DriveName"/> - <att value="RequestingInstance" to_value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="REQUEST" to="DMCAPABILITYGROUPTOKEN"> - <node from="REQUEST" to="DM"> - <att value="RequestingClient" to_value="DriveName"/> - <att value="RequestingInstance" to_value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="REQUEST" to="CARTRIDGE"> - <node from="REQUEST" to="LM"> - <att value="RequestingClient" to_value="LibraryName"/> - <att value="RequestingInstance" to_value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - </path> - <path from="REQUEST" to="CARTRIDGEGROUP"> - <node from="REQUEST" to="LM"> - <att value="RequestingClient" to_value="LibraryName"/> - <att value="RequestingInstance" to_value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="REQUEST" to="CARTRIDGEGROUPAPPLICATION"> - <node from="REQUEST" to="SESSION"> - <att value="AcceptingSessionID" to_value="SessionID"/> - </node> - <node from="SESSION" to="AI"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="AI" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="REQUEST" to="CARTRIDGETYPE"> - <node from="REQUEST" to="LM"> - <att value="RequestingClient" to_value="LibraryName"/> - <att value="RequestingInstance" to_value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="REQUEST" to="SIDE"> - <node from="REQUEST" to="LM"> - <att value="RequestingClient" to_value="LibraryName"/> - <att value="RequestingInstance" to_value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="SIDE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="REQUEST" to="PARTITION"> - <node from="REQUEST" to="LM"> - <att value="RequestingClient" to_value="LibraryName"/> - <att value="RequestingInstance" to_value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="PARTITION"> - <att value="CartridgeID"/> - </node> - </path> - <path from="REQUEST" to="VOLUME"> - <node from="REQUEST" to="DM"> - <att value="RequestingClient" to_value="DriveName"/> - <att value="RequestingInstance" to_value="DMName"/> - </node> - <node from="DM" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="CARTRIDGE"> - <att value="LibraryName"/> - </node> - <node from="CARTRIDGE" to="VOLUME"> - <att value="CartridgeID"/> - </node> - </path> - <path from="REQUEST" to="MOUNTLOGICAL"> - <node from="REQUEST" to="DM"> - <att value="RequestingClient" to_value="DriveName"/> - <att value="RequestingInstance" to_value="DMName"/> - </node> - <node from="DM" to="MOUNTLOGICAL"> - <att value="DMName"/> - </node> - </path> - <path from="REQUEST" to="MOUNTPHYSICAL"> - <node from="REQUEST" to="LM"> - <att value="RequestingClient" to_value="LibraryName"/> - <att value="RequestingInstance" to_value="LMName"/> - </node> - <node from="LM" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="MOUNTPHYSICAL"> - <att value="LibraryName"/> - </node> - </path> - <path from="REQUEST" to="CONNECTION"> - <node from="REQUEST" to="LM"> - <att value="RequestingClient" to_value="LibraryName"/> - <att value="RequestingInstance" to_value="LMName"/> - </node> - <node from="LM" to="CONNECTION"> - <att value="LibraryName" to_value="ConnectionClientName"/> - <att value="LMName" to_value="ConnectionClientInstance"/> - </node> - </path> - <path from="REQUEST" to="SESSION"> - <node from="REQUEST" to="SESSION"> - <att value="AcceptingSessionID" to_value="SessionID"/> - </node> - </path> - <path from="REQUEST" to="NOTIFY"> - <node from="REQUEST" to="SESSION"> - <att value="AcceptingSessionID" to_value="SessionID"/> - </node> - <node from="SESSION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="REQUEST" to="TASK"> - <node from="REQUEST" to="TASK"> - <att value="RequestID" to_value="TaskID"/> - </node> - </path> - <path from="REQUEST" to="TASKCARTRIDGE"> - <node from="REQUEST" to="TASK"> - <att value="RequestID" to_value="TaskID"/> - </node> - <node from="TASK" to="TASKCARTRIDGE"> - <att value="TaskID"/> - </node> - </path> - <path from="REQUEST" to="TASKDRIVE"> - <node from="REQUEST" to="TASK"> - <att value="RequestID" to_value="TaskID"/> - </node> - <node from="TASK" to="TASKDRIVE"> - <att value="TaskID"/> - </node> - </path> - <path from="REQUEST" to="TASKLIBRARY"> - <node from="REQUEST" to="TASK"> - <att value="RequestID" to_value="TaskID"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="STALEHANDLE" to="APPLICATION"> - <node from="STALEHANDLE" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="STALEHANDLE" to="AI"> - <node from="STALEHANDLE" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - </path> - <path from="STALEHANDLE" to="LIBRARY"> - <node from="STALEHANDLE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - </path> - <path from="STALEHANDLE" to="LIBRARYACCESS"> - <node from="STALEHANDLE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARYACCESS"> - <att value="LibraryName"/> - </node> - </path> - <path from="STALEHANDLE" to="LM"> - <node from="STALEHANDLE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="LIBRARY"> - <att value="LibraryName"/> - </node> - <node from="LIBRARY" to="LM"> - <att value="LibraryName"/> - </node> - </path> - <path from="STALEHANDLE" to="BAY"> - <node from="STALEHANDLE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - </path> - <path from="STALEHANDLE" to="SLOT"> - <node from="STALEHANDLE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - </path> - <path from="STALEHANDLE" to="SLOTGROUP"> - <node from="STALEHANDLE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTGROUP"> - <att value="BayName"/> - </node> - </path> - <path from="STALEHANDLE" to="SLOTCONFIG"> - <node from="STALEHANDLE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="BAY"> - <att value="BayName"/> - </node> - <node from="BAY" to="SLOTCONFIG"> - <att value="LibraryName"/> - <att value="LMName"/> - <att value="BayName"/> - </node> - </path> - <path from="STALEHANDLE" to="SLOTTYPE"> - <node from="STALEHANDLE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="SLOT"> - <att value="CartridgeID"/> - <att value="CartridgePCL"/> - </node> - <node from="SLOT" to="SLOTTYPE"> - <att value="SlotTypeName"/> - </node> - </path> - <path from="STALEHANDLE" to="DRIVE"> - <node from="STALEHANDLE" to="DRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="STALEHANDLE" to="DRIVEGROUP"> - <node from="STALEHANDLE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DRIVEGROUP"> - <att value="DriveGroupName"/> - </node> - </path> - <path from="STALEHANDLE" to="DRIVEGROUPAPPLICATION"> - <node from="STALEHANDLE" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="DRIVEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="STALEHANDLE" to="DM"> - <node from="STALEHANDLE" to="DM"> - <att value="DMName"/> - </node> - </path> - <path from="STALEHANDLE" to="DMBITFORMAT"> - <node from="STALEHANDLE" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - </path> - <path from="STALEHANDLE" to="DMBITFORMATTOKEN"> - <node from="STALEHANDLE" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMBITFORMAT"> - <att value="DMName"/> - </node> - <node from="DMBITFORMAT" to="DMBITFORMATTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMBitFormatName"/> - </node> - </path> - <path from="STALEHANDLE" to="DMCAPABILITY"> - <node from="STALEHANDLE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITY"> - <att value="DriveName"/> - </node> - </path> - <path from="STALEHANDLE" to="DMCAPABILITYTOKEN"> - <node from="STALEHANDLE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="STALEHANDLE" to="DMCAPABILITYDEFAULTTOKEN"> - <node from="STALEHANDLE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="DMCAPABILITYDEFAULTTOKEN"> - <att value="DriveName"/> - </node> - </path> - <path from="STALEHANDLE" to="DMCAPABILITYGROUP"> - <node from="STALEHANDLE" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - </path> - <path from="STALEHANDLE" to="DMCAPABILITYGROUPTOKEN"> - <node from="STALEHANDLE" to="DM"> - <att value="DMName"/> - </node> - <node from="DM" to="DMCAPABILITYGROUP"> - <att value="DMName"/> - </node> - <node from="DMCAPABILITYGROUP" to="DMCAPABILITYGROUPTOKEN"> - <att value="DriveName"/> - <att value="DMName"/> - <att value="DMCapabilityGroupName"/> - </node> - </path> - <path from="STALEHANDLE" to="CARTRIDGE"> - <node from="STALEHANDLE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="STALEHANDLE" to="CARTRIDGEGROUP"> - <node from="STALEHANDLE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGEGROUP"> - <att value="CartridgeGroupName"/> - </node> - </path> - <path from="STALEHANDLE" to="CARTRIDGEGROUPAPPLICATION"> - <node from="STALEHANDLE" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="CARTRIDGEGROUPAPPLICATION"> - <att value="ApplicationName"/> - </node> - </path> - <path from="STALEHANDLE" to="CARTRIDGETYPE"> - <node from="STALEHANDLE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="CARTRIDGETYPE"> - <att value="CartridgeTypeName"/> - </node> - </path> - <path from="STALEHANDLE" to="SIDE"> - <node from="STALEHANDLE" to="SIDE"> - <att value="Side1Name"/> - </node> - </path> - <path from="STALEHANDLE" to="PARTITION"> - <node from="STALEHANDLE" to="PARTITION"> - <att value="PartitionName"/> - </node> - </path> - <path from="STALEHANDLE" to="VOLUME"> - <node from="STALEHANDLE" to="VOLUME"> - <att value="VolumeName"/> - </node> - </path> - <path from="STALEHANDLE" to="MOUNTLOGICAL"> - <node from="STALEHANDLE" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="MOUNTLOGICAL"> - <att value="ApplicationName"/> - </node> - </path> - <path from="STALEHANDLE" to="MOUNTPHYSICAL"> - <node from="STALEHANDLE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="MOUNTPHYSICAL"> - <att value="DriveName"/> - </node> - </path> - <path from="STALEHANDLE" to="CONNECTION"> - <node from="STALEHANDLE" to="MOUNTPHYSICAL"> - <att value="CartridgeID"/> - </node> - <node from="MOUNTPHYSICAL" to="SESSION"> - <att value="SessionID"/> - </node> - <node from="SESSION" to="CONNECTION"> - <att value="ConnectionID"/> - </node> - </path> - <path from="STALEHANDLE" to="SESSION"> - <node from="STALEHANDLE" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="STALEHANDLE" to="NOTIFY"> - <node from="STALEHANDLE" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="CONNECTION"> - <att value="AIName" to_value="ConnectionClientInstance"/> - <att value="ApplicationName" to_value="ConnectionClientName"/> - </node> - <node from="CONNECTION" to="NOTIFY"> - <att value="ConnectionID"/> - </node> - </path> - <path from="STALEHANDLE" to="TASK"> - <node from="STALEHANDLE" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - </path> - <path from="STALEHANDLE" to="TASKCARTRIDGE"> - <node from="STALEHANDLE" to="CARTRIDGE"> - <att value="CartridgeID"/> - </node> - <node from="CARTRIDGE" to="TASKCARTRIDGE"> - <att value="CartridgeID"/> - </node> - </path> - <path from="STALEHANDLE" to="TASKDRIVE"> - <node from="STALEHANDLE" to="DRIVE"> - <att value="DriveName"/> - </node> - <node from="DRIVE" to="TASKDRIVE"> - <att value="DriveName"/> - </node> - </path> - <path from="STALEHANDLE" to="TASKLIBRARY"> - <node from="STALEHANDLE" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="TASK"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="TASK" to="TASKLIBRARY"> - <att value="TaskID"/> - </node> - </path> - <path from="STALEHANDLE" to="REQUEST"> - <node from="STALEHANDLE" to="APPLICATION"> - <att value="ApplicationName"/> - </node> - <node from="APPLICATION" to="AI"> - <att value="ApplicationName"/> - </node> - <node from="AI" to="SESSION"> - <att value="AIName"/> - <att value="ApplicationName"/> - </node> - <node from="SESSION" to="REQUEST"> - <att value="SessionID" to_value="AcceptingSessionID"/> - </node> - </path> - </paths> -</mm_paths> diff --git a/usr/src/cmd/mms/mm/common/mm_sql.c b/usr/src/cmd/mms/mm/common/mm_sql.c deleted file mode 100644 index ed29043411..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_sql.c +++ /dev/null @@ -1,4978 +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 <stdlib.h> -#include <string.h> -#include <errno.h> -#include <syslog.h> -#include <mms_list.h> -#include <mms_parser.h> -#include <mms_par_impl.h> -#include <libpq-fe.h> -#include <mms_trace.h> -#include <mms_strapp.h> -#include <pthread.h> -#include "mm_db.h" -#include "mm.h" -#include "mm_util.h" -#include "mm_commands.h" -#include "mm_sql.h" -#include "mm_sql_impl.h" -#include "mm_path.h" - - -static char *_SrcFile = __FILE__; - -extern mm_pkey_t *mm_get_pkey(char *obj); - -char *mm_sql_number_buf(mm_command_t *cmd); -char *mm_sql_order_buf(mm_command_t *cmd); -static sql_ops_tab_t opstab[] = { - "strlohi", "ASC", - "strhilo", "DESC", - "numlohi", "ASC", - "numhilo", "DESC", - "regex", "~", - "streq", "=", - "strne", "<>", - "strlt", "<", - "strle", "<=", - "strgt", ">", - "strge", ">=", - "numeq", "=", - "numne", "<>", - "numlt", "<", - "numle", "<=", - "numgt", ">", - "numge", ">=", - "and", "AND", - "or", "OR", - "not", "NOT", - "hosteq", "=", - "hostne", "<>" -}; -static int num_ops = sizeof (opstab) / sizeof (sql_ops_tab_t); - - -char * -mm_get_cart_pcl(mm_command_t *cmd, char *cart_id, mm_db_t *db) -{ - char *value; - char *cart_pcl; - - /* - * Get cartridge pcl from cartridge id - */ - if (cart_id == NULL) { - mms_trace(MMS_DEVP, "cartridge id is null"); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_EXPLICIT) + strlen(ENOMATCH) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_EXPLICIT, ENOMATCH); - return (NULL); - } - if (mm_db_exec(HERE, db, "select \"CartridgePCL\" from \"CARTRIDGE\" " - "where \"CartridgeID\" = '%s'", cart_id) != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_INTERNAL) + strlen(EDATABASE) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INTERNAL, EDATABASE); - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - return (NULL); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_DEVP, "cartridge pcl failed"); - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_ERROR) + strlen(cmd->cmd_task) + - strlen(ECLASS_EXPLICIT) + strlen(ENOMATCH) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_EXPLICIT, ENOMATCH); - mm_clear_db(&db->mm_db_results); - return (NULL); - } - value = PQgetvalue(db->mm_db_results, 0, 0); - if (value[0] == '\0') { - value = "none"; - } - cart_pcl = strdup(value); - mm_clear_db(&db->mm_db_results); - if (cart_pcl == NULL) { - no_mem: - MM_ABORT_NO_MEM(); - } - return (cart_pcl); -} - - -int -mm_set_cartridge_status(char *id, char *status, mm_db_t *db) { - if ((id == NULL) || - (status == NULL)) { - mms_trace(MMS_ERR, - "id and/or status cannot be null"); - return (1); - } - /* Allowed values for status are : */ - /* in use */ - /* unavailable */ - /* available */ - if (mm_db_exec(HERE, db, - "update \"CARTRIDGE\" " - "set \"CartridgeStatus\" = '%s' " - "where \"CartridgeID\" = '%s';", - status, id) != MM_DB_OK) { - mms_trace(MMS_ERR, - "Error updateing cartridge state, %s, %s", - id, status); - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - return (1); - } - return (0); -} - -int -mm_set_drive_statesoft(char *drive, char *state, mm_db_t *db) { - if ((drive == NULL) || - (state == NULL)) { - mms_trace(MMS_ERR, - "drive and/or state cannot be null"); - return (1); - } - /* Allowed values for status are : */ - /* in use */ - /* ready */ - if (mm_db_exec(HERE, db, - "update \"DRIVE\" " - "set \"DriveStateSoft\" = '%s' " - "where \"DriveName\" = '%s';", - state, drive) != MM_DB_OK) { - mms_trace(MMS_ERR, - "Error updateing drive state, %s, %s", - drive, state); - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - return (1); - } - return (0); -} - - - -void -mm_set_mount_info_cart(char *cart_id, - cmd_mount_info_t *mount_info) { - if (mount_info->cmi_cartridge) - free(mount_info->cmi_cartridge); - mount_info->cmi_cartridge = NULL; - mount_info->cmi_cartridge = - mms_strapp(mount_info->cmi_cartridge, - cart_id); -} -void -mm_set_mount_info_drive(char *drive, - cmd_mount_info_t *mount_info) { - if (mount_info->cmi_drive) - free(mount_info->cmi_drive); - mount_info->cmi_drive = NULL; - mount_info->cmi_drive = - mms_strapp(mount_info->cmi_drive, - drive); -} -void -mm_set_mount_info_library(char *library, - cmd_mount_info_t *mount_info) { - if (mount_info->cmi_library) - free(mount_info->cmi_library); - mount_info->cmi_library = NULL; - mount_info->cmi_library = - mms_strapp(mount_info->cmi_library, - library); -} -void -mm_set_mount_info_dm(char *dm, - cmd_mount_info_t *mount_info) { - if (mount_info->cmi_dm) - free(mount_info->cmi_dm); - mount_info->cmi_dm = NULL; - mount_info->cmi_dm = - mms_strapp(mount_info->cmi_dm, - dm); -} -void -mm_set_mount_info_pcl(char *pcl, - cmd_mount_info_t *mount_info) { - if (mount_info->cmi_pcl) - free(mount_info->cmi_pcl); - mount_info->cmi_pcl = NULL; - mount_info->cmi_pcl = - mms_strapp(mount_info->cmi_pcl, - pcl); -} - - -void -mm_free_mount_info(cmd_mount_info_t *mount_info) { - if (mount_info->cmi_cartridge) - free(mount_info->cmi_cartridge); - if (mount_info->cmi_drive) - free(mount_info->cmi_drive); - if (mount_info->cmi_library) - free(mount_info->cmi_library); - if (mount_info->cmi_dm) - free(mount_info->cmi_dm); - if (mount_info->cmi_pcl) - free(mount_info->cmi_pcl); - mount_info->cmi_cartridge = NULL; - mount_info->cmi_pcl = NULL; - mount_info->cmi_drive = NULL; - mount_info->cmi_library = NULL; - mount_info->cmi_dm = NULL; -} - - - -void -mm_print_dm_status(mm_dm_stat_t *dm_stat) { - mms_trace(MMS_DEVP, - "DM, %s, Status for Drive, %s, host, %s", - dm_stat->dm_stat_name, - dm_stat->dm_stat_drive, - dm_stat->dm_stat_host); - mms_trace(MMS_DEVP, - " DMStateHard = %s", - dm_stat->dm_stat_hard); - mms_trace(MMS_DEVP, - " DMStateSoft = %s", - dm_stat->dm_stat_soft); - mms_trace(MMS_DEVP, - " DMDisabled = %s", - dm_stat->dm_stat_disabled); -} - -void -mm_free_dm_status(mm_dm_stat_t *dm_stat) { - if (dm_stat == NULL) { - return; - } - if (dm_stat->dm_stat_name) - free(dm_stat->dm_stat_name); - if (dm_stat->dm_stat_hard) - free(dm_stat->dm_stat_hard); - if (dm_stat->dm_stat_disabled) - free(dm_stat->dm_stat_disabled); - if (dm_stat->dm_stat_soft) - free(dm_stat->dm_stat_soft); - if (dm_stat->dm_stat_host) - free(dm_stat->dm_stat_host); - if (dm_stat->dm_stat_drive) - free(dm_stat->dm_stat_drive); - - free(dm_stat); -} - -mm_dm_stat_t * -mm_get_dm_status(char *dm_name, char *drive_name, char *host, mm_db_t *db) { - mm_dm_stat_t *dm_status = NULL; - - char *cmd_buf = NULL; - /* when dm name is null, use drive and host to return the dm status */ - cmd_buf = mms_strapp(cmd_buf, - "select " - "\"DM\".\"DMStateHard\", " - "\"DM\".\"DMStateSoft\", " - "\"DM\".\"DriveName\", " - "\"DM\".\"DMDisabled\", " - "\"DM\".\"DMTargetHost\", " - "\"DM\".\"DMName\" " - "from \"DM\" "); - - if (dm_name == NULL) { - if ((drive_name == NULL) || - (host == NULL)) { - mms_trace(MMS_ERR, - "need drive and host if dm namd is null", - ", mm_get_dm_status"); - free(cmd_buf); - return (NULL); - } - /* use drive/host constraint */ - cmd_buf = mms_strapp(cmd_buf, - "where \"DriveName\" = '%s' " - "and pg_host_ident(\"DMTargetHost\") " - "= pg_host_ident('%s');", - drive_name, - host); - } else { - /* use dm name constrant */ - cmd_buf = mms_strapp(cmd_buf, - "where \"DM\".\"DMName\" = '%s'", - dm_name); - } - if (mm_db_exec(HERE, db, cmd_buf) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error, mm_get_dm_status"); - free(cmd_buf); - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - return (NULL); - } - free(cmd_buf); - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, - "row num mismatch, " - "mm_get_drive_status"); - mm_clear_db(&db->mm_db_results); - return (NULL); - } - dm_status = (mm_dm_stat_t *)calloc(1, sizeof (mm_dm_stat_t)); - if (dm_status == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc dm_status"); - mm_clear_db(&db->mm_db_results); - return (NULL); - } - - dm_status->dm_stat_hard = mms_strapp(dm_status->dm_stat_hard, - PQgetvalue(db->mm_db_results, 0, 0)); - dm_status->dm_stat_soft = mms_strapp(dm_status->dm_stat_soft, - PQgetvalue(db->mm_db_results, 0, 1)); - dm_status->dm_stat_drive = mms_strapp(dm_status->dm_stat_drive, - PQgetvalue(db->mm_db_results, 0, 2)); - dm_status->dm_stat_disabled = mms_strapp(dm_status->dm_stat_disabled, - PQgetvalue(db->mm_db_results, 0, 3)); - dm_status->dm_stat_host = mms_strapp(dm_status->dm_stat_host, - PQgetvalue(db->mm_db_results, 0, 4)); - dm_status->dm_stat_name = mms_strapp(dm_status->dm_stat_name, - PQgetvalue(db->mm_db_results, 0, 5)); - mm_clear_db(&db->mm_db_results); - return (dm_status); - -} - -void -mm_print_drive_status(mm_drive_stat_t *drive_stat) { - mms_trace(MMS_DEVP, - "Drive Status for Drive, %s", - drive_stat->drive_stat_name); - mms_trace(MMS_DEVP, - " DriveDisabled = %s", - drive_stat->drive_stat_disabled); - mms_trace(MMS_DEVP, - " DriveBroken = %s", - drive_stat->drive_stat_broken); - mms_trace(MMS_DEVP, - " DriveStateSoft = %s", - drive_stat->drive_stat_soft); - mms_trace(MMS_DEVP, - " DriveStateHard = %s", - drive_stat->drive_stat_hard); - mms_trace(MMS_DEVP, - " DriveLibraryAccessible = %s", - drive_stat->drive_stat_lib_acc); - mms_trace(MMS_DEVP, - " ExclusiveAppName = %s", - drive_stat->drive_stat_excl_app); - mms_trace(MMS_DEVP, - " DriveOnline = %s", - drive_stat->drive_stat_online); - mms_trace(MMS_DEVP, - " DriveGroupName = %s", - drive_stat->drive_stat_group); - mms_trace(MMS_DEVP, - " LibraryName = %s", - drive_stat->drive_stat_library); - mms_trace(MMS_DEVP, - " DrivePriority = %s", - drive_stat->drive_stat_priority); - mms_trace(MMS_DEVP, - " DMName = %s", - drive_stat->drive_stat_dm); - mms_trace(MMS_DEVP, - " DriveGeometry = %s", - drive_stat->drive_stat_geometry); - mms_trace(MMS_DEVP, - " DriveSerialNum = %s", - drive_stat->drive_stat_serial); - mms_trace(MMS_DEVP, - " CartridgePCL = %s", - drive_stat->drive_stat_pcl); - mms_trace(MMS_DEVP, - " DriveLibraryOccupied = %s", - drive_stat->drive_stat_drvlib_occ); -} -void -mm_free_drive_status(mm_drive_stat_t *drive_stat) { - if (drive_stat == NULL) { - return; - } - if (drive_stat->drive_stat_name) - free(drive_stat->drive_stat_name); - if (drive_stat->drive_stat_hard) - free(drive_stat->drive_stat_hard); - if (drive_stat->drive_stat_disabled) - free(drive_stat->drive_stat_disabled); - if (drive_stat->drive_stat_soft) - free(drive_stat->drive_stat_soft); - if (drive_stat->drive_stat_library) - free(drive_stat->drive_stat_library); - if (drive_stat->drive_stat_lib_acc) - free(drive_stat->drive_stat_lib_acc); - if (drive_stat->drive_stat_group) - free(drive_stat->drive_stat_group); - if (drive_stat->drive_stat_excl_app) - free(drive_stat->drive_stat_excl_app); - if (drive_stat->drive_stat_broken) - free(drive_stat->drive_stat_broken); - if (drive_stat->drive_stat_online) - free(drive_stat->drive_stat_online); - if (drive_stat->drive_stat_priority) - free(drive_stat->drive_stat_priority); - if (drive_stat->drive_stat_dm) - free(drive_stat->drive_stat_dm); - if (drive_stat->drive_stat_geometry) - free(drive_stat->drive_stat_geometry); - if (drive_stat->drive_stat_serial) - free(drive_stat->drive_stat_serial); - if (drive_stat->drive_stat_pcl) - free(drive_stat->drive_stat_pcl); - if (drive_stat->drive_stat_drvlib_occ) - free(drive_stat->drive_stat_drvlib_occ); - free(drive_stat); -} - -mm_drive_stat_t * -mm_get_drive_status(char *drive_name, mm_db_t *db) { - mm_drive_stat_t *drive_status = NULL; - if (mm_db_exec(HERE, db, - "select " - "\"DRIVE\".\"DriveDisabled\", " - "\"DRIVE\".\"DriveBroken\", " - "\"DRIVE\".\"DriveStateSoft\", " - "\"DRIVE\".\"DriveLibraryAccessible\", " - "\"DRIVE\".\"ExclusiveAppName\", " - "\"DRIVE\".\"DriveOnline\", " - "\"DRIVE\".\"DriveGroupName\", " - "\"DRIVE\".\"DriveStateHard\", " - "\"DRIVE\".\"LibraryName\", " - "\"DRIVE\".\"DrivePriority\", " - "\"DRIVE\".\"DMName\", " - "\"DRIVE\".\"DriveGeometry\", " - "\"DRIVE\".\"DriveSerialNum\", " - "\"DRIVE\".\"CartridgePCL\", " - "\"DRIVE\".\"DriveLibraryOccupied\" " - "from \"DRIVE\" " - "where \"DriveName\" = '%s';", - drive_name) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error, mm_get_drive_status"); - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - return (NULL); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, - "row num mismatch, " - "mm_get_drive_status"); - mm_clear_db(&db->mm_db_results); - return (NULL); - } - drive_status = (mm_drive_stat_t *)calloc(1, sizeof (mm_drive_stat_t)); - if (drive_status == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc drive_status"); - return (NULL); - } - drive_status->drive_stat_name = - mms_strapp(drive_status->drive_stat_name, - drive_name); - drive_status->drive_stat_disabled = - mms_strapp(drive_status->drive_stat_disabled, - PQgetvalue(db->mm_db_results, 0, 0)); - drive_status->drive_stat_broken = - mms_strapp(drive_status->drive_stat_broken, - PQgetvalue(db->mm_db_results, 0, 1)); - drive_status->drive_stat_soft = - mms_strapp(drive_status->drive_stat_soft, - PQgetvalue(db->mm_db_results, 0, 2)); - drive_status->drive_stat_lib_acc = - mms_strapp(drive_status->drive_stat_lib_acc, - PQgetvalue(db->mm_db_results, 0, 3)); - drive_status->drive_stat_excl_app = - mms_strapp(drive_status->drive_stat_excl_app, - PQgetvalue(db->mm_db_results, 0, 4)); - drive_status->drive_stat_online = - mms_strapp(drive_status->drive_stat_online, - PQgetvalue(db->mm_db_results, 0, 5)); - drive_status->drive_stat_group = - mms_strapp(drive_status->drive_stat_group, - PQgetvalue(db->mm_db_results, 0, 6)); - drive_status->drive_stat_hard = - mms_strapp(drive_status->drive_stat_hard, - PQgetvalue(db->mm_db_results, 0, 7)); - drive_status->drive_stat_library = - mms_strapp(drive_status->drive_stat_library, - PQgetvalue(db->mm_db_results, 0, 8)); - drive_status->drive_stat_priority = - mms_strapp(drive_status->drive_stat_priority, - PQgetvalue(db->mm_db_results, 0, 9)); - drive_status->drive_stat_dm = - mms_strapp(drive_status->drive_stat_dm, - PQgetvalue(db->mm_db_results, 0, 10)); - drive_status->drive_stat_geometry = - mms_strapp(drive_status->drive_stat_geometry, - PQgetvalue(db->mm_db_results, 0, 11)); - drive_status->drive_stat_serial = - mms_strapp(drive_status->drive_stat_serial, - PQgetvalue(db->mm_db_results, 0, 12)); - drive_status->drive_stat_pcl = - mms_strapp(drive_status->drive_stat_pcl, - PQgetvalue(db->mm_db_results, 0, 13)); - drive_status->drive_stat_drvlib_occ = - mms_strapp(drive_status->drive_stat_drvlib_occ, - PQgetvalue(db->mm_db_results, 0, 14)); - - mm_clear_db(&db->mm_db_results); - return (drive_status); - -} - -void -mm_print_lm_status(mm_lm_stat_t *lm_stat) { - mms_trace(MMS_DEVP, - "LM Status for LM, %s", - lm_stat->lm_stat_name); - mms_trace(MMS_DEVP, - " LibraryName = %s", - lm_stat->lm_stat_library); - mms_trace(MMS_DEVP, - " LMStateHard = %s", - lm_stat->lm_stat_hard); - mms_trace(MMS_DEVP, - " LMStateSoft = %s", - lm_stat->lm_stat_soft); - mms_trace(MMS_DEVP, - " LMDisabled = %s", - lm_stat->lm_stat_disabled); -} - -void -mm_free_lm_status(mm_lm_stat_t *lm_stat) { - if (lm_stat == NULL) { - return; - } - if (lm_stat->lm_stat_name) - free(lm_stat->lm_stat_name); - if (lm_stat->lm_stat_hard) - free(lm_stat->lm_stat_hard); - if (lm_stat->lm_stat_disabled) - free(lm_stat->lm_stat_disabled); - if (lm_stat->lm_stat_soft) - free(lm_stat->lm_stat_soft); - if (lm_stat->lm_stat_library) - free(lm_stat->lm_stat_library); - free(lm_stat); -} -mm_lm_stat_t * -mm_get_lm_status(char *lm_name, mm_db_t *db) { - mm_lm_stat_t *lm_status = NULL; - if (mm_db_exec(HERE, db, - "select " - "\"LM\".\"LMStateHard\", " - "\"LM\".\"LMStateSoft\", " - "\"LM\".\"LMDisabled\", " - "\"LM\".\"LibraryName\" " - "from \"LM\" " - "where \"LMName\" = '%s';", - lm_name) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error, mm_get_lm_status"); - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - return (NULL); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, - "row num mismatch, " - "mm_get_lm_status"); - mm_clear_db(&db->mm_db_results); - return (NULL); - } - lm_status = (mm_lm_stat_t *)calloc(1, sizeof (mm_lm_stat_t)); - if (lm_status == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc lm_status"); - return (NULL); - } - lm_status->lm_stat_name = - mms_strapp(lm_status->lm_stat_name, - lm_name); - lm_status->lm_stat_hard = - mms_strapp(lm_status->lm_stat_hard, - PQgetvalue(db->mm_db_results, 0, 0)); - lm_status->lm_stat_soft = - mms_strapp(lm_status->lm_stat_soft, - PQgetvalue(db->mm_db_results, 0, 1)); - lm_status->lm_stat_disabled = - mms_strapp(lm_status->lm_stat_disabled, - PQgetvalue(db->mm_db_results, 0, 2)); - lm_status->lm_stat_library = - mms_strapp(lm_status->lm_stat_library, - PQgetvalue(db->mm_db_results, 0, 3)); - mm_clear_db(&db->mm_db_results); - return (lm_status); -} -void -mm_print_library_status(mm_lib_stat_t *lib_stat) { - mms_trace(MMS_DEVP, - "Library Status for Library, %s", - lib_stat->lib_stat_name); - mms_trace(MMS_DEVP, - " LibraryOnline = %s", - lib_stat->lib_stat_online); - mms_trace(MMS_DEVP, - " LibraryDisabled = %s", - lib_stat->lib_stat_disabled); - mms_trace(MMS_DEVP, - " LibraryBroken = %s", - lib_stat->lib_stat_broken); - mms_trace(MMS_DEVP, - " LMName = %s", - lib_stat->lib_stat_lm); -} - - -void -mm_free_library_status(mm_lib_stat_t *lib_stat) { - if (lib_stat == NULL) { - return; - } - if (lib_stat->lib_stat_name) - free(lib_stat->lib_stat_name); - if (lib_stat->lib_stat_online) - free(lib_stat->lib_stat_online); - if (lib_stat->lib_stat_disabled) - free(lib_stat->lib_stat_disabled); - if (lib_stat->lib_stat_broken) - free(lib_stat->lib_stat_broken); - if (lib_stat->lib_stat_lm) - free(lib_stat->lib_stat_lm); - free(lib_stat); -} -mm_lib_stat_t * -mm_get_library_status(char *library_name, mm_db_t *db) { - mm_lib_stat_t *library_status = NULL; - - if (mm_db_exec(HERE, db, - "select " - "\"LIBRARY\".\"LibraryOnline\", " - "\"LIBRARY\".\"LibraryDisabled\", " - "\"LIBRARY\".\"LibraryBroken\", " - "\"LIBRARY\".\"LMName\" " - "from \"LIBRARY\" " - "where \"LibraryName\" = '%s';", - library_name) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error, mm_get_library_status"); - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - return (NULL); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, - "row num mismatch, " - "mm_get_library_status"); - mm_clear_db(&db->mm_db_results); - return (NULL); - } - - library_status = (mm_lib_stat_t *)calloc(1, sizeof (mm_lib_stat_t)); - if (library_status == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc library_status"); - return (NULL); - } - library_status->lib_stat_name = - mms_strapp(library_status->lib_stat_name, - library_name); - library_status->lib_stat_online = - mms_strapp(library_status->lib_stat_online, - PQgetvalue(db->mm_db_results, 0, 0)); - library_status->lib_stat_disabled = - mms_strapp(library_status->lib_stat_disabled, - PQgetvalue(db->mm_db_results, 0, 1)); - library_status->lib_stat_broken = - mms_strapp(library_status->lib_stat_broken, - PQgetvalue(db->mm_db_results, 0, 2)); - library_status->lib_stat_lm = - mms_strapp(library_status->lib_stat_lm, - PQgetvalue(db->mm_db_results, 0, 3)); - mm_clear_db(&db->mm_db_results); - return (library_status); -} - - -static char * -mm_sql_get_ops(char *op) -{ - int x; - - for (x = 0; x < num_ops; x++) { - if (strcmp(opstab[x].sql_mmp_ops, op) == 0) { - return (opstab[x].sql_ops); - } - } - /* Not in table */ - return ("??UNKNOWN??"); -} - -int -mm_sql_chk_len(char **line, int off, int *bufsize, int len) -{ - char *new; - int new_bufsize; - - - if (off + len < *bufsize) { - return (0); - } - while (off + len > *bufsize) { - new_bufsize = *bufsize + SQL_CMD_BUF_INCR; - new = realloc(*line, new_bufsize); - if (new == NULL) { - return (-1); - } - *line = new; - *bufsize = new_bufsize; - } - return (0); -} - - -int -mm_notify_delete(mm_db_t *db, mm_command_t *cmd, char *objname, - int match_off) -{ - PGresult *results; - - int rows; - int row; - - - mms_trace(MMS_DEVP, "mm_notify_delete, object %s", objname); - - /* get object instance */ - if (mm_db_exec(HERE, db, "SELECT \"%sName\", \"%sTargetHost\"" - " FROM \"%s\" %s", objname, objname, - objname, &cmd->cmd_buf[match_off]) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - return (MM_CMD_ERROR); - } - - results = db->mm_db_results; - rows = PQntuples(results); - - if (rows == 0) { - mms_trace(MMS_DEVP, - "Didn't match any %s's for delete", objname); - mm_clear_db(&db->mm_db_results); - return (INTRP_OK); - } - for (row = 0; row < rows; row ++) { - mms_trace(MMS_DEVP, - "notify object %s instance %s", - objname, - PQgetvalue(results, row, 0)); - - if (mm_notify_add_config(cmd->wka_ptr, cmd, - EVENT_CFG_DELETE, - objname, - PQgetvalue(results, row, 0), - PQgetvalue(results, row, 1))) { - mms_trace(MMS_ERR, - "mm_notify_delete: " - "error adding config event"); - } - - } - - mm_clear_db(&db->mm_db_results); - return (INTRP_OK); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -} - - - -int -mm_sql_notify_inst(mm_db_t *db, mm_command_t *cmd, char *objname, - int match_off, char **objinst) -{ - PGresult *results = db->mm_db_results; - char *value; - - - - mms_trace(MMS_DEVP, "sql notify inst, object %s", objname); - - *objinst = NULL; - - /* get object instance */ - if (mm_db_exec(HERE, db, "SELECT \"%sName\" FROM \"%s\" %s", objname, - objname, &cmd->cmd_buf[match_off]) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - db->mm_db_results = results; - return (MM_CMD_ERROR); - } - - if (PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - db->mm_db_results = results; - return (INTRP_OK); - } - value = PQgetvalue(db->mm_db_results, 0, 0); - if (value[0] == '\0') { - *objinst = strdup("none"); /* none used for empty string */ - } else { - *objinst = strdup(value); - } - mm_clear_db(&db->mm_db_results); - db->mm_db_results = results; - if (objinst == NULL) { - MM_ABORT("object instance"); - return (MM_CMD_ERROR); - } - mms_trace(MMS_DEVP, "notify object %s instance %s", objname, *objinst); - return (INTRP_OK); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -} - -void -mm_sql_report_write_value(char **buf, PGresult *results, - int row, int col, mm_command_t *cmd, - int reportmode) { - - mm_db_t *db = &cmd->wka_ptr->mm_data->mm_db; - - /* 3 possible reportmode formatting */ - int name_rt = 1; - int value_rt = 2; - int namevalue_rt = 3; - - Oid oid; - char *value; - char *name; - - char date[24]; - int i; - int len; - - name = PQfname(results, col); - value = PQgetvalue(results, row, col); - oid = PQftype(results, col); - - /* database data types to mms string conversions */ - oid = PQftype(results, col); - if (oid == db->mm_db_cfg->mm_db_bool_oid) { - if (strcmp(value, "t") == 0) { - value = "true"; - } else if (strcmp(value, "f") == 0) { - value = "false"; - } - } else if (oid == db->mm_db_cfg->mm_db_timestamp_oid) { - if (strcmp(value, "-infinity") == 0) { - /* mms time not set */ - value = "0000 00 00 00 00 00 000"; - } else { - strcpy(date, value); - value = date; - /* mms UTC time format */ - value[4] = ' '; /* - */ - value[7] = ' '; /* - */ - value[13] = ' '; /* : */ - value[16] = ' '; /* : */ - if (value[19] == '\0') { - value[20] = '\0'; - } - value[19] = ' '; /* . */ - - - len = strlen(value); - for (i = len; i < 23; i++) { - value[i] = '0'; - } - value[23] = '\0'; - } - } - if ((reportmode == name_rt) || - (reportmode == namevalue_rt)) { - /* add name */ - *(buf) = mms_strapp(*(buf), - " \"%s\"", - name); - } - if ((reportmode == value_rt) || - (reportmode == namevalue_rt)) { - *(buf) = mms_strapp(*(buf), " \"%s\"", value); - } - return; - -} - - -char * -mm_sql_report_attr(mm_command_t *cmd, - int row, int *col_count, - int num_atts, int reportmode, - PGresult *results) { - - int col = *(col_count); - int start_col = *(col_count); - - char *attr_buf = NULL; - int print = 0; - - if (print) - mms_trace(MMS_DEVP, - "create attlist clause for row %d", - row); - /* print the attr list for row starting with col_count */ - attr_buf = mms_strapp(attr_buf, - "attrlist["); - /* LINTED: */ - for (col; col < (start_col + num_atts); col ++) { - mm_sql_report_write_value(&attr_buf, - results, row, - col, cmd, - reportmode); - } - attr_buf = mms_strapp(attr_buf, - "]"); - *(col_count) = col; - return (attr_buf); - -} - -char * -mm_sql_report_text_row(mm_command_t *cmd, - int row, PGresult *results, int reportmode, - mms_list_t *format) { - - mm_char_list_t *cur; - mm_char_list_t *next; - - char *text_buf = NULL; - char *attr_buf = NULL; - int col_count = 0; - - int print = 0; - - /* Create the text clause for the report in cmd */ - if (print) - mms_trace(MMS_DEVP, - "create text clause for row %d", - row); - - /* First bracket for this text clause */ - text_buf = mms_strapp(text_buf, "text["); - for (cur = mms_list_head(format); - cur != NULL; - cur = next) { - next = mms_list_next(format, cur); - if (cur->number == 0) { - /* Do data base format conversion */ - /* The function will write into text buf */ - mm_sql_report_write_value(&text_buf, - results, row, - col_count, cmd, - reportmode); - col_count ++; - } else { - /* This is an attrlist clause */ - if ((attr_buf = mm_sql_report_attr(cmd, - row, &col_count, - cur->number, reportmode, - results)) == NULL) { - mms_trace(MMS_ERR, - "error setting atr_buf"); - if (text_buf) - free(text_buf); - return (NULL); - } - text_buf = mms_strapp(text_buf, "%s", - attr_buf); - free(attr_buf); - - - } - } - - /* Trailing bracket for this text text */ - text_buf = mms_strapp(text_buf, "]"); - - return (text_buf); - - -} - - - -int -mm_sql_format_report(mm_command_t *cmd, mms_par_node_t *report, - mms_list_t *format) { - - mms_par_node_t *report_work; - mms_par_node_t *report_work_next; - mms_par_node_t *object; - mms_par_node_t *object_next; - - - /* 2 possible data types in report */ - int data_type; - int obj_att = 1; - int att_list = 2; - - char *cur_obj; - char *cur_attr; - - int print = 0; - int num_atts = 0; - mm_db_t *db = &cmd->wka_ptr->mm_data->mm_db; - - /* Create the text clause for the report in cmd */ - if (print) - mms_trace(MMS_DEVP, - "determine formatting for this report"); - - data_type = 0; - /* Need to use attr list for OBJECTS */ - report_work = NULL; - for (object = mms_pn_lookup(report, NULL, NULL, &report_work); - object != NULL; - object = mms_pn_lookup(report, NULL, NULL, &report_work)) { - if (object->pn_string != NULL) { - if (print) - mms_trace(MMS_DEVP, - "cur object is %s", - object->pn_string); - } - - if (object->pn_type == MMS_PN_OBJ) { - /* determine if attr list is needed */ - report_work_next = NULL; - report_work_next = report_work; - object_next = NULL; - object_next = - mms_pn_lookup(report, NULL, NULL, - &report_work_next); - - if ((object_next != NULL) && - (object_next->pn_type == MMS_PN_ATTR)) { - /* don't need an attrlist */ - /* set the obj name */ - /* The next object will be an attribute */ - if (print) - mms_trace(MMS_DEVP, - "set obj for obj.attr, %s", - object->pn_string); - cur_obj = object->pn_string; - } else { - /* Need attr list */ - /* Write all name/values for this obj */ - if (print) - mms_trace(MMS_DEVP, - "set obj for attr list, %s", - object->pn_string); - cur_obj = object->pn_string; - data_type = att_list; - } - } - if (object->pn_type == MMS_PN_ATTR) { - /* Write the name/value for this obj.att */ - if (print) - mms_trace(MMS_DEVP, - "set attr for obj.attr, %s", - object->pn_string); - cur_attr = object->pn_string; - data_type = obj_att; - } - - if (data_type == obj_att) { - data_type = 0; - /* This is an obj_att */ - (void) mm_add_int(0, format); - if (print) - mms_trace(MMS_DEVP, - "add 0 to int list %s.\"%s\"", - cur_obj, cur_attr); - - } - if (data_type == att_list) { - data_type = 0; - /* This is an attr list */ - /* Determine the number of attributes */ - if (print) - mms_trace(MMS_DEVP, - "set attr num for %s", - cur_obj); - - if (mm_db_exec(HERE, db, - "select * from \"%s\" limit 1;", - cur_obj) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error getting attribute number"); - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - return (1); - } - num_atts = PQnfields(db->mm_db_results); - if (print) - mms_trace(MMS_DEVP, - "attr num is %d for %s", - num_atts, - cur_obj); - (void) mm_add_int(num_atts, format); - mm_clear_db(&db->mm_db_results); - - } - - - - } - - /* done */ - return (0); - - - -} -int -mm_check_cmd_size(int header_length, char *text_clause, char *text_buf) { - - int buf_len; - int clause_len; - int char_size = sizeof (char); - - if (text_clause == NULL) { - /* is the 1st text clause, this must fit */ - return (0); - } - if (text_buf == NULL) { - return (0); - } - - buf_len = strlen(text_buf); - clause_len = strlen(text_clause); - - if ((char_size * (header_length + buf_len + clause_len)) > - MM_CMD_SIZE_LIMIT) { - mms_trace(MMS_DEVP, - "header len == %d, buf len == %d, " - "clause len == %d, total == %d, " - "LIMIT == %d", - header_length, buf_len, clause_len, - header_length + buf_len + clause_len, - MM_CMD_SIZE_LIMIT); - return (1); - } else { - return (0); - } -} - -static int -mm_sql_report(mm_command_t *cmd) -{ - mm_db_t *db = &cmd->wka_ptr->mm_data->mm_db; - mms_par_node_t *report; - mms_par_node_t *reportmode; - PGresult *results; - - int report_type = 2; - int name_rt = 1; - int namevalue_rt = 3; - - /* buf for whole response */ - char *resp_buf = NULL; - /* buf for multiple text clauses */ - char *text_buf = NULL; - /* buf for a single text clause */ - char *text_clause = NULL; - - int number_of_rows = 0; - int row; - - /* Report format */ - mms_list_t format; - - /* CMD size limit */ - int header_length; - - - mms_trace(MMS_DEVP, "sql report"); - - mms_list_create(&format, sizeof (mm_char_list_t), - offsetof(mm_char_list_t, mm_char_list_next)); - - if (mm_db_exec(HERE, db, "%s;", cmd->cmd_buf) != MM_DB_DATA) { - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - return (1); - } - if (PQresultStatus(db->mm_db_results) != PGRES_TUPLES_OK) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(ECLASS_INTERNAL) + strlen(EDATABASE) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_ERROR, cmd->cmd_task, - ECLASS_INTERNAL, EDATABASE); - return (1); - } - - number_of_rows = PQntuples(db->mm_db_results); - mms_trace(MMS_DEVP, "number of rows is %d", number_of_rows); - - /* Only return info user wants. The default is value only. */ - reportmode = mms_pn_lookup(cmd->cmd_root, "reportmode", - MMS_PN_CLAUSE, NULL); - - if (reportmode && mms_pn_lookup(reportmode, "name", - MMS_PN_KEYWORD, NULL)) { - report_type = name_rt; - } else if (reportmode && mms_pn_lookup(reportmode, "namevalue", - MMS_PN_KEYWORD, NULL)) { - report_type = namevalue_rt; - } else if (reportmode && mms_pn_lookup(reportmode, "number", - MMS_PN_KEYWORD, NULL)) { - /* Generate a the number report and return */ - text_buf = mms_strapp(text_buf, - "text[\"%d\"]", - number_of_rows); - if (cmd->cmd_buf != NULL) { - free(cmd->cmd_buf); - cmd->cmd_buf = NULL; - } - cmd->cmd_buf = mms_strapp(cmd->cmd_buf, - RESPONSE_SUCCESS_STR, - cmd->cmd_task, - text_buf); - free(text_buf); - mm_clear_db(&db->mm_db_results); - mms_trace(MMS_DEVP, "\n\n%s\n", cmd->cmd_buf); - return (0); - - } - - /* Build the text report */ - /* there will be a text clause for each of the rows */ - results = db->mm_db_results; - - report = mms_pn_lookup(cmd->cmd_root, "report", - MMS_PN_CLAUSE, NULL); - if (report == NULL) { - /* no report clause */ - /* there will be no text clause in response */ - number_of_rows = 0; - } else { - /* Determine the formatting for the entire report */ - if (mm_sql_format_report(cmd, report, &format)) { - mms_trace(MMS_ERR, - "error determineing report format"); - mm_system_error(cmd, - "error determineing report format"); - mm_clear_db(&results); - return (1); - } - } - if (number_of_rows != 0) { - /* There will be text clauses */ - header_length = strlen(RESPONSE_INTERMEDIATE) + - strlen(cmd->cmd_task); - mms_trace(MMS_DEVP, - "response header size is %d", - header_length); - } - - for (row = 0; row < number_of_rows; row++) { - text_clause = NULL; - - if ((text_clause = mm_sql_report_text_row(cmd, row, results, - report_type, - &format)) == NULL) { - mms_trace(MMS_ERR, - "error generating text clause"); - mm_system_error(cmd, - "error generating text clause"); - mm_clear_db(&results); - return (1); - - } - - /* Check the MM_CMD_SIZE_LIMIT */ - /* before appending the next text clause */ - /* this command may need intermediate packets */ - if (mm_check_cmd_size(header_length, text_clause, text_buf)) { - - mm_char_list_t *node; - - /* This text clause will push response over limit */ - mms_trace(MMS_DEVP, - "command size over the limit"); - /* add the curr text buf to the response list */ - if (resp_buf) - free(resp_buf); - resp_buf = NULL; - resp_buf = mms_strapp(resp_buf, RESPONSE_INTERMEDIATE, - cmd->cmd_task, - text_buf); - - node = - (mm_char_list_t *)malloc(sizeof (mm_char_list_t)); - if (node == NULL) { - mms_trace(MMS_ERR, - "Error malloc response object"); - mm_clear_db(&results); - return (1); - } else { - memset(node, 0, sizeof (mm_char_list_t)); - node->text = NULL; - node->text = resp_buf; - mms_list_insert_tail(&cmd->cmd_resp_list, node); - resp_buf = NULL; - } - - if (text_buf) - free(text_buf); - text_buf = NULL; - } - text_buf = mms_strapp(text_buf, - text_clause); - if (text_clause) - free(text_clause); - text_clause = NULL; - - } - - /* clean up formatting */ - mm_free_list(&format); - mms_list_destroy(&format); - - if (number_of_rows == 0) { - mm_char_list_t *node; - - /* add the curr text buf to the response list */ - if (resp_buf) - free(resp_buf); - resp_buf = NULL; - resp_buf = mms_strapp(resp_buf, RESPONSE_SUCCESS, - cmd->cmd_task); - - node = - (mm_char_list_t *)malloc(sizeof (mm_char_list_t)); - if (node == NULL) { - mms_trace(MMS_ERR, "Error malloc response object"); - mm_clear_db(&results); - return (1); - } else { - memset(node, 0, sizeof (mm_char_list_t)); - node->text = NULL; - node->text = resp_buf; - mms_list_insert_tail(&cmd->cmd_resp_list, node); - resp_buf = NULL; - } - - /* Set the success response with no text */ - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + - strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - } else { - mm_char_list_t *node; - /* add the curr text buf to the response list */ - if (resp_buf) - free(resp_buf); - resp_buf = NULL; - resp_buf = mms_strapp(resp_buf, RESPONSE_SUCCESS_STR, - cmd->cmd_task, - text_buf); - - node = (mm_char_list_t *)malloc(sizeof (mm_char_list_t)); - if (node == NULL) { - mms_trace(MMS_ERR, "Error malloc response object"); - mm_clear_db(&results); - return (1); - } else { - memset(node, 0, sizeof (mm_char_list_t)); - node->text = NULL; - node->text = resp_buf; - mms_list_insert_tail(&cmd->cmd_resp_list, node); - resp_buf = NULL; - } - - /* Set the success response with a text */ - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS_STR) + strlen(cmd->cmd_task) + - strlen(text_buf) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS_STR, cmd->cmd_task, text_buf); - } - - if (text_buf) - free(text_buf); - mm_clear_db(&results); - return (0); - -no_mem: - MM_ABORT_NO_MEM(); - return (1); - -} - - -static void -mm_sql_trans_volname(mm_command_t *cmd, int *offset) -{ - mms_par_node_t *volname; - mms_par_node_t *arg; - int off = *offset; - - - mms_trace(MMS_DEVP, "sql trans volname"); - MMS_PN_LOOKUP(volname, cmd->cmd_root, "volname", - MMS_PN_CLAUSE, NULL); - - SQL_CHK_LEN(&cmd->cmd_buf, off, &cmd->cmd_bufsize, 1); - off += snprintf(cmd->cmd_buf + off, cmd->cmd_bufsize - off, "("); - - mms_list_foreach(&volname->pn_arglist, arg) { - SQL_CHK_LEN(&cmd->cmd_buf, off, &cmd->cmd_bufsize, - 28 + strlen(arg->pn_string)); - off += snprintf(cmd->cmd_buf + off, cmd->cmd_bufsize - off, - "(\"VOLUME\".\"VolumeName\" = '%s')", - arg->pn_string); - if (arg != mms_list_tail(&volname->pn_arglist)) { - SQL_CHK_LEN(&cmd->cmd_buf, off, - &cmd->cmd_bufsize, 4); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, " OR "); - } - } - SQL_CHK_LEN(&cmd->cmd_buf, off, &cmd->cmd_bufsize, 1); - off += snprintf(cmd->cmd_buf + off, cmd->cmd_bufsize - off, ")"); - - *offset = off; - return; - -no_mem: - MM_ABORT_NO_MEM(); - return; - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - return; - -} - -int -mm_make_constraint_helper(mms_par_node_t *node, mm_command_t *cmd, - int num, char **buf, int *offset, - int *bufsize, int current, int reg_ex) { - - mms_par_node_t *arg; - mms_par_node_t *next_arg; - int off = *offset; - int b_size = *bufsize; - char *sql_ops; - const char *att_test; - char *att_cond; - char *obj; - char *att; - int cur = current; - int regex = reg_ex; - int twice = 0; - - - - mms_trace(MMS_DEVP, "constraint helper -> num -> %d " \ - " current -> %d", num, current); - - if (node->pn_string != NULL) { - mms_trace(MMS_DEVP, "1 Object is %s", node->pn_string); - if (strcmp(node->pn_string, "regex") == 0) { - regex = 1; - } - } - - if (*buf != NULL) { - mms_trace(MMS_DEVP, "1)%s", *buf); - - } - - - if (node->pn_type & MMS_PN_STRING) { - if (cur == num) { - - /* Could be numeric or null string or string. */ - if (node->pn_type == MMS_PN_NUMERIC) { - - SQL_CHK_LEN(buf, off, &b_size, - 1 + strlen(node->pn_string)); - off += snprintf(*buf + off, b_size - off, - "%s", node->pn_string); - - - } else if (node->pn_type & MMS_PN_NULLSTR) { - if (strcmp(*buf + off - 3, " = ") == 0) { - - off -= 2; /* backup over operator */ - SQL_CHK_LEN(buf, off, &b_size, 7); - off += snprintf(*buf + off, b_size - off, "ISNULL"); - - } else if (strcmp(*buf + off - 4, " <= ") == 0 || - strcmp(*buf + off - 4, " >= ") == 0) { - - off -= 3; /* backup over operator */ - SQL_CHK_LEN(buf, off, &b_size, 7); - off += snprintf(*buf + off, b_size - off, "ISNULL"); - - } else if (strcmp(*buf + off - 4, " <> ") == 0) { - - off -= 3; /* backup over operator */ - SQL_CHK_LEN(buf, off, &b_size, 8); - off += snprintf(*buf + off, b_size - off, "NOTNULL"); - } else { - SQL_CHK_LEN(buf, off, &b_size, - 1 + strlen(node->pn_string)); - off += snprintf(*buf + off, b_size - off, - "%s", node->pn_string); - } - } else { - SQL_CHK_LEN(buf, off, &b_size, - 3 + strlen(node->pn_string)); - off += snprintf(*buf + off, b_size - off, - "'%s'", node->pn_string); - } - } - if (!regex) - cur ++; - /* Just Worte a constraint value */ - } - - - if (node->pn_type == MMS_PN_OBJ) { - - /* An object-attribute */ - twice = 0; - if (cur == num) { - if (*buf != NULL) { - twice = 1; - } - SQL_CHK_LEN(buf, off, &b_size, - 4 + strlen(node->pn_string)); - off += snprintf(*buf + off, b_size - off, - "\"%s\".", node->pn_string); - } - arg = mms_list_head(&node->pn_arglist); - if (cur == num) { - SQL_CHK_LEN(buf, off, &b_size, - 3 + strlen(arg->pn_string)); - off += snprintf(*buf + off, b_size - off, - "\"%s\"", arg->pn_string); - if (regex) - cur ++; - if (twice) - cur ++; - } - - } else if (node->pn_flags & MMS_PN_MULTIOPS) { - - /* - * A multiops has two or more args hanging off the arglist. - * Insert the ops between the args by adding an arg, then add - * the ops and repeat until the last arg. - */ - if (node->pn_flags & MMS_PN_REGEX) { - - /* sql regular expression is at end of list */ - arg = mms_list_head(&node->pn_arglist); - mms_list_remove(&node->pn_arglist, arg); - mms_list_insert_tail(&node->pn_arglist, arg); - } - mms_list_foreach(&node->pn_arglist, arg) { - cur = mm_make_constraint_helper(arg, cmd, - num, buf, &off, - &b_size, cur, regex); - - if (arg != mms_list_tail(&node->pn_arglist)) { - - sql_ops = mm_sql_get_ops(node->pn_string); - if ((strcmp(sql_ops, "AND") == 0) || - (strcmp(sql_ops, "OR") == 0) || - (strcmp(sql_ops, "NOT") == 0) || - (strcmp(sql_ops, "ASC") == 0) || - /* LINTED: dont change */ - (strcmp(sql_ops, "DESC") == 0)) { - } else { - if (cur == num) { - SQL_CHK_LEN(buf, off, - &b_size, - 3 + strlen(sql_ops)); - off += snprintf(*buf + off, b_size - off, - " %s ", sql_ops); - } - } - } - - } - if (node->pn_flags & MMS_PN_REGEX) { - /* restore list to original order */ - arg = mms_list_tail(&node->pn_arglist); - mms_list_remove(&node->pn_arglist, arg); - mms_list_insert_head(&node->pn_arglist, arg); - } - } else if (node->pn_flags & MMS_PN_UNARYOPS) { - - /* Unary ops has only one arg */ - if (strcmp(node->pn_string, "isattr") == 0 || - strcmp(node->pn_string, "noattr") == 0) { - - att_test = "mm_obj_has_att('%s','%s') = '%s'"; - - if (strcmp(node->pn_string, "isattr") == 0) { - att_cond = "true"; - } else { - att_cond = "false"; - } - - arg = mms_list_head(&node->pn_arglist); - obj = arg->pn_string; - - next_arg = mms_list_head(&arg->pn_arglist); - att = next_arg->pn_string; - if (cur == num) { - SQL_CHK_LEN(buf, off, &b_size, - strlen(att_test) + 1); - off += snprintf(*buf + off, b_size - off, - att_test, obj, att, att_cond); - } - } else { - sql_ops = mm_sql_get_ops(node->pn_string); - if (cur == num) { - SQL_CHK_LEN(buf, off, &b_size, - strlen(sql_ops) + 3); - off += snprintf(*buf + off, b_size - off, - " %s ", sql_ops); - } - arg = mms_list_head(&node->pn_arglist); - cur = mm_make_constraint_helper(arg, cmd, - num, buf, &off, - &b_size, cur, regex); - } - } - *offset = off; - *bufsize = b_size; - - return (cur); - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -not_found: - - return (MM_CMD_ERROR); -} - -char * -mm_make_constraint(mm_command_t *cmd, int num) { - char *object; - char *buf = NULL; - mms_par_node_t *match; - mms_par_node_t *node; - int off = 0; - int bufsize = 0; - int cur = 0; - - - mms_trace(MMS_DEBUG, "mm_make_constraint"); - - object = (char *)mm_return_char(&cmd->cmd_dest_list, num); - - - match = mms_pn_lookup(cmd->cmd_root, "match", - MMS_PN_CLAUSE, NULL); - if (match == NULL) { - return (NULL); - } - - - mms_list_foreach(&match->pn_arglist, node) { - - mms_trace(MMS_DEVP, "examing a node..."); - - off = 0; - bufsize = 0; - cur = mm_make_constraint_helper(node, cmd, num, &buf, &off, - &bufsize, cur, 0); - - mms_trace(MMS_DEVP, "After helper..."); - - } - if (buf != NULL) { - mms_trace(MMS_DEVP, "Final Constraint for %s -> %s", - object, buf); - } else { - mms_trace(MMS_DEVP, "Final for %s is NULL", - object); - return (NULL); - } - - return (buf); -} -int -mm_use_and_or(mm_command_t *cmd) { - /* - * return 1 if the operator is 'and' - * between constraints with indexes 'idx1' and 'idx2' - * return 0 if the operator is 'or' - */ - mms_par_node_t *match; - mms_par_node_t *node; - int oper = 1; - - match = mms_pn_lookup(cmd->cmd_root, "match", - MMS_PN_CLAUSE, NULL); - if (match == NULL) { - return (NULL); - } - - - mms_list_foreach(&match->pn_arglist, node) { - - mms_trace(MMS_DEVP, "examing a node..."); - if (node->pn_string != NULL) { - mms_trace(MMS_DEVP, " Node is %s", node->pn_string); - if (strcmp(node->pn_string, "and") == 0) { - oper = 1; - } - if (strcmp(node->pn_string, "or") == 0) { - oper = 0; - } - } - - } - return (oper); -} - -int -mm_sql_report_func(mm_command_t *cmd, mm_db_t *db) { - char *buf = NULL; - mm_path_t *path = NULL; - char *joined[100]; - int joined_count = 0; - int skip = 0; - int wrote_one = 0; - - char *source_buf; - char *dest_buf; - char *savepoint = NULL; - - int print_message = 0; - int i; - int y; - int j; - int k; - int x; - int l; - - mms_trace(MMS_DEBUG, "mm_sql_make_sql_func"); - - for (y = 0; y < 100; y ++) { - joined[y] = NULL; - } - - /* create report functins for each report onject */ - for (i = 0; i < cmd->cmd_source_num; i ++) { /* source */ - joined_count = 0; - /* Make report_n() for this source */ - - source_buf = - (char *)mm_return_char(&cmd->cmd_source_list, i); - buf = mms_strapp(buf, - "CREATE OR REPLACE FUNCTION "\ - "report_%d_%d() RETURNS SETOF \"%s\" AS $$\n", - i, db->mm_db_fd, source_buf); - buf = mms_strapp(buf, - "select distinct \"%s\".* from \"%s\" ", - source_buf, - source_buf); - joined_count = 0; - joined[0] = NULL; - joined[0] = mms_strapp(joined[0], source_buf); - - - joined_count ++; - for (j = 0; j < cmd->cmd_dest_num; j ++) { - dest_buf = - (char *)mm_return_char(&cmd->cmd_dest_list, j); - - if (print_message) { - mms_trace(MMS_DEVP, " 1) Dest %d -> %s", - j, dest_buf); - - mms_trace(MMS_DEVP, "mm_get_path(%s, %s)", - dest_buf, - source_buf); - } - - - if ((path = mm_get_path(dest_buf, - source_buf)) == NULL) { - mms_trace(MMS_DEVP, "Path is NULL, %s to %s", - dest_buf, - source_buf); - - } else { - for (k = 0; k < path->mm_node_num; k++) { - skip = 0; - for (x = 0; x < joined_count; x++) { - - if (strcmp(joined[x], - path->mm_node[k]->mm_obj) == 0) { - /* same so skip */ - skip = 1; - } - } - if (!skip) { - buf = mms_strapp(buf, - "\ncross join \"%s\" ", - path->mm_node[k]->mm_obj); - - joined[joined_count] = NULL; - joined[joined_count] = - mms_strapp(joined[joined_count], - path->mm_node[k]->mm_obj); - joined_count ++; - } - } - } - - } - - if (cmd->cmd_dest_num == 0) { - buf = mms_strapp(buf, - ";\n"); - } - - for (j = 0; j < cmd->cmd_dest_num; j ++) { - /* j cmd_dest_num */ - if (j == 0) { - buf = mms_strapp(buf, - "\nwhere \n(\n"); - } - dest_buf = - (char *)mm_return_char(&cmd->cmd_dest_list, j); - if (print_message) { - mms_trace(MMS_DEVP, " 2) Dest %d -> %s", - j, dest_buf); - mms_trace(MMS_DEVP, "mm_get_path(%s, %s)", - dest_buf, - source_buf); - } - - if ((path = mm_get_path(dest_buf, - source_buf)) == NULL) { - - if (strcmp(dest_buf, - source_buf) == 0) { - /* same object */ - buf = mms_strapp(buf, "(true)\n"); - wrote_one = 1; - } else { - /* no path between */ - buf = mms_strapp(buf, "(false)\n"); - wrote_one = 1; - } - - } else { - - - for (k = path->mm_node_num - 1; k >= 0; k--) { - /* node[%d] has %d edges, k, */ - /* path->mm_node[k]->mm_edge_num */ - for (l = 0; - l < path->mm_node[k]->mm_edge_num; - l++) { - /* - * if (path->mm_node[k]-> - * mm_edge[l]->mm_ref_att != NULL) { - * - * } - */ - /* add this edge constraint */ - wrote_one = 1; - if (k == path->mm_node_num - 1) { - buf = mms_strapp(buf, - "(\"%s\".", - source_buf); - } else { - buf = mms_strapp(buf, - "(\"%s\".", - path->mm_node - [k+1]->mm_obj); - } - if (path->mm_node[k]-> - mm_edge[l]->mm_ref_att == NULL) { - buf = mms_strapp(buf, - "\"%s\" = ", - path->mm_node[k]-> - mm_edge[l]->mm_att); - } else { - buf = mms_strapp(buf, - "\"%s\" = ", - path->mm_node[k]-> - mm_edge[l]->mm_ref_att); - } - buf = mms_strapp(buf, - "\"%s\".\"%s\")\n", - path->mm_node[k]->mm_obj, - path->mm_node[k]-> - mm_edge[l]->mm_att); - - if (l+1 < path->mm_node[k]-> - mm_edge_num) { - buf = mms_strapp(buf, "and\n"); - } - - } - - - if (k - 1 >= 0) { - buf = mms_strapp(buf, "and\n"); - } - - } - - } - if (j + 1 < cmd->cmd_dest_num) { - buf = mms_strapp(buf, "and\n"); - } - - - - if (j + 1 == cmd->cmd_dest_num) { - int p; - /* Add all constraints here */ - - for (p = 0; - p < cmd->cmd_const_num; - p ++) { - if (p == 0) { - if (wrote_one) - buf = mms_strapp(buf, - "and\n(\n"); - } - buf = mms_strapp(buf, - (char *) - mm_return_char(&cmd-> - cmd_const_list, p)); - if (p+1 < cmd->cmd_const_num) { - buf = - mms_strapp(buf, - "and\n"); - } - if (p + 1 == - cmd->cmd_const_num) { - /* parenn for constraints */ - buf = mms_strapp(buf, ")\n"); - } - } - /* paren for where ( */ - if (wrote_one) { - buf = mms_strapp(buf, - ");\n"); - } else { - buf = mms_strapp(buf, - ";\n"); - } - } - - } - - - buf = mms_strapp(buf, - "$$ LANGUAGE SQL;\n"); - - savepoint = mms_strnew("report_%d_%d", i, db->mm_db_fd); - if (mm_db_txn_savepoint(db, savepoint) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_sql_report_func: " - "db error setting savepoint"); - } - if (mm_db_exec(HERE, db, "drop function report_%d_%d();", i, - db->mm_db_fd) != - MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - if (mm_db_txn_savepoint_rollback(db, - savepoint) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_sql_report_func: " - "db error rollingback savepoint"); - } - } - if (mm_db_txn_release_savepoint(db, - savepoint) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_sql_report_func: " - "db error releaseing savepoint"); - } - free(savepoint); - - if (mm_db_exec(HERE, db, buf) != MM_DB_OK) { - mms_trace(MMS_ERR, "Error adding path match function"); - mm_sql_db_err_rsp_new(cmd, db); - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - free(buf); - return (1); - } - free(buf); - buf = NULL; - - for (y = 0; y < joined_count; y ++) { - free(joined[y]); - joined[y] = NULL; - } - - - } - return (0); - -} - -int -mm_sql_report_func_attr(mm_command_t *cmd) { - char *buf = NULL; - char *order_buf = NULL; - mm_path_t *path = NULL; - char *joined[100]; - int joined_count = 0; - int skip = 0; - mm_db_t *db = &cmd->cmd_mm_data->mm_db; - int wrote_one = 0; - char *temp_buf = NULL; - char *savepoint = NULL; - - char *source_buf; - char *dest_buf; - int y; - int j; - int k; - int x; - int l; - int p; - int i; - - mms_trace(MMS_DEBUG, "mm_sql_make_sql_func_attr"); - - for (y = 0; y < 100; y ++) { - joined[y] = NULL; - } - - /* create report functins for each report onject */ - for (i = 0; i < cmd->cmd_source_num; i ++) { /* source */ - joined_count = 0; - - /* Make report_n() for this source */ - - source_buf = - (char *)mm_return_char(&cmd->cmd_source_list, i); - buf = mms_strapp(buf, - "CREATE OR REPLACE FUNCTION "\ - "report_%d_%d() RETURNS SETOF \"%s\" AS $$\n", - i, db->mm_db_fd, source_buf); - buf = mms_strapp(buf, - "select distinct \"%s\".* from \"%s\" ", - source_buf, - source_buf); - joined_count = 0; - joined[0] = NULL; - joined[0] = mms_strapp(joined[0], source_buf); - - - joined_count ++; - for (j = 0; j < cmd->cmd_dest_num; j ++) { - dest_buf = - (char *)mm_return_char(&cmd->cmd_dest_list, j); - - if ((path = mm_get_path(dest_buf, - source_buf)) == NULL) { - mms_trace(MMS_DEVP, "Path is NULL, %s to %s", - dest_buf, - source_buf); - - } else { - for (k = 0; k < path->mm_node_num; k++) { - skip = 0; - for (x = 0; x < joined_count; x++) { - if (strcmp(joined[x], - path->mm_node[k]->mm_obj) == 0) { - /* same so skip */ - skip = 1; - } - } - if (!skip) { - buf = mms_strapp(buf, - "\ncross join \"%s\" ", - path->mm_node[k]->mm_obj); - joined[joined_count] = NULL; - joined[joined_count] = - mms_strapp(joined[joined_count], - path->mm_node[k]->mm_obj); - joined_count ++; - } - } - } - - } - - order_buf = mm_sql_order_buf(cmd); - buf = mms_strapp(buf, order_buf); - if (order_buf != NULL) - free(order_buf); - - for (j = 0; j < cmd->cmd_dest_num; j ++) { - dest_buf = - (char *)mm_return_char(&cmd->cmd_dest_list, j); - /* j cmd_dest_num */ - if (j == 0) { - buf = mms_strapp(buf, - "\nwhere \n(\n"); - - } - - if ((path = mm_get_path(dest_buf, - source_buf)) == NULL) { - - if (strcmp(dest_buf, - source_buf) == 0) { - /* same object */ - buf = mms_strapp(buf, "(true)\n"); - wrote_one = 1; - } else { - /* no path between */ - buf = mms_strapp(buf, "(false)\n"); - wrote_one = 1; - } - - } else { - - - for (k = path->mm_node_num - 1; k >= 0; k--) { - - for (l = 0; - l < path->mm_node[k]->mm_edge_num; - l++) { - /* - * if (path->mm_node[k]-> - * mm_edge[l]->mm_ref_att != NULL) { - * - * } - */ - - /* add this edge constraint */ - wrote_one = 1; - if (k == path->mm_node_num - 1) { - buf = mms_strapp(buf, - "(\"%s\".", - source_buf); - } else { - buf = mms_strapp(buf, - "(\"%s\".", - path->mm_node - [k+1]->mm_obj); - } - if (path->mm_node[k]-> - mm_edge[l]->mm_ref_att == NULL) { - buf = mms_strapp(buf, - "\"%s\" = ", - path->mm_node[k]-> - mm_edge[l]->mm_att); - } else { - buf = mms_strapp(buf, - "\"%s\" = ", - path->mm_node[k]-> - mm_edge[l]->mm_ref_att); - } - buf = mms_strapp(buf, - "\"%s\".\"%s\")\n", - path->mm_node[k]->mm_obj, - path->mm_node[k]-> - mm_edge[l]->mm_att); - - if (l+1 < path->mm_node[k]-> - mm_edge_num) { - buf = mms_strapp(buf, "and\n"); - } - - } - - - if (k - 1 >= 0) { - buf = mms_strapp(buf, "and\n"); - } - - } - - } - if (j + 1 < cmd->cmd_dest_num) { - buf = mms_strapp(buf, "and\n"); - } - - - - if (j + 1 == cmd->cmd_dest_num) { - /* Add all constraints here */ - - for (p = 0; - p < cmd->cmd_const_num; - p ++) { - if (p == 0) { - if (wrote_one) - buf = mms_strapp(buf, - "and\n(\n"); - } - buf = mms_strapp(buf, - (char *) - mm_return_char(&cmd-> - cmd_const_list, p)); - if (p+1 < cmd->cmd_const_num) { - buf = - mms_strapp(buf, - "and\n"); - } - if (p + 1 == - cmd->cmd_const_num) { - /* parenn for constraints */ - buf = mms_strapp(buf, ")\n"); - } - } - - /* paren for where ( */ - if (wrote_one) { - buf = mms_strapp(buf, - ")\n"); - } else { - buf = mms_strapp(buf, - "\n"); - } - } - - } - - temp_buf = mms_strapp(temp_buf, mm_sql_number_buf(cmd)); - if (temp_buf != NULL) { - buf = mms_strapp(buf, temp_buf); - free(temp_buf); - } - - buf = mms_strapp(buf, - " ; $$ LANGUAGE SQL;\n"); - - - savepoint = mms_strnew("report_%d_%d", i, db->mm_db_fd); - if (mm_db_txn_savepoint(db, - savepoint) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_sql_report_func_attr: " - "db error setting savepoint"); - } - if (mm_db_exec(HERE, db, "drop function report_%d_%d();", i, - db->mm_db_fd) != - MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - if (mm_db_txn_savepoint_rollback(db, - savepoint) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_sql_report_func_attr: " - "db error setting savepoint"); - } - } - if (mm_db_txn_release_savepoint(db, - savepoint) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_sql_report_func_attr: " - "db error releaseing savepoint"); - } - free(savepoint); - - if (mm_db_exec(HERE, db, buf) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - mms_trace(MMS_ERR, "Error adding path match function"); - return (1); - } - free(buf); - buf = NULL; - - for (y = 0; y < joined_count; y ++) { - free(joined[y]); - joined[y] = NULL; - } - - - } - return (0); -} - - -int -mm_sql_from_where(mm_command_t *cmd, mm_db_t *db) -{ - char *buf = NULL; - char *final_buf = NULL; - mm_path_t *path = NULL; - char *joined[100]; - int joined_count = 0; - int skip = 0; - mm_pkey_t *p_key = NULL; - - char *source_buf_i; - char *source_buf_j; - int y; - int i; - int j; - int k; - int x; - int l; - - mms_trace(MMS_DEVP, "mm_sql_from_where"); - - for (y = 0; y < 100; y ++) { - joined[y] = NULL; - } - /* Generate all report_n() for this command */ - - if (mm_sql_report_func(cmd, db)) { - mms_trace(MMS_ERR, - "error creating report funcs"); - return (1); - } - - joined_count = 0; - - for (i = 0; i < cmd->cmd_source_num; i ++) { - - /* - * ex, i = 0 - * report_0() t0, "DM" - * t0 is arbitrary table alias - */ - source_buf_i = (char *)mm_return_char(&cmd->cmd_source_list, i); - buf = mms_strapp(buf, - "\nreport_%d_%d() t%d, \"%s\" ", - i, db->mm_db_fd, i, source_buf_i); - joined[i] = NULL; - joined[i] = mms_strapp(joined[i], - source_buf_i); - joined_count ++; - - if (i+1 < cmd->cmd_source_num) { - buf = mms_strapp(buf, - "cross join "); - } - } - - /* Add objects to FROM clause */ - /* add implied constraints between source objects */ - - - for (i = 0; i < cmd->cmd_source_num; i ++) { - source_buf_i = (char *)mm_return_char(&cmd->cmd_source_list, i); - for (j = i+1; j < cmd->cmd_source_num; j ++) { - source_buf_j = (char *) - mm_return_char(&cmd->cmd_source_list, j); - if ((path = mm_get_path(source_buf_j, - source_buf_i)) != NULL) { - - for (k = 0; k < path->mm_node_num; k++) { - skip = 0; - for (x = 0; x < joined_count; x++) { - - if (strcmp(joined[x], - path->mm_node[k]-> - mm_obj) == 0) { - /* same so skip */ - skip = 1; - } - } - if (!skip) { - buf = mms_strapp(buf, - "\ncross join \n\"%s\" ", - path->mm_node[k]->mm_obj); - - joined[joined_count] = NULL; - joined[joined_count] = - mms_strapp(joined[joined_count], - path->mm_node[k]->mm_obj); - joined_count ++; - } - - } - } - - } - } - - buf = mms_strapp(buf, "\nwhere \n(\n"); - - for (i = 0; i < cmd->cmd_source_num; i ++) { - source_buf_i = (char *)mm_return_char(&cmd->cmd_source_list, i); - p_key = mm_get_pkey(source_buf_i); - for (j = 0; j < p_key->mm_att_num; j ++) { - buf = mms_strapp(buf, - "(t%d.\"%s\" = \"%s\".\"%s\")\n", - i, p_key->mm_att[j], source_buf_i, - p_key->mm_att[j]); - if (j+1 < p_key->mm_att_num) { - buf = mms_strapp(buf, "and\n"); - } - } - if (i+1 < cmd->cmd_source_num) { - buf = mms_strapp(buf, "and\n"); - } - } - - - /* Now add the implied path constraints */ - - for (i = 0; i < cmd->cmd_source_num; i ++) { - source_buf_i = (char *)mm_return_char(&cmd->cmd_source_list, i); - for (j = i+1; j < cmd->cmd_source_num; j ++) { - source_buf_j = (char *) - mm_return_char(&cmd->cmd_source_list, j); - if ((path = mm_get_path(source_buf_j, - source_buf_i)) != NULL) { - for (k = path->mm_node_num - 1; k >= 0; k--) { - for (l = 0; - l < path->mm_node[k]->mm_edge_num; - l++) { - /* - * if (path->mm_node[k]-> - * mm_edge[l]->mm_ref_att != NULL) { - * - * } - */ - - /* add this edge constraint */ - /* will always need an 'and' */ - buf = mms_strapp(buf, "and\n"); - if (k == path->mm_node_num - 1) { - buf = mms_strapp(buf, - "(\"%s\".", - source_buf_i); - } else { - buf = mms_strapp(buf, - "(\"%s\".", - path->mm_node - [k+1]->mm_obj); - } - if (path->mm_node[k]-> - mm_edge[l]->mm_ref_att == NULL) { - buf = mms_strapp(buf, - "\"%s\" = ", - path->mm_node[k]-> - mm_edge[l]->mm_att); - } else { - buf = mms_strapp(buf, - "\"%s\" = ", - path->mm_node[k]-> - mm_edge[l]->mm_ref_att); - } - buf = mms_strapp(buf, - "\"%s\".\"%s\")\n", - path->mm_node[k]->mm_obj, - path->mm_node[k]-> - mm_edge[l]->mm_att); - } - } - } - } - } - - buf = mms_strapp(buf, ")\n"); - - final_buf = mms_strapp(final_buf, cmd->cmd_buf); - final_buf = mms_strapp(final_buf, buf); - - SQL_CHK_LEN(&cmd->cmd_buf, NULL, - &cmd->cmd_bufsize, strlen(final_buf) + 1); - strcpy(cmd->cmd_buf, final_buf); - - - for (y = 0; y < joined_count; y ++) { - free(joined[y]); - joined[y] = NULL; - } - free(buf); - free(final_buf); - return (0); - -no_mem: - MM_ABORT_NO_MEM(); - return (1); - - -} - - - -int -mm_attribute_match(mm_command_t *cmd) { - - char *buf = NULL; - mm_db_t *db = &cmd->cmd_mm_data->mm_db; - mm_pkey_t *p_key = NULL; - - int j; - int i; - - char *source_buf_0; - - mms_trace(MMS_DEBUG, "mm_attribute_match"); - buf = mms_strapp(buf, cmd->cmd_buf); - mms_trace(MMS_DEVP, "buf is %s", - buf); - - buf = mms_strapp(buf, "\nwhere\n"); - /* get pkey for this source */ - source_buf_0 = (char *)mm_return_char(&cmd->cmd_source_list, 0); - p_key = mm_get_pkey(source_buf_0); - buf = mms_strapp(buf, "(\n"); - - for (j = 0; j < p_key->mm_att_num; j ++) { - buf = mms_strapp(buf, - "(\"%s\".\"%s\" in \n", - source_buf_0, - p_key->mm_att[j]); - buf = mms_strapp(buf, - "(select \"%s\".\"%s\" from "\ - "report_0_%d() t%d, \"%s\" where\n", - source_buf_0, - p_key->mm_att[j], - db->mm_db_fd, - j, - source_buf_0); - - buf = mms_strapp(buf, "(\n"); - for (i = 0; i < p_key->mm_att_num; i ++) { - - buf = mms_strapp(buf, - "(t%d.\"%s\" = \"%s\".\"%s\") ", - j, - p_key->mm_att[i], - source_buf_0, - p_key->mm_att[i]); - - if (i+1 < p_key->mm_att_num) { - buf = mms_strapp(buf, "and\n"); - } - } - buf = mms_strapp(buf, ")\n"); - buf = mms_strapp(buf, ")\n"); - buf = mms_strapp(buf, ")\n"); - if (j+1 < p_key->mm_att_num) { - buf = mms_strapp(buf, "and\n"); - } - } - - buf = mms_strapp(buf, ")\n"); - - - SQL_CHK_LEN(&cmd->cmd_buf, NULL, - &cmd->cmd_bufsize, strlen(buf) + 1); - strcpy(cmd->cmd_buf, buf); - - free(buf); - - return (INTRP_OK); - - - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); - -} - -static int -mm_sql_trans_match_exp(mms_par_node_t *node, mm_command_t *cmd, - int *offset, int host_ident) -{ - mms_par_node_t *arg; - mms_par_node_t *next_arg; - int off = *offset; - char *sql_ops; - const char *att_test; - char *att_cond; - char *obj; - char *att; - - int need_int_cast = 0; - int need_host_ident = 0; - - int print_message = 0; - - mms_trace(MMS_DEVP, "sql trans match exp"); - if (cmd->cmd_buf != NULL) { - if (print_message) - mms_trace(MMS_DEVP, - " cmdbuf == %s", - cmd->cmd_buf); - } else { - if (print_message) - mms_trace(MMS_DEVP, - " cmd_buf is NULL"); - } - - if (node->pn_type & MMS_PN_STRING) { - if (print_message) - mms_trace(MMS_DEVP, - " (node->pn_type & MMS_PN_STRING)"); - - /* Could be numeric or null string or string. */ - if (node->pn_type == MMS_PN_NUMERIC) { - SQL_CHK_LEN(&cmd->cmd_buf, off, &cmd->cmd_bufsize, - 1 + strlen(node->pn_string)); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, - "%s", node->pn_string); - } else if (node->pn_type & MMS_PN_NULLSTR) { - /* Still support NULLSTR ?? */ - if (strcmp(&cmd->cmd_buf[off - 3], " = ") == 0) { - off -= 2; /* backup over operator */ - SQL_CHK_LEN(&cmd->cmd_buf, - off, &cmd->cmd_bufsize, 7); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, "ISNULL"); - } else if (strcmp(&cmd->cmd_buf[off - 4], - " <= ") == 0 || - strcmp(&cmd->cmd_buf[off - 4], - " >= ") == 0) { - off -= 3; /* backup over operator */ - SQL_CHK_LEN(&cmd->cmd_buf, off, - &cmd->cmd_bufsize, 7); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, "ISNULL"); - } else if (strcmp(&cmd->cmd_buf[off - 4], - " <> ") == 0) { - off -= 3; /* backup over operator */ - SQL_CHK_LEN(&cmd->cmd_buf, off, - &cmd->cmd_bufsize, 8); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, "NOTNULL"); - } else { - SQL_CHK_LEN(&cmd->cmd_buf, - off, &cmd->cmd_bufsize, - 1 + strlen(node->pn_string)); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, - "%s", node->pn_string); - } - } else { - if (host_ident) { - SQL_CHK_LEN(&cmd->cmd_buf, off, - &cmd->cmd_bufsize, 15); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, - "pg_host_ident("); - } - SQL_CHK_LEN(&cmd->cmd_buf, off, &cmd->cmd_bufsize, - 3 + strlen(node->pn_string)); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, - "'%s'", node->pn_string); - if (host_ident) { - SQL_CHK_LEN(&cmd->cmd_buf, off, - &cmd->cmd_bufsize, 2); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, ")"); - } - } - - } - - if (node->pn_type == MMS_PN_OBJ) { - if (print_message) - mms_trace(MMS_DEVP, - " node->pn_type == MMS_PN_OBJ"); - - /* An object-attribute */ - if (cmd->cmd_notify_to == 1) { - SQL_CHK_LEN(&cmd->cmd_buf, off, &cmd->cmd_bufsize, - 2 + strlen("NEW")); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, "%s.", "NEW"); - } else { - SQL_CHK_LEN(&cmd->cmd_buf, off, &cmd->cmd_bufsize, - 4 + strlen(node->pn_string)); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, - "\"%s\".", node->pn_string); - } - arg = mms_list_head(&node->pn_arglist); - SQL_CHK_LEN(&cmd->cmd_buf, off, &cmd->cmd_bufsize, - 3 + strlen(arg->pn_string)); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, - "\"%s\"", arg->pn_string); - } else if (node->pn_flags & MMS_PN_MULTIOPS) { - - if (print_message) - mms_trace(MMS_DEVP, - "(node->pn_flags & MMS_PN_MULTIOPS)"); - if (node->pn_string != NULL) { - if ((strcmp(node->pn_string, - "numeq") == 0) || - (strcmp(node->pn_string, - "numne") == 0) || - (strcmp(node->pn_string, - "numlt") == 0) || - (strcmp(node->pn_string, - "numle") == 0) || - (strcmp(node->pn_string, - "numgt") == 0) || - (strcmp(node->pn_string, - "numge") == 0)) { - SQL_CHK_LEN(&cmd->cmd_buf, off, - &cmd->cmd_bufsize, 6); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, "int4("); - need_int_cast = 1; - } - if (print_message) - mms_trace(MMS_DEVP, - " %s", - node->pn_string); - if ((strcmp(node->pn_string, - "hosteq") == 0) || - (strcmp(node->pn_string, - "hostne") == 0)) { - SQL_CHK_LEN(&cmd->cmd_buf, off, - &cmd->cmd_bufsize, 15); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, - "pg_host_ident("); - need_int_cast = 1; - need_host_ident = 1; - } - } - - /* - * A multiops has two or more args hanging off the arglist. - * Insert the ops between the args by adding an arg, then add - * the ops and repeat until the last arg. - */ - if (node->pn_flags & MMS_PN_REGEX) { - /* sql regular expression is at end of list */ - arg = mms_list_head(&node->pn_arglist); - mms_list_remove(&node->pn_arglist, arg); - mms_list_insert_tail(&node->pn_arglist, arg); - } - mms_list_foreach(&node->pn_arglist, arg) { - if (arg->pn_type == MMS_PN_OPS) { - SQL_CHK_LEN(&cmd->cmd_buf, off, - &cmd->cmd_bufsize, 2); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, "("); - } - - if (mm_sql_trans_match_exp(arg, cmd, - &off, need_host_ident)) { - mms_trace(MMS_ERR, - "mm_sql_trans_match_exp: " - "error translating match expression"); - return (1); - } - if (arg->pn_type == MMS_PN_OPS) { - SQL_CHK_LEN(&cmd->cmd_buf, off, - &cmd->cmd_bufsize, 2); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, ")"); - } - if (need_int_cast) { - SQL_CHK_LEN(&cmd->cmd_buf, off, - &cmd->cmd_bufsize, 2); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, ")"); - need_int_cast = 0; - } - if (arg != mms_list_tail(&node->pn_arglist)) { - sql_ops = mm_sql_get_ops(node->pn_string); - SQL_CHK_LEN(&cmd->cmd_buf, off, - &cmd->cmd_bufsize, - 3 + strlen(sql_ops)); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, - " %s ", sql_ops); - } - } - - if (node->pn_flags & MMS_PN_REGEX) { - /* restore list to original order */ - arg = mms_list_tail(&node->pn_arglist); - mms_list_remove(&node->pn_arglist, arg); - mms_list_insert_head(&node->pn_arglist, arg); - } - } else if (node->pn_flags & MMS_PN_UNARYOPS) { - if (print_message) - mms_trace(MMS_DEVP, - "(node->pn_flags & MMS_PN_UNARYOPS)"); - - /* Unary ops has only one arg */ - if (strcmp(node->pn_string, "isset") == 0 || - strcmp(node->pn_string, "notset") == 0) { - arg = mms_list_head(&node->pn_arglist); - - if (mm_sql_trans_match_exp(arg, cmd, - &off, need_host_ident)) { - mms_trace(MMS_ERR, - "mm_sql_trans_match_exp: " - "error translating match expression"); - return (1); - } - if (strcmp(node->pn_string, "isset") == 0) { - /* isset */ - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, - " IS NOT NULL"); - } else { - /* notnot */ - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, - " ISNULL"); - } - - - } else if (strcmp(node->pn_string, "isattr") == 0 || - strcmp(node->pn_string, "noattr") == 0) { - - att_test = "mm_obj_has_att('%s','%s') = '%s'"; - - if (strcmp(node->pn_string, "isattr") == 0) { - att_cond = "true"; - } else { - att_cond = "false"; - } - - arg = mms_list_head(&node->pn_arglist); - obj = arg->pn_string; - - next_arg = mms_list_head(&arg->pn_arglist); - att = next_arg->pn_string; - - SQL_CHK_LEN(&cmd->cmd_buf, off, &cmd->cmd_bufsize, - strlen(att_test) + 1); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, - att_test, obj, att, att_cond); - - } else { - sql_ops = mm_sql_get_ops(node->pn_string); - SQL_CHK_LEN(&cmd->cmd_buf, off, &cmd->cmd_bufsize, - strlen(sql_ops) + 3); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, - " %s ", sql_ops); - SQL_CHK_LEN(&cmd->cmd_buf, off, &cmd->cmd_bufsize, 2); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, "("); - arg = mms_list_head(&node->pn_arglist); - - if (mm_sql_trans_match_exp(arg, cmd, - &off, need_host_ident)) { - mms_trace(MMS_ERR, - "mm_sql_trans_match_exp: " - "error translating match expression"); - return (1); - } - SQL_CHK_LEN(&cmd->cmd_buf, off, &cmd->cmd_bufsize, 2); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, ")"); - } - } - *offset = off; - return (0); - -no_mem: - MM_ABORT_NO_MEM(); - return (1); - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - return (1); - -} - - -void -mm_sql_number(mm_command_t *cmd) -{ - - - char *buf = NULL; - char *final_buf = NULL; - char *number_buf = NULL; - - mms_trace(MMS_DEVP, "mm_sql_number"); - /* This function will append the number buf to cmd_buf */ - - number_buf = mm_sql_number_buf(cmd); - - buf = mms_strapp(buf, number_buf); - - if (number_buf != NULL) - free(number_buf); - - if (buf == NULL) { - return; - } - - final_buf = mms_strapp(final_buf, cmd->cmd_buf); - final_buf = mms_strapp(final_buf, buf); - - SQL_CHK_LEN(&cmd->cmd_buf, NULL, - &cmd->cmd_bufsize, strlen(final_buf) + 1); - strcpy(cmd->cmd_buf, final_buf); - - if (buf) - free(buf); - if (final_buf) - free(final_buf); - - return; - -no_mem: - MM_ABORT_NO_MEM(); -} - - - -char * -mm_sql_number_buf(mm_command_t *cmd) -{ - /* This function returns a buf of the number clause */ - mms_par_node_t *number; - mms_par_node_t *range; - mms_par_node_t *node; - mms_par_node_t *arg1; - mms_par_node_t *arg2; - int range1 = 0; - int range2 = 0; - - int val; - - char *buf = NULL; - mms_par_node_t *work; - - - - mms_trace(MMS_DEVP, "mm_sql_number_buf"); - number = mms_pn_lookup(cmd->cmd_root, "number", - MMS_PN_CLAUSE, NULL); - if (number == NULL) { - mms_trace(MMS_DEVP, "didn't find a number clause"); - return (NULL); - } - /* - * Subtract one from the number because the postgres data index - * starts at zero and the mmp command number starts at one. - */ - node = mms_list_head(&number->pn_arglist); - - - - if ((range = mms_pn_lookup(number, NULL, - MMS_PN_RANGE, NULL)) != NULL) { - mms_trace(MMS_DEVP, "inside range.."); - - work = NULL; - /* Have a range */ - /* get the 1st and last arg */ - arg1 = mms_pn_lookup(range, NULL, - MMS_PN_STRING, &work); - arg2 = mms_pn_lookup(range, NULL, - MMS_PN_STRING, &work); - - if ((arg1->pn_string == NULL) || - (arg2->pn_string == NULL)) { - mms_trace(MMS_ERR, - "an arg in range cannot be NULL"); - return (buf); - } - - if (strcmp(arg1->pn_string, "FIRST") == 0) { - if (arg2->pn_type & MMS_PN_NUMERIC) { - range1 = 1; - sscanf(arg2->pn_string, "%d", &range2); - } else { - return (buf); - } - } else if (strcmp(arg2->pn_string, "LAST") == 0) { - if (arg1->pn_type & MMS_PN_NUMERIC) { - sscanf(arg1->pn_string, "%d", &val); - val -= 1; - buf = mms_strapp(buf, " OFFSET %d ", val); - - return (buf); - } else { - return (buf); - } - } else if (arg1->pn_type & MMS_PN_NUMERIC && - arg2->pn_type & MMS_PN_NUMERIC) { - sscanf(arg1->pn_string, "%d", &range1); - sscanf(arg2->pn_string, "%d", &range2); - } else { - return (buf); - } - range1 -= 1; - range2 -= 1; - buf = mms_strapp(buf, " LIMIT %d OFFSET %d ", - range2 - range1 + 1, range1); - - } else if (strcmp(node->pn_string, "FIRST") == 0) { - buf = mms_strapp(buf, " LIMIT 1 OFFSET 0 "); - - } else if (node->pn_type & MMS_PN_NUMERIC) { - sscanf(node->pn_string, "%d", &val); - val -= 1; - buf = mms_strapp(buf, " LIMIT 1 OFFSET %d ", val); - - } - - if (buf == NULL) { - mms_trace(MMS_ERR, - "found a number clause, " - "but didn't write any sql"); - mms_trace(MMS_DEVP, "Number buf is NULL"); - return (buf); - } - - - - - return (buf); - - -no_mem: - MM_ABORT_NO_MEM(); - return (NULL); - -not_found: - return (NULL); - -} - - - -int -mm_get_range(mm_command_t *cmd, mm_range_t *range) -{ - mms_par_node_t *number; - mms_par_node_t *node; - mms_par_node_t *arg1; - mms_par_node_t *arg2; - - /* - * Get number clause range, number[a..b] or number[a] - */ - - memset(range, 0, sizeof (mm_range_t)); - - if ((number = mms_pn_lookup(cmd->cmd_root, "number", - MMS_PN_CLAUSE, NULL)) == NULL) { - /* no number */ - range->mm_range_type = MM_RANGE_NONE; - return (0); - } - - node = mms_list_head(&number->pn_arglist); - if (node->pn_type == MMS_PN_RANGE) { - - /* number range */ - arg1 = mms_list_head(&node->pn_arglist); - arg2 = mms_list_tail(&node->pn_arglist); - - if (strcmp(arg1->pn_string, "FIRST") == 0 && - strcmp(arg2->pn_string, "LAST") == 0) { - mms_trace(MMS_DEVP, "number-clause range first-last"); - range->mm_range_type = MM_RANGE_FIRST_LAST; - range->mm_range_first = 1; - return (0); - } else if (strcmp(arg1->pn_string, "FIRST") == 0) { - range->mm_range_type = MM_RANGE_FIRST; - range->mm_range_first = 1; - if (arg2->pn_type & MMS_PN_NUMERIC) { - range->mm_range_last = - atoi(arg2->pn_string); - mms_trace(MMS_DEVP, - "number-clause range first-%d", - range->mm_range_last); - return (0); - } - } else if (strcmp(arg2->pn_string, "LAST") == 0) { - range->mm_range_type = MM_RANGE_LAST; - if (arg1->pn_type & MMS_PN_NUMERIC) { - range->mm_range_first = - atoi(arg1->pn_string); - mms_trace(MMS_DEVP, "number-clause " - "range %d-last", - range->mm_range_first); - return (0); - } - } else if (arg1->pn_type & MMS_PN_NUMERIC && - arg2->pn_type & MMS_PN_NUMERIC) { - range->mm_range_type = MM_RANGE_NUMS; - range->mm_range_first = atoi(arg1->pn_string); - range->mm_range_last = atoi(arg2->pn_string); - mms_trace(MMS_DEVP, "number-clause range %d-%d", - range->mm_range_first, range->mm_range_last); - return (0); - } - - mms_trace(MMS_DEVP, "number-clause range lookup failed"); - return (1); - - } - - /* single number */ - range->mm_range_type = MM_RANGE_A_NUM; - range->mm_range_first = atoi(node->pn_string); - mms_trace(MMS_DEVP, "number-clause number %d", - range->mm_range_first); - return (0); -} - -void -mm_sql_order(mm_command_t *cmd) -{ - char *buf = NULL; - char *final_buf = NULL; - char *order_buf = NULL; - - mms_trace(MMS_DEVP, "mm_sql_order"); - - order_buf = mm_sql_order_buf(cmd); - - buf = mms_strapp(buf, order_buf); - if (order_buf != NULL) - free(order_buf); - if (buf == NULL) { - return; - } - - final_buf = mms_strapp(final_buf, cmd->cmd_buf); - final_buf = mms_strapp(final_buf, buf); - - SQL_CHK_LEN(&cmd->cmd_buf, NULL, - &cmd->cmd_bufsize, strlen(final_buf) + 1); - - - strcpy(cmd->cmd_buf, final_buf); - - - if (buf) - free(buf); - if (final_buf) - free(final_buf); - - return; - -no_mem: - MM_ABORT_NO_MEM(); -} - -char * -mm_sql_order_buf(mm_command_t *cmd) -{ - mms_par_node_t *order; - mms_par_node_t *ops; - mms_par_node_t *object; - mms_par_node_t *attr; - - mms_par_node_t *work = NULL; - int ordercnt = 0; - char *sql_ops; - - char *buf = NULL; - - int need_int_cast = 0; - - mms_trace(MMS_DEVP, "mm_sql_order_buf"); - - for (order = mms_pn_lookup(cmd->cmd_root, "order", - MMS_PN_CLAUSE, &work); - order != NULL; - ordercnt++, - order = mms_pn_lookup(cmd->cmd_root, "order", - MMS_PN_CLAUSE, &work)) { - if (ordercnt == 0) { - buf = mms_strapp(buf, "ORDER BY "); - } else { - buf = mms_strapp(buf, ", "); - } - ops = mms_list_head(&order->pn_arglist); - sql_ops = mm_sql_get_ops(ops->pn_string); - mms_trace(MMS_DEVP, - "op == %s", - ops->pn_string); - - if ((strcmp(ops->pn_string, - "numhilo") == 0) || - (strcmp(ops->pn_string, - "numlohi") == 0)) { - need_int_cast = 1; - buf = mms_strapp(buf, - "int4("); - } - - object = mms_list_head(&ops->pn_arglist); - buf = mms_strapp(buf, "\"%s\".", - object->pn_string); - - attr = mms_list_head(&object->pn_arglist); - buf = mms_strapp(buf, "\"%s\" ", - attr->pn_string); - if (need_int_cast) { - buf = mms_strapp(buf, ") "); - } - - buf = mms_strapp(buf, "%s", sql_ops); - - } - if (buf == NULL) { - mms_trace(MMS_DEVP, "Order buf is NULL"); - buf = mms_strapp(buf, " "); - return (buf); - } - - return (buf); - -no_mem: - MM_ABORT_NO_MEM(); - return (NULL); - -} - - -void -mm_sql_db_err_rsp_new(mm_command_t *cmd, mm_db_t *db) -{ - int dbstatus; - char *dbmessage; - - dbstatus = PQresultStatus(db->mm_db_results); - dbmessage = PQresultErrorMessage(db-> - mm_db_results); - - free(cmd->cmd_buf); - if ((cmd->cmd_buf = mm_db_sql_err_rsp(dbstatus, dbmessage, - cmd->wka_ptr->wka_conn.cci_language, cmd->cmd_task)) == NULL) { - MM_ABORT_NO_MEM(); - return; - } - mm_clear_db(&db->mm_db_results); - -} - -int -mm_add_match_list(char *str, mms_list_t *list) { - /* Checks is str is already in list */ - /* If str exists, do nothing */ - /* Else add to list and inc num */ - if (mm_in_char_list(list, str)) { - return (1); - } - if (mm_add_char(str, list)) { - mms_trace(MMS_ERR, - "mm_add_match_list: " - "error adding char"); - return (1); - } - return (0); -} - -int -/* LINTED: mm_wka may be used in the future */ -mm_get_const(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *match; - mms_par_node_t *node; - int off = 0; - mms_par_node_t *vol_name; - - mms_trace(MMS_DEVP, "mm_get_const"); - - if (cmd->cmd_buf != NULL) { - free(cmd->cmd_buf); - cmd->cmd_buf = NULL; - cmd->cmd_bufsize = 0; - } - - /* Look up the match clause */ - match = mms_pn_lookup(cmd->cmd_root, "match", - MMS_PN_CLAUSE, NULL); - if (match == NULL) { - /* No match clause, chek for volname */ - vol_name = mms_pn_lookup(cmd->cmd_root, "volname", - MMS_PN_CLAUSE, NULL); - if (vol_name != NULL) { - /* Found a volname */ - mm_sql_trans_volname(cmd, &off); - } else { - /* No match and no volname */ - return (1); - } - if (cmd->cmd_buf != NULL) { - mms_trace(MMS_DEVP, "cmd_buf is \n%s\n", cmd->cmd_buf); - } - mms_trace(MMS_DEVP, "cmd_const_num = %d", cmd->cmd_const_num); - - if (mm_add_char(cmd->cmd_buf, - &cmd->cmd_const_list)) { - mms_trace(MMS_ERR, "Error adding char to const list" - "- out of memory"); - return (1); - } - - cmd->cmd_const_num ++; - return (0); - } - /* We have a match clause */ - node = mms_list_head(&match->pn_arglist); - if (node == NULL) { - mms_trace(MMS_ERR, "Error translating match expression"); - return (1); - } - if (mm_sql_trans_match_exp(node, cmd, &off, 0)) { - mms_trace(MMS_ERR, "Error translating match expression"); - return (1); - } - - /* List way */ - if (mm_add_char(cmd->cmd_buf, - &cmd->cmd_const_list)) { - mms_trace(MMS_ERR, "Error adding char to source list"); - return (1); - } - - /* Array Way */ - - cmd->cmd_const_num ++; - - /* List TEST */ - mms_trace(MMS_DEVP, "Printing char_list const..."); - mm_print_char_list(&cmd->cmd_const_list); - return (0); - - - -no_mem: - MM_ABORT_NO_MEM(); - return (MM_CMD_ERROR); -} - - - - - -int -/* LINTED: mm_wka may be used in the future */ -mm_get_source(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - mms_par_node_t *report; - mms_par_node_t *object; - mms_par_node_t *work; - int source_count = 0; - int skip = 0; - - mms_trace(MMS_DEBUG, "mm_get_source"); - - report = mms_pn_lookup(cmd->cmd_root, "report", - MMS_PN_CLAUSE, NULL); - if (report == NULL) { - cmd->cmd_source_num = 0; - return (1); - } - work = NULL; - for (object = mms_pn_lookup(report, NULL, MMS_PN_OBJ, &work); - object != NULL; - object = mms_pn_lookup(report, NULL, MMS_PN_OBJ, &work)) { - skip = 0; - if (mm_in_char_list(&cmd->cmd_source_list, - object->pn_string)) { - /* already have this as a source */ - skip = 1; - } - - if (!skip) { - /* List way */ - if (mm_add_char(object->pn_string, - &cmd->cmd_source_list)) { - mms_trace(MMS_ERR, "Error adding " - "char to source list"); - return (1); - } - - /* Array Way */ - - source_count ++; - } - - } - cmd->cmd_source_num = source_count; - /* List TEST */ - mms_trace(MMS_DEVP, "Printing char_list source..."); - mm_print_char_list(&cmd->cmd_source_list); - return (0); - -} - -void -mm_get_dest_helper(mms_par_node_t *node, mm_command_t *cmd) -{ - mms_par_node_t *arg; - int skip = 0; - - if (node->pn_type == MMS_PN_OBJ) { - if (node->pn_string != NULL) { - - skip = 0; - if (mm_in_char_list(&cmd->cmd_dest_list, - node->pn_string)) { - /* already have this as a dest */ - skip = 1; - } - if (!skip) { - /* List way */ - if (mm_add_char(node->pn_string, - &cmd->cmd_dest_list)) { - mms_trace(MMS_ERR, "Error adding " - "char to source list"); - } - - /* Array Way */ - - cmd->cmd_dest_num ++; - } - - } - arg = mms_list_head(&node->pn_arglist); - } else if (node->pn_flags & MMS_PN_MULTIOPS) { - if (node->pn_flags & MMS_PN_REGEX) { - /* sql regular expression is at end of list */ - arg = mms_list_head(&node->pn_arglist); - mms_list_remove(&node->pn_arglist, arg); - mms_list_insert_tail(&node->pn_arglist, arg); - } - mms_list_foreach(&node->pn_arglist, arg) { - mm_get_dest_helper(arg, cmd); - - } - if (node->pn_flags & MMS_PN_REGEX) { - /* restore list to original order */ - arg = mms_list_tail(&node->pn_arglist); - mms_list_remove(&node->pn_arglist, arg); - mms_list_insert_head(&node->pn_arglist, arg); - } - } else if (node->pn_flags & MMS_PN_UNARYOPS) { - if (strcmp(node->pn_string, "isattr") == 0 || - strcmp(node->pn_string, "noattr") == 0) { - arg = mms_list_head(&node->pn_arglist); - - } else { - arg = mms_list_head(&node->pn_arglist); - mm_get_dest_helper(arg, cmd); - } - } -} - -void -mm_clear_const(mm_command_t *cmd) { - mm_free_list(&cmd->cmd_const_list); - cmd->cmd_const_num = 0; -} - -void -mm_clear_dest(mm_command_t *cmd) { - mm_free_list(&cmd->cmd_dest_list); - cmd->cmd_dest_num = 0; -} -void -mm_clear_source(mm_command_t *cmd) { - mm_free_list(&cmd->cmd_source_list); - cmd->cmd_source_num = 0; -} - - - -int -/* LINTED: mm_wka may be used in the future */ -mm_get_dest(mm_wka_t *mm_wka, mm_command_t *cmd) -{ - - mms_par_node_t *match; - mms_par_node_t *node; - mms_par_node_t *vol_name; - - mms_trace(MMS_DEVP, "mm_get_dest"); - - match = mms_pn_lookup(cmd->cmd_root, "match", - MMS_PN_CLAUSE, NULL); - if (match == NULL) { - vol_name = mms_pn_lookup(cmd->cmd_root, "volname", - MMS_PN_CLAUSE, NULL); - if (vol_name != NULL) { - /* List way */ - if (mm_add_char("VOLUME", - &cmd->cmd_dest_list)) { - mms_trace(MMS_ERR, "Error adding " - "char to source list"); - } - - /* Array Way */ - - cmd->cmd_dest_num ++; - return (0); - } - return (1); - - } - mms_list_foreach(&match->pn_arglist, node) { - mm_get_dest_helper(node, cmd); - } - /* List TEST */ - mms_trace(MMS_DEVP, "Printing char_list dest..."); - mm_print_char_list(&cmd->cmd_dest_list); - return (0); - -} - -int -mm_non_priv_const(mm_wka_t *mm_wka, mm_command_t *cmd) { - - char *const_buf = NULL; - mms_list_t *source_list = &cmd->cmd_source_list; - cci_t *conn = &mm_wka->wka_conn; - char *app_name = conn->cci_client; - - - /* - * Cartridge/volume constriants - */ - /* Check for the objects in the source list */ - if (mm_in_char_list(source_list, "CARTRIDGE") || - mm_in_char_list(source_list, "PARTITION") || - mm_in_char_list(source_list, "SIDE") || - mm_in_char_list(source_list, "SLOT") || - mm_in_char_list(source_list, "CARTRIDGEGROUP") || - mm_in_char_list(source_list, "CARTRIDGEGROUPAPPLICATION")) { - /* Add constraint for CARTRIDGE */ - (void) mm_add_to_dest(cmd, - "CARTRIDGEGROUPAPPLICATION"); - if (const_buf) - free(const_buf); - const_buf = NULL; - const_buf = mms_strapp(const_buf, - "\"CARTRIDGEGROUPAPPLICATION\"." - "\"ApplicationName\" = '%s'", - app_name); - (void) mm_add_to_const(cmd, const_buf); - } - if (mm_in_char_list(source_list, "VOLUME")) { - /* Add constraint for VOLUME */ - (void) mm_add_to_dest(cmd, - "VOLUME"); - if (const_buf) - free(const_buf); - const_buf = NULL; - const_buf = mms_strapp(const_buf, - "\"VOLUME\"." - "\"ApplicationName\" = '%s'", - app_name); - (void) mm_add_to_const(cmd, const_buf); - } - - - /* - * Drive/Mount constraints - */ - if (mm_in_char_list(source_list, "DRIVE") || - mm_in_char_list(source_list, "DRIVEGROUP") || - mm_in_char_list(source_list, "DRIVEGROUPAPPLICATION") || - mm_in_char_list(source_list, "DM") || - mm_in_char_list(source_list, "DMCAPABILITY") || - mm_in_char_list(source_list, "DMCAPABILITYTOKEN") || - mm_in_char_list(source_list, "DMCAPABILITYDEFAULTTOKEN") || - mm_in_char_list(source_list, "DMCAPABILITYGROUP") || - mm_in_char_list(source_list, "DMCAPABILITYGROUPTOKEN") || - mm_in_char_list(source_list, "DMBITFORMAT") || - mm_in_char_list(source_list, "DMBITFORMATTOKEN")) { - /* Add constraint for DRIVE */ - (void) mm_add_to_dest(cmd, - "DRIVEGROUPAPPLICATION"); - if (const_buf) - free(const_buf); - const_buf = NULL; - const_buf = mms_strapp(const_buf, - "\"DRIVEGROUPAPPLICATION\"." - "\"ApplicationName\" = '%s'", - app_name); - (void) mm_add_to_const(cmd, const_buf); - } - if (mm_in_char_list(source_list, "MOUNTPHYSICAL") || - mm_in_char_list(source_list, "MOUNTLOGICAL") || - mm_in_char_list(source_list, "STALEHANDLE")) { - /* Add constraint for MOUNTPHYSICAL */ - (void) mm_add_to_dest(cmd, - "MOUNTPHYSICAL"); - if (const_buf) - free(const_buf); - const_buf = NULL; - const_buf = mms_strapp(const_buf, - "\"MOUNTPHYSICAL\"." - "\"ApplicationName\" = '%s'", - app_name); - (void) mm_add_to_const(cmd, const_buf); - } - /* - * System/connection constraints - */ - - if (mm_in_char_list(source_list, "APPLICATION") || - mm_in_char_list(source_list, "AI")) { - /* Add constraint for APPLICATION */ - (void) mm_add_to_dest(cmd, - "APPLICATION"); - if (const_buf) - free(const_buf); - const_buf = NULL; - const_buf = mms_strapp(const_buf, - "\"APPLICATION\"." - "\"ApplicationName\" = '%s'", - app_name); - (void) mm_add_to_const(cmd, const_buf); - } - - if (mm_in_char_list(source_list, "CONNECTION") || - mm_in_char_list(source_list, "SESSION") || - mm_in_char_list(source_list, "NOTIFY")) { - /* Add constraint for DRIVE */ - (void) mm_add_to_dest(cmd, - "CONNECTION"); - if (const_buf) - free(const_buf); - const_buf = NULL; - const_buf = mms_strapp(const_buf, - "\"CONNECTION\"." - "\"ConnectionClientName\" = '%s'", - app_name); - (void) mm_add_to_const(cmd, const_buf); - } - if (const_buf) - free(const_buf); - const_buf = NULL; - return (0); -} - -void -mm_path_match_report(mm_command_t *cmd, mm_db_t *db) -{ - - int off; - mms_par_node_t *report; - mms_par_node_t *reportmode; - mms_par_node_t *object; - mms_par_node_t *attr; - mms_par_node_t *work; - mm_wka_t *mm_wka = cmd->wka_ptr; - - mms_trace(MMS_DEVP, "mm_path_match_report"); - - report = mms_pn_lookup(cmd->cmd_root, "report", - MMS_PN_CLAUSE, NULL); - if (report == NULL) { - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, - strlen(RESPONSE_SUCCESS) + - strlen(cmd->cmd_task) + 1); - (void) snprintf(cmd->cmd_buf, cmd->cmd_bufsize, - RESPONSE_SUCCESS, cmd->cmd_task); - return; - } - - mm_clear_source(cmd); - if (mm_get_source(mm_wka, cmd)) { - /* Command does not have a report clause */ - mms_trace(MMS_DEVP, "No report clause"); - } else { - /* TEMP - Trace out our source info */ - mms_trace(MMS_DEVP, "Source count is %d", cmd->cmd_source_num); - mm_print_char_list(&cmd->cmd_source_list); - } - - mm_clear_dest(cmd); - if (mm_get_dest(mm_wka, cmd)) { - /* Command does not have a match/volname clause */ - mms_trace(MMS_DEVP, "No match/volname Clause"); - } else { - /* TEMP - Trace out our dest info */ - mms_trace(MMS_DEVP, "Dest count is %d", cmd->cmd_dest_num); - mm_print_char_list(&cmd->cmd_dest_list); - } - - /* Build Constraint List */ - mm_clear_const(cmd); - if (mm_get_const(mm_wka, cmd)) { - /* Command does not have a match/volname clause */ - mms_trace(MMS_DEVP, "No match/volname Clause???"); - } else { - /* TEMP - Trace out our const info */ - mms_trace(MMS_DEVP, "Const count is %d", cmd->cmd_const_num); - mm_print_char_list(&cmd->cmd_const_list); - } - - /* For non priv-clients, check the source list */ - /* Add any additional constraits necessary */ - /* ie. VOLUME.ApplicationName = cci_client */ - /* both source + dest may need adds */ - if (cmd->wka_ptr->wka_privilege == MM_PRIV_STANDARD) { - mms_trace(MMS_DEVP, - "add non-priv constraints"); - /* Need to check source list and */ - /* add constraints as necessary */ - if (mm_non_priv_const(mm_wka, cmd)) { - mms_trace(MMS_ERR, - "error adding non-priv " - "client constraints"); - } - mms_trace(MMS_DEVP, - "const list after additions, %d", - cmd->cmd_const_num); - mm_print_char_list(&cmd->cmd_const_list); - } else { - mms_trace(MMS_DEVP, - "skip constraints forpriv client"); - } - - SQL_CHK_LEN(&cmd->cmd_buf, 0, &cmd->cmd_bufsize, 7); - off = snprintf(cmd->cmd_buf, cmd->cmd_bufsize, "SELECT "); - - /* If unique is specified in the reportmode clause, insert DISTINCT */ - reportmode = mms_pn_lookup(cmd->cmd_root, "reportmode", - MMS_PN_CLAUSE, NULL); - if (reportmode && mms_pn_lookup(reportmode, "unique", - MMS_PN_KEYWORD, NULL)) { - SQL_CHK_LEN(&cmd->cmd_buf, off, &cmd->cmd_bufsize, 9); - off += snprintf(cmd->cmd_buf + off, cmd->cmd_bufsize - off, - "DISTINCT "); - } - work = NULL; - for (object = mms_pn_lookup(report, NULL, MMS_PN_OBJ, &work); - object != NULL; - object = mms_pn_lookup(report, NULL, MMS_PN_OBJ, &work)) { - attr = mms_pn_lookup(object, NULL, MMS_PN_ATTR, NULL); - if (attr == NULL) { - /* show all attributes */ - SQL_CHK_LEN(&cmd->cmd_buf, off, &cmd->cmd_bufsize, - 4 + strlen(object->pn_string)); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, - "\"%s\".*,", object->pn_string); - } else { - /* - * More than one object column reference can't be be - * ambiguous, specify object and attribute. - */ - SQL_CHK_LEN(&cmd->cmd_buf, off, &cmd->cmd_bufsize, - 6 + strlen(object->pn_string) + - strlen(object->pn_string) + - strlen(attr->pn_string)); - off += snprintf(cmd->cmd_buf + off, - cmd->cmd_bufsize - off, - "\"%s\".\"%s\",", - object->pn_string, - attr->pn_string); - } - } - off--; /* overwrite the last comma */ - SQL_CHK_LEN(&cmd->cmd_buf, off, &cmd->cmd_bufsize, 6); - off += snprintf(cmd->cmd_buf + off, cmd->cmd_bufsize - off, " FROM "); - - if (mm_sql_from_where(cmd, db)) { - mms_trace(MMS_ERR, - "mm_path_match_report: " - "db error creating helper functions"); - return; - } - - mm_sql_order(cmd); - mm_sql_number(cmd); - - - if (mm_sql_report(cmd)) { - mms_trace(MMS_ERR, - "mm_path_match_report: " - "error generating final response"); - } - return; - -no_mem: - MM_ABORT_NO_MEM(); - return; - -not_found: - mm_response_error(cmd, - ECLASS_LANGUAGE, - ENOTFOUND, - MM_5062_MSG, - NULL); - return; - -} - -/* - * function to set a LM/DM/DRIVE/LIBRARY state - * uses its own db connection - * to set drive 1, DRIVE.DriveStateHard to 'loaded' : - * mm_sql_update_state(&mm_data, "DRIVE", "DriveStateHard", "loaded", - * "DriveName", "drive1"); - */ -#define MM_SQL_UPDATE_STATE "update \"%s\" "\ - "set \"%s\" = '%s' "\ - "where \"%s\" = '%s';" -void -mm_sql_update_state(mm_data_t *data, char *object, char *attribute, - char *value, char *instance, char *name) -{ - - mm_db_t *db = &data->mm_db; - if (mm_db_exec(HERE, db, MM_SQL_UPDATE_STATE, - object, attribute, value, - instance, name) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - mms_trace(MMS_ERR, - "mm_sql_update_state: " - "db error updating db states"); - } - return; - -} - - -int -/* LINTED: db is used by this function */ -mm_system_settings(mm_db_t *db, int *request_oper, int *auto_clear) { - - -#if 1 - /* TEMP - dont request, always clear */ - *auto_clear = 1; - *request_oper = 0; - return (0); -#else - rc = mm_db_exec(HERE, db, - "select " - "\"AskClearDriveAtLMConfig\"," - "\"ClearDriveAtLMConfig\" " - "from \"SYSTEM\";"); - if (rc != MM_DB_DATA) { - mms_trace(MMS_ERR, "Db error in mm_clear_unknown_tape"); - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - return (1); - } - if (PQntuples(db->mm_db_results) < 1) { - mms_trace(MMS_ERR, "Missing SYSTEM object"); - return (1); - - } - mms_trace(MMS_DEVP, "AskClearDrive = %s, ClearDrive = %s", - PQgetvalue(db->mm_db_results, 0, 0), - PQgetvalue(db->mm_db_results, 0, 1)); - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), - "yes") == 0) { - *request_oper = 1; - - } - /* Don't ask the oper */ - if (strcmp(PQgetvalue(db->mm_db_results, 0, 1), - "yes") == 0) { - *auto_clear = 1; - } - return (0); -#endif -} - -int -/* LINTED: a mm_wka arg is required by all cmd functions */ -mm_req_test_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) { - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - mms_trace(MMS_DEVP, "mm_req_test_cmd_func"); - mms_trace(MMS_DEVP, "request clear for %s, %s", - mount_info->cmi_drive, mount_info->cmi_cartridge); - return (MM_DEPEND_DONE); - -} - - - -int -mm_add_clear_request(mm_wka_t *mm_wka, mm_command_t *cmd) { - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - mm_command_t *req_cmd; - mm_wka_t *oper_wka; - mm_data_t *mm_data = mm_wka->mm_data; - uuid_text_t uuid; - - mms_trace(MMS_DEVP, "adding clear drive request," - "drive %s, cartridge %s", - mount_info->cmi_drive, mount_info->cmi_cartridge); - - - oper_wka = NULL; - mms_list_foreach(&mm_data->mm_wka_list, oper_wka) { - if ((strcmp(oper_wka->wka_conn.cci_instance, - "oper") == 0) && - (strcmp(oper_wka->wka_conn.cci_client, - "MMS") == 0)) { - /* Found the wka of oper */ - break; - } - } - if (oper_wka == NULL) { - mms_trace(MMS_DEBUG, "operator not connected"); - return (1); - } - - if ((req_cmd = mm_alloc_cmd(oper_wka)) == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_command_t: %s", - strerror(errno)); - return (1); - } - mm_add_depend(req_cmd, cmd); - mm_get_uuid(uuid); - req_cmd->cmd_root = NULL; - req_cmd->cmd_task = NULL; - req_cmd->cmd_task = strdup(uuid); - if (req_cmd->cmd_task == NULL) { - mms_trace(MMS_ERR, "Error malloc cmd_task in add cmd"); - return (MM_CMD_ERROR); - } - req_cmd->cmd_func = mm_req_test_cmd_func; - req_cmd->cmd_name = strdup("clear drive oper request"); - - req_cmd->cmd_mount_info.cmi_drive = strdup(mount_info->cmi_drive); - req_cmd->cmd_mount_info.cmi_cartridge = - strdup(mount_info->cmi_cartridge); - mms_list_insert_tail(&mm_data->mm_cmd_queue, req_cmd); - return (0); - -} -extern int mm_errorcode_eq(mms_par_node_t *cmd_response, char *code) { - - /* This function takes an MMP/DMP/LMP */ - /* response and returns a pointer to the error code */ - - mm_response_t response; - - - if (mm_parse_response(cmd_response, &response) == 1) { - mms_trace(MMS_ERR, - "Error parsing command response"); - return (0); - } - if ((response.error_class == NULL) || - (response.error_code == NULL)) { - /* Might not be an error response */ - return (0); - } - if (strcmp(response.error_code, code) == 0) { - return (1); - } - return (0); - -} -int -mm_non_physical_clear_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) { - mm_db_t *db = &cmd->cmd_mm_data->mm_db; - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - /* 1. DMP detach */ - /* 2. DMP release */ - /* 3. Schedule delay unmount/unload */ - - if (cmd->cmd_state == 0) { - mms_trace(MMS_DEVP, - "non-physical clear, add detach"); - /* Need both drive and dm set */ - if ((mount_info->cmi_drive == NULL)) { - mms_trace(MMS_ERR, - "cmi_drive/dm is NULL for " - "this non-physical clear"); - return (MM_CMD_ERROR); - } - /* Get DM Name */ - if (mm_db_exec(HERE, db, - "select \"DMName\" from \"DRIVE\" " - "where \"DRIVE\".\"DriveName\" = '%s';", - mount_info->cmi_drive) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error"); - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, - "row num mismatch"); - mm_clear_db(&db->mm_db_results); - return (MM_CMD_ERROR); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), "") == 0) { - mms_trace(MMS_ERR, - "missing dm name"); - mm_clear_db(&db->mm_db_results); - return (MM_CMD_ERROR); - } - mm_set_mount_info_dm(PQgetvalue(db->mm_db_results, 0, 0), - mount_info); - mm_clear_db(&db->mm_db_results); - - /* Send a detach */ - if (mm_dmp_add_cmd(mm_wka, cmd, mount_info->cmi_dm, - MM_DMP_DETACH) == NULL) { - mms_trace(MMS_ERR, - "mm_non_physical_clear_cmd_func: " - "error adding dmp detach"); - } - cmd->cmd_state = 1; - return (MM_DISPATCH_DEPEND); - - } - if (cmd->cmd_state == 1) { - mms_trace(MMS_DEVP, - "non-physical clear, add release"); - /* - * Detach has returned - * check error, update states - * Add Unload command - */ - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - if ((cmd->cmd_response != NULL) && - mm_errorcode_eq(cmd->cmd_response, - "DM_E_NOEXISTHANDLE")) { - mms_trace(MMS_DEVP, - "DM doesn't know the handle, " - "skip DMP unload, " - "send LMP unmount"); - /* Clear depend error flags */ - MM_UNSET_FLAG(cmd->cmd_flags, - MM_CMD_DEPEND_ERROR); - } else { - /* detach returned handle in use */ - mms_trace(MMS_ERR, - "non-physical clear_drive -> " - "DMP detach error, " - "handle may be inuse"); - return (MM_CMD_ERROR); - } - - } - mms_trace(MMS_DEVP, - "DM is not using handle, send DMP release"); - if (mm_dmp_add_cmd(mm_wka, cmd, mount_info->cmi_dm, - MM_DMP_RELEASE) == NULL) { - mms_trace(MMS_ERR, - "mm_non_physical_clear_cmd_func: " - "error adding dmp release"); - } - cmd->cmd_state = 2; - return (MM_DISPATCH_DEPEND); - } - if (cmd->cmd_state == 2) { - mms_trace(MMS_DEVP, - "non-physical clear, schedule unload"); - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - /* unload returned an error */ - mms_trace(MMS_ERR, "clear_drive -> DMP release error"); - } - if (mm_db_exec(HERE, db, - "select distinct \"CARTRIDGE\"." - "\"CartridgeID\" from \"CARTRIDGE\"" - "cross join \"DRIVE\"" - "where" - "((\"CARTRIDGE\".\"LibraryName\" " - "= \"DRIVE\".\"LibraryName\")" - "and" - "(\"DRIVE\".\"DriveName\" = '%s')" - "and" - "(\"CARTRIDGE\".\"CartridgePCL\" = " - "\"DRIVE\".\"CartridgePCL\"));", - mount_info->cmi_drive) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error"); - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, - "row num mismatch"); - mm_clear_db(&db->mm_db_results); - return (MM_CMD_ERROR); - } - mm_set_mount_info_cart(PQgetvalue(db->mm_db_results, 0, 0), - mount_info); - mm_clear_db(&db->mm_db_results); - - if (mm_db_exec(HERE, db, "delete from \"TASKCARTRIDGE\"" - "where \"TaskID\" = '%s';", cmd->cmd_uuid) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - mms_trace(MMS_ERR, - "mm_non_physical_clear_cmd_func: " - "db error deleting TASKCARTRIDGE"); - } - if (mm_db_exec(HERE, db, "delete from \"TASKDRIVE\" " - "where \"TaskID\" = '%s';", cmd->cmd_uuid) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - mms_trace(MMS_ERR, - "mm_non_physical_clear_cmd_func: " - "db error deleting TASKDRIVE"); - } - if (mm_db_exec(HERE, db, "delete from \"TASKLIBRARY\" " - "where \"TaskID\" = '%s';", cmd->cmd_uuid) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - mms_trace(MMS_ERR, - "mm_non_physical_clear_cmd_func: " - "db error deleting TASKLIBRARY"); - } - if (mm_db_exec(HERE, db, "delete from \"TASK\" " - "where \"TaskID\" = '%s';", cmd->cmd_uuid) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - mms_trace(MMS_ERR, - "mm_non_physical_clear_cmd_func: " - "db error deleting TASK"); - } - if (mm_db_exec(HERE, db, "delete from \"MOUNTLOGICAL\" " - "where \"CartridgeID\" = '%s';", - mount_info->cmi_cartridge) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - mms_trace(MMS_ERR, - "mm_non_physical_clear_cmd_func: " - "db error deleting MOUNTLOGICAL"); - } - if (mm_db_exec(HERE, db, "delete from \"MOUNTPHYSICAL\" " - "where \"CartridgeID\" = '%s';", - mount_info->cmi_cartridge) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - mms_trace(MMS_ERR, - "mm_non_physical_clear_cmd_func: " - "db error deleting MOUNTPHYSICAL"); - } - - if (mm_schedule_unload(mm_wka, cmd)) { - mms_trace(MMS_ERR, - "mm_non_physical_clear_cmd_func: " - "error scheduling delay unload"); - } - cmd->cmd_remove = 1; - mms_trace(MMS_DEVP, - "non-physical clear complete, delay unload scheduled"); - return (MM_DISPATCH_AGAIN); - - } - mms_trace(MMS_ERR, - "mm_non_physical_clear_cmd_func: unknown cmd state"); - return (MM_CMD_ERROR); -} - - -#define MM_CLEAR_START 0 -#define MM_CLEAR_SLOTSCAN 20 -#define MM_CLEAR_DETACH 21 -#define MM_CLEAR_RELEASE 22 -#define MM_CLEAR_UNLOAD 23 -#define MM_CLEAR_UNMOUNT 24 -#define MM_CLEAR_FINAL 25 - -int -mm_clear_drive_cmd_func(mm_wka_t *mm_wka, mm_command_t *cmd) { - mm_db_t *db = &cmd->cmd_mm_data->mm_db; - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - mm_data_t *data = cmd->cmd_mm_data; - int rc; - - mm_command_t *lmp_umnt_cmd; - uuid_text_t new_task; - - - /* This is a physical unmount */ - /* detach, release, unload, unmount */ -start: - if (cmd->cmd_state == MM_CLEAR_START) { - - /* Clear depend error flags, */ - /* On the 1st cmd state of clear drive */ - /* ignore any errors */ - /* This clear drive may be running after */ - /* A DMP activate which may have errored */ - /* Try to clear anyways */ - - MM_UNSET_FLAG(cmd->cmd_flags, - MM_CMD_DEPEND_ERROR); - - if (mount_info->cmi_library == NULL) { - mms_trace(MMS_ERR, - "library name not set for clear drive"); - return (MM_CMD_ERROR); - } - /* Confirm LM is connected and active */ - rc = mm_db_exec(HERE, db, - "select distinct " - "\"LM\".\"LMStateSoft\" from \"LM\"" - "cross join \"LIBRARY\"" - "where((\"LM\".\"LibraryName\" = " - "\"LIBRARY\".\"LibraryName\")" - "and(\"LIBRARY\".\"LibraryName\" = '%s'));", - mount_info->cmi_library); - if (rc != MM_DB_DATA) { - mms_trace(MMS_ERR, "Exec returned with no Data"); - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_ERR, - "library, %s, has no lm assigned", - mount_info->cmi_library); - mm_clear_db(&db->mm_db_results); - return (MM_CMD_ERROR); - } - - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), - "not ready") == 0) { - mms_trace(MMS_DEVP, "lm is not ready, wait"); - MM_SET_FLAG(cmd->cmd_flags, MM_CMD_DISPATCHABLE); - mm_clear_db(&db->mm_db_results); - return (MM_NO_DISPATCH); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), "ready") == 0) { - mms_trace(MMS_DEVP, "lm ready, continue"); - } else { - mms_trace(MMS_ERR, - "lm state = %s, cancel clear drive", - PQgetvalue(db->mm_db_results, 0, 0)); - mm_clear_db(&db->mm_db_results); - return (MM_CMD_ERROR); - } - mm_clear_db(&db->mm_db_results); - - mms_trace(MMS_DEBUG, "LM Ready, try to clear " - "drive -> %s, send scan", - mount_info->cmi_drive); - - /* Add LMP scan command for this drive */ - if (mm_add_lmp_scan(mm_wka->mm_data, cmd, - mount_info->cmi_drive, - NULL, mount_info->cmi_library)) { - mms_trace(MMS_ERR, - "Error adding LMP scan"); - return (MM_CMD_ERROR); - } else { - mms_trace(MMS_DEBUG, - "Added LMP scan"); - cmd->cmd_state = MM_CLEAR_DETACH; - - } - /* If DRIVE is occupied and has pcl set */ - /* MM will need to send lmp scan for the */ - /* cartridge as well */ - - if (mount_info->cmi_pcl != NULL) { - mms_trace(MMS_DEVP, - "cmi_pcl already set, %s", - mount_info->cmi_pcl); - cmd->cmd_state = MM_CLEAR_SLOTSCAN; - return (MM_DISPATCH_DEPEND); - } - - /* set mount_info->cmi_pcl */ - if (mm_db_exec(HERE, db, - "select distinct " - "\"DRIVE\".\"CartridgePCL\"" - "from \"DRIVE\" " - "where" - " \"DRIVE\".\"DriveName\" = '%s'; ", - mount_info->cmi_drive) != MM_DB_DATA) { - mms_trace(MMS_ERR, "Couldn't get Cartridge_PCL -> " - "mm_clear_drive_cmd_func"); - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_ERR, - "error getting pcl from drive"); - mm_clear_db(&db->mm_db_results); - return (MM_CMD_ERROR); - } - if (strcmp(PQgetvalue(db->mm_db_results, - 0, 0), MM_NON_MMS_CART) == 0) { - mms_trace(MMS_DEVP, - "drive loaded with non-mms cart"); - /* If non-mms cart return */ - /* since this is not part of MMS */ - /* MM does not need a cart scan */ - mm_clear_db(&db->mm_db_results); - return (MM_DISPATCH_DEPEND); - } - if (strcmp(PQgetvalue(db->mm_db_results, - 0, 0), "") != 0) { - /* DRIVE.pcl was set */ - cmd->cmd_state = MM_CLEAR_SLOTSCAN; - mm_set_mount_info_pcl(PQgetvalue(db-> - mm_db_results, 0, 0), - mount_info); - } - mm_clear_db(&db->mm_db_results); - - return (MM_DISPATCH_DEPEND); - } - - if (cmd->cmd_state == MM_CLEAR_SLOTSCAN) { - /* Command state when a lmp scan for slot is needed */ - /* Drive scan has completed */ - mms_trace(MMS_DEVP, - "drive scan complete, send scan of PCL"); - - /* Add LMP scan command for this drive */ - if (mm_add_lmp_scan(mm_wka->mm_data, cmd, - NULL, mount_info->cmi_pcl, - mount_info->cmi_library)) { - mms_trace(MMS_ERR, - "Error adding LMP scan"); - return (MM_CMD_ERROR); - } else { - mms_trace(MMS_DEBUG, - "Added LMP scan"); - cmd->cmd_state = MM_CLEAR_DETACH; - - } - if (mount_info->cmi_pcl != NULL) { - free(mount_info->cmi_pcl); - mount_info->cmi_pcl = NULL; - } - return (MM_DISPATCH_DEPEND); - } - - if (cmd->cmd_state == MM_CLEAR_DETACH) { - /* Send the DMP detach command */ - mms_trace(MMS_DEVP, - "physical clear, add detach"); - /* Need drive set */ - if ((mount_info->cmi_drive == NULL)) { - mms_trace(MMS_ERR, - "cmi_drive is NULL for " - "this physical clear"); - return (MM_CMD_ERROR); - } - - /* set mount_info->cmi_pcl */ - if (mm_db_exec(HERE, db, - "select distinct " - "\"DRIVE\".\"CartridgePCL\"" - "from \"DRIVE\" " - "where" - " \"DRIVE\".\"DriveName\" = '%s'; ", - mount_info->cmi_drive) != MM_DB_DATA) { - mms_trace(MMS_ERR, "Couldn't get Cartridge_PCL -> " - "mm_clear_drive_cmd_func"); - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - return (MM_CMD_ERROR); - } - - if (PQntuples(db->mm_db_results) == 0) { - mms_trace(MMS_ERR, - "error getting pcl from drive"); - mm_clear_db(&db->mm_db_results); - return (MM_CMD_ERROR); - } - - if (strcmp(PQgetvalue(db->mm_db_results, - 0, 0), "") == 0) { - mms_trace(MMS_DEVP, - "LMP scan of drive shows %s is clear", - mount_info->cmi_drive); - - mms_trace(MMS_INFO, "%s Cleared Successfully", - mount_info->cmi_drive); - - /* Set States For a Clear Drive */ - if (mm_db_exec(HERE, db, - "update \"DRIVE\" set " - "\"DriveStateHard\" = 'unloaded', " - "\"DMName\" = DEFAULT, " - "\"DriveLibraryOccupied\" = 'f' " - "where \"DriveName\" = '%s';", - mount_info->cmi_drive) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - mms_trace(MMS_ERR, - "mm_clear_drive_cmd_func: " - "db error updating DRIVE"); - } - - /* Delete any mountphysical, mountlogical, */ - /* or stalehandle */ - if (mm_db_exec(HERE, db, - "delete from \"MOUNTLOGICAL\" " - "where \"DriveName\" = '%s';", - mount_info->cmi_drive) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - mms_trace(MMS_ERR, - "mm_clear_drive_cmd_func: " - "db error deleting MOUNTLOGICAL"); - } - if (mm_db_exec(HERE, db, - "delete from \"STALEHANDLE\" " - "where \"DriveName\" = '%s';", - mount_info->cmi_drive) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - mms_trace(MMS_ERR, - "mm_clear_drive_cmd_func: " - "db error deleting STALEHANDLE"); - } - if (mm_db_exec(HERE, db, - "delete from \"MOUNTPHYSICAL\" " - "where \"DriveName\" = '%s';", - mount_info->cmi_drive) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - mms_trace(MMS_ERR, - "mm_clear_drive_cmd_func: " - "db error deleting MOUNTPHYSICAL"); - } - - mm_clear_db(&db->mm_db_results); - db->mm_db_results = NULL; - if (mm_has_depend(cmd)) { - return (MM_DEPEND_DONE); - } - return (MM_CMD_DONE); - - } - - if (strcmp(PQgetvalue(db->mm_db_results, - 0, 0), MM_NON_MMS_CART) == 0) { - mms_trace(MMS_DEVP, - "this is a clear drive for a non-mms cartridge"); - /* Look in the response to the scan to */ - /* find the pcl in this drive */ - if (mount_info->cmi_pcl != NULL) { - mms_trace(MMS_DEVP, - "pcl already set to %s", - mount_info->cmi_pcl); - } else { - mms_trace(MMS_ERR, - "pcl is NULL for a non-MMS cart"); - mm_clear_db(&db->mm_db_results); - return (MM_CMD_ERROR); - } - } else { - mm_set_mount_info_pcl(PQgetvalue(db-> - mm_db_results, 0, 0), - mount_info); - } - mm_clear_db(&db->mm_db_results); - if (mount_info->cmi_pcl == NULL) { - mms_trace(MMS_ERR, - "pcl is NULL "); - return (MM_CMD_ERROR); - } - mms_trace(MMS_DEVP, - "pcl set to %s", - mount_info->cmi_pcl); - /* Get DM Name */ - if (mm_db_exec(HERE, db, - "select \"DMName\" from \"DRIVE\" " - "where \"DRIVE\".\"DriveName\" = '%s';", - mount_info->cmi_drive) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error"); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, - "row num mismatch"); - mm_clear_db(&db->mm_db_results); - return (MM_CMD_ERROR); - } - if (strcmp(PQgetvalue(db->mm_db_results, 0, 0), "") == 0) { - mms_trace(MMS_ERR, - "missing dm name in DRIVE, " - "dm may already be detached, check STALEHANDLE"); - mm_clear_db(&db->mm_db_results); - /* Try getting DMName from STALEHANDLE */ - if (mm_db_exec(HERE, db, - "select \"DMName\" from \"STALEHANDLE\" " - "where \"STALEHANDLE\".\"DriveName\" = '%s';", - mount_info->cmi_drive) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error"); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, - "Can't find STALEHANDLE, continue unmount"); - mm_clear_db(&db->mm_db_results); - cmd->cmd_state = MM_CLEAR_UNLOAD; - goto start; - } - } - mm_set_mount_info_dm(PQgetvalue(db->mm_db_results, 0, 0), - mount_info); - mm_clear_db(&db->mm_db_results); - - /* Send a detach */ - if (mm_dmp_add_cmd(mm_wka, cmd, mount_info->cmi_dm, - MM_DMP_DETACH) == NULL) { - mms_trace(MMS_ERR, - "mm_clear_drive_cmd_func: " - "error adding dmp detach"); - } - cmd->cmd_state = MM_CLEAR_RELEASE; - return (MM_DISPATCH_DEPEND); - } - - if (cmd->cmd_state == MM_CLEAR_RELEASE) { - /* Send the DMP release command */ - mms_trace(MMS_DEVP, - "physical clear, add release"); - /* - * Detach has returned - * check error, update states - * Add Unload command - */ - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - if ((cmd->cmd_response != NULL) && - mm_errorcode_eq(cmd->cmd_response, - "DM_E_NOEXISTHANDLE")) { - mms_trace(MMS_DEVP, - "DM doesn't know the handle, " - "skip DMP unload, " - "send LMP unmount"); - /* Clear depend error flags */ - MM_UNSET_FLAG(cmd->cmd_flags, - MM_CMD_DEPEND_ERROR); - } else { - /* detach returned handle in use */ - mms_trace(MMS_ERR, "physical clear_drive -> " - "DMP detach error, " - "handle may be inuse"); - return (MM_CMD_ERROR); - } - - } - mms_trace(MMS_DEVP, - "DM is not using handle, send DMP release if dm is ready"); - - /* Check, if DM is not activated, don't send a release */ - if (mm_db_exec(HERE, db, - "select \"DMStateSoft\" from \"DM\" " - "where \"DM\".\"DMName\" = '%s';", - mount_info->cmi_dm) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error"); - return (MM_CMD_ERROR); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, - "Can't find DM, continue unmount"); - mm_clear_db(&db->mm_db_results); - return (MM_CMD_ERROR); - } - if ((strcmp(PQgetvalue(db->mm_db_results, 0, 0), - "present") == 0) || - (strcmp(PQgetvalue(db->mm_db_results, 0, 0), - "absent") == 0) || - (strcmp(PQgetvalue(db->mm_db_results, 0, 0), - "disconnected") == 0)) { - /* DM cannot process release */ - /* Continue to unmount */ - mms_trace(MMS_DEVP, - "DMStateSoft = %s, don't send release, " - "continue with unmount", - PQgetvalue(db->mm_db_results, 0, 0)); - mm_clear_db(&db->mm_db_results); - cmd->cmd_state = MM_CLEAR_UNLOAD; - goto start; - } - mms_trace(MMS_DEVP, - "DMStateSoft = %s, about to send release", - PQgetvalue(db->mm_db_results, 0, 0)); - mm_clear_db(&db->mm_db_results); - if (mm_dmp_add_cmd(mm_wka, cmd, mount_info->cmi_dm, - MM_DMP_RELEASE) == NULL) { - mms_trace(MMS_ERR, - "mm_clear_drive_cmd_func: " - "error adding dmp release"); - } - cmd->cmd_state = MM_CLEAR_UNLOAD; - return (MM_DISPATCH_DEPEND); - } - if (cmd->cmd_state == MM_CLEAR_UNLOAD) { - - /* Always send a DMP unload before the physicalunmount */ - /* If MM knows what DM to send to */ - - /* Try to send an unload now */ - MM_UNSET_FLAG(cmd->cmd_flags, - MM_CMD_DEPEND_ERROR); - - if (mount_info->cmi_dm == NULL) { - mms_trace(MMS_ERR, - "didn't find DM Name, " - "skip DMP unload"); - cmd->cmd_state = MM_CLEAR_UNMOUNT; - goto start; - } - mms_trace(MMS_DEVP, - "sending %s DMP unload", - mount_info->cmi_dm); - if (mm_dmp_add_cmd(mm_wka, cmd, mount_info->cmi_dm, - MM_DMP_UNLOAD) == NULL) { - mms_trace(MMS_ERR, - "mm_clear_drive_func: " - "error adding dmp unload"); - } - cmd->cmd_state = MM_CLEAR_UNMOUNT; - return (MM_DISPATCH_DEPEND); - } - - if (cmd->cmd_state == MM_CLEAR_UNMOUNT) { - /* DMP unload has completed, ignore any errors */ - /* and continue with the LMP unmount */ - - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - mms_trace(MMS_ERR, - "error during DMP unload, " - "continue with LMP unmount"); - /* Clear depend error flags */ - MM_UNSET_FLAG(cmd->cmd_flags, - MM_CMD_DEPEND_ERROR); - } - mms_trace(MMS_DEVP, - "physical clear, add unmount"); - mms_trace(MMS_INFO, "Unmounting %s from %s", - mount_info->cmi_pcl, - mount_info->cmi_drive); - - /* - * LMP unmount command - */ - - /* ********************* */ - /* TODO: FIX SIDE NAME!! */ - if ((lmp_umnt_cmd = mm_alloc_cmd(mm_wka)) == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_command_t: %s", - strerror(errno)); - return (MM_CMD_ERROR); - } - lmp_umnt_cmd->cmd_func = mm_lmp_unmount_cmd_func; - mm_get_uuid(new_task); - lmp_umnt_cmd->cmd_textcmd = mms_strnew(LMP_UNMOUNT, new_task, - mount_info->cmi_pcl, - mount_info->cmi_pcl, - "side 1", - mount_info->cmi_drive, - mount_info->cmi_pcl, - mount_info->cmi_pcl, - "side 1"); - mm_set_mount_info_drive(cmd->cmd_mount_info.cmi_drive, - &lmp_umnt_cmd->cmd_mount_info); - lmp_umnt_cmd->cmd_root = - mm_text_to_par_node(lmp_umnt_cmd->cmd_textcmd, - mms_lmpm_parse); - lmp_umnt_cmd->cmd_task = mm_get_task(lmp_umnt_cmd->cmd_root); - mm_add_depend(lmp_umnt_cmd, cmd); - lmp_umnt_cmd->cmd_name = strdup("lmp unmount"); - - pthread_mutex_lock(&data->mm_queue_mutex); - mms_list_insert_tail(&data->mm_cmd_queue, lmp_umnt_cmd); - pthread_mutex_unlock(&data->mm_queue_mutex); - - cmd->cmd_state = MM_CLEAR_FINAL; - return (MM_DISPATCH_DEPEND); - } - if (cmd->cmd_state == MM_CLEAR_FINAL) { - /* - * LMP mount has returned - * check for error, - * Return MM_DEPEND_DONE on success - */ - if (cmd->cmd_flags & MM_CMD_DEPEND_ERROR) { - return (MM_CMD_ERROR); - } - mms_trace(MMS_INFO, "%s Cleared Successfully", - mount_info->cmi_drive); - - /* Set States For a Clear Drive */ - if (mm_db_exec(HERE, db, - "update \"DRIVE\" set " - "\"DriveStateHard\" = 'unloaded', " - "\"DMName\" = DEFAULT, " - "\"DriveLibraryOccupied\" = 'f' " - "where \"DriveName\" = '%s';", - mount_info->cmi_drive) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_clear_drive_cmd_func: " - "db error updating DRIVE"); - } - - - /* Delete any mountphysical, mountlogical, or stalehandle */ - if (mm_db_exec(HERE, db, "delete from \"MOUNTLOGICAL\" "\ - "where \"DriveName\" = '%s';", - mount_info->cmi_drive) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_clear_drive_cmd_func: " - "db error deleting MOUNTLOGICAL"); - } - if (mm_db_exec(HERE, db, "delete from \"STALEHANDLE\" "\ - "where \"DriveName\" = '%s';", - mount_info->cmi_drive) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_clear_drive_cmd_func: " - "db error deleting STALEHANDLE"); - } - if (mm_db_exec(HERE, db, "delete from \"MOUNTPHYSICAL\" "\ - "where \"DriveName\" = '%s';", - mount_info->cmi_drive) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_clear_drive_cmd_func: " - "db error deleting MOUNTPHYSICAL"); - } - - if (mm_has_depend(cmd)) { - return (MM_DEPEND_DONE); - } - return (MM_CMD_DONE); - } - mms_trace(MMS_ERR, - "mm_clear_drive_cmd_func: unknown cmd state"); - return (MM_CMD_ERROR); -} - -mm_command_t * -mm_add_clear_drive(char *drive_name, mm_data_t *mm_data, - mm_db_t *db, - mm_command_t *parent_cmd, char *cart_pcl, int force, - int nonphysical) { - - mm_command_t *cmd; - mm_wka_t *lm_wka; - PGresult *lm_name; - uuid_text_t uuid; - - mm_command_t *cur_cmd; - - mms_trace(MMS_DEVP, "Adding mm_clear_drive_cmd_func"); - - if (drive_name == NULL) { - mms_trace(MMS_DEBUG, - "mm_add_clear_drive passed null drive_name"); - return (NULL); - } - if (mm_data == NULL) { - mms_trace(MMS_DEBUG, - "mm_add_clear_drive passed null mm_data"); - return (NULL); - } - if (db == NULL) { - mms_trace(MMS_DEBUG, - "mm_add_clear_drive passed null db pointer"); - return (NULL); - } - - - if (mm_db_exec(HERE, db, - "select \"LMName\", \"LibraryName\" "\ - "from \"LM\" " \ - "where \"LibraryName\" in "\ - "(select \"LibraryName\" from "\ - "\"DRIVE\" where \"DriveName\" = '%s');", - drive_name) != MM_DB_DATA) { - mms_trace(MMS_ERR, "Couldn't get LM Name -> " \ - "mm_add_clear_drive"); - mm_clear_db(&db->mm_db_results); - return (NULL); - } - lm_name = db->mm_db_results; - if (PQntuples(lm_name) == 0) { - mms_trace(MMS_ERR, "Couldn't get LM Name -> " \ - "mm_add_clear_drive"); - mm_clear_db(&lm_name); - return (NULL); - } - - /* Check the queue, if there is already a clear drive, */ - /* do not add another */ - /* If other is found, return a pointer to that clear drive */ - pthread_mutex_lock(&mm_data->mm_queue_mutex); - mms_list_foreach(&mm_data->mm_cmd_queue, cur_cmd) { - if ((cur_cmd->cmd_func == mm_clear_drive_cmd_func) || - (cur_cmd->cmd_func == - mm_non_physical_clear_cmd_func)) { - if ((strcmp(cur_cmd->cmd_mount_info.cmi_drive, - drive_name) == 0) && - (strcmp(cur_cmd->cmd_mount_info.cmi_library, - PQgetvalue(lm_name, 0, 1)) == 0)) { - mms_trace(MMS_ERR, - "already have a clear " - "drive for %s , %s", - drive_name, - PQgetvalue(lm_name, 0, 1)); - pthread_mutex_unlock(&mm_data-> - mm_queue_mutex); - mm_clear_db(&lm_name); - return (cur_cmd); - } - - } - } - pthread_mutex_unlock(&mm_data->mm_queue_mutex); - - - - lm_wka = NULL; - mms_list_foreach(&mm_data->mm_wka_list, lm_wka) { - if (strcmp(lm_wka->wka_conn.cci_instance, - PQgetvalue(lm_name, 0, 0)) == 0) { - /* Found the wka of lm */ - break; - } - } - if ((lm_wka == NULL) || (strcmp(lm_wka->wka_conn.cci_instance, - PQgetvalue(lm_name, 0, 0)) != 0)) { - /* bad wka */ - mms_trace(MMS_DEBUG, "Could not find a connected LM"); - mm_clear_db(&lm_name); - return (NULL); - } - if ((cmd = mm_alloc_cmd(lm_wka)) == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_command_t: %s", - strerror(errno)); - mm_clear_db(&lm_name); - return (NULL); - } - if (parent_cmd != NULL) { - mm_add_depend(cmd, parent_cmd); - } - mm_get_uuid(uuid); - cmd->cmd_root = NULL; - cmd->cmd_task = NULL; - cmd->cmd_task = strdup(uuid); - if (cmd->cmd_task == NULL) { - mms_trace(MMS_ERR, "Error malloc cmd_task in add cmd"); - mm_clear_db(&lm_name); - return (NULL); - } - if (nonphysical) { - cmd->cmd_func = mm_non_physical_clear_cmd_func; - } else { - cmd->cmd_func = mm_clear_drive_cmd_func; - } - cmd->cmd_name = strdup("clear drive"); - - cmd->cmd_mount_info.cmi_drive = strdup(drive_name); - cmd->cmd_mount_info.cmi_library = strdup(PQgetvalue(lm_name, 0, 1)); - - /* Force or not */ - cmd->cmd_mount_info.cui_force = force; - - /* Cart_pcl */ - if (cart_pcl != NULL) { - mm_set_mount_info_pcl(cart_pcl, - &cmd->cmd_mount_info); - } - pthread_mutex_lock(&mm_data->mm_queue_mutex); - mms_list_insert_tail(&mm_data->mm_cmd_queue, cmd); - pthread_mutex_unlock(&mm_data->mm_queue_mutex); - mm_clear_db(&lm_name); - return (cmd); - -} diff --git a/usr/src/cmd/mms/mm/common/mm_sql.h b/usr/src/cmd/mms/mm/common/mm_sql.h deleted file mode 100644 index 0e16d0d88f..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_sql.h +++ /dev/null @@ -1,43 +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 _MM_SQL_H_ -#define _MM_SQL_H_ - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum intrp_rval intrp_rval_t; -enum intrp_rval { - INTRP_OK, - INTRP_DATA -}; - -#ifdef __cplusplus -} -#endif - -#endif /* _MM_SQL_H_ */ diff --git a/usr/src/cmd/mms/mm/common/mm_sql_impl.h b/usr/src/cmd/mms/mm/common/mm_sql_impl.h deleted file mode 100644 index f866851d73..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_sql_impl.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 _MM_SQL_IMPL_H_ -#define _MM_SQL_IMPL_H_ - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct sql_ops_tab sql_ops_tab_t; -struct sql_ops_tab { - char *sql_mmp_ops; - char *sql_ops; -}; - -/* - * Common SQL - */ -int mm_sql_chk_len(char **line, int off, int *bufsize, int len); -void mm_sql_db_err_rsp_new(mm_command_t *command, mm_db_t *db); -int mm_sql_trans_match_new(mm_command_t *command, int *offset); -int mm_sql_trans_order_new(mm_command_t *cmd, int *offset); -int mm_sql_trans_number_new(mm_command_t *cmd, int *offset); -int mm_sql_report_clause_new(mm_command_t *command, char *objname); -int mm_sql_notify_inst_new(mm_db_t *db, mm_command_t *cmd, char *objname, - int match_off, char **objinst); -void mm_sql_order(mm_command_t *cmd); -void mm_sql_number(mm_command_t *cmd); -int mm_notify_delete(mm_db_t *db, mm_command_t *cmd, char *objname, - int match_off); -int mm_get_dest(mm_wka_t *mm_wka, mm_command_t *cmd); -int mm_get_const(mm_wka_t *mm_wka, mm_command_t *cmd); -int mm_add_char(char *str, mms_list_t *list); - -#ifdef __cplusplus -} -#endif - -#endif /* _MM_SQL_IMPL_H_ */ diff --git a/usr/src/cmd/mms/mm/common/mm_task.c b/usr/src/cmd/mms/mm/common/mm_task.c deleted file mode 100644 index 17abaeb27a..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_task.c +++ /dev/null @@ -1,2047 +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. - */ - - -#include <sys/types.h> -#include <mms_list.h> -#include <mms_parser.h> -#include <libpq-fe.h> -#include <string.h> -#include <stdlib.h> -#include <pthread.h> -#include <errno.h> -#include <syslog.h> -#include <mms_trace.h> -#include <mms_strapp.h> -#include "mm_db.h" -#include "mm.h" -#include "mm_util.h" -#include "mm_sql.h" -#include "mm_commands.h" -#include "mm_sql.h" -#include "mm_sql_impl.h" -#include "mm_task.h" - -static char *_SrcFile = __FILE__; - -#define MM_BE_ERROR 0 -#define MM_BE_DISPATCH 1 -#define MM_BE_BLOCKING 2 -#define MM_BE_OK 3 - -cmi_drive_list_t * -tm_return_drive_ptr(char *drive, cmi_cart_list_t *cart) { - /* if drive is NULL return the 1st drive in the list */ - cmi_drive_list_t *cur_drive = NULL; - - if (drive == NULL) { - cur_drive = mms_list_head(&cart->cmi_drive_list); - if (cur_drive == NULL) { - mms_trace(MMS_ERR, - "1st drive was NULL"); - } - return (cur_drive); - - } - - mms_list_foreach(&cart->cmi_drive_list, cur_drive) { - if (strcmp(cur_drive->cmi_drive_name, - drive) == 0) { - return (cur_drive); - } - } - return (NULL); -} - -cmi_cart_list_t * -tm_return_cart_ptr(char *cart_id, cmd_mount_info_t *mount_info) { - cmi_cart_list_t *cur_cart; - mms_list_foreach(&mount_info->cmi_cart_list, cur_cart) { - if (strcmp(cur_cart->cmi_cart_id, - cart_id) == 0) { - return (cur_cart); - } - } - return (NULL); -} - - -char * -tm_return_dm_name(char *drive_name, char *host, mm_data_t *mm_data) { - /* Return the dm name for drive_name on host */ - mm_db_t *db = &mm_data->mm_db_tm; - char *dm_name = NULL; - if (mm_db_exec(HERE, db, - "select \"DMName\" from \"DM\" " - "where \"DM\".\"DriveName\" = '%s' and " - " pg_host_ident(\"DMTargetHost\") " - "= pg_host_ident('%s');", - drive_name, host) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error, tm_return_dm_name"); - return (NULL); - } - if (PQntuples(db->mm_db_results) != 1) { - mms_trace(MMS_ERR, - "row num mismatch , tm_return_dm_name"); - return (NULL); - } - dm_name = mms_strapp(dm_name, PQgetvalue(db->mm_db_results, 0, 0)); - mm_clear_db(&db->mm_db_results); - return (dm_name); -} - -int -tm_can_dispatch_mount(mm_command_t *cmd, mm_data_t *mm_data) -{ - - /* Use this function for both unmout and mounts */ - mm_db_t *db = &mm_data->mm_db_tm; - - mm_wka_t *mm_wka = cmd->wka_ptr; - - - int rc; - - mms_trace(MMS_DEVP, - "tm_can_dispatch_mount"); - - rc = mm_mount_ready(mm_wka, cmd, db, 0); - switch (rc) { - - case MM_MOUNT_ERROR: - /* Error code should be set */ - mms_trace(MMS_ERR, - "internal error, mm_mount_ready"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (0); - - case MM_MOUNT_READY: - /* The mount is ready, mount_info should be set */ - /* continue to state 1 */ - cmd->cmd_state = 1; - mms_trace(MMS_DEVP, - "mount is ready to go, " - "continue to state 1"); - MM_SET_FLAG(cmd->cmd_flags, MM_CMD_DISPATCHABLE); - return (1); - - case MM_MOUNT_NEED_UNLOAD: - /* this immediate mount needs to */ - /* wait for an unload */ - cmd->cmd_state = 1; - mms_trace(MMS_DEVP, - "mount waiting " - "for unload to complete"); - return (1); - - case MM_MOUNT_NOT_READY: - /* Error code should be set */ - mms_trace(MMS_ERR, - "blocking mount not ready, " - "wait longer and try later"); - return (0); - - default: - mms_trace(MMS_ERR, - "bad rc mm_mount_ready"); - mm_system_error(cmd, - "bad rc mm_mount_ready"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (0); - } - -} - - - -PGresult* tm_get_inuse_carts(mm_command_t *cmd, mm_data_t *mm_data) { - /* returns ordered list of inuse candidate cartridges */ - /* for task_id */ - - mm_db_t *db = &mm_data->mm_db_tm; - char *task_id = cmd->cmd_uuid; - - if (mm_db_exec(HERE, db, "select \"CartridgeID\" " - "from \"CARTRIDGE\" " - "where \"CartridgeStatus\" = 'in use' " - "and \"CartridgeID\" " - "in (select distinct \"CartridgeID\" " - "from \"TASKCARTRIDGE\" " - "where \"TaskID\" = '%s') " - "order by \"CartridgeNumberMounts\";", - task_id) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db_error, tm_get_inuse_carts"); - return (NULL); - } - return (db->mm_db_results); -} - -int -tm_can_dispatch_unmount(mm_command_t *cmd, mm_data_t *mm_data) -{ - mm_db_t *db = &mm_data->mm_db_tm; - mm_wka_t *mm_wka = cmd->wka_ptr; - - int rc; - - mms_trace(MMS_DEVP, - "tm_can_dispatch_unmount"); - - rc = mm_unmount_ready(mm_wka, cmd, db); - switch (rc) { - - case MM_UNMOUNT_ERROR: - /* Error code should be set */ - mms_trace(MMS_ERR, - "internal error, mm_unmount_ready"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (0); - - case MM_UNMOUNT_READY: - /* The unmount is ready, unmount_info should be set */ - /* continue to state 1 */ - cmd->cmd_state = 1; - mms_trace(MMS_DEVP, - "unmount is ready to go, " - "continue to state 1"); - return (1); - - case MM_UNMOUNT_NOT_READY: - /* Error code should be set */ - mms_trace(MMS_ERR, - "blocking unmount not ready, " - "wait longer and try later"); - return (0); - default: - mms_trace(MMS_ERR, - "bad rc mm_unmount_ready"); - mm_system_error(cmd, - "bad rc mm_unmount_ready"); - cmd->cmd_remove = 1; - mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf); - return (0); - } - -} - -int -mm_be_remove_non_ready(mm_command_t *cmd) { - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - cmi_cart_list_t *cart = NULL; - cmi_drive_list_t *drive = NULL; - mms_list_foreach(&mount_info->cmi_cart_list, cart) { - if (cart->cmi_cart_not_ready) { - cart->cmi_remove_cart = 1; - } - mms_list_foreach(&cart->cmi_drive_list, drive) { - if (drive->cmi_drive_not_ready) { - drive->cmi_remove_drive = 1; - } - } - } - mm_mount_clean_candidates(cmd); - return (0); -} - -int -tm_be_unmount_ready(mm_wka_t *mm_wka, mm_command_t *cmd, mm_db_t *db, - mm_command_t *end_cmd) { - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - PGresult *cart_results; - int cart_rows; - - int found_cart_drive = 0; - int found_ready_cart_drive = 0; - - cmi_cart_list_t *cart = NULL; - cmi_drive_list_t *drive = NULL; - - /* Do drive/cart/lib selection using path matching */ - if ((cart_results = mm_unmount_cart_results(mm_wka, - cmd, db)) == NULL) { - mm_system_error(end_cmd, - "error getting candidate " - "cartridge"); - /* No carts or error */ - return (MM_UNMOUNT_ERROR); - } - - cart_rows = PQntuples(cart_results); - mms_trace(MMS_DEVP, "Number of Cartridges is %d", cart_rows); - if (cart_rows == 0) { - /* No Cartridge Matches Error */ - mms_trace(MMS_INFO, - "match statment in mount " - "didn't match any cartridge/volumes"); - mm_response_error(end_cmd, - ECLASS_EXPLICIT, ENOMATCH, - MM_5052_MSG, - NULL); - mm_clear_db(&cart_results); - return (MM_UNMOUNT_ERROR); - } - - /* Create the list objects for */ - /* every cartridge/drive candidate */ - if (mm_mount_init_candidates(cmd, cart_results, - db)) { - mms_trace(MMS_ERR, - "error initializing candidate lists"); - /* err buf should be set by mm_mount_init */ - /* so return and remove */ - mm_system_error(end_cmd, - "error init candidate lists"); - return (MM_UNMOUNT_ERROR); - } - mms_trace(MMS_DEVP, "candidate list created, check availability "); - - /* Check the availability of the candidates */ - if (mm_mount_check_candidates(mm_wka, cmd, - db)) { - mms_trace(MMS_ERR, - "error checking candidate lists"); - mm_system_error(end_cmd, - "error checking candidate lists"); - return (MM_UNMOUNT_ERROR); - } - mms_trace(MMS_DEVP, "done checking list"); - - /* Print mount information */ - mm_print_mount_summary(mm_wka, cmd); - found_cart_drive = 0; - found_ready_cart_drive = 0; - - mms_list_foreach(&mount_info->cmi_cart_list, cart) { - mms_list_foreach(&cart->cmi_drive_list, drive) { - found_cart_drive = 1; - if ((cart->cmi_cart_not_ready == 0) && - (drive->cmi_drive_not_ready == 0)) { - found_ready_cart_drive = 1; - } - } - } - - - /* If there is a library or drive error */ - /* the error buff has already been set */ - if (found_cart_drive == 0) { - mms_trace(MMS_ERR, - "No candidate " - "cartridge/library/drive " - "combination found"); - mm_response_error(end_cmd, - ECLASS_EXPLICIT, - "ENOSOLUTIONS", - MM_5105_MSG, - NULL); - return (MM_UNMOUNT_ERROR); - } - if (found_ready_cart_drive == 0) { - mms_trace(MMS_ERR, - "candidate " - "cartridge/library/drive " - "combination found, but is not ready"); - mm_response_error(end_cmd, - ECLASS_RETRY, - "ETMPUNAVAIL", - MM_5104_MSG, - NULL); - return (MM_UNMOUNT_NOT_READY); - } - - return (MM_UNMOUNT_READY); - -} - -int -tm_be_mount_ready(mm_wka_t *mm_wka, mm_command_t *cmd, mm_db_t *db, - mm_command_t *end_cmd) { - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - PGresult *cart_results; - int cart_rows; - - cmi_cart_list_t *cart = NULL; - cmi_drive_list_t *drive = NULL; - - - int found_cart_drive = 0; - int found_ready_cart_drive = 0; - - char *err_text = NULL; - - - /* Need to set end_cmd buf correctly for any MM_MOUNT_ERROR return */ - - - /* Do drive/cart/lib selection using path matching */ - if ((cart_results = mm_mount_cart_results(mm_wka, - cmd, db)) == NULL) { - mm_system_error(end_cmd, - "error getting candidate " - "cartridge"); - /* No carts or error */ - return (MM_MOUNT_ERROR); - } - - cart_rows = PQntuples(cart_results); - mms_trace(MMS_DEVP, "Number of Cartridges is %d", cart_rows); - - if (cart_rows == 0) { - /* No Cartridge Matches Error */ - mms_trace(MMS_INFO, - "match statment in mount " - "didn't match any cartridge/volumes"); - mm_response_error(end_cmd, - ECLASS_EXPLICIT, ENOMATCH, - MM_5052_MSG, - NULL); - mm_clear_db(&cart_results); - return (MM_MOUNT_ERROR); - } - /* Create the list objects for */ - /* every cartridge/drive candidate */ - if (mm_mount_init_candidates(cmd, cart_results, - db)) { - mms_trace(MMS_ERR, - "error initializing candidate lists"); - /* err buf should be set by mm_mount_init */ - /* so return and remove */ - mm_system_error(end_cmd, - "error init candidate lists"); - mm_clear_db(&cart_results); - return (MM_MOUNT_ERROR); - } - mms_trace(MMS_DEVP, "candidate list created, check availability "); - mm_clear_db(&cart_results); - - /* Check the availability of the candidates */ - if (mm_mount_check_candidates(mm_wka, cmd, - db)) { - mms_trace(MMS_ERR, - "error checking candidate lists"); - mm_system_error(end_cmd, - "error checking candidate lists"); - return (MM_MOUNT_ERROR); - } - mms_trace(MMS_DEVP, "done checking list"); - - /* Print mount information */ - mm_print_mount_summary(mm_wka, cmd); - - - /* - * For blocking mounts, - * check that at least some cart/drive combo exists - * if that cart/drive exists, but is not ready, return not ready - * - * for immediate mounts, check that at least one combination exists - */ - - found_cart_drive = 0; - found_ready_cart_drive = 0; - - mms_list_foreach(&mount_info->cmi_cart_list, cart) { - mms_list_foreach(&cart->cmi_drive_list, drive) { - found_cart_drive = 1; - if ((cart->cmi_cart_not_ready == 0) && - (drive->cmi_drive_not_ready == 0)) { - found_ready_cart_drive = 1; - } - } - } - - - /* If there is a library or drive error */ - /* the error buff has already been set */ - if (found_cart_drive == 0) { - mms_trace(MMS_ERR, - "No candidate " - "cartridge/library/drive " - "combination found"); - - /* If this cmd has a retry error class */ - /* Send a retry error */ - if (strcmp(cmd->cmd_eclass, ECLASS_RETRY) == 0) { - /* This is a retry error */ - mms_trace(MMS_ERR, - "Error is from a retry error"); - - mm_response_error(end_cmd, - ECLASS_RETRY, - "ETMPUNAVAIL", - MM_5104_MSG, - NULL); - return (MM_MOUNT_ERROR); - } - err_text = mm_return_err_text(cmd->cmd_err_ptr); - mm_response_error(end_cmd, - ECLASS_EXPLICIT, - "ENOSOLUTIONS", - MM_5110_MSG, - "err_text", err_text, - NULL); - free(err_text); - return (MM_MOUNT_ERROR); - } - if (found_ready_cart_drive == 0) { - mms_trace(MMS_ERR, - "candidate " - "cartridge/library/drive " - "combination found, but is not ready"); - - mm_response_error(end_cmd, - ECLASS_RETRY, - "ETMPUNAVAIL", - MM_5104_MSG, - NULL); - - return (MM_MOUNT_NOT_READY); - } - - return (MM_MOUNT_READY); -} - -#define TM_CANCEL_RESPONSE "response task[\"%s\"] cancelled;" - -void -mm_cancel_cmd_buf(mm_command_t *cmd) { - char *buf = NULL; - buf = mms_strnew(TM_CANCEL_RESPONSE, cmd->cmd_task); - SQL_CHK_LEN(&cmd->cmd_buf, 0, - &cmd->cmd_bufsize, strlen(buf) + 1); - strcpy(cmd->cmd_buf, buf); - free(buf); - buf = NULL; - return; -no_mem: - MM_ABORT_NO_MEM(); -} - -void -tm_be_cancel_all(mm_command_t *cmd) { - mm_command_t *cur_cmd; - - /* Send cancel for all commands in this group */ - mms_list_foreach(&cmd->cmd_beginend_list, cur_cmd) { - mm_cancel_cmd_buf(cur_cmd); - - mm_send_text(cur_cmd->wka_ptr->mm_wka_conn, - cur_cmd->cmd_buf); - } - -} - -int -tm_be_set_mount(mm_command_t *cmd, mm_db_t *db, - mm_command_t *end_cmd) { - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - char *drive_to_unload = NULL; - char *lib_to_unload = NULL; - - - - /* cmd is the mount command */ - MM_SET_FLAG(cmd->cmd_flags, - MM_CMD_DISPATCHABLE); - cmd->cmd_state = 1; - - /* This code is the same code as is in mm_set_immediate_mount */ - /* make a common function?? */ - if (mm_mount_candidate_loaded(cmd)) { - mms_trace(MMS_DEVP, - "a candidate cartridge is loaded"); - mount_info->cmi_mount_type = - MM_CANDIDATE_LOADED; - } else if (mm_mount_open_drive(cmd)) { - mms_trace(MMS_DEVP, - "open drive found"); - mount_info->cmi_mount_type = - MM_OPEN_DRIVE; - } else if (mm_mount_loaded_drive(cmd, db, &drive_to_unload, - &lib_to_unload)) { - /* 2 mount time */ - /* these mounts need an unmount, then mount */ - if (drive_to_unload == NULL && - lib_to_unload == NULL) { - mount_info->cmi_mount_type = - MM_UNMOUNT_DRIVE; - mms_trace(MMS_DEVP, - "drive loaded with non-candidate " - "must unload 1st"); - /* Need to set up parent command */ - /* return as dispatch depend */ - mms_trace(MMS_DEVP, - "%s needs unload to complete first", - mount_info->cmi_drive); - MM_UNSET_FLAG(cmd->cmd_flags, - MM_CMD_DISPATCHABLE); - } else { - mms_trace(MMS_DEVP, - "candidate loaded in non-candidate drive " - "must unload 1st"); - /* Need to set up parent command */ - /* return as dispatch depend */ - mms_trace(MMS_DEVP, - "%s needs unload to complete first", - drive_to_unload); - mount_info->cmi_mount_type = - MM_UNMOUNT_CART; - mount_info->cmi_first_drive = - strdup(drive_to_unload); - mount_info->cmi_first_lib = - strdup(lib_to_unload); - MM_UNSET_FLAG(cmd->cmd_flags, - MM_CMD_DISPATCHABLE); - free(drive_to_unload); - free(lib_to_unload); - } - } else if (mm_unmount_2_drive(cmd, db)) { - /* 3 mount time */ - /* Candidate cart is mounted, */ - /* the only candidate drive is loaded with non-candidate */ - /* need to unmount candidate cart, unmount candidate drive */ - /* then mount candidate cart/drive */ - MM_UNSET_FLAG(cmd->cmd_flags, MM_CMD_DISPATCHABLE); - - } else { - mms_trace(MMS_ERR, - "no drives found due to other candidates"); - mm_set_least_severe(cmd); - if (cmd->cmd_err_ptr == NULL) { - mms_trace(MMS_ERR, - "cmd has no errors, set ENOMATCH"); - mm_response_error(end_cmd, - ECLASS_EXPLICIT, ENOMATCH, - MM_5052_MSG, - NULL); - } - return (MM_BE_ERROR); - } - - /* Select Is done - print the results */ - mms_trace(MMS_DEVP, "Cart/Lib/Drive selection " - "complete for task %s", - cmd->cmd_uuid); - mms_trace(MMS_DEVP, "Cartridge ID is %s", - mount_info->cmi_cartridge); - mms_trace(MMS_DEVP, "Library is %s", - mount_info->cmi_library); - mms_trace(MMS_DEVP, "Drive is %s", - mount_info->cmi_drive); - mms_trace(MMS_DEVP, "DM is %s", - mount_info->cmi_dm); - - /* since this mount will work, clear the error flags for it */ - if (cmd->cmd_eclass != NULL) { - free(cmd->cmd_eclass); - cmd->cmd_eclass = NULL; - } - if (cmd->cmd_ecode != NULL) { - free(cmd->cmd_ecode); - cmd->cmd_ecode = NULL; - } - cmd->cmd_mount_info.cmi_mount_ok = 1; - - return (MM_BE_DISPATCH); -} - -int -tm_be_set_unmount(mm_wka_t *mm_wka, mm_command_t *cmd, - mm_command_t *end_cmd) { - cmd_mount_info_t *mount_info = &cmd->cmd_mount_info; - - cmi_cart_list_t *cart = NULL; - cmi_drive_list_t *drive = NULL; - - char *cur_cartid = NULL; - char *cur_library = NULL; - char *cur_dm = NULL; - char *cur_drive = NULL; - - /* cmd is the unmount command */ - - cart = mms_list_head(&mount_info->cmi_cart_list); - if (cart == NULL) { - mm_response_error(end_cmd, - ECLASS_RETRY, - "ETMPUNAVAIL", - MM_5104_MSG, - NULL); - if (mm_wka->wka_begin_end.be_mode == - ACCESS_MODE_BLOCKING) { - return (MM_BE_BLOCKING); - } - mms_trace(MMS_ERR, - "unmount has no candidates" - " due to other unmount"); - return (MM_BE_ERROR); - } - cur_library = cart->cmi_library; - cur_cartid = cart->cmi_cart_id; - - drive = mms_list_head(&cart->cmi_drive_list); - if (drive == NULL) { - mm_response_error(end_cmd, - ECLASS_RETRY, - "ETMPUNAVAIL", - MM_5104_MSG, - NULL); - if (mm_wka->wka_begin_end.be_mode == - ACCESS_MODE_BLOCKING) { - return (MM_BE_BLOCKING); - } - mms_trace(MMS_ERR, - "unmount has no candidates" - " due to other unmount"); - return (MM_BE_ERROR); - } - - cur_drive = drive->cmi_drive_name; - cur_dm = drive->cmi_dm_name; - - - mm_set_mount_info_cart(cur_cartid, - mount_info); - mm_set_mount_info_drive(cur_drive, - mount_info); - mm_set_mount_info_dm(cur_dm, - mount_info); - mm_set_mount_info_library(cur_library, - mount_info); - - /* Select Is done - print the results */ - mms_trace(MMS_DEVP, "Cart/Lib/Drive selection " - "complete for task %s", - cmd->cmd_uuid); - mms_trace(MMS_DEVP, "Cartridge ID is %s", - mount_info->cmi_cartridge); - mms_trace(MMS_DEVP, "Library is %s", - mount_info->cmi_library); - mms_trace(MMS_DEVP, "Drive is %s", - mount_info->cmi_drive); - mms_trace(MMS_DEVP, "DM is %s", - mount_info->cmi_dm); - - return (MM_BE_DISPATCH); -} - -void -tm_be_rm_error_candidates(mm_command_t *cmd, mm_command_t *err_cmd) { - /* remove candidates set in err_cmd */ - /* from the beginend candidatea list in cmd */ - - mm_cmd_err_t *err = err_cmd->cmd_err_ptr; - mm_command_t *cur_cmd; - cmd_mount_info_t *cur_mount_info; - - cmi_cart_list_t *cart = NULL; - cmi_drive_list_t *drive = NULL; - - mms_list_t *cart_list; - - int seen_same = 0; - mm_cmd_err_t *cur_err = NULL; - - mms_trace(MMS_DEVP, - "tm_be_rm_error_candidates: "); - if (err == NULL) { - mms_trace(MMS_ERR, - "tm_be_rm_error_candidates: " - "error ptr set to NULL"); - return; - } - - mms_trace(MMS_DEVP, - " Error to remove:"); - mm_print_err(err); - - mms_list_foreach(&cmd->cmd_beginend_list, cur_cmd) { - /* same command */ - if (cur_cmd == err_cmd) { - seen_same = 1; - continue; - } - if (seen_same == 0) { - continue; - } - - /* check cur_cmd's error */ - mms_list_foreach(&cur_cmd->cmd_err_list, cur_err) { - if (mm_same_err(err, cur_err)) { - cur_err->err_already_used = 1; - mms_trace(MMS_DEVP, - " matched an err"); - } - } - cur_cmd->cmd_err_ptr = NULL; - mm_set_least_severe(cur_cmd); - - cur_mount_info = &cur_cmd->cmd_mount_info; - cart_list = &cur_mount_info->cmi_cart_list; - mms_list_foreach(cart_list, cart) { - /* Check this cart */ - if ((err->retry_cart != NULL) && - (cart->cmi_cart_id != NULL) && - (strcmp(err->retry_cart, - cart->cmi_cart_id) == 0)) { - cart->cmi_cart_used = 1; - mms_trace(MMS_DEVP, - "tm_be_rm_error_candidates: " - "set a cart as used"); - } - mms_list_foreach(&cart->cmi_drive_list, drive) { - /* check this drive */ - if ((err->retry_drive != NULL) && - (drive->cmi_drive_name != NULL) && - (strcmp(err->retry_drive, - drive->cmi_drive_name) == 0)) { - drive->cmi_drive_used = 1; - mms_trace(MMS_DEVP, - "tm_be_rm_error_candidates: " - "set a drive as used"); - } - } - } - } -} - -void -tm_be_rm_mount_candidates(mm_command_t *cmd, mm_command_t *set_cmd) { - /* remove candidates set in set_cmd */ - /* from the beginend candidatea list in cmd */ - mm_command_t *cur_cmd; - cmd_mount_info_t *set_mount_info = &set_cmd->cmd_mount_info; - cmd_mount_info_t *cur_mount_info; - - cmi_cart_list_t *cart = NULL; - cmi_drive_list_t *drive = NULL; - - mms_list_t *cart_list; - - int seen_same = 0; - - mms_trace(MMS_DEVP, - "set %s and %s as used candidates", - set_mount_info->cmi_cartridge, - set_mount_info->cmi_drive); - mms_list_foreach(&cmd->cmd_beginend_list, cur_cmd) { - /* same command */ - if (cur_cmd == set_cmd) { - seen_same = 1; - continue; - } - if (seen_same == 0) { - continue; - } - cur_mount_info = &cur_cmd->cmd_mount_info; - cart_list = &cur_mount_info->cmi_cart_list; - mms_list_foreach(cart_list, cart) { - if (strcmp(set_mount_info->cmi_cartridge, - cart->cmi_cart_id) == 0) { - cart->cmi_cart_used = 1; - } - mms_list_foreach(&cart->cmi_drive_list, drive) { - if (strcmp(set_mount_info->cmi_drive, - drive->cmi_drive_name) == 0) { - drive->cmi_drive_used = 1; - } - } - } - } -} - -void -tm_be_rm_unmount_candidates(mm_command_t *cmd, mm_command_t *set_cmd) { - /* remove candidates set in set_cmd */ - /* from the beginend candidatea list in cmd */ - mm_command_t *cur_cmd; - cmd_mount_info_t *set_mount_info = &set_cmd->cmd_mount_info; - cmd_mount_info_t *cur_mount_info; - cmi_cart_list_t *cart = NULL; - - cmi_drive_list_t *drive = NULL; - - - mms_list_t *cart_list; - - int seen_same = 0; - - mms_trace(MMS_DEVP, - "remove %s and %s from candidate lists", - set_mount_info->cmi_cartridge, - set_mount_info->cmi_drive); - mms_list_foreach(&cmd->cmd_beginend_list, cur_cmd) { - if (cur_cmd->cmd_func == mm_mount_cmd_func) { - /* not an unmount */ - continue; - } - /* same command */ - if (cur_cmd == set_cmd) { - seen_same = 1; - continue; - } - if (seen_same == 0) { - continue; - } - cur_mount_info = &cur_cmd->cmd_mount_info; - cart_list = &cur_mount_info->cmi_cart_list; - mms_list_foreach(cart_list, cart) { - if (strcmp(set_mount_info->cmi_cartridge, - cart->cmi_cart_id) == 0) { - cart->cmi_remove_cart = 1; - } - mms_list_foreach(&cart->cmi_drive_list, drive) { - if (strcmp(set_mount_info->cmi_drive, - drive->cmi_drive_name) == 0) { - drive->cmi_remove_drive = 1; - } - } - } - mm_mount_clean_candidates(cur_cmd); - } -} - -int -tm_be_is_in_unmount(char *drive_name, mm_command_t *end_cmd) { - mm_command_t *cur_cmd; - - mms_list_foreach(&end_cmd->cmd_beginend_list, cur_cmd) { - if (cur_cmd->cmd_func == mm_mount_cmd_func) { - /* not an unmount */ - continue; - } - if (strcmp(cur_cmd->cmd_mount_info.cmi_drive, - drive_name) == 0) { - return (1); - } - } - return (0); -} - -int -tm_be_init_mount(mm_command_t *end_cmd, mm_db_t *db) { - /* this function needs to initialize the mount cmd's */ - /* Candidate lists using the selected carts/drives */ - /* in the unmount commands */ - /* tm_be_match_mount will match mounts to unmounts */ - - PGresult *cart_results; - int cart_rows; - - mm_wka_t *mm_wka = end_cmd->wka_ptr; - - mm_command_t *cur_cmd; - - cmi_cart_list_t *cart = NULL; - cmi_drive_list_t *drive = NULL; - mms_list_t *cart_list; - - mms_list_foreach(&end_cmd->cmd_beginend_list, cur_cmd) { - /* Do drive/cart/lib selection using path matching */ - if ((cart_results = mm_mount_cart_results(mm_wka, - cur_cmd, db)) == NULL) { - mm_system_error(end_cmd, - "error getting candidate " - "cartridge"); - /* No carts or error */ - return (MM_BE_ERROR); - } - cart_rows = PQntuples(cart_results); - mms_trace(MMS_DEVP, "Number of Cartridges is %d", cart_rows); - - if (cart_rows == 0) { - /* No Cartridge Matches Error */ - mms_trace(MMS_INFO, - "match statment in mount " - "didn't match any cartridge/volumes"); - mm_response_error(end_cmd, - ECLASS_EXPLICIT, ENOMATCH, - MM_5052_MSG, - NULL); - mm_clear_db(&cart_results); - return (MM_BE_ERROR); - } - - /* Create the list objects for */ - /* every cartridge/drive candidate */ - if (mm_mount_init_candidates(cur_cmd, cart_results, - db)) { - mms_trace(MMS_ERR, - "error initializing candidate lists"); - /* err buf should be set by mm_mount_init */ - /* so return and remove */ - mm_system_error(end_cmd, - "error init candidate lists"); - mm_clear_db(&cart_results); - return (MM_BE_ERROR); - } - mm_clear_db(&cart_results); - } - - mms_trace(MMS_DEVP, - "keep only drive candidates selected in unmount cmd"); - /* Keep only the drive candidates selected in a unmount command */ - mms_list_foreach(&end_cmd->cmd_beginend_list, cur_cmd) { - if (cur_cmd->cmd_func == mm_unmount_cmd_func) { - /* not an mount */ - continue; - } - cart_list = &cur_cmd->cmd_mount_info.cmi_cart_list; - mms_list_foreach(cart_list, cart) { - mms_list_foreach(&cart->cmi_drive_list, drive) { - mms_trace(MMS_DEVP, - " check if %s is selected in an unmount", - drive->cmi_drive_name); - if (tm_be_is_in_unmount(drive->cmi_drive_name, - end_cmd) == 0) { - mms_trace(MMS_DEVP, - " remove this drive"); - drive->cmi_remove_drive = 1; - } else { - mms_trace(MMS_DEVP, - " keep this drive"); - drive->cmi_remove_drive = 0; - } - } - } - mm_mount_clean_candidates(cur_cmd); - } - return (MM_BE_OK); - -} -int -tm_be_match_mount(mm_command_t *mnt_cmd, mm_command_t *end_cmd, mm_db_t *db) { - /* select the cart drive for this mnt */ - mm_wka_t *mm_wka = end_cmd->wka_ptr; - cmd_mount_info_t *mount_info = &mnt_cmd->cmd_mount_info; - - cmi_cart_list_t *cart = NULL; - cmi_drive_list_t *drive = NULL; - - char *cur_cartid = NULL; - char *cur_library = NULL; - char *cur_dm = NULL; - char *cur_drive = NULL; - - mm_command_t *unmnt_cmd1 = NULL; - mm_command_t *unmnt_cmd2 = NULL; - - mm_command_t *cur_cmd; - int found_unmount = 0; - - mms_trace(MMS_DEVP, - "tm_be_match_mount"); - MM_UNSET_FLAG(mnt_cmd->cmd_flags, - MM_CMD_DISPATCHABLE); - mnt_cmd->cmd_state = 1; - - - cart = mms_list_head(&mount_info->cmi_cart_list); - if (cart == NULL) { - mm_response_error(end_cmd, - ECLASS_RETRY, - "ETMPUNAVAIL", - MM_5104_MSG, - NULL); - if (mm_wka->wka_begin_end.be_mode == - ACCESS_MODE_BLOCKING) { - return (MM_BE_BLOCKING); - } - mms_trace(MMS_ERR, - "mount has no candidates"); - return (MM_BE_ERROR); - } - cur_library = cart->cmi_library; - cur_cartid = cart->cmi_cart_id; - - drive = mms_list_head(&cart->cmi_drive_list); - if (drive == NULL) { - mm_response_error(end_cmd, - ECLASS_RETRY, - "ETMPUNAVAIL", - MM_5104_MSG, - NULL); - if (mm_wka->wka_begin_end.be_mode == - ACCESS_MODE_BLOCKING) { - return (MM_BE_BLOCKING); - } - mms_trace(MMS_ERR, - "mount has no candidates"); - return (MM_BE_ERROR); - } - - cur_drive = drive->cmi_drive_name; - cur_dm = drive->cmi_dm_name; - - mm_set_mount_info_cart(cur_cartid, - mount_info); - mm_set_mount_info_drive(cur_drive, - mount_info); - mm_set_mount_info_dm(cur_dm, - mount_info); - mm_set_mount_info_library(cur_library, - mount_info); - - /* Select Is done - print the results */ - mms_trace(MMS_DEVP, "Cart/Lib/Drive selection " - "complete for task %s", - mnt_cmd->cmd_uuid); - mms_trace(MMS_DEVP, "Cartridge ID is %s", - mount_info->cmi_cartridge); - mms_trace(MMS_DEVP, "Library is %s", - mount_info->cmi_library); - mms_trace(MMS_DEVP, "Drive is %s", - mount_info->cmi_drive); - mms_trace(MMS_DEVP, "DM is %s", - mount_info->cmi_dm); - - - mm_remove_all_depend(mnt_cmd); - mms_list_foreach(&end_cmd->cmd_beginend_list, cur_cmd) { - if (cur_cmd->cmd_func == mm_mount_cmd_func) { - /* not an unmount */ - continue; - } - if (strcmp(mount_info->cmi_drive, - cur_cmd->cmd_mount_info.cmi_drive) == 0) { - /* same drive */ - mm_add_depend(mnt_cmd, cur_cmd); - found_unmount = 1; - unmnt_cmd1 = cur_cmd; - } - } - if (found_unmount == 0) { - mm_system_error(end_cmd, - "couldn't find unmount for this mount"); - mms_trace(MMS_ERR, - "couldn't find unmount for this mount"); - return (MM_BE_ERROR); - } - - - /* Is this cart currently loaded */ - if (mm_db_exec(HERE, db, - "select \"LibraryName\",\"DriveName\" " - "from \"DRIVE\" where \"DRIVE\"." - "\"CartridgePCL\" = (select \"CartridgePCL\" " - "from \"CARTRIDGE\" where \"CartridgeID\" = '%s');", - mount_info->cmi_cartridge) != MM_DB_DATA) { - mms_trace(MMS_ERR, - "tm_be_match_mount: " - "db error getting drive info"); - mm_sql_db_err_rsp_new(end_cmd, db); - return (MM_BE_ERROR); - } - - if (PQntuples(db->mm_db_results) == 0) { - /* Cur cart is not loaded */ - mms_trace(MMS_DEVP, - "cartid %s not found in a drive", - mount_info->cmi_cartridge); - } else { - mms_trace(MMS_DEVP, - "need to unmount %s, %s " - "before mount ", - PQgetvalue(db->mm_db_results, 0, 0), - PQgetvalue(db->mm_db_results, 0, 1)); - - unmnt_cmd2 = mm_return_unload( - PQgetvalue(db->mm_db_results, 0, 0), - PQgetvalue(db->mm_db_results, 0, 1), - mm_wka->mm_data); - if (unmnt_cmd2 == NULL) { - mm_system_error(end_cmd, - "couldn't find unmount for this mount"); - mms_trace(MMS_ERR, - "couldn't find unmount for this mount"); - return (MM_BE_ERROR); - } - MM_SET_FLAG(unmnt_cmd1->cmd_flags, - MM_CMD_DISPATCHABLE); - MM_UNSET_FLAG(mnt_cmd->cmd_flags, MM_CMD_DISPATCHABLE); - MM_UNSET_FLAG(unmnt_cmd2->cmd_flags, MM_CMD_DISPATCHABLE); - mms_trace(MMS_DEVP, - "unmnt_cmd1->cmd_name == %s (%p)", - unmnt_cmd1->cmd_name, - unmnt_cmd1); - mms_trace(MMS_DEVP, - "unmnt_cmd2->cmd_name == %s (%p)", - unmnt_cmd2->cmd_name, unmnt_cmd2); - mms_trace(MMS_DEVP, - "mnt_cmd->cmd_name == %s (%p)", - mnt_cmd->cmd_name, mnt_cmd); - mm_remove_all_depend(mnt_cmd); - mm_add_depend(unmnt_cmd1, unmnt_cmd2); - mm_add_depend(unmnt_cmd2, mnt_cmd); - } - mm_clear_db(&db->mm_db_results); - mms_trace(MMS_DEVP, - "mount finished setting up"); - return (MM_BE_OK); -} - -int -tm_be_pairs(mm_command_t *cmd, mm_data_t *mm_data) { - /* This is what the function may return */ - /* MM_BE_ERROR */ - /* MM_BE_BLOCKING */ - /* MM_BE_DISPATCH */ - /* For BLOCKING and MMS_ERROR, end cmd error buf */ - /* Should be set */ - - mm_db_t *db = &mm_data->mm_db_tm; - mm_wka_t *mm_wka = cmd->wka_ptr; - mm_command_t *cur_cmd; - int rc; - mms_trace(MMS_DEVP, - "tm_be_pairs"); - - mms_list_foreach(&cmd->cmd_beginend_list, cur_cmd) { - if (cur_cmd->cmd_func == mm_mount_cmd_func) { - /* not an unmount */ - continue; - } - - rc = tm_be_unmount_ready(cur_cmd->wka_ptr, cur_cmd, db, cmd); - switch (rc) { - - case MM_UNMOUNT_ERROR: - /* Error code should be set */ - mms_trace(MMS_ERR, - "internal error, mm_unmount_ready"); - return (MM_BE_ERROR); - - case MM_UNMOUNT_READY: - mms_trace(MMS_DEVP, - "unmount is ready to go, "); - break; - - case MM_UNMOUNT_NOT_READY: - if (mm_wka->wka_begin_end.be_mode == - ACCESS_MODE_IMMEDIATE) { - /* Error code should be set */ - mms_trace(MMS_ERR, - "immediate begin-end group " - "is not ready"); - return (MM_BE_ERROR); - } - /* Error code should be set */ - mms_trace(MMS_ERR, - "blocking unmount not ready, " - "wait longer and try later"); - return (MM_BE_BLOCKING); - default: - mms_trace(MMS_ERR, - "bad rc mm_unmount_ready"); - mm_system_error(cmd, - "bad rc mm_unmount_ready"); - return (MM_BE_ERROR); - } - } - mms_trace(MMS_DEVP, - "unmounts prepared"); - /* Unmounts prepared/partially ready */ - /* now determine exactly which tapes to unmount */ - mms_list_foreach(&cmd->cmd_beginend_list, cur_cmd) { - if (cur_cmd->cmd_func == mm_mount_cmd_func) { - /* not an unmount */ - continue; - } - mms_trace(MMS_DEVP, "set up a unmount for dispatch"); - rc = tm_be_set_unmount(cur_cmd->wka_ptr, - cur_cmd, cmd); - if (rc == MM_BE_ERROR) { - mms_trace(MMS_ERR, "error setting up unmount"); - /* error set for end command already */ - return (MM_BE_ERROR); - } else if (rc == MM_BE_BLOCKING) { - mms_trace(MMS_ERR, - "blocking mount not ready, " - "wait longer and try later"); - return (MM_BE_BLOCKING); - } - /* remove cmi_cart and cmi_drive from */ - /* above from the remaining */ - /* unmount candidates */ - tm_be_rm_unmount_candidates(cmd, cur_cmd); - MM_SET_FLAG(cur_cmd->cmd_flags, - MM_CMD_DISPATCHABLE); - cur_cmd->cmd_state = 1; - cur_cmd->cmd_mount_info.cui_physical = 1; - } - mms_trace(MMS_DEVP, - "unmounts cart/drive selected and set"); - /* All unmount cmds have been set up */ - /* set up each mount using the candidates in unmounts */ - if (tm_be_init_mount(cmd, db) == MM_BE_ERROR) { - mms_trace(MMS_ERR, "error init mounts for unmounts"); - /* error set for end command already */ - return (MM_BE_ERROR); - } - mms_trace(MMS_DEVP, - "mounts initialized"); - mms_list_foreach(&cmd->cmd_beginend_list, cur_cmd) { - if (cur_cmd->cmd_func == mm_unmount_cmd_func) { - /* not an mount */ - continue; - } - /* tm_be_match_mount will match this */ - /* mount with an unmount */ - MM_UNSET_FLAG(cur_cmd->cmd_flags, - MM_CMD_DISPATCHABLE); - cur_cmd->cmd_state = 1; - rc = tm_be_match_mount(cur_cmd, cmd, db); - if (rc == MM_BE_ERROR) { - mms_trace(MMS_ERR, "error setting up unmount"); - /* error set for end command already */ - return (MM_BE_ERROR); - } - - } - - /* All mounts have been setup, */ - /* create the TASK objects */ - mms_list_foreach(&cmd->cmd_beginend_list, cur_cmd) { - mm_set_mount_objs(cur_cmd, db); - } - /* Put these mounts on the command queue */ - tm_be_add_mounts(cmd); - - /* All mounts are set and ready to go */ - return (MM_BE_DISPATCH); - -} - - -void tm_be_add_mounts(mm_command_t *cmd) { - mm_command_t *next; - mm_command_t *cur; - - for (cur = mms_list_head(&cmd->cmd_beginend_list); - cur != NULL; - cur = next) { - next = mms_list_next(&cmd->cmd_beginend_list, cur); - - mms_list_remove(&cmd->cmd_beginend_list, - cur); - pthread_mutex_lock(&cmd->wka_ptr->mm_data->mm_queue_mutex); - mms_list_insert_tail(&cmd->wka_ptr->mm_data->mm_cmd_queue, cur); - pthread_mutex_unlock(&cmd->wka_ptr->mm_data->mm_queue_mutex); - } -} - -void -mm_be_order_mount_cmds(mm_command_t *cmd) -{ - mm_command_t *be_cmd; - mm_command_t *next_cmd; - - /* Put mount commands with already loaded cartridges on */ - /* front of begin end mount list. */ - - for (be_cmd = mms_list_head(&cmd->cmd_beginend_list); - be_cmd != NULL; - be_cmd = next_cmd) { - next_cmd = mms_list_next(&cmd->cmd_beginend_list, be_cmd); - if (mm_mount_candidate_loaded(be_cmd)) { - mms_list_remove(&cmd->cmd_beginend_list, be_cmd); - mms_list_insert_head(&cmd->cmd_beginend_list, be_cmd); - } - } -} - -int -tm_be_mounts(mm_command_t *cmd, mm_data_t *mm_data) { - mm_db_t *db = &mm_data->mm_db_tm; - mm_wka_t *mm_wka = cmd->wka_ptr; - mm_command_t *cur_cmd; - int rc; - - /* Errors */ - int mount_has_error = 0; - - char *err_text = NULL; - - /* This is the function can return */ - /* MM_BE_ERROR */ - /* MM_BE_BLOCKING */ - /* MM_BE_DISPATCH */ - /* For BLOCKING and MMS_ERROR, end cmd error buf */ - /* Should be set */ - - mms_trace(MMS_DEVP, - "tm_be_mounts"); - - - /* Instead of returning set mount_has_error or mount_would_block */ - /* After calling for ever mount generate the correct error code */ - mms_list_foreach(&cmd->cmd_beginend_list, cur_cmd) { - cur_cmd->cmd_mount_info.cmi_mount_ok = 0; - rc = tm_be_mount_ready(cur_cmd->wka_ptr, cur_cmd, db, cmd); - switch (rc) { - - case MM_MOUNT_ERROR: - /* Error code should be set */ - mms_trace(MMS_ERR, - "tm_be_mounts: " - "internal error, tm_be_mount_ready"); - mount_has_error = 1; - break; - - case MM_MOUNT_READY: - /* The mount is ready, mount_info should be set */ - /* continue to state 1 */ - mms_trace(MMS_DEVP, - "tm_be_mounts: " - "mount is ready to go "); - cur_cmd->cmd_mount_info.cmi_mount_ok = 1; - break; - - case MM_MOUNT_NEED_UNLOAD: - /* this immediate mount needs to */ - /* wait for an unload */ - mms_trace(MMS_DEVP, - "tm_be_mounts: " - "mount needs to wait " - "for unload to complete"); - cur_cmd->cmd_mount_info.cmi_mount_ok = 1; - break; - - case MM_MOUNT_NOT_READY: - mount_has_error = 1; - mms_trace(MMS_ERR, - "tm_be_mounts: " - "mount not ready, " - "wait longer and try later"); - break; - default: - mms_trace(MMS_ERR, - "tm_be_mounts: " - "bad rc mm_mount_ready"); - mm_system_error(cmd, - "bad rc mm_mount_ready"); - return (MM_BE_ERROR); - } - } - - - /* Determine the correct error code to use for the end command */ - /* Each mount in the group with an error will have ecode and eclass */ - if (mount_has_error) { - mms_trace(MMS_ERR, - "at least one mount had " - "an error for this begin-end"); - - /* at least one mount had an error */ - /* for each mount set the least sever errror */ - /* if any mount has a error more severe than retry */ - /* return error for the end command */ - /* since this mount will not work for immediate or blocking */ - mms_list_foreach(&cmd->cmd_beginend_list, cur_cmd) { - if (cur_cmd->cmd_mount_info.cmi_mount_ok) { - mms_trace(MMS_ERR, - "tm_be_mounts: " - "this mount is ok, no errors"); - } else { - mms_trace(MMS_ERR, - "tm_be_mounts: " - "this mount has errors, set least severe"); - - mm_set_least_severe(cur_cmd); - if (strcmp(cur_cmd->cmd_eclass, - ECLASS_RETRY) != 0) { - /* this is not a retry error class */ - /* return error for this end command */ - mms_trace(MMS_ERR, - "at least one mount's " - "least severe error is" - " more severe than retry, " - "this begin-end group " - "will not work"); - /* One or more mount has errors */ - /* that are non retry */ - err_text = - mm_return_err_text(cur_cmd-> - cmd_err_ptr); - mm_response_error(cmd, - ECLASS_EXPLICIT, - "ENOSOLUTIONS", - MM_5110_MSG, - "err_text", err_text, - NULL); - free(err_text); - return (MM_BE_ERROR); - } - } - } - - - - } - - - mm_be_order_mount_cmds(cmd); - - /* All mounts are either ok or retry */ - /* Determine which error to return/block */ - /* for immediate, return retry or nosolutions */ - /* for blocking, block or return nosolutions */ - - - /* Mount candidate lists have been set up, */ - /* divide the resources and set up the exact */ - /* Drive/cartridge combination */ - - mount_has_error = 0; - mms_list_foreach(&cmd->cmd_beginend_list, cur_cmd) { - - mms_trace(MMS_DEVP, "set up a mount for dispatch"); - - /* tm_be_set_mount returns MM_BE_ERROR or MM_BE_DISPATCH */ - - if (cur_cmd->cmd_mount_info.cmi_mount_ok) { - rc = tm_be_set_mount(cur_cmd, - db, cmd); - } else { - rc = MM_BE_ERROR; - } - - if (rc == MM_BE_ERROR) { - mount_has_error = 1; - /* If the cur err ptr is null or */ - /* pointing to a non-retry error class */ - /* This begin-end group cannot succeede */ - if ((cur_cmd->cmd_err_ptr == NULL) || - (strcmp(cur_cmd->cmd_err_ptr->eclass, - ECLASS_RETRY) != 0)) { - mms_trace(MMS_ERR, - "tm_be_mounts: " - "There are no valid " - "solutions to this mount "); - - err_text = - mm_return_err_text(cur_cmd-> - cmd_err_ptr); - mm_response_error(cmd, - ECLASS_EXPLICIT, - "ENOSOLUTIONS", - MM_5110_MSG, - "err_text", err_text, - NULL); - free(err_text); - return (MM_BE_ERROR); - } - tm_be_rm_error_candidates(cmd, cur_cmd); - } else { - tm_be_rm_mount_candidates(cmd, cur_cmd); - } - } - - if (mount_has_error) { - /* If this is immediate, return retry error class for the end */ - /* if this is blocking, then block for the whole group */ - /* Set error for retry */ - mm_response_error(cmd, - ECLASS_RETRY, - "ETMPUNAVAIL", - MM_5104_MSG, - NULL); - return (MM_BE_BLOCKING); - } - mms_list_foreach(&cmd->cmd_beginend_list, cur_cmd) { - if (mm_dispatch_now(mm_wka, cur_cmd, db)) { - /* error should be set */ - mms_trace(MMS_ERR, - "error setting up mount for dispatch"); - } - } - /* All mounts have been setup, */ - /* create the TASK objects */ - mms_list_foreach(&cmd->cmd_beginend_list, cur_cmd) { - mm_set_mount_objs(cur_cmd, db); - } - /* Put these mounts on the command queue */ - tm_be_add_mounts(cmd); - - /* All mounts are set and ready to go */ - return (MM_BE_DISPATCH); -} - -int -tm_be_cmd_has_unmounts(mm_command_t *cmd) { - mm_command_t *cur_cmd; - int unmount_count = 0; - int mount_count = 0; - - int print_message = 1; - /* Returns 1 if this has unmounts */ - /* Also makes sure unmounts are paird with mounts */ - if (print_message) - mms_trace(MMS_DEVP, - "tm_be_cmd_has_unmounts"); - mms_list_foreach(&cmd->cmd_beginend_list, cur_cmd) { - if (cur_cmd->cmd_func == mm_mount_cmd_func) { - if (print_message) - mms_trace(MMS_DEVP, - "saw a mount"); - mount_count ++; - } else if (cur_cmd->cmd_func == mm_unmount_cmd_func) { - if (print_message) - mms_trace(MMS_DEVP, - "saw an unmount"); - unmount_count ++; - } - } - if (unmount_count == 0) - return (0); - if (unmount_count == mount_count) - return (1); - mm_system_error(cmd, - "num mounts does not match num unmounts"); - return (-1); -} - -int -tm_can_dispatch_end(mm_command_t *cmd, mm_data_t *mm_data) -{ - mm_db_t *db = &mm_data->mm_db_tm; - mm_wka_t *mm_wka = cmd->wka_ptr; - - int rc; - int immediate = 0; - int unmount = 0; - - if (mm_wka->wka_begin_end.be_mode == - ACCESS_MODE_IMMEDIATE) - immediate = 1; - - /* Determine the begin-end type */ - /* Currently there are 2 types */ - /* 1. A group of all mounts */ - /* 2. A group of unmounts paired 1to1 w/mounts */ - if ((unmount = tm_be_cmd_has_unmounts(cmd)) == -1) { - /* Error buf is set */ - goto cmd_error; - } - if (unmount == 1) { - rc = tm_be_pairs(cmd, mm_data); - } else { - rc = tm_be_mounts(cmd, mm_data); - } - switch (rc) { - case MM_BE_BLOCKING: - if (immediate) - goto cmd_error; - return (0); - case MM_BE_DISPATCH: - /* Send success for end */ - mm_path_match_report(cmd, db); - (void) mm_del_tm_cmd(db, cmd->cmd_uuid); - mm_send_response(mm_wka->mm_wka_conn, cmd); - return (1); - case MM_BE_ERROR: - /* Error buf is set */ - goto cmd_error; - } - - -cmd_error: - /* Error buf must be set */ - (void) mm_del_tm_cmd(db, cmd->cmd_uuid); - cmd->cmd_remove = 1; - mm_send_text(cmd->wka_ptr->mm_wka_conn, - cmd->cmd_buf); - tm_be_cancel_all(cmd); - return (0); -} - -int -tm_can_dispatch(char *task_id, mm_data_t *mm_data) -{ - - mms_list_t *cmd_queue = &mm_data->mm_cmd_queue; - - mm_command_t *cur_cmd; - - - mms_trace(MMS_DEVP, "tm_can_dispatch"); - - /* Find the command associated with this task */ - pthread_mutex_lock(&mm_data->mm_queue_mutex); - mms_list_foreach(cmd_queue, cur_cmd) { - if ((strcmp(task_id, - cur_cmd->cmd_uuid) == 0)) { - /* task id matches */ - break; - } - - } - pthread_mutex_unlock(&mm_data->mm_queue_mutex); - if (cur_cmd == NULL) { - mms_trace(MMS_INFO, "Could not match task %s with a command", - task_id); - return (0); - } - - mms_trace(MMS_DEVP, "Matched Task with command - cmd is %s", - cur_cmd->cmd_uuid); - if (cur_cmd->cmd_remove) { - /* This command has already been marked for removal */ - /* skip and let main thread clean it up */ - mms_trace(MMS_DEVP, - "skip %s, marked for remove", - cur_cmd->cmd_uuid); - return (0); - } - - if (cur_cmd->cmd_func == mm_mount_cmd_func) { - pthread_mutex_lock(&cur_cmd->wka_ptr-> - wka_local_lock); - /* Set cmd_dispatchable inside this func */ - if (tm_can_dispatch_mount(cur_cmd, mm_data)) { - pthread_mutex_unlock(&cur_cmd->wka_ptr-> - wka_local_lock); - return (1); - } - pthread_mutex_unlock(&cur_cmd->wka_ptr-> - wka_local_lock); - return (0); - } else if (cur_cmd->cmd_func == mm_unmount_cmd_func) { - pthread_mutex_lock(&cur_cmd->wka_ptr-> - wka_local_lock); - if (tm_can_dispatch_unmount(cur_cmd, mm_data)) { - /* set command as dispatchable */ - MM_SET_FLAG(cur_cmd->cmd_flags, MM_CMD_DISPATCHABLE); - pthread_mutex_unlock(&cur_cmd->wka_ptr-> - wka_local_lock); - return (1); - } - pthread_mutex_unlock(&cur_cmd->wka_ptr-> - wka_local_lock); - - return (0); - } else if (cur_cmd->cmd_func == mm_end_cmd_func) { - pthread_mutex_lock(&cur_cmd->wka_ptr-> - wka_local_lock); - if (tm_can_dispatch_end(cur_cmd, mm_data)) { - /* set command as dispatchable */ - MM_SET_FLAG(cur_cmd->cmd_flags, MM_CMD_DISPATCHABLE); - pthread_mutex_unlock(&cur_cmd->wka_ptr-> - wka_local_lock); - return (1); - } - pthread_mutex_unlock(&cur_cmd->wka_ptr-> - wka_local_lock); - } else { - mms_trace(MMS_ERR, - "command is not a mount/unmount or end"); - return (0); - } - return (0); -} - - -int -mm_get_tm_cmd(mm_data_t *mm_data) -{ - mm_db_t *db = &mm_data->mm_db_tm; - PGresult *tasks; - int num_tasks; - int num_dispatched = 0; - int i; - - /* used when a mount needs a drive unloaded 1st */ - - - mms_trace(MMS_DEVP, "mm_get_tm_cmd"); - - mms_trace(MMS_DEVP, "Getting list of tasks..."); - - /* Get ordered list of blocked tasks */ - if (mm_db_exec(HERE, db, - "select * from " - "(select \"TaskID\"," - "\"TaskPriority\" from \"TASK\" " - "where \"TaskState\" = 'blocked' " - "order by \"TaskArrivalTime\") " - "as foo order by \"TaskPriority\" " - "desc;") != MM_DB_DATA) { - mms_trace(MMS_ERR, - "mm_get_tm_cmd: " - "db error getting task info"); - return (1); - } - - tasks = db->mm_db_results; - num_tasks = PQntuples(tasks); - if (num_tasks == 0) { - mms_trace(MMS_DEVP, "%d tasks found", - num_tasks); - mm_clear_db(&tasks); - mms_trace(MMS_DEVP, "TaskManager is Done"); - return (0); - } - mms_trace(MMS_DEVP, "%d tasks found, trying dispatch", - num_tasks); - for (i = 0; i < num_tasks; i++) { - /* Try to dispatch each task */ - mms_trace(MMS_DEVP, " task %s, priority %s", - PQgetvalue(tasks, i, 0), - PQgetvalue(tasks, i, 1)); - - if (tm_can_dispatch(PQgetvalue(tasks, i, 0), - mm_data) == 1) { - /* Task ok for dispatch */ - mms_trace(MMS_INFO, "task %s ready for dispatch", - PQgetvalue(tasks, i, 0)); - num_dispatched ++; - } else { - /* Resources not available */ - mms_trace(MMS_DEVP, "task %s not ready", - PQgetvalue(tasks, i, 0)); - } - } - - mms_trace(MMS_DEVP, "%d tasks dispatched", - num_dispatched); - - if (num_dispatched == 0) { - mms_trace(MMS_DEVP, "TaskManager is Done"); - mm_clear_db(&tasks); - return (0); - } - /* wakeup worker thread to do work */ - - pthread_mutex_lock(&mm_data->mm_worker_mutex); - mm_data->mm_work_todo = 1; - pthread_cond_signal(&mm_data->mm_work_cv); - pthread_mutex_unlock(&mm_data->mm_worker_mutex); - - - mms_trace(MMS_DEVP, "TaskManager is Done"); - mm_clear_db(&tasks); - return (0); - -} - -mm_db_rval_t -mm_set_tm_task(mm_db_t *db, mm_command_t *command) -{ - return (mm_new_tm_task(db, command, "blocked")); -} - -mm_db_rval_t -mm_new_tm_task(mm_db_t *db, mm_command_t *command, char *state) -{ - mm_db_rval_t rc; - char *cmd_text; - - if ((cmd_text = mms_pn_build_cmd_text(command->cmd_root)) == NULL) { - return (MM_DB_ERROR); /* out of memory */ - } - rc = mm_db_exec(HERE, db, "INSERT INTO \"TASK\" " - "(\"TaskID\", \"TaskType\", \"ApplicationName\", " - "\"AIName\", \"TaskStatement\", \"ClientTaskID\", " - "\"TaskState\") VALUES " - "('%s', '%s', '%s', '%s', $$%s$$, '%s', '%s')", - command->cmd_uuid, - command->cmd_root->pn_string, - command->wka_ptr->wka_conn.cci_client, - command->wka_ptr->wka_conn.cci_instance, - cmd_text, command->cmd_task, state); - free(cmd_text); - return (rc); -} - -mm_db_rval_t -mm_set_tm_cartridge(mm_db_t *db, char *taskid, char *cartridge_id) -{ - mm_db_rval_t rc; - PGresult *task_results; - - rc = mm_db_exec(HERE, db, - "select * from \"TASKCARTRIDGE\" where " - "\"TaskID\" = '%s' and \"CartridgeID\" = '%s'", - taskid, cartridge_id); - if (rc != MM_DB_DATA) { - mms_trace(MMS_ERR, - "mm_set_tm_cartridge: " - "db error getting info for" - " TASKCARTRIDGE"); - mm_clear_db(&db->mm_db_results); - return (rc); - } - task_results = db->mm_db_results; - if (PQntuples(task_results) == 0) { - rc = mm_db_exec(HERE, db, "INSERT INTO \"TASKCARTRIDGE\" " - "(\"TaskID\", \"CartridgeID\") VALUES ('%s', '%s')", - taskid, cartridge_id); - if (rc != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_tm_cartridge: " - "db error inserting TASKCARTRIDGE"); - mm_clear_db(&db->mm_db_results); - } - } else { - if (rc == MM_DB_DATA) { - rc = MM_DB_OK; - } - } - mm_clear_db(&task_results); - return (rc); -} - -mm_db_rval_t -mm_set_tm_drive(mm_db_t *db, char *taskid, char *drive) -{ - mm_db_rval_t rc; - PGresult *task_results; - - rc = mm_db_exec(HERE, db, - "select * from \"TASKDRIVE\" where " - "\"TaskID\" = '%s' and \"DriveName\" = '%s'", - taskid, drive); - if (rc != MM_DB_DATA) { - mms_trace(MMS_ERR, - "mm_set_tm_drive: " - "db error getting info for" - " TASKDRIVE"); - mm_clear_db(&db->mm_db_results); - return (rc); - } - task_results = db->mm_db_results; - if (PQntuples(task_results) == 0) { - rc = mm_db_exec(HERE, db, "INSERT INTO \"TASKDRIVE\" " - "(\"TaskID\", \"DriveName\") VALUES ('%s', '%s')", - taskid, drive); - if (rc != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_tm_drive: " - "db error inserting TASKDRIVE"); - mm_clear_db(&db->mm_db_results); - } - } else { - if (rc == MM_DB_DATA) { - rc = MM_DB_OK; - } - } - mm_clear_db(&task_results); - return (rc); -} - -mm_db_rval_t -mm_set_tm_library(mm_db_t *db, char *taskid, char *library) -{ - mm_db_rval_t rc; - PGresult *task_results; - - rc = mm_db_exec(HERE, db, - "select * from \"TASKLIBRARY\" where " - "\"TaskID\" = '%s' and \"LibraryName\" = '%s'", - taskid, library); - if (rc != MM_DB_DATA) { - mms_trace(MMS_ERR, - "mm_set_tm_library: " - "db error getting info for" - " TASKLIBRARY"); - mm_clear_db(&db->mm_db_results); - return (rc); - } - task_results = db->mm_db_results; - if (PQntuples(task_results) == 0) { - rc = mm_db_exec(HERE, db, "INSERT INTO \"TASKLIBRARY\" " - "(\"TaskID\", \"LibraryName\") VALUES ('%s', '%s')", - taskid, library); - if (rc != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_set_tm_library: " - "db error inserting TASKLIBRARY"); - mm_clear_db(&db->mm_db_results); - } - } else { - if (rc == MM_DB_DATA) { - rc = MM_DB_OK; - } - } - mm_clear_db(&task_results); - return (rc); -} - -mm_db_rval_t -mm_set_tm_cmd_dispatched(mm_db_t *db, char *taskid) -{ - mm_db_rval_t rc; - - rc = mm_db_exec(HERE, db, "UPDATE \"TASK\" " - "SET \"TaskState\" = 'dispatched' " - "WHERE \"TaskID\" = '%s'", taskid); - - return (rc); -} - -mm_db_rval_t -mm_del_tm_cmd(mm_db_t *db, char *taskid) -{ - mm_db_rval_t rc; - - rc = mm_db_exec(HERE, db, "DELETE FROM \"TASK\" " - "WHERE \"TaskID\" = '%s'", taskid); - if (rc != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_del_tm_cmd: " - "db error deleteing from TASK"); - } - - rc = mm_db_exec(HERE, db, "delete from \"REQUEST\" where " - "\"RequestingTaskID\" = '%s' and " - "\"RequestState\" != 'responded';", taskid); - - if (rc != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_del_tm_cmd: " - "db error deleteing from REQUEST"); - } - - return (rc); -} - -mm_db_rval_t -mm_chg_tm_cmd_priority(mm_db_t *db, char *taskid, int priority) -{ - mm_db_rval_t rc; - - rc = mm_db_exec(HERE, db, "UPDATE \"TASK\" " - "SET \"TaskPriority\" = '%s' " - "WHERE \"TaskID\" = '%s'", priority, taskid); - - return (rc); -} diff --git a/usr/src/cmd/mms/mm/common/mm_task.h b/usr/src/cmd/mms/mm/common/mm_task.h deleted file mode 100644 index 8b4064653f..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_task.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 _MM_TASK_H -#define _MM_TASK_H - - -#ifdef __cplusplus -extern "C" { -#endif - - -int mm_get_tm_cmd(mm_data_t *mm_data); -mm_db_rval_t mm_set_tm_task(mm_db_t *db, mm_command_t *cmd); -mm_db_rval_t mm_new_tm_task(mm_db_t *db, mm_command_t *command, char *state); -mm_db_rval_t mm_set_tm_cartridge(mm_db_t *db, char *taskid, char *cartridge_id); -mm_db_rval_t mm_set_tm_drive(mm_db_t *db, char *taskid, char *drive); -mm_db_rval_t mm_set_tm_library(mm_db_t *db, char *taskid, char *library); -mm_db_rval_t mm_set_tm_cmd_dispatched(mm_db_t *db, char *taskid); -mm_db_rval_t mm_del_tm_cmd(mm_db_t *db, char *taskid); -mm_db_rval_t mm_chg_tm_cmd_priority(mm_db_t *db, char *taskid, int priority); -void tm_be_add_mounts(mm_command_t *cmd); - -#ifdef __cplusplus -} -#endif - -#endif /* _MM_TASK_H */ diff --git a/usr/src/cmd/mms/mm/common/mm_types.c b/usr/src/cmd/mms/mm/common/mm_types.c deleted file mode 100644 index 9183416fb5..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_types.c +++ /dev/null @@ -1,923 +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 <stdlib.h> -#include <string.h> -#include <errno.h> -#include <pthread.h> -#include <syslog.h> -#include <mms_list.h> -#include <mms_parser.h> -#include <mms_par_impl.h> -#include <libpq-fe.h> -#include <mms_trace.h> -#include <mms_strapp.h> -#include <libxml/parser.h> -#include "mm_db.h" -#include "mm.h" -#include "mm_util.h" -#include "mm_commands.h" -#include "mm_sql.h" -#include "mm_sql_impl.h" -#include "mm_task.h" -#include "mm_path.h" - -static char *_SrcFile = __FILE__; - -typedef struct mm_type_library mm_type_library_t; -struct mm_type_library { - mms_list_node_t mm_library_list_next; - mms_list_t mm_library_name_list; - mms_list_t mm_shape_name_list; -}; - -typedef struct mm_type_data mm_type_data_t; -struct mm_type_data { - int mm_error; - int mm_level; - int mm_once; - mms_list_t mm_drive_name_list; - mms_list_t mm_cart_name_list; - mms_list_t mm_library_list; - - mm_type_library_t *cur_lib; -}; -static void mm_check_drive_string(char *drive_name); -static void mm_check_cartridge_string(char *cartridge_name); -static void mm_check_cartridgetype_string(char *cartridge_name); -static void mm_check_library_string(char *library_name); -static void mm_check_slottype_string(char *cartridgeshape_name, - char *cur_library_name); -static int mm_verify_types(mm_type_data_t *type_data); -static int mm_parse_types(mm_type_data_t *type_data, char *fn); -static void mm_parse_type_start_elements(void *xml_type_data, - const xmlChar *xml_name, const xmlChar **xml_atts); -static void mm_parse_type_end_elements(void *xml_type_data, - const xmlChar *xml_name); - -static mm_db_t *db; - - -static PGresult *drive_results; -static int num_drive; -static PGresult *cartridge_results; -static int num_cartridge; -static PGresult *library_results; -static int num_library; -static PGresult *slottype_results; -static int num_slottype; -static PGresult *carttype_results; -static int num_carttype; - -static void -mm_library_list_destroy(mms_list_t *list) { - mm_type_library_t *lib_list; - mm_type_library_t *next_lib_list; - - for (lib_list = mms_list_head(list); - lib_list != NULL; - lib_list = next_lib_list) { - - mm_char_list_destroy(&lib_list->mm_library_name_list); - mm_char_list_destroy(&lib_list->mm_shape_name_list); - - next_lib_list = - mms_list_next(list, - lib_list); - mms_list_remove(list, - lib_list); - free(lib_list); - } - -} - -static -mm_type_library_t * -mm_alloc_lib_struct() { - mm_type_library_t *lib; - lib = (mm_type_library_t *)calloc(1, sizeof (mm_type_library_t)); - - if (lib == NULL) { - printf("could not allocate mem for lib struct"); - exit(1); - } - - mms_list_create(&lib->mm_library_name_list, sizeof (mm_char_list_t), - offsetof(mm_char_list_t, mm_char_list_next)); - mms_list_create(&lib->mm_shape_name_list, sizeof (mm_char_list_t), - offsetof(mm_char_list_t, mm_char_list_next)); - - return (lib); -} - - -int -mm_init_types(mm_data_t *mm_data, char *fn) -{ - mm_type_data_t type_data; - - mms_trace(MMS_DEVP, "types init %s", fn); - - db = &mm_data->mm_db; - - - - - /* Get existing drives/carts/library/slottypes */ - if (mm_db_exec(HERE, db, - "select \"DriveString\" " - "from \"DRIVELIST\";") != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error getting drive strings"); - mm_clear_db(&db->mm_db_results); - return (1); - } else { - drive_results = db->mm_db_results; - num_drive = PQntuples(drive_results); - } - if (mm_db_exec(HERE, db, - "select \"CartridgeString\" " - "from \"CARTRIDGELIST\";") != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error getting cartridge strings"); - mm_clear_db(&drive_results); - mm_clear_db(&db->mm_db_results); - return (1); - } else { - cartridge_results = db->mm_db_results; - num_cartridge = PQntuples(cartridge_results); - } - if (mm_db_exec(HERE, db, - "select \"LibraryString\" " - "from \"LIBRARYLIST\";") != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error getting library strings"); - mm_clear_db(&drive_results); - mm_clear_db(&cartridge_results); - mm_clear_db(&db->mm_db_results); - return (1); - } else { - library_results = db->mm_db_results; - num_library = PQntuples(library_results); - } - if (mm_db_exec(HERE, db, - "select \"SlotTypeName\", \"CartridgeShapeName\" " - "from \"SLOTTYPE\";") != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error getting slottype strings"); - mm_clear_db(&drive_results); - mm_clear_db(&cartridge_results); - mm_clear_db(&library_results); - mm_clear_db(&db->mm_db_results); - return (1); - } else { - slottype_results = db->mm_db_results; - num_slottype = PQntuples(slottype_results); - } - - if (mm_db_exec(HERE, db, - "select \"CartridgeTypeName\", \"CartridgeShapeName\" " - "from \"CARTRIDGETYPE\";") != MM_DB_DATA) { - mms_trace(MMS_ERR, - "db error getting CARTRIDGETYPE strings"); - mm_clear_db(&drive_results); - mm_clear_db(&cartridge_results); - mm_clear_db(&library_results); - mm_clear_db(&slottype_results); - mm_clear_db(&db->mm_db_results); - return (1); - } else { - carttype_results = db->mm_db_results; - num_carttype = PQntuples(carttype_results); - } - - - memset(&type_data, 0, sizeof (mm_type_data_t)); - - /* Create drive cart and library lists */ - mms_list_create(&type_data.mm_drive_name_list, sizeof (mm_char_list_t), - offsetof(mm_char_list_t, mm_char_list_next)); - mms_list_create(&type_data.mm_cart_name_list, sizeof (mm_char_list_t), - offsetof(mm_char_list_t, mm_char_list_next)); - mms_list_create(&type_data.mm_library_list, sizeof (mm_type_library_t), - offsetof(mm_type_library_t, mm_library_list_next)); - - - type_data.mm_error = 0; - - if (mm_parse_types(&type_data, fn)) { - mm_clear_db(&drive_results); - mm_clear_db(&cartridge_results); - mm_clear_db(&library_results); - mm_clear_db(&slottype_results); - mm_clear_db(&carttype_results); - mm_char_list_destroy(&type_data.mm_drive_name_list); - mm_char_list_destroy(&type_data.mm_cart_name_list); - mm_library_list_destroy(&type_data.mm_library_list); - - return (1); - } - - - mms_trace(MMS_DEVP, - "parsing types done, verify now"); - - if (mm_verify_types(&type_data)) { - mms_trace(MMS_ERR, - "error verifying types"); - mm_clear_db(&drive_results); - mm_clear_db(&cartridge_results); - mm_clear_db(&library_results); - mm_clear_db(&slottype_results); - mm_clear_db(&carttype_results); - - mm_char_list_destroy(&type_data.mm_drive_name_list); - mm_char_list_destroy(&type_data.mm_cart_name_list); - mm_library_list_destroy(&type_data.mm_library_list); - return (1); - } - - mms_trace(MMS_DEVP, - "types verified successfully, " - "type init done"); - - mm_clear_db(&drive_results); - mm_clear_db(&cartridge_results); - mm_clear_db(&library_results); - mm_clear_db(&slottype_results); - mm_clear_db(&carttype_results); - - mm_char_list_destroy(&type_data.mm_drive_name_list); - mm_char_list_destroy(&type_data.mm_cart_name_list); - mm_library_list_destroy(&type_data.mm_library_list); - - return (0); -} - -static void -mm_types_delete_drive(mm_type_data_t *type_data) { - mm_char_list_t *node; - mm_char_list_t *next; - - char *buf = NULL; - - int found_one = 0; - - buf = mms_strapp(buf, - "delete from \"DRIVELIST\" where "); - - for (node = mms_list_head(&type_data->mm_drive_name_list); - node != NULL; - node = next) { - next = mms_list_next(&type_data->mm_drive_name_list, node); - if (found_one != 0) { - buf = mms_strapp(buf, " and "); - } - found_one = 1; - buf = mms_strapp(buf, "(\"DriveString\" != '%s') ", - node->text); - } - - if (found_one) { - buf = mms_strapp(buf, ";"); - if (mm_db_exec(HERE, db, buf) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_types_delete_drive: " - "db error deleting from drivelist"); - } - } - free(buf); - -} - -static void -mm_types_delete_cart(mm_type_data_t *type_data) { - mm_char_list_t *node; - mm_char_list_t *next; - - char *buf = NULL; - - int found_one = 0; - - buf = mms_strapp(buf, - "delete from \"CARTRIDGELIST\" where "); - - for (node = mms_list_head(&type_data->mm_cart_name_list); - node != NULL; - node = next) { - next = mms_list_next(&type_data->mm_cart_name_list, node); - if (found_one != 0) { - buf = mms_strapp(buf, " and "); - } - found_one = 1; - buf = mms_strapp(buf, "(\"CartridgeString\" != '%s') ", - node->text); - } - - if (found_one) { - buf = mms_strapp(buf, ";"); - if (mm_db_exec(HERE, db, buf) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_types_delete_cart: " - "db error deleting from cartlist"); - } - - } - free(buf); - -} - -static void -mm_types_delete_library(mm_type_data_t *type_data) { - - mm_type_library_t *lib_list; - mm_type_library_t *next_lib_list; - - mm_char_list_t *node; - mm_char_list_t *next; - - mm_char_list_t *node2; - mm_char_list_t *next2; - - char *lib_buf = NULL; - char *slottype_buf = NULL; - - int found_one_lib = 0; - int found_one_slottype = 0; - - lib_buf = mms_strapp(lib_buf, - "delete from \"LIBRARYLIST\" where "); - - slottype_buf = mms_strapp(slottype_buf, - "delete from \"SLOTTYPE\" where "); - - for (lib_list = mms_list_head(&type_data->mm_library_list); - lib_list != NULL; - lib_list = next_lib_list) { - next_lib_list = - mms_list_next(&type_data->mm_library_list, - lib_list); - - - for (node = mms_list_head(&lib_list->mm_library_name_list); - node != NULL; - node = next) { - next = mms_list_next(&lib_list-> - mm_library_name_list, - node); - - if (found_one_lib != 0) { - lib_buf = mms_strapp(lib_buf, " and "); - } - found_one_lib = 1; - lib_buf = mms_strapp(lib_buf, - "(\"LibraryString\" != '%s') ", - node->text); - - - - for (node2 = mms_list_head(&lib_list-> - mm_shape_name_list); - node2 != NULL; - node2 = next2) { - next2 = mms_list_next(&lib_list-> - mm_shape_name_list, node2); - - if (found_one_slottype != 0) { - slottype_buf = - mms_strapp(slottype_buf, " and "); - } - found_one_slottype = 1; - slottype_buf = mms_strapp(slottype_buf, - "((\"SlotTypeName\" != '%s') and " - "(\"CartridgeShapeName\" != '%s')) ", - node->text, - node2->text); - } - } - } - - if (found_one_lib) { - lib_buf = mms_strapp(lib_buf, ";"); - if (mm_db_exec(HERE, db, lib_buf) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_types_delete_library: " - "db error deleting from librarylist"); - } - - - } - if (found_one_slottype) { - slottype_buf = mms_strapp(slottype_buf, ";"); - if (mm_db_exec(HERE, db, slottype_buf) != MM_DB_OK) { - mms_trace(MMS_ERR, - "mm_types_delete_library: " - "db error deleting from slottype"); - } - } - free(lib_buf); - free(slottype_buf); - -} - - - -static int -mm_verify_types(mm_type_data_t *type_data) -{ - mm_type_library_t *lib_list; - mm_type_library_t *next_lib_list; - - mm_char_list_t *node; - mm_char_list_t *next; - - mm_char_list_t *node2; - mm_char_list_t *next2; - - - int print = 0; - /* Print out what we have in the lists */ - if (print) { - mms_trace(MMS_DEVP, - "Drive Strings:"); - mm_print_char_list(&type_data-> - mm_drive_name_list); - } - for (node = mms_list_head(&type_data->mm_drive_name_list); - node != NULL; - node = next) { - next = mms_list_next(&type_data->mm_drive_name_list, node); - mm_check_drive_string(node->text); - } - - - if (print) { - mms_trace(MMS_DEVP, - "Cartridge Strings:"); - mm_print_char_list(&type_data-> - mm_cart_name_list); - } - for (node = mms_list_head(&type_data->mm_cart_name_list); - node != NULL; - node = next) { - next = mms_list_next(&type_data->mm_cart_name_list, node); - mm_check_cartridge_string(node->text); - } - - - for (lib_list = mms_list_head(&type_data->mm_library_list); - lib_list != NULL; - lib_list = next_lib_list) { - next_lib_list = - mms_list_next(&type_data->mm_library_list, - lib_list); - if (print) { - mms_trace(MMS_DEVP, - "Library Strings:"); - mm_print_char_list(&lib_list-> - mm_library_name_list); - mms_trace(MMS_DEVP, - "Slottype Strings:"); - mm_print_char_list(&lib_list-> - mm_shape_name_list); - } - - for (node = mms_list_head(&lib_list->mm_library_name_list); - node != NULL; - node = next) { - next = mms_list_next(&lib_list-> - mm_library_name_list, - node); - mm_check_library_string(node->text); - - for (node2 = mms_list_head(&lib_list-> - mm_shape_name_list); - node2 != NULL; - node2 = next2) { - next2 = mms_list_next(&lib_list-> - mm_shape_name_list, node2); - mm_check_slottype_string(node2->text, - node->text); - - } - } - - } - - /* Create the Side1Name column for default types */ - if (mm_db_exec(HERE, db, - "ALTER TABLE \"CARTRIDGETYPE\" " - "ADD \"Side1Name\" text;") != MM_DB_OK) { - /* If there is an error ignore it */ - mm_clear_db(&db->mm_db_results); - } - - for (node = mms_list_head(&type_data->mm_cart_name_list); - node != NULL; - node = next) { - next = mms_list_next(&type_data->mm_cart_name_list, node); - mm_check_cartridgetype_string(node->text); - } - - /* All strings in xml are now in db */ - /* now delete any strings that are not in the xml */ - mm_types_delete_drive(type_data); - mm_types_delete_cart(type_data); - mm_types_delete_library(type_data); - - - return (0); -} - -static int -mm_parse_types(mm_type_data_t *type_data, char *fn) -{ - xmlSAXHandler handler; - memset(&handler, 0, sizeof (xmlSAXHandler)); - handler.startElement = mm_parse_type_start_elements; - handler.endElement = mm_parse_type_end_elements; - xmlDefaultSAXHandlerInit(); - xmlSAXUserParseFile(&handler, type_data, fn); - if (type_data->mm_once == 0) { - type_data->mm_error = __LINE__; - } - if (type_data->mm_error) { - mms_trace(MMS_ERR, "%s parse - error %d level %d", - fn, - type_data->mm_error, - type_data->mm_level); - } - return (type_data->mm_error); - - -} - - -static void -mm_check_drive_string(char *drive_name) { - int i; - char *cur_drive; - int matched_drive = 0; - - for (i = 0; i < num_drive; i++) { - cur_drive = PQgetvalue(drive_results, - i, 0); - if (strcmp(drive_name, cur_drive) == 0) { - /* already have this drive name */ - matched_drive = 1; - } - } - - if (matched_drive == 0) { - /* Need to add this drive to drive list */ - if (mm_db_exec(HERE, db, - "insert into \"DRIVELIST\" " - "(\"DriveString\") values('%s');", - drive_name) != MM_DB_OK) { - mms_trace(MMS_ERR, - "error inserting %s " - "into DRIVELIST", - drive_name); - mm_clear_db(&db->mm_db_results); - } - } -} -static void -mm_check_cartridge_string(char *cartridge_name) { - int i; - char *cur_cartridge; - int matched_cartridge = 0; - - for (i = 0; i < num_cartridge; i++) { - cur_cartridge = PQgetvalue(cartridge_results, - i, 0); - if (strcmp(cartridge_name, cur_cartridge) == 0) { - /* already have this cartridge name */ - matched_cartridge = 1; - } - } - - if (matched_cartridge == 0) { - /* Need to add this cartridge to cartridge list */ - if (mm_db_exec(HERE, db, - "insert into \"CARTRIDGELIST\" " - "(\"CartridgeString\") values('%s');", - cartridge_name) != MM_DB_OK) { - mms_trace(MMS_ERR, - "error inserting %s " - "into CARTRIDGELIST", - cartridge_name); - mm_clear_db(&db->mm_db_results); - } - } -} - -static void -mm_check_cartridgetype_string(char *cartridgeshape_name) { - int i; - char *cur_carttype; - char *cur_cartshape; - int matched_cartridge = 0; - - for (i = 0; i < num_carttype; i++) { - cur_carttype = PQgetvalue(carttype_results, - i, 0); - cur_cartshape = PQgetvalue(carttype_results, - i, 1); - if ((strcmp(cartridgeshape_name, cur_carttype) == 0) && - (strcmp(cartridgeshape_name, cur_cartshape) == 0)) { - /* already have this cartridge name */ - matched_cartridge = 1; - } - } - - if (matched_cartridge == 0) { - /* Need to add this cartridge to cartridge list */ - if (mm_db_exec(HERE, db, - "insert into \"CARTRIDGETYPE\" " - "(\"CartridgeTypeName\", " - "\"CartridgeShapeName\", " - "\"Side1Name\", " - "\"CartridgeTypeMediaType\") values('%s'," - "'%s', 'side 1', 'data');", - cartridgeshape_name, - cartridgeshape_name) != MM_DB_OK) { - mms_trace(MMS_ERR, - "error inserting %s " - "into CARTRIDGETYPE", - cartridgeshape_name); - mm_clear_db(&db->mm_db_results); - } - } -} - -static void -mm_check_library_string(char *library_name) { - int i; - char *cur_library; - int matched_library = 0; - - for (i = 0; i < num_library; i++) { - cur_library = PQgetvalue(library_results, - i, 0); - if (strcmp(library_name, cur_library) == 0) { - /* already have this library name */ - matched_library = 1; - } - } - - if (matched_library == 0) { - /* Need to add this library to library list */ - if (mm_db_exec(HERE, db, - "insert into \"LIBRARYLIST\" " - "(\"LibraryString\") values('%s');", - library_name) != MM_DB_OK) { - mms_trace(MMS_ERR, - "error inserting %s " - "into LIBRARYLIST", - library_name); - mm_clear_db(&db->mm_db_results); - } - } - -} - -static void -mm_check_slottype_string(char *cartridgeshape_name, - char *cur_library_name) { - int i; - char *cur_slottype; - char *cur_cartridgeshape; - int matched_slottype = 0; - - for (i = 0; i < num_slottype; i++) { - cur_slottype = PQgetvalue(slottype_results, - i, 0); - cur_cartridgeshape = PQgetvalue(slottype_results, - i, 1); - if ((strcmp(cur_library_name, cur_slottype) == 0) && - (strcmp(cartridgeshape_name, cur_cartridgeshape) == 0)) { - /* already have this slottype name */ - matched_slottype = 1; - } - } - - if (matched_slottype == 0) { - /* Need to add this slottype to slottype list */ - if (mm_db_exec(HERE, db, - "insert into \"SLOTTYPE\" " - "(\"SlotTypeName\", \"CartridgeShapeName\") " - "values('%s', '%s');", - cur_library_name, - cartridgeshape_name) != MM_DB_OK) { - mms_trace(MMS_ERR, - "error inserting %s, %s " - "into SLOTTYPE", - cur_library_name, - cartridgeshape_name); - } - } -} - - - -static void -mm_parse_type_start_elements(void *xml_type_data, const xmlChar *xml_name, - const xmlChar **xml_atts) -{ - mm_type_data_t *type_data = (mm_type_data_t *)xml_type_data; - char *name = (char *)xml_name; - char **atts = (char **)xml_atts; - - mm_type_library_t *new_lib; - - if (type_data->mm_error) { - return; - } - - if (type_data->mm_once == 0) { - type_data->mm_once = 1; - } - - if (type_data->mm_level == 0 && - strcmp(name, "mm_types") == 0) { - type_data->mm_level = 1; - return; - } - - if (type_data->mm_level == 1 && - strcmp(name, "mm_drive_list") == 0) { - type_data->mm_level = 2; - return; - } - if (type_data->mm_level == 1 && - strcmp(name, "mm_cartridge_list") == 0) { - type_data->mm_level = 2; - return; - } - if (type_data->mm_level == 1 && - strcmp(name, "mm_library_list") == 0) { - type_data->mm_level = 2; - return; - } - if (type_data->mm_level == 2 && - strcmp(name, "mm_library") == 0) { - type_data->mm_level = 3; - new_lib = mm_alloc_lib_struct(); - mms_list_insert_tail(&type_data->mm_library_list, - new_lib); - type_data->cur_lib = new_lib; - return; - } - if (type_data->mm_level == 3 && - strcmp(name, "mm_slottype_list") == 0) { - type_data->mm_level = 4; - return; - } - if (type_data->mm_level == 3 && - strcmp(name, "mm_cartridgeshape_list") == 0) { - type_data->mm_level = 4; - return; - } - - - if (type_data->mm_level == 2 && - strcmp(name, "mm_drive_string") == 0) { - if (atts[0] == NULL || strcmp(atts[0], "value") != 0) { - type_data->mm_error = __LINE__; - } else if (atts[1] != NULL) { - mms_trace(MMS_DEVP, - " mm_drive_string=%s", - atts[1]); - if (mm_add_char(atts[1], - &type_data->mm_drive_name_list)) { - mms_trace(MMS_ERR, - "mm_parse_type_start_elements: " - "out of mem adding to drive list"); - } - - } - return; - } - if (type_data->mm_level == 2 && - strcmp(name, "mm_cartridge_string") == 0) { - if (atts[0] == NULL || strcmp(atts[0], "value") != 0) { - type_data->mm_error = __LINE__; - } else if (atts[1] != NULL) { - mms_trace(MMS_DEVP, - " mm_cartridge_string=%s", - atts[1]); - if (mm_add_char(atts[1], - &type_data->mm_cart_name_list)) { - mms_trace(MMS_ERR, - "mm_parse_type_start_elements: " - "out of mem adding to cart list"); - } - - } - return; - } - - if (type_data->mm_level == 4 && - strcmp(name, "mm_slottype") == 0) { - if (atts[0] == NULL || strcmp(atts[0], "name") != 0) { - type_data->mm_error = __LINE__; - } else if (atts[1] != NULL) { - mms_trace(MMS_DEVP, - " mm_slottype name=%s", - atts[1]); - if (mm_add_char(atts[1], - &type_data->cur_lib->mm_library_name_list)) { - mms_trace(MMS_ERR, - "mm_parse_type_start_elements: " - "out of mem adding to library list"); - } - - } - return; - } - if (type_data->mm_level == 4 && - strcmp(name, "mm_cartridgeshape") == 0) { - if (atts[0] == NULL || strcmp(atts[0], "name") != 0) { - type_data->mm_error = __LINE__; - } else if (atts[1] != NULL) { - mms_trace(MMS_DEVP, - " mm_cartridgeshape name=%s", - atts[1]); - if (mm_add_char(atts[1], - &type_data->cur_lib->mm_shape_name_list)) { - mms_trace(MMS_ERR, - "mm_parse_type_start_elements: " - "out of mem adding to shape list"); - } - } - return; - } - - type_data->mm_error = __LINE__; -} - -static void -mm_parse_type_end_elements(void *xml_type_data, const xmlChar *xml_name) -{ - mm_type_data_t *type_data = (mm_type_data_t *)xml_type_data; - char *name = (char *)xml_name; - - - - if (type_data->mm_level == 2 && - strcmp(name, "mm_drive_list") == 0) { - type_data->mm_level = 1; - return; - } - if (type_data->mm_level == 2 && - strcmp(name, "mm_cartridge_list") == 0) { - type_data->mm_level = 1; - return; - } - if (type_data->mm_level == 2 && - strcmp(name, "mm_library_list") == 0) { - type_data->mm_level = 1; - return; - } - if (type_data->mm_level == 3 && - strcmp(name, "mm_library") == 0) { - type_data->mm_level = 2; - type_data->cur_lib = NULL; - return; - } - if (type_data->mm_level == 4 && - strcmp(name, "mm_slottype_list") == 0) { - type_data->mm_level = 3; - return; - } - if (type_data->mm_level == 4 && - strcmp(name, "mm_cartridgeshape_list") == 0) { - type_data->mm_level = 3; - return; - } - -} diff --git a/usr/src/cmd/mms/mm/common/mm_types.xml b/usr/src/cmd/mms/mm/common/mm_types.xml deleted file mode 100644 index d20444e1f4..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_types.xml +++ /dev/null @@ -1,83 +0,0 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE mm_paths SYSTEM "/etc/mms/types/mm_types.dtd"> -<!-- - 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. - ---> - - <mm_types> - <mm_drive_list> - <mm_drive_string value="DISK"/> - <mm_drive_string value="9840"/> - <mm_drive_string value="T9840B"/> - <mm_drive_string value="T9840C"/> - <mm_drive_string value="T9940A"/> - <mm_drive_string value="T9940B"/> - <mm_drive_string value="LTO1"/> - <mm_drive_string value="LTO2"/> - <mm_drive_string value="LTO3"/> - <mm_drive_string value="LTO4"/> - <mm_drive_string value="SDLT600"/> - </mm_drive_list> - <mm_cartridge_list> - <mm_cartridge_string value="DISK"/> - <mm_cartridge_string value="9840"/> - <mm_cartridge_string value="9940"/> - <mm_cartridge_string value="LTO1"/> - <mm_cartridge_string value="LTO2"/> - <mm_cartridge_string value="LTO3"/> - <mm_cartridge_string value="LTO4"/> - <mm_cartridge_string value="SDLT2"/> - </mm_cartridge_list> - <mm_library_list> - <mm_library> - <mm_slottype_list> - <mm_slottype name="DISK"/> - </mm_slottype_list> - <mm_cartridgeshape_list> - <mm_cartridgeshape name="DISK"/> - </mm_cartridgeshape_list> - </mm_library> - <mm_library> - <mm_slottype_list> - <mm_slottype name="L180"/> - <mm_slottype name="L500"/> - <mm_slottype name="L700"/> - <mm_slottype name="SL500"/> - <mm_slottype name="SL3000"/> - <mm_slottype name="SL8500"/> - </mm_slottype_list> - <mm_cartridgeshape_list> - <mm_cartridgeshape name="9840"/> - <mm_cartridgeshape name="9940"/> - <mm_cartridgeshape name="LTO1"/> - <mm_cartridgeshape name="LTO2"/> - <mm_cartridgeshape name="LTO3"/> - <mm_cartridgeshape name="LTO4"/> - <mm_cartridgeshape name="SDLT2"/> - </mm_cartridgeshape_list> - </mm_library> - </mm_library_list> -</mm_types> - - - diff --git a/usr/src/cmd/mms/mm/common/mm_util.c b/usr/src/cmd/mms/mm/common/mm_util.c deleted file mode 100644 index 0c151dd0f1..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_util.c +++ /dev/null @@ -1,1568 +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/stat.h> -#include <fcntl.h> -#include <mms_list.h> -#include <mms_parser.h> -#include <mms_par_impl.h> -#include <libpq-fe.h> -#include <string.h> -#include <stdlib.h> -#include <sys/time.h> -#include <pthread.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/uuid.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <errno.h> -#include <unistd.h> -#include <signal.h> -#include <stdio.h> -#include <string.h> -#include <fcntl.h> -#include <dirent.h> -#include <procfs.h> -#include <mms_trace.h> -#include <mms_strapp.h> -#include <netdb.h> -#include <sys/utsname.h> -#include <strings.h> -#include <ctype.h> -#include <sys/resource.h> -#include <syslog.h> -#include <msg_sub.h> -#include <host_ident.h> -#include <mms_cfg.h> -#include "mm_db.h" -#include "mm.h" -#include "mm_sql.h" -#include "mm_commands.h" -#include "mm_util.h" - -static char *_SrcFile = __FILE__; - -extern void uuid_clear(uuid_t uu); -extern void uuid_generate_random(uuid_t uu); -extern void uuid_generate(uuid_t uu); /* hits bug id 6397009 */ -extern void uuid_unparse(uuid_t uu, char *out); - -/* - * mm_err_eclass_rank - * return int of the rank of this eclass - * higher numbers mean more severe - */ -int -mm_err_eclass_rank(char *eclass) -{ - /* 13 total error classes */ - - if (strcmp(eclass, ECLASS_LANGUAGE) == 0) - return (13); - if (strcmp(eclass, ECLASS_EXPLICIT) == 0) - return (12); - if (strcmp(eclass, ECLASS_INTERNAL) == 0) - return (11); - if (strcmp(eclass, ECLASS_INVALID) == 0) - return (10); - if (strcmp(eclass, ECLASS_DM_INVALID) == 0) - return (9); - if (strcmp(eclass, ECLASS_DM_CONFIG) == 0) - return (8); - if (strcmp(eclass, ECLASS_EXIST) == 0) - return (7); - if (strcmp(eclass, ECLASS_SUBOP) == 0) - return (6); - if (strcmp(eclass, ECLASS_CONFIG) == 0) - return (5); - if (strcmp(eclass, ECLASS_STATE) == 0) - return (4); - if (strcmp(eclass, ECLASS_PERMPRIV) == 0) - return (3); - if (strcmp(eclass, ECLASS_COMPAT) == 0) - return (2); - if (strcmp(eclass, ECLASS_RETRY) == 0) - return (1); - return (0); -} - -char * -mm_return_err_text(mm_cmd_err_t *err) { - /* Generate a quick text for this error */ - /* to be used as error text for an end command */ - char *buf = NULL; - - mms_trace(MMS_DEVP, - "mm_return_err_text: "); - - if (err == NULL) { - mms_trace(MMS_DEVP, - "err ptr is NULL"); - buf = mms_strapp(buf, - "none"); - return (buf); - } - - if (err->eclass != NULL) { - buf = mms_strapp(buf, - "%s ", err->eclass); - mms_trace(MMS_DEVP, - " %s", err->eclass); - - } - if (err->ecode != NULL) { - buf = mms_strapp(buf, - "%s ", err->ecode); - mms_trace(MMS_DEVP, - " %s", err->ecode); - } - if (err->retry_cart != NULL) { - buf = mms_strapp(buf, - "%s ", err->retry_cart); - mms_trace(MMS_DEVP, - " %s", err->retry_cart); - } - if (err->retry_drive != NULL) { - buf = mms_strapp(buf, - "%s ", err->retry_drive); - mms_trace(MMS_DEVP, - " %s", err->retry_drive); - } - if (err->retry_lib != NULL) { - buf = mms_strapp(buf, - "%s ", err->retry_lib); - mms_trace(MMS_DEVP, - " %s", err->retry_lib); - } - if (buf == NULL) { - buf = mms_strapp(buf, - "none"); - mms_trace(MMS_DEVP, - "err ptr not NULL, but empty"); - } - return (buf); -} - - - -int -mm_same_err_helper(char *str1, char *str2) { - if (str1 == NULL) { - if (str2 == NULL) { - /* both ptrs are NULL, return 0 */ - return (0); - } else { - /* str1 is NULL, str2 is not */ - return (1); - } - } else { - /* str1 is not NULL */ - if (str2 == NULL) { - /* str1 is not, str2 is NULL */ - return (1); - } - } - - /* both str's are not NULL */ - return (strcmp(str1, str2)); -} - - -int -mm_same_err(mm_cmd_err_t *err1, mm_cmd_err_t *err2) { - - if ((err1 == NULL) || - (err2 == NULL)) { - mms_trace(MMS_DEVP, - "mm_same_err: " - "err1 or err2 is NULL"); - return (0); - } - if ((err1->eclass == NULL) || - (err2->eclass == NULL)) { - mms_trace(MMS_DEVP, - "mm_same_err: " - "one or both err class was NULL"); - return (0); - } - if (strcmp(err1->eclass, err2->eclass) != 0) { - mms_trace(MMS_DEVP, - "mm_same_err: " - "eclasses are different"); - return (0); - } - - if (mm_same_err_helper(err1->retry_cart, - err2->retry_cart) != 0) { - mms_trace(MMS_DEVP, - "mm_same_err: " - "retry cart is different"); - return (0); - } - if (mm_same_err_helper(err1->retry_drive, - err2->retry_drive) != 0) { - mms_trace(MMS_DEVP, - "mm_same_err: " - "retry drive is different"); - return (0); - } - if (mm_same_err_helper(err1->retry_lib, - err2->retry_lib) != 0) { - mms_trace(MMS_DEVP, - "mm_same_err: " - "retry lib is different"); - return (0); - } - mms_trace(MMS_DEVP, - "mm_same_err: " - "errors are the same"); - return (1); -} - -void -mm_set_buf_to_err(mm_command_t *cmd, mm_cmd_err_t *err) -{ - - /* set current cmd_buf to least_err */ - if (cmd->cmd_buf != NULL) { - free(cmd->cmd_buf); - cmd->cmd_buf = NULL; - } - cmd->cmd_buf = strdup(err->err_buf); - cmd->cmd_bufsize = err->err_bufsize; - if (cmd->cmd_ecode != NULL) { - free(cmd->cmd_ecode); - cmd->cmd_ecode = NULL; - } - if (cmd->cmd_eclass != NULL) { - free(cmd->cmd_eclass); - cmd->cmd_eclass = NULL; - } - cmd->cmd_ecode = strdup(err->ecode); - cmd->cmd_eclass = strdup(err->eclass); -} - -void -mm_clear_cur_err(mm_command_t *cmd) -{ - if (cmd->cmd_ecode != NULL) { - free(cmd->cmd_ecode); - cmd->cmd_ecode = NULL; - } - if (cmd->cmd_eclass != NULL) { - free(cmd->cmd_eclass); - cmd->cmd_eclass = NULL; - } - if (cmd->cmd_buf != NULL) { - free(cmd->cmd_buf); - cmd->cmd_buf = NULL; - } - cmd->cmd_bufsize = 0; - -} - - -void -mm_set_least_severe(mm_command_t *cmd) -{ - - mm_cmd_err_t *err = NULL; - mm_cmd_err_t *least_err = NULL; - int cur_rank = 0; - int least_rank = 0; - int first = 1; - - - mms_list_foreach(&cmd->cmd_err_list, err) { - if (err->err_already_used) { - continue; - } - if (err->eclass == NULL) - continue; - if (first) { - least_err = err; - least_rank = - mm_err_eclass_rank(least_err->eclass); - first = 0; - continue; - } - cur_rank = mm_err_eclass_rank(err->eclass); - if (cur_rank < least_rank) { - least_rank = cur_rank; - least_err = err; - } - - } - if (first) { - mms_trace(MMS_ERR, - "mm_set_least_severe: " - "there are no unused " - "errors in the list"); - cmd->cmd_err_ptr = NULL; - return; - } - mms_trace(MMS_ERR, - "mm_set_least_severe: " - "setting error %s %s", - least_err->eclass, - least_err->ecode); - mm_set_buf_to_err(cmd, least_err); - cmd->cmd_err_ptr = least_err; -} - -void -mm_set_retry_drive(mm_command_t *cmd, char *drive) -{ - mm_cmd_err_t *err = NULL; - if ((err = mms_list_tail(&cmd->cmd_err_list)) == NULL) { - return; - } - if (err->retry_drive != NULL) { - free(err->retry_drive); - err->retry_drive = NULL; - } - if (drive == NULL) { - return; - } - err->retry_drive = - mms_strapp(err->retry_drive, - drive); -} - -void -mm_set_retry_lib(mm_command_t *cmd, char *lib) -{ - mm_cmd_err_t *err = NULL; - if ((err = mms_list_tail(&cmd->cmd_err_list)) == NULL) { - return; - } - if (err->retry_lib != NULL) { - free(err->retry_lib); - err->retry_lib = NULL; - } - if (lib == NULL) { - return; - } - err->retry_lib= - mms_strapp(err->retry_lib, - lib); -} -void -mm_set_retry_cart(mm_command_t *cmd, char *cart) -{ - mm_cmd_err_t *err = NULL; - if ((err = mms_list_tail(&cmd->cmd_err_list)) == NULL) { - return; - } - if (err->retry_cart != NULL) { - free(err->retry_cart); - err->retry_cart = NULL; - } - if (cart == NULL) { - return; - } - err->retry_cart = - mms_strapp(err->retry_cart, - cart); -} - -void -mm_clear_db(PGresult **results) -{ - if (*results != NULL) { - PQclear(*results); - *results = NULL; - } -} - -void -mm_rm_err(mm_command_t *cmd, mm_cmd_err_t *err) -{ - mm_cmd_err_t *cur_err = NULL; - mm_cmd_err_t *next_err = NULL; - - for (cur_err = mms_list_head(&cmd->cmd_err_list); - cur_err != NULL; - cur_err = next_err) { - next_err = mms_list_next(&cmd->cmd_err_list, - cur_err); - if (mm_same_err(err, cur_err)) { - cur_err->err_already_used = 1; - mms_trace(MMS_DEVP, - "mm_rm_err: " - "an error marked as used"); - } - - } - - -} - -void -mm_print_err(mm_cmd_err_t *err) -{ - - mms_trace(MMS_DEVP, - " %s, %s %s", - err->eclass, - err->ecode, - err->err_buf); - if (err->retry_drive != NULL) - mms_trace(MMS_DEVP, - " retry_drive = %s", - err->retry_drive); - if (err->retry_cart != NULL) - mms_trace(MMS_DEVP, - " retry_cart = %s", - err->retry_cart); - if (err->retry_lib != NULL) - mms_trace(MMS_DEVP, - " retry_lib = %s", - err->retry_lib); -} - -void -mm_print_err_list(mm_command_t *cmd) -{ - mm_cmd_err_t *err = NULL; - int err_count = 1; - - mms_trace(MMS_DEVP, - "mm_print_err_list: " - "error list is :"); - mms_list_foreach(&cmd->cmd_err_list, err) { - if (err->err_already_used) - continue; - mms_trace(MMS_DEVP, - " Error # %d:", - err_count); - mm_print_err(err); - err_count ++; - } -} - -void -mm_system_error(mm_command_t *cmd, char *fmt, ...) -{ - va_list args; - char *text; - - va_start(args, fmt); - - text = mms_vstrapp(NULL, fmt, args); - - va_end(args); - - mm_response_error(cmd, - ECLASS_INTERNAL, "ESYSTEM", - MM_5021_MSG, - "text", - text, - NULL); - - free(text); -} - -int -mm_copy_cmd_buf(mm_command_t *cmd1, mm_command_t *cmd2) { - SQL_CHK_LEN(&cmd1->cmd_buf, 0, &cmd1->cmd_bufsize, - strlen(cmd2->cmd_buf) + 1); - strcpy(cmd1->cmd_buf, cmd2->cmd_buf); -no_mem: - MM_ABORT_NO_MEM(); - return (1); -} - -char * -mm_ret_loctext(mms_par_node_t *root) { - mms_par_node_t *loctext_clause; - mms_par_node_t *loctext_arg; - mms_par_node_t *work = 0; - int i = 0; - - if ((loctext_clause = mms_pn_lookup(root, "loctext", - MMS_PN_CLAUSE, NULL)) == NULL) { - mms_trace(MMS_DEVP, - "response does not have a loctext clause"); - return (NULL); - } - while (i < 2) { - if ((loctext_arg = mms_pn_lookup(loctext_clause, NULL, - MMS_PN_STRING, &work)) == NULL) { - mms_trace(MMS_DEVP, - "response does not have an arg " - "in the loctext clause"); - return (NULL); - } - i ++; - } - return (loctext_arg->pn_string); -} - -int -mm_ret_msg_id(mms_par_node_t *root) { - - /* This function looks up a message id */ - /* from the parse tree root */ - /* if there is no message id, */ - /* return -1 */ - - mms_par_node_t *id_clause; - mms_par_node_t *id_arg; - mms_par_node_t *work = 0; - int i = 0; - int message_id = -1; - - if ((id_clause = mms_pn_lookup(root, "id", - MMS_PN_CLAUSE, 0)) == NULL) { - mms_trace(MMS_DEVP, - "response does not have an id clause"); - return (-1); - } - while (i < 3) { - if ((id_arg = mms_pn_lookup_arg(id_clause, NULL, - MMS_PN_STRING, &work)) == NULL) { - mms_trace(MMS_DEVP, - "response is missing an arg in the id clause"); - return (-1); - } - i ++; - } - if (id_arg->pn_string != NULL) { - message_id = atoi(id_arg->pn_string); - return (message_id); - } else { - mms_trace(MMS_ERR, - "bad id in message id arguement"); - return (-1); - } - - -} - -char * -mm_ret_response_msg(mm_command_t *cmd) { - char *msg_rsp = NULL; - - int message_id = 0; - char *local_text = NULL; - - /* - * If there is a message, - * look up the id in the catalog, - * and create the loctext. - * If there is no matching id, - * use the id number and the - * loc text from the response - */ - - if (cmd->cmd_response == NULL) { - mms_trace(MMS_DEVP, - "cmd->cmd_response is NULL," - "no response found"); - msg_rsp = mms_strapp(msg_rsp, "none"); - return (msg_rsp); - } - - /* Get the id and loctext */ - if ((message_id = mm_ret_msg_id(cmd->cmd_response)) == -1) { - mms_trace(MMS_DEVP, - "response does not have a message id"); - } else { - mms_trace(MMS_DEVP, - "message id is %d", - message_id); - } - if ((local_text = mm_ret_loctext(cmd->cmd_response)) == NULL) { - mms_trace(MMS_DEVP, - "response does not have a loctext"); - } else { - mms_trace(MMS_DEVP, - "local text is %s", - local_text); - } - if ((message_id == -1) && - (local_text == NULL)) { - mms_trace(MMS_DEVP, - "there is no message in this response" - "msg_rsp == 'none'"); - msg_rsp = mms_strapp(msg_rsp, "none"); - return (msg_rsp); - } - /* Check if the id is in the catalog */ - if (mm_msg_exists(message_id) == 0) { - /* no catalog message found */ - /* Use the id and/or loctext */ - msg_rsp = mms_strapp(msg_rsp, - "id: %d", - message_id); - if (local_text != NULL) { - msg_rsp = mms_strapp(msg_rsp, - " loctext: %s", - local_text); - } - return (msg_rsp); - } - - - if (mm_msg_parse(cmd, cmd->cmd_response)) { - mms_trace(MMS_ERR, - "mm_ret_response_msg: " - "internal error parsing message"); - } - if (cmd->cmd_msg.msg_localized) { - msg_rsp = mms_strapp(msg_rsp, cmd->cmd_msg.msg_localized); - return (msg_rsp); - } - mms_trace(MMS_ERR, - "error getting message from catalog"); - msg_rsp = mms_strapp(msg_rsp, "none"); - return (msg_rsp); - -} - - - -void -mm_set_cmd_err_buf(mm_command_t *cmd, char *class, char *token) { - - - mms_trace(MMS_DEBUG, "mm_set_cmd_err_buf"); - - /* If a child command had an error, */ - /* we should include the message in this error response */ - /* The error response should be in cmd->cmd_response */ - - mms_trace(MMS_ERR, " Class is %s, length %d", - class, strlen(class)); - mms_trace(MMS_ERR, " Token is %s, length %d", - token, strlen(token)); - - mm_response_error(cmd, - class, token, MM_5019_MSG, - NULL); - return; - - -no_mem: - MM_ABORT_NO_MEM(); -} - - -mm_command_t * -mm_alloc_cmd(mm_wka_t *mm_wka) { - /* Use this function to allocate mem space */ - /* for any MMS command */ - /* Sets up command for the given wka */ - - mm_data_t *mm_data = mm_wka->mm_data; - mm_command_t *mm_cmd; - cci_t *conn = &mm_wka->wka_conn; - - mm_cmd = (mm_command_t *)calloc(1, sizeof (mm_command_t)); - if (mm_cmd == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_command_t: %s", - strerror(errno)); - return (NULL); - } - /* set initial values */ - (void) snprintf(mm_cmd->wka_uuid, sizeof (mm_cmd->wka_uuid), - "%s", mm_wka->wka_conn.cci_uuid); - mm_get_uuid(mm_cmd->cmd_uuid); - MM_SET_FLAG(mm_cmd->cmd_flags, MM_CMD_DISPATCHABLE); - MM_SET_FLAG(mm_cmd->cmd_flags, MM_CMD_NEED_ACCEPT); - mm_cmd->wka_ptr = mm_wka; - mm_cmd->cmd_mm_data = mm_data; - - /* Zero ints */ - mm_cmd->cmd_state = 0; - mm_cmd->cmd_remove = 0; - mm_cmd->cmd_mount_info.cmi_need_clear = 0; - mm_cmd->cmd_notify_to = 0; - mm_cmd->cmd_begin_has_end = 0; - mm_cmd->cmd_bufsize = 0; - mm_cmd->cmd_source_num = 0; - mm_cmd->cmd_dest_num = 0; - mm_cmd->cmd_const_num = 0; - mm_cmd->cmd_begin_has_end = 0; - mm_cmd->cmd_notify_to = 0; - - /* char ptrs */ - mm_cmd->cmd_buf = NULL; - mm_cmd->cmd_begin_cmd = NULL; - mm_cmd->cmd_eclass = NULL; - mm_cmd->cmd_ecode = NULL; - mm_cmd->cmd_name = NULL; - mm_cmd->cmd_task = NULL; - mm_cmd->cmd_textcmd = NULL; - mm_cmd->cmd_report = NULL; - mm_cmd->cmd_err_ptr = NULL; - - /* mount command info */ - mm_cmd->cmd_mount_info.cmi_dm = NULL; - mm_cmd->cmd_mount_info.cmi_drive = NULL; - mm_cmd->cmd_mount_info.cmi_library = NULL; - mm_cmd->cmd_mount_info.cmi_cartridge = NULL; - mm_cmd->cmd_mount_info.cmi_pcl = NULL; - mm_cmd->cmd_mount_info.cmi_side_name = NULL; - mm_cmd->cmd_mount_info.cmi_capability = NULL; - mm_cmd->cmd_mount_info.cmi_handle = NULL; - mm_cmd->cmd_mount_info.cmi_where = NULL; - mm_cmd->cmd_mount_info.cmi_filename = NULL; - mm_cmd->cmd_mount_info.cmi_user = NULL; - mm_cmd->cmd_mount_info.cmi_blocksize = NULL; - mm_cmd->cmd_mount_info.cmi_filesequence = NULL; - mm_cmd->cmd_mount_info.cmi_volumeid = NULL; - mm_cmd->cmd_mount_info.cmi_retention = NULL; - mm_cmd->cmd_mount_info.cmi_first_drive = NULL; - mm_cmd->cmd_mount_info.cmi_first_lib = NULL; - mm_cmd->cmd_mount_info.cmi_second_drive = NULL; - mm_cmd->cmd_mount_info.cmi_second_lib = NULL; - mm_cmd->cmd_mount_info.cui_signature_type = NULL; - mm_cmd->cmd_mount_info.cui_signature = NULL; - - /* Create the source and dest lists */ - mm_cmd->cmd_has_list = 1; - mms_list_create(&mm_cmd->cmd_source_list, sizeof (mm_char_list_t), - offsetof(mm_char_list_t, mm_char_list_next)); - mms_list_create(&mm_cmd->cmd_dest_list, sizeof (mm_char_list_t), - offsetof(mm_char_list_t, mm_char_list_next)); - mms_list_create(&mm_cmd->cmd_const_list, sizeof (mm_char_list_t), - offsetof(mm_char_list_t, mm_char_list_next)); - mms_list_create(&mm_cmd->cmd_resp_list, sizeof (mm_char_list_t), - offsetof(mm_char_list_t, mm_char_list_next)); - /* error list */ - - mms_list_create(&mm_cmd->cmd_err_list, sizeof (mm_cmd_err_t), - offsetof(mm_cmd_err_t, mm_cmd_err_next)); - - - /* Initalize the access mode list */ - mms_list_create(&mm_cmd->cmd_mount_info.cmi_mode_list, - sizeof (cmi_mode_list_t), - offsetof(cmi_mode_list_t, cmi_mode_next)); - mm_cmd->cmd_mount_info.cmi_total_modes = 0; - /* initialize the cart list */ - mms_list_create(&mm_cmd->cmd_mount_info.cmi_cart_list, - sizeof (cmi_cart_list_t), - offsetof(cmi_cart_list_t, cmi_cart_next)); - - - mms_list_create(&mm_cmd->cmd_depend_list, sizeof (mm_command_t), - offsetof(mm_command_t, cmd_depend_list_next)); - - /* Create Begin-end list */ - mms_list_create(&mm_cmd->cmd_beginend_list, sizeof (mm_command_t), - offsetof(mm_command_t, cmd_next)); - - - if (mm_wka->wka_hello_needed == B_FALSE) { - /* Set Cmd->language */ - if (strcmp(conn->cci_language, "MMP") == 0) { - mm_cmd->cmd_language = MM_LANG_MMP; - } - if (strcmp(conn->cci_language, "DMP") == 0) { - mm_cmd->cmd_language = MM_LANG_DMP; - } - if (strcmp(conn->cci_language, "LMP") == 0) { - mm_cmd->cmd_language = MM_LANG_LMP; - } - } else { - /* Havent revieved a hello yet */ - mm_cmd->cmd_language = MM_LANG_MMP; - } - return (mm_cmd); -} - - -void -mm_get_uuid(uuid_text_t uuid) -{ - uuid_t uu; - - uuid_clear(uu); - /* - * Hit bugid 6397009 core dumped from get_ethernet_address() using - * uuid_generate(uu); so use uuid_generate_random(uu); instead. - */ - uuid_generate_random(uu); - uuid_unparse(uu, uuid); -} - -int -mm_is_fd_valid(int fd) -{ - if (fcntl(fd, F_GETFD, 0) == -1) { - return (-1); /* failed, fd is invalid */ - } - return (0); /* success, fd is valid */ -} - -int -mm_set_fd_limit(int fd_limit) -{ - struct rlimit rlp; - char buf[20]; - - if (getrlimit(RLIMIT_NOFILE, &rlp) != 0) { - mms_trace(MMS_ERR, "fd limit query %d: %s", - errno, strerror(errno)); - return (1); - } - if (fd_limit == -1) { - snprintf(buf, sizeof (buf), "\"default\""); - } else { - snprintf(buf, sizeof (buf), "%d", fd_limit); - } - mms_trace(MMS_DEVP, "mm fd limit is %s", buf); - mms_trace(MMS_DEVP, "current fd limit is %d", rlp.rlim_cur); - mms_trace(MMS_DEVP, "max fd limit is %d", rlp.rlim_max); - - /* wants to use system's open file descriptor max */ - if (fd_limit == -1) { - return (0); - } - - /* sanity check */ - if (fd_limit < MM_FD_LIMIT_MIN) { - fd_limit = MM_FD_LIMIT_MIN; - } else if (fd_limit > MM_FD_LIMIT_MAX) { - fd_limit = MM_FD_LIMIT_MAX; - } - if (fd_limit > rlp.rlim_max) { - fd_limit = rlp.rlim_max; - } - - /* change the current limit */ - rlp.rlim_cur = fd_limit; - - if (setrlimit(RLIMIT_NOFILE, &rlp) != 0) { - mms_trace(MMS_ERR, "fd limit set %d: %s", errno, - strerror(errno)); - /* don't exit. see that the limit is unchanged */ - } - - if (getrlimit(RLIMIT_NOFILE, &rlp) != 0) { - mms_trace(MMS_ERR, "fd limit get %d: %s", - errno, strerror(errno)); - return (1); - } - mms_trace(MMS_INFO, "current fd limit is %d", rlp.rlim_cur); - mms_trace(MMS_INFO, "max fd limit is %d", rlp.rlim_max); - return (0); -} - -void -mm_input_file(char *buf, int *result, void *callback_parm) -{ - mm_cb_file_t *parm = (mm_cb_file_t *)callback_parm; - - if (parm->mm_cbf_index == parm->mm_cbf_len) { - parm->mm_cbf_index = 0; - parm->mm_cbf_len = 0; - if (fgets(parm->mm_cbf_buf, parm->mm_cbf_size, - parm->mm_cbf_fp) == NULL) { - buf[0] = EOF; - *result = 0; - } else { - parm->mm_cbf_len = strlen(parm->mm_cbf_buf); - buf[0] = parm->mm_cbf_buf[parm->mm_cbf_index++]; - *result = 1; - } - } else { - buf[0] = parm->mm_cbf_buf[parm->mm_cbf_index++]; - *result = 1; - } -} - -char * -mm_parse_error(mms_list_t *err_list) -{ - mms_par_err_t *err; - char *resp; - - if ((err = mms_list_head(err_list)) == NULL) { - return (NULL); - } - resp = mms_strnew("response unacceptable " - "message [ id [ \"ieee\" \"1244\" \"5000\" ] " - "arguments [ " - "\"line\" \"%d\" " - "\"col\" \"%d\" " - "\"token\" \"%s\" " - "\"code\" \"%d\" " - "\"msg\" \"%s\" ] " - "loctext [ \"en\" \"line %d col %d " - "token %s code %d msg %s\" ] ]; ", err->pe_line, - err->pe_col, err->pe_token, err->pe_code, - err->pe_msg, err->pe_line, err->pe_col, - err->pe_token, err->pe_code, err->pe_msg); - - return (resp); -} - -mms_par_node_t * -mm_text_to_par_node(char *buf, parser_func_t parse_func) -{ - mms_par_node_t *cmd; - mms_list_t err_list; - int rc; - mms_par_err_t *err; - - rc = parse_func(&cmd, &err_list, buf); - if (rc) { - if (err = mms_list_head(&err_list)) { - mms_trace(MMS_ERR, "parse error\n" - "line %d col %d token %s code %d msg %s\n%s", - err->pe_line, err->pe_col, - err->pe_token, err->pe_code, - err->pe_msg, buf); - } else { - mms_trace(MMS_ERR, "parse error"); - } - mms_pe_destroy(&err_list); - mms_pn_destroy(cmd); - return (NULL); - } - mms_pe_destroy(&err_list); - return (cmd); -} - - -void -mm_send_response(mms_t *conn, mm_command_t *cmd) -{ - - /* Response list */ - mms_list_t *resp_list = &cmd->cmd_resp_list; - mm_char_list_t *cur_resp; - mm_char_list_t *next_resp; - - int sent_one = 0; - int sent_count = 0; - - mms_trace(MMS_DEVP, "mm_send_response"); - - for (cur_resp = mms_list_head(resp_list); - cur_resp != NULL; - cur_resp = next_resp) { - next_resp = mms_list_next(resp_list, cur_resp); - if (cur_resp->text != NULL) { - mm_send_text(conn, cur_resp->text); - sent_count ++; - sent_one = 1; - } - } - mms_trace(MMS_DEVP, "sent %d responses from list", - sent_count); - if (!sent_one) { - /* If there was not a response in the list */ - /* check the cmd_buf and send */ - mms_trace(MMS_DEVP, - "no response in list"); - if (cmd->cmd_buf != NULL) { - /* No response in the list */ - /* send the cmd_buf */ - mms_trace(MMS_DEVP, - "no resp in list, send cmd_buf"); - mm_send_text(conn, cmd->cmd_buf); - } - } - -} - - -void -mm_send_text(mms_t *conn, char *buf) -{ - int rc; - char ebuf[MMS_EBUF_LEN]; - int len; - - len = strlen(buf); - rc = mms_writer(conn, buf); - - if (rc != len) { - mms_get_error_string(&conn->mms_err, ebuf, MMS_EBUF_LEN); - mms_trace(MMS_ERR, "send buf fd -> %d, count %d\n\n%s\n%s\n", - conn->mms_fd, len, buf, ebuf); - mms_close(conn); - return; - } else { - mms_trace(MMS_DEVP, "sent fd -> %d, count %d\n\n%s\n", - conn->mms_fd, len, buf); - } -} - -void -mm_send_text_si(mms_t *conn, char *buf) -{ - int rc; - char ebuf[MMS_EBUF_LEN]; - int len; - - len = strlen(buf); - rc = mms_writer(conn, buf); - - if (rc != len) { - mms_get_error_string(&conn->mms_err, ebuf, MMS_EBUF_LEN); - mms_trace(MMS_ERR, "send buf fd -> %d, count %d\n\n%s\n%s\n", - conn->mms_fd, len, buf, ebuf); - mms_close(conn); - return; - } else { - mms_trace(MMS_DEVP, "sent fd -> %d, count %d\n\n", - conn->mms_fd, len); - } -} - -int -mm_parse_response(mms_par_node_t *root, mm_response_t *response) -{ - mms_par_node_t *arg; - mms_par_node_t *value; - mms_par_node_t *work; - char *text; - - text = mms_pn_build_cmd_text(root); - mms_trace(MMS_DEVP, "parse response\n%s", text); - free(text); - - if (mms_pn_lookup(root, "response", MMS_PN_CMD, NULL) == NULL) { - return (1); - } - - if (arg = mms_pn_lookup(root, "accepted", MMS_PN_KEYWORD, NULL)) { - response->response_type = MM_RESPONSE_ACCEPTED; - response->response_string = arg->pn_string; - } else if (arg = mms_pn_lookup(root, "unacceptable", - MMS_PN_KEYWORD, NULL)) { - response->response_type = MM_RESPONSE_UNACCEPTABLE; - response->response_string = arg->pn_string; - } else if (arg = mms_pn_lookup(root, "success", - MMS_PN_KEYWORD, NULL)) { - response->response_type = MM_RESPONSE_SUCCESS; - response->response_string = arg->pn_string; - } else if (arg = mms_pn_lookup(root, "cancelled", - MMS_PN_KEYWORD, NULL)) { - response->response_type = MM_RESPONSE_CANCELLED; - response->response_string = arg->pn_string; - } else if (arg = mms_pn_lookup(root, "error", - MMS_PN_CLAUSE, NULL)) { - response->response_type = MM_RESPONSE_ERROR; - response->response_string = arg->pn_string; - - work = NULL; - if (value = mms_pn_lookup(arg, NULL, - MMS_PN_KEYWORD, &work)) { - response->error_class = value->pn_string; - } - - if (value = mms_pn_lookup(arg, NULL, - MMS_PN_KEYWORD, &work)) { - response->error_code = value->pn_string; - } - } - - /* TODO: response text and message clauses */ - - return (0); -} - -/* get client connection hostname and ip mms_address from IPv4 or IPv6 */ -int -mm_connect_info(int fd, cci_t *conn) -{ - int sa_len; - union { - struct sockaddr *sa; - struct sockaddr_in *sin; - struct sockaddr_in6 *sin6; - } sa; - const int host_len = sizeof (mms_cli_host_t); - mms_cli_host_t host_str; - - - sa.sa = (struct sockaddr *)calloc(sizeof (char), host_len); - if (sa.sa == NULL) { - return (1); - } - sa_len = host_len; - - if (getpeername(fd, sa.sa, &sa_len)) { - free(sa.sa); - return (1); - } else if (sa.sa->sa_family == AF_INET) { - if (inet_ntop(AF_INET, &sa.sin->sin_addr, - host_str, host_len) == NULL) { - free(sa.sa); - return (1); - } - conn->cci_port = sa.sin->sin_port; - } else if (sa.sa->sa_family == AF_INET6) { - if (inet_ntop(AF_INET6, &sa.sin6->sin6_addr, - host_str, host_len) == NULL) { - free(sa.sa); - return (1); - } - conn->cci_port = sa.sin6->sin6_port; - } else { - free(sa.sa); - return (1); - } - free(sa.sa); - - if (mms_host_ident(host_str, conn->cci_host, conn->cci_ip) == NULL) { - return (1); - } - - return (0); -} - -/* get host from mm data as represented internally by mm */ -char * -mm_data_host_ident(mm_data_t *data) -{ - return (data->mm_host_ip); -} - -/* get host from work area as represented internally by mm */ -char * -mm_wka_host_ident(mm_wka_t *wka) -{ - return (wka->wka_conn.cci_ip); -} - -/* get host from command as represented internally by mm */ -char * -mm_cmd_host_ident(mm_command_t *cmd) -{ - return (cmd->wka_ptr->wka_conn.cci_ip); -} - -/* get host from cci as represented internally by mm */ -char * -mm_cci_host_ident(cci_t *conn) -{ - return (conn->cci_ip); -} - -/* get host from string as represented internally by mm */ -char * -mm_host_ident(char *host_str) -{ - mms_cli_host_t host; - cci_ip_t ip; - char *ident; - - if ((ident = mms_host_ident(host_str, host, ip)) == NULL) { - return (NULL); - } - return (strdup(ident)); -} - -void -mm_write_trace_level(mms_trace_sev_t severity) -{ - char *value; - - if ((value = mms_trace_sev2str(severity)) == NULL) { - value = mms_trace_sev2str(MMS_SEV_ERROR); - } - (void) mms_cfg_setvar(MMS_CFG_MM_TRACE, value); -} - -mms_trace_sev_t -mm_read_trace_level(void) -{ - char *value; - mms_trace_sev_t severity; - - if ((value = mms_cfg_alloc_getvar(MMS_CFG_MM_TRACE, NULL)) == NULL) { - severity = MMS_SEV_ERROR; - } else { - (void) mms_trace_str2sev(value, &severity); - } - if (value) - free(value); - return (severity); -} - -void -mm_reconcile_trace_level(mm_db_t *db) -{ - char *level; - mms_trace_sev_t db_severity; - mms_trace_sev_t file_severity; - - /* - * Reconcile file and database mms_trace level. - */ - if (mm_db_exec(HERE, db, "select \"TraceLevel\" from " - "\"SYSTEM\";") != MM_DB_DATA) { - mm_clear_db(&db->mm_db_results); - return; - } - if (PQntuples(db->mm_db_results) != 1) { - mm_clear_db(&db->mm_db_results); - return; - } - level = PQgetvalue(db->mm_db_results, 0, 0); - (void) mms_trace_str2sev(level, &db_severity); - mm_clear_db(&db->mm_db_results); - file_severity = mm_read_trace_level(); - if (file_severity != db_severity) { - if ((level = mms_trace_sev2str(file_severity)) == NULL) { - mm_write_trace_level(db_severity); - (void) mms_trace_filter(db_severity); - } else if (mm_db_exec(HERE, db, "update \"SYSTEM\" set " - "\"TraceLevel\" = '%s';", level) != MM_DB_OK) { - mm_clear_db(&db->mm_db_results); - } - } -} - -int -mm_get_fd_limit(mm_db_t *db) -{ - int limit; - - /* - * Get the allowed number of open sockets from the database - */ - if (mm_db_exec(HERE, db, "select \"SocketFdLimit\" from " - "\"SYSTEM\";") != MM_DB_DATA) { - limit = -1; - } else if (PQntuples(db->mm_db_results) != 1) { - limit = -1; - } else { - limit = atoi(PQgetvalue(db->mm_db_results, 0, 0)); - } - mm_clear_db(&db->mm_db_results); - - if (!(limit == -1 || (limit >= 1 && limit <= 65536))) { - limit = -1; - } - mms_trace(MMS_DEVP, "socket fd limit %d", limit); - return (limit); -} - - -char * -mm_return_char(mms_list_t *list, int index) { - mm_char_list_t *node; - mm_char_list_t *next; - int count = 0; - - for (node = mms_list_head(list); - node != NULL; - node = next) { - next = mms_list_next(list, node); - if (count == index) { - return (node->text); - } - count ++; - } - return (NULL); -} - - - -int -mm_add_char(char *str, mms_list_t *list) { - mm_char_list_t *node; - - - node = - (mm_char_list_t *)malloc(sizeof (mm_char_list_t)); - - if (node == NULL) { - mms_trace(MMS_ERR, "Error malloc source object"); - return (1); - } else { - memset(node, 0, sizeof (mm_char_list_t)); - node->text = NULL; - node->text = mms_strapp(node->text, str); - mms_list_insert_tail(list, node); - } - return (0); - -} - -void -mm_free_list(mms_list_t *list) { - mm_char_list_t *cur; - mm_char_list_t *next; - - for (cur = mms_list_head(list); - cur != NULL; - cur = next) { - next = mms_list_next(list, cur); - if (cur->text) - free(cur->text); - mms_list_remove(list, - cur); - free(cur); - } -} - -int -mm_add_int(int number, mms_list_t *list) { - mm_char_list_t *node; - - node = - (mm_char_list_t *)malloc(sizeof (mm_char_list_t)); - - if (node == NULL) { - mms_trace(MMS_ERR, "Error malloc source object"); - return (1); - } else { - memset(node, 0, sizeof (mm_char_list_t)); - node->number = number; - mms_list_insert_tail(list, node); - } - return (0); - -} - - -void -mm_print_char_list(mms_list_t *list) { - mm_char_list_t *node; - mm_char_list_t *next; - - for (node = mms_list_head(list); - node != NULL; - node = next) { - next = mms_list_next(list, node); - mms_trace(MMS_DEVP, " %s", node->text); - } -} - -int -mm_in_char_list(mms_list_t *list, char *str) { - mm_char_list_t *node; - mm_char_list_t *next; - - for (node = mms_list_head(list); - node != NULL; - node = next) { - next = mms_list_next(list, node); - if (strcmp(node->text, str) == 0) { - /* same */ - return (1); - } - } - return (0); - - - -} - -int -mm_replace_char(mms_list_t *list, int index, char *str) { - mm_char_list_t *node; - mm_char_list_t *next; - int count = 0; - - for (node = mms_list_head(list); - node != NULL; - node = next) { - next = mms_list_next(list, node); - if (count == index) { - free(node->text); - node->text = strdup(str); - return (0); - } - } - return (1); -} - - -int -mm_add_obj_list(mms_list_t *list, char *obj) { - mm_char_list_t *mm_char_struct; - - mm_char_list_t *cur_char; - mm_char_list_t *next; - /* If the obj is already in the list, skip */ - for (cur_char = mms_list_head(list); - cur_char != NULL; - cur_char = next) { - next = mms_list_next(list, cur_char); - if (strcmp(cur_char->text, obj) == 0) { - /* already have this obj */ - return (1); - } - } - /* Don't have this obj yet */ - mm_char_struct = (mm_char_list_t *) - calloc(1, sizeof (mm_char_list_t)); - if (mm_char_struct == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc mm_char_list_t: %s", - strerror(errno)); - return (1); - } - mm_char_struct->text = strdup(obj); - mms_list_insert_tail(list, mm_char_struct); - return (0); - -} - -int -mm_add_to_source(mm_command_t *cmd, char *str) { - - mms_list_t *source_list = &cmd->cmd_source_list; - - if (mm_add_obj_list(source_list, - str) == 0) { - cmd->cmd_source_num ++; - return (0); - } - return (1); -} -int -mm_add_to_dest(mm_command_t *cmd, char *str) { - - mms_list_t *dest_list = &cmd->cmd_dest_list; - - if (mm_add_obj_list(dest_list, - str) == 0) { - cmd->cmd_dest_num ++; - return (0); - } - return (1); -} -int -mm_add_to_const(mm_command_t *cmd, char *str) { - - mms_list_t *const_list = &cmd->cmd_const_list; - - if (mm_add_obj_list(const_list, - str) == 0) { - cmd->cmd_const_num ++; - return (0); - } - return (1); -} - -/* - * mm_free_err: - * -free's memory inside mm_cmd_err_t - * -caller should free the struct itself - */ - -void -mm_free_err(mm_cmd_err_t *cmd_error) { - if (cmd_error->ecode != NULL) { - free(cmd_error->ecode); - cmd_error->ecode = NULL; - } - if (cmd_error->eclass != NULL) { - free(cmd_error->eclass); - cmd_error->eclass = NULL; - } - if (cmd_error->err_buf != NULL) { - free(cmd_error->err_buf); - cmd_error->err_buf = NULL; - } - if (cmd_error->retry_drive != NULL) { - free(cmd_error->retry_drive); - cmd_error->retry_drive = NULL; - } - if (cmd_error->retry_cart != NULL) { - free(cmd_error->retry_cart); - cmd_error->retry_cart = NULL; - } - if (cmd_error->retry_lib != NULL) { - free(cmd_error->retry_lib); - cmd_error->retry_lib = NULL; - } - cmd_error->err_bufsize = 0; -} - -/* - * mm_free_err_list: - * -free's an entire cmd's err list - * -caller should call list destroy on the actual list - */ -void -mm_free_err_list(mm_command_t *cmd) { - - mm_cmd_err_t *cur_err; - mm_cmd_err_t *next_err; - - mms_list_t *err_list; - - err_list = &cmd->cmd_err_list; - - /* If the obj is already in the list, skip */ - for (cur_err = mms_list_head(err_list); - cur_err != NULL; - cur_err = next_err) { - next_err = mms_list_next(err_list, cur_err); - /* remove this from the list and free */ - mms_list_remove(err_list, - cur_err); - mm_free_err(cur_err); - free(cur_err); - } - -} - -/* - * mm_alloc_err: - * -allocates and initializes a new mm_cmd_err_t struct - */ - -mm_cmd_err_t * -mm_alloc_err() { - - mm_cmd_err_t *err = NULL; - - err = (mm_cmd_err_t *)calloc(1, sizeof (mm_cmd_err_t)); - if (err == NULL) { - mms_trace(MMS_ERR, - "mm_alloc_err: " - "Unable to malloc mm_cmd_err_t: %s", - strerror(errno)); - return (NULL); - } - err->eclass = NULL; - err->ecode = NULL; - err->err_buf = NULL; - err->err_bufsize = 0; - err->retry_drive = NULL; - err->retry_cart = NULL; - err->retry_lib = NULL; - err->err_already_used = 0; - - return (err); -} diff --git a/usr/src/cmd/mms/mm/common/mm_util.h b/usr/src/cmd/mms/mm/common/mm_util.h deleted file mode 100644 index d8716a27ce..0000000000 --- a/usr/src/cmd/mms/mm/common/mm_util.h +++ /dev/null @@ -1,118 +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 _MM_UTIL_H -#define _MM_UTIL_H - - -/* - * Parser command xml text file line callback structure - */ -typedef struct mm_cb_file mm_cb_file_t; -struct mm_cb_file { /* parser file callback */ - FILE *mm_cbf_fp; - char *mm_cbf_buf; - int mm_cbf_len; - int mm_cbf_index; - int mm_cbf_size; - mms_par_node_t **mm_cbf_node; -}; - -/* - * Enumerated response string - */ -typedef enum mm_response_type mm_response_type_t; -enum mm_response_type { - MM_RESPONSE_SUCCESS, - MM_RESPONSE_ACCEPTED, - MM_RESPONSE_UNACCEPTABLE, - MM_RESPONSE_CANCELLED, - MM_RESPONSE_ERROR -}; - -/* - * Response parse tree pointers - */ -typedef struct mm_response mm_response_t; -struct mm_response { - char *response_string; - mm_response_type_t response_type; - char *error_class; - char *error_code; -}; - - -typedef struct mm_char_list mm_char_list_t; -struct mm_char_list { - mms_list_node_t mm_char_list_next; - char *text; - int number; -}; - -/* - * MM, MMP, DMP, LMP routines - */ -extern void mm_get_uuid(uuid_text_t uuid); -extern int mm_is_fd_valid(int fd); -extern int mm_set_fd_limit(int fd_limit); -extern void mm_input(char *buf, int *result, int max, void *callback); -extern void mm_input_file(char *buf, int *result, void *callback); -extern char *mm_parse_error(mms_list_t *err_list); -extern mms_par_node_t *mm_text_to_par_node(char *buf, parser_func_t parse_func); -extern void mm_send_text(mms_t *conn, char *buf); -extern void mm_send_text_si(mms_t *conn, char *buf); -extern void mm_send_response(mms_t *conn, mm_command_t *cmd); -extern int mm_parse_response(mms_par_node_t *cmd, - mm_response_t *response); -extern int mm_connect_info(int fd, cci_t *conn); -/* get host from data type as represented internally by mm */ -extern char *mm_data_host_ident(mm_data_t *data); -extern char *mm_wka_host_ident(mm_wka_t *wka); -extern char *mm_cmd_host_ident(mm_command_t *cmd); -extern char *mm_cci_host_ident(cci_t *conn); -extern char *mm_host_ident(char *host_str); -extern mms_trace_sev_t mm_read_trace_level(void); -extern void mm_write_trace_level(mms_trace_sev_t sev); -extern void mm_reconcile_trace_level(mm_db_t *db); -extern int mm_get_fd_limit(mm_db_t *db); -extern int mm_add_char(char *str, mms_list_t *list); -extern int mm_add_int(int number, mms_list_t *list); -extern void mm_print_char_list(mms_list_t *list); -extern int mm_in_char_list(mms_list_t *list, char *str); -extern char *mm_return_char(mms_list_t *list, int index); -extern void mm_free_list(mms_list_t *list); -extern char *mm_ret_response_msg(mm_command_t *cmd); -extern void mm_free_err_list(mm_command_t *cmd); -extern mm_cmd_err_t *mm_alloc_err(); -extern void mm_print_err_list(mm_command_t *cmd); -extern void mm_print_err(mm_cmd_err_t *err); -extern void mm_set_retry_drive(mm_command_t *cmd, char *drive); -extern void mm_set_retry_lib(mm_command_t *cmd, char *lib); -extern void mm_set_retry_cart(mm_command_t *cmd, char *cart); -extern void mm_set_least_severe(mm_command_t *cmd); -extern int mm_same_err(mm_cmd_err_t *err1, mm_cmd_err_t *err2); -extern void mm_clear_cur_err(mm_command_t *cmd); -extern void mm_rm_err(mm_command_t *cmd, mm_cmd_err_t *err); -extern char *mm_return_err_text(mm_cmd_err_t *err); -#endif /* _MM_UTIL_H */ diff --git a/usr/src/cmd/mms/mm/common/mms_db b/usr/src/cmd/mms/mm/common/mms_db deleted file mode 100644 index f705c98a2b..0000000000 --- a/usr/src/cmd/mms/mm/common/mms_db +++ /dev/null @@ -1,2534 +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. -# -# -# This file contains the MMS data model and modifications. -# -# MMS Data Model: -# IEEE MMS Std. 1244.1-2000 sections 11-19 relational database model. -# Each MMS object is a SQL table. -# Each MMS object attribute is a SQL table column. -# Each MMS object instance is a SQL table row. -# -# MMS Data Model Modifications: -# If you add an upgrade be sure to add a downgrade for the change. - -# Only put database version digits 1-9 in column 1. -# Change existing database modifications in a new version. -# A table column add or delete requires updating the system defined table. -# SQL continuation lines can be indented. -# -# File Syntax: -# <version><mod> <sql> -# <sql-continued><sql-terminator> -# -# version = [1-9][0-9]+ starting in column 1 -# mod = u or d character for upgrade or downgrade -# sql = SQL command -# sql-continued = SQL command continuation lines can be indented. -# sql-terminator = ; -# -# Example: -# --------- -# 2u ALTER TABLE "MM" ADD "Test1" text default 'value1'; -# 2u SELECT mm_system_defined_add('MM','Test1'); -# -# 2d ALTER TABLE "MM" DROP "Test1"; -# 2d SELECT mm_system_defined_del('MM','Test1'); - -# -# Load PostgreSQL PL/pgSQL Language -# -1u CREATE FUNCTION plpgsql_call_handler() RETURNS language_handler - LANGUAGE 'C' AS 'plpgsql.so'; - -1u CREATE LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler - LANCOMPILER 'PL/pgSQL'; - -# -# Load Solaris UUID -# -1u CREATE FUNCTION pg_get_uuid() RETURNS text - LANGUAGE 'C' AS - '/usr/lib/mms/libpg.so'; - -# -# Load host name to IP address lookup -# -1u CREATE FUNCTION pg_host_ident(text) RETURNS text - LANGUAGE 'C' AS - '/usr/lib/mms/libpg.so'; - -# -# MMS Data Model Objects -# - -1u CREATE TABLE "APPLICATION" ( - "ApplicationName" text, - "SignatureAlgorithm" text - default 'undefined', - "AllowRemoteMount" boolean - default 'false' NOT NULL, - "BypassVerify" boolean - default 'true' NOT NULL, - "ReadWriteMode" text - CONSTRAINT "ReadWriteMode_CC" - CHECK("ReadWriteMode" = 'fixed' OR - "ReadWriteMode" = 'variable') - default 'fixed' NOT NULL, - "ValidateFileName" text - CONSTRAINT "ValidateFileName_CC" - CHECK("ValidateFileName" = 'yes' OR - "ValidateFileName" = 'no') - default 'no' NOT NULL, - "ValidateVolumeID" text - CONSTRAINT "ValidateVolumeID_CC" - CHECK("ValidateVolumeID" = 'yes' OR - "ValidateVolumeID" = 'no') - default 'yes' NOT NULL, - "ValidateExpirationDate" text - CONSTRAINT "ValidateExpirationDate_CC" - CHECK("ValidateExpirationDate" = 'yes' OR - "ValidateExpirationDate" = 'no') - default 'no' NOT NULL, - "SwitchLabel" text - CONSTRAINT "SwitchLabel_CC" - CHECK("SwitchLabel" = 'yes' OR - "SwitchLabel" = 'ask' OR - "SwitchLabel" = 'no') - default 'yes' NOT NULL, - "WriteOverExistingData" text - CONSTRAINT "WriteOverExistingData_CC" - CHECK("WriteOverExistingData" = 'yes' OR - "WriteOverExistingData" = 'ask' OR - "WriteOverExistingData" = 'no') - default 'yes' NOT NULL, - "Retention" integer - CONSTRAINT "Retention_CC" - CHECK("Retention" >= 0 AND - "Retention" <= 99999) - default 0, - CONSTRAINT "APPLICATION_PK" PRIMARY KEY("ApplicationName") - /* CLIENT-DEFINED */ -); - -1u CREATE TABLE "AI" ( - "AIName" text - NOT NULL, - "ApplicationName" text - CONSTRAINT "ApplicationName_CC" - REFERENCES "APPLICATION", - "PrivilegeChangeable" boolean - default 'false' NOT NULL, - "DefaultPriority" integer - CONSTRAINT "DefaultPriority_CC" - CHECK("DefaultPriority" >= 0 AND - "DefaultPriority" <= 1000) - default 500, - "SessionsAllowed" text - CONSTRAINT "SessionsAllowed_CC" - CHECK("SessionsAllowed" = 'multiple' OR - "SessionsAllowed" = 'single') - default 'single' NOT NULL, - "MessageLevel" text - CONSTRAINT "MessageLevel_CC" - CHECK("MessageLevel" = 'emergency' OR - "MessageLevel" = 'alert' OR - "MessageLevel" = 'critical' OR - "MessageLevel" = 'error' OR - "MessageLevel" = 'warning' OR - "MessageLevel" = 'notice' OR - "MessageLevel" = 'information' OR - "MessageLevel" = 'debug' OR - "MessageLevel" = 'developer') - default 'error' NOT NULL, - CONSTRAINT "AI_PK" PRIMARY KEY("ApplicationName", "AIName") - /* CLIENT-DEFINED */ -); - -1u CREATE TABLE "CONNECTION" ( - "Language" text - CONSTRAINT "Language_CC" - CHECK("Language" = 'MMP' OR - "Language" = 'DMP' OR - "Language" = 'LMP') - NOT NULL, - "Version" text - CONSTRAINT "Version_CC" - CHECK("Version" = '1.0') - default '1.0' NOT NULL, - "ConnectionClientName" text - NOT NULL, - "ConnectionClientInstance" text - NOT NULL, - "ConnectionClientHost" text - NOT NULL, - "ConnectionClientPort" text - NOT NULL, - "ConnectionTimeCreated" timestamp (3) - default current_timestamp NOT NULL, - "ConnectionTimeLastActive" timestamp (3) - default current_timestamp NOT NULL, - "ConnectionID" text /* uuid */, - CONSTRAINT "CONNECTION_PK" PRIMARY KEY("ConnectionID") -); - -1u CREATE TABLE "SESSION" ( - "SessionID" text /* uuid */, - "ApplicationName" text - CONSTRAINT "ApplicationName_CC" - REFERENCES "APPLICATION", - "AIName" text - NOT NULL, - "ConnectionID" text - CONSTRAINT "ConnectionID_CC" - REFERENCES "CONNECTION", - "Language" text - CONSTRAINT "Language_CC" - CHECK("Language" = 'MMP' OR - "Language" = 'DMP' OR - "Language" = 'LMP') - default 'MMP' NOT NULL, - "SessionAttached" boolean - default 'true' NOT NULL, - "SessionClientHost" text - NOT NULL, - "SessionClientPort" text - NOT NULL, - "SessionTimeCreated" timestamp (3) - default current_timestamp NOT NULL, - "SessionTimeLastActive" timestamp (3) - default current_timestamp NOT NULL, - "SessionTag" text - default NULL, - CONSTRAINT "SESSION_PK" PRIMARY KEY("SessionID"), - CONSTRAINT "SESSION_FK" FOREIGN KEY("ApplicationName", "AIName") - REFERENCES "AI" - /* CLIENT-DEFINED */ -); - - -# Only the events currently implemented have a scope other than 'off' - -1u CREATE TABLE "NOTIFY" ( - "ConnectionID" text, - "ConnectionClientName" text, - "ConnectionClientInstance" text, - "NotifyConfigChange" text - CONSTRAINT "NotifyConfigChange_CC" - CHECK("NotifyConfigChange" = 'global' OR - "NotifyConfigChange" = 'host' OR - "NotifyConfigChange" = 'off') - default 'off' NOT NULL, - "NotifyNewDrive" text - CONSTRAINT "NotifyNewDrive_CC" - CHECK("NotifyNewDrive" = 'global' OR - "NotifyNewDrive" = 'application' OR - "NotifyNewDrive" = 'off') - default 'off' NOT NULL, - "NotifyNewCartridge" text - CONSTRAINT "NotifyNewCartridge_CC" - CHECK("NotifyNewCartridge" = 'global' OR - "NotifyNewCartridge" = 'application' OR - "NotifyNewCartridge" = 'off') - default 'off' NOT NULL, - "NotifyMessage" text - CONSTRAINT "NotifyMessage_CC" - CHECK("NotifyMessage" = 'global' OR - "NotifyMessage" = 'off') - default 'off' NOT NULL, - "NotifyRequest" text - CONSTRAINT "NotifyRequest_CC" - CHECK("NotifyRequest" = 'global' OR - "NotifyRequest" = 'off') - default 'off' NOT NULL, - "NotifyVolumeInject" text - CONSTRAINT "NotifyVolumeInject_CC" - CHECK("NotifyVolumeInject" = 'global' OR - "NotifyVolumeInject" = 'application' OR - "NotifyVolumeInject" = 'instance' OR - "NotifyVolumeInject" = 'off') - default 'off' NOT NULL, - "NotifyVolumeEject" text - CONSTRAINT "NotifyVolumeEject_CC" - CHECK("NotifyVolumeEject" = 'global' OR - "NotifyVolumeEject" = 'application' OR - "NotifyVolumeEject" = 'instance' OR - "NotifyVolumeEject" = 'off') - default 'off' NOT NULL, - "NotifyVolumeAdd" text - CONSTRAINT "NotifyVolumeAdd_CC" - CHECK("NotifyVolumeAdd" = 'global' OR - "NotifyVolumeAdd" = 'application' OR - "NotifyVolumeAdd" = 'instance' OR - "NotifyVolumeAdd" = 'off') - default 'off' NOT NULL, - "NotifyVolumeDelete" text - CONSTRAINT "NotifyVolumeDelete_CC" - CHECK("NotifyVolumeDelete" = 'global' OR - "NotifyVolumeDelete" = 'application' OR - "NotifyVolumeDelete" = 'instance' OR - "NotifyVolumeDelete" = 'off') - default 'off' NOT NULL, - "NotifyDMUp" text - CONSTRAINT "NotifyDMUp_CC" - CHECK("NotifyDMUp" = 'global' OR - "NotifyDMUp" = 'host' OR - "NotifyDMUp" = 'off') - default 'off' NOT NULL, - "NotifyDMDown" text - CONSTRAINT "NotifyDMDown_CC" - CHECK("NotifyDMDown" = 'global' OR - "NotifyDMDown" = 'host' OR - "NotifyDMDown" = 'off') - default 'off' NOT NULL, - "NotifyDriveOnline" text - CONSTRAINT "NotifyDriveOnline_CC" - CHECK("NotifyDriveOnline" = 'global' OR - "NotifyDriveOnline" = 'application' OR - "NotifyDriveOnline" = 'off') - default 'off' NOT NULL, - "NotifyDriveOffline" text - CONSTRAINT "NotifyDriveOffline_CC" - CHECK("NotifyDriveOffline" = 'global' OR - "NotifyDriveOffline" = 'application' OR - "NotifyDriveOffline" = 'off') - default 'off' NOT NULL, - "NotifyLMUp" text - CONSTRAINT "NotifyLMUp_CC" - CHECK("NotifyLMUp" = 'global' OR - "NotifyLMUp" = 'off') - default 'off' NOT NULL, - "NotifyLMDown" text - CONSTRAINT "NotifyLMDown_CC" - CHECK("NotifyLMDown" = 'global' OR - "NotifyLMDown" = 'off') - default 'off' NOT NULL, - "NotifyLibraryCreate" text - CONSTRAINT "NotifyLibraryCreate_CC" - CHECK("NotifyLibraryCreate" = 'global' OR - "NotifyLibraryCreate" = 'off') - default 'off' NOT NULL, - "NotifyLibraryDelete" text - CONSTRAINT "NotifyLibraryDelete_CC" - CHECK("NotifyLibraryDelete" = 'global' OR - "NotifyLibraryDelete" = 'off') - default 'off' NOT NULL, - "NotifyDriveDelete" text - CONSTRAINT "NotifyDriveDelete_CC" - CHECK("NotifyDriveDelete" = 'global' OR - "NotifyDriveDelete" = 'off') - default 'off' NOT NULL, - "NotifyStatus" text - CONSTRAINT "NotifyStatus_CC" - CHECK("NotifyStatus" = 'global' OR - "NotifyStatus" = 'off') - default 'off' NOT NULL, - "NotifyCartridge" text - CONSTRAINT "NotifyCartridge_CC" - CHECK("NotifyCartridge" = 'global' OR - "NotifyCartridge" = 'off') - default 'off' NOT NULL, - "NotifyVolume" text - CONSTRAINT "NotifyVolume_CC" - CHECK("NotifyVolume" = 'global' OR - "NotifyVolume" = 'off') - default 'off' NOT NULL, - CONSTRAINT "NOTIFY_PK" PRIMARY KEY("ConnectionID") -); - -1u CREATE TABLE "NOTIFYRULES"( - "ConnectionID" text, - "NotifyID" text, - "NotifyTag" text, - "NotifyObject" text, - "NotifyAction" text, - "NotifyScope" text -); - -1u CREATE TABLE "EVENTRULES"( - "NotifyID" text, - "NotifyObject" text, - "Data1" text, - "Data2" text, - "Data3" text, - "Data4" text, - "Data5" text -); - -1u CREATE TABLE "LIBRARY" ( - "LibraryName" text, - "LibraryDisabled" text - CONSTRAINT "LibraryDisabled_CC" - CHECK("LibraryDisabled" = 'true' OR - "LibraryDisabled" = 'false' OR - "LibraryDisabled" = 'temporary') - default 'false' NOT NULL, - "LibraryBroken" boolean - default 'false' NOT NULL, - "LMName" text, - "LibraryStateHard" text - CONSTRAINT "LibraryStateHard_CC" - CHECK("LibraryStateHard" = 'unknown') - default 'unknown' NOT NULL, - "LibraryStateSoft" text - CONSTRAINT "LibraryStateSoft_CC" - CHECK("LibraryStateSoft" = 'ready' OR - "LibraryStateSoft" = 'in use') - default 'ready' NOT NULL, - "LibraryOnline" text - CONSTRAINT "LibraryOnline_CC" - CHECK("LibraryOnline" = 'true' OR - "LibraryOnline" = 'false') - default 'false' NOT NULL, - "LibraryType" text, - "LibraryConnection" text - CONSTRAINT "LibraryConnection_CC" - CHECK("LibraryConnection" = 'network' OR - "LibraryConnection" = 'direct'), - "LibraryIP" text, - "LibraryPath" text, - "LibraryACS" text, - "LibraryLSM" text, - "LibrarySerialNumber" text, - "LibraryACSLSPort" int, - "DefaultLibraryPath" text, - CONSTRAINT "LIBRARY_PK" PRIMARY KEY("LibraryName") - /* SYSTEM-DEFINED */ -); - -1u CREATE TABLE "LIBRARYACCESS"( - "LibraryName" text - CONSTRAINT "LibraryName_CC" - REFERENCES "LIBRARY", - "HostName" text - CONSTRAINT "HostName_CC" - CHECK("HostName" != 'localhost' AND - "HostName" != '127.0.0.1' AND - "HostName" != '::1') - NOT NULL, - "LibraryPath" text - NOT NULL, - CONSTRAINT "LIBRARYACCESS_PK" - PRIMARY KEY("LibraryName", "HostName") -); - -1u CREATE TABLE "LM" ( - "LibraryName" text - CONSTRAINT "LibraryName_CC" - REFERENCES "LIBRARY", - "LMName" text, - "LMHost" text, - "LMTargetPath" text, - "LMTargetHost" text - CONSTRAINT "LMTargetHost_CC" - CHECK("LMTargetHost" != 'localhost' AND - "LMTargetHost" != '127.0.0.1' AND - "LMTargetHost" != '::1'), - "LMMessageLevel" text - CONSTRAINT "LMMessageLevel_CC" - CHECK("LMMessageLevel" = 'emergency' OR - "LMMessageLevel" = 'alert' OR - "LMMessageLevel" = 'critical' OR - "LMMessageLevel" = 'error' OR - "LMMessageLevel" = 'warning' OR - "LMMessageLevel" = 'notice' OR - "LMMessageLevel" = 'information' OR - "LMMessageLevel" = 'debug' OR - "LMMessageLevel" = 'developer') - default 'error' NOT NULL, - "LMStateHard" text - CONSTRAINT "LMStateHard_CC" - CHECK("LMStateHard" = 'ready' OR - "LMStateHard" = 'broken') - default 'ready' NOT NULL, - "LMStateSoft" text - CONSTRAINT "LMStateSoft_CC" - CHECK("LMStateSoft" = 'absent' OR - "LMStateSoft" = 'present' OR - "LMStateSoft" = 'not ready' OR - "LMStateSoft" = 'disconnected' OR - "LMStateSoft" = 'ready') - default 'absent' NOT NULL, - "LMDisabled" text - CONSTRAINT "LMDisabled_CC" - CHECK("LMDisabled" = 'false' OR - "LMDisabled" = 'true') - default 'false' NOT NULL, - "TraceLevel" text - CONSTRAINT "TraceLevel_CC" - CHECK("TraceLevel" = 'emergency' OR - "TraceLevel" = 'alert' OR - "TraceLevel" = 'critical' OR - "TraceLevel" = 'operational' OR - "TraceLevel" = 'error' OR - "TraceLevel" = 'warning' OR - "TraceLevel" = 'notice' OR - "TraceLevel" = 'information' OR - "TraceLevel" = 'debug' OR - "TraceLevel" = 'developer') - default 'debug' NOT NULL, - "TraceFileSize" text - default '10M', - "LMSSIPort" int - CONSTRAINT "LMSSIPort_CC" - CHECK("LMSSIPort" > 0) - default 50004, - CONSTRAINT "LM_PK" PRIMARY KEY("LMName") - /* SYSTEM-DEFINED */ -); - -1u CREATE TABLE "BAY" ( - "BayName" text - NOT NULL, - "LibraryName" text - CONSTRAINT "LibraryName_CC" - REFERENCES "LIBRARY", - "LMName" text - CONSTRAINT "LMName_CC" - REFERENCES "LM" ON DELETE CASCADE, - "BayAccessible" boolean - default 'false' NOT NULL, - CONSTRAINT "BAY_PK" PRIMARY KEY ("BayName", "LibraryName", "LMName") -); - -1u CREATE TABLE "SLOTTYPE" ( - "SlotTypeName" text - NOT NULL, - "CartridgeShapeName" text - NOT NULL, - CONSTRAINT "SLOTTYPE_PK" - PRIMARY KEY ("SlotTypeName", "CartridgeShapeName") - /* SYSTEM-DEFINED */ -); - -1u CREATE TABLE "CARTRIDGEGROUP" ( - "CartridgeGroupName" text, - "CartridgeGroupPriority" integer - CONSTRAINT "CartridgeGroupPriority_CC" - CHECK("CartridgeGroupPriority" >= 0) - default 1000, - CONSTRAINT "CARTRIDGEGROUP_PK" PRIMARY KEY("CartridgeGroupName") - /* CLIENT-DEFINED */ -); - -1u CREATE TABLE "CARTRIDGETYPE" ( - "CartridgeTypeName" text, - "CartridgeTypeNumberSides" integer - CONSTRAINT "CartridgeTypeNumberSides_CC" - CHECK("CartridgeTypeNumberSides" >= 1) - default 1, - "CartridgeTypeMediaLength" integer - CONSTRAINT "CartridgeTypeMediaLength_CC" - CHECK("CartridgeTypeMediaLength" >= 0) - default 0, - "CartridgeTypeMediaType" text - CONSTRAINT "CartridgeTypeMediaType_CC" - CHECK("CartridgeTypeMediaType" = 'data' OR - "CartridgeTypeMediaType" = 'cleaning' OR - "CartridgeTypeMediaType" = 'diagnostic' OR - "CartridgeTypeMediaType" = 'microcode' OR - "CartridgeTypeMediaType" = 'alignment' OR - "CartridgeTypeMediaType" = 'worm' OR - "CartridgeTypeMediaType" = 'volsafe') - default 'data' NOT NULL, - "MaxUseCount" integer - CONSTRAINT "MaxUseCount_CC" - CHECK("MaxUseCount" >= 0) - default 100000, - "CartridgeShapeName" text /* trigger REFERENCES "SLOTTYPE" */, - CONSTRAINT "CARTRIDGETYPE_PK" PRIMARY KEY("CartridgeTypeName") - /* SYSTEM-DEFINED */ -); - -1u CREATE TABLE "CARTRIDGE" ( - "CartridgeID" text - default pg_get_uuid(), - "CartridgePCL" text - NOT NULL, - "CartridgeState" text - CONSTRAINT "CartridgeState_CC" - CHECK("CartridgeState" = 'defined' OR - "CartridgeState" = 'identified' OR - "CartridgeState" = 'allocatable' OR - "CartridgeState" = 'error' OR - "CartridgeState" = 'deallocated' OR - "CartridgeState" = 'recycled') - default 'defined' NOT NULL, - "CartridgeStatus" text - CONSTRAINT "CartridgeStatus_CC" - CHECK("CartridgeStatus" = 'in use' OR - "CartridgeStatus" = 'unavailable' OR - "CartridgeStatus" = 'available') - default 'unavailable' NOT NULL, - "CartridgeDriveOccupied" boolean - default 'false' NOT NULL, - "CartridgeTypeName" text - CONSTRAINT "CartridgeTypeName_CC" - REFERENCES "CARTRIDGETYPE" NOT NULL, - "CartridgeGroupName" text - CONSTRAINT "CartridgeGroupName_CC" - REFERENCES "CARTRIDGEGROUP", - "CartridgeTimeCreated" timestamp (3) - default current_timestamp NOT NULL, - "CartridgeTimeMountedLast" timestamp (3) - default '-infinity' NOT NULL, - "CartridgeTimeMountedTotal" timestamp (3) - default '-infinity' NOT NULL, - "CartridgeNumberMounts" integer - CONSTRAINT "CartridgeNumberMounts_CC" - CHECK("CartridgeNumberMounts" >= 0) - default 0, - "CartridgeNumberVolumes" integer - CONSTRAINT "CartridgeNumberVolumes_CC" - CHECK("CartridgeNumberVolumes" >= 0) - default 0, - "CartridgeWriteProtected" text - CONSTRAINT "CartridgeWriteProtected_CC" - CHECK("CartridgeWriteProtected" = 'yes' OR - "CartridgeWriteProtected" = 'no' OR - "CartridgeWriteProtected" = 'unknown' ) - default 'unknown' NOT NULL, - "CartridgeRecoveredReads" integer - CONSTRAINT "CartridgeRecoveredReads_CC" - CHECK("CartridgeRecoveredReads" >= 0) - default '0', - "CartridgeRecoveredWrites" integer - CONSTRAINT "CartridgeRecoveredWrites_CC" - CHECK("CartridgeRecoveredWrites" >= 0) - default '0', - "CartridgeUnrecoveredReads" integer - CONSTRAINT "CartridgeUnrecoveredReads_CC" - CHECK("CartridgeUnrecoveredReads" >= 0) - default '0', - "CartridgeUnrecoveredWrites" integer - CONSTRAINT "CartridgeUnrecoveredWrites_CC" - CHECK("CartridgeUnrecoveredWrites" >= 0) - default '0', - "CartridgeBytesRead" text - default '0', - "CartridgeBytesWritten" text - default '0', - "CartridgeMediaError" text - CONSTRAINT "CartridgeMediaError_CC" - CHECK("CartridgeMediaError" = 'yes' OR - "CartridgeMediaError" = 'no' ) - default 'no' NOT NULL, - "ApplicationName" text - CONSTRAINT "ApplicationName_CC" - REFERENCES "APPLICATION", - "LibraryName" text - CONSTRAINT "LibraryName_CC" - REFERENCES "LIBRARY", - CONSTRAINT "CARTRIDGE_PK" PRIMARY KEY("CartridgeID") - /* CLIENT-DEFINED */ -); - -1u CREATE TABLE "CARTRIDGEGROUPAPPLICATION" ( - "ApplicationName" text - CONSTRAINT "ApplicationName_CC" - REFERENCES "APPLICATION", - "CartridgeGroupName" text - CONSTRAINT "CartridgeGroupName_CC" - REFERENCES "CARTRIDGEGROUP", - "CartridgeGroupApplicationPriority" integer - default 1000, - CONSTRAINT "CARTRIDGEGROUPAPPLICATION_PK" - PRIMARY KEY ("ApplicationName", "CartridgeGroupName") -); - -1u CREATE TABLE "SIDE" ( - "CartridgeID" text - CONSTRAINT "CartridgeID_CC" - REFERENCES "CARTRIDGE", - "SideName" text - NOT NULL, - "SideNumberMounts" integer - CONSTRAINT "SideNumberMounts_CC" - CHECK("SideNumberMounts" >= 0) - default 0, - "SideTimeCreated" timestamp (3) - default current_timestamp NOT NULL, - "SideTimeMountedLast" timestamp (3) - default '-infinity' NOT NULL, - "SideTimeMountedTotal" integer - CONSTRAINT "SideTimeMountedTotal_CC" - CHECK("SideTimeMountedTotal" >= 0) - default 0, - CONSTRAINT "SIDE_PK" PRIMARY KEY ("CartridgeID", "SideName") - /* CLIENT-DEFINED */ -); - -1u CREATE TABLE "PARTITION" ( - "PartitionName" text - NOT NULL, - "CartridgeID" text - CONSTRAINT "CartridgeID_CC" - REFERENCES "CARTRIDGE", - "CartridgePCL" text - NOT NULL, - "LibraryName" text - CONSTRAINT "LibraryName_CC" - REFERENCES "LIBRARY", - "SideName" text - NOT NULL, - "PartitionSize" integer - CONSTRAINT "PartitionSize_CC" - CHECK("PartitionSize" >= -1) - default -1, - "PartitionAvailable" integer - CONSTRAINT "PartitionAvailable_CC" - CHECK("PartitionAvailable" >= -1) - default -1, - "PartitionPercentAvailable" integer - CONSTRAINT "PartitionPercentAvailable_CC" - CHECK("PartitionPercentAvailable" >= -1) - default -1, - "PartitionBitFormat" text - default 'bit_unknown', - "PartitionAllocatable" boolean - default 'true' NOT NULL, - "PartitionSignature" text - CONSTRAINT "PartitionSignature_CC" - CHECK("PartitionSignature" = 'undefined') - default 'undefined' NOT NULL, - "PartitionSignatureState" text - CONSTRAINT "PartitionSignatureState_CC" - CHECK("PartitionSignatureState" = 'unimplemented' OR - "PartitionSignatureState" = 'unknown' OR - "PartitionSignatureState" = 'uninitialized' OR - "PartitionSignatureState" = 'system' OR - "PartitionSignatureState" = 'application' OR - "PartitionSignatureState" = 'sysactive' OR - "PartitionSignatureState" = 'appactive') - default 'unimplemented' NOT NULL, - "PartitionSignatureAlgorithm" text - default 'undefined', - "PartitionSignatureType" text, - "PartitionMediaSerial" text - default 'undefined', - "PartitionMediaSerialState" text - CONSTRAINT "PartitionMediaSerialState_CC" - CHECK("PartitionMediaSerialState" = 'unknown' OR - "PartitionMediaSerialState" = 'uninitialized' OR - "PartitionMediaSerialState" = 'known' OR - "PartitionMediaSerialState" = 'unimplemented') - default 'unknown' NOT NULL, - "PartitionNumberMounts" integer - CONSTRAINT "PartitionNumberMounts_CC" - CHECK("PartitionNumberMounts" >= 0) - default 0, - "PartitionTimeCreated" timestamp (3) - default current_timestamp NOT NULL, - "PartitionTimeMountedTotal" integer - CONSTRAINT "PartitionTimeMountedTotal_CC" - CHECK("PartitionTimeMountedTotal" >= 0) - default 0, - "PartitionTimeMountedLast" timestamp (3) - default '-infinity' NOT NULL, - "PartitionEOFPos" text, - "PartitionRWMode" text - CONSTRAINT "PartitionRWMode_CC" - CHECK("PartitionRWMode" = 'readonly' OR - "PartitionRWMode" = 'readwrite') - default 'readwrite' NOT NULL, - CONSTRAINT "PARTITION_FK" - FOREIGN KEY ("CartridgeID", "SideName") REFERENCES "SIDE", - CONSTRAINT "PARTITION_PK" - PRIMARY KEY ("CartridgeID", "SideName", "PartitionName") - /* CLIENT-DEFINED */ -); - -1u CREATE TABLE "VOLUME" ( - "ApplicationName" text - CONSTRAINT "ApplicationName_CC" - REFERENCES "APPLICATION", - "AIName" text - default 'any' NOT NULL, - "VolumeName" text - NOT NULL, - "VolumeSerialNumber" text, - "LabelType" text - CONSTRAINT "LabelType_CC" - CHECK("LabelType" = 'ansi' OR - "LabelType" = 'ibm' OR - "LabelType" = 'nonlabeled' OR - "LabelType" = 'unknown') - default 'unknown' NOT NULL, - "CartridgeID" text - CONSTRAINT "CartridgeID_CC" - REFERENCES "CARTRIDGE", - "SideName" text - NOT NULL, - "PartitionName" text - NOT NULL, - "VolumeNumberMounts" integer - CONSTRAINT "VolumeNumberMounts_CC" - CHECK("VolumeNumberMounts" >= 0) - default 0, - "VolumeTimeCreated" timestamp (3) - default current_timestamp NOT NULL, - "VolumeTimeMountedLast" timestamp (3) - default '-infinity' NOT NULL, - "VolumeTimeMountedTotal" integer - CONSTRAINT "VolumeTimeMountedTotal_CC" - CHECK("VolumeTimeMountedTotal" >= 0) - default 0, - CONSTRAINT "VOLUME_FK" - FOREIGN KEY ("CartridgeID", "SideName", "PartitionName") - REFERENCES "PARTITION", - CONSTRAINT "VOLUME_PK" - PRIMARY KEY ("VolumeName", "ApplicationName") - /* CLIENT-DEFINED */ -); - -1u CREATE TABLE "DRIVEGROUP" ( - "DriveGroupName" text, - "DriveGroupUnloadTime" integer - CONSTRAINT "DriveGroupUnloadTime_CC" - CHECK("DriveGroupUnloadTime" >= 0) - default 60, - CONSTRAINT "DRIVEGROUP_PK" PRIMARY KEY("DriveGroupName") - /* SYSTEM-DEFINED */ -); - -1u CREATE TABLE "DRIVEGROUPAPPLICATION" ( - "DriveGroupName" text - CONSTRAINT "DriveGroupName_CC" - REFERENCES "DRIVEGROUP", - "ApplicationName" text - CONSTRAINT "ApplicationName_CC" - REFERENCES "APPLICATION", - "DriveGroupApplicationPriority" integer - CONSTRAINT "DriveGroupApplicationPriority_CC" - CHECK("DriveGroupApplicationPriority" >= 0) - default 1000, - "DriveGroupApplicationUnloadTime" integer - CONSTRAINT "DriveGroupApplicationUnloadTime_CC" - CHECK("DriveGroupApplicationUnloadTime" >= 0) - default 60, - CONSTRAINT "DRIVEGROUPAPPLICATION_PK" - PRIMARY KEY ("DriveGroupName", "ApplicationName") -); - -1u CREATE TABLE "DRIVE" ( - "DriveName" text, - "DriveGroupName" text - CONSTRAINT "DriveGroupName_CC" - REFERENCES "DRIVEGROUP", - "DrivePriority" integer - CONSTRAINT "DrivePriority_CC" - CHECK("DrivePriority" >= 0 AND - "DrivePriority" <= 1000) - default 1000, - "DMName" text, - "DriveShapeName" text - default 'unknown', - "DriveDisabled" text - CONSTRAINT "DriveDisabled_CC" - CHECK("DriveDisabled" = 'true' OR - "DriveDisabled" = 'false' OR - "DriveDisabled" = 'temporary') - default 'false' NOT NULL, - "DriveBroken" boolean - default 'false' NOT NULL, - "DriveStateSoft" text - CONSTRAINT "DriveStateSoft_CC" - CHECK("DriveStateSoft" = 'in use' OR - "DriveStateSoft" = 'ready' OR - "DriveStateSoft" = 'unavailable') - default 'unavailable' NOT NULL, - "DriveStateHard" text - CONSTRAINT "DriveStateHard_CC" - CHECK("DriveStateHard" = 'loaded' OR - "DriveStateHard" = 'loading' OR - "DriveStateHard" = 'unloading' OR - "DriveStateHard" = 'unloaded') - default 'unloaded' NOT NULL, - "DriveTimeCreated" timestamp (3) - default current_timestamp NOT NULL, - "DriveTimeMountedLast" timestamp (3) - default '-infinity' NOT NULL, - "DriveTimeMountedTotal" timestamp (3) - default '-infinity' NOT NULL, - "DriveNumberMounts" integer - CONSTRAINT "DriveNumberMounts_CC" - CHECK("DriveNumberMounts" >= 0) - default 0, - "DriveNumberMountsSinceCleaning" integer - CONSTRAINT "DriveNumberMountsSinceCleaning_CC" - CHECK("DriveNumberMountsSinceCleaning" >= 0) - default 0, - "LibraryName" text - CONSTRAINT "LibraryName_CC" - REFERENCES "LIBRARY", - "BayName" text, - "DriveLibraryAccessible" boolean - default 'false' NOT NULL, - "DriveLibraryOccupied" boolean - default 'false' NOT NULL, - "CartridgePCL" text /* trigger REFERENCES "CARTRIDGE" */, - "DriveNeedsCleaning" text - CONSTRAINT "DriveNeedsCleaning_CC" - CHECK("DriveNeedsCleaning" = 'true' OR - "DriveNeedsCleaning" = 'false' OR - "DriveNeedsCleaning" = 'advisory' OR - "DriveNeedsCleaning" = 'mandatory') - default 'false' NOT NULL, - "MaxMounts" integer - CONSTRAINT "MaxMounts_CC" - CHECK("MaxMounts" >= 0) - default 0, - "ExclusiveAppName" text - default 'none' NOT NULL, - "ReserveDrive" text - CONSTRAINT "ReserveDrive_CC" - CHECK("ReserveDrive" = 'yes' OR - "ReserveDrive" = 'no') - default 'yes' NOT NULL, - "DefaultBlocksize" integer - CONSTRAINT "DefaultBlocksize_CC" - CHECK("DefaultBlocksize" >= 0) - default '262144', - "DriveGeometry" text, - "DriveSerialNum" text, - "DriveOnline" boolean - default 'false' NOT NULL, - "DriveVendorID" text, - "DriveProductID" text, - "DriveTypeName" text, - CONSTRAINT "DRIVE_PK" PRIMARY KEY("DriveName") - /* SYSTEM-DEFINED */ -); - -1u CREATE TABLE "DM" ( - "DMName" text, - "DriveName" text - CONSTRAINT "DriveName_CC" - REFERENCES "DRIVE", - "DMHost" text, - "DMTargetPath" text, - "DMTargetHost" text - CONSTRAINT "DMTargetHost_CC" - CHECK("DMTargetHost" != 'localhost' AND - "DMTargetHost" != '127.0.0.1' AND - "DMTargetHost" != '::1'), - "DMMessageLevel" text - CONSTRAINT "DMMessageLevel_CC" - CHECK("DMMessageLevel" = 'emergency' OR - "DMMessageLevel" = 'alert' OR - "DMMessageLevel" = 'critical' OR - "DMMessageLevel" = 'error' OR - "DMMessageLevel" = 'warning' OR - "DMMessageLevel" = 'notice' OR - "DMMessageLevel" = 'information' OR - "DMMessageLevel" = 'debug' OR - "DMMessageLevel" = 'developer') - default 'error' NOT NULL, - "DMStateHard" text - CONSTRAINT "DMStateHard_CC" - CHECK("DMStateHard" = 'ready' OR - "DMStateHard" = 'broken') - default 'ready' NOT NULL, - "DMStateSoft" text - CONSTRAINT "DMStateSoft_CC" - CHECK("DMStateSoft" = 'absent' OR - "DMStateSoft" = 'present' OR - "DMStateSoft" = 'not ready' OR - "DMStateSoft" = 'disconnected' OR - "DMStateSoft" = 'ready' OR - "DMStateSoft" = 'reserved') - default 'absent' NOT NULL, - "DMDisabled" text - CONSTRAINT "DMDisabled_CC" - CHECK("DMDisabled" = 'false' OR - "DMDisabled" = 'true') - default 'false' NOT NULL, - "TraceLevel" text - CONSTRAINT "TraceLevel_CC" - CHECK("TraceLevel" = 'emergency' OR - "TraceLevel" = 'alert' OR - "TraceLevel" = 'critical' OR - "TraceLevel" = 'operational' OR - "TraceLevel" = 'error' OR - "TraceLevel" = 'warning' OR - "TraceLevel" = 'notice' OR - "TraceLevel" = 'information' OR - "TraceLevel" = 'debug' OR - "TraceLevel" = 'developer') - default 'debug' NOT NULL, - "TraceFileSize" text - default '10M', - CONSTRAINT "DM_PK" PRIMARY KEY("DMName") - /* SYSTEM-DEFINED */ -); - -1u CREATE TABLE "DMCAPABILITY" ( - "DriveName" text - CONSTRAINT "DriveName_CC" - REFERENCES "DRIVE" ON DELETE CASCADE, - "DMName" text - CONSTRAINT "DMName_CC" - REFERENCES "DM" ON DELETE CASCADE, - "DMCapabilityName" text - NOT NULL, - CONSTRAINT "DMCAPABILITY_PK" - PRIMARY KEY ("DriveName", "DMName", "DMCapabilityName") - /* CLIENT-DEFINED */ -); - -1u CREATE TABLE "DMCAPABILITYTOKEN" ( - "DriveName" text - CONSTRAINT "DriveName_CC" - REFERENCES "DRIVE" ON DELETE CASCADE, - "DMName" text - CONSTRAINT "DMName_CC" - REFERENCES "DM" ON DELETE CASCADE, - "DMCapabilityName" text, - "DMCapabilityToken" text - NOT NULL, - CONSTRAINT "DMCAPABILITYTOKEN_FK" - FOREIGN KEY ("DriveName", "DMName", "DMCapabilityName") - REFERENCES "DMCAPABILITY" ON DELETE CASCADE -); - -1u CREATE TABLE "DMCAPABILITYDEFAULTTOKEN" ( - "DriveName" text - CONSTRAINT "DriveName_CC" - REFERENCES "DRIVE" ON DELETE CASCADE, - "DMName" text - CONSTRAINT "DMName_CC" - REFERENCES "DM" ON DELETE CASCADE, - "DMCapabilityToken" text - NOT NULL -); - -1u CREATE TABLE "DMCAPABILITYGROUP" ( - "DriveName" text - CONSTRAINT "DriveName_CC" - REFERENCES "DRIVE" ON DELETE CASCADE, - "DMName" text - CONSTRAINT "DMName_CC" - REFERENCES "DM" ON DELETE CASCADE, - "DMCapabilityGroupName" text - NOT NULL, - "DMCapabilityGroupDefaultName" text, - "DMCapabilityGroupType" text - CONSTRAINT "DMCapabilityGroupType_CC" - CHECK("DMCapabilityGroupType" = 'interchange' OR - "DMCapabilityGroupType" = 'access') - DEFAULT 'access', - CONSTRAINT "DMCAPABILITYGROUP_PK" - PRIMARY KEY("DriveName", "DMName", "DMCapabilityGroupName") -); - -1u CREATE TABLE "DMCAPABILITYGROUPTOKEN" ( - "DriveName" text, - "DMName" text, - "DMCapabilityGroupName" text, - "DMCapabilityToken" text - NOT NULL, - CONSTRAINT "DMCAPABILITYGROUPTOKEN_PK" - PRIMARY KEY ("DriveName", "DMName", "DMCapabilityToken"), - CONSTRAINT "DMCAPABILITYGROUPTOKEN_FK" - FOREIGN KEY ("DriveName", "DMName", "DMCapabilityGroupName") - REFERENCES "DMCAPABILITYGROUP" ON DELETE CASCADE -); - -1u CREATE TABLE "DMBITFORMAT" ( - "DriveName" text - CONSTRAINT "DriveName_CC" - REFERENCES "DRIVE" ON DELETE CASCADE, - "DMName" text - CONSTRAINT "DMName_CC" - REFERENCES "DM" ON DELETE CASCADE, - "DMBitFormatName" text, - "DMBitFormatDefaultToken" text - NOT NULL, - CONSTRAINT "DMBITFORMAT_PK" - PRIMARY KEY ("DriveName", "DMName", "DMBitFormatName") -); - -1u CREATE TABLE "DMBITFORMATTOKEN" ( - "DriveName" text - NOT NULL, - "DMName" text - NOT NULL, - "DMBitFormatName" text, - "DMCapabilityToken" text - NOT NULL, - CONSTRAINT "DMBITFORMATTOKEN_PK" - PRIMARY KEY ("DriveName", "DMName", "DMBitFormatName", - "DMCapabilityToken"), - CONSTRAINT "DMBITFORMATTOKEN_FK" - FOREIGN KEY ("DriveName", "DMName", "DMCapabilityToken") - REFERENCES "DMCAPABILITYGROUPTOKEN" ON DELETE CASCADE -); - -1u CREATE TABLE "SLOTGROUP" ( - "SlotGroupName" text - NOT NULL, - "Direction" text - CONSTRAINT "Direction_CC" - CHECK("Direction" = 'in' OR - "Direction" = 'out' OR - "Direction" = 'both' OR - "Direction" = 'none') - default 'none', - "Type" text - CONSTRAINT "Type_CC" - CHECK("Type" = 'port' OR - "Type" = 'magazine' OR - "Type" = 'ordinary') - default 'ordinary' NOT NULL, - "LibraryName" text - CONSTRAINT "LibraryName_CC" - REFERENCES "LIBRARY", - "LMName" text - CONSTRAINT "LMName_CC" - REFERENCES "LM", - "BayName" text, - CONSTRAINT "SLOTGROUP_FK" - FOREIGN KEY("BayName", "LibraryName", "LMName") - REFERENCES "BAY" ON DELETE CASCADE, - CONSTRAINT "SLOTGROUP_PK" PRIMARY KEY ("SlotGroupName", "LibraryName") -); - -1u CREATE TABLE "SLOT" ( - "SlotName" text, - "LibraryName" text - CONSTRAINT "LibraryName_CC" - REFERENCES "LIBRARY", - "LMName" text - CONSTRAINT "LMName_CC" - REFERENCES "LM", - "BayName" text, - "SlotGroupName" text - NOT NULL, - "SlotTypeName" text /* trigger REFERENCES "SLOTTYPE" */, - "CartridgeID" text - CONSTRAINT "CartridgeID_CC" - REFERENCES "CARTRIDGE", - "CartridgePCL" text /* trigger REFERENCES "CARTRIDGE" */, - "SlotAccessable" boolean - default 'false' NOT NULL, - "SlotOccupied" boolean - default 'false' NOT NULL, - CONSTRAINT "SLOT_FK" - FOREIGN KEY ("SlotGroupName", "LibraryName") - REFERENCES "SLOTGROUP", - CONSTRAINT "SLOT_2ND_FK" - FOREIGN KEY ("BayName", "LibraryName", "LMName") - REFERENCES "BAY", - CONSTRAINT "SLOT_PK" PRIMARY KEY("SlotName") -); - -1u CREATE TABLE "SLOTCONFIG" ( - "LibraryName" text - CONSTRAINT "LibraryName_CC" - REFERENCES "LIBRARY" ON DELETE CASCADE, - "LMName" text - CONSTRAINT "LMName_CC" - REFERENCES "LM" ON DELETE CASCADE, - "BayName" text, - "SlotTypeName" text, - "SlotConfigNumberFree" integer - CONSTRAINT "SlotConfigNumberFree_CC" - CHECK("SlotConfigNumberFree" >= 0) - default 0, - "SlotConfigNumberTotal" integer - CONSTRAINT "SlotConfigNumberTotal_CC" - CHECK("SlotConfigNumberTotal" >= 0) - default 0, - CONSTRAINT "SLOTCONFIG_FK" - FOREIGN KEY ("BayName", "LibraryName", "LMName") - REFERENCES "BAY" ON DELETE CASCADE -); - -1u CREATE TABLE "MOUNTLOGICAL" ( - "ApplicationName" text - CONSTRAINT "ApplicationName_CC" - REFERENCES "APPLICATION", - "VolumeName" text - NOT NULL, - "PartitionName" text - NOT NULL, - "SideName" text - NOT NULL, - "CartridgeID" text - CONSTRAINT "CartridgeID_CC" - REFERENCES "CARTRIDGE", - "DriveName" text - CONSTRAINT "DriveName_CC" - REFERENCES "DRIVE", - "DMName" text - CONSTRAINT "DMName_CC" - REFERENCES "DM", - "DMCapabilityName" text, - "MountLogicalHandle" text, - "MountLogicalTimeWhenMounted" timestamp (3) - default current_timestamp NOT NULL, - CONSTRAINT "MOUNTLOGICAL_FK" - FOREIGN KEY ("VolumeName", "ApplicationName") - REFERENCES "VOLUME", - CONSTRAINT "MOUNTLOGICAL_PK" PRIMARY KEY("MountLogicalHandle") -); - -1u CREATE TABLE "MOUNTPHYSICAL" ( - "ApplicationName" text - CONSTRAINT "ApplicationName_CC" - REFERENCES "APPLICATION", - "DriveName" text - CONSTRAINT "DriveName_CC" - REFERENCES "DRIVE", - "LibraryName" text - CONSTRAINT "LibraryName_CC" - REFERENCES "LIBRARY", - "CartridgeID" text - CONSTRAINT "CartridgeID_CC" - REFERENCES "CARTRIDGE", - "CartridgePCL" text /* trigger REFERENCES "CARTRIDGE" */, - "SideName" text NOT NULL, - "SlotName" text NOT NULL, - "MountPhysicalTimeWhenMounted" timestamp (3) - default current_timestamp NOT NULL, - "SessionID" text - NOT NULL, - CONSTRAINT "MOUNTPHYSICAL_FK" - FOREIGN KEY ("CartridgeID", "SideName") REFERENCES "SIDE", - CONSTRAINT "MOUNTPHYSICAL_PK" - PRIMARY KEY ("ApplicationName", "DriveName", "LibraryName", - "CartridgeID", "SideName") -); - -1u CREATE TABLE "DRIVECARTRIDGEACCESS" ( - "DriveName" text, - "DMName" text, - "CartridgeID" text, - "SideName" text - NOT NULL, - "PartitionName" text - NOT NULL, - "ApplicationName" text, - "DriveCartridgeAccessTimeMount" timestamp (3) - default '-infinity' NOT NULL, - "DriveCartridgeAccessByteReadCount" bigint - CONSTRAINT "DriveCartridgeAccessByteReadCount_CC" - CHECK("DriveCartridgeAccessByteReadCount" >= -1) - default -1, - "DriveCartridgeAccessByteWriteCount" bigint - CONSTRAINT "DriveCartridgeAccessByteWriteCount_CC" - CHECK("DriveCartridgeAccessByteWriteCount" >= -1) - default -1, - "DriveCartridgeAccessHardReadErrorCount" integer - CONSTRAINT "DriveCartridgeAccessHardReadErrorCount_CC" - CHECK("DriveCartridgeAccessHardReadErrorCount" >= -1) - default -1, - "DriveCartridgeAccessSoftReadErrorCount" integer - CONSTRAINT "DriveCartridgeAccessSoftReadErrorCount_CC" - CHECK("DriveCartridgeAccessSoftReadErrorCount" >= -1) - default -1, - "DriveCartridgeAccessHardWriteErrorCount" integer - CONSTRAINT "DriveCartridgeAccessHardWriteErrorCount_CC" - CHECK("DriveCartridgeAccessHardWriteErrorCount" >= -1) - default -1, - "DriveCartridgeAccessSoftWriteErrorCount" integer - CONSTRAINT "DriveCartridgeAccessSoftWriteErrorCount_CC" - CHECK("DriveCartridgeAccessSoftWriteErrorCount" >= -1) - default -1, - "DriveCartridgeAccessTimeUnmount" timestamp (3) - default '-infinity' NOT NULL, - "DriveCartridgeAccessMediumByteReadCount" bigint - CONSTRAINT "DriveCartridgeAccessMediumByteReadCount_CC" - CHECK("DriveCartridgeAccessMediumByteReadCount" >= 0) - default 0, - "DriveCartridgeAccessMediumByteWriteCount" bigint - CONSTRAINT "DriveCartridgeAccessMediumByteWriteCount_CC" - CHECK("DriveCartridgeAccessMediumByteWriteCount" >= 0) - default 0, - "CartridgePCL" text, - "DriveSerialNum" text, - "CartridgeShapeName" text, - "DriveShapeName" text, - /* CLIENT-DEFINED */ - CONSTRAINT "DRIVECARTRIDGEACCESS_PK" - PRIMARY KEY("CartridgeID", "DriveName", - "DriveCartridgeAccessTimeUnmount") -); - -1u CREATE table "DRIVECARTRIDGEERROR" ( - "DriveName" text, - "DMName" text, - "CartridgeID" text, - "SideName" text NOT NULL, - "PartitionName" text NOT NULL, - "ApplicationName" text, - "CartridgePCL" text, - "DriveSerialNum" text, - "CartridgeShapeName" text, - "DriveShapeName" text, - "CDB" text, - "SCSICommand" text, - "IOStatus" text, - "SenseKey" text, - "AdditionalSenseCode" text, - "AdditionalSenseCodeQualifier" text, - "SenseBytes" text, - "ErrorText" text, - "TimeStamp" timestamp (3) - default current_timestamp NOT NULL, - CONSTRAINT "DRIVECARTRIDGEERROR_PK" - PRIMARY KEY("DriveName","CartridgeID","TimeStamp") -); - -1u CREATE TABLE "TASK" ( - "TaskID" text, - "TaskType" text, - "TaskArrivalTime" timestamp (3) - default current_timestamp NOT NULL, - "TaskPriority" integer - CONSTRAINT "TaskPriority_CC" - CHECK("TaskPriority" >= 0) - default 1000, - "ApplicationName" text - CONSTRAINT "ApplicationName_CC" - REFERENCES "APPLICATION", - "AIName" text - NOT NULL, - "TaskStatement" text, - "TaskState" text - CONSTRAINT "TaskState_CC" - CHECK("TaskState" = 'blocked' OR - "TaskState" = 'dispatched') - default 'blocked', - "ClientTaskID" text, - CONSTRAINT "TASK_FK" - FOREIGN KEY("ApplicationName", "AIName") REFERENCES "AI", - CONSTRAINT "TASK_PK" PRIMARY KEY("TaskID") -); - -1u CREATE TABLE "TASKCARTRIDGE" ( - "TaskID" text - CONSTRAINT "TaskID_CC" - REFERENCES "TASK" ON DELETE CASCADE, - "CartridgeID" text - CONSTRAINT "CartridgeID_CC" - REFERENCES "CARTRIDGE" -); - -1u CREATE TABLE "TASKDRIVE" ( - "TaskID" text - CONSTRAINT "TaskID_CC" - REFERENCES "TASK" ON DELETE CASCADE, - "DriveName" text - CONSTRAINT "DriveName_CC" - REFERENCES "DRIVE" -); - -1u CREATE TABLE "TASKLIBRARY" ( - "TaskID" text - CONSTRAINT "TaskID_CC" - REFERENCES "TASK" ON DELETE CASCADE, - "LibraryName" text - CONSTRAINT "LibraryName_CC" - REFERENCES "LIBRARY" -); - -1u CREATE TABLE "MESSAGE" ( - "MessageID" text - default pg_get_uuid(), - "MessageSenderType" text - CONSTRAINT "MessageSenderType_CC" - CHECK("MessageSenderType" = 'LM' OR - "MessageSenderType" = 'DM' OR - "MessageSenderType" = 'MM' OR - "MessageSenderType" = 'AI') - NOT NULL, - "MessageSenderName" text, - "MessageSenderInstance" text, - "MessageConnectionID" text, - "MessageHost" text, - "MessageLevel" text - CONSTRAINT "MessageLevel_CC" - CHECK("MessageLevel" = 'emergency' OR - "MessageLevel" = 'alert' OR - "MessageLevel" = 'critical' OR - "MessageLevel" = 'error' OR - "MessageLevel" = 'warning' OR - "MessageLevel" = 'notice' OR - "MessageLevel" = 'information' OR - "MessageLevel" = 'debug' OR - "MessageLevel" = 'developer') - NOT NULL, - "MessageManufacturer" text, - "MessageModel" text, - "MessageNumber" text, - "MessageText" text, - "MessageTimeCreated" timestamp (3) - default current_timestamp NOT NULL, - CONSTRAINT "MESSAGE_PK" PRIMARY KEY("MessageID") -); - -1u CREATE sequence request_seqnum minvalue 1 maxvalue 99999 cycle; - -1u CREATE TABLE "REQUEST" ( - "RequestID" text, - "RequestingTaskID" text - /* trigger REFERENCES "TASK" ("TaskID") */, - "RequestingClient" text, - "RequestingInstance" text, - "RequestingConnectionID" text, - "RequestHost" text, - "RequestingClientType" text - CONSTRAINT "RequestingClientType_CC" - CHECK("RequestingClientType" = 'LM' OR - "RequestingClientType" = 'DM' OR - "RequestingClientType" = 'MM' OR - "RequestingClientType" = 'AI') - NOT NULL, - "RequestPriority" integer - CONSTRAINT "RequestPriority_CC" - CHECK("RequestPriority" >= 0 AND - "RequestPriority" <= 1000), - "RequestState" text - CONSTRAINT "RequestState_CC" - CHECK("RequestState" = 'pending' OR - "RequestState" = 'accepted' OR - "RequestState" = 'responded') - default 'pending' NOT NULL, - "RequestManufacturer" text, - "RequestModel" text, - "RequestNumber" text, - "RequestText" text, - "AcceptingClient" text, - "AcceptingInstance" text, - "AcceptingSessionID" text - /* trigger REFERENCES "SESSION" ("SessionID") */, - "ResponseManufacturer" text, - "ResponseModel" text, - "ResponseNumber" text, - "ResponseText" text, - "RequestTimeCreated" timestamp (3) - default current_timestamp NOT NULL, - "RequestTimeAccepted" timestamp (3) - default '-infinity' NOT NULL, - "RequestTimeResponded" timestamp (3) - default '-infinity' NOT NULL, - "RequestAlias" integer - default nextval('request_seqnum'), - CONSTRAINT "REQUEST_PK" PRIMARY KEY("RequestID") -); - -1u CREATE function check_fd_limit(integer) returns boolean as ' - begin - if $1 >= 30 and $1 <= 65536 then - return true; - end if; - if $1 = -1 then - return true; - end if; - return false; - end; - ' language 'plpgsql'; - -1u CREATE TABLE "SYSTEM" ( - "Administrator" text - default 'unknown', - "AttendanceMode" text - CONSTRAINT "AttendanceMode_CC" - CHECK("AttendanceMode" = 'attended' OR - "AttendanceMode" = 'unattended') - default 'attended' NOT NULL, - "SystemLogLevel" text - CONSTRAINT "SystemLogLevel_CC" - CHECK("SystemLogLevel" = 'emergency' OR - "SystemLogLevel" = 'alert' OR - "SystemLogLevel" = 'critical' OR - "SystemLogLevel" = 'error' OR - "SystemLogLevel" = 'warning' OR - "SystemLogLevel" = 'notice' OR - "SystemLogLevel" = 'information' OR - "SystemLogLevel" = 'debug' OR - "SystemLogLevel" = 'developer') - default 'error' NOT NULL, - "SystemAcceptLevel" text - CONSTRAINT "SystemAcceptLevel_CC" - CHECK("SystemAcceptLevel" = 'emergency' OR - "SystemAcceptLevel" = 'alert' OR - "SystemAcceptLevel" = 'critical' OR - "SystemAcceptLevel" = 'error' OR - "SystemAcceptLevel" = 'warning' OR - "SystemAcceptLevel" = 'notice' OR - "SystemAcceptLevel" = 'information' OR - "SystemAcceptLevel" = 'debug' OR - "SystemAcceptLevel" = 'developer') - default 'error' NOT NULL, - "SystemLogFile" text - default '/var/log/mms/system_log', - "SystemMessageLimit" integer - CONSTRAINT "SystemMessageLimit_CC" - CHECK("SystemMessageLimit" >= 0) - default 100, - "SystemMessageCount" integer - CONSTRAINT "SystemMessageCount_CC" - CHECK("SystemMessageCount" >= 0) - default 0, - "SystemRequestLimit" integer - CONSTRAINT "SystemRequestLimit_CC" - CHECK("SystemRequestLimit" >= 0) - default 100, - "SystemRequestCount" integer - CONSTRAINT "SystemRequestCount_CC" - CHECK("SystemRequestLimit" >= 0) - default 0, - "SystemSyncLimit" integer - CONSTRAINT "SystemSyncLimit_CC" - CHECK("SystemSyncLimit" >= 0) - default 1000, - "SystemDCALimit" integer - CONSTRAINT "SystemDCALimit_CC" - CHECK("SystemDCALimit" >= 0) - default 100, - "SystemDCACount" integer - CONSTRAINT "SystemDCACount_CC" - CHECK("SystemDCACount" >= 0) - default 0, - "ClearDriveAtLMConfig" text - CONSTRAINT "ClearDriveAtLMConfig_CC" - CHECK("ClearDriveAtLMConfig" = 'yes' OR - "ClearDriveAtLMConfig" = 'no') - default 'no' NOT NULL, - "AskClearDriveAtLMConfig" text - CONSTRAINT "AskClearDriveAtLMConfig_CC" - CHECK("AskClearDriveAtLMConfig" = 'yes' OR - "AskClearDriveAtLMConfig" = 'no') - default 'yes' NOT NULL, - "PreemptReservation" text - CONSTRAINT "PreemptReservation_CC" - CHECK("PreemptReservation" = 'yes' OR - "PreemptReservation" = 'ask' OR - "PreemptReservation" = 'no') - default 'yes' NOT NULL, - /* MM settings --> */ - "MessageLevel" text - CONSTRAINT "MessageLevel_CC" - CHECK("MessageLevel" = 'emergency' OR - "MessageLevel" = 'alert' OR - "MessageLevel" = 'critical' OR - "MessageLevel" = 'error' OR - "MessageLevel" = 'warning' OR - "MessageLevel" = 'notice' OR - "MessageLevel" = 'information' OR - "MessageLevel" = 'debug' OR - "MessageLevel" = 'developer') - default 'error' NOT NULL, - "TraceLevel" text - CONSTRAINT "TraceLevel_CC" - CHECK("TraceLevel" = 'emergency' OR - "TraceLevel" = 'alert' OR - "TraceLevel" = 'critical' OR - "TraceLevel" = 'operational' OR - "TraceLevel" = 'error' OR - "TraceLevel" = 'warning' OR - "TraceLevel" = 'notice' OR - "TraceLevel" = 'information' OR - "TraceLevel" = 'debug' OR - "TraceLevel" = 'developer') - default 'debug' NOT NULL, - "TraceFileSize" text - default '10M', - "SocketFdLimit" integer - CONSTRAINT "SocketFdLimit_CC" - CHECK(check_fd_limit("SocketFdLimit")) - default -1, - "SystemLogFileSize" text - default '10M', - "SystemName" text, - "SystemInstance" text, - "UnloadDelayTime" integer - default '20', - "DefaultBlocksize" integer - CONSTRAINT "DefaultBlocksize_CC" - CHECK("DefaultBlocksize" >= 0) - default '262144', - "SystemDiskMountTimeout" integer - CONSTRAINT "SystemDiskMountTimeout_CC" - CHECK("SystemDiskMountTimeout" >= 0) - default 5, - "WatcherStartsLimit" integer - CONSTRAINT "WatcherStartsLimit_CC" - CHECK("WatcherStartsLimit" >= 3 OR - "WatcherStartsLimit" = -1) - default 3, - "WatcherTimeLimit" integer - CONSTRAINT "WatcherTimeLimit_CC" - CHECK("WatcherTimeLimit" >= 60) - default 60, - "DriveRecordRetention" integer - CONSTRAINT "DriveRecordRetention_CC" - CHECK("DriveRecordRetention" >= 1) - default 30, - CONSTRAINT "SYSTEM_PK" PRIMARY KEY("Administrator") - /* SYSTEM-DEFINED */ -); - -1u CREATE TABLE "STALEHANDLE" ( - "ApplicationName" text - CONSTRAINT "ApplicationName_CC" - REFERENCES "APPLICATION", - "VolumeName" text - NOT NULL, - "PartitionName" text - NOT NULL, - "SideName" text - NOT NULL, - "CartridgeID" text - CONSTRAINT "CartridgeID_CC" - REFERENCES "CARTRIDGE", - "DriveName" text - CONSTRAINT "DriveName_CC" - REFERENCES "DRIVE", - "DMName" text - CONSTRAINT "DMName_CC" - REFERENCES "DM", - "MountLogicalHandle" text, - CONSTRAINT "STALEHANDLE_FK" - FOREIGN KEY ("VolumeName", "ApplicationName") - REFERENCES "VOLUME" -); - -1u CREATE TABLE "MM" ( - "DBInitialized" boolean - default 'false' NOT NULL, - "DBVersion" integer - CONSTRAINT "DBVersion_CC" - CHECK("DBVersion" >= 1) - default '1' -); - -1u CREATE TABLE "SYSTEM_DEFINED" ( - objname text, - attribute text, - CONSTRAINT "SYSTEM_DEFINED_PK" PRIMARY KEY(objname, attribute) -); - -1u CREATE table "EVENT"( - "ObjectName" text, - "Info1" text, - "Info2" text, - "Info3" text, - "Info4" text, - "Seen" boolean - default 'false' -); - -1u CREATE table "DMSHAPEPRIORITY"( - "DMName" text - CONSTRAINT "DMName_CC" - REFERENCES "DM" ON DELETE CASCADE, - "DMShapePriority" integer, - "DMShapeName" text -); - -1u CREATE table "DMDENSITYPRIORITY"( - "DMName" text - CONSTRAINT "DMName_CC" - REFERENCES "DM" ON DELETE CASCADE, - "DMDensityPriority" integer, - "DMDensityName" text -); - - -# SQL FUNCTIONS - -1u CREATE FUNCTION gettypename(text, text) RETURNS - SETOF "CARTRIDGE" AS $$ - SELECT * FROM "CARTRIDGE" - WHERE "CartridgeID" = $1; - $$ LANGUAGE SQL; - -1u CREATE function getcarttype(text, text) returns - setof "CARTRIDGETYPE" as $$ - select * from "CARTRIDGETYPE" - where "CartridgeTypeName" in - (select "CartridgeTypeName" from gettypename($1, $2)); - $$language sql; - -1u CREATE function getdrivename(text, text) returns - setof "DMCAPABILITYGROUPTOKEN" as $$ - select * from "DMCAPABILITYGROUPTOKEN" - where "DMCapabilityToken" - in (select distinct "CartridgeShapeName" - from getcarttype($1, $2)); - $$language sql; - -1u CREATE function getdrivetable(text, text) returns - setof "DRIVE" as $$ - select * from "DRIVE" where - "LibraryName" in (select "LibraryName" - from gettypename($1, $2)); - $$language sql; - -# Below is backup func NOT USED NOW -1u CREATE function getdrivetable2(text, text) returns - setof "DRIVE" as $$ - select * from "DRIVE" where - "DriveName" in (select "DriveName" - from getdrivename($1, $2)) and - "LibraryName" in (select "LibraryName" - from gettypename($1, $2)); - $$language sql; - - -1u CREATE function getall(text, text, text) - returns setof "DM" as $$ - select * from "DM" - where pg_host_ident("DMTargetHost") = pg_host_ident($2) - and "DriveName" in(select "DriveName" from getdrivetable($1, $2) - where "DriveGroupName" in - (select "DriveGroupName" from "DRIVEGROUPAPPLICATION" - where "ApplicationName" = $3)); - $$language sql; - -1u CREATE FUNCTION gettype() RETURNS - SETOF "CARTRIDGE" AS $$ SELECT * FROM "CARTRIDGE"; - $$ LANGUAGE SQL; - -1u CREATE FUNCTION getcart() RETURNS - SETOF "CARTRIDGE" AS $$ - select * from "CARTRIDGE" where "CartridgeID" - IN (select "CartridgeID" from gettype()); - $$ LANGUAGE SQL; - -1u CREATE function mm_obj_has_att(text,text) returns - boolean as $$ select case when $2 = (select attname - from pg_attribute where (attrelid = (select oid - from pg_class where relname = $1)) and (attname = $2)) - then true else false end; $$ language sql; - -1u CREATE function drive_cart(text, text) - returns setof "DRIVE" as $$ - select "DRIVE".* from "DRIVE" - cross join "DMCAPABILITYTOKEN" - cross join "SLOTTYPE" - cross join "CARTRIDGETYPE" - cross join "CARTRIDGE" - where ( - ("DRIVE"."DriveName" = "DMCAPABILITYTOKEN"."DriveName") - and - ("SLOTTYPE"."CartridgeShapeName" = - "DMCAPABILITYTOKEN"."DMCapabilityToken") and - ("CARTRIDGETYPE"."CartridgeShapeName" = - "SLOTTYPE"."CartridgeShapeName") and - ("CARTRIDGE"."CartridgeTypeName" = - "CARTRIDGETYPE"."CartridgeTypeName") and - ("DRIVE"."DriveName" = $1) and - ("CARTRIDGE"."CartridgeID" = $2) ); $$ LANGUAGE SQL; - -1u CREATE function good_tok(text, text, text) - returns setof "DMCAPABILITYTOKEN" as $$ - select "DMCAPABILITYTOKEN".* from "DMCAPABILITYTOKEN" - cross join "DM" - where ( - ("DM"."DMName" = "DMCAPABILITYTOKEN"."DMName") and - ("DMCAPABILITYTOKEN"."DriveName" = $1) and - (pg_host_ident("DM"."DMTargetHost") = pg_host_ident($3)) and - ("DMCAPABILITYTOKEN"."DMCapabilityToken" = $2) ); - $$ LANGUAGE SQL; - -# -# MMS data model object reference validation. -# - -# Function and trigger for SLOTTYPE update or delete. Validate -# SLOTTYPE references by CARTRIDGETYPE, SLOT, and SLOTCONFIG. -1u CREATE FUNCTION mm_func_slottype() RETURNS TRIGGER AS ' - DECLARE - name TEXT; - shape TEXT; - BEGIN - IF TG_OP = ''UPDATE'' THEN - IF NEW."CartridgeShapeName" NOTNULL AND - NEW."CartridgeShapeName" != OLD."CartridgeShapeName" THEN - --check cartridgetype shape reference to slottype - SELECT INTO shape "CartridgeShapeName" FROM - "CARTRIDGETYPE" WHERE - "CARTRIDGETYPE"."CartridgeShapeName" = - NEW."CartridgeShapeName"; - IF FOUND THEN - RAISE EXCEPTION ''"CartridgeShapeName" - still referenced by "CARTRIDGETYPE" for update''; - END IF; - END IF; - IF NEW."SlotTypeName" NOTNULL AND - NEW."SlotTypeName" != OLD."SlotTypeName" THEN - --check slot type reference to slottype - SELECT INTO name "SlotTypeName" FROM "SLOT" - WHERE "SLOT"."SlotTypeName" = - NEW."SlotTypeName"; - IF FOUND THEN - RAISE EXCEPTION ''"SlotTypeName" - still referenced by "SLOT" for update''; - END IF; - END IF; - RETURN NEW; - ELSIF TG_OP = ''DELETE'' THEN - --check cartridgetype shape reference to slottype - SELECT INTO shape "CartridgeShapeName" FROM - "CARTRIDGETYPE" WHERE - "CARTRIDGETYPE"."CartridgeShapeName" = - OLD."CartridgeShapeName"; - IF FOUND THEN - RAISE EXCEPTION ''"CartridgeShapeName" - still referenced by CARTRIDGETYPE for delete''; - END IF; - --check slot type reference to slottype - SELECT INTO name "SlotTypeName" FROM "SLOT" - WHERE "SLOT"."SlotTypeName" = OLD."SlotTypeName"; - IF FOUND THEN - RAISE EXCEPTION ''"SlotTypeName" - still referenced by "SLOT" for delete''; - END IF; - RETURN OLD; - END IF; - END; - ' LANGUAGE 'plpgsql'; - -1u CREATE TRIGGER mm_trig_slottype BEFORE - UPDATE OR DELETE ON "SLOTTYPE" - FOR EACH ROW EXECUTE PROCEDURE mm_func_slottype(); - -# Function and trigger for CARTRIDGETYPE insert or update. Validate -# reference to SLOTTYPE. -1u CREATE FUNCTION mm_func_cartridgetype_shape() RETURNS TRIGGER AS ' - DECLARE - shape TEXT; - BEGIN - IF TG_OP = ''INSERT'' THEN - IF NEW."CartridgeShapeName" ISNULL THEN - RAISE EXCEPTION ''"CartridgeShapeName" is NULL''; - END IF; - SELECT INTO shape "CartridgeShapeName" FROM "SLOTTYPE" - WHERE "CartridgeShapeName" = NEW."CartridgeShapeName"; - IF NOT FOUND THEN - RAISE EXCEPTION ''"CartridgeShapeName" - does not exist in "SLOTTYPE" for insert''; - END IF; - RETURN NEW; - ELSIF TG_OP = ''UPDATE'' AND - NEW."CartridgeShapeName" NOTNULL THEN - SELECT INTO shape "CartridgeShapeName" FROM "SLOTTYPE" - WHERE "CartridgeShapeName" = NEW."CartridgeShapeName"; - IF NOT FOUND THEN - RAISE EXCEPTION ''"CartridgeShapeName" - does not exist in "SLOTTYPE" for update''; - END IF; - RETURN NEW; - END IF; - END; - ' LANGUAGE 'plpgsql'; - -1u CREATE TRIGGER mm_trig_slottype_shape BEFORE - INSERT OR UPDATE ON "CARTRIDGETYPE" - FOR ROW EXECUTE PROCEDURE mm_func_cartridgetype_shape(); - -# Function and trigger for SLOT and SLOTCONFIG. Validate -# reference to SLOTTYPE. -1u CREATE FUNCTION mm_func_slottypename() RETURNS TRIGGER AS ' - DECLARE - name TEXT; - BEGIN - IF TG_OP = ''INSERT'' THEN - IF NEW."SlotTypeName" ISNULL THEN - RAISE EXCEPTION ''"SlotTypeName" is NULL''; - END IF; - SELECT INTO name "SlotTypeName" FROM "SLOTTYPE" - WHERE "SlotTypeName" = NEW."SlotTypeName"; - IF NOT FOUND THEN - RAISE EXCEPTION ''"SlotTypeName" - does not exist in "SLOTTYPE" for insert''; - END IF; - RETURN NEW; - ELSIF TG_OP = ''UPDATE'' AND NEW."SlotTypeName" NOTNULL THEN - SELECT INTO name "SlotTypeName" FROM "SLOTTYPE" - WHERE "SlotTypeName" = NEW."SlotTypeName"; - IF NOT FOUND THEN - RAISE EXCEPTION ''"SlotTypeName" - does not exist in "SLOTTYPE" for update''; - END IF; - RETURN NEW; - END IF; - END; - ' LANGUAGE 'plpgsql'; - -1u CREATE TRIGGER mm_trig_slot BEFORE - INSERT OR UPDATE ON "SLOT" - FOR ROW EXECUTE PROCEDURE mm_func_slottypename(); - -1u CREATE TRIGGER mm_trig_slotconfig BEFORE - INSERT OR UPDATE ON "SLOTCONFIG" - FOR ROW EXECUTE PROCEDURE mm_func_slottypename(); - -# Function and trigger for CARTRIDGE CartridgePCL validation. -1u CREATE FUNCTION mm_func_cartridgepcl() RETURNS TRIGGER AS ' - DECLARE - pcl TEXT; - BEGIN - IF TG_OP = ''UPDATE'' THEN - IF NEW."CartridgePCL" NOTNULL AND - NEW."CartridgePCL" != OLD."CartridgePCL" THEN - SELECT INTO pcl "CartridgePCL" FROM "DRIVE" - WHERE "CartridgePCL" = NEW."CartridgePCL"; - IF FOUND THEN - RAISE EXCEPTION ''"CartridgePCL" - still referenced by "DRIVE" for update''; - END IF; - SELECT INTO pcl "CartridgePCL" FROM "SLOT" - WHERE "CartridgePCL" = NEW."CartridgePCL"; - IF FOUND THEN - RAISE EXCEPTION ''"CartridgePCL" - still referenced by "SLOT" for update''; - END IF; - SELECT INTO pcl "CartridgePCL" FROM "MOUNTPHYSICAL" - WHERE "CartridgePCL" = NEW."CartridgePCL"; - IF FOUND THEN - RAISE EXCEPTION ''"CartridgePCL" - still referenced by "MOUNTPHYSICAL" for update''; - END IF; - END IF; - RETURN NEW; - ELSIF TG_OP = ''DELETE'' THEN - SELECT INTO pcl "CartridgePCL" FROM "DRIVE" - WHERE "CartridgePCL" = OLD."CartridgePCL"; - IF FOUND THEN - RAISE EXCEPTION ''"CartridgePCL" - still referenced by "DRIVE" for delete''; - END IF; - SELECT INTO pcl "CartridgePCL" FROM "SLOT" - WHERE "CartridgePCL" = OLD."CartridgePCL"; - IF FOUND THEN - RAISE EXCEPTION ''"CartridgePCL" - still referenced by "SLOT" for delete''; - END IF; - SELECT INTO pcl "CartridgePCL" FROM "MOUNTPHYSICAL" - WHERE "CartridgePCL" = OLD."CartridgePCL"; - IF FOUND THEN - RAISE EXCEPTION ''"CartridgePCL" - still referenced by "MOUNTPHYSICAL" for delete''; - END IF; - RETURN OLD; - END IF; - END; - ' LANGUAGE 'plpgsql'; - -1u CREATE TRIGGER mm_trig_cartridgepcl BEFORE - UPDATE OR DELETE ON "CARTRIDGE" - FOR ROW EXECUTE PROCEDURE mm_func_cartridgepcl(); - -# Function and trigger for SLOT and SLOTCONFIG. Validate -# reference to SLOTTYPE. -1u CREATE FUNCTION mm_func_pcl() RETURNS TRIGGER AS ' - DECLARE - pcl TEXT; - BEGIN - IF TG_OP = ''INSERT'' THEN - IF NEW."CartridgePCL" ISNULL THEN - IF TG_RELNAME = ''DRIVE'' THEN - RETURN NEW; - END IF; - RAISE EXCEPTION ''"CartridgePCL" is NULL''; - END IF; - SELECT INTO pcl "CartridgePCL" FROM "CARTRIDGE" - WHERE "CartridgePCL" = NEW."CartridgePCL"; - IF NOT FOUND THEN - RAISE EXCEPTION ''"CartridgePCL" - does not exist in "CARTRIDGE" for insert''; - END IF; - RETURN NEW; - ELSIF TG_OP = ''UPDATE'' THEN - IF NEW."CartridgePCL" NOTNULL THEN - SELECT INTO pcl "CartridgePCL" FROM "CARTRIDGE" - WHERE "CartridgePCL" = NEW."CartridgePCL"; - IF NOT FOUND THEN - IF TG_RELNAME = ''DRIVE'' THEN - IF NEW."CartridgePCL" = ''non-MMS'' THEN - RETURN NEW; - END IF; - END IF; - RAISE EXCEPTION ''"CartridgePCL" - does not exist in "CARTRIDGE" for update''; - END IF; - END IF; - RETURN NEW; - END IF; - END; - ' LANGUAGE 'plpgsql'; - -1u CREATE TRIGGER mm_trig_drive_pcl BEFORE - INSERT OR UPDATE ON "DRIVE" - FOR ROW EXECUTE PROCEDURE mm_func_pcl(); - -1u CREATE TRIGGER mm_trig_slot_pcl BEFORE - INSERT OR UPDATE ON "SLOT" - FOR ROW EXECUTE PROCEDURE mm_func_pcl(); - -1u CREATE TRIGGER mm_trig_mountphysical_pcl BEFORE - INSERT OR UPDATE ON "MOUNTPHYSICAL" - FOR ROW EXECUTE PROCEDURE mm_func_pcl(); - -# Verify drive bayname reference -1u CREATE FUNCTION mm_func_drive_bayname() RETURNS TRIGGER AS ' - DECLARE - bayname TEXT; - BEGIN - IF TG_OP = ''INSERT'' OR TG_OP = ''UPDATE'' THEN - IF NEW."BayName" NOTNULL THEN - SELECT INTO bayname "BayName" - FROM "BAY" - WHERE NEW."BayName" = "BayName" - AND NEW."LibraryName" = "LibraryName"; - IF NOT FOUND THEN - RAISE EXCEPTION ''"DRIVE"."BayName" - does not exist in "BAY" for insert/update''; - END IF; - END IF; - RETURN NEW; - END IF; - END; - ' LANGUAGE 'plpgsql'; - -1u CREATE TRIGGER mm_trig_drive_bayname BEFORE - INSERT OR UPDATE ON "DRIVE" - FOR ROW EXECUTE PROCEDURE mm_func_drive_bayname(); - -# LMP full config mountphysical slotname reference to slot -1u CREATE FUNCTION mm_func_mountphysical() RETURNS TRIGGER AS ' - DECLARE - slotname TEXT; - sessionid TEXT; - BEGIN - IF TG_OP = ''INSERT'' OR TG_OP = ''UPDATE'' THEN - IF NEW."SessionID" NOTNULL THEN - SELECT INTO sessionid "SessionID" - FROM "SESSION" - WHERE NEW."SessionID" = "SessionID"; - IF NOT FOUND THEN - RAISE EXCEPTION ''"MOUNTPHYSICAL"."SessionID" - does not exist in "SESSION" for insert/update''; - END IF; - END IF; - RETURN NEW; - IF NEW."SlotName" NOTNULL THEN - SELECT INTO slotname "SlotName" - FROM "SLOT" - WHERE NEW."SlotName" = "SlotName" - AND NEW."LibraryName" = "LibraryName"; - IF NOT FOUND THEN - RAISE EXCEPTION ''"MOUNTPHYSICAL"."SlotName" - does not exist in "SLOT" for insert/update''; - END IF; - END IF; - RETURN NEW; - END IF; - END; - ' LANGUAGE 'plpgsql'; - -1u CREATE TRIGGER mm_trig_mountphysical BEFORE - INSERT OR UPDATE ON "MOUNTPHYSICAL" - FOR ROW EXECUTE PROCEDURE mm_func_mountphysical(); - -# Request data validation. -1u CREATE FUNCTION mm_func_request() RETURNS TRIGGER AS ' - DECLARE - task TEXT; - session TEXT; - BEGIN - IF TG_OP = ''INSERT'' THEN - -- allow mm, dm, or lm request without task.taskid - IF NEW."RequestingTaskID" ISNULL THEN - RETURN NEW; - END IF; - -- validate request task.taskid before insert - SELECT INTO task "TaskID" - FROM "TASK" WHERE - NEW."RequestingTaskID" = "TaskID"; - IF NOT FOUND THEN - RAISE EXCEPTION ''"REQUEST". - "RequestingTaskID" is not a - "TASK"."TaskID"''; - END IF; - RETURN NEW; - ELSIF TG_OP = ''UPDATE'' THEN - -- validate accepting session is connected - IF NEW."AcceptingSessionID" NOTNULL THEN - SELECT INTO session "SessionID" - FROM "SESSION" WHERE - NEW."AcceptingSessionID" = - "SessionID"; - IF NOT FOUND THEN - RAISE EXCEPTION ''"REQUEST". - "AcceptingSessionID" is not a - "SESSION"."SessionID"''; - END IF; - END IF; - RETURN NEW; - END IF; - END; - ' LANGUAGE 'plpgsql'; - -1u CREATE TRIGGER mm_trig_request BEFORE - INSERT OR UPDATE ON "REQUEST" - FOR ROW EXECUTE PROCEDURE mm_func_request(); - -1u CREATE FUNCTION mm_func_volume() RETURNS TRIGGER AS ' - DECLARE - ainame TEXT; - BEGIN - IF TG_OP = ''INSERT'' OR TG_OP = ''UPDATE'' THEN - IF NEW."AIName" NOTNULL THEN - SELECT INTO ainame "AIName" FROM "AI" - WHERE "AI"."ApplicationName" = - NEW."ApplicationName" AND - "AI"."AIName" = NEW."AIName"; - IF NOT FOUND THEN - IF NEW."AIName" = ''any'' THEN - RETURN NEW; - END IF; - RAISE EXCEPTION ''"AIName" - does not exist in "AI" for update''; - END IF; - END IF; - END IF; - RETURN NEW; - END; - ' LANGUAGE 'plpgsql'; - -1u CREATE TRIGGER mm_trig_volume BEFORE - INSERT OR UPDATE ON "VOLUME" - FOR ROW EXECUTE PROCEDURE mm_func_volume(); - -1u CREATE FUNCTION mm_func_dup_pcls() RETURNS TRIGGER AS ' - DECLARE - pcl TEXT; - BEGIN - IF TG_OP = ''INSERT'' THEN - IF NEW."CartridgePCL" NOTNULL AND - NEW."LibraryName" NOTNULL THEN - SELECT INTO pcl "CartridgePCL" FROM "CARTRIDGE" - WHERE "CARTRIDGE"."CartridgePCL" = - NEW."CartridgePCL" AND - "CARTRIDGE"."LibraryName" = NEW."LibraryName"; - IF FOUND THEN - RAISE EXCEPTION ''"CartridgePCL" already exists - in library''; - END IF; - END IF; - ELSIF TG_OP = ''UPDATE'' THEN - IF NEW."CartridgePCL" NOTNULL AND - NEW."LibraryName" NOTNULL THEN - SELECT INTO pcl "CartridgePCL" FROM "CARTRIDGE" - WHERE "CARTRIDGE"."CartridgePCL" = - NEW."CartridgePCL" AND - "CARTRIDGE"."LibraryName" = NEW."LibraryName" - AND OLD."CartridgePCL" != NEW."CartridgePCL"; - IF FOUND THEN - RAISE EXCEPTION ''"CartridgePCL" already exists - in library''; - END IF; - END IF; - END IF; - RETURN NEW; - END; - ' LANGUAGE 'plpgsql'; - -1u CREATE TRIGGER mm_trig_dup_pcls BEFORE - INSERT OR UPDATE ON "CARTRIDGE" - FOR ROW EXECUTE PROCEDURE mm_func_dup_pcls(); - - -# Triggers and Functions for Status Event table -1u CREATE function mm_func_insert_event() returns trigger as ' - begin - if TG_OP = ''UPDATE'' then - if TG_RELNAME = ''DRIVE'' then - insert into "EVENT" ("ObjectName", - "Info1") values(''DRIVE'', - NEW."DriveName"); - end if; - if TG_RELNAME = ''DM'' then - insert into "EVENT" ("ObjectName", - "Info1") values(''DM'', - NEW."DMName"); - end if; - if TG_RELNAME = ''LIBRARY'' then - insert into "EVENT" ("ObjectName", - "Info1") values(''LIBRARY'', - NEW."LibraryName"); - end if; - if TG_RELNAME = ''LM'' then - insert into "EVENT" ("ObjectName", - "Info1") values(''LM'', - NEW."LMName"); - end if; - end if; - if TG_RELNAME = ''REQUEST'' then - if TG_OP = ''DELETE'' then - insert into "EVENT" ("ObjectName", - "Info1","Info2","Info3") values(''REQUEST'', - OLD."RequestID", - OLD."RequestingClientType", - OLD."RequestingInstance"); - return OLD; - else - insert into "EVENT" ("ObjectName", - "Info1","Info2","Info3") values(''REQUEST'', - NEW."RequestID", - NEW."RequestingClientType", - NEW."RequestingInstance"); - end if; - end if; - if TG_RELNAME = ''MESSAGE'' then - insert into "EVENT" ("ObjectName", - "Info1","Info2","Info3") values(''MESSAGE'', - NEW."MessageID", - NEW."MessageSenderType", - NEW."MessageSenderInstance"); - end if; - if TG_RELNAME = ''CARTRIDGE'' then - if TG_OP = ''DELETE'' then - insert into "EVENT" ("ObjectName", - "Info1","Info2") values(''CARTRIDGE'', - OLD."CartridgeID", - ''delete''); - return OLD; - elsif TG_OP = ''UPDATE'' then - if OLD."CartridgeID" != NEW."CartridgeID" then - insert into "EVENT" ("ObjectName", - "Info1","Info2") values(''CARTRIDGE'', - OLD."CartridgeID", - ''delete''); - insert into "EVENT" ("ObjectName", - "Info1","Info2") values(''CARTRIDGE'', - NEW."CartridgeID", - ''new''); - else - insert into "EVENT" ("ObjectName", - "Info1","Info2") values(''CARTRIDGE'', - NEW."CartridgeID", - ''change''); - end if; - elsif TG_OP = ''INSERT'' then - insert into "EVENT" ("ObjectName", - "Info1","Info2") values(''CARTRIDGE'', - NEW."CartridgeID", - ''new''); - end if; - end if; - if TG_RELNAME = ''VOLUME'' then - if TG_OP = ''DELETE'' then - insert into "EVENT" ("ObjectName", - "Info1","Info2","Info3") values(''VOLUME'', - OLD."VolumeName", - OLD."ApplicationName", - ''delete''); - return OLD; - elsif TG_OP = ''UPDATE'' then - if OLD."VolumeName" != NEW."VolumeName" AND - OLD."ApplicationName" != NEW."ApplicationName" - then - insert into "EVENT" ("ObjectName", - "Info1","Info2","Info3") - values(''VOLUME'', - OLD."VolumeName", - OLD."ApplicationName", - ''delete''); - insert into "EVENT" ("ObjectName", - "Info1","Info2","Info3") - values(''VOLUME'', - OLD."VolumeName", - OLD."ApplicationName", - ''new''); - else - insert into "EVENT" ("ObjectName", - "Info1","Info2","Info3") - values(''VOLUME'', - NEW."VolumeName", - NEW."ApplicationName", - ''change''); - end if; - elsif TG_OP = ''INSERT'' then - insert into "EVENT" ("ObjectName", - "Info1","Info2","Info3") values(''VOLUME'', - NEW."VolumeName", - NEW."ApplicationName", - ''new''); - end if; - end if; - return NEW; - end; - ' LANGUAGE 'plpgsql'; - -1u CREATE trigger mm_trig_insert_dm_event - before insert or update on "DM" - for row execute procedure mm_func_insert_event(); - -1u CREATE trigger mm_trig_insert_lm_event - before insert or update on "LM" - for row execute procedure mm_func_insert_event(); - -1u CREATE trigger mm_trig_insert_drive_event - before insert or update on "DRIVE" - for row execute procedure mm_func_insert_event(); - -1u CREATE trigger mm_trig_insert_library_event - before insert or update on "LIBRARY" - for row execute procedure mm_func_insert_event(); - -1u CREATE trigger mm_trig_insert_request_event - before insert or update or delete on "REQUEST" - for row execute procedure mm_func_insert_event(); - -1u CREATE trigger mm_trig_insert_message_event - before insert or update on "MESSAGE" - for row execute procedure mm_func_insert_event(); - -1u CREATE trigger mm_trig_cartridge_event - before insert or update or delete on "CARTRIDGE" - for row execute procedure mm_func_insert_event(); - -1u CREATE trigger mm_trig_volume_event - before insert or update or delete on "VOLUME" - for row execute procedure mm_func_insert_event(); - -# Create LIBRARY/DRIVE/CARTRIDGE LISTS - -1u CREATE table "LIBRARYLIST"( - "LibraryString" text NOT NULL, - CONSTRAINT "LIBRARYLIST_PK" PRIMARY KEY("LibraryString") -); -1u CREATE table "DRIVELIST"( - "DriveString" text NOT NULL, - CONSTRAINT "DRIVELIST_PK" PRIMARY KEY("DriveString") -); -1u CREATE table "CARTRIDGELIST"( - "CartridgeString" text NOT NULL, - CONSTRAINT "CARTRIDGELIST_PK" PRIMARY KEY("CartridgeString") -); - -# Create Password Handlers -1u CREATE TABLE "MMPASSWORD" ( - "ApplicationName" text, - "Password" text default 'changeme' NOT NULL, - CONSTRAINT "MMPASSWORD_PK" PRIMARY KEY("ApplicationName") -); - -1u CREATE FUNCTION mm_func_getpassword(text) RETURNS text AS ' - DECLARE - newpass TEXT; - BEGIN - SELECT INTO newpass (select md5($1)); - RETURN newpass; - END; - ' LANGUAGE 'plpgsql'; - -1u CREATE FUNCTION mm_func_setpassword() RETURNS TRIGGER AS ' - DECLARE - newpass TEXT; - BEGIN - IF TG_OP = ''INSERT'' OR TG_OP = ''UPDATE'' THEN - IF NEW."Password" NOTNULL THEN - IF length(NEW."Password") < 8 THEN - RAISE EXCEPTION - ''"Password" length is less than 8 characters.''; - END IF; - SELECT INTO newpass - (select mm_func_getpassword(NEW."Password")); - -- let user reuse the same password - -- IF TG_OP = ''UPDATE'' THEN - -- internal mms app can reuse the same password - -- IF OLD."ApplicationName" NOTNULL AND - -- OLD."ApplicationName" != ''MMS'' AND - -- newpass = OLD."Password" THEN - -- RAISE EXCEPTION - -- ''"Password" not changed, new and old passwords are the same.''; - -- END IF; - -- END IF; - SELECT INTO NEW."Password" newpass; - END IF; - END IF; - RETURN NEW; - END; - ' LANGUAGE 'plpgsql'; - -1u CREATE TRIGGER mm_trig_setpassword BEFORE - INSERT OR UPDATE ON "MMPASSWORD" - FOR ROW EXECUTE PROCEDURE mm_func_setpassword(); - -1u CREATE FUNCTION mm_func_defpassword() RETURNS TRIGGER AS ' - BEGIN - IF TG_OP = ''INSERT'' THEN - INSERT INTO "MMPASSWORD" ("ApplicationName","Password") - VALUES (NEW."ApplicationName",default); - ELSIF TG_OP = ''UPDATE'' THEN - IF NEW."ApplicationName" != OLD."ApplicationName" THEN - UPDATE "MMPASSWORD" SET - "ApplicationName" = NEW."ApplicationName" WHERE - "ApplicationName" = OLD."ApplicationName"; - END IF; - ELSIF TG_OP = ''DELETE'' THEN - DELETE FROM "MMPASSWORD" WHERE - "ApplicationName" = OLD."ApplicationName"; - RETURN OLD; - END IF; - RETURN NEW; - END; - ' LANGUAGE 'plpgsql'; - -1u CREATE TRIGGER mm_trig_defpassword BEFORE - INSERT OR UPDATE OR DELETE ON "APPLICATION" - FOR ROW EXECUTE PROCEDURE mm_func_defpassword(); - -# Disk archiving host library path configuration -1u CREATE FUNCTION mm_func_librarypath() RETURNS TRIGGER AS ' - BEGIN - -- Validate default disk library path is not null. - IF TG_OP = ''INSERT'' OR TG_OP = ''UPDATE'' THEN - IF NEW."LibraryType" = ''DISK'' THEN - IF NEW."DefaultLibraryPath" ISNULL THEN - RAISE EXCEPTION ''"LIBRARY"."DefaultLibraryPath" must not be null for "LIBRARY"."LibraryType" "DISK"''; - END IF; - -- Validate default disk library path ends in library name - IF ((select length(NEW."DefaultLibraryPath") - - length(NEW."LibraryName") = position(NEW."LibraryName" in - NEW."DefaultLibraryPath") - 1)) != ''t'' THEN - RAISE EXCEPTION ''"LIBRARY"."DefaultLibraryPath" must end in "LIBRARY"."LibraryName"''; - END IF; - END IF; - RETURN NEW; - END IF; - END; - ' LANGUAGE 'plpgsql'; - -1u CREATE TRIGGER mm_func_librarypath BEFORE - INSERT OR UPDATE ON "LIBRARY" - FOR ROW EXECUTE PROCEDURE mm_func_librarypath(); - -1u CREATE FUNCTION mm_func_libraryaccess() RETURNS TRIGGER AS ' - BEGIN - -- Validate alternate disk library access path ends in library name - IF TG_OP = ''INSERT'' OR TG_OP = ''UPDATE'' THEN - IF ((select length(NEW."LibraryPath") - - length(NEW."LibraryName") = position(NEW."LibraryName" in - NEW."LibraryPath") - 1)) != ''t'' THEN - RAISE EXCEPTION ''"LIBRARYACCESS"."LibraryPath" must end in -"LIBRARYACCESS"."LibraryName"''; - END IF; - RETURN NEW; - END IF; - END; - ' LANGUAGE 'plpgsql'; - -1u CREATE TRIGGER mm_func_libraryaccess BEFORE - INSERT OR UPDATE ON "LIBRARYACCESS" - FOR ROW EXECUTE PROCEDURE mm_func_libraryaccess(); - - -# Initialize Database -1u INSERT INTO "APPLICATION" ("ApplicationName") VALUES ('MMS'); - -1u INSERT INTO "AI" ("AIName", "ApplicationName", "PrivilegeChangeable", - "DefaultPriority", "SessionsAllowed") - VALUES ('admin', 'MMS', 'true', '0', 'multiple'); - -1u INSERT INTO "AI" ("AIName", "ApplicationName", "PrivilegeChangeable", - "DefaultPriority", "SessionsAllowed") - VALUES ('oper', 'MMS', 'true', '0', 'multiple'); - -1u INSERT INTO "AI" ("AIName", "ApplicationName", "PrivilegeChangeable", - "DefaultPriority", "SessionsAllowed") - VALUES('watcher', 'MMS', 'true', '0', 'multiple'); - -1u INSERT INTO "SYSTEM" ("Administrator") VALUES ('admin'); - -1u CREATE FUNCTION mm_system_defined_init() RETURNS boolean AS ' - DECLARE - -- MMS objects with user or system defined attributes - table text[] = ''{ "APPLICATION", "AI", "SESSION", "LIBRARY", - "LM", "SLOTTYPE", "CARTRIDGEGROUP", "CARTRIDGETYPE", - "CARTRIDGE", "SIDE", "PARTITION", "VOLUME", - "DRIVEGROUP", "DRIVE", "DM", "DMCAPABILITY", - "DRIVECARTRIDGEACCESS", "SYSTEM", "LIBRARYACCESS", - "DRIVECARTRIDGEERROR", NULL }''; - i integer = 1; - BEGIN - -- Save MMS system defined object attributes - WHILE table[i] IS NOT NULL LOOP - INSERT INTO "SYSTEM_DEFINED" (objname,attribute) - SELECT table[i],attname FROM pg_attribute - WHERE (attrelid = (select oid - FROM pg_class WHERE - relname = table[i])) AND attname ~ ''^[A-Z]''; - i := i + 1; - END LOOP; - RETURN true; - END; - ' LANGUAGE 'plpgsql'; - -1u SELECT mm_system_defined_init(); - -1u DROP FUNCTION mm_system_defined_init(); - -# Add or delete upgrade/downgrade system defined table columns. -1u CREATE FUNCTION mm_system_defined_add(text,text) RETURNS boolean AS ' - BEGIN - INSERT INTO "SYSTEM_DEFINED" (objname, attribute) - VALUES ($1, $2); - RETURN true; - END - ' LANGUAGE 'plpgsql'; - -1u CREATE FUNCTION mm_system_defined_del(text,text) RETURNS boolean AS ' - BEGIN - DELETE FROM "SYSTEM_DEFINED" WHERE objname = $1 AND - attribute = $2; - RETURN true; - END - ' LANGUAGE 'plpgsql'; - -26u INSERT INTO "MM" ("DBInitialized", "DBVersion") VALUES ('true', '1'); - - -###################################################################### -# # -# Add your upgrade/downgrade version immediately after this comment # -# # -# Start upgrades at version 27 because 1-26 have already been used. # -# # -###################################################################### - -###################################################################### -# # -# Add your upgrade/downgrade version immediately before this comment # -# # -###################################################################### diff --git a/usr/src/cmd/mms/mm/common/mms_openssl.cnf b/usr/src/cmd/mms/mm/common/mms_openssl.cnf deleted file mode 100644 index 4fbfb2fedb..0000000000 --- a/usr/src/cmd/mms/mm/common/mms_openssl.cnf +++ /dev/null @@ -1,103 +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. -# - - -# -# MMS CA configuration file. -# - -ssldir=/var/mms/ssl -cadir=$ssldir/ca -pubdir=$ssldir/pub -expdays=3650 - -[ ca ] -default_ca = mms_ca - -[ mms_ca ] -certificate = $cadir/mms_ca_cert.pem -database = $cadir/index.txt -new_certs_dir = $cadir/certs -private_key = $cadir/mms_ca_key.pem -serial = $cadir/serial -crl = $pubdir/mms_crl.pem - -default_crl_days = $expdays -default_days = $expdays -default_md = sha1 - -policy = mms_ca_policy -x509_extensions = certificate_extensions - -nameopt = default_ca -certopt = default_ca - -unique_subject = no - -prompt = no -distinguished_name = client_distinguished_name - -[ mms_ca_policy ] -commonName = optional -stateOrProvinceName = optional -countryName = optional -emailAddress = optional -organizationName = optional -organizationalUnitName = optional -localityName = optional - -[ certificate_extensions ] -basicConstraints = CA:false - -[ client_distinguished_name ] -commonName = MMS Client -stateOrProvinceName = . -countryName = US -emailAddress = . -organizationName = SMI -organizationalUnitName = SDASH -localityName = . - -[ req ] -default_bits = 2048 -default_keyfile = $cadir/mms_ca_key.pem -default_md = sha1 - -prompt = no -distinguished_name = mms_ca_distinguished_name - -x509_extensions = mms_ca_extensions - -[ mms_ca_distinguished_name ] -commonName = MMS CA -stateOrProvinceName = . -countryName = US -emailAddress = . -organizationName = SMI -organizationalUnitName = SDASH -localityName = . - -[ mms_ca_extensions ] -basicConstraints = CA:true diff --git a/usr/src/cmd/mms/mm/common/mmsssl.sh b/usr/src/cmd/mms/mm/common/mmsssl.sh deleted file mode 100644 index 0772a8699b..0000000000 --- a/usr/src/cmd/mms/mm/common/mmsssl.sh +++ /dev/null @@ -1,535 +0,0 @@ -#!/bin/sh -# -# 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. -# -# -# -# MMS SSL Self-Signed Certificate Authority -# - -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/sadm/bin:$PATH -LD_LIBRARY_PATH=/lib:/usr/lib:$LD_LIBRARY_PATH - -umask 066 -PROG=`basename $0` - - -# Now setup directories -SSLDIR="/var/mms/ssl" -CADIR="$SSLDIR/ca" -PUBDIR="$SSLDIR/pub" -ROOT_CNF="$CADIR/mms_openssl.cnf" -CERTSDIR="$CADIR/certs" -DIR= - -# DSA Parameters Prime Number Bit Length -PRIME_BITS=2048 - -# User -USER="" -MMS_USER="mms" - -# Root files (CA) -SERIAL="$CADIR/serial" -INDEX="$CADIR/index.txt" -CRL="$PUBDIR/$MMS_USER""_crl.pem" -ROOT_CERT="$CADIR/$MMS_USER""_ca_cert.pem" -ROOT_KEY="$CADIR/$MMS_USER""_ca_key.pem" -PASSWD_FILE="$CADIR/$MMS_USER""_ca_pass" -ROOT_PEM="$CADIR/$MMS_USER""_ca.pem" -ROOT_CERT_PUB="$PUBDIR/$MMS_USER""_ca_cert.pem" -MMS_PEM="$PUBDIR/$MMS_USER.pem" -MMS_CERT="$PUBDIR/$MMS_USER""_cert.pem" -MMS_DH1024="$PUBDIR/$MMS_USER""_dh1024.pem" - -root_user() -{ - user=`/bin/id | grep root | wc -l` - if [ $user -eq 0 ]; then - echo "Error, you must be root to run this script." - exit 1 - fi -} - -gen_password() -{ - pass_file="$1" - - echo - echo "Generate private key password phrase" - - /bin/dd if=/dev/random bs=1 count=15 2>/dev/null | \ - openssl base64 > "$pass_file" - if [ ! -f "$pass_file" ]; then - exit 1 - fi -} - -# setup mms as ca (certificate authority) -initialize() -{ - echo - echo "Initialize certificate authority" - - # certificate serial number - echo "01" > "$SERIAL" - if [ ! -f "$SERIAL" ]; then - exit 1 - fi - - # certificate database - touch "$INDEX" - if [ ! -f "$INDEX" ]; then - exit 1 - fi - - # new certs dir - mkdir $CERTSDIR - if [ $? -ne 0 ]; then - exit 1 - fi - - chmod 0700 $CERTSDIR - if [ $? -ne 0 ]; then - exit 1 - fi - - # ca random password phrase - gen_password "$PASSWD_FILE" -} - -# generate crl (certificate revocation list) file -update_crl() -{ - echo - echo "Update CRL" - - cmd="openssl ca -gencrl -out $CRL -config $ROOT_CNF" - cmd="$cmd -passin file:$PASSWD_FILE" - echo $cmd - $cmd - if [ $? -ne 0 ]; then - exit 1 - fi - - # publish the list, let everyone read the file - chmod 0640 $CRL - if [ $? -ne 0 ]; then - exit 1 - fi - - # tell mm to reload updated crl - svcadm refresh mms:mm > /dev/null 2>&1 -} - -# compute public shared prime number p and generator g -dh_pem() -{ - echo - echo "Generate Diffie-Hellman parameters" - - cmd="openssl dhparam -check -5 1024 -out $MMS_DH1024 -outform PEM" - echo $cmd - $cmd - if [ $? -ne 0 ]; then - exit 1 - fi - - chmod 0600 $MMS_DH1024 - if [ $? -ne 0 ]; then - exit 1 - fi -} - -# rsa private key -rsa_key() -{ - rsa_key_file="$1" - - echo - echo "Create RSA certificate with SHA-1 signature" - - cmd="openssl genrsa -out $rsa_key_file -des3" - cmd="$cmd -passout file:$PASSWD_FILE" - echo $cmd - $cmd - if [ $? -ne 0 ]; then - exit 1 - fi -} - -# generate self signed root certificate and private key -rsa_cert() -{ - echo - echo "Generate self-signed certificate authority" - - unset -v OPENSSL_CONF - # gen self signed ca certificate - cmd="openssl req -x509 -newkey rsa:$PRIME_BITS -out $ROOT_CERT" - cmd="$cmd -keyout $ROOT_KEY -sha1 -outform PEM" - cmd="$cmd -passout file:$PASSWD_FILE" - echo $cmd - $cmd - if [ $? -ne 0 ]; then - exit 1 - fi - - chmod 0600 "$ROOT_CERT" - if [ $? -ne 0 ]; then - exit 1 - fi - - # mms_ca.pem - cat $ROOT_CERT $ROOT_KEY > $ROOT_PEM - if [ ! -f $ROOT_PEM ]; then - exit 1 - fi - - # put ca certificate in public directory - cp $ROOT_CERT $ROOT_CERT_PUB - if [ $? -ne 0 ]; then - exit 1 - fi - - # let everyone read public ca certificate - chmod 0440 $ROOT_CERT_PUB - if [ $? -ne 0 ]; then - exit 1 - fi - - # view certificate info - openssl x509 -subject -issuer -noout -in $ROOT_CERT - - # initialize cert revocation list - update_crl -} - -certificate_request() -{ - dir=$1 - mess=$2 - - echo - echo "Generate certificate request ($USER,$dir)" - - mkdir -p "$dir" - if [ $? -ne 0 ]; then - exit 1 - fi - - # user password phrase - pass_file="$dir/$USER""_pass" - gen_password "$pass_file" - - # filenames - req="$dir/$USER""_req.pem" - - key="$dir/$USER""_key.pem" - - # use default openssl configuration for certificate request - unset -v OPENSSL_CONF - - # generate certificate request - cmd="openssl req -newkey rsa:$PRIME_BITS -keyout $key -keyform PEM" - cmd="$cmd -out $req -outform PEM -sha1 -passout file:$pass_file" - echo $cmd - $cmd - if [ $? -ne 0 ]; then - exit 1 - fi - if [ $mess -eq 1 ]; then - echo - echo - echo - echo "Certificate request: $req" - echo "Private key: $key" - echo "Private key password: $pass_file" - echo - echo "Email certificate request file to MMS CA for signing." - echo - fi -} - -ca_sign() -{ - echo - echo "Sign certificate request" - - # filenames - req="$PUBDIR/$USER""_req.pem" - - cert="$PUBDIR/$USER""_cert.pem" - - key="$PUBDIR/$USER""_key.pem" - - root_cert=`basename $ROOT_CERT` - - # root signs client certificate request - cmd="openssl ca -in $req -out $cert -notext -cert $ROOT_CERT" - cmd="$cmd -config $ROOT_CNF -md sha1 -passin file:$PASSWD_FILE" - echo $cmd - $cmd - if [ $? -ne 0 ]; then - exit 1 - fi - - if [ -f $key ]; then - # combine certificate, private key and public root certificate - pem="$PUBDIR/$USER.pem" - cat $cert $key $ROOT_CERT_PUB > $pem - if [ $? -ne 0 ]; then - rm -f $pem - echo "Error, create $pem" - else - echo - echo "The combined certificate, private key and CA certificate file\n$pem" - echo - fi - else - user_cert=`basename $cert` - user_key=`basename $key` - # remote user without access to ssl public directory - echo - echo "Use the distinguished name email address to deliver" - echo "the following files to the user:" - echo "\t$cert" - echo "\t$ROOT_CERT_PUB" - echo - echo "Instruct the user to do the following:" - echo "\tcat $user_cert $user_key $root_cert > $USER.pem" - echo - fi -} - -# revoke client's certificate -revoke_certificate() -{ - echo "Revoke certificate" - - # filename - cert="$PUBDIR/$USER""_cert.pem" - - # revoke certificate - cmd="openssl ca -revoke $cert -config $ROOT_CNF" - cmd="$cmd -passin file:$PASSWD_FILE" - echo $cmd - $cmd - if [ $? -ne 0 ]; then - exit 1 - fi - - # add revoked cert to the list - update_crl -} - -check_client() -{ - if [ -z "$USER" ]; then - echo "Error, missing user name." - exit 1 - fi -} - -usage() -{ - echo "usage: mmsssl.sh [ ca | req | crl ] [-v] [-n]" - echo - echo "mmsssl.sh ca -c configure mms ca" - echo "mmsssl.sh ca -s -u user_name sign certificate request" - echo "mmsssl.sh ca -r -u user_name revoke certificate" - echo "mmsssl.sh req -u user_name [-d path] certificate request" - echo "mmsssl.sh crl revoked certificate list" - echo - echo "Examples:" - echo "1. Create the MMS CA and MM RSA certificates:" - echo "\t% mmsssl.sh ca -c" - echo "\tRun the command only once on the host where the MM will execute." - echo "\tDiffie-Hellman (DH) parameters are generated." - echo "\tYou will enter a DN (Distinguished Name) once for the CA and" - echo "\tonce for the MM certificate. You will sign the MM certificate" - echo "\tand commit the request." - echo - echo "2. MMS user certificate request:" - echo "\t% mmsssl.sh req -u JohnQPublic" - echo "\tEmail the JohnQPublic_req.pem to the MMS CA for signing." - echo - echo "3. MMS CA signs user certificate request:" - echo "\t% cp JohnQPublic_req.pem \\" - echo "\t$PUBDIR/JohnQPublic_req.pem" - echo "\tCopy certificate request into the MMS CA for signing." - echo "\t% mmsssl.sh ca -s -u JohnQPublic" - echo "\tYou will sign the MM certificate and commit the request." - echo "\tEmail the JohnQPublic_cert.pem and mms_ca_cert.pem "\ - "files to the user." - echo - echo "4. MMS user creates single PEM file for MMS:" - echo "\t% cat JohnQPublic_cert.pem JohnQPublic_key.pem \\" - echo "\tmms_ca_cert.pem > JohnQPublic.pem" - echo - echo "5. MMS CA revokes user certificate:" - echo "\t% mmsssl.sh ca -r -u JohnQPublic" - echo "\tThe revoked certificate is added to the file" - echo "\t$PUBDIR/mms_crl.pem" - echo - echo "6. MMS CA reviews CRL (Certificate Revocation List):" - echo "\t% mmsssl.sh crl" - echo "\tLists revoked certificate serial numbers." - echo - echo "Notes:" - echo "1. user_name is one word i.e. John Q. Public is JohnQPublic" - echo "2. one-way authentication is where only the server is configured" - echo " with a RSA certificate." - echo "3. two-way authentication is when the server and client both have" - echo " a RSA certificate." - echo "4. MMS supports both one-way and two-way authentication." - echo "5. The MMS CA can use a certificate request made by a tool" - echo " other than this script." - echo "6. The crl.pem file contains the CRL for this MMS CA." - echo "7. The MM, Watcher, LM (Library Manager) and DM (Drive Manager)" - echo " can use the same certificate." - echo - exit 2 -} - -# -# Main -# - -if [ $# -eq 0 ]; then - usage -fi - -choice=$1 -oper="" -shift -found=0 -while getopts "csru:d:" opt; do - found=0 - case $opt in - c) - # setup mms ca - oper="configure" - found=1 - ;; - s) - # Create Signed Certificate on this host. - # - # On remote hosts its a two step process: - # 1. request certificate - # 2. CA sign's certificate - oper="sign" - found=1 - ;; - r) - # Revoke Certificate - # - # Update the MM CA CRL and put on all remote hosts - # especially if you have one MM CA for multiple MMs. - oper="revoke" - found=1 - ;; - u) - # User Name - USER="$OPTARG" - found=1 - ;; - d) - # User directory - DIR="$OPTARG" - found=1 - ;; - esac - - if [ $found -eq 0 ]; then - usage - fi -done - -case $choice in -ca) - # setup non-root MMS client in /etc - OPENSSL_CONF="$ROOT_CNF" - HOME="$CADIR" - root_user - case $oper in - configure) - # setup MMS CA - root_user - initialize - dh_pem - rsa_cert - - # sign mms certificate request - USER=$MMS_USER - certificate_request "$PUBDIR" 0 - ca_sign - echo "Done" - ;; - - sign) - # sign certificate request - check_client - ca_sign - echo "Done" - ;; - - revoke) - if [ -z "$USER" ]; then - echo "Error, missing client user name." - exit 1 - fi - - revoke_certificate - echo "Done" - ;; - - *) usage - ;; - esac - ;; - -req) - # certificate request - check_client - if [ "$DIR" = "" ]; then - DIR="$HOME/mms" - fi - certificate_request "$DIR" 1 - echo "Done" - ;; - -crl) - # show certificate revocation list - crl=$CRL - root_cert=$ROOT_CERT - openssl crl -in $crl -text -noout - openssl crl -in $crl -noout -CAfile $root_cert - echo "Done" - ;; - -*) usage - ;; -esac - -exit 0 diff --git a/usr/src/cmd/mms/mm/i386/Makefile b/usr/src/cmd/mms/mm/i386/Makefile deleted file mode 100644 index 7e02307f11..0000000000 --- a/usr/src/cmd/mms/mm/i386/Makefile +++ /dev/null @@ -1,27 +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.cmd -include ../Makefile.com diff --git a/usr/src/cmd/mms/mm/sparc/Makefile b/usr/src/cmd/mms/mm/sparc/Makefile deleted file mode 100644 index 7e02307f11..0000000000 --- a/usr/src/cmd/mms/mm/sparc/Makefile +++ /dev/null @@ -1,27 +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.cmd -include ../Makefile.com diff --git a/usr/src/cmd/mms/mms.xml b/usr/src/cmd/mms/mms.xml deleted file mode 100644 index c7b7d50ff3..0000000000 --- a/usr/src/cmd/mms/mms.xml +++ /dev/null @@ -1,295 +0,0 @@ -<?xml version="1.0"?> -<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1"> -<!-- - 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. - ---> - -<service_bundle type='manifest' name='SUNWmmsu:mms'> - -<service - name='application/management/mms' - type='service' - version='1'> - - <dependency - name='network' - grouping='require_all' - restart_on='none' - type='service'> - <service_fmri value='svc:/milestone/network:default' /> - </dependency> - - <dependency - name='filesystem-local' - grouping='require_all' - restart_on='none' - type='service'> - <service_fmri value='svc:/system/filesystem/local:default' /> - </dependency> - - <property_group name='general' type='framework'> - <propval - name='action_authorization' - type='astring' - value='solaris.smf.manage.mms' /> - <propval - name='value_authorization' - type='astring' - value='solaris.smf.manage.mms' /> - </property_group> - - <property_group name='config' type='application'> - <propval - name='type' - type='astring' - value='server' /> - <propval - name='value_authorization' - type='astring' - value='solaris.smf.value.mms' /> - </property_group> - - <property_group name='manager' type='application'> - <!-- MM and watcher shared data. --> - <propval - name='host' - type='ustring' - value='localhost' /> - <propval - name='port' - type='integer' - value='7151' /> - <propval - name='value_authorization' - type='astring' - value='solaris.smf.value.mms' /> - </property_group> - - <property_group name='ssl' type='application'> - <!-- - MM and watcher shared ssl data files. - --> - <propval - name='enabled' - type='boolean' - value='false' /> - <propval - name='verify' - type='boolean' - value='false' /> - <propval - name='cert_file' - type='astring' - value='' /> - <propval - name='pass_file' - type='astring' - value='' /> - <propval - name='dh_file' - type='astring' - value='' /> - <propval - name='crl_file' - type='astring' - value='' /> - <propval - name='cipher' - type='astring' - value='' /> - <propval - name='peer_file' - type='astring' - value='' /> - <propval - name='value_authorization' - type='astring' - value='solaris.smf.value.mms' /> - </property_group> - - <instance name='wcr' enabled='false'> - <!-- Watcher --> - <exec_method - type='method' - name='start' - exec='/lib/svc/method/mmswcr' - timeout_seconds='60'> - </exec_method> - - <exec_method - type='method' - name='stop' - exec=':kill' - timeout_seconds='60'> - </exec_method> - - <exec_method - type='method' - name='refresh' - exec=':kill -HUP' - timeout_seconds='60'> - </exec_method> - - <property_group name='option' type='application'> - <propval - name='ssi_path' - type='astring' - value='/opt/mms/bin/acsls' /> - <propval - name='libapi_path' - type='astring' - value='/opt/mms/lib/acsls' /> - <propval - name='value_authorization' - type='astring' - value='solaris.smf.value.mms' /> - </property_group> - </instance> - - <instance name='db' enabled='false'> - <!-- PostgreSQL Database --> - <method_context> - <method_credential user='postgres' group='postgres' /> - </method_context> - - <exec_method - type='method' - name='start' - exec='/lib/svc/method/mmsdb start' - timeout_seconds='60'> - </exec_method> - - <exec_method - type='method' - name='stop' - exec='/lib/svc/method/mmsdb stop' - timeout_seconds='60'> - </exec_method> - - <exec_method - type='method' - name='refresh' - exec='/lib/svc/method/mmsdb refresh' - timeout_seconds='60'> - </exec_method> - - <property_group name='postgresql' type='application'> - <propval - name='bin' - type='astring' - value='/usr/postgres/8.3/bin' /> - <propval - name='data' - type='astring' - value='/var/mms/db/data83' /> - <propval - name='value_authorization' - type='astring' - value='solaris.smf.value.mms' /> - </property_group> - </instance> - - <instance name='mm' enabled='false'> - <!-- Media Manager --> - - <exec_method - type='method' - name='start' - exec='/lib/svc/method/mmsmm' - timeout_seconds='60'> - </exec_method> - - <exec_method - type='method' - name='stop' - exec=':kill' - timeout_seconds='60'> - </exec_method> - - <exec_method - type='method' - name='refresh' - exec=':kill -HUP' - timeout_seconds='60'> - </exec_method> - - <property_group name='db' type='application'> - <propval - name='host' - type='ustring' - value='localhost' /> - <propval - name='port' - type='integer' - value='7656' /> - <propval - name='user' - type='astring' - value='postgres' /> - <propval - name='name' - type='astring' - value='mms' /> - <propval - name='value_authorization' - type='astring' - value='solaris.smf.value.mms' /> - </property_group> - - <property_group name='option' type='application'> - <propval - name='trace' - type='astring' - value='developer' /> - <propval - name='db_reconnect_max_retry' - type='integer' - value='50' /> - <propval - name='db_reconnect_timeout' - type='integer' - value='3' /> - <propval - name='value_authorization' - type='astring' - value='solaris.smf.value.mms' /> - </property_group> - </instance> - - <stability value='Unstable' /> - - <template> - <common_name> - <loctext xml:lang='C'> - Media Management System service - </loctext> - </common_name> - <documentation> - <manpage title='mms' section='5' - manpath='/usr/share/man' /> - </documentation> - </template> - -</service> - -</service_bundle> diff --git a/usr/src/cmd/mms/mmsdb b/usr/src/cmd/mms/mmsdb deleted file mode 100644 index b198b11daf..0000000000 --- a/usr/src/cmd/mms/mmsdb +++ /dev/null @@ -1,103 +0,0 @@ -#!/sbin/sh -# -# 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/svc/share/smf_include.sh - -getproparg() { - val=`svcprop -c -p $1 $SMF_FMRI` - [ -n "$val" ] && echo $val -} - -check_data_dir() { - if [ ! -d $PGDATA ]; then - echo "Error: postgresql/data directory $PGDATA does not exist" - exit $SMF_EXIT_ERR_CONFIG - fi - - if [ ! -w $PGDATA ]; then - echo "Error: postgresql/data directory $PGDATA is not writable by postgres" - exit $SMF_EXIT_ERR_CONFIG - fi - - if [ ! -d $PGDATA/base -o ! -d $PGDATA/global -o ! -f $PGDATA/PG_VERSION ]; then - echo "Error: postgresql/data directory $PGDATA is not empty, nor is it a valid PostgreSQL data directory" - exit $SMF_EXIT_ERR_CONFIG - fi -} - -if [ -z "$SMF_FMRI" ]; then - echo "Error: SMF framework variables are not initialized." - exit $SMF_EXIT_ERR -fi - -PGBIN=`getproparg postgresql/bin` -PGDATA=`getproparg postgresql/data` -PGUSER=`getproparg method_context/user` - -if [ -z "$PGDATA" ]; then - echo "Error: postgresql/data property not set" - exit $SMF_EXIT_ERR_CONFIG -fi - -if [ -z "$PGBIN" ]; then - echo "Error: postgresql/bin property not set" - exit $SMF_EXIT_ERR_CONFIG -fi - -if [ -z "$PGUSER" ]; then - echo "Error: method_context/user property not set" - exit $SMF_EXIT_ERR_CONFIG -fi - -case "$1" in -'start') - check_data_dir - $PGBIN/pg_ctl -D $PGDATA start - ;; - -'stop') - status=`$PGBIN/pg_ctl -D $PGDATA status | /bin/grep PID` - $PGBIN/pg_ctl -D $PGDATA stop -m fast - if [ -z "$status" ]; then - pattern="$PGBIN/postgres -D $PGDATA" - /bin/pgrep -u $PGUSER -f "$pattern" > /dev/null 2>&1 - if [ $? -eq 0 ]; then - echo "Sending immediate shutdown signal." - /bin/pkill -QUIT -u $PGUSER -f "$pattern" - fi - fi - ;; - -'refresh') - $PGBIN/pg_ctl -D $PGDATA reload - ;; - -*) - echo "Usage: $0 {start|stop|refresh}" - exit 1 - ;; - -esac -exit $SMF_EXIT_OK diff --git a/usr/src/cmd/mms/utility/Makefile b/usr/src/cmd/mms/utility/Makefile deleted file mode 100644 index ed4e0ebc72..0000000000 --- a/usr/src/cmd/mms/utility/Makefile +++ /dev/null @@ -1,53 +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. -# - -include $(SRC)/Makefile.master - -SUBDIRS = \ - mms_client - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -EXPLDIR = $(ROOT)/usr/bin - -FILES = $(EXPLDIR)/mmsexplorer - -all clean clobber lint: $(SUBDIRS) - -install: $(FILES) $(SUBDIRS) - -FILEMODE = 755 - -$(SUBDIRS): FRC - @cd $@; pwd; VERSION='$(VERSION)' $(MAKE) $(TARGET) - -FRC: - -$(EXPLDIR)/%: explorer/% - $(INS.file) diff --git a/usr/src/cmd/mms/utility/explorer/mmsexplorer b/usr/src/cmd/mms/utility/explorer/mmsexplorer deleted file mode 100644 index 9e374c4a94..0000000000 --- a/usr/src/cmd/mms/utility/explorer/mmsexplorer +++ /dev/null @@ -1,884 +0,0 @@ -#!/bin/sh -# -# 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. -# - - -# -# mmsexplorer -# -# mmsexplorer is a script that gathers information about the installed system -# and places it in a file for MMS customer support. -# -# NOTE: this script must be run as root. -# -# $Revision: 1.7 $ -# - -# Check for root user -user=`/bin/id | /bin/grep root | /bin/wc -l` -if [ $user -eq 0 ]; then - echo "Error, you must be root to run this script." - exit 1 -fi - -# INPUT OPTIONS -TGZ=ON -while getopts u OPT; do - case $OPT in - u) TGZ=OFF;; - ?) echo "Usage: $0 [-u] [report_name] [num_lines]" 1>&2; exit 1;; - *) echo "Usage: $0 [-u] [report_name] [num_lines]" 1>&2; exit 1;; - esac -done -shift `expr $OPTIND - 1` - -# REPORT LOCATION -REPORT=${1:-/tmp/MMSreport.`/bin/uname -n`.`/bin/date '+%Y'``/bin/date '+%m'``/bin/date '+%d'`.`/bin/date '+%H'``/bin/date '+%M'``/bin/date '+%Z'`} - -# How many lines from log files, etc., to show in the output report. -# Default is 1,000, but your support provider may ask you to change -# this to provide additional historical log messages. -HOW_MANY_LINES=${2:-1000} - -# How many lines from the media manager log file to show in the output -# report. Default is 5,000. -MM_LINES=`/bin/expr $HOW_MANY_LINES \* 5` -[ $MM_LINES -lt 5000 ] && MM_LINES=5000 - -# How many lines from a SMF service log file to show in the output -# report. Default is 100. -SVCLOG_LINES=`/bin/expr $HOW_MANY_LINES / 10` -[ $SVCLOG_LINES -lt 100 ] && SVCLOG_LINES=100 - -### -# CONFIGURATION VARIABLES - -# The number of lines from each mdb invocation -MDB_LINES=100000 - -# Locale for messages -LOCALE=C - -# END OF CONFIGURATION VARIABLES - NO CHANGES BELOW HERE, PLEASE -### - -# MMSreport name -REPORTNAME=`basename $REPORT` - -# MMSreport directory -REPORTDIR=`dirname $REPORT` - -# MMS Service Configuration -PGADMIN=`/bin/svcprop -c -p method_context/user mms:db` -PGBIN=`/bin/svcprop -c -p postgresql/bin mms:db` -PGDATA=`/bin/svcprop -c -p postgresql/data mms:db` -PGHOST=`/bin/svcprop -c -p db/host mms:mm` -PGPORT=`/bin/svcprop -c -p db/port mms:mm` -DBNAME=`/bin/svcprop -c -p db/name mms:mm` -PGUSER=`/bin/svcprop -c -p db/user mms:mm` -PGPASS=${PGDATA}/../.pga - -# Directories that MMS uses -TMPDIR=/tmp -ETCDIR=/etc/mms -VARDIR=/var/mms -USERDIR=/opt/mms - -# Output files -OUTDATABASE=${REPORTDIR}/${REPORTNAME}.database.gz -OUTALLTRACE=${REPORTDIR}/${REPORTNAME}.trace.tar.gz - -# Temporary work files -TMP=$TMPDIR/$$.tmp -TMPPAT=$TMPDIR/$$.mms_patchlist -TMPPROC=$TMPDIR/$$.mms_procs -TMPBGDF=$TMPDIR/$$.mms_bg_df - -# A tag emitted on lines indicating serious problems -TAG=":-( " - -# The prompt we fake on echoed command lines -PROMPT="`/bin/uname -n`# " - -# Function definitions - -# How many "."s on the current line? 999 means "too many". -COUNT=999 - -# Note: If you find the lines of dots aren't the same length, or you -# get extra "."s in your output file, then check to make sure you -# haven't done something like "verbose ls >>$REPORT", because then -# twiddle's dot will go to the report file instead of the screen! -twiddle(){ - COUNT=`expr $COUNT + 1` - if [ $COUNT -ge 45 ]; then - COUNT=1 - echo - /bin/echo Please wait.\\c - fi - /bin/echo .\\c -} - -# Execute a command, echoing it as it does so. -verbose(){ - twiddle - echo "" >>$REPORT 2>&1 - echo $PROMPT $* >>$REPORT 2>&1 - eval $* >>$REPORT 2>&1 - echo "" >>$REPORT 2>&1 -} - -# Indenting version of the above verbose function. -verbosei(){ - twiddle - echo "" >>$REPORT 2>&1 - echo " " $PROMPT $* >>$REPORT 2>&1 - (eval $* | /bin/sed -e "s/^/ /" )>>$REPORT 2>&1 - echo "" >>$REPORT 2>&1 -} - -# Head version of the above verbose function. -verbosehead(){ - twiddle - echo "" >>$REPORT 2>&1 - echo $PROMPT $* >>$REPORT 2>&1 - eval $* 2>&1 | head -100 >>$REPORT 2>&1 - echo "" >>$REPORT 2>&1 -} - -# Show a file, with title and verbose echoing of the cat command. -showfiles(){ -for file in $*; do - echo "------------------- $file -------------------" >>$REPORT 2>&1 - if [ -d $file -o -c $file -o -b $file -o -p $file ]; then - verbose /bin/ls -l $file - echo $TAG "$file is a directory, char special, block special or pipe.">>$REPORT 2>&1 - echo "" >>$REPORT 2>&1 - elif [ -r $file ]; then - verbose /bin/ls -l $file - verbose /bin/cat $file - elif [ -f $file ]; then - verbose /bin/ls -l $file - echo $file is not readable >>$REPORT 2>&1 - echo "" >>$REPORT 2>&1 - else - echo $file does not exist >>$REPORT 2>&1 - echo "" >>$REPORT 2>&1 - fi -done -} - -# Indenting version of the above showfiles function. -showifiles(){ -for file in $*; do - echo " ------------------- $file -------------------" >>$REPORT 2>&1 - if [ -d $file -o -c $file -o -b $file -o -p $file ]; then - verbosei /bin/ls -l $file - echo $TAG " $file is a directory, char special, block special or pipe.">>$REPORT 2>&1 - echo "" >>$REPORT 2>&1 - elif [ -r $file ]; then - verbosei /bin/ls -l $file - verbosei /bin/cat $file - elif [ -f $file ]; then - verbosei /bin/ls -l $file - echo " " $file is not readable >>$REPORT 2>&1 - echo "" >>$REPORT 2>&1 - else - echo " " $file does not exist >>$REPORT 2>&1 - echo "" >>$REPORT 2>&1 - fi -done -} - -# Show at least $HOW_MANY_LINES lines of a group of files -showenuf(){ -ENUF=0 -REM=$HOW_MANY_LINES -for file in $*; do - echo "------------------- $file -------------------" >>$REPORT 2>&1 - if [ -d $file -o -c $file -o -b $file -o -p $file ]; then - verbose /bin/ls -l $file - echo $TAG "$file is a directory, char special, block special or pipe.">>$REPORT 2>&1 - echo "" >>$REPORT 2>&1 - elif [ -r $file ]; then - verbose /bin/ls -l $file - if [ ! -s $file ]; then - echo $file is zero length >>$REPORT 2>&1 - echo "" >>$REPORT 2>&1 - elif [ `/bin/file $file | /bin/grep -c text` -eq 0 ]; then - echo $file is not a text file >>$REPORT 2>&1 - echo "" >>$REPORT 2>&1 - else - ENUF=`/bin/tail -$REM $file | /bin/wc | /bin/cut -c1-8` - verbose /bin/tail -$REM $file - if [ $ENUF -ge $REM ]; then - return - else - REM=`expr $REM - $ENUF` - fi - fi - elif [ -f $file ]; then - verbose /bin/ls -l $file - echo $file is not readable >>$REPORT 2>&1 - echo "" >>$REPORT 2>&1 - else - echo $file does not exist >>$REPORT 2>&1 - echo "" >>$REPORT 2>&1 - fi -done -} - -# Show at least n lines of a group of files -show_enuf(){ - lines=$HOW_MANY_LINES - HOW_MANY_LINES=$1 - shift - showenuf $* - HOW_MANY_LINES=$lines -} - -# Show just the last $HOW_MANY_LINES lines of a file -showtails(){ -for file in $*; do - echo "------------------- $file -------------------" >>$REPORT 2>&1 - if [ -d $file -o -c $file -o -b $file -o -p $file ]; then - verbose /bin/ls -l $file - echo $TAG "$file is a directory, char special, block special or pipe.">>$REPORT 2>&1 - echo "" >>$REPORT 2>&1 - elif [ -r $file ]; then - verbose /bin/ls -l $file - if [ ! -s $file ]; then - echo $file is zero length >>$REPORT 2>&1 - echo "" >>$REPORT 2>&1 - elif [ `/bin/file $file | /bin/grep -c text` -eq 0 ]; then - echo $file is not a text file >>$REPORT 2>&1 - echo "" >>$REPORT 2>&1 - else - verbose /bin/tail -$HOW_MANY_LINES $file - fi - elif [ -f $file ]; then - verbose /bin/ls -l $file - echo $file is not readable >>$REPORT 2>&1 - echo "" >>$REPORT 2>&1 - else - echo $file does not exist >>$REPORT 2>&1 - echo "" >>$REPORT 2>&1 - fi -done -} - -# Show last n lines of a file -show_tails(){ - lines=$HOW_MANY_LINES - HOW_MANY_LINES=$1 - shift - showtails $* - HOW_MANY_LINES=$lines -} - - -# End of function definitions - -# Generate the report -if [ $TGZ = "ON" ]; then - echo "Report name: $REPORT.tar.gz" - echo "Lines per file: $HOW_MANY_LINES" - echo "Output format: tar.gz (default) Use -u for unarchived/uncompressed." -else - echo "Report name: $REPORT" - echo "Lines per file: $HOW_MANY_LINES" - echo "Output format: unarchived/uncompressed" -fi - -/bin/rm -f $REPORT -echo "MMS Software Support Report" >$REPORT -echo " " >>$REPORT -echo "Run at `/bin/date`" >>$REPORT -echo "Run at `/bin/date -u`" >>$REPORT -echo " " >>$REPORT -echo "Run on `/bin/uname -n` by `/bin/id`" >>$REPORT -echo " " >>$REPORT - -echo "This report generated into: $REPORT" >>$REPORT -echo "" >>$REPORT 2>&1 - -echo "------------------- locale --------------------------" >>$REPORT -verbose /bin/locale -LC_ALL=$LOCALE -export LC_ALL - -echo "------------------- boot time -----------------------" >>$REPORT -verbose /bin/who -b - -echo "------------------- uptime --------------------------" >>$REPORT -verbose /bin/uptime - -echo "------------------- system type ---------------------" >>$REPORT -SYS_TYPE=`/bin/grep -i nexus /var/adm/messages* 2>&1 | head -1 | /bin/sed -e "s/^.*nexus = //"` -if [ X = X$SYS_TYPE ]; then - SYS_TYPE="Not Available" -fi -echo "\n$SYS_TYPE" >>$REPORT -echo "" >>$REPORT 2>&1 - -echo "------------------- uname ---------------------------" >>$REPORT -verbose /bin/uname -a - -# -# Check for some Solaris patches we know are required for proper operation -# of MMS. There may be others; this list is subject to change. -# Issue a warning if the patch isn't there; otherwise echo the full patch id. -# -SOL_VER=`/bin/uname -r | /bin/cut -c1-5` -if [ $SOL_VER = "5.11" ]; then - NEEDED="NONE" -else - NEEDED="UNKNOWN" - echo $TAG "Unknown Solaris release level $SOL_VER" >>$REPORT -fi - -showfiles /etc/release - -echo "------------------- application architecture info ---" >>$REPORT - -verbose /bin/isainfo - -echo "------------------- kernel architecture info --------" >>$REPORT - -KERN_ARCH=`/bin/isainfo -kv` -KERN_VER=` echo $KERN_ARCH | /bin/cut -c1-2` -if [ X"$KERN_VER" = X64 ]; then - echo "\nSolaris is running in 64-bit kernel mode." >>$REPORT -else - echo "\nSolaris is running in 32-bit kernel mode." >>$REPORT -fi -if [ X"$KERN_ARCH" != X ]; then - echo $KERN_ARCH >>$REPORT -fi -echo "" >>$REPORT 2>&1 - -echo "------------------- check system patches ------------" >>$REPORT -echo "\nPatches needed for Solaris ${SOL_VER}: $NEEDED\n" >>$REPORT -if [ X"$NEEDED" = "XNONE" -o X"$NEEDED" = "XUNKNOWN" ]; then - NEEDED="" -fi - -echo "\nPatches installed for Solaris:\n" >>$REPORT - -verbose "/bin/showrev -p 2>/dev/null | /bin/sed -e 's/Obso.*//' | /bin/sort > $TMPPAT" - -showifiles $TMPPAT -for patch in $NEEDED; do - PATCHFOUND=`/bin/grep -w $patch $TMPPAT` - if [ "X$PATCHFOUND" = "X" ]; then - echo $TAG "Solaris patch " $patch " not installed.\n" >>$REPORT - else - echo "Solaris " $PATCHFOUND " installed.\n" >>$REPORT - fi -done -/bin/rm -f $TMPPAT - -echo "\nPatches installed for MMS:\n" >>$REPORT - -verbose "/bin/showrev -p 2>/dev/null | /bin/egrep 'SUNWhsmr|SUNWhsmu|SUNWmmsr|SUNWmmsu|SUNWpostgr-83-client|SUNWpostgr-83-server|SUNWopenssl' | /bin/sed -e 's/Obso.*//' | /bin/sed -e 's/Patch: //' > $TMPPAT" - -showifiles $TMPPAT -for i in `/bin/cat $TMPPAT`; do - verbose "/bin/ls -ld /var/sadm/patch/${i}" - verbose "/bin/ls -l /var/sadm/patch/${i}/log" -done -/bin/rm -f $TMPPAT - -# -# SUNWhsmr - Sun ADM HSM software Solaris 11 (root) -# SUNWhsmu - Sun ADM HSM software Solaris 11 (usr) -# SUNWmmsr - MMS Solaris (root) -# SUNWmmsu - MMS Solaris (usr) -# SUNWpostgr-83-client - PostgreSQL client tools -# SUNWpostgr-83-server - PostgreSQL database server -# SUNWopenssl-commands - OpenSSL commands (usr) -# SUNWopenssl-libraries - OpenSSL libraries (usr) -# SUNWopensslr - OpenSSL (root) -# STKacsls - Automated Cartridge System Library Software by StorageTek -# SUNWfcp - Sun FCP SCSI Device Driver (system) -# SUNWfcpx - Sun FCP SCSI Device Driver 64-bit (system) -# SUNWfctl - Sun Fibre Channel Transport layer (system) -# SUNWfctlx - Sun Fibre Channel Transport layer 64-bit (system) -# SUNWqlc - Qlogic ISP 2200/2202 Fibre Channel Device Driver (system) -# SUNWqlcx - Qlogic ISP 2200/2202 Fibre Channel Device Driver 64-bit (system) -# SUNWsmgr - SANsurfer, QLogic Fibre Channel Administration (system) -# JNIC - JNI Fibre Channel SCSI HBA Driver (system) -# QLA2200-3 - QLogic QLA2200 driver (system) -# -echo "------------------- package info --------------------" >>$REPORT - -for PACKAGE in SUNWhsmr SUNWhsmu SUNWmmsr SUNWmmsu SUNWpostgr-83-client SUNWpostgr-83-server SUNWopenssl-commands SUNWopenssl-libraries SUNWopensslr STKacsls SUNWfcp SUNWfcpx SUNWfctl SUNWfctlx SUNWqlc SUNWqlcx SUNWsmgr JNIC QLA2200-3 -do - twiddle - echo "" >>$REPORT 2>&1 - verbose /bin/pkginfo -l $PACKAGE - verbose /usr/sbin/pkgchk $PACKAGE -done - -#showfiles /opt/SUNWsamfs/include/version.h - -echo "------------------- kernel info ---------------------" >>$REPORT -echo "" >>$REPORT 2>&1 -echo "/bin/ls -l /kernel/drv/dmd" >>$REPORT 2>&1 -/bin/ls -l /kernel/drv/dmd >>$REPORT 2>&1 -echo "/bin/ls -l /kernel/drv/*/dmd" >>$REPORT 2>&1 -/bin/ls -l /kernel/drv/*/dmd >>$REPORT 2>&1 -echo "" >>$REPORT 2>&1 -echo "/bin/ls -l /kernel/drv/dda" >>$REPORT 2>&1 -/bin/ls -l /kernel/drv/dda >>$REPORT 2>&1 -echo "/bin/ls -l /kernel/drv/*/dda" >>$REPORT 2>&1 -/bin/ls -l /kernel/drv/*/dda >>$REPORT 2>&1 -echo "" >>$REPORT 2>&1 - -echo "------------------- modinfo output ------------------" >>$REPORT -verbose "/usr/sbin/modinfo | /bin/grep ' dmd '" -verbose "/usr/sbin/modinfo | /bin/grep ' dda '" -verbose "/usr/sbin/modinfo | /bin/grep ' sd '" -verbose "/usr/sbin/modinfo | /bin/grep ' st '" -verbose "/usr/sbin/modinfo | /bin/egrep -i 'dmd|fcp|fctl|fp|qlc|ssd|disk|tape'" - -echo "------------------- storage array info ------------------" >>$REPORT -if [ -f /usr/sbin/luxadm ]; then - verbose /usr/sbin/luxadm qlgc -fi - -echo "------------------- device configuration info -----------" >>$REPORT -if [ -f /usr/sbin/cfgadm ]; then - verbose /usr/sbin/cfgadm -al -fi - -echo "------------------- ls -lR /opt/mms ------------" >>$REPORT -verbose /bin/ls -lR /opt/mms -verbose /bin/ls -lL /opt/mms - -echo "------------------- ls -lR /etc/mms ------------" >>$REPORT -verbose /bin/ls -lR /etc/mms -verbose /bin/ls -lL /etc/mms - -echo "------------------- ls -lR /var/mms ------------" >>$REPORT -if [ -d /var/mms ]; then - verbose /bin/ls -l `/bin/find /var/mms -type d -print | /bin/grep -v "$PGDATA"` -else - verbose /bin/ls -l /var/mms -fi -verbose /bin/ls -lL /varmms - -showtails /var/adm/messages - -echo "------------------- service configuration -----------" >>$REPORT -verbose /bin/svcprop -c mms - -showifiles $PGDATA/pg_hba.conf -showifiles $PGDATA/pg_ident.conf -showifiles $PGDATA/postgresql.conf -showifiles $PGDATA/postgresql.pid -verbose /bin/ls -lL /tmp/.s.PGSQL.$PGPORT /tmp/.s.PGSQL.${PGPORT}.lock - -verbose "/bin/ps -ef | /bin/egrep -i 'pg_ctl|psql|postmaster'" - -verbose /bin/svcs -xv mms:db - -show_tails $SVCLOG_LINES /var/svc/log/application-management-mms:db.log - -verbose /bin/ls -l $PGDATA/../mms_db /etc/mms/db/mms_db -verbose /bin/ls -lL $PGDATA/../mms_db /etc/mms/db/mms_db - -# check for database downgrade -verbose /bin/diff $PGDATA/../mms_db /etc/mms/db/mms_db - -# order database log files from current day of week -DOW=`/bin/date +%a` -CURRENT= -BEFORE= -AFTER= -found=0 -for DAY in Sun Mon Tue Wed Thu Fri Sat; do - file="$PGDATA/../log/log.$DAY" - if [ "$DAY" = "$DOW" ]; then - CURRENT="$file" - found=1 - elif [ $found -eq 1 ]; then - AFTER="$file $AFTER" - else - BEFORE="$file $BEFORE" - fi -done -showenuf $CURRENT $BEFORE $AFTER - - -# database snapshot -object="APPLICATION AI CONNECTION SESSION NOTIFY NOTIFYRULES "\ -"EVENTRULES LIBRARYACCESS LIBRARY LM BAY SLOTTYPE CARTRIDGEGROUP "\ -"CARTRIDGETYPE CARTRIDGE CARTRIDGEGROUPAPPLICATION SIDE PARTITION VOLUME "\ -"DRIVEGROUP DRIVEGROUPAPPLICATION DRIVE DRIVECARTRIDGEERROR DM DMCAPABILITY "\ -"DMCAPABILITYTOKEN DMCAPABILITYDEFAULTTOKEN DMCAPABILITYGROUP "\ -"DMCAPABILITYGROUPTOKEN DMBITFORMAT DMBITFORMATTOKEN SLOTGROUP SLOT "\ -"SLOTCONFIG MOUNTLOGICAL MOUNTPHYSICAL DRIVECARTRIDGEACCESS "\ -"TASK TASKCARTRIDGE TASKDRIVE TASKLIBRARY MESSAGE REQUEST SYSTEM "\ -"STALEHANDLE DMSHAPEPRIORITY DMDENSITYPRIORITY "\ -"LIBRARYLIST DRIVELIST CARTRIDGELIST " - -cmd="select * from \\\"MM\\\";" -cmd="$cmd select \\\"ApplicationName\\\",length(\\\"Password\\\") from \\\"MMPASSWORD\\\";" - -for table in $object; do - cmd="$cmd select * from \\\"$table\\\";" -done - -/bin/su - $PGADMIN -c "PGPASSFILE=${PGPASS} ; export PGPASSFILE ; /bin/echo \"$cmd\" | $PGBIN/psql -h $PGHOST -p $PGPORT -d $DBNAME -U $PGUSER -e" 2>&1 | /bin/gzip -f > $OUTDATABASE - -echo "------------------- media manager service -----------" >>$REPORT -echo "" >>$REPORT 2>&1 -showfiles $ETCDIR/types/mm_types.xml - -verbose "/bin/ps -ef | /bin/egrep -i 'mmsmm'" - -verbose /usr/lib/mmsmm -v - -verbose /bin/svcs -xv mms:mm - -show_tails $SVCLOG_LINES /var/svc/log/application-management-mms:mm.log - -show_enuf $MM_LINES /var/log/mms/mm/mm.debug* - -showenuf /var/log/mms/system_log* - -echo "------------------- watcher service -----------------" >>$REPORT - -verbose "/bin/ps -ef | /bin/egrep -i 'mmswcr|mmslm|mmsdm'" - -verbose /bin/svcs -xv mms:wcr - -show_tails $SVCLOG_LINES /var/svc/log/application-management-mms:wcr.log - -showenuf /var/log/mms/wcr/wcr.debug* - -LMS=`/bin/ls /var/log/mms/lm/*.debug 2>/dev/null` -for LM in $LMS; do - showenuf ${LM}* -done - -DMS=`/bin/ls /var/log/mms/dm/*.debug 2>/dev/null` -for DM in $DMS; do - showenuf ${DM}* -done - -APIS=`/bin/ls /var/log/mms/api/*.debug 2>/dev/null` -for API in $APIS; do - showenuf ${API}* -done - -# all trace -/bin/tar -cf - -C /var adm/messages -C /var/log mms | /bin/gzip -f > $OUTALLTRACE - -showfiles /kernel/drv/dmd.conf -showfiles /kernel/drv/dda.conf -showfiles /kernel/drv/st.conf -showfiles /kernel/drv/fp.conf -showfiles /kernel/drv/fcp.conf -showfiles /kernel/drv/jni.conf -showfiles /kernel/drv/qla*.conf -showfiles /kernel/drv/qlc.conf -showfiles /etc/driver_classes -showfiles /etc/driver_aliases -showfiles /etc/system -showfiles /etc/devlink.tab - -echo "------------------- hostid --------------------------" >>$REPORT -echo "" >>$REPORT 2>&1 -echo "hostid is `/usr/bin/hostid`" >>$REPORT 2>&1 -echo "" >>$REPORT 2>&1 - -echo "------------------- network info --------------------" >>$REPORT -verbose /usr/sbin/ifconfig -a -verbose /bin/grep rpc /etc/nsswitch.conf -verbose /bin/grep services /etc/nsswitch.conf -verbose /bin/grep mms /etc/rpc -verbose "/bin/ypcat rpc | /bin/grep mms" -verbose /bin/grep mms /etc/services -verbose /bin/grep mms /etc/yp/src/services -verbose "/bin/ypcat services | /bin/grep mms" -showfiles /etc/hostname* -showfiles /etc/inet/hosts -showfiles /etc/inet/ipnodes -showfiles /etc/inet/services -showfiles /etc/nsswitch.conf - -echo "------------------- ipcs info -----------------------" >>$REPORT -verbose /bin/ipcs -a - -echo "------------------- /devices/pseudo/dmd -------------" >>$REPORT -echo "" >>$REPORT 2>&1 -verbose /bin/ls -l /devices/pseudo/dmd@* -verbose /bin/ls -Ll /devices/pseudo/dmd@* - -echo "------------------- /dev/dda ------------------------" >>$REPORT -echo "" >>$REPORT 2>&1 -verbose /bin/ls -l /dev/dda -verbose /bin/ls -Ll /dev/dda - -echo "------------------- /dev/rmt ------------------------" >>$REPORT -echo "" >>$REPORT 2>&1 -echo "/bin/ls -l /dev/rmt/*[0-9]" >>$REPORT 2>&1 -/bin/ls -l /dev/rmt/*[0-9] >>$REPORT 2>&1 -echo "" >>$REPORT 2>&1 -echo "/bin/ls -Ll /dev/rmt/*[0-9]" >>$REPORT 2>&1 -/bin/ls -Ll /dev/rmt/*[0-9] >>$REPORT 2>&1 -echo "" >>$REPORT 2>&1 - -echo "------------------- /dev/dsk ------------------------" >>$REPORT -echo "" >>$REPORT 2>&1 -echo "/bin/ls -l /dev/dsk/*s2" >>$REPORT 2>&1 -/bin/ls -l /dev/dsk/*s2 >>$REPORT 2>&1 -echo "" >>$REPORT 2>&1 -echo "/bin/ls -Ll /dev/dsk/*s2" >>$REPORT 2>&1 -/bin/ls -Ll /dev/dsk/*s2 >>$REPORT 2>&1 -echo "" >>$REPORT 2>&1 - -echo "------------------- /dev/rdsk -----------------------" >>$REPORT -echo "" >>$REPORT 2>&1 -echo "/bin/ls -l /dev/rdsk/*s2" >>$REPORT 2>&1 -/bin/ls -l /dev/rdsk/*s2 >>$REPORT 2>&1 -echo "" >>$REPORT 2>&1 -echo "/bin/ls -Ll /dev/rdsk/*s2" >>$REPORT 2>&1 -/bin/ls -Ll /dev/rdsk/*s2 >>$REPORT 2>&1 -echo "" >>$REPORT 2>&1 - -echo "------------------- threadlist of running system ----" >>$REPORT -echo '=n"---- date/time ----" - time/y - lbolt/K - =n"---- utsname ----" - utsname::print - =n"---- threadlist ----" - ::threadlist -v - =n"---- function call args ----" - ::walk thread | ::findstack ".$c6" - =n"---- mms_ mdb end ----"' | /bin/mdb -k 2>&1 | head -$MDB_LINES >> $REPORT 2>&1 - -echo "------------------- stack tracebacks ----------------" >>$REPORT -# ps -e only returns 8 characters, so match on first 8. -MMS=`/bin/ps -e | /bin/egrep -i 'mmsmm|mmswcr' | /bin/awk '{print $1}'` -for mms in $MMS; do - echo "\n/bin/ptree $mms" >>$REPORT - /bin/ptree $mms >>$REPORT - /bin/ptree $mms > $TMPPROC - procs=`/bin/cat $TMPPROC | /bin/awk '{print $1}'` - for pid in $procs; do - verbose "/bin/pstack $pid; /bin/pflags $pid" - done - /bin/rm -f $TMPPROC -done -if [ "$MMS" = "" ]; then - echo "Sorry, mms_ processes not running.\n" >>$REPORT -fi - -echo "------------------- filesystem information ----------" >>$REPORT -# Background this command so it doesn't hang the script -# on file system problems. -echo "" >>$REPORT 2>&1 -echo " " $PROMPT /bin/df -kl >>$REPORT 2>&1 -/bin/df -kl > $TMPBGDF 2>&1 & -sleep 5 -twiddle -sleep 5 -if [ -s $TMPBGDF ]; then - /bin/cat $TMPBGDF | /bin/sed -e "s/^/ /" >>$REPORT 2>&1 -else - echo " $TAG /bin/df -kl timed out" >>$REPORT 2>&1 -fi -echo "" >>$REPORT 2>&1 -/bin/rm -f $TMPBGDF - -verbosei /etc/mount - -showifiles /etc/mnttab /etc/vfstab /etc/dfs/dfstab /etc/inittab - -echo "" >>$REPORT 2>&1 -echo "------------------- ps -edalf -----------------------" >>$REPORT -verbose /bin/ps -edalf - -echo "------------------- iostat --------------------------" >>$REPORT -verbose "/bin/iostat -en | /bin/grep -v ' nfs'" - -echo "------------------- mpstat --------------------------" >>$REPORT -verbose "/bin/mpstat" - -echo "------------------- kstat ---------------------------" >>$REPORT -verbose "/bin/kstat -n cpu_info0" - -echo "------------------- prstat --------------------------" >>$REPORT -verbose /bin/prstat 1 1 - -echo "------------------- prtconf -------------------------" >>$REPORT -verbose /usr/sbin/prtconf -V -verbose /usr/sbin/prtconf - -echo "------------------- core files ----------------------" >>$REPORT -echo "" >>$REPORT 2>&1 - -ONLINE_CORE_FILES="" -for DIR in $ETCDIR $VARDIR $USERDIR; do - - CORE_FILES="" - if [ -d $DIR ]; then - if [ -r $DIR -a -x $DIR ]; then - echo "CORE_FILES=/bin/find $DIR -follow -name \"core*\" -type f -print" >>$REPORT - CORE_FILES=`/bin/find $DIR -follow -name "core*" -type f -print` - for file in $CORE_FILES; do - verbose "/bin/ls -tlLd $file; /bin/file $file" - done - fi - else - echo $TAG missing $DIR >>$REPORT 2>&1 - fi - - if [ x"$CORE_FILES" != x ]; then - ONLINE_CORE_FILES="$ONLINE_CORE_FILES $CORE_FILES" - else - echo "" >>$REPORT 2>&1 - fi - -done - -if [ -f /core ]; then - verbose "/bin/ls -tlLd /core; /bin/file /core" - ONLINE_CORE_FILES="$ONLINE_CORE_FILES /core" -fi - -echo "------------------- core file stack tracebacks ------" >>$REPORT -for CORE in $ONLINE_CORE_FILES; do - verbose "/bin/pstack $CORE; /bin/pflags $CORE" -done - -echo "------------------- system panic dumps --------------" >>$REPORT -verbose /usr/sbin/dumpadm -dumpdir=`/usr/sbin/dumpadm | /bin/grep "core dir" | /bin/sed -e "s/Savecore directory: //" | /bin/awk '{print $1}'` -enabled=`/usr/sbin/dumpadm | /bin/grep "core ena" | /bin/sed -e "s/Savecore enabled: //" | /bin/awk '{print $1}'` -if [ -n "$enabled" ]; then - if [ $enabled = "no" ]; then - echo $TAG Core dump program \'savecore\' disabled by /usr/sbin/dumpadm >>$REPORT - fi -fi - -if [ -n "$dumpdir" ]; then - coredir=`eval echo $dumpdir` - verbose /bin/ls -ld $coredir - verbose /bin/ls -l $coredir - for unix in `ls $coredir/unix.[0-9]* 2>/dev/null` - do - twiddle - vmcore=`echo $unix | /bin/sed -e "s./unix./vmcore."` - verbose /bin/ls -l $unix $vmcore - verbose /bin/file $unix $vmcore - VM_SOL_VER=`/bin/file $vmcore | /bin/cut -d" " -f2` - # Only process vmcores that match the running Solaris release. - if [ $SOL_VER = $VM_SOL_VER ]; then - echo '=n"---- date/time ----" - time/y - lbolt/K - =n"---- utsname ----" - utsname::print - =n"---- panic string ----" - *panicstr/s - =n"----panic_regs/2K----" - panic_regs/2K - =n"---- stack traceback ----" - $c - =n"---- stack traceback verbose----" - $C - =n"---- message buffer ----" - $<msgbuf - =n"---- threadlist ----" - ::threadlist -v - =n"---- function call args ----" - ::walk thread | ::findstack ".$c6" - =n"---- mms_ mdb end ----"' | mdb -k $unix $vmcore 2>&1 | head -$MDB_LINES >>$REPORT 2>&1 - fi - done -fi - -echo "" >>$REPORT 2>&1 -echo "End at `/bin/date` on `/bin/uname -n` by `/bin/id`" >>$REPORT -echo " " >>$REPORT -echo "------------------- THE END -------------------------" >>$REPORT -echo " " -echo " " - - -echo " " -echo "The following files should now be ftp'ed to your support provider" -echo "as ftp type binary." -echo " " - -# -# Use the following syntax for the report name in order to echo -# any unspecified dot slash for the path. -# -if [ $TGZ = "ON" ]; then - echo "${REPORTDIR}/${REPORTNAME}.tar.gz" -else - echo "${REPORTDIR}/${REPORTNAME}" -fi -chmod 444 ${REPORTDIR}/${REPORTNAME} - -TARFILES=$REPORTNAME -for file in $OUTDATABASE $OUTALLTRACE; do - if [ -s $file ]; then - if [ $TGZ = "ON" ]; then - TARFILES="$TARFILES `basename $file`" - else - echo "$file" - fi - chmod 444 $file - fi -done -echo " " - -if [ $TGZ = "ON" ]; then - ( - cd $REPORTDIR - /bin/tar cf ${REPORTNAME}.tar $TARFILES 2>/dev/null - chmod 555 ${REPORTNAME}.tar - /bin/rm -f $TARFILES - /bin/gzip ${REPORTNAME}.tar - ) -fi - -if [ x"$ONLINE_CORE_FILES" != x ]; then - echo "This script found the following core files. Please ftp them as" - echo "binary files to your support provider only if they appear to be" - echo "from the MMS product." - echo " " - for file in $ONLINE_CORE_FILES; do - /bin/file $file | /bin/sed -e "s/:.*,/ :/" ; /bin/ls -tlLd $file - echo - done -fi - diff --git a/usr/src/cmd/mms/utility/mms_client/Makefile b/usr/src/cmd/mms/utility/mms_client/Makefile deleted file mode 100644 index 3a3c393869..0000000000 --- a/usr/src/cmd/mms/utility/mms_client/Makefile +++ /dev/null @@ -1,28 +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. -# - -SUBDIRS = $(MACH) - -include ../../Makefile.subdirs diff --git a/usr/src/cmd/mms/utility/mms_client/Makefile.com b/usr/src/cmd/mms/utility/mms_client/Makefile.com deleted file mode 100644 index 401747c390..0000000000 --- a/usr/src/cmd/mms/utility/mms_client/Makefile.com +++ /dev/null @@ -1,76 +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. -# - -SRCS = mmsclient.c - -.KEEP_STATE: -.SUFFIXES: - -PROG = mmsclient - -OBJS = $(SRCS:%.c=%.o) -lint_SRCS = $(SRCS:%.c=%.ln) - -include $(SRC)/cmd/Makefile.cmd - -FILEMODE = 0755 - -CFLAGS += $(CTF_FLAGS) $(CC_VERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -D_REENTRANT -CPPFLAGS += -I. -I../common -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/lib/mms/mms/common - -LDLIBS += -lc -LDLIBS += -L$(SRC)/lib/mms/mms/$(MACH) -lmms - -.NO_PARALLEL: -.PARALLEL: $(OBJS) $(lint_SRCS) - -C99MODE= $(C99_ENABLE) - -all: $(PROG) - -$(PROG): $(OBJS) - $(LINK.c) $(OBJS) -o $@ $(LDLIBS) - $(CTFMERGE) -L VERSION -o $@ $(OBJS) - $(POST_PROCESS) - -%.o: ../common/%.c - $(COMPILE.c) $< - $(CTFCONVERT_O) - -clean: - $(RM) $(OBJS) $(lint_SRCS) - -lint: $(lint_SRCS) - -%.ln: ../common/%.c - $(LINT.c) -c $< - -install: all $(ROOTBIN)/$(PROG) - -include $(SRC)/cmd/Makefile.targ diff --git a/usr/src/cmd/mms/utility/mms_client/common/mmsclient.c b/usr/src/cmd/mms/utility/mms_client/common/mmsclient.c deleted file mode 100644 index 370c8f6152..0000000000 --- a/usr/src/cmd/mms/utility/mms_client/common/mmsclient.c +++ /dev/null @@ -1,1172 +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 <signal.h> -#include <pthread.h> -#include <mms.h> -#include <mms_cores.h> -#include <ctype.h> - -#define BUFSZ 1024 - - -typedef struct cli_data cli_data_t; -struct cli_data { - char *host; - char *port; - char *client; - char *instance; - char *password; - char *tag; - char *mm_pass; - char *net_file; - mms_network_cfg_t net; - int exiting; - mms_list_t async_list; - int async_waiting; - pthread_mutex_t cli_async_lock; - char *tag_to_sync; - int wait_for_sync; - int sync_has_namevalue; - void *ssl_data; - int waiting_to_exit; - pthread_cond_t async_cv; - pthread_mutex_t async_mutex; -}; - -typedef struct cli_cmd cli_cmd_t; -struct cli_cmd { - mms_list_node_t cli_cmd_next; - int cmd_is_sync; - char *cmd_text; - char *cmd_task; - void *cmd_rsp; - mms_par_node_t *cmd_root; - int cmd_namevalue; - char *cmd_tag; -}; - -cli_data_t data; -void *sp; - -pthread_attr_t event_attr; -pthread_attr_t cmd_attr; - -extern -int mms_ainit(void **, int *, mms_callbk_t *, mms_rsp_callbk_t *); - -cli_cmd_t * -cli_alloc_cmd() { - cli_cmd_t *cmd; - - cmd = (cli_cmd_t *)calloc(1, sizeof (cli_cmd_t)); - if (cmd == NULL) { - printf("could not allocate mem for new command"); - exit(1); - } - cmd->cmd_text = NULL; - cmd->cmd_task = NULL; - cmd->cmd_rsp = NULL; - cmd->cmd_namevalue = 0; - return (cmd); -} - -void -cli_destroy_cmd(cli_cmd_t *cmd) { - - if (cmd->cmd_text != NULL) { - free(cmd->cmd_text); - } - if (cmd->cmd_task != NULL) { - free(cmd->cmd_task); - } - if (cmd->cmd_rsp != NULL) { - mms_free_rsp(cmd->cmd_rsp); - } - if (cmd->cmd_tag != NULL) { - free(cmd->cmd_tag); - } - if (cmd->cmd_root != NULL) { - mms_pn_destroy(cmd->cmd_root); - } - free(cmd); -} - -void -/* LINTED: void arg is required */ -mms_catch_reader(void *ev) -{ - printf("mms_catch_reader: Reader shutting down\n"); -} - -void -mms_client_errlog(char *prefix, char *msg) -{ - printf("mms_client_errlog: prefix - %s\nmsg - %s\n", prefix, msg); -} - -/*ARGSUSED*/ -static void -client_handle_event(void *param, void *ev) -{ - mms_rsp_ele_t *lev = (mms_rsp_ele_t *)ev; - - if (lev->mms_rsp_str != NULL) { - printf("Event received:\n %s\n", - lev->mms_rsp_str); - fflush(stdout); - } -} - -static -void -attrlist(mms_par_node_t *attrlist, int namevalue) -{ - mms_par_node_t *arg; - mms_par_node_t *work; - - printf(" attrlist\n"); - work = NULL; - for (arg = mms_pn_lookup_arg(attrlist, NULL, NULL, &work); - arg != NULL; - arg = mms_pn_lookup_arg(attrlist, NULL, NULL, &work)) { - if (arg->pn_type & MMS_PN_STRING) { - if (namevalue) { - /* print 2 */ - printf(" %s", - arg->pn_string); - arg = mms_pn_lookup_arg(attrlist, - NULL, NULL, &work); - printf(" %s\n", - arg->pn_string); - - } else { - /* print 1 */ - printf(" %s\n", - arg->pn_string); - } - } - } -} - - -static -void -text_clause(mms_par_node_t *text, int namevalue) -{ - mms_par_node_t *arg; - mms_par_node_t *work; - - printf(" text\n"); - work = NULL; - for (arg = mms_pn_lookup_arg(text, NULL, NULL, &work); - arg != NULL; - arg = mms_pn_lookup_arg(text, NULL, NULL, &work)) { - - if ((arg->pn_type & MMS_PN_CLAUSE) && - (strcmp(arg->pn_string, "attrlist") == 0)) { - attrlist(arg, namevalue); - - } - if (arg->pn_type & MMS_PN_STRING) { - if (namevalue) { - /* print 2 */ - printf(" %s", - arg->pn_string); - arg = mms_pn_lookup_arg(text, - NULL, NULL, &work); - printf(" %s\n", - arg->pn_string); - - } else { - /* print 1 */ - printf(" %s\n", - arg->pn_string); - } - } - - } -} - -static void -cli_print_async_rsp(mms_rsp_ele_t *lrsp) { - /* lrsp->mms_rsp_cmd is */ - /* the parse tree of the response */ - mms_par_node_t *work; - mms_par_node_t *text; - mms_par_node_t *cmd; - - cli_cmd_t *cur_cmd; - cli_cmd_t *next; - - int namevalue = 0; - - cmd = lrsp->mms_rsp_cmd; - - printf("success, %s\n", - lrsp->mms_rsp_tid); - - for (cur_cmd = mms_list_head(&data.async_list); - cur_cmd != NULL; - cur_cmd = next) { - next = mms_list_next(&data.async_list, cur_cmd); - /* Test task and remove if the same */ - if (strcmp(cur_cmd->cmd_task, - lrsp->mms_rsp_tid) == 0) { - namevalue = cur_cmd->cmd_namevalue; - break; - } - } - - - - work = NULL; - /* For each text clause print the results */ - - for (text = mms_pn_lookup(cmd, - "text", MMS_PN_CLAUSE, &work); - text != NULL; - text = mms_pn_lookup(cmd, - "text", MMS_PN_CLAUSE, &work)) { - text_clause(text, namevalue); - } - fflush(stdout); -} - -static void -cli_print_sync_rsp(mms_rsp_ele_t *lrsp) { - /* lrsp->mms_rsp_cmd is */ - /* the parse tree of the response */ - mms_par_node_t *work; - mms_par_node_t *text; - mms_par_node_t *cmd; - cmd = lrsp->mms_rsp_cmd; - - printf("success, %s\n", - lrsp->mms_rsp_tid); - work = NULL; - /* For each text clause print the results */ - - for (text = mms_pn_lookup(cmd, - "text", MMS_PN_CLAUSE, &work); - text != NULL; - text = mms_pn_lookup(cmd, - "text", MMS_PN_CLAUSE, &work)) { - text_clause(text, data.sync_has_namevalue); - } - data.sync_has_namevalue = 0; - fflush(stdout); -} - -static void -mms_client_handle_rsp(void *rsp) -{ - int class; - int code; - char *msg; - - mms_rsp_ele_t *lrsp = (mms_rsp_ele_t *)rsp; - - switch (mms_rsp_type(rsp)) { - case MMS_API_RSP_UNACC: - printf("Command was not accepted\n"); - printf("Response - %s\n", lrsp->mms_rsp_str); - break; - case MMS_API_RSP_FINAL: - printf("Command was successful\n"); - cli_print_sync_rsp(lrsp); - break; - case MMS_API_RSP_FINAL_ERR: - printf("Command received an error response\n"); - printf("Response - %s\n", lrsp->mms_rsp_str); - if (mms_handle_err_rsp(rsp, &class, &code, - &msg) != MMS_API_OK) { - printf("Error response handler failed\n"); - break; - } - printf("Error class %d, %s\n", class, - mms_sym_code_to_str(class)); - printf("Error code %d, %s\n", code, - mms_sym_code_to_str(code)); - if (msg != NULL) - printf("Error message:\n%s\n", msg); - else - printf("No message clause in error rsp\n"); - break; - case MMS_API_RSP_FINAL_CANC: - printf("Command received a cancelled response\n"); - printf("Response - %s\n", lrsp->mms_rsp_str); - break; - default: - printf("Unknow response type\n"); - printf("Response - %s\n", lrsp->mms_rsp_str); - break; - } -} - - -void -/* LINTED: param required */ -mms_client_handle_async_rsp(void *param, void *rsp) -{ - - int class; - int code; - - char *msg; - - mms_rsp_ele_t *lrsp = (mms_rsp_ele_t *)rsp; - - cli_cmd_t *cur_cmd; - cli_cmd_t *next; - cli_cmd_t *remove_cmd; - - int found_other = 0; - - pthread_mutex_lock(&data. - cli_async_lock); - - switch (mms_rsp_type(rsp)) { - case MMS_API_RSP_UNACC: - printf("Command was not accepted\n"); - printf("Response - %s\n", lrsp->mms_rsp_str); - break; - case MMS_API_RSP_FINAL: - printf("\n\nCommand was successful\n"); - cli_print_async_rsp(lrsp); - printf("\n\n"); - break; - case MMS_API_RSP_FINAL_ERR: - printf("Command received an error response\n"); - printf("Response - %s\n", lrsp->mms_rsp_str); - if (mms_handle_err_rsp(rsp, &class, &code, - &msg) != MMS_API_OK) { - printf("Error response handler failed\n"); - break; - } - printf("Error class %d, %s\n", class, - mms_sym_code_to_str(class)); - printf("Error code %d, %s\n", code, - mms_sym_code_to_str(code)); - if (msg != NULL) - printf("Error message:\n%s\n", msg); - else - printf("No message clause in error rsp\n"); - break; - case MMS_API_RSP_FINAL_CANC: - printf("Command received a cancelled response\n"); - printf("Response - %s\n", lrsp->mms_rsp_str); - break; - default: - printf("Unknow response type\n"); - printf("Response - %s\n", lrsp->mms_rsp_str); - break; - } - - - for (cur_cmd = mms_list_head(&data.async_list); - cur_cmd != NULL; - cur_cmd = next) { - next = mms_list_next(&data.async_list, cur_cmd); - /* Test task and remove if the same */ - if (strcmp(cur_cmd->cmd_task, - lrsp->mms_rsp_tid) == 0) { - mms_list_remove(&data.async_list, - cur_cmd); - remove_cmd = cur_cmd; - } else { - /* there is at least one other */ - /* async command waiting */ - found_other = 1; - } - } - - /* There are no async commands left */ - if (!found_other) { - pthread_mutex_lock(&data.async_mutex); - data.async_waiting = 0; - if (data.waiting_to_exit) { - pthread_cond_signal(&data.async_cv); - } - pthread_mutex_unlock(&data.async_mutex); - } - - /* If we are waiting for a sync point check if this is the response */ - /* we are waiting for */ - if (data.wait_for_sync == 1 && data.tag_to_sync != NULL) { - if (strstr(data.tag_to_sync, lrsp->mms_rsp_tid) != NULL) { - /* Got the response we are waiting for */ - free(data.tag_to_sync); - data.tag_to_sync = NULL; - data.wait_for_sync = 0; - } - } - - mms_free_rsp(rsp); - remove_cmd->cmd_rsp = NULL; - cli_destroy_cmd(remove_cmd); - pthread_mutex_unlock(&data. - cli_async_lock); - -} - -int -cli_need_arsp(char *buf) { - cli_cmd_t *cur_cmd; - cli_cmd_t *next; - - pthread_mutex_lock(&data. - cli_async_lock); - for (cur_cmd = mms_list_head(&data.async_list); - cur_cmd != NULL; - cur_cmd = next) { - next = mms_list_next(&data.async_list, cur_cmd); - if (strstr(buf, cur_cmd->cmd_task) != NULL) { - - pthread_mutex_unlock(&data. - cli_async_lock); - return (1); - } - } - - pthread_mutex_unlock(&data. - cli_async_lock); - return (0); -} - -static void -mms_client_signal_handler(int signo) -{ - if (signo == SIGPIPE) - data.exiting = 1; -} - -static void -mms_client_signal(int sig, void (*handler) ()) -{ - struct sigaction act, oact; - - memset(&act, 0, sizeof (act)); - act.sa_sigaction = handler; - sigemptyset(&act.sa_mask); - act.sa_flags = 0; - if (sig != SIGALRM) { - act.sa_flags |= SA_RESTART; - } - if (sigaction(sig, &act, &oact) < 0) { - (void) printf("Can't set signal handler for " - "signal %d: %s", sig, strerror(errno)); - exit(1); - } -} - -static void -mms_client_init() -{ - int rc; - int vers; - - mms_callbk_t err_callbk; - mms_rsp_callbk_t ev_callbk; - - mms_err_t mms_err; - char mms_ebuf[MMS_EBUF_LEN]; - - sigset_t new_mask; - sigset_t old_mask; - - sigemptyset(&new_mask); - sigaddset(&new_mask, SIGPIPE); - pthread_sigmask(SIG_BLOCK, &new_mask, &old_mask); - mms_client_signal(SIGPIPE, mms_client_signal_handler); - - err_callbk.mms_func = &mms_catch_reader; - err_callbk.mms_param = NULL; - - ev_callbk.mms_func = &client_handle_event; - ev_callbk.mms_param = NULL; - - if ((rc = mms_ainit(&sp, &vers, &err_callbk, - &ev_callbk)) != MMS_API_OK) { - printf("Error in mms_ainit(), %d, %s\n", rc, - mms_sym_code_to_str(rc)); - exit(1); - } - - if (vers != MMS_API_VERSION) { - printf("Mismatch of versions between client %d and API %d\n", - MMS_API_VERSION, vers); - exit(1); - } - - printf("Connect to MM:\n"); - printf(" Host: %s\n", data.host); - printf(" Port: %s\n", data.port); - printf(" Client: %s\n", data.client); - printf(" Instance: %s\n", data.instance); - printf(" Password:\n"); - printf(" Tag: %s\n", data.tag); - - -#ifdef MMS_OPENSSL - if (mms_ssl_client(&data.net, &data.ssl_data, &mms_err)) { - - mms_get_error_string(&mms_err, mms_ebuf, MMS_EBUF_LEN); - fprintf(stderr, "ssl init - %s\n", mms_ebuf); - - fprintf(stderr, "Couldn't init ssl\n"); - exit(1); - } -#endif /* MMS_OPENSSL */ - - - if ((rc = mms_hello(sp, data.host, data.port, - data.client, data.instance, data.tag, - data.password, data.mm_pass, data.ssl_data)) != MMS_API_OK) { - printf("Error in mms_hello(), %d, %s\n", rc, - mms_sym_code_to_str(rc)); - exit(1); - } - - if ((rc = pthread_attr_init(&cmd_attr)) != 0) { - printf("Error in attr_init, errno - %s\n", strerror(errno)); - exit(1); - } - - if ((rc = pthread_attr_setdetachstate(&cmd_attr, - PTHREAD_CREATE_DETACHED)) != 0) { - printf("Error in attr setdetachstate, errno - %s\n", - strerror(errno)); - pthread_attr_destroy(&cmd_attr); - exit(1); - } - if ((rc = pthread_attr_init(&event_attr)) != 0) { - printf("Error in attr_init, errno - %s\n", strerror(errno)); - exit(1); - } - - if ((rc = pthread_attr_setdetachstate(&event_attr, - PTHREAD_CREATE_DETACHED)) != 0) { - printf("Error in attr setdetachstate, errno - %s\n", - strerror(errno)); - pthread_attr_destroy(&event_attr); - exit(1); - } - - printf("Client API initialized\n"); - -} - - - -void -set_default_connect_info() { - - if (data.net_file != NULL) { - /* Net file was passed */ - if (data.net.cli_host) - data.host = - mms_strapp(data.host, - data.net.cli_host); - if (data.net.cli_port) - data.port = - mms_strapp(data.port, - data.net.cli_port); - if (data.net.cli_name) - data.client = - mms_strapp(data.client, - data.net.cli_name); - if (data.net.cli_inst) - data.instance = - mms_strapp(data.instance, - data.net.cli_inst); - if (data.net.cli_pass) - data.password = - mms_strapp(data.password, - data.net.cli_pass); - if (data.net.mm_pass) - data.mm_pass = - mms_strapp(data.mm_pass, - data.net.mm_pass); - - } - - if (data.host == NULL) { - data.host = mms_strapp(data.host, "localhost"); - } - if (data.port == NULL) { - data.port = mms_strapp(data.port, "7151"); - } - if (data.client == NULL) { - data.client = mms_strapp(data.client, "MMS"); - } - if (data.instance == NULL) { - data.instance = mms_strapp(data.instance, "admin"); - } - - if (data.tag == NULL) { - data.tag = mms_strapp(data.tag, "mms_client-pid=%d", - getpid()); - } -} - -void -usage(void) -{ - fprintf(stderr, "Usage: mms_client\n"); - fprintf(stderr, "-h Help\n"); - fprintf(stderr, "-f File name\n"); - fprintf(stderr, "-A Application name\n"); - fprintf(stderr, "-i Instance name\n"); - fprintf(stderr, "-s System name (MM_Host_Name)\n"); - fprintf(stderr, "-P Password File\n"); - fprintf(stderr, "-p Port\n"); - fprintf(stderr, "-t Tag\n"); - fprintf(stderr, "-n Network config file\n"); - exit(2); -} - -int -cli_parse_cmd(cli_cmd_t *cmd) { - int rc; - mms_list_t err_list; - mms_par_err_t *err = NULL; - rc = mms_mmp_parse(&cmd->cmd_root, &err_list, cmd->cmd_text); - mms_list_foreach(&err_list, err) { - printf("error parse, " - "line %d, col %d, near token \"%s\", err code %d, %s\n", - err->pe_line, - err->pe_col, - err->pe_token, - err->pe_code, - err->pe_msg); - } - mms_pe_destroy(&err_list); - if (rc) { - return (1); - } - return (0); -} - -int -use_namevalue(cli_cmd_t *command) { - mms_par_node_t *cmd; - mms_par_node_t *reportmode; - - cmd = command->cmd_root; - - if ((reportmode = mms_pn_lookup(cmd, "reportmode", - MMS_PN_CLAUSE, 0)) != NULL) { - if (mms_pn_lookup(reportmode, "namevalue", - NULL, 0) != NULL) { - if (command->cmd_is_sync == 1) { - data.sync_has_namevalue = 1; - } - return (1); - } - } - - if (command->cmd_is_sync == 1) { - data.sync_has_namevalue = 0; - } - return (0); -} - -char * -cli_return_task(cli_cmd_t *cmd) { - mms_par_node_t *task_clause = NULL; - mms_par_node_t *work = NULL; - mms_par_node_t *task_str = NULL; - - if (cmd->cmd_root == NULL) { - printf("cli_return_task: cmd->cmd_root is NULL\n"); - exit(1); - } - task_clause = mms_pn_lookup(cmd->cmd_root, "task", MMS_PN_CLAUSE, - &work); - if (task_clause == NULL) { - return (NULL); - } - task_str = mms_pn_lookup(task_clause, NULL, MMS_PN_STRING, &work); - if (task_str == NULL) { - return (NULL); - } - - if (cmd->cmd_task == NULL) { - cmd->cmd_task = mms_strapp(cmd->cmd_task, - task_str->pn_string); - } - /* Also set namevalue for printing later */ - cmd->cmd_namevalue = use_namevalue(cmd); - - return (task_str->pn_string); -} - -void -cli_send_sync(cli_cmd_t *cmd) { - - if (cli_return_task(cmd) == NULL) { - printf("not task found in:\n%s\n", - cmd->cmd_text); - exit(1); - } - - printf("-----------------------\n"); - printf("* Send Sync:\n"); - printf("%s\n", cmd->cmd_text); - printf("-----------------------\n"); - - if (mms_send_cmd(sp, cmd->cmd_text, - &cmd->cmd_rsp) != MMS_API_OK) { - printf("error show command failed\n"); - exit(1); - } - printf("* Sync Sent\n"); - fflush(stdout); - - - mms_client_handle_rsp(cmd->cmd_rsp); - mms_free_rsp(cmd->cmd_rsp); - cmd->cmd_rsp = NULL; - -} - -void -cli_send_async(cli_cmd_t *cmd) { - - if (cli_return_task(cmd) == NULL) { - printf("not task found in:\n%s\n", - cmd->cmd_text); - exit(1); - } - - printf("-----------------------\n"); - printf("@ Send Async:\n"); - printf("%s\n", cmd->cmd_text); - printf("-----------------------\n"); - - if (mms_send_acmd(sp, cmd->cmd_text, - mms_client_handle_async_rsp, - &cmd->cmd_rsp) != MMS_API_OK) { - printf("error async command failed\n"); - exit(1); - } - printf("@ Async Sent\n"); - fflush(stdout); -} - -static void -cli_print_events() { - char cmd_buf[BUFSZ]; - - printf("press any key to continue with the script\n\n"); - fflush(stdout); - (void) fgets(cmd_buf, BUFSZ, stdin); -} - -void -cli_mmp_prompt() { - char cmd_buf[BUFSZ]; - cli_cmd_t *command1 = NULL; - int go = 0; - - printf("MMP prompt, enter \"q\" to quit" \ - " and continue\n"); - - fflush(stdout); - - go = 1; - while (go) { - if (command1 == NULL) { - command1 = cli_alloc_cmd(); - } - - printf("\n>"); - (void) fgets(cmd_buf, BUFSZ, stdin); - if (cmd_buf[0] == 'q') { - go = 0; - if (command1->cmd_text != NULL) { - memset(command1->cmd_text, - 0, - sizeof (command1->cmd_text)); - } - cli_destroy_cmd(command1); - command1 = NULL; - continue; - } - command1->cmd_text = - mms_strapp(command1->cmd_text, cmd_buf); - - - if (strrchr(command1->cmd_text, ';') != NULL) { - if (cli_parse_cmd(command1)) { - printf("could not " - "parse command, " - "check syntax\n"); - memset(cmd_buf, 0, - sizeof (cmd_buf)); - cli_destroy_cmd(command1); - command1 = NULL; - - } else { - /* Command is sync */ - command1->cmd_is_sync = 1; - cli_send_sync(command1); - cli_destroy_cmd(command1); - command1 = NULL; - } - } - } -} - - -void -cli_print_async() { - - cli_cmd_t *cur_cmd; - cli_cmd_t *next; - - - pthread_mutex_lock(&data. - cli_async_lock); - printf("Outstanding async commands:\n"); - for (cur_cmd = mms_list_head(&data.async_list); - cur_cmd != NULL; - cur_cmd = next) { - next = mms_list_next(&data.async_list, cur_cmd); - if (cur_cmd->cmd_task != NULL) { - - printf(" %s\n", cur_cmd->cmd_task); - - } - } - - pthread_mutex_unlock(&data. - cli_async_lock); - -} - - -int -main(int argc, char **argv) -{ - int c; - - int is_async = 0; - - cli_cmd_t *command1; - - FILE *fp = NULL; - FILE *pass_fp = NULL; - char buf[BUFSZ]; - char *cur_cmd_text = NULL; - char *shell_cmd = NULL; - int prompt_only = 0; - - const char *optflags = "A:i:s:p:t:f:n:hP:"; - char *prompt = NULL; - char *corename; - - int i = 0; - - command1 = NULL; - - data.host = NULL; - data.port = NULL; - data.client = NULL; - data.instance = NULL; - data.password = NULL; - data.tag = NULL; - data.tag_to_sync = NULL; - - data.ssl_data = NULL; - data.net_file = NULL; - - data.exiting = 0; - data.async_waiting = 0; - data.wait_for_sync = 0; - data.sync_has_namevalue = 0; - data.waiting_to_exit = 0; - pthread_mutex_init(&data.async_mutex, NULL); - pthread_cond_init(&data.async_cv, NULL); - - - if (mms_set_core(MMS_CORES_DIR, NULL)) { - fprintf(stderr, "core setup %s\n", strerror(errno)); - fprintf(stderr, "Run as ROOT for cores\n"); - } - - corename = mms_strapp(NULL, "core.mmsclient"); - /* Check to see how many core files exist */ - if (mms_man_cores(MMS_CORES_DIR, corename)) { - fprintf(stderr, "core management %s\n", strerror(errno)); - fprintf(stderr, "Run as ROOT for cores\n"); - } - free(corename); - - pthread_mutex_init(&data.cli_async_lock, NULL); - - /* real optarg processing */ - while ((c = getopt(argc, argv, optflags)) != EOF) { - switch (c) { - case 'A': - data.client = mms_strapp(data.client, optarg); - break; - case 'i': - data.instance = mms_strapp(data.instance, optarg); - break; - case 's': - data.host = mms_strapp(data.host, optarg); - break; - case 'P': - if ((pass_fp = fopen(optarg, "r")) == NULL) { - fprintf(stderr, "error opening file %s\n", - optarg); - return (1); - } - break; - case 'p': - data.port = mms_strapp(data.port, optarg); - break; - case 't': - data.tag = mms_strapp(data.tag, optarg); - break; - case 'f': - if ((fp = fopen(optarg, "r")) == NULL) { - fprintf(stderr, "error opening file %s\n", - optarg); - return (1); - } - break; - case 'n': - data.net_file = mms_strapp(data.net_file, optarg); - break; - case 'h': - usage(); - default: - usage(); - } - } - - if (fp == NULL) { - prompt_only = 1; - } - - - /* Read the network config file */ - (void) memset(&data.net, 0, sizeof (mms_network_cfg_t)); - if (data.net_file != NULL) { - printf("Using net config file, %s\n", - data.net_file); - if (mms_net_cfg_read(&data.net, data.net_file)) { - fprintf(stderr, "Unable to get net info from " - "network config file, %s\n", data.net_file); - exit(1); - } - } - - /* init the async command list */ - mms_list_create(&data.async_list, sizeof (cli_cmd_t), - offsetof(cli_cmd_t, cli_cmd_next)); - - /* Set defaults for connect */ - set_default_connect_info(); - - /* Get password */ - if (data.net_file == NULL) { - - if (pass_fp == NULL) { - /* Prompt for password */ - prompt = mms_strapp(prompt, "MM Password for %s %s : ", - data.client, data.instance); - data.password = getpassphrase(prompt); - free(prompt); - } else { - /* Read pass word from pass_fp */ - if (fgets(buf, sizeof (buf), pass_fp) == NULL) { - fprintf(stderr, - "Unable to read password from passfile\n"); - exit(1); - } - for (i = 0; i < sizeof (buf); i++) { - if ((buf[i] == NULL) || - (isspace(buf[i]) && - !isblank(buf[i]))) { - buf[i] = '\0'; - break; - } - } - data.password = mms_strapp(data.password, buf); - } - } else if (pass_fp != NULL) { - fprintf(stdout, - "WARNING: -P and -n used, " - "using password in network config file\n"); - } - - mms_client_init(); - - /* Read file and send commands, dont exit if an async command */ - /* is waiting for a response */ - - if (prompt_only) { - while ((!data.exiting) || - data.async_waiting) { - cli_mmp_prompt(); - data.exiting = 1; - } - } - - while ((!data.exiting) || - data.async_waiting) { - if (fgets(buf, sizeof (buf), fp) == NULL) { - data.exiting = 1; - break; - } - - /* If this is a blank line or a comment */ - if (buf[0] == '#' || buf[0] == '\n') { - if (buf[0] == '#') - printf("%s\n", - buf); - continue; } - - /* client should wait and print incomming events */ - if (buf[0] == '%') { - cli_print_events(); - } - /* execute a shell command */ - if (buf[0] == '!') { - shell_cmd = &buf[1]; - printf("Execute: \n %s\n", shell_cmd); - system(shell_cmd); - printf("Done\n"); - shell_cmd = NULL; - continue; - } - - /* Interactive MMP prompt */ - if (buf[0] == '>') { - cli_mmp_prompt(); - continue; - } - - /* The next command will be async */ - if (buf[0] == '@') { - is_async = 1; - continue; } - - /* client should wait for the response */ - /* to this command */ - if (buf[0] == '$') { - printf("^^^^^^^^^^^^^^^^^^^^^^^\n"); - printf("sync point: \n %s\n", - buf); - printf("^^^^^^^^^^^^^^^^^^^^^^^\n"); - if (cli_need_arsp(buf)) { - - pthread_mutex_lock(&data. - cli_async_lock); - data.wait_for_sync = 1; - data.tag_to_sync = - mms_strapp(data.tag_to_sync, - buf); - - pthread_mutex_unlock(&data. - cli_async_lock); - while (data.wait_for_sync) { - } - - printf("=======================\n"); - printf("synced with tag : %s\n", - buf); - printf("=======================\n"); - - - } else { - printf("already got " - "response for %s", - buf); - } - continue; } - - /* This is a command */ - - cur_cmd_text = mms_strapp(cur_cmd_text, buf); - if (strrchr(cur_cmd_text, ';') == NULL) { - continue; } - - command1 = cli_alloc_cmd(); - command1->cmd_text = mms_strapp(command1->cmd_text, - cur_cmd_text); - - if (cli_parse_cmd(command1)) { - printf("could not parse command, " - "check syntax\n\n%s\n", - command1->cmd_text); - exit(1); - } - - if (is_async) { - /* Command is async */ - pthread_mutex_lock(&data.async_mutex); - data.async_waiting = 1; - pthread_mutex_unlock(&data.async_mutex); - command1->cmd_is_sync = 0; - - pthread_mutex_lock(&data. - cli_async_lock); - mms_list_insert_tail(&data.async_list, - command1); - pthread_mutex_unlock(&data. - cli_async_lock); - cli_send_async(command1); - is_async = 0; - command1 = NULL; - } else { - /* Command is sync */ - command1->cmd_is_sync = 1; - cli_send_sync(command1); - cli_destroy_cmd(command1); - command1 = NULL; - } - - free(cur_cmd_text); - cur_cmd_text = NULL; - } - - /* Wait for any remaining async commands */ - pthread_mutex_lock(&data.async_mutex); - if (data.async_waiting == 1) { - data.waiting_to_exit = 1; - pthread_cond_wait(&data.async_cv, - &data.async_mutex); - } - pthread_mutex_unlock(&data.async_mutex); - printf("All Commands finished\n"); - - return (0); -} diff --git a/usr/src/cmd/mms/utility/mms_client/i386/Makefile b/usr/src/cmd/mms/utility/mms_client/i386/Makefile deleted file mode 100644 index 732f299da3..0000000000 --- a/usr/src/cmd/mms/utility/mms_client/i386/Makefile +++ /dev/null @@ -1,27 +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 $(SRC)/cmd/Makefile.cmd -include ../Makefile.com diff --git a/usr/src/cmd/mms/utility/mms_client/sparc/Makefile b/usr/src/cmd/mms/utility/mms_client/sparc/Makefile deleted file mode 100644 index 732f299da3..0000000000 --- a/usr/src/cmd/mms/utility/mms_client/sparc/Makefile +++ /dev/null @@ -1,27 +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 $(SRC)/cmd/Makefile.cmd -include ../Makefile.com diff --git a/usr/src/cmd/mms/wcr/Makefile b/usr/src/cmd/mms/wcr/Makefile deleted file mode 100644 index 9912e2b4e7..0000000000 --- a/usr/src/cmd/mms/wcr/Makefile +++ /dev/null @@ -1,28 +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. -# - -SUBDIRS = $(MACH) - -include ../Makefile.subdirs diff --git a/usr/src/cmd/mms/wcr/Makefile.com b/usr/src/cmd/mms/wcr/Makefile.com deleted file mode 100644 index 8682c5c942..0000000000 --- a/usr/src/cmd/mms/wcr/Makefile.com +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -SRCS = watcher.c - -.KEEP_STATE: -.SUFFIXES: - -PROG = mmswcr - -OBJS = $(SRCS:%.c=%.o) -lint_SRCS = $(SRCS:%.c=%.ln) - -include ../../../Makefile.cmd - -ROOTCMDDIR= $(ROOT)/lib/svc/method - -CPPFLAGS += -DMMS_OPENSSL -D_REENTRANT -CPPFLAGS += -I. -I../common -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/lib/mms/mms/common -CPPFLAGS += -I$(SRC)/uts/common/io/mms/dmd - -CFLAGS += $(CTF_FLAGS) $(CC_VERBOSE) - -LDLIBS += -lc -lcontract -LDLIBS += -L$(SRC)/lib/mms/mms/$(MACH) -lmms - -.NO_PARALLEL: -.PARALLEL: $(OBJS) $(lint_SRCS) - -C99MODE= $(C99_ENABLE) - -LIBSVC = $(ROOT)/lib/svc/method - -FILES += $(ROOTBIN)/mmsssi.sh - -all: $(PROG) - -$(PROG): $(OBJS) - $(LINK.c) $(OBJS) -o $@ $(LDLIBS) - $(CTFMERGE) -L VERSION -o $@ $(OBJS) - $(POST_PROCESS) - -%.o: ../common/%.c - $(COMPILE.c) $< - $(CTFCONVERT_O) - -clean: - $(RM) $(OBJS) $(lint_SRCS) - -lint: $(lint_SRCS) - -%.ln: ../common/%.c - $(LINT.c) -c $< - -install: all $(ROOTCMD) $(FILES) - -include ../../../Makefile.targ - -$(ROOTBIN)/%: ../common/% - $(INS.file) - diff --git a/usr/src/cmd/mms/wcr/common/mmsssi.sh b/usr/src/cmd/mms/wcr/common/mmsssi.sh deleted file mode 100644 index 0ac2166991..0000000000 --- a/usr/src/cmd/mms/wcr/common/mmsssi.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/csh -f -# -# 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 script is used by the watcher daemon to keep a copy of ssi running. -# If this script exits, the daemon will start another. If the site -# for whatever reason, has its own version of ssi, then this script -# should be modified to wait for a SIGTERM signal and then exit. SIGTERM is -# the signal sent by the daemon to stop the process. -# -# - -/usr/sbin/ping ${CSI_HOSTNAME} >&! /dev/null -if ( $status != "0" ) then - echo "ACSLS server ${CSI_HOSTNAME} IS UNPINGABLE" >> /var/log/mms/wcr/wcr.debug - exit 1 -endif -# -# -setenv CSI_TCP_RPCSERVICE TRUE -setenv CSI_UDP_RPCSERVICE TRUE -setenv CSI_CONNECT_AGETIME 172800 -setenv CSI_RETRY_TIMEOUT 4 -setenv CSI_RETRY_TRIES 5 -setenv ACSAPI_PACKET_VERSION 4 -exec ${MMS_SSI_PATH}/ssi $1 ${ACSAPI_SSI_SOCKET} 23 ; diff --git a/usr/src/cmd/mms/wcr/common/watcher.c b/usr/src/cmd/mms/wcr/common/watcher.c deleted file mode 100644 index 1c1d7ae078..0000000000 --- a/usr/src/cmd/mms/wcr/common/watcher.c +++ /dev/null @@ -1,3974 +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 <limits.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <sys/time.h> -#include <sys/resource.h> -#include <syslog.h> -#include <signal.h> -#include <unistd.h> -#include <stropts.h> -#include <fcntl.h> -#include <sys/stat.h> -#include <sys/mkdev.h> -#include <string.h> -#include <errno.h> -#include <stdlib.h> -#include <stdio.h> -#include <dmd_impl.h> -#include <mms_list.h> -#include <mms_network.h> -#include "mms_parser.h" -#include <mms_trace.h> -#include <netdb.h> -#include <watcher_impl.h> -#include <dirent.h> -#include <procfs.h> -#include <libscf.h> -#include <libcontract.h> -#include <sys/ctfs.h> -#include <sys/contract/process.h> -#include <host_ident.h> -#include <mms_cores.h> -#include <mms_cfg.h> -#include <net_cfg_service.h> -#include <mms_strapp.h> - -static char *_SrcFile = __FILE__; -int wcr_debug = MMS_SEV_DEVP; - -wcr_wka_t wka; - - -typedef void sigfunc(int, siginfo_t *, void *); -void wcr_chk_child_death(wcr_wka_t *wka); - -/* - * wcr_free_DM_LM - * - * Parameters: - * - DM_LM : ptr to wcr_DM_LM_t - * - * Free's memory inside a wcr_DM_LM_t - * sets ptrs = NULL - * caller should free struct itself if desired - * - * Return Values: - * none - */ -void -wcr_free_DM_LM(wcr_DM_LM_t *DM_LM_dev) -{ - if (DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_DM_name != NULL) { - free(DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_DM_name); - DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_DM_name = NULL; - - } - if (DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_drive_name != NULL) { - free(DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_drive_name); - DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_drive_name = NULL; - } - if (DM_LM_dev-> - wcr_host_name != NULL) { - free(DM_LM_dev-> - wcr_host_name); - DM_LM_dev-> - wcr_host_name = NULL; - } - if (DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_dev_tar_path != NULL) { - free(DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_dev_tar_path); - DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_dev_tar_path = NULL; - } - if (DM_LM_dev-> - wcr_disabled != NULL) { - free(DM_LM_dev-> - wcr_disabled); - DM_LM_dev-> - wcr_disabled = NULL; - } - if (DM_LM_dev-> - wcr_DM_LM_union.wcr_LM. - wcr_LM_name != NULL) { - free(DM_LM_dev-> - wcr_DM_LM_union.wcr_LM. - wcr_LM_name); - DM_LM_dev-> - wcr_DM_LM_union.wcr_LM. - wcr_LM_name = NULL; - } - if (DM_LM_dev-> - wcr_DM_LM_union.wcr_LM. - wcr_library_name != NULL) { - free(DM_LM_dev-> - wcr_DM_LM_union.wcr_LM. - wcr_library_name); - DM_LM_dev-> - wcr_DM_LM_union.wcr_LM. - wcr_library_name = NULL; - } - if (DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_dev_mgr_path != NULL) { - free(DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_dev_mgr_path); - DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_dev_mgr_path = NULL; - } - -} - - -/* - * wcr_alloc_DM_LM - * - * Parameters: - * none - * - * allocate a new wcr_DM_LM_t struct - * initialize all pointers - * - * Return Values: - * NULL : if alloc failed - * ptr to new wcr_DM_LM_t : if alloc is successful - * - */ -wcr_DM_LM_t * -wcr_alloc_DM_LM() -{ - wcr_DM_LM_t *DM_LM_dev; - - DM_LM_dev = - (wcr_DM_LM_t *)malloc(sizeof (wcr_DM_LM_t)); - if (DM_LM_dev == NULL) { - mms_trace(MMS_ERR, - "Unable to mallor wcr_DM_LM_t: %s", - strerror(errno)); - return (NULL); - } - memset(DM_LM_dev, 0, sizeof (wcr_DM_LM_t)); - - /* Initialize pointers */ - - DM_LM_dev->wcr_DM_LM_union.wcr_DM. - wcr_DM_name = NULL; - DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_drive_name = NULL; - DM_LM_dev-> - wcr_host_name = NULL; - DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_dev_tar_path = NULL; - DM_LM_dev-> - wcr_disabled = NULL; - DM_LM_dev-> - wcr_DM_LM_union.wcr_LM. - wcr_LM_name = NULL; - DM_LM_dev-> - wcr_DM_LM_union.wcr_LM. - wcr_library_name = NULL; - DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_dev_mgr_path = NULL; - - return (DM_LM_dev); -} - - -/* - * wcr_ssi_is_running() - * checks to see if ssi process (prog) with owner (user) is running - * returns true if the process is running, false if it is not. - * passes back the pid of the running process - */ - -int -wcr_ssi_is_running(char *prog, int *pid, int ssi_port) -{ - int psdata; - DIR *procdir; - struct dirent *procdirp; - psinfo_t p; - char *fullpath; - char *ssiarg; - char *argcpy; - int i; - - mms_trace(MMS_DEVP, - "wcr_ssi_is_running: " - "check if %s is running on port %d", - prog, ssi_port); - - if ((procdir = opendir("/proc")) == NULL) { - mms_trace(MMS_ERR, "opendir failure: %s\n", strerror(errno)); - return (0); - } - - /* Look for the ssi process psinfo file */ - while ((procdirp = readdir(procdir)) != NULL) { - if (strcmp(procdirp->d_name, ".") == 0 || - strcmp(procdirp->d_name, "..") == 0) - continue; - else { - fullpath = - mms_strapp(NULL, - "/proc/%s/psinfo", procdirp->d_name); - if ((psdata = open(fullpath, O_RDONLY)) == -1) - mms_trace(MMS_ERR, - "open failure: %s\n", strerror(errno)); - read(psdata, (void *) &p, sizeof (p)); - - if (strcmp(p.pr_fname, "ssi") == 0) { - /* ssi found, get the ssi's port */ - argcpy = strdup(p.pr_psargs); - ssiarg = strtok(argcpy, " "); - for (i = 0; i < 2; i++) - ssiarg = strtok(NULL, " "); - if (atoi(ssiarg) == ssi_port) { - *pid = atoi(procdirp->d_name); - close(psdata); - closedir(procdir); - free(fullpath); - return (1); - } - } - close(psdata); - } - } - - /* ssi wasn't found running on the port */ - close(psdata); - closedir(procdir); - free(fullpath); - mms_trace(MMS_DEVP, "wcr_ssi_is_running: " - "didn't find a ssi running"); - - return (0); -} - - -/* - * Initialize message logging. - */ -static void -wcr_init_log() -{ - if (mms_trace_open(WCR_TRACE_FILE, MMS_ID_WCR, wcr_debug, -1, 1, 1)) { - mms_trace(MMS_NOTICE, "Unable to open mms_trace file \"%s\"", - WCR_TRACE_FILE); - } -} - -/* - * wcr_init_wka() - * -Initializes the watcher's work area. - * -Creates 2 lists, 1 list of wcr_dev type - * and 1 list of wcr_wka_DM_LM type - * -Saves the first device ordinal - * -Saves the host name of this watcher's host - */ - -void -wcr_init_wka(wcr_wka_t *wka) -{ - memset(wka, 0, sizeof (wcr_wka_t)); - - mms_list_create(&wka->wcr_wka_DM_LM_list, sizeof (wcr_DM_LM_t), - offsetof(wcr_DM_LM_t, wcr_DM_LM_next)); - - mms_list_create(&wka->wcr_old_DM_LM_list, sizeof (wcr_DM_LM_t), - offsetof(wcr_DM_LM_t, wcr_DM_LM_next)); - - mms_list_create(&wka->wcr_events, sizeof (wcr_event_t), - offsetof(wcr_event_t, wcr_event_next)); - - mms_list_create(&wka->wcr_net_LM_list, sizeof (wcr_net_LM_t), - offsetof(wcr_net_LM_t, wcr_net_LM_next)); - - wka->wcr_wka_next_ordinal = WCR_FIRST_DEV_ORDINAL; - gethostname(wka->wcr_host_name, MAXHOSTNAMELEN); - - wka->wcr_mms_conn.mms_fd = -1; - - wka->wcr_cfd = -1; -} - -void -wcr_net_cfg_free(mms_network_cfg_t *net_cfg, mms_list_t **mm_list) -{ - wcr_MM_t *mm; - wcr_MM_t *next_mm; - - mms_net_cfg_free(net_cfg); - (void) memset(net_cfg, 0, sizeof (mms_network_cfg_t)); - - if (mm_list && *mm_list) { - for (mm = mms_list_head(*mm_list); - mm != NULL; - mm = next_mm) { - next_mm = mms_list_next(*mm_list, mm); - mms_list_remove(*mm_list, mm); - free(mm); - } - mms_list_destroy(*mm_list); - free(*mm_list); - *mm_list = NULL; - } -} - -/* - * Read watcher network configuration file - */ -int -wcr_net_cfg_read(mms_network_cfg_t *net_cfg, mms_list_t **mm_list) -{ - wcr_MM_t *mm = NULL; - char *p = NULL; - char *q = NULL; - - *mm_list = NULL; - if (mms_net_cfg_service(net_cfg, "watcher", "MMP", "1.0")) { - mms_trace(MMS_ERR, "net config read"); - mms_net_cfg_free(net_cfg); - return (1); - } - - *mm_list = (mms_list_t *)calloc(1, sizeof (mms_list_t)); - mms_list_create(*mm_list, sizeof (wcr_MM_t), - offsetof(wcr_MM_t, wcr_MM_next)); - - p = net_cfg->cli_host; - while (p != NULL) { - if (q = strchr(p, ',')) { - *q = '\0'; - } - mms_trace(MMS_DEVP, "mm host %s port %s", p, net_cfg->cli_port); - mm = (wcr_MM_t *)calloc(1, sizeof (wcr_MM_t)); - (void) snprintf(mm->wcr_mm_host, MAXHOSTNAMELEN, "%s", p); - mms_list_insert_tail(*mm_list, mm); - p = q; - if (p != NULL) { - p++; - } - } - return (0); -} - -/* - * Initialize the watcher - * This requires that the driver dmd must have been properly installed. - * The config file dmd.conf has only one entry for instance 0. - * -Makes call to initialize the watcher's workarea - * -Fork and exit from parent to become daemon - * -Fill in wka_net_cfg struct with values from watcher's - * network config file - * -Open the watcher device - */ -int -wcr_init_watcher(wcr_wka_t *wka) -{ - int fd; - int mms_trace_fd; - pid_t pid; - int i; - mms_err_t err; - char ebuf[MMS_EBUF_LEN]; - char *corename; - - /* - * Init work area - */ - wcr_init_wka(wka); - - /* - * Init message logging - */ - wcr_init_log(); - - /* - * Cores dir - */ - if (mms_set_core(MMS_CORES_DIR, NULL)) { - mms_trace(MMS_ERR, "core setup %s", strerror(errno)); - } - - corename = mms_strapp(NULL, "core.mmswcr"); - /* Check to see how many core files exist */ - if (mms_man_cores(MMS_CORES_DIR, corename)) { - mms_trace(MMS_ERR, - "wcr_init_watcher: mms_man_cores failed %s", - strerror(errno)); - } - free(corename); - - /* - * Read config before becoming smf daemon - */ - if (wcr_net_cfg_read(&wka->wcr_wka_net_cfg, &wka->wcr_wka_MM_list)) { - mms_trace(MMS_ERR, "Read network configuration failed"); - exit(SMF_EXIT_ERR_CONFIG); - } - - /* - * Become a smf daemon - */ - if (pid = fork()) { - /* - * Parent process - */ - if (pid == (pid_t)(-1)) { - mms_trace(MMS_ERR, "fork - %s\n", strerror(errno)); - exit(1); - } else { - /* Successfully forked, parent exits */ - exit(0); - } - } - - /* - * In child. - */ - - /* - * Close all opened files except mms_trace - */ - mms_trace_fd = mms_trace_get_fd(); - for (i = 0; i < OPEN_MAX; i++) { - if (i != mms_trace_fd) - close(i); - } - - /* - * Become session leader - */ - setsid(); - - /* - * Clear file mode create mask - */ - umask(0); - - /* - * Open the watcher device - */ - fd = open(WCR_WATCHER, O_RDWR); - - if (fd < 0) { - if (errno == EBUSY) { - mms_trace(MMS_ERR, "A watcher is already active"); - return (1); - } else { - mms_trace(MMS_ERR, "Unable to open watcher device: %s", - strerror(errno)); - return (1); - } - } - -#ifdef MMS_OPENSSL - if (mms_ssl_client(&wka->wcr_wka_net_cfg, &wka->wcr_ssl_data, &err)) { - mms_get_error_string(&err, ebuf, MMS_EBUF_LEN); - mms_trace(MMS_ERR, "ssl init - %s", ebuf); - return (1); - } -#endif /* MMS_OPENSSL */ - - return (0); - - -} - - - -/* - * Initiate a session with MMS - * -Use mms_mmconnect to connect a mm from a mm list - * -Store the file descriptor - */ - -int -wcr_init_session(wcr_wka_t *wka) -{ - int err; - char *tag = NULL; - wcr_MM_t *mm = NULL; - - /* Get first mm from list */ - if (wka->wcr_wka_MM_list == NULL || - (mm = mms_list_head(wka->wcr_wka_MM_list)) == NULL || - mm->wcr_mm_host == NULL) { - mms_trace(MMS_ERR, "empty mm list"); - exit(1); - } - - /* Connect to MM */ - wka->wcr_connected = 0; - while (!wka->wcr_connected) { - if (wka->wcr_wka_sighup) { - mms_trace(MMS_DEVP, "refresh mm list"); - return (1); - } - wka->wcr_wka_net_cfg.cli_host = mm->wcr_mm_host; - mms_trace(MMS_DEVP, "mm host %s port %s\n", - wka->wcr_wka_net_cfg.cli_host, - wka->wcr_wka_net_cfg.cli_port); - if (mms_mmconnect(&wka->wcr_wka_net_cfg, - wka->wcr_ssl_data, - &wka->wcr_mms_conn, &err, tag)) { - mms_get_error_string(&wka->wcr_mms_conn.mms_err, - wka->wcr_mms_ebuf, MMS_EBUF_LEN); - - mms_trace(MMS_ERR, "Watcher failed to connect " - "to %s MM: (%d) %s", - mm->wcr_mm_host, - err, - wka->wcr_mms_ebuf); - - /* Get next mm from list */ - mm = mms_list_next(wka->wcr_wka_MM_list, mm); - if (mm == NULL) { - /* Reached end of mm list, start over */ - mm = mms_list_head(wka->wcr_wka_MM_list); - } - wcr_chk_child_death(wka); - sleep(2); - } else { - wka->wcr_connected = 1; - mms_trace(MMS_DEVP, "connected"); - } - } - strcpy(wka->wcr_mm_host, wka->wcr_wka_net_cfg.cli_host); - return (0); -} - -void -/* LINTED: wka may be used in the future */ -wcr_build_struct(mms_par_node_t *attr, wcr_DM_LM_t *DM_LM_dev, wcr_wka_t *wka) -{ - - mms_par_node_t *name; - mms_par_node_t *value; - - mms_list_pair_foreach(&attr->pn_arglist, name, - value) { - if (strcmp("DMName", - name->pn_string) == 0) { - /* mms_trace(MMS_NOTICE,"*SET DMName*\n"); */ - DM_LM_dev->wcr_DM_flag = - 1; - DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_DM_name = mms_strapp(DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_DM_name, value->pn_string); - } - if (strcmp("DriveName", - name->pn_string) == 0) { - /* mms_trace(MMS_NOTICE, "*SET DriveName*\n"); */ - DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_drive_name = mms_strapp(DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_drive_name, value->pn_string); - } - if (strcmp("DMTargetHost", - name->pn_string) == 0) { - /* mms_trace(MMS_NOTICE, "*SET Hostname*\n"); */ - DM_LM_dev-> - wcr_host_name = mms_strapp(DM_LM_dev-> - wcr_host_name, - value->pn_string); - } - if (strcmp("DMTargetPath", - name->pn_string) == 0) { - /* mms_trace(MMS_NOTICE, "*SET Path*\n"); */ - DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_dev_tar_path = mms_strapp(DM_LM_dev-> - wcr_DM_LM_union.wcr_DM. - wcr_dev_tar_path, - value->pn_string); - } - if (strcmp("DMDisabled", - name->pn_string) == 0) { - /* mms_trace(MMS_NOTICE, "*SET DMDisabled*\n"); */ - DM_LM_dev-> - wcr_disabled = mms_strapp(DM_LM_dev-> - wcr_disabled, - value->pn_string); - } - if (strcmp("LMName", - name->pn_string) == 0) { - /* mms_trace(MMS_NOTICE, "*SET LMName*\n"); */ - DM_LM_dev->wcr_DM_flag = - 0; - DM_LM_dev-> - wcr_DM_LM_union.wcr_LM. - wcr_LM_name = mms_strapp(DM_LM_dev-> - wcr_DM_LM_union.wcr_LM. - wcr_LM_name, - value->pn_string); - } - if (strcmp("LMTargetHost", - name->pn_string) == 0) { - /* mms_trace(MMS_NOTICE, "*SET Hostname*\n"); */ - DM_LM_dev-> - wcr_host_name = mms_strapp(DM_LM_dev-> - wcr_host_name, - value->pn_string); - } - if (strcmp("LibraryName", - name->pn_string) == 0) { - /* mms_trace(MMS_NOTICE, "*SET LibraryName*\n"); */ - DM_LM_dev-> - wcr_DM_LM_union.wcr_LM. - wcr_library_name = mms_strapp(DM_LM_dev-> - wcr_DM_LM_union.wcr_LM. - wcr_library_name, - value->pn_string); - } - if (strcmp("LMDisabled", - name->pn_string) == 0) { - /* mms_trace(MMS_NOTICE, "*SET LMDisabled*\n"); */ - DM_LM_dev-> - wcr_disabled = mms_strapp(DM_LM_dev-> - wcr_disabled, - value->pn_string); - } - } -} - -/* - * wcr_attrlist() - * -This function takes a parsed node tree of the attrlist portion of a - * resonse from MM and adds the correct struct obj to the - * wcr_wka_DM_LM_list in the watcher work area - */ - -void -wcr_attrlist(mms_par_node_t *cmd, wcr_wka_t *wka) -{ - - - mms_par_node_t *text; - mms_par_node_t *attr; - mms_par_node_t *tw; - mms_par_node_t *work; - wcr_DM_LM_t *DM_LM_dev; - - tw = 0; - for (text = mms_pn_lookup(cmd, "text", MMS_PN_CLAUSE, &tw); - text != NULL; - text = mms_pn_lookup(cmd, "text", MMS_PN_CLAUSE, &tw)) { - - - work = NULL; - for (attr = mms_pn_lookup(text, "attrlist", - MMS_PN_CLAUSE, &work); - attr != NULL; - attr = mms_pn_lookup(text, "attrlist", - MMS_PN_CLAUSE, &work)) { - - - /* Create a new list node */ -#if 1 - - DM_LM_dev = wcr_alloc_DM_LM(); - if (DM_LM_dev == NULL) { - mms_trace(MMS_ERR, - "Unable to mallor wcr_DM_LM_t: %s", - strerror(errno)); - return; - } - - -#else - DM_LM_dev = - (wcr_DM_LM_t *)malloc(sizeof (wcr_DM_LM_t)); - if (DM_LM_dev == NULL) { - mms_trace(MMS_ERR, - "Unable to mallor wcr_DM_LM_t: %s", - strerror(errno)); - } - memset(DM_LM_dev, 0, sizeof (wcr_DM_LM_t)); -#endif - /* end of list create */ - - wcr_build_struct(attr, DM_LM_dev, wka); - - if (strcmp(DM_LM_dev->wcr_disabled, "true") == 0) { - free(DM_LM_dev); - } else { - DM_LM_dev->wcr_del_pending = 0; - mms_list_insert_tail(&wka->wcr_wka_DM_LM_list, - DM_LM_dev); - } - } - } -} - -/* - * wcr_create_list - * -takes in a "success" response in xml, creates a parse node tree - * and passes the tree to wcr_attrlist to perform the actall list creation - */ - -int -wcr_create_list(char *response, wcr_wka_t *wka) -{ - - mms_par_node_t *cmd = NULL; - mms_list_t err_list; - mms_par_err_t *err = NULL; - int rc; - - - rc = mms_mmp_parse(&cmd, &err_list, response); - mms_list_foreach(&err_list, err) { - mms_trace(MMS_ERR, "error parse, " - "line %d, col %d, near token \"%s\", err code %d, %s\n", - err->pe_line, - err->pe_col, - err->pe_token, - err->pe_code, - err->pe_msg); - } - mms_pe_destroy(&err_list); - if (rc) { - mms_trace(MMS_ERR, "Parse Error: %s", - strerror(errno)); - mms_pn_destroy(cmd); - return (MMS_ERROR); - } - - if (mms_pn_lookup(cmd, "success", MMS_PN_KEYWORD, 0) != NULL) { - - if (mms_pn_lookup(cmd, "attrlist", - MMS_PN_CLAUSE, NULL) != NULL) { - wcr_attrlist(cmd, wka); - } - rc = SUCCESS; - - } else if (mms_pn_lookup(cmd, "unacceptable", - MMS_PN_KEYWORD, 0) != NULL) { - - rc = UNACCEPTABLE; - - } else if (mms_pn_lookup(cmd, "cancelled", - MMS_PN_KEYWORD, 0) != NULL) { - - rc = CANCELLED; - - } else { - rc = MMS_ERROR; - } - - mms_pn_destroy(cmd); - return (rc); -} - -/* - * wcr_indent - * -subroutine used to add "level" number of tabs to the file pointed at - * by fp - */ -void -wcr_indent(int level, FILE *fp) -{ - int i; - for (i = 0; i < level; i++) { - fprintf(fp, " "); - } -} - -/* - * wcr_write_DM_cfg - * -this function performs the actual writing of a DM's config file - * -It takes in a single DM_LM_dev object, opens a file and writes the - * config information - * -files are named by the instance name followed by "_cfg.xml" - * (ex. dm1_cfg.xml) - */ - -void -wcr_write_DM_cfg(wcr_DM_LM_t *DM_LM_dev, wcr_wka_t *wka) -{ - - - FILE *cfg_fp = NULL; - char *cfg_file_name = NULL; - char *hello = mms_obfpassword(wka->wcr_wka_net_cfg.cli_pass, 0); - char *welcome = mms_obfpassword(wka->wcr_wka_net_cfg.mm_pass, 0); - - - cfg_file_name = mms_strapp(cfg_file_name, WCR_DM_LM_CONFIG_NAME, - DM_LM_dev->wcr_DM_LM_union.wcr_DM.wcr_DM_name); - - if ((cfg_fp = fopen(cfg_file_name, "w")) == NULL) { - mms_trace(MMS_ERR, "Unable to write to %s\n", cfg_file_name); - } - fprintf(cfg_fp, - "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n"); - fprintf(cfg_fp, - "<!-- DM Configuration -->\n"); - fprintf(cfg_fp, "<dm_cfg>\n"); - wcr_indent(1, cfg_fp); - fprintf(cfg_fp, "<!-- Network Configuration -->\n"); - wcr_indent(1, cfg_fp); - fprintf(cfg_fp, "<mms_network_cfg\n"); - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "host = \"%s\"\n", wka->wcr_wka_net_cfg.cli_host); - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "port = \"%s\"\n", wka->wcr_wka_net_cfg.cli_port); - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "name = \"%s\"\n", - DM_LM_dev->wcr_DM_LM_union.wcr_DM. - wcr_drive_name); - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "language = \"DMP\"\n"); - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "instance = \"%s\"\n", - DM_LM_dev->wcr_DM_LM_union.wcr_DM.wcr_DM_name); - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "password = \"%s\"\n", hello); - wcr_indent(2, cfg_fp); - if (welcome) { - fprintf(cfg_fp, "mm_password = \"%s\"\n", welcome); - } - if (wka->wcr_wka_net_cfg.ssl_enabled) { - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "ssl_enabled = \"true\"\n"); - if (wka->wcr_wka_net_cfg.ssl_cert_file) { - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "ssl_cert_file = \"%s\"\n", - wka->wcr_wka_net_cfg.ssl_cert_file); - } - if (wka->wcr_wka_net_cfg.ssl_pass) { - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "ssl_pass = \"%s\"\n", - wka->wcr_wka_net_cfg.ssl_pass); - } - if (wka->wcr_wka_net_cfg.ssl_pass_file) { - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "ssl_pass_file = \"%s\"\n", - wka->wcr_wka_net_cfg.ssl_pass_file); - } - if (wka->wcr_wka_net_cfg.ssl_crl_file) { - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "ssl_crl_file = \"%s\"\n", - wka->wcr_wka_net_cfg.ssl_crl_file); - } - if (wka->wcr_wka_net_cfg.ssl_peer_file) { - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "ssl_peer_file = \"%s\"\n", - wka->wcr_wka_net_cfg.ssl_peer_file); - } - if (wka->wcr_wka_net_cfg.ssl_cipher) { - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "ssl_cipher = \"%s\"\n", - wka->wcr_wka_net_cfg.ssl_cipher); - } - } else { - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "ssl_enabled = \"false\"\n"); - } - wcr_indent(1, cfg_fp); - fprintf(cfg_fp, "/>\n\n"); - wcr_indent(1, cfg_fp); - fprintf(cfg_fp, "<!-- DM specific config goes here -->\n"); - wcr_indent(1, cfg_fp); - fprintf(cfg_fp, "<dev_cfg\n"); - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "path = \"%s\"\n", - DM_LM_dev->wcr_DM_LM_union.wcr_DM.wcr_dev_mgr_path); - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "target = \"%s\"\n", - DM_LM_dev->wcr_DM_LM_union.wcr_DM.wcr_dev_tar_path); - wcr_indent(1, cfg_fp); - fprintf(cfg_fp, "/>\n"); - fprintf(cfg_fp, "</dm_cfg>\n"); - chmod(cfg_file_name, S_IRUSR); - fclose(cfg_fp); - free(hello); - free(welcome); - free(cfg_file_name); - -} - -/* - * wcr_write_LM_cfg - * -this function performs the actual writing of a LM's config file - * -It takes in a single DM_LM_dev object, opens a file and writes the - * config information - * -files are named by the instance name followed by "_cfg.xml" - * (ex. lm1_cfg.xml) - */ - -void -wcr_write_LM_cfg(wcr_DM_LM_t *DM_LM_dev, wcr_wka_t *wka) -{ - FILE *cfg_fp = NULL; - char *cfg_file_name = NULL; - char *hello = mms_obfpassword(wka->wcr_wka_net_cfg.cli_pass, 0); - char *welcome = mms_obfpassword(wka->wcr_wka_net_cfg.mm_pass, 0); - - cfg_file_name = mms_strapp(cfg_file_name, WCR_DM_LM_CONFIG_NAME, - DM_LM_dev->wcr_DM_LM_union.wcr_LM.wcr_LM_name); - - if ((cfg_fp = fopen(cfg_file_name, "w")) == NULL) { - mms_trace(MMS_ERR, "Unable to write to %s\n", cfg_file_name); - } - fprintf(cfg_fp, - "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n"); - fprintf(cfg_fp, - "<!-- LM Configuration -->\n"); - fprintf(cfg_fp, "<mms_cfg>\n"); - wcr_indent(1, cfg_fp); - fprintf(cfg_fp, "<!-- Network Configuration -->\n"); - wcr_indent(1, cfg_fp); - fprintf(cfg_fp, "<mms_network_cfg\n"); - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "host = \"%s\"\n", wka->wcr_wka_net_cfg.cli_host); - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "port = \"%s\"\n", wka->wcr_wka_net_cfg.cli_port); - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "name = \"%s\"\n", - DM_LM_dev->wcr_DM_LM_union.wcr_LM.wcr_library_name); - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "language = \"LMP\"\n"); - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "instance = \"%s\"\n", - DM_LM_dev->wcr_DM_LM_union.wcr_LM.wcr_LM_name); - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "password = \"%s\"\n", hello); - wcr_indent(2, cfg_fp); - if (welcome) { - fprintf(cfg_fp, "mm_password = \"%s\"\n", welcome); - } - if (wka->wcr_wka_net_cfg.ssl_enabled) { - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "ssl_enabled = \"true\"\n"); - if (wka->wcr_wka_net_cfg.ssl_cert_file) { - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "ssl_cert_file = \"%s\"\n", - wka->wcr_wka_net_cfg.ssl_cert_file); - } - if (wka->wcr_wka_net_cfg.ssl_pass) { - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "ssl_pass = \"%s\"\n", - wka->wcr_wka_net_cfg.ssl_pass); - } - if (wka->wcr_wka_net_cfg.ssl_pass_file) { - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "ssl_pass_file = \"%s\"\n", - wka->wcr_wka_net_cfg.ssl_pass_file); - } - if (wka->wcr_wka_net_cfg.ssl_crl_file) { - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "ssl_crl_file = \"%s\"\n", - wka->wcr_wka_net_cfg.ssl_crl_file); - } - if (wka->wcr_wka_net_cfg.ssl_peer_file) { - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "ssl_peer_file = \"%s\"\n", - wka->wcr_wka_net_cfg.ssl_peer_file); - } - if (wka->wcr_wka_net_cfg.ssl_cipher) { - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "ssl_cipher = \"%s\"\n", - wka->wcr_wka_net_cfg.ssl_cipher); - } - } else { - wcr_indent(2, cfg_fp); - fprintf(cfg_fp, "ssl_enabled = \"false\"\n"); - } - wcr_indent(1, cfg_fp); - fprintf(cfg_fp, "/>\n"); - fprintf(cfg_fp, "</mms_cfg>\n"); - chmod(cfg_file_name, S_IRUSR); - fclose(cfg_fp); - free(hello); - free(welcome); - free(cfg_file_name); -} - -/* - * wcr_write_cfg - * -takes in the watcher's workarea - * -calls the approperate config write function - */ - -int -wcr_write_cfg(wcr_wka_t *wka) -{ - wcr_DM_LM_t *DM_LM_dev; - mms_trace(MMS_NOTICE, "Writing CFG Files"); - mms_list_foreach(&wka->wcr_wka_DM_LM_list, DM_LM_dev) { - - if (DM_LM_dev->wcr_DM_flag) { - wcr_write_DM_cfg(DM_LM_dev, wka); - } else { - wcr_write_LM_cfg(DM_LM_dev, wka); - } - } - return (0); -} -void -wcr_add_event(mms_par_node_t *cmd, wcr_wka_t *wka) { - - mms_par_node_t *arg; - mms_par_node_t *work; - mms_par_node_t *value; - - char *old_inst_name = NULL; - char *new_inst_name = NULL; - char *type = NULL; - char *object = NULL; - char *inst_name = NULL; - - wcr_event_t *event_struct = NULL; - - int debug = 0; - - if (mms_pn_lookup(cmd, "event", - MMS_PN_CMD, 0) != NULL) { - if (debug) { - mms_trace(MMS_NOTICE, "event"); } - arg = mms_pn_lookup(cmd, "config", - MMS_PN_CLAUSE, 0); - if (arg) { - if (debug) { - mms_trace(MMS_NOTICE, " config"); } - } - work = NULL; - if (arg && (value - = mms_pn_lookup(arg, NULL, - MMS_PN_STRING, - &work))) { - if (debug) { - mms_trace(MMS_NOTICE, " object %s", - value->pn_string); } - - object = value->pn_string; - } - if (arg && (value = mms_pn_lookup(arg, - NULL, - MMS_PN_STRING, - &work))) { - if (debug) { - mms_trace(MMS_NOTICE, " type %s", - value->pn_string); } - - type = value->pn_string; - } - if (arg && strcmp(value->pn_string, "change") - == 0) { - if (value = mms_pn_lookup(arg, NULL, - MMS_PN_STRING, - &work)) { - if (debug) { - mms_trace(MMS_NOTICE, - " new instance %s", - value->pn_string); } - - new_inst_name = value->pn_string; - } - if (value && (value = - mms_pn_lookup(arg, - NULL, - MMS_PN_STRING, - &work))) { - - if (debug) { - mms_trace(MMS_NOTICE, - " old instance %s", - value->pn_string); } - - old_inst_name = value->pn_string; - } - } else if (arg && (value = - mms_pn_lookup(arg, NULL, - MMS_PN_STRING, - &work))) { - if (debug) { - mms_trace(MMS_NOTICE, " instance %s", - value->pn_string); } - inst_name = value->pn_string; - } - - } - event_struct = - (wcr_event_t *)malloc(sizeof (wcr_event_t)); - if (event_struct == NULL) { - mms_trace(MMS_ERR, - "Unable to malloc wcr_event_t: %s", - strerror(errno)); - } - memset(event_struct, 0, sizeof (wcr_event_t)); - - if (old_inst_name != NULL) { - strlcpy(event_struct->wcr_old_inst_name, old_inst_name, - sizeof (event_struct->wcr_old_inst_name)); } - if (new_inst_name != NULL) { - strlcpy(event_struct->wcr_new_inst_name, new_inst_name, - sizeof (event_struct->wcr_new_inst_name)); } - if (type != NULL) { - strlcpy(event_struct->wcr_type, type, - sizeof (event_struct->wcr_type)); } - if (object != NULL) { - strlcpy(event_struct->wcr_object, object, - sizeof (event_struct->wcr_object)); } - if (inst_name != NULL) { - strlcpy(event_struct->wcr_inst_name, inst_name, - sizeof (event_struct->wcr_inst_name)); } - event_struct->wcr_done = 0; - - mms_list_insert_tail(&wka->wcr_events, event_struct); - -} -/* - * wcr_send_cmd - * -Takes a command string to send to MM and the watcher's work area - * -Coverts the command to xml - * -sends the command to MM using MM's filedescriptor and mms_writer - * -reads the response from MM using mms_reader - * -returns the second protion of the response ("success" half) - */ - -char * -wcr_send_cmd(char *cmd_str, wcr_wka_t *wka) -{ - mms_par_node_t *cmd = NULL; - mms_list_t err_list; - int len; - char *rsp = NULL; - mms_par_err_t *err = NULL; - int go = 1; - int rc; - - len = strlen(cmd_str); - if (mms_writer(&wka->wcr_mms_conn, - cmd_str) != len) { - mms_get_error_string(&wka->wcr_mms_err, wka->wcr_mms_ebuf, - MMS_EBUF_LEN); - mms_trace(MMS_ERR, "mms_writer, " - "Write cmd failed: %s, %s", - strerror(errno), wka->wcr_mms_ebuf); - mms_close(&wka->wcr_mms_conn); - return (NULL); - } - mms_trace(MMS_INFO, "cmd is %s", cmd_str); - while (go) { - rsp = NULL; - if (mms_reader(&wka->wcr_mms_conn, &rsp) <= 0) { - mms_get_error_string(&wka->wcr_mms_err, - wka->wcr_mms_ebuf, - MMS_EBUF_LEN); - mms_trace(MMS_ERR, "mms_reader," - " Read cmd response failed: %s, %s", - strerror(errno), wka->wcr_mms_ebuf); - mms_close(&wka->wcr_mms_conn); - return (NULL); - } - mms_trace(MMS_DEBUG, "Read : %s", rsp); - - rc = mms_mmp_parse(&cmd, &err_list, rsp); - mms_list_foreach(&err_list, err) { - mms_trace(MMS_ERR, "error parse, " - "line %d, col %d, near token \"%s\", "\ - "err code %d, %s\n", - err->pe_line, - err->pe_col, - err->pe_token, - err->pe_code, - err->pe_msg); - } - if (rc) { - mms_trace(MMS_ERR, "Parse Error: %s", - strerror(errno)); - mms_pn_destroy(cmd); - return (NULL); - } - if (mms_pn_lookup(cmd, "event", - MMS_PN_CMD, 0) != NULL) { - wcr_add_event(cmd, wka); - mms_pn_destroy(cmd); - continue; - } - - if (mms_pn_lookup(cmd, - "response", MMS_PN_CMD, 0) - == NULL) { - mms_trace(MMS_ERR, - "Error- no command response to show: %s", - strerror(errno)); - mms_pn_destroy(cmd); - return (NULL); - } - if (mms_pn_lookup(cmd, - "accepted", MMS_PN_KEYWORD, 0) != NULL) { - mms_trace(MMS_DEBUG, "Command accepted"); - mms_pn_destroy(cmd); - } else if (mms_pn_lookup(cmd, - "success", MMS_PN_KEYWORD, 0) != NULL) { - mms_trace(MMS_DEBUG, "Command success"); - mms_pn_destroy(cmd); - go = 0; - } - - } - return (rsp); -} - -/* - * wcr_get_config - * -takes in the watcher's workarea - * -creates a linked list of all DM and LM that are to be running - * on this watcher's host - */ - - - -int -wcr_get_config(wcr_wka_t *wka) -{ - - char *cmd_str = NULL; - char *response = NULL; - wcr_DM_LM_t *DM_LM_dev = NULL; - - int num_dev = 0; - /* generate show command for current WD host */ - - /* For DM's */ - cmd_str = mms_strapp(cmd_str, SHOW_DM_CMD_STRING, wka->wcr_host_name); - - if ((response = wcr_send_cmd(cmd_str, wka)) == NULL) { - mms_trace(MMS_ERR, - "Error sending show command"); - free(cmd_str); - return (1); - } - - if (wcr_create_list(response, wka) == MMS_ERROR) { - mms_trace(MMS_ERR, - "wcr_get_config: " - "internal error creating wka list"); - } - - mms_list_foreach(&wka->wcr_wka_DM_LM_list, DM_LM_dev) { - - DM_LM_dev->wcr_DM_LM_union.wcr_DM.wcr_dev_mgr_path = - mms_strapp(DM_LM_dev-> - wcr_DM_LM_union.wcr_DM.wcr_dev_mgr_path, - WCR_DEV_MGR_PATH, num_dev+1); - DM_LM_dev->wcr_DM_LM_union.wcr_DM.wcr_dev_number = num_dev+1; - - num_dev ++; - - - } - free(cmd_str); - cmd_str = NULL; - - /* For LM's */ - cmd_str = mms_strapp(cmd_str, SHOW_LM_CMD_STRING, wka->wcr_host_name); - - if ((response = wcr_send_cmd(cmd_str, wka)) == NULL) { - mms_trace(MMS_ERR, "Error sending lm show command"); - free(cmd_str); - return (1); - } - if (wcr_create_list(response, wka) == MMS_ERROR) { - mms_trace(MMS_ERR, - "wcr_get_config: " - "internal error creating wka list"); - } - - - free(cmd_str); - return (0); -} - -/* Free a single net lm */ -/* caller needs to free net_lm itself */ -void -wcr_free_net_lm(wcr_net_LM_t *net_LM) { - if (net_LM->wcr_lm_name) - free(net_LM->wcr_lm_name); -} - -/* Free all net_LM in the list */ -void -wcr_free_all_ssi(wcr_wka_t *wka) { - - wcr_net_LM_t *cur_net_LM; - wcr_net_LM_t *next_net_LM; - - for (cur_net_LM = mms_list_head(&wka->wcr_net_LM_list); - cur_net_LM != NULL; - cur_net_LM = next_net_LM) { - next_net_LM = - mms_list_next(&wka->wcr_net_LM_list, - cur_net_LM); - mms_list_remove(&wka->wcr_net_LM_list, - cur_net_LM); - wcr_free_net_lm(cur_net_LM); - free(cur_net_LM); - cur_net_LM = NULL; - } - -} - - -/* - * wcr_set_ssi: - * either insert this net_LM in the list - * or set an existing net_LM in the list - * to the values in the new net_LM - */ -int -wcr_set_ssi(wcr_wka_t *wka, wcr_net_LM_t *net_LM) { - wcr_net_LM_t *cur_net_LM; - - /* Check list to see if there is already a */ - /* net_LM for this lm */ - /* If so, set the ssi info on that and free net_LM */ - mms_list_foreach(&wka->wcr_net_LM_list, - cur_net_LM) { - if (strcmp(cur_net_LM->wcr_lm_name, - net_LM->wcr_lm_name) == 0) { - /* already have this LM */ - cur_net_LM->wcr_ssi_port = - net_LM->wcr_ssi_port; - cur_net_LM->wcr_acsls_port = - net_LM->wcr_acsls_port; - return (1); - } - } - mms_list_insert_tail(&wka->wcr_net_LM_list, - net_LM); - return (0); -} - -/* - * wcr_check_ssi - * looks at the current ssi list, - * if 2 lm's are set to use the same - * ssi port, but have different libraryip's - * send a message and return error - */ - -int -wcr_check_ssi(wcr_wka_t *wka, wcr_net_LM_t *net_LM) { - wcr_net_LM_t *cur_net_LM = NULL; - char *cmd_str = NULL; - char *response = NULL; - - - mms_list_foreach(&wka->wcr_net_LM_list, cur_net_LM) { - if ((cur_net_LM->wcr_ssi_port == - net_LM->wcr_ssi_port) && - (strcmp(cur_net_LM->wcr_ssi_host, - net_LM->wcr_ssi_host) != 0)) { - /* same ssi port and different hosts */ - mms_trace(MMS_ERR, - "wcr_check_ssi: " - "Conflicting ssi configuration, " - "same ssi port but different hosts: " - "%s %d %s , %s %d %s", - net_LM->wcr_lm_name, - net_LM->wcr_ssi_port, - net_LM->wcr_ssi_host, - cur_net_LM->wcr_lm_name, - cur_net_LM->wcr_ssi_port, - cur_net_LM->wcr_ssi_host); - /* Send message 8000 */ - /* generate show command for current WD host */ - cmd_str = mms_strapp(cmd_str, - WCR_SSI_ERR_MSG, - wka->wcr_host_name, - net_LM->wcr_lm_name, - net_LM->wcr_ssi_port, - net_LM->wcr_ssi_host, - cur_net_LM->wcr_lm_name, - cur_net_LM->wcr_ssi_port, - cur_net_LM->wcr_ssi_host); - /* Send MMP command to MM */ - if ((response = wcr_send_cmd(cmd_str, wka)) - == NULL) { - mms_trace(MMS_ERR, - "Error sending ssi error message"); - } else { - free(response); - } - free(cmd_str); - return (1); - } - } - free(cmd_str); - return (0); -} - -/* - * wcr_get_ssi - * -takes in the watcher's workarea - * -obtains the acsls's servers hostname from MM - * -if lm_name is NULL get ssi for the whole host - * -else get ssi info for just that lm - */ - -/* ARGSUSED */ -int -wcr_get_ssi(wcr_wka_t *wka, char *lm_name) -{ - - /* Get SSI infor for this host */ - /* There may be more than one LM */ - - - int rc; - - mms_par_node_t *text_work = NULL; - mms_par_node_t *text_arg = NULL; - mms_par_node_t *lib_work = NULL; - mms_par_node_t *lib_arg = NULL; - - char *cmd_str = NULL; - char *response = NULL; - - mms_list_t err_list; - mms_par_err_t *err = NULL; - mms_par_node_t *cmd = NULL; - - char *cur_lmname = NULL; - char *cur_libraryip = NULL; - char *cur_acslsport = NULL; - char *cur_ssiport = NULL; - - wcr_net_LM_t *net_LM = NULL; - - /* generate show command for current WD host */ - if (lm_name == NULL) { - /* Get SSI for all LM's */ - /* delete the SSI list */ - cmd_str = mms_strapp(cmd_str, - SHOW_LM_SSI_STRING, - wka->wcr_host_name); - wcr_free_all_ssi(wka); - } else { - cmd_str = mms_strapp(cmd_str, - SHOW_LM_SSI_STRING_NAME, - wka->wcr_host_name, lm_name); - } - /* Send MMP command to MM */ - if ((response = wcr_send_cmd(cmd_str, wka)) == NULL) { - mms_trace(MMS_ERR, - "Error sending lm ssi show command"); - free(cmd_str); - return (1); - } - /* Parse the response */ - rc = mms_mmp_parse(&cmd, &err_list, response); - mms_list_foreach(&err_list, err) { - mms_trace(MMS_ERR, "error parse, " - "line %d, col %d, near token \"%s\", err code %d, %s\n", - err->pe_line, - err->pe_col, - err->pe_token, - err->pe_code, - err->pe_msg); - } - mms_pe_destroy(&err_list); - if (rc) { - mms_trace(MMS_ERR, "Parse Error: %s", strerror(errno)); - mms_pn_destroy(cmd); - free(cmd_str); - return (1); - } - - /* Check for success */ - if (mms_pn_lookup(cmd, "success", MMS_PN_KEYWORD, 0) == NULL) { - mms_trace(MMS_ERR, "wcr_get_ssi did not get a successful " - "response: %s", strerror(errno)); - free(cmd_str); - return (1); - } - /* For each text returned, create a wcr_net_LM struct */ - /* If there is already an existing wcr_net_LM with the same info */ - /* Don't make a duplicate */ - - text_work = NULL; - for (text_arg = mms_pn_lookup_arg(cmd, "text", NULL, &text_work); - text_arg != NULL; - text_arg = mms_pn_lookup_arg(cmd, "text", NULL, &text_work)) { - - if (cur_lmname) - free(cur_lmname); - if (cur_libraryip) - free(cur_libraryip); - if (cur_acslsport) - free(cur_acslsport); - if (cur_ssiport) - free(cur_ssiport); - cur_lmname = NULL; - cur_libraryip = NULL; - cur_acslsport = NULL; - cur_ssiport = NULL; - - /* Get LMName */ - lib_work = NULL; - if (mms_pn_lookup_arg(text_arg, "LMName", - NULL, &lib_work) == NULL) { - mms_trace(MMS_ERR, - "wcr_get_ssi: " - "unable to find LMName in response"); - continue; - } - if ((lib_arg = mms_pn_lookup_arg(text_arg, NULL, - NULL, &lib_work)) == NULL) { - mms_trace(MMS_ERR, - "wcr_get_ssi: " - "unable to find LMName in response"); - continue; - } - cur_lmname = strdup(lib_arg->pn_string); - - /* Get LibraryIP */ - lib_work = NULL; - if (mms_pn_lookup_arg(text_arg, "LibraryIP", - NULL, &lib_work) == NULL) { - mms_trace(MMS_ERR, - "wcr_get_ssi: " - "unable to find LibraryIP in response"); - continue; - } - if ((lib_arg = mms_pn_lookup_arg(text_arg, NULL, - NULL, &lib_work)) == NULL) { - mms_trace(MMS_ERR, - "wcr_get_ssi: " - "unable to find LibraryIP in response"); - continue; - } - cur_libraryip = strdup(lib_arg->pn_string); - - /* Get LibraryACSLSPort */ - lib_work = NULL; - if (mms_pn_lookup_arg(text_arg, "LibraryACSLSPort", - NULL, &lib_work) == NULL) { - mms_trace(MMS_ERR, - "wcr_get_ssi: " - "unable to find LibraryACSLSPort in response"); - continue; - } - if ((lib_arg = mms_pn_lookup_arg(text_arg, NULL, - NULL, &lib_work)) == NULL) { - mms_trace(MMS_ERR, - "wcr_get_ssi: " - "unable to find LibraryACSLSPort in response"); - continue; - } - cur_acslsport = strdup(lib_arg->pn_string); - - /* Get LMSSIPort */ - lib_work = NULL; - if (mms_pn_lookup_arg(text_arg, "LMSSIPort", - NULL, &lib_work) == NULL) { - mms_trace(MMS_ERR, - "wcr_get_ssi: " - "unable to find LMSSIPort in response"); - continue; - } - if ((lib_arg = mms_pn_lookup_arg(text_arg, NULL, - NULL, &lib_work)) == NULL) { - mms_trace(MMS_ERR, - "wcr_get_ssi: " - "unable to find LMSSIPort in response"); - continue; - } - cur_ssiport = strdup(lib_arg->pn_string); - - - if ((cur_lmname == NULL) || - (cur_libraryip == NULL) || - (cur_acslsport == NULL) || - (cur_ssiport == NULL)) { - mms_trace(MMS_ERR, - "wcr_get_ssi: " - "unable to get ACSLS/SSI " - "info from MM"); - continue; - } - mms_trace(MMS_DEVP, - "wcr_get_ssi:" - "ssi needed for %s, acsls ip=%s, acsls port=%s," - " ssi port=%s", - cur_lmname, cur_libraryip, cur_acslsport, - cur_ssiport); - /* Allocate a new struct for this ssi info */ - - net_LM = NULL; - net_LM = (wcr_net_LM_t *)calloc(1, sizeof (wcr_net_LM_t)); - if (net_LM == NULL) { - mms_trace(MMS_ERR, - "wcr_get_ssi: " - "unable to calloc net_LM"); - continue; - } - /* Set values in net_LM */ - strcpy(net_LM->wcr_ssi_host, cur_libraryip); - net_LM->wcr_ssi_port = atoi(cur_ssiport); - if (strcmp(cur_acslsport, "") == 0) { - net_LM->wcr_acsls_port = -1; - } else { - net_LM->wcr_acsls_port = - atoi(cur_acslsport); - } - net_LM->wcr_lm_name = cur_lmname; - cur_lmname = NULL; - /* insert net_LM into the list */ - /* Before insert check if this host already has an */ - /* ssi setup to run on cur_ssiport */ - /* If yes, send a message to MM indicating an incorrect */ - /* configuration */ - - if (wcr_check_ssi(wka, net_LM)) { - mms_trace(MMS_ERR, - "wcr_get_ssi: " - "incorrect ssi configuration, " - "do not attempt to start this ssi"); - wcr_free_net_lm(net_LM); - free(net_LM); - net_LM = NULL; - } else { - if (wcr_set_ssi(wka, net_LM)) { - /* already had this net_LM */ - wcr_free_net_lm(net_LM); - free(net_LM); - net_LM = NULL; - } - - } - - - } - - /* Clean up memory */ - if (cur_lmname) - free(cur_lmname); - if (cur_libraryip) - free(cur_libraryip); - if (cur_acslsport) - free(cur_acslsport); - if (cur_ssiport) - free(cur_ssiport); - cur_lmname = NULL; - cur_libraryip = NULL; - cur_acslsport = NULL; - cur_ssiport = NULL; - mms_trace(MMS_DEVP, - "wcr_get_ssi:" - "finished getting ssi info"); - free(cmd_str); - return (0); -} - -/* - * Configure drive and library managers - * wcr_config() - * -Takes in the a watcher's workarea - * -creates a list of wcr_dev type that will be used to start DMs - * -writes config files for every DM and LM that is to be running - * on this watcher 's host - */ - -int -wcr_config(wcr_wka_t *wka) -{ - wcr_DM_LM_t *DM_LM_dev; - - /* - * Configure devices - */ - - mms_list_foreach(&wka->wcr_wka_DM_LM_list, DM_LM_dev) { - if (DM_LM_dev->wcr_DM_flag) { - /* - * Verify the target device exists - */ - - if (ioctl(wka->wcr_wka_fd, WCR_ADD_DEV, - wka->wcr_wka_next_ordinal) < 0) { - mms_trace(MMS_ERR, - "Unable to add device %s, ordinal %d", - DM_LM_dev-> - wcr_DM_LM_union. - wcr_DM.wcr_dev_tar_path, - wka->wcr_wka_next_ordinal); - } - /* dv->wcr_dev_flags |= WCR_DEV_START; */ - DM_LM_dev->wcr_DM_LM_union.wcr_DM.wcr_dev_ordinal - = wka->wcr_wka_next_ordinal; - - mms_trace(MMS_NOTICE, "For %s Ordinal is %d", - DM_LM_dev-> - wcr_DM_LM_union.wcr_DM.wcr_DM_name, - DM_LM_dev-> - wcr_DM_LM_union.wcr_DM.wcr_dev_ordinal); - - - wka->wcr_wka_next_ordinal++; - } - } - - - /* Write the DM and LM config info to file */ - - if (wcr_write_cfg(wka)) { - mms_trace(MMS_ERR, "Unable to write cfg file"); - exit(1); - } - - return (0); - - - -} - -void -wcr_prefork(wcr_wka_t *wka) -{ - int rc; - - /* - * Setup separate contract for forked process - */ - if (wka->wcr_cfd == -1) { - wka->wcr_cfd = open64(CTFS_ROOT "/process/template", O_RDWR); - if (wka->wcr_cfd < 0) { - mms_trace(MMS_ERR, "contract template open %s", - strerror(errno)); - return; - } - if (rc = ct_pr_tmpl_set_param(wka->wcr_cfd, CT_PR_PGRPONLY)) { - mms_trace(MMS_ERR, "contract template set param %s", - strerror(rc)); - goto prefork_error; - } - if (rc = ct_tmpl_set_informative(wka->wcr_cfd, - CT_PR_EV_HWERR)) { - mms_trace(MMS_ERR, "contract template set info %s", - strerror(rc)); - goto prefork_error; - } - if (rc = ct_pr_tmpl_set_fatal(wka->wcr_cfd, CT_PR_EV_HWERR)) { - mms_trace(MMS_ERR, "contract template set fatal %s", - strerror(rc)); - goto prefork_error; - } - if (rc = ct_tmpl_set_critical(wka->wcr_cfd, CT_PR_EV_HWERR)) { - mms_trace(MMS_ERR, "contract template set critical %s", - strerror(rc)); - goto prefork_error; - } - } - if (rc = ct_tmpl_activate(wka->wcr_cfd)) { - mms_trace(MMS_ERR, "contract template activate %s", - strerror(rc)); - goto prefork_error; - } - return; - -prefork_error: - if (wka->wcr_cfd >= 0) - close(wka->wcr_cfd); - wka->wcr_cfd = -1; -} - -void -wcr_child_postfork(wcr_wka_t *wka) -{ - int rc; - - /* - * Clear contract - */ - if (wka->wcr_cfd < 0) { - mms_trace(MMS_ERR, "contract not open"); - return; - } - - if (rc = ct_tmpl_clear(wka->wcr_cfd)) { - mms_trace(MMS_ERR, "contract clear %s", strerror(rc)); - } - close(wka->wcr_cfd); -} - -void -wcr_parent_postfork(wcr_wka_t *wka, pid_t pid) -{ - int rc; - int fd; - char path[PATH_MAX]; - ct_stathdl_t st; - ctid_t latest; - - /* - * Abandon forked process contract - */ - if (wka->wcr_cfd < 0) { - mms_trace(MMS_ERR, "contract not open"); - return; - } - - if (rc = ct_tmpl_clear(wka->wcr_cfd)) { - mms_trace(MMS_ERR, "contract clear %s", strerror(rc)); - } - - if (pid == -1) { - mms_trace(MMS_ERR, "contract fork failed"); - return; - } - - if ((fd = open64(CTFS_ROOT "/process/latest", O_RDONLY)) < 0) { - mms_trace(MMS_ERR, "contract latest open %s", strerror(rc)); - return; - } - if (rc = ct_status_read(fd, CTD_COMMON, &st)) { - mms_trace(MMS_ERR, "contract status read %s", strerror(rc)); - close(fd); - return; - } - latest = ct_status_get_id(st); - ct_status_free(st); - (void) close(fd); - - snprintf(path, PATH_MAX, CTFS_ROOT "/all/%ld/ctl", latest); - if ((fd = open64(path, O_WRONLY)) < 0) { - mms_trace(MMS_ERR, "contract latest write open %s", - strerror(errno)); - return; - } - if (rc = ct_ctl_abandon(fd)) { - mms_trace(MMS_ERR, "contract abandon", strerror(rc)); - } - close(fd); -} - -/* - * wcr_exec_dm - * -This perfoms the fork and exec operations necessary to start a DM - * -It takes in the watcher work area and a wcr_dev_t dv on the DM to - * start - */ - - -void -wcr_exec_dm(wcr_wka_t *wka, wcr_DM_LM_t *DM_LM_dev) -{ - pid_t pid; - char *cfg_name = NULL; - char *cmd_name = NULL; - - wcr_prefork(wka); - if (pid = fork()) { - wcr_parent_postfork(wka, pid); - if (pid == (pid_t)(-1)) { - /* Fork error */ - mms_trace(MMS_ERR, "Fork error for device : "); - return; - } else { - /* In parent. Save dm's pid */ - DM_LM_dev->wcr_dev_pid = pid; - } - } else { - wcr_child_postfork(wka); - /* - * In child process. - * Close the watcher device. - */ - - close(wka->wcr_wka_fd); - - /* - * Exec the drive/lib manager - */ - cfg_name = mms_strapp(cfg_name, - WCR_DM_LM_CONFIG_NAME, - DM_LM_dev->wcr_DM_LM_union.wcr_DM.wcr_DM_name); - mms_trace(MMS_NOTICE, "EXEC a DM - %s", - DM_LM_dev->wcr_DM_LM_union.wcr_DM.wcr_DM_name); - cmd_name = mms_strapp(cmd_name, - WCR_DEV_MGR_PROG, "mmsdm"); - if (execl(cmd_name, cmd_name, - cfg_name, (char *)0)) { - /* Can't exec the drive/lib manager */ - - mms_trace(MMS_ERR, "Unable to execute program %s", - cmd_name); - free(cmd_name); - free(cfg_name); - exit(-1); - - } - free(cmd_name); - free(cfg_name); - } -} - -void -wcr_exec_lm(wcr_wka_t *wka, wcr_DM_LM_t *DM_LM_dev) -{ - pid_t pid; - char *cfg_name = NULL; - char *cmd_name = NULL; - - wcr_prefork(wka); - if (pid = fork()) { - wcr_parent_postfork(wka, pid); - if (pid == (pid_t)(-1)) { - /* Fork error */ - mms_trace(MMS_ERR, "Fork error for device : "); - return; - } else { - /* In parent. Save lm's pid */ - DM_LM_dev->wcr_dev_pid = pid; - } - } else { - wcr_child_postfork(wka); - /* - * In child process. - * Close the watcher device. - */ - - close(wka->wcr_wka_fd); - - /* - * Exec the drive/lib manager - */ - cfg_name = mms_strapp(cfg_name, - WCR_DM_LM_CONFIG_NAME, - DM_LM_dev->wcr_DM_LM_union.wcr_LM.wcr_LM_name); - mms_trace(MMS_NOTICE, "EXEC a LM - %s", - DM_LM_dev->wcr_DM_LM_union.wcr_LM.wcr_LM_name); - cmd_name = mms_strapp(cmd_name, - WCR_DEV_MGR_PROG, "mmslm"); - if (execl(cmd_name, cmd_name, - cfg_name, (char *)0)) { - /* Can't exec the drive/lib manager */ - - mms_trace(MMS_ERR, "Unable to execute program %s", - cmd_name); - free(cfg_name); - free(cmd_name); - exit(-1); - - } - free(cfg_name); - free(cmd_name); - } -} - - -void -wcr_exec_ssi(wcr_wka_t *wka, wcr_net_LM_t *net_LM) -{ - pid_t pid; - char *env_acs_hostname = NULL; - char *env_ssi_port = NULL; - char *env_acsls_port = NULL; - char *env_ssi_path = NULL; - char *cmd_name = NULL; - char *equ = NULL; - - int proc; - - int ssi_port = 0; - - - char *ssi_path = NULL; - - /* Get SSI path from smf */ - if ((ssi_path = mms_cfg_alloc_getvar(MMS_CFG_SSI_PATH, NULL)) == NULL) { - /* report service configuration repoistory scf_error() */ - mms_trace(MMS_ERR, "using default-path, ssi path cfg error"); - ssi_path = strdup("/opt/mms/bin/acsls"); - } - - - mms_trace(MMS_DEVP, - "wcr_exec_ssi: " - "ssi for %s, acsls ip=%s, acsls port=%d," - " ssi port=%d, ssi path=%s", - net_LM->wcr_lm_name, - net_LM->wcr_ssi_host, - net_LM->wcr_acsls_port, - net_LM->wcr_ssi_port, - ssi_path); - - - if (net_LM->wcr_ssi_host[0] == '\0') { - mms_trace(MMS_DEBUG, "No ssi configured on host %s", - wka->wcr_host_name); - free(ssi_path); - return; - } - - if (wcr_ssi_is_running("ssi", &proc, - net_LM->wcr_ssi_port)) { - - if (proc == net_LM->wcr_dev_pid) { - mms_trace(MMS_NOTICE, "ssi is required and " - "already running from previous start: " - "pid = %d, port=%d", proc, - net_LM->wcr_ssi_port); - } else { - mms_trace(MMS_NOTICE, "ssi is required, " - "but is already running: " - "pid = %d, port=%d", - proc, net_LM->wcr_ssi_port); - } - free(ssi_path); - return; - } - - mms_trace(MMS_OPER, "SSI configured to run on host %s, port %d", - net_LM->wcr_ssi_host, - net_LM->wcr_ssi_port); - /* Set ACSLS Server Host */ - mms_trace(MMS_OPER, - "CSI_HOSTNAME = %s", - net_LM->wcr_ssi_host); - env_acs_hostname = mms_strapp(env_acs_hostname, - "CSI_HOSTNAME=%s", - net_LM->wcr_ssi_host); - putenv(env_acs_hostname); - - /* Set ACSLS Server port */ - if (net_LM->wcr_acsls_port != -1) { - mms_trace(MMS_OPER, - "CSI_HOSTPORT = %d", - net_LM->wcr_acsls_port); - env_acsls_port = mms_strapp(env_acsls_port, - "CSI_HOSTPORT=%d", - net_LM->wcr_acsls_port); - putenv(env_acsls_port); - } else { - mms_trace(MMS_OPER, - "ACSLS server port not set, " - "ssi will use default " - "from portmapper"); - } - - /* Get the ACLS port number from MM */ - /* Pass the port number as an argument to t_ssi.sh */ - ssi_port = net_LM->wcr_ssi_port; - if (ssi_port == 0) { - mms_trace(MMS_ERR, - "wcr_exec_ssi: " - "unable to get acsls port number from MM, " - "trying default port, 50004"); - ssi_port = 50004; - } - /* Set the SSI port */ - mms_trace(MMS_OPER, - "ACSAPI_SSI_SOCKET = %d", ssi_port); - env_ssi_port = - mms_strapp(env_ssi_port, - "ACSAPI_SSI_SOCKET=%d", ssi_port); - putenv(env_ssi_port); - - /* Set path to ssi binary */ - mms_trace(MMS_OPER, - "MMS_SSI_PATH = %s", - ssi_path); - env_ssi_path = - mms_strapp(env_ssi_path, - "MMS_SSI_PATH=%s", - ssi_path); - putenv(env_ssi_path); - - wcr_prefork(wka); - if (pid = fork()) { - wcr_parent_postfork(wka, pid); - - if (env_ssi_path != NULL) - free(env_ssi_path); - if (env_ssi_port != NULL) - free(env_ssi_port); - if (env_acsls_port != NULL) - free(env_acsls_port); - if (env_acs_hostname != NULL) - free(env_acs_hostname); - - if (pid == (pid_t)(-1)) { - /* Fork error */ - mms_trace(MMS_ERR, "Fork error for device : "); - free(ssi_path); - return; - } else { - /* In parent. Save ssi's pid */ - net_LM->wcr_dev_pid = pid; - } - } else { - wcr_child_postfork(wka); - - mms_trace(MMS_NOTICE, "In child process"); - - /* - * In child process. - * Close the watcher device. - */ - close(wka->wcr_wka_fd); - - /* - * Exec the SSI daemon - */ - cmd_name = mms_strapp(cmd_name, WCR_SSI_SH, WCR_SSI_SCRIPT); - equ = mms_strapp(equ, "%ld", (long)getpid()); - mms_trace(MMS_NOTICE, "EXEC a SSI, pid - %s", equ); - if (execl(cmd_name, WCR_SSI_SCRIPT, equ, (char *)0)) { - /* Can't exec the ssi manager */ - mms_trace(MMS_ERR, "Unable to execute program %s", - cmd_name); - if (cmd_name != NULL) - free(cmd_name); - if (equ != NULL) - free(equ); - if (env_ssi_path != NULL) - free(env_ssi_path); - if (env_ssi_port != NULL) - free(env_ssi_port); - if (env_acsls_port != NULL) - free(env_acsls_port); - if (env_acs_hostname != NULL) - free(env_acs_hostname); - exit(-1); - } - if (cmd_name != NULL) - free(cmd_name); - if (equ != NULL) - free(equ); - if (env_ssi_path != NULL) - free(env_ssi_path); - if (env_ssi_port != NULL) - free(env_ssi_port); - if (env_acsls_port != NULL) - free(env_acsls_port); - if (env_acs_hostname != NULL) - free(env_acs_hostname); - } -} - -void -wcr_exec_restart_ssi(wcr_wka_t *wka, wcr_net_LM_t *net_LM, int status) -{ - time_t cur_time; - char *cmd_str = NULL; - char *response = NULL; - char *ssi_path = NULL; - - /* Get SSI path from smf */ - if ((ssi_path = mms_cfg_alloc_getvar(MMS_CFG_SSI_PATH, NULL)) == NULL) { - /* report service configuration repoistory scf_error() */ - mms_trace(MMS_ERR, "using default-path, ssi path cfg error"); - ssi_path = strdup("/opt/mms/bin/acsls"); - } - - /* - * Count number of restarts in a time period. - */ - time(&cur_time); - if (WEXITSTATUS(status) == 2 || - net_LM->wcr_ssi_starts == 0 || - (cur_time - net_LM->wcr_time) > wka->wcr_time) { - net_LM->wcr_time = cur_time; - net_LM->wcr_ssi_starts = 1; - } else { - net_LM->wcr_ssi_starts++; - } - if (wka->wcr_starts != -1 && - net_LM->wcr_ssi_starts >= wka->wcr_starts) { - /* - * SSI - * Restarted n times in s seconds. - * Log system message and set watcher to maintenance - */ - mms_trace(MMS_ERR, - "SSI restarting too quickly, " - "putting watcher in maintenance mode."); - /* Send message 8001 */ - /* generate show command for current WD host */ - cmd_str = mms_strapp(cmd_str, - WCR_SSI_PATH_MSG, - ssi_path); - /* Send MMP command to MM */ - if ((response = wcr_send_cmd(cmd_str, wka)) - == NULL) { - mms_trace(MMS_ERR, - "Error sending ssi error message"); - } else { - free(response); - } - free(cmd_str); - } else { - /* - * SSI - * Was aborted or exited w/ status != 1 or != 0 - * Restart - */ - sleep(5); - wcr_exec_ssi(wka, net_LM); - } -} -void -wcr_exec_all_ssi(wcr_wka_t *wka) { - wcr_net_LM_t *net_LM; - mms_list_foreach(&wka->wcr_net_LM_list, net_LM) { - wcr_exec_ssi(wka, net_LM); - } -} - -void -wcr_exec_one_ssi(wcr_wka_t *wka, char *lm_name) { - wcr_net_LM_t *net_LM; - mms_list_foreach(&wka->wcr_net_LM_list, net_LM) { - if (strcmp(lm_name, - net_LM->wcr_lm_name) == 0) { - wcr_exec_ssi(wka, net_LM); - return; - } - } - mms_trace(MMS_ERR, - "wcr_exec_one_ssi: " - "coudln't find SSI info for %s" - " check configuration", - lm_name); -} - -void -wcr_exec_lm_dm(wcr_wka_t *wka, wcr_DM_LM_t *DM_LM_dev) -{ - if (DM_LM_dev->wcr_DM_flag) { - wcr_exec_dm(wka, DM_LM_dev); - } else { - wcr_exec_lm(wka, DM_LM_dev); - } -} - -void -wcr_start_lm_dm(wcr_wka_t *wka) -{ - wcr_DM_LM_t *DM_LM_dev; - mms_list_foreach(&wka->wcr_wka_DM_LM_list, DM_LM_dev) { - wcr_exec_lm_dm(wka, DM_LM_dev); - } -} - -/* - * wcr_sigchld - * -Counts the number of SIGCHILD signals caught - */ - -void -/* LINTED: may be used in future */ -wcr_sigchld(int sig, siginfo_t *sip, void *ucp) -{ - /* - * A drive/library manager has terminated - */ - - mms_trace(MMS_NOTICE, "Caught SIGCHLD - %d", sig); - wka.wcr_wka_sigchld++; -} - -/* - * wcr_sighup - * -Counts the number of SIGHUP signals caught - */ - -void -/* LINTED: may be used in future */ -wcr_sighup(int sig, siginfo_t *sip, void *ucp) -{ - /* - * Service configuration change - */ - - mms_trace(MMS_NOTICE, "Caught SIGHUP - %d", sig); - wka.wcr_wka_sighup = 1; -} - -/* ARGSUSED */ -void -wcr_sigterm(int sig, siginfo_t *sip, void *ucp) -{ - /* - * Service configuration change - */ - - mms_trace(MMS_NOTICE, "Caught SIGTERM - %d", sig); - mms_trace_flush(); - exit(0); -} - -/* - * wcr_signal - * -signal handler function - */ - -void -wcr_signal(int sig, sigfunc *handler) -{ - /* - * Setup to catch signals - */ - struct sigaction act, oact; - - memset(&act, 0, sizeof (act)); - act.sa_sigaction = handler; - sigemptyset(&act.sa_mask); - act.sa_flags = SA_SIGINFO; - if (sig != SIGALRM) { - /* - * Allow alarm signal to interrupt - */ - act.sa_flags |= SA_RESTART; - } - if (sigaction(sig, &act, &oact) < 0) { - mms_trace(MMS_ERR, "Can't set signal handler for signal %d: %s", - sig, strerror(errno)); - exit(1); - } - -} - -/* - * wcr_setup_sig_handler - * -sets up the signal handler function - */ - -void -wcr_setup_sig_handler() -{ - /* - * Setup SIG_CHLD and SIGHUP handlers - */ - wcr_signal(SIGCHLD, wcr_sigchld); - wcr_signal(SIGHUP, wcr_sighup); - wcr_signal(SIGTERM, wcr_sigterm); - mms_trace(MMS_NOTICE, "Set to catch SIGCHLD and SIGHUP"); -} - - - -void -wcr_del_died(wcr_wka_t *wka, pid_t pid) { - wcr_DM_LM_t *DM_LM_dev; - - mms_list_foreach(&wka->wcr_wka_DM_LM_list, DM_LM_dev) { - if (DM_LM_dev->wcr_dev_pid == pid) { - break; - } - } - if (DM_LM_dev->wcr_DM_flag) { - mms_trace(MMS_NOTICE, "DELETING DM Dev %s", - DM_LM_dev-> - wcr_DM_LM_union.wcr_DM.wcr_DM_name); - } else { - mms_trace(MMS_NOTICE, "DELETING LM Dev %s", - DM_LM_dev-> - wcr_DM_LM_union.wcr_LM.wcr_LM_name); - } - mms_list_remove(&wka->wcr_wka_DM_LM_list, DM_LM_dev); - wcr_free_DM_LM(DM_LM_dev); - free(DM_LM_dev); - DM_LM_dev = NULL; -} - - - - -int -wcr_get_LM_DM(char *name, wcr_DM_LM_t **LM_DM, wcr_wka_t *wka) -{ - wcr_DM_LM_t *DM_LM_dev = NULL; - - mms_list_foreach(&wka->wcr_wka_DM_LM_list, DM_LM_dev) { - if (DM_LM_dev->wcr_DM_flag) { - if (strcmp(name, - DM_LM_dev->wcr_DM_LM_union. - wcr_DM.wcr_DM_name) == 0) { - *LM_DM = DM_LM_dev; - return (1); - } - } else if (strcmp(name, - DM_LM_dev->wcr_DM_LM_union. - wcr_LM.wcr_LM_name) == 0) { - *LM_DM = DM_LM_dev; - return (1); - } - } - return (0); -} - -void -wcr_print_LM_DM(wcr_wka_t *wka) -{ - wcr_DM_LM_t *DM_LM_dev = NULL; - char *dmname = NULL; - char *drivename = NULL; - char *lmname = NULL; - char *libraryname = NULL; - int printone = 0; - mms_trace(MMS_DEBUG, "Current LM & DM list:"); - mms_list_foreach(&wka->wcr_wka_DM_LM_list, DM_LM_dev) { - printone = 1; - if (DM_LM_dev->wcr_DM_flag) { - dmname = DM_LM_dev->wcr_DM_LM_union. - wcr_DM.wcr_DM_name; - drivename = DM_LM_dev->wcr_DM_LM_union. - wcr_DM.wcr_drive_name; - mms_trace(MMS_DEBUG, - " DM, %s %s", - dmname, drivename); - } else { - lmname = DM_LM_dev->wcr_DM_LM_union. - wcr_LM.wcr_LM_name; - libraryname = DM_LM_dev->wcr_DM_LM_union. - wcr_LM.wcr_library_name; - mms_trace(MMS_DEBUG, - " LM, %s %s", - lmname, libraryname); - } - - } - if (!printone) { - mms_trace(MMS_DEBUG, " *none*"); - } -} - - - - -/* - * wcr_get_dev_number() - * returns the next available device number, used for DM - * (pigeon hole problem) - */ - -int -wcr_get_dev_number(wcr_wka_t *wka) -{ - - int number_of_dev = 0; - wcr_DM_LM_t *LM_DM; - int match = 0; - int use = 0; - int i; - - mms_list_foreach(&wka->wcr_wka_DM_LM_list, LM_DM) { - number_of_dev ++; - } - LM_DM = NULL; - - for (i = 1; i <= number_of_dev+1; i++) { - match = 0; - mms_list_foreach(&wka->wcr_wka_DM_LM_list, LM_DM) { - if (i == LM_DM-> - wcr_DM_LM_union.wcr_DM.wcr_dev_number) { - match = 1; - } - } - - if (!match) { - use = i; - return (use); - } - } - return (-1); -} - -/* - * wcr-is_LM_DM_disabled() - * -Is LM/DM disabled - */ - - -int -wcr_is_LM_DM_disabled(char *response, char *inst) -{ - int rc; - mms_par_node_t *cmd = NULL; - mms_list_t err_list; - mms_par_node_t *tw = NULL; - mms_par_node_t *text = NULL; - mms_par_node_t *work = NULL; - mms_par_node_t *attr = NULL; - mms_par_node_t *name = NULL; - mms_par_node_t *value = NULL; - int found; - int disabled; - - rc = mms_mmp_parse(&cmd, &err_list, response); - mms_pe_destroy(&err_list); - if (rc) { - mms_pn_destroy(cmd); - return (0); - } - - tw = NULL; - found = 0; - for (text = mms_pn_lookup(cmd, "text", MMS_PN_CLAUSE, &tw); - text != NULL && !found; - text = mms_pn_lookup(cmd, "text", MMS_PN_CLAUSE, &tw)) { - - work = NULL; - for (attr = mms_pn_lookup(text, "attrlist", - MMS_PN_CLAUSE, &work); - attr != NULL && !found; - attr = mms_pn_lookup(text, "attrlist", - MMS_PN_CLAUSE, &work)) { - - disabled = 0; - mms_list_pair_foreach(&attr->pn_arglist, name, - value) { - if (strcmp("DMName", - name->pn_string) == 0) { - if (strcmp(inst, - value->pn_string) == 0) { - found = 1; - } - } else if (strcmp("LMName", - name->pn_string) == 0) { - if (strcmp(inst, - value->pn_string) == 0) { - found = 1; - } - } else if (strcmp("DMDisabled", - name->pn_string) == 0) { - disabled = strcmp("false", - value->pn_string); - } else if (strcmp("LMDisabled", - name->pn_string) == 0) { - disabled = strcmp("false", - value->pn_string); - } - } - } - } - mms_pn_destroy(cmd); - if (found && disabled) { - return (1); - } - return (0); -} - -/* - * wcr-new_event() - * -Need to get the config information for the new LM/DM - * -Need to create a new LM/DM object and add it to the list - * -Need to start process for the new object - */ - - -void -wcr_new_event(wcr_wka_t *wka, char *name, char *type) -{ - char *cmd_str = NULL; - - char *response = NULL; - wcr_DM_LM_t *new_LM_DM = NULL; - int num_dev = 1; - wcr_DM_LM_t *cur_LM_DM = NULL; - int rc; - - /* make sure object is not already in the list */ - wcr_print_LM_DM(wka); - if (wcr_get_LM_DM(name, &new_LM_DM, wka)) { - mms_trace(MMS_NOTICE, - "Duplicate LM/DM Found- Cannot create new"); - return; - } - - new_LM_DM = NULL; - - /* Generate the correct show command */ - if (strcmp(type, "DM") == 0) { - cmd_str = mms_strapp(cmd_str, - WCR_SHOW_NEW_DM, name, - wka->wcr_host_name); - if ((num_dev = wcr_get_dev_number(wka)) == -1) { - mms_trace(MMS_ERR, "Failed to get new dev number"); - } - - } else if (strcmp(type, "LM") == 0) { - cmd_str = mms_strapp(cmd_str, - WCR_SHOW_NEW_LM, name, - wka->wcr_host_name); - } else { - mms_trace(MMS_ERR, - "Unknown type of New Event %s - %s not added", - type, name); - return; - } - /* send the show command and add the new dev to the list */ - if ((response = wcr_send_cmd(cmd_str, wka)) == NULL) { - mms_trace(MMS_ERR, - "Error sending command"); - free(cmd_str); - return; - } - free(cmd_str); - /* mms_trace(MMS_NOTICE, "response- %s", response); */ - rc = wcr_create_list(response, wka); - - /* select the new device and exec its binary */ - - cur_LM_DM = NULL; - if (!wcr_get_LM_DM(name, &cur_LM_DM, wka)) { - if (rc == SUCCESS && wcr_is_LM_DM_disabled(response, name)) { - mms_trace(MMS_NOTICE, "Found disabled DM/LM %s", name); - return; - } - mms_trace(MMS_ERR, "Could NOT find new DM/LM %s", name); - return; - } - - /* - * Check if new dev is LM or DM, - * If LM, write cfg file and exec - * If DM, set up dev path, write cfg, and exec - */ - - if (!cur_LM_DM->wcr_DM_flag) { - /* check to see if SSI needs to be started */ - if (wcr_get_ssi(wka, name)) { - mms_trace(MMS_ERR, - "Error getting ssi hostname"); - } else { - wcr_exec_one_ssi(wka, name); - } - /* It is an LM */ - wcr_write_LM_cfg(cur_LM_DM, wka); - wcr_exec_lm_dm(wka, cur_LM_DM); - return; - } - - cur_LM_DM->wcr_DM_LM_union. - wcr_DM.wcr_dev_number = num_dev; - - - if (cur_LM_DM-> - wcr_DM_LM_union.wcr_DM. - wcr_dev_mgr_path != NULL) { - free(cur_LM_DM-> - wcr_DM_LM_union.wcr_DM. - wcr_dev_mgr_path); - cur_LM_DM-> - wcr_DM_LM_union.wcr_DM. - wcr_dev_mgr_path = NULL; - } - cur_LM_DM->wcr_DM_LM_union.wcr_DM.wcr_dev_mgr_path = - mms_strapp(cur_LM_DM->wcr_DM_LM_union.wcr_DM.wcr_dev_mgr_path, - WCR_DEV_MGR_PATH, num_dev); - - if (ioctl(wka->wcr_wka_fd, WCR_ADD_DEV, - num_dev) < 0) { - mms_trace(MMS_ERR, "Unable to add device %s, ordinal %d", - cur_LM_DM->wcr_DM_LM_union.wcr_DM.wcr_dev_tar_path, - num_dev); - } - /* dv->wcr_dev_flags |= WCR_DEV_START; */ - cur_LM_DM->wcr_DM_LM_union.wcr_DM.wcr_dev_ordinal - = num_dev; - - wcr_write_DM_cfg(cur_LM_DM, wka); - wcr_exec_lm_dm(wka, cur_LM_DM); -} - -void -wcr_change_died(wcr_wka_t *wka, pid_t pid) { - wcr_DM_LM_t *DM_LM_dev = NULL; - char *name = NULL; - char *type = NULL; - - mms_list_foreach(&wka->wcr_wka_DM_LM_list, DM_LM_dev) { - if (DM_LM_dev->wcr_dev_pid == pid) { - break; - } - } - if (DM_LM_dev->wcr_DM_flag) { - name = DM_LM_dev-> - wcr_DM_LM_union.wcr_DM.wcr_DM_name; - type = "DM"; - } else { - name = DM_LM_dev-> - wcr_DM_LM_union.wcr_LM.wcr_LM_name; - type = "LM"; - } - - /* mms_list_remove(&wka->wcr_wka_DM_LM_list, DM_LM_dev); */ - mms_trace(MMS_NOTICE, "Obj to change is %s, type is %s", name, type); - - - wcr_del_died(wka, pid); - wcr_new_event(wka, name, type); -} - -/* - * wcr_del_event() - * -Need to kill child LM/DM - * -Need to delete LM/DM object from the list - */ - -void -/* LINTED: type may be used later */ -wcr_del_event(wcr_wka_t *wka, char *name, char *type) -{ - wcr_DM_LM_t *LM_DM = NULL; - mms_trace(MMS_NOTICE, "Attempting to delete LM/DM - %s", name); - - if (!wcr_get_LM_DM(name, &LM_DM, wka)) { - mms_trace(MMS_ERR, "Could NOT find DM/LM %s in list", name); - return; - } - LM_DM->wcr_del_pending = 1; - kill(LM_DM->wcr_dev_pid, SIGTERM); - - LM_DM = NULL; -} - -/* - * wcr_disable_event() - * -Need to delete LM/DM object from the list - */ - -void -/* LINTED: type may be used later */ -wcr_disable_event(wcr_wka_t *wka, char *name, char *type) -{ - wcr_DM_LM_t *LM_DM = NULL; - mms_trace(MMS_NOTICE, "Attempting to disable LM/DM - %s", name); - - if (!wcr_get_LM_DM(name, &LM_DM, wka)) { - mms_trace(MMS_ERR, "Could NOT find DM/LM %s in list", name); - return; - } - LM_DM->wcr_del_pending = 1; - - LM_DM = NULL; - -} - -/* - * wcr_compare() - * -Check for LM/DM object change. - */ - -int -wcr_compare(wcr_DM_LM_t *LM_DM_1, wcr_DM_LM_t *LM_DM_2) -{ - int changed = 0; - - if (LM_DM_1->wcr_DM_flag) { - /* Compare DM attributes */ - if (strcmp(LM_DM_1->wcr_DM_LM_union. - wcr_DM.wcr_DM_name, - LM_DM_2->wcr_DM_LM_union. - wcr_DM.wcr_DM_name) != 0) { - mms_trace(MMS_NOTICE, "LM_DM_1 - %s, LM_DM_2 - %s", - LM_DM_1->wcr_DM_LM_union. - wcr_DM.wcr_DM_name, LM_DM_2->wcr_DM_LM_union. - wcr_DM.wcr_DM_name); - changed = 1; - } else if (strcmp(LM_DM_1->wcr_DM_LM_union. - wcr_DM.wcr_dev_tar_path, - LM_DM_2->wcr_DM_LM_union. - wcr_DM.wcr_dev_tar_path) != 0) { - mms_trace(MMS_NOTICE, "LM_DM_1 - %s, LM_DM_2 - %s", - LM_DM_1->wcr_DM_LM_union. - wcr_DM.wcr_dev_tar_path, - LM_DM_2->wcr_DM_LM_union. - wcr_DM.wcr_dev_tar_path); - changed = 1; - } else if (strcmp(LM_DM_1->wcr_DM_LM_union. - wcr_DM.wcr_drive_name, - LM_DM_2->wcr_DM_LM_union. - wcr_DM.wcr_drive_name) != 0) { - mms_trace(MMS_NOTICE, "LM_DM_1 - %s, LM_DM_2 - %s", - LM_DM_1->wcr_DM_LM_union. - wcr_DM.wcr_drive_name, - LM_DM_2->wcr_DM_LM_union. - wcr_DM.wcr_drive_name); - changed = 1; - } - - } else { - /* Compare LM attributes */ - if (strcmp(LM_DM_1->wcr_DM_LM_union. - wcr_LM.wcr_LM_name, - LM_DM_2->wcr_DM_LM_union. - wcr_LM.wcr_LM_name) != 0) { - mms_trace(MMS_NOTICE, "LM_DM_1 - %s, LM_DM_2 - %s", - LM_DM_1->wcr_DM_LM_union. - wcr_LM.wcr_LM_name, - LM_DM_2->wcr_DM_LM_union. - wcr_LM.wcr_LM_name); - changed = 1; - } else if (strcmp(LM_DM_1->wcr_DM_LM_union. - wcr_LM.wcr_library_name, - LM_DM_2->wcr_DM_LM_union. - wcr_LM.wcr_library_name) != 0) { - mms_trace(MMS_NOTICE, "LM_DM_1 - %s, LM_DM_2 - %s", - LM_DM_1->wcr_DM_LM_union. - wcr_LM.wcr_library_name, - LM_DM_2->wcr_DM_LM_union. - wcr_LM.wcr_library_name); - changed = 1; - } - } - return (changed); -} - - -/* - * wcr_change_event() - * -Need to kill child LM/DM - * -Need to alter LM/DM object in the list - * -Need to write a new config file - * -Need to restart the LM/DM - */ - -void -wcr_change_event(wcr_wka_t *wka, char *old_name, char *new_name, char *type) -{ - wcr_DM_LM_t *LM_DM; - char *response = NULL; - char *cmd_str = NULL; - wcr_DM_LM_t *temp_LM_DM = NULL; - mms_par_node_t *cmd = NULL; - mms_list_t err_list; - mms_par_err_t *err = NULL; - int rc; - mms_par_node_t *text = NULL; - mms_par_node_t *tw = NULL; - mms_par_node_t *work = NULL; - mms_par_node_t *attr = NULL; - int changed = 0; - - - mms_trace(MMS_NOTICE, "Attempting to change LM/DM - %s", old_name); - - if (!wcr_get_LM_DM(old_name, &LM_DM, wka)) { - /* - * The LM/DM has already exited with a no restart exit code - * and has been removed from the active list - * this is likley due to an inncorrect user configuration - * call new event with the new name to re-config and start - * the LM/DM - */ - mms_trace(MMS_NOTICE, "Could NOT find DM/LM %s"\ - " to change in active list", - old_name); - wcr_new_event(wka, new_name, type); - return; - } - /* The LM/DM to be changed is active so check for config changes */ - if (strcmp(type, "DM") == 0) { - cmd_str = mms_strapp(cmd_str, - WCR_SHOW_NEW_DM, new_name, - wka->wcr_host_name); - } else if (strcmp(type, "LM") == 0) { - cmd_str = mms_strapp(cmd_str, - WCR_SHOW_NEW_LM, new_name, - wka->wcr_host_name); - } else { - mms_trace(MMS_ERR, - "Unknown type of change Event %s - %s not added", - type, new_name); - return; - } - - /* send the show command and add the new dev to the list */ - if ((response = wcr_send_cmd(cmd_str, wka)) == NULL) { - mms_trace(MMS_ERR, - "Error sending command"); - free(cmd_str); - return; - } - free(cmd_str); - /* mms_trace(MMS_NOTICE, "response is %s", response); */ - /* Malloc memory for temporary LM DM */ - -#if 1 - - temp_LM_DM = wcr_alloc_DM_LM(); - if (temp_LM_DM == NULL) { - mms_trace(MMS_ERR, - "Unable to mallor wcr_DM_LM_t: %s", - strerror(errno)); - return; - } - -#else - temp_LM_DM = - (wcr_DM_LM_t *)malloc(sizeof (wcr_DM_LM_t)); - if (temp_LM_DM == NULL) { - mms_trace(MMS_ERR, - "Unable to mallor wcr_DM_LM_t: %s", - strerror(errno)); - } - memset(temp_LM_DM, 0, sizeof (wcr_DM_LM_t)); -#endif - /* parse response */ - rc = mms_mmp_parse(&cmd, &err_list, response); - mms_list_foreach(&err_list, err) { - mms_trace(MMS_ERR, "error parse, " - "line %d, col %d, near token \"%s\", err code %d, %s\n", - err->pe_line, - err->pe_col, - err->pe_token, - err->pe_code, - err->pe_msg); - } - mms_pe_destroy(&err_list); - if (rc) { - mms_trace(MMS_ERR, "Parse Error: %s", - strerror(errno)); - mms_pn_destroy(cmd); - return; - } - if (mms_pn_lookup(cmd, "success", MMS_PN_KEYWORD, 0) != NULL) { - - if (text = mms_pn_lookup(cmd, "attrlist", - MMS_PN_CLAUSE, NULL)) { - tw = 0; - for (text = mms_pn_lookup(cmd, "text", - MMS_PN_CLAUSE, &tw); - text != NULL; - text = mms_pn_lookup(cmd, "text", - MMS_PN_CLAUSE, &tw)) { - work = NULL; - for (attr = mms_pn_lookup(text, "attrlist", - MMS_PN_CLAUSE, - &work); - attr != NULL; - attr = mms_pn_lookup(text, "attrlist", - MMS_PN_CLAUSE, - &work)) { - - wcr_build_struct(attr, - temp_LM_DM, wka); - } - } - } - - mms_pn_destroy(cmd); - - } else { - mms_trace(MMS_ERR, "change event-cannot read"\ - "successful response: %s", - strerror(errno)); - } - - /* compare temp to existing LM DM */ - - changed = wcr_compare(temp_LM_DM, LM_DM); - - /* if changed set flage to true */ - if (changed) { - mms_trace(MMS_NOTICE, "Sending lm SIGINT"); - LM_DM->wcr_change_pending = 1; - kill(LM_DM->wcr_dev_pid, SIGINT); - } else { - mms_trace(MMS_NOTICE, "%s is unchanged", old_name); - } - - free(response); - wcr_free_DM_LM(temp_LM_DM); - free(temp_LM_DM); - - LM_DM = NULL; - - /* test - print the names of all LM DM with change pending */ - mms_list_foreach(&wka->wcr_wka_DM_LM_list, LM_DM) { - if (LM_DM->wcr_change_pending) { - if (LM_DM->wcr_DM_flag) { - mms_trace(MMS_NOTICE, "%s has change pending", - LM_DM->wcr_DM_LM_union. - wcr_DM.wcr_DM_name); - } else { - mms_trace(MMS_NOTICE, "%s has change pending", - LM_DM->wcr_DM_LM_union. - wcr_LM.wcr_LM_name); - - } - - } - } - -} - -void -wcr_old_dev(pid_t pid, wcr_wka_t *wka) -{ - wcr_DM_LM_t *DM_LM_dev; - wcr_DM_LM_t *next_DM_LM_dev; - /* int status; */ - - - for (DM_LM_dev = mms_list_head(&wka->wcr_old_DM_LM_list); - DM_LM_dev != NULL; - DM_LM_dev = next_DM_LM_dev) { - next_DM_LM_dev = mms_list_next(&wka->wcr_old_DM_LM_list, - DM_LM_dev); - if (DM_LM_dev->wcr_dev_pid == pid) { - mms_list_remove(&wka->wcr_old_DM_LM_list, DM_LM_dev); - break; - } - } - if (DM_LM_dev) { - wcr_free_DM_LM(DM_LM_dev); - free(DM_LM_dev); - } else { - mms_trace(MMS_ERR, "No child process found with pid %d", pid); - } -} - -int -wcr_cmd_status(char *response) -{ - mms_par_node_t *cmd = NULL; - mms_list_t err_list; - mms_par_err_t *err = NULL; - int rc; - - rc = mms_mmp_parse(&cmd, &err_list, response); - mms_list_foreach(&err_list, err) { - mms_trace(MMS_ERR, "error parse, " - "line %d, col %d, near token \"%s\", err code %d, %s\n", - err->pe_line, - err->pe_col, - err->pe_token, - err->pe_code, - err->pe_msg); - } - mms_pe_destroy(&err_list); - if (rc) { - mms_trace(MMS_ERR, "Parse Error: %d", rc); - mms_pn_destroy(cmd); - return (MMS_ERROR); - } - if (mms_pn_lookup(cmd, "success", MMS_PN_KEYWORD, 0) != NULL) { - rc = SUCCESS; - } else if (mms_pn_lookup(cmd, "unacceptable", - MMS_PN_KEYWORD, 0) != NULL) { - rc = UNACCEPTABLE; - } else if (mms_pn_lookup(cmd, "cancelled", - MMS_PN_KEYWORD, 0) != NULL) { - rc = CANCELLED; - } else { - rc = MMS_ERROR; - } - mms_pn_destroy(cmd); - return (rc); -} - -void -wcr_set_privilege_level(wcr_wka_t *wka, char *level) -{ - char *cmd_str = NULL; - char *response = NULL; - int rc; - - cmd_str = mms_strapp(cmd_str, - PRIVILEGE_CMD_STR, level); - if ((response = wcr_send_cmd(cmd_str, wka)) == NULL) { - mms_trace(MMS_ERR, - "Error sending %s privilege change", - level); - free(cmd_str); - return; - } - free(cmd_str); - if ((rc = wcr_cmd_status(response)) != SUCCESS) { - mms_trace(MMS_ERR, - "Error %d response for %s privilege change", - rc, level); - } - free(response); -} - -void -wcr_set_dm_broken(wcr_wka_t *wka, wcr_DM_LM_t *DM_LM_dev) -{ - char *cmd_str = NULL; - char *response = NULL; - int rc; - - cmd_str = mms_strapp(cmd_str, - ATTR_BROKEN_DM_CMD_STRING, - DM_LM_dev->wcr_DM_LM_union.wcr_DM.wcr_DM_name, - wka->wcr_host_name); - if ((response = wcr_send_cmd(cmd_str, wka)) == NULL) { - mms_trace(MMS_ERR, - "Error sending DM %s broken attribute change", - DM_LM_dev->wcr_DM_LM_union.wcr_DM.wcr_DM_name); - free(cmd_str); - return; - } - free(cmd_str); - if ((rc = wcr_cmd_status(response)) != SUCCESS) { - mms_trace(MMS_ERR, - "Error %d response for DM %s broken attribute change", - rc, DM_LM_dev->wcr_DM_LM_union.wcr_DM.wcr_DM_name); - } - free(response); -} - -void -wcr_set_lm_broken(wcr_wka_t *wka, wcr_DM_LM_t *DM_LM_dev) -{ - char *cmd_str = NULL; - char *response = NULL; - int rc; - - cmd_str = mms_strapp(cmd_str, - ATTR_BROKEN_LM_CMD_STRING, - DM_LM_dev->wcr_DM_LM_union.wcr_LM.wcr_LM_name, - wka->wcr_host_name); - if ((response = wcr_send_cmd(cmd_str, wka)) == NULL) { - mms_trace(MMS_ERR, - "Error sending LM %s broken attribute change", - DM_LM_dev->wcr_DM_LM_union.wcr_LM.wcr_LM_name); - free(cmd_str); - return; - } - free(cmd_str); - if ((rc = wcr_cmd_status(response)) != SUCCESS) { - mms_trace(MMS_ERR, - "Error %d response for LM %s broken attribute change", - rc, DM_LM_dev->wcr_DM_LM_union.wcr_LM.wcr_LM_name); - } - free(response); -} - -void -wcr_set_lm_dm_broken(wcr_wka_t *wka, wcr_DM_LM_t *DM_LM_dev) -{ - wcr_set_privilege_level(wka, "system"); - if (DM_LM_dev->wcr_DM_flag) { - wcr_set_dm_broken(wka, DM_LM_dev); - } else { - wcr_set_lm_broken(wka, DM_LM_dev); - } - wcr_set_privilege_level(wka, "administrator"); -} - -/* - * wcr_chk_child_death - * -checks for death of children - */ -void -wcr_chk_child_death(wcr_wka_t *wka) -{ - pid_t pid; - wcr_DM_LM_t *DM_LM_dev; - int status; - time_t cur_time; - - wcr_net_LM_t *net_LM; - - do { - - if ((pid = waitpid((pid_t)-1, &status, WNOHANG)) == -1) { - if (errno == EINTR) { - /* Wait interrupted, will restart wait */ - continue; - } else { - mms_trace(MMS_ERR, "Waitpid Error - %s", - strerror(errno)); - return; - } - - } else if (pid == 0) { - /* No more sigchld */ - wka->wcr_wka_sigchld = 0; - break; - } - - mms_trace(MMS_NOTICE, "child pid %d died", pid); - mms_list_foreach(&wka->wcr_wka_DM_LM_list, DM_LM_dev) { - if (DM_LM_dev->wcr_dev_pid == pid) { - break; - } - } - - if (DM_LM_dev == NULL) { - mms_list_foreach(&wka->wcr_net_LM_list, net_LM) { - if (net_LM->wcr_dev_pid == pid) { - mms_trace(MMS_NOTICE, - "SSI exited with status - %d", - WEXITSTATUS(status)); - wcr_exec_restart_ssi(wka, net_LM, - status); - } else { - wcr_old_dev(pid, wka); - } - } - continue; - } - - if (DM_LM_dev->wcr_del_pending) { - if (DM_LM_dev->wcr_DM_flag) { - mms_trace(MMS_NOTICE, - "%s Exited with status %d -"\ - " Del Pending", - DM_LM_dev->wcr_DM_LM_union. - wcr_DM.wcr_DM_name, - WEXITSTATUS(status)); - } else { - mms_trace(MMS_NOTICE, - "%s Exited with status %d -"\ - " Del Pending", - DM_LM_dev->wcr_DM_LM_union. - wcr_LM.wcr_LM_name, - WEXITSTATUS(status)); - } - wcr_del_died(wka, pid); - - } else if (DM_LM_dev->wcr_change_pending) { - if (DM_LM_dev->wcr_DM_flag) { - mms_trace(MMS_NOTICE, - "%s Exited with status %d"\ - " - Change Pending", - DM_LM_dev->wcr_DM_LM_union. - wcr_DM.wcr_DM_name, - WEXITSTATUS(status)); - } else { - mms_trace(MMS_NOTICE, - "%s Exited with status %d"\ - " - Change Pending", - DM_LM_dev->wcr_DM_LM_union. - wcr_LM.wcr_LM_name, - WEXITSTATUS(status)); - } - DM_LM_dev->wcr_starts = 0; - wcr_change_died(wka, pid); - - - } else if (WIFEXITED(status) && - ((WEXITSTATUS(status) == 1) || - (WEXITSTATUS(status) == 0))) { - if (DM_LM_dev->wcr_DM_flag) { - mms_trace(MMS_NOTICE, - "%s Exited with status %d -"\ - " No Restart", - DM_LM_dev->wcr_DM_LM_union. - wcr_DM.wcr_DM_name, - WEXITSTATUS(status)); - } else { - mms_trace(MMS_NOTICE, - "%s Exited with status %d -"\ - " No Restart", - DM_LM_dev->wcr_DM_LM_union. - wcr_LM.wcr_LM_name, - WEXITSTATUS(status)); - } - /* - * DM or LM - * Exited with status == 1 or == 0 - * Do not restart - */ - wcr_del_died(wka, pid); - - } else if (wka->wcr_connected == 0) { - /* - * Watcher not connected to MM - */ - if (DM_LM_dev->wcr_DM_flag) { - mms_trace(MMS_NOTICE, - "%s Exited with status %d -" - " Watcher not connected to MM", - DM_LM_dev->wcr_DM_LM_union. - wcr_DM.wcr_DM_name, - WEXITSTATUS(status)); - } else { - mms_trace(MMS_NOTICE, - "%s Exited with status %d -" - " Watcher not connected to MM", - DM_LM_dev->wcr_DM_LM_union. - wcr_LM.wcr_LM_name, - WEXITSTATUS(status)); - } - wcr_del_died(wka, pid); - - } else { - if (DM_LM_dev->wcr_DM_flag) { - mms_trace(MMS_NOTICE, - "%s Exited with status %d - Restart", - DM_LM_dev->wcr_DM_LM_union. - wcr_DM.wcr_DM_name, - WEXITSTATUS(status)); - } else { - mms_trace(MMS_NOTICE, - "%s Exited with status %d - Restart", - DM_LM_dev->wcr_DM_LM_union. - wcr_LM.wcr_LM_name, - WEXITSTATUS(status)); - } - - /* - * Count number of restarts in a time period. - */ - time(&cur_time); - if (WEXITSTATUS(status) == 2 || - DM_LM_dev->wcr_starts == 0 || - (cur_time - DM_LM_dev->wcr_time) > wka->wcr_time) { - DM_LM_dev->wcr_time = cur_time; - DM_LM_dev->wcr_starts = 1; - } else { - DM_LM_dev->wcr_starts++; - } - if (wka->wcr_starts != -1 && - DM_LM_dev->wcr_starts >= wka->wcr_starts) { - /* - * DM or LM - * Restarted n times in s seconds. - * Set broken and remove from list. - */ - mms_trace(MMS_ERR, - "%s restarting too quickly, " - "setting broken state.", - DM_LM_dev->wcr_DM_LM_union. - wcr_LM.wcr_LM_name); - wcr_set_lm_dm_broken(wka, DM_LM_dev); - wcr_del_died(wka, pid); - } else { - /* - * DM or LM - * Was aborted or exited w/ status != 1 or != 0 - * Restart - */ - wcr_exec_lm_dm(wka, DM_LM_dev); - } - } - /* LINTED: */ - } while (1); -} - -void -wcr_change_dev_num(wcr_wka_t *wka, char *name, int num) -{ - wcr_DM_LM_t *new_LM_DM = NULL; - - mms_list_foreach(&wka->wcr_wka_DM_LM_list, new_LM_DM) { - if (strcmp(name, - new_LM_DM-> - wcr_DM_LM_union.wcr_DM.wcr_DM_name) == 0) { - new_LM_DM->wcr_DM_LM_union. - wcr_DM.wcr_dev_number = num; - - if (new_LM_DM-> - wcr_DM_LM_union.wcr_DM. - wcr_dev_mgr_path != NULL) { - free(new_LM_DM-> - wcr_DM_LM_union.wcr_DM. - wcr_dev_mgr_path); - new_LM_DM-> - wcr_DM_LM_union.wcr_DM. - wcr_dev_mgr_path = NULL; - } - new_LM_DM->wcr_DM_LM_union. - wcr_DM.wcr_dev_mgr_path = - mms_strapp(new_LM_DM->wcr_DM_LM_union. - wcr_DM.wcr_dev_mgr_path, - WCR_DEV_MGR_PATH, num); - wcr_write_DM_cfg(new_LM_DM, wka); - } - } -} - -int -wcr_set_notify(wcr_wka_t *wka) { - char *cmd_str = NULL; - char *response = NULL; - - cmd_str = mms_strapp(cmd_str, WCR_SET_NOTIFY); - response = wcr_send_cmd(cmd_str, wka); - free(cmd_str); - if (response == NULL) { - mms_trace(MMS_ERR, - "Error setting watcher notification "); - return (1); - } else { - free(response); - } - return (0); - - -} - -void -/* LINTED: sig_mask may be used later */ -wcr_do_work(wcr_wka_t *wka, const sigset_t *sig_mask) -{ - mms_par_node_t *cmd = NULL; - mms_list_t err_list; - char *rsp = NULL; - mms_par_err_t *err = NULL; - int rc; - - - - rsp = NULL; - if (mms_reader(&wka->wcr_mms_conn, &rsp) <= 0) { - mms_trace(MMS_ERR, "Read EOF: lost connection to MM"); - mms_close(&wka->wcr_mms_conn); - return; - } - - mms_trace(MMS_NOTICE, "EVENT is %s", rsp); - - rc = mms_mmp_parse(&cmd, &err_list, rsp); - mms_list_foreach(&err_list, err) { - mms_trace(MMS_ERR, "error parse, " - "line %d, col %d, near token \"%s\", "\ - "err code %d, %s\n", - err->pe_line, - err->pe_col, - err->pe_token, - err->pe_code, - err->pe_msg); - } - - if (rc) { - mms_trace(MMS_ERR, "Parse Error: %s", - strerror(errno)); - mms_pn_destroy(cmd); - } - if (mms_pn_lookup(cmd, "event", - MMS_PN_CMD, 0) != NULL) { - wcr_add_event(cmd, wka); - } - mms_pn_destroy(cmd); - - - - -} -void -wcr_proc_events(wcr_wka_t *wka) -{ - wcr_event_t *an_event = NULL; - - char *old_inst_name = NULL; - char *new_inst_name = NULL; - char *type = NULL; - char *object = NULL; - char *inst_name = NULL; - - mms_list_foreach(&wka->wcr_events, an_event) { - if (!an_event->wcr_done) { - old_inst_name = an_event->wcr_old_inst_name; - new_inst_name = an_event->wcr_old_inst_name; - type = an_event->wcr_type; - object = an_event->wcr_object; - inst_name = an_event->wcr_inst_name; - - if (strcmp("new", type) == 0) { - /* mms_trace(MMS_NOTICE, */ - /* "Found NEW event"); */ - wcr_new_event(wka, inst_name, object); - } else if (strcmp("enable", type) == 0) { - /* mms_trace(MMS_NOTICE, */ - /* "Found ENABLE event"); */ - wcr_new_event(wka, inst_name, object); - } else if (strcmp("delete", type) == 0) { - /* mms_trace(MMS_NOTICE, */ - /* "Found DELETE event"); */ - wcr_del_event(wka, inst_name, object); - } else if (strcmp("disable", type) == 0) { - /* mms_trace(MMS_NOTICE, */ - /* "Found DISABLE event"); */ - wcr_disable_event(wka, inst_name, object); - } else if (strcmp("change", type) == 0) { - /* mms_trace(MMS_NOTICE, */ - /* "Found CHANGE event"); */ - wcr_change_event(wka, - old_inst_name, - new_inst_name, - object); - } else { - mms_trace(MMS_ERR, "Unknown Event Type"); - } - an_event->wcr_done = 1; - } - } - - -} - -int -wcr_prune(wcr_wka_t *wka) -{ - wcr_event_t *an_event; - int found_not_done = 0; - int remove; - int go = 1; - - while (go) { - remove = 0; - mms_list_foreach(&wka->wcr_events, an_event) { - if (an_event->wcr_done) { - remove = 1; - break; - } else { - found_not_done = 1; - } - } - if (remove) { - mms_list_remove(&wka->wcr_events, an_event); - free(an_event); - } else { go = 0; } - } - return (found_not_done); - -} - -/* - * wcr_refresh() - * -Read network configure file. - * -Check for mm host change. - */ - -void -wcr_refresh(wcr_wka_t *wka) -{ - mms_network_cfg_t net_cfg; - mms_list_t *mm_list = NULL; - wcr_MM_t *mm = NULL; - char *mm_host = NULL; - - mms_trace(MMS_DEVP, "service refresh"); - - /* read network config */ - if (wcr_net_cfg_read(&net_cfg, &mm_list)) { - mms_trace(MMS_ERR, "config read"); - exit(SMF_EXIT_ERR_CONFIG); - } - - /* determine if mm host changed */ - if (wka->wcr_wka_net_cfg.cli_host != NULL) { - char host[2][MMS_HOST_IDENT_LEN+1]; - char ip[2][MMS_IP_IDENT_LEN+1]; - char *ok[2]; - - ok[0] = mms_host_ident(wka->wcr_wka_net_cfg.cli_host, - host[0], ip[0]); - - mms_list_foreach(mm_list, mm) { - - ok[1] = mms_host_ident(mm->wcr_mm_host, host[1], ip[1]); - - /* compare host names and ip addresses */ - if (strcmp(mm->wcr_mm_host, - wka->wcr_wka_net_cfg.cli_host) == 0 || - - (ok[0] && ok[1] && strcmp(ip[0], ip[1]) == 0)) { - - /* validate connection */ - if (fcntl(wka->wcr_mms_conn.mms_fd, - F_GETFD, 0) != -1) { - mm_host = mm->wcr_mm_host; - } - break; - } - } - } - - /* replace network config */ - wcr_net_cfg_free(&wka->wcr_wka_net_cfg, &wka->wcr_wka_MM_list); - (void) memcpy(&wka->wcr_wka_net_cfg, &net_cfg, - sizeof (mms_network_cfg_t)); - wka->wcr_wka_MM_list = mm_list; - wka->wcr_wka_net_cfg.cli_host = mm_host; - - /* handle mm host */ - if (wka->wcr_wka_net_cfg.cli_host) { - mms_trace(MMS_NOTICE, "mm host unchanged"); - if (wcr_write_cfg(wka)) { - mms_trace(MMS_ERR, - "Unable to write cfg file"); - } - } else { - mms_trace(MMS_NOTICE, "mm host changed"); - if (wka->wcr_mms_conn.mms_fd >= 0) { - mms_close(&wka->wcr_mms_conn); - } - } -} - -void -wcr_get_system(wcr_wka_t *wka) -{ - char *response = NULL; - int rc; - mms_list_t err_list; - mms_par_err_t *err = NULL; - mms_par_node_t *cmd = NULL; - mms_par_node_t *work = NULL; - mms_par_node_t *value = NULL; - - - wka->wcr_starts = 3; - wka->wcr_time = 60; - - if ((response = wcr_send_cmd(SHOW_SYSTEM_CMD_STR, wka)) == NULL) { - mms_trace(MMS_ERR, - "Error sending system settings show command"); - return; - } - - rc = mms_mmp_parse(&cmd, &err_list, response); - mms_list_foreach(&err_list, err) { - mms_trace(MMS_ERR, "error parse, " - "line %d, col %d, near token \"%s\", err code %d, %s\n", - err->pe_line, - err->pe_col, - err->pe_token, - err->pe_code, - err->pe_msg); - } - mms_pe_destroy(&err_list); - if (rc) { - mms_trace(MMS_ERR, "Parse Error: %d", rc); - goto cleanup; - } - - if (mms_pn_lookup(cmd, "success", MMS_PN_KEYWORD, 0) == NULL) { - mms_trace(MMS_ERR, "wcr_get_system did not get a successful " - "response"); - goto cleanup; - } - - work = NULL; - if (mms_pn_lookup(cmd, "WatcherStartsLimit", - MMS_PN_STRING, &work) != NULL) { - if ((value = mms_pn_lookup(cmd, NULL, - MMS_PN_STRING, &work)) != NULL) { - wka->wcr_starts = atoi(mms_pn_token(value)); - mms_trace(MMS_DEBUG, "wcr_starts %d", wka->wcr_starts); - } - } - - work = NULL; - if (mms_pn_lookup(cmd, "WatcherTimeLimit", - MMS_PN_STRING, &work) != NULL) { - if ((value = mms_pn_lookup(cmd, NULL, - MMS_PN_STRING, &work)) != NULL) { - wka->wcr_time = atoi(mms_pn_token(value)); - mms_trace(MMS_DEBUG, "wcr_time %d", wka->wcr_time); - } - } - -cleanup: - mms_pn_destroy(cmd); - free(response); -} - -/* - * wcr_reconnect() - * -Connect to network configuration mm host. - * -Reconcile existing LM/DMs with new connection configuration. - * -Start new LM/DMs - */ - -int -wcr_reconnect(wcr_wka_t *wka) -{ - mms_list_t devmgr_list; - wcr_DM_LM_t *devmgr = NULL; - wcr_DM_LM_t *next_devmgr = NULL; - wcr_DM_LM_t *LM_DM = NULL; - wcr_DM_LM_t *next_LM_DM = NULL; - wcr_event_t *event = NULL; - wcr_event_t *next_event = NULL; - int found; - int rc; - char prev_mm_host[MAXHOSTNAMELEN]; - int mm_changed; - - for (event = mms_list_head(&wka->wcr_events); - event != NULL; - event = next_event) { - next_event = mms_list_next(&wka->wcr_events, event); - mms_list_remove(&wka->wcr_events, event); - free(event); - } - - strcpy(prev_mm_host, wka->wcr_mm_host); - if (wcr_init_session(wka)) { - mms_trace(MMS_DEVP, "refreshed"); - return (1); - } - mm_changed = strcmp(prev_mm_host, wka->wcr_mm_host); - - wcr_get_system(wka); - - if (wcr_set_notify(wka)) { - mms_trace(MMS_ERR, "notify"); - return (1); - } - - if (wcr_write_cfg(wka)) { - mms_trace(MMS_ERR, - "Unable to write cfg file"); - } - - mms_list_create(&devmgr_list, sizeof (wcr_DM_LM_t), - offsetof(wcr_DM_LM_t, wcr_DM_LM_next)); - - for (LM_DM = mms_list_head(&wka->wcr_wka_DM_LM_list); - LM_DM != NULL; - LM_DM = next_LM_DM) { - next_LM_DM = mms_list_next(&wka->wcr_wka_DM_LM_list, LM_DM); - mms_list_remove(&wka->wcr_wka_DM_LM_list, LM_DM); - mms_list_insert_tail(&devmgr_list, LM_DM); - } - - if (wcr_get_config(wka)) { - mms_trace(MMS_ERR, "get config"); - rc = 1; - goto cleanup; - } - - for (devmgr = mms_list_head(&devmgr_list); - devmgr != NULL; - devmgr = next_devmgr) { - next_devmgr = mms_list_next(&devmgr_list, devmgr); - found = 0; - for (LM_DM = mms_list_head(&wka->wcr_wka_DM_LM_list); - LM_DM != NULL; - LM_DM = next_LM_DM) { - next_LM_DM = mms_list_next(&wka->wcr_wka_DM_LM_list, - LM_DM); - if (strcmp(LM_DM->wcr_DM_LM_union. - wcr_DM.wcr_DM_name, - devmgr->wcr_DM_LM_union. - wcr_DM.wcr_DM_name) == 0) { - found = 1; - break; - } - } - if (found == 0 || LM_DM->wcr_DM_flag != devmgr->wcr_DM_flag) { - /* not found or different type */ - mms_trace(MMS_NOTICE, "Sending %s SIGTERM", - devmgr->wcr_DM_LM_union. - wcr_DM.wcr_DM_name); - devmgr->wcr_del_pending = 1; - kill(devmgr->wcr_dev_pid, SIGTERM); - mms_list_remove(&devmgr_list, devmgr); - mms_list_insert_tail(&wka->wcr_old_DM_LM_list, devmgr); - } else if (wcr_compare(LM_DM, devmgr)) { - /* found, change */ - mms_trace(MMS_NOTICE, "Sending %s SIGINT", - devmgr->wcr_DM_LM_union. - wcr_DM.wcr_DM_name); - kill(devmgr->wcr_dev_pid, SIGINT); - LM_DM->wcr_dev_pid = devmgr->wcr_dev_pid; - LM_DM->wcr_change_pending = 1; - mms_list_remove(&wka->wcr_wka_DM_LM_list, LM_DM); - mms_list_insert_head(&devmgr_list, LM_DM); - mms_list_remove(&devmgr_list, devmgr); - wcr_free_DM_LM(devmgr); - free(devmgr); - } else { - /* found, no change */ - mms_trace(MMS_NOTICE, "Found Existing %s", - devmgr->wcr_DM_LM_union. - wcr_DM.wcr_DM_name); - if (mm_changed) { - /* point children at new mm host */ - mms_trace(MMS_NOTICE, "Sending %s SIGINT", - devmgr->wcr_DM_LM_union. - wcr_DM.wcr_DM_name); - kill(devmgr->wcr_dev_pid, SIGINT); - } - mms_list_remove(&wka->wcr_wka_DM_LM_list, LM_DM); - wcr_free_DM_LM(LM_DM); - free(LM_DM); - } - } - - if (wcr_config(wka)) { - mms_trace(MMS_ERR, "config"); - rc = 1; - goto cleanup; - } - - if (wcr_get_ssi(wka, NULL)) { - mms_trace(MMS_ERR, "get ssi"); - rc = 1; - goto cleanup; - } else { - wcr_exec_all_ssi(wka); - } - - wcr_start_lm_dm(wka); - - rc = 0; - -cleanup: - /* add existing LM/DMs to list */ - for (devmgr = mms_list_head(&devmgr_list); - devmgr != NULL; - devmgr = next_devmgr) { - next_devmgr = mms_list_next(&devmgr_list, devmgr); - mms_list_remove(&devmgr_list, devmgr); - mms_list_insert_tail(&wka->wcr_wka_DM_LM_list, devmgr); - } - mms_list_destroy(&devmgr_list); - return (rc); -} - -/* - * wcr_connection() - * -Handle service SIGHUP refresh - * -Establish mm connection - */ - -void -wcr_connection(wcr_wka_t *wka) -{ - int rc = 0; - - do { - if (wka->wcr_wka_sighup) { - wka->wcr_wka_sighup = 0; - wcr_refresh(wka); - } - if (fcntl(wka->wcr_mms_conn.mms_fd, F_GETFD, 0) == -1) { - rc = wcr_reconnect(wka); - } - } while (rc); -} - -int -/* LINTED: may be used later */ -main(int argc, char **argv) -{ - - sigset_t cur_mask; - sigset_t new_mask; - int go = 1; - fd_set fdset; - int rc; - - /* - * Init the watcher - * -Initializes the watcher work area and device list - * -Becomes daemon - * -Reads cfg - * -Opens watcher device - */ - if (wcr_init_watcher(&wka)) { - mms_trace(MMS_ERR, "Unable to initialize the watcher\n"); - exit(1); - } - - mms_trace(MMS_INFO, "Watcher Starting..."); - - - /* - * Setup signal handlers - */ - wcr_setup_sig_handler(); - - /* - * Setup singals to block - */ - sigemptyset(&new_mask); - /* Block SIGCHLD which checking child death */ - sigaddset(&new_mask, SIGCHLD); - sigprocmask(SIG_BLOCK, &new_mask, &cur_mask); - - - while (go) { - - wcr_connection(&wka); - - FD_ZERO(&fdset); - FD_SET(wka.wcr_mms_conn.mms_fd, &fdset); - - /* mms_trace(MMS_NOTICE, "Waiting for Event Notification\n"); */ - wcr_chk_child_death(&wka); - while (wcr_prune(&wka)) { - wcr_proc_events(&wka); - } - mms_trace(MMS_NOTICE, "Waiting on Pselect....."); - mms_trace_flush(); /* flush mms_trace buffer */ - rc = pselect(wka.wcr_mms_conn.mms_fd+1, - &fdset, NULL, NULL, NULL, &cur_mask); - /* mms_trace(MMS_NOTICE, "Pselect returned %d error " */ - /* "code %d ", c, errno); */ - /* Process MMP commands. */ - /* mms_trace(MMS_NOTICE, "Do work"); */ - if (rc > 0) { - wcr_do_work(&wka, &cur_mask); - } - - } - -#ifdef MMS_OPENSSL - mms_ssl_finish(wka.wcr_ssl_data); -#endif /* MMS_OPENSSL */ - - return (0); - - -} diff --git a/usr/src/cmd/mms/wcr/common/watcher_impl.h b/usr/src/cmd/mms/wcr/common/watcher_impl.h deleted file mode 100644 index c96a5cca5a..0000000000 --- a/usr/src/cmd/mms/wcr/common/watcher_impl.h +++ /dev/null @@ -1,210 +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 __WATCHER_IMPL_H -#define __WATCHER_IMPL_H - - -#ifdef __cplusplus -extern "C" { -#endif - -#define WCR_DEV_START 0x01 - - -typedef struct wcr_net_LM { - char wcr_ssi_host[MAXHOSTNAMELEN]; - int wcr_ssi_port; - int wcr_acsls_port; - int wcr_ssi_starts; - int wcr_time; - pid_t wcr_dev_pid; - mms_list_node_t wcr_net_LM_next; - char *wcr_lm_name; -} wcr_net_LM_t; - -typedef struct wcr_MM { - mms_list_node_t wcr_MM_next; - char wcr_mm_host[MAXHOSTNAMELEN]; -} wcr_MM_t; - -/* wka Watcher Work Area */ -typedef struct wcr_wka { - int wcr_wka_next_ordinal; - int wcr_wka_sigchld; - int wcr_wka_sighup; - mms_network_cfg_t wcr_wka_net_cfg; - mms_list_t *wcr_wka_MM_list; - mms_list_t wcr_wka_DM_LM_list; - mms_list_t wcr_old_DM_LM_list; - int wcr_wka_fd; - char wcr_host_name[MAXHOSTNAMELEN]; - char wcr_mm_host[MAXHOSTNAMELEN]; - mms_list_t wcr_net_LM_list; - mms_list_t wcr_events; - mms_t wcr_mms_conn; - mms_err_t wcr_mms_err; - char wcr_mms_ebuf[MMS_EBUF_LEN]; - int wcr_cfd; - int wcr_time; - int wcr_starts; - int wcr_connected; - void *wcr_ssl_data; -} wcr_wka_t; - -typedef struct wcr_event { - mms_list_node_t wcr_event_next; - char wcr_type[1024]; - char wcr_object[1024]; - char wcr_inst_name[1024]; - char wcr_new_inst_name[1024]; - char wcr_old_inst_name[1024]; - int wcr_done; -} wcr_event_t; - -typedef struct wcr_DM { - char *wcr_DM_name; - char *wcr_drive_name; - char *wcr_dev_tar_path; - char *wcr_dev_mgr_path; - major_t wcr_dev_major; - minor_t wcr_dev_minor; - int wcr_dev_ordinal; - int wcr_dev_number; -} wcr_DM_t; - -typedef struct wcr_LM { - char *wcr_LM_name; - char *wcr_library_name; - -} wcr_LM_t; - -typedef struct wcr_DM_LM { - mms_list_node_t wcr_DM_LM_next; - int wcr_DM_flag; - char *wcr_host_name; - char wcr_path[1024]; - char *wcr_disabled; - pid_t wcr_dev_pid; - int wcr_del_pending; - int wcr_change_pending; - union { - struct wcr_DM wcr_DM; - struct wcr_LM wcr_LM; - } wcr_DM_LM_union; - time_t wcr_time; - int wcr_starts; -} wcr_DM_LM_t; - - -#define WCR_WORK_TO_DO 0x01 - -#define WCR_WATCHER "/devices/pseudo/dmd@0:watcher" -#define WCR_FIRST_DEV_ORDINAL DMD_FIRST_DEV_ORDINAL - -#define MMS_ERROR 1 -#define ACCEPT 2 -#define UNACCEPTABLE 3 -#define SUCCESS 4 -#define CANCELLED 5 -#define MMS_WELCOME 6 -#define MMS_UNWELCOME 7 - -#define SHOW_DM_CMD_STRING "show task [\"wcr show DMs\"] " \ - "match[ hosteq (DM.\"DMTargetHost\" \"%s\") ] " \ - "report[DM] reportmode[namevalue];" -#define SHOW_LM_CMD_STRING "show task [\"wcr show LMs\"] " \ - "match[ hosteq (LM.\"LMTargetHost\" \"%s\") ] " \ - "report[LM] reportmode[namevalue];" -#define SHOW_LM_SSI_STRING "show task [\"wcr show SSI\"] "\ - "match[ and(hosteq (LM.\"LMTargetHost\" \"%s\") "\ - "strne(LIBRARY.\"LibraryIP\" \"\")"\ - ")] "\ - "report[LM.\"LMName\" LIBRARY.\"LibraryIP\" "\ - "LIBRARY.\"LibraryACSLSPort\" LM.\"LMSSIPort\" ] "\ - "reportmode[namevalue];" -#define SHOW_LM_SSI_STRING_NAME "show task [\"wcr show SSI\"] "\ - "match[ and(hosteq (LM.\"LMTargetHost\" \"%s\") "\ - "strne(LIBRARY.\"LibraryIP\" \"\")"\ - "streq(LM.\"LMName\" \"%s\")"\ - ")] "\ - "report[LM.\"LMName\" LIBRARY.\"LibraryIP\" "\ - "LIBRARY.\"LibraryACSLSPort\" LM.\"LMSSIPort\" ] "\ - "reportmode[namevalue];" -#define SHOW_SYSTEM_CMD_STR "show task ['wcr show system settings'] " \ - "report[SYSTEM.'WatcherStartsLimit' SYSTEM.'WatcherTimeLimit'] " \ - "reportmode[namevalue];" -#define PRIVILEGE_CMD_STR "privilege task['wcr set privilege'] level[%s];" -#define ATTR_BROKEN_LM_CMD_STRING "attribute task['wcr set lm broken'] " \ - "match[and(streq(LM.'LMName' '%s') hosteq(LM.'LMTargetHost' '%s'))] " \ - "set[LM.'LMStateHard' 'broken'];" -#define ATTR_BROKEN_DM_CMD_STRING "attribute task['wcr set dm broken'] " \ - "match[and(streq(DM.'DMName' '%s') hosteq(DM.'DMTargetHost' '%s'))] " \ - "set[DM.'DMStateHard' 'broken'];" - -#define WCR_DEV_MGR_PATH "/devices/pseudo/dmd@0:%ddrm" - -#define WCR_DEV_MGR_PROG "/usr/lib/%s" -#define WCR_SSI_SH "/usr/bin/%s" -#define WCR_SSI_SCRIPT "mmsssi.sh" - -#if 0 -#define WCR_MM_PROG "/usr/bin/mms" -#endif -#define WCR_DM_LM_CONFIG_NAME "/etc/mms/config/%s_cfg.xml" -#define WCR_NOTIFY_EVENTS "\"NotifyConfigChange\"" -#define WCR_TRACE_FILE "/var/log/mms/wcr/wcr.debug" - - -#define WCR_SHOW_NEW_DM "show task [\"wcr show new dm\"] " \ - "match[ and (streq (DM.\"DMName\" \"%s\") " \ - "hosteq (DM.\"DMTargetHost\" \"%s\")) ] " \ - "report[DM] reportmode[namevalue];" - -#define WCR_SHOW_NEW_LM "show task [\"wcr show new lm\"] " \ - "match[ and (streq (LM.\"LMName\" \"%s\") " \ - "hosteq (LM.\"LMTargetHost\" \"%s\")) ] " \ - "report[LM] reportmode[namevalue];" - -#define WCR_SET_NOTIFY "notify task[\"watchernotify\"] "\ - "receive [\"NotifyConfigChange\" \"host\"]; " - -#define WCR_SSI_ERR_MSG "message task[\"wcr ssi config error\"] "\ - "who [ administrator ] severity [ error ] "\ - "message [ id ['SUNW' 'MMS' '8000' ]"\ - "arguments [ 'wcr_host' '%s' 'lmname1' '%s' "\ - "'ssiport1' '%d' 'ssihost1' '%s' 'lmname2' '%s' "\ - "'ssiport2' '%d' 'ssihost2' '%s']];" - -#define WCR_SSI_PATH_MSG "message task[\"wcr ssi path error\"] "\ - "who [ administrator ] severity [ error ] "\ - "message [ id ['SUNW' 'MMS' '8001' ]"\ - "arguments [ 'ssipath' '%s']];" - - -#ifdef __cplusplus -} -#endif - -#endif /* __WATCHER_IMPL_H */ diff --git a/usr/src/cmd/mms/wcr/i386/Makefile b/usr/src/cmd/mms/wcr/i386/Makefile deleted file mode 100644 index 7e02307f11..0000000000 --- a/usr/src/cmd/mms/wcr/i386/Makefile +++ /dev/null @@ -1,27 +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.cmd -include ../Makefile.com diff --git a/usr/src/cmd/mms/wcr/sparc/Makefile b/usr/src/cmd/mms/wcr/sparc/Makefile deleted file mode 100644 index 7e02307f11..0000000000 --- a/usr/src/cmd/mms/wcr/sparc/Makefile +++ /dev/null @@ -1,27 +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.cmd -include ../Makefile.com diff --git a/usr/src/common/mms/h/acsapi.h b/usr/src/common/mms/h/acsapi.h deleted file mode 100644 index 586afeae33..0000000000 --- a/usr/src/common/mms/h/acsapi.h +++ /dev/null @@ -1,400 +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 _ACSAPI_H_ -#define _ACSAPI_H_ - -#ifndef _ACSSYS_H_ - -#endif - -#include "inclds.h" - -#include "apidef.h" -#include "apipro.h" - - -typedef struct { - DRIVEID drive_id; - STATUS status; - DRIVEID dlocked_drive_id; -} ACS_LO_DRV_STATUS; - -typedef struct { - VOLID vol_id; - STATUS status; - VOLID dlocked_vol_id; -} ACS_LO_VOL_STATUS; - -typedef struct { - STATUS audit_int_status; - CAPID cap_id; - unsigned short count; - VOLID vol_id[MAX_ID]; - STATUS vol_status[MAX_ID]; -} ACS_AUDIT_INT_RESPONSE; - - -typedef struct { - STATUS audit_acs_status; - unsigned short count; - ACS acs[MAX_ID]; - STATUS acs_status[MAX_ID]; -} ACS_AUDIT_ACS_RESPONSE; - -typedef struct { - STATUS audit_lsm_status; - unsigned short count; - LSMID lsm_id[MAX_ID]; - STATUS lsm_status[MAX_ID]; -} ACS_AUDIT_LSM_RESPONSE; - -typedef struct { - STATUS audit_pnl_status; - unsigned short count; - PANELID panel_id[MAX_ID]; - STATUS panel_status[MAX_ID]; -} ACS_AUDIT_PNL_RESPONSE; - -typedef struct { - STATUS audit_sub_status; - unsigned short count; - SUBPANELID subpanel_id[MAX_ID]; - STATUS subpanel_status[MAX_ID]; -} ACS_AUDIT_SUB_RESPONSE; - -typedef struct { - STATUS audit_srv_status; -} ACS_AUDIT_SRV_RESPONSE; - -typedef struct { - STATUS cancel_status; - REQ_ID req_id; -} ACS_CANCEL_RESPONSE; - -typedef struct { - STATUS idle_status; -} ACS_IDLE_RESPONSE; - -typedef struct { - STATUS start_status; -} ACS_START_RESPONSE; - -typedef struct { - STATUS enter_status; - CAPID cap_id; - unsigned short count; - VOLID vol_id[MAX_ID]; - STATUS vol_status[MAX_ID]; -} ACS_ENTER_RESPONSE; - -typedef struct { - STATUS eject_status; - CAPID cap_id; - unsigned short count; - CAPID cap_used[MAX_ID]; - VOLID vol_id[MAX_ID]; - STATUS vol_status[MAX_ID]; -} ACS_EJECT_RESPONSE; - -typedef struct { - STATUS clear_lock_drv_status; - unsigned short count; - ACS_LO_DRV_STATUS drv_status[MAX_ID]; -} ACS_CLEAR_LOCK_DRV_RESPONSE; - -typedef struct { - STATUS clear_lock_vol_status; - unsigned short count; - ACS_LO_VOL_STATUS vol_status[MAX_ID]; -} ACS_CLEAR_LOCK_VOL_RESPONSE; - -typedef struct { - STATUS lock_drv_status; - LOCKID lock_id; - unsigned short count; - ACS_LO_DRV_STATUS drv_status[MAX_ID]; -} ACS_LOCK_DRV_RESPONSE; - -typedef struct { - STATUS lock_vol_status; - LOCKID lock_id; - unsigned short count; - ACS_LO_VOL_STATUS vol_status[MAX_ID]; -} ACS_LOCK_VOL_RESPONSE; - -typedef struct { - STATUS unlock_drv_status; - unsigned short count; - ACS_LO_DRV_STATUS drv_status[MAX_ID]; -} ACS_UNLOCK_DRV_RESPONSE; - -typedef struct { - STATUS unlock_vol_status; - unsigned short count; - ACS_LO_VOL_STATUS vol_status[MAX_ID]; -} ACS_UNLOCK_VOL_RESPONSE; - -typedef struct { - STATUS dismount_status; - VOLID vol_id; - DRIVEID drive_id; -} ACS_DISMOUNT_RESPONSE; - -typedef struct { - STATUS mount_status; - VOLID vol_id; - DRIVEID drive_id; -} ACS_MOUNT_RESPONSE; - -typedef struct { - STATUS mount_scratch_status; - VOLID vol_id; - POOL pool; - DRIVEID drive_id; -} ACS_MOUNT_SCRATCH_RESPONSE; - -typedef struct { - STATUS query_acs_status; - unsigned short count; - QU_ACS_STATUS acs_status[MAX_ID]; -} ACS_QUERY_ACS_RESPONSE; - -typedef struct { - STATUS query_cap_status; - unsigned short count; - QU_CAP_STATUS cap_status[MAX_ID]; -} ACS_QUERY_CAP_RESPONSE; - -typedef struct { - STATUS query_cln_status; - unsigned short count; - QU_CLN_STATUS cln_status[MAX_ID]; -} ACS_QUERY_CLN_RESPONSE; - -typedef struct { - STATUS query_drv_status; - unsigned short count; - QU_DRV_STATUS drv_status[MAX_ID]; -} ACS_QUERY_DRV_RESPONSE; - -typedef struct { - STATUS query_drv_group_status; - GROUPID group_id; - GROUP_TYPE group_type; - unsigned short count; - QU_VIRT_DRV_MAP virt_drv_map[MAX_VTD_MAP]; -} ACS_QU_DRV_GROUP_RESPONSE; - -typedef struct { - STATUS query_lock_drv_status; - unsigned short count; - QL_DRV_STATUS drv_status[MAX_ID]; -} ACS_QUERY_LOCK_DRV_RESPONSE; - -typedef struct { - STATUS query_lock_vol_status; - unsigned short count; - QL_VOL_STATUS vol_status[MAX_ID]; -} ACS_QUERY_LOCK_VOL_RESPONSE; - -typedef struct { - STATUS query_lsm_status; - unsigned short count; - QU_LSM_STATUS lsm_status[MAX_ID]; -} ACS_QUERY_LSM_RESPONSE; - -typedef struct { - STATUS query_mmi_status; - QU_MMI_RESPONSE mixed_media_info_status; -} ACS_QUERY_MMI_RESPONSE; - -typedef struct { - STATUS query_mnt_status; - unsigned short count; - QU_MNT_STATUS mnt_status[MAX_ID]; -} ACS_QUERY_MNT_RESPONSE; - -typedef struct { - STATUS query_msc_status; - unsigned short count; - QU_MSC_STATUS msc_status[MAX_ID]; -} ACS_QUERY_MSC_RESPONSE; - -typedef struct { - STATUS query_pol_status; - unsigned short count; - QU_POL_STATUS pool_status[MAX_ID]; -} ACS_QUERY_POL_RESPONSE; - -typedef struct { - STATUS query_prt_status; - unsigned short count; - QU_PRT_STATUS prt_status[MAX_ID]; -} ACS_QUERY_PRT_RESPONSE; - -typedef struct { - STATUS query_req_status; - unsigned short count; - QU_REQ_STATUS req_status[MAX_ID]; -} ACS_QUERY_REQ_RESPONSE; - -typedef struct { - STATUS query_scr_status; - unsigned short count; - QU_SCR_STATUS scr_status[MAX_ID]; -} ACS_QUERY_SCR_RESPONSE; - -typedef struct { - STATUS query_srv_status; - unsigned short count; - QU_SRV_STATUS srv_status[MAX_ID]; -} ACS_QUERY_SRV_RESPONSE; - -typedef struct { - STATUS query_subpool_name_status; - unsigned short count; - QU_SUBPOOL_NAME_STATUS subpool_name_status[MAX_ID]; -} ACS_QU_SUBPOOL_NAME_RESPONSE; - -typedef struct { - STATUS query_vol_status; - unsigned short count; - QU_VOL_STATUS vol_status[MAX_ID]; -} ACS_QUERY_VOL_RESPONSE; - -typedef struct { - STATUS set_cap_status; - CAP_PRIORITY cap_priority; - CAP_MODE cap_mode; - unsigned short count; - CAPID cap_id[MAX_ID]; - STATUS cap_status[MAX_ID]; -} ACS_SET_CAP_RESPONSE; - -typedef struct { - STATUS set_clean_status; - unsigned short max_use; - unsigned short count; - VOLID vol_id[MAX_ID]; - STATUS vol_status[MAX_ID]; -} ACS_SET_CLEAN_RESPONSE; - -typedef struct { - STATUS set_scratch_status; - POOL pool; - unsigned short count; - VOLID vol_id[MAX_ID]; - STATUS vol_status[MAX_ID]; -} ACS_SET_SCRATCH_RESPONSE; - -typedef struct { - STATUS define_pool_status; - unsigned long lwm; - unsigned long hwm; - unsigned long attributes; - unsigned short count; - POOL pool[MAX_ID]; - STATUS pool_status[MAX_ID]; -} ACS_DEFINE_POOL_RESPONSE; - -typedef struct { - STATUS delete_pool_status; - unsigned short count; - POOL pool[MAX_ID]; - STATUS pool_status[MAX_ID]; -} ACS_DELETE_POOL_RESPONSE; - -typedef struct { - STATUS vary_acs_status; - STATE acs_state; - unsigned short count; - ACS acs[MAX_ID]; - STATUS acs_status[MAX_ID]; -} ACS_VARY_ACS_RESPONSE; - -typedef struct { - STATUS vary_cap_status; - STATE cap_state; - unsigned short count; - CAPID cap_id[MAX_ID]; - STATUS cap_status[MAX_ID]; -} ACS_VARY_CAP_RESPONSE; - -typedef struct { - STATUS vary_drv_status; - STATE drive_state; - unsigned short count; - DRIVEID drive_id[MAX_ID]; - STATUS drive_status[MAX_ID]; -} ACS_VARY_DRV_RESPONSE; - -typedef struct { - STATUS vary_lsm_status; - STATE lsm_state; - unsigned short count; - LSMID lsm_id[MAX_ID]; - STATUS lsm_status[MAX_ID]; -} ACS_VARY_LSM_RESPONSE; - -typedef struct { - STATUS vary_prt_status; - STATE port_state; - unsigned short count; - PORTID port_id[MAX_ID]; - STATUS port_status[MAX_ID]; -} ACS_VARY_PRT_RESPONSE; - -typedef struct { - STATUS register_status; - EVENT_REPLY_TYPE event_reply_type; - EVENT_SEQUENCE event_sequence; - EVENT event; -} ACS_REGISTER_RESPONSE; - -typedef struct { - STATUS unregister_status; - EVENT_REGISTER_STATUS event_register_status; -} ACS_UNREGISTER_RESPONSE; - -typedef struct { - STATUS check_registration_status; - EVENT_REGISTER_STATUS event_register_status; -} ACS_CHECK_REGISTRATION_RESPONSE; - -typedef struct { - STATUS display_status; - TYPE display_type; - DISPLAY_XML_DATA display_xml_data; -} ACS_DISPLAY_RESPONSE; - -typedef struct { - STATUS mount_pinfo_status; - POOLID pool_id; - DRIVEID drive_id; - VOLID vol_id; -} ACS_MOUNT_PINFO_RESPONSE; - -#endif /* _ACSAPI_H_ */ diff --git a/usr/src/common/mms/h/acssys.h b/usr/src/common/mms/h/acssys.h deleted file mode 100644 index 43991d1d2c..0000000000 --- a/usr/src/common/mms/h/acssys.h +++ /dev/null @@ -1,134 +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 _ACSSYS_H_ -#define _ACSSYS_H_ - - -#include <limits.h> -#ifdef AS400 -#define acs_audit_acs ACS000 -#define acs_audit_lsm ACS001 -#define acs_audit_panel ACS002 -#define acs_audit_subpanel ACS003 -#define acs_cancel ACS004 -#define acs_clear_lock_drive ACS005 -#define acs_clear_lock_volume ACS006 -#define acs_command ACS111 -#define acs_define_pool ACS007 -#define acs_delete_pool ACS008 -#define acs_dismount ACS009 -#define acs_eject ACS010 -#define acs_enter ACS011 -#define acs_idle ACS012 -#define acs_lock_drive ACS013 -#define acs_lock_volume ACS014 -#define acs_mount ACS015 -#define acs_mount_scratch ACS016 -#define acs_query_acs ACS017 -#define acs_query_lsm ACS018 -#define acs_query_clean ACS019 -#define acs_query_drive ACS020 -#define acs_query_lock_drive ACS021 -#define acs_query_lock_volume ACS022 -#define acs_query_cap ACS023 -#define acs_query_mount ACS024 -#define acs_query_mount_scratch ACS025 -#define acs_query_pool ACS026 -#define acs_query_port ACS027 -#define acs_query_request ACS028 -#define acs_query_scratch ACS029 -#define acs_query_server ACS030 -#define acs_query_volume ACS031 -#define acs_response ACS032 -#define acs_set_access ACS055 -#define acs_set_cap ACS033 -#define acs_set_clean ACS034 -#define acs_set_scratch ACS035 -#define acs_start ACS036 -#define acs_state ACS112 -#define acs_status ACS110 -#define acs_unlock_drive ACS037 -#define acs_unlock_volume ACS038 -#define acs_vary_acs ACS039 -#define acs_vary_drive ACS040 -#define acs_vary_lsm ACS041 -#define acs_vary_port ACS042 -#define acs_venter ACS043 -#define acs_xeject ACS044 -#define acs_query_mm_info ACS045 -#define acs_vary_cap ACS046 -#define acs_audit_server ACS047 -#define acs_register ACS048 -#define acs_unregister ACS049 -#define acs_check_registration ACS050 -#define acs_display ACS051 -#define acs_mount_pinfo ACS052 -#define acs_query_mount_scratch_pinfo ACS053 -#define acs_query_drive_group ACS056 -#define acs_query_subpool_name ACS057 -#define acs_get_packet_version ACS107 -#define acs_type ACS109 -#define acs_type_response ACS108 -#endif - - -#define _DB_DEFS_API_HEADER_ "api/db_defs_api.h" -#define _DEFS_API_HEADER_ "api/defs_api.h" -#define _IDENT_API_HEADER_ "api/ident_api.h" -#define _IPC_HDR_API_HEADER_ "api/ipc_hdr_api.h" -#define _STRUCTS_API_HEADER_ "api/structs_api.h" -#define _LMSTRUCTS_API_HEADER_ "api/lm_structs_api.h" - - - -typedef enum -{ - ACSMSG_BAD_INPUT_SELECT = 1, - ACSMSG_IPC_READ_FAILED, - ACSMSG_IPC_WRITE_FAILED, - ACSMSG_IPC_CREATE_FAILED, - ACSMSG_NOT_EXTENDED, - ACSMSG_BAD_VERSION, - ACSMSG_INVALID_VERSION, - ACSMSG_BAD_COUNT, - ACSMSG_BAD_SOCKET, - ACSMSG_BAD_FINAL_RESPONSE, - ACSMSG_BAD_INT_RESPONSE, - ACSMSG_BAD_QUERY_RESPONSE, - ACSMSG_BAD_RESPONSE, - ACSMSG_AUD_RES_COUNT, - ACSMSG_BAD_AUDIT_RESP_TYPE, - ACSMSG_BAD_QUERY_RESP_TYPE, - ACSMSG_VARY_RESP_COUNT, - ACSMSG_BAD_VARY_RESP_TYPE, - ACSMSG_SSI_NOT_RUNNING, - ACSMSG_VARY_RESP_FAILED, - ACSMSG_BAD_RESPONSE_TYPE, - ACSMSG_INVALID_TYPE, - ACSMSG_LAST, - ACSMSG_FOR_SIZE_ONLY = INT_MAX -} ACSMESSAGES; -#endif /* _ACSSYS_H_ */ diff --git a/usr/src/common/mms/h/api/db_defs_api.h b/usr/src/common/mms/h/api/db_defs_api.h deleted file mode 100644 index 71a2eee165..0000000000 --- a/usr/src/common/mms/h/api/db_defs_api.h +++ /dev/null @@ -1,643 +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 _DB_DEFS_API_ -#define _DB_DEFS_API_ -#ifdef sun -#define SIGNED -#else -#define SIGNED signed -#endif - -typedef SIGNED char ACS; -#define MIN_ACS 0 -#define MAX_ACS 31 -#define ANY_ACS -1 - -#define MIN_VTD 0x80 - -typedef SIGNED char LSM; -#define MIN_LSM 0 -#define MAX_LSM 126 -#define ANY_LSM -1 - -typedef char PORT; -#define MIN_PORT 0 -#define MAX_PORT 15 -#define PORT_NAME_SIZE 70 - -#define CSI_NAME_LENGTH 16 -#define MAX_CSI_LABEL 20 -#define MAX_CSI_DESCRIP 1000 - -typedef SIGNED char CAP; -#define MIN_CAP 0 -#define MAX_CAP 2 -#define ANY_CAP -1 -#define ALL_CAP -2 - -typedef char PANEL; -#define MIN_PANEL 0 -#define MAX_PANEL 60 - -typedef char DRIVE; -#define MIN_DRIVE 0 -#define MAX_DRIVE 19 - -typedef char ROW; -#define MIN_ROW 0 -#define MAX_ROW 41 - -typedef char COL; -#define MIN_COL 0 -#define MAX_COL 23 - -typedef short LOCKID; -#define NO_LOCK_ID 0 -#define MIN_LOCK_ID 0 -#define MAX_LOCK_ID 32767 - -typedef SIGNED char MEDIA_TYPE; -#define ANY_MEDIA_TYPE (-1) -#define ALL_MEDIA_TYPE (-2) -#define UNKNOWN_MEDIA_TYPE (-3) - -typedef SIGNED char DRIVE_TYPE; -#define ANY_DRIVE_TYPE (-1) -#define UNKNOWN_DRIVE_TYPE (-3) - -typedef long POOL; -#define COMMON_POOL 0 -#define MAX_POOL 65534 -#define SAME_POOL -1 - -#define MAX_WATER_MARK 2147483647 -#define MIN_WATER_MARK 0 - -typedef SIGNED char CAP_PRIORITY; -#define NO_PRIORITY 0 -#define MIN_PRIORITY 1 -#define MAX_PRIORITY 16 -#define SAME_PRIORITY -1 - -typedef char REQUEST_PRIORITY; - -#define PCAP_PRIORITY 98 -#define DEFAULT_PRIORITY 25 -#define PCAP_SIZE 1 - -typedef SIGNED int PANEL_TYPE; - -typedef char HAND; -#define MIN_HAND 0 -#define MAX_HAND 1 - -typedef unsigned long EVENT_SEQUENCE; - -#define EXTERNAL_USERID_SIZE 64 -typedef struct { - char user_label[EXTERNAL_USERID_SIZE]; -} USERID; - -#define EXTERNAL_PASSWORD_SIZE 64 -typedef struct { - char password[EXTERNAL_PASSWORD_SIZE]; -} PASSWORD; - -typedef struct { - USERID user_id; - PASSWORD password; -} ACCESSID; - - -typedef long FREECELLS; -#ifdef LINUX -#undef OVERFLOW -#endif - -#define OVERFLOW 1 -#define EXTERNAL_LABEL_SIZE 6 -#define SOCKET_NAME_SIZE 14 - -#define JOB_NAME_SIZE 8 -#define STEP_NAME_SIZE 8 -#define DATASET_NAME_SIZE 44 -#define SUBPOOL_NAME_SIZE 13 -#define GROUPID_SIZE 8 -#define MGMT_CLAS_SIZE 8 - - -#define MAX_DRIVE_PANEL 4 - -typedef enum { - LOCATION_FIRST = 0, - LOCATION_CELL, - LOCATION_DRIVE, - LOCATION_LAST -} LOCATION; - -/* state codes */ -typedef enum { - STATE_FIRST = 0, - STATE_CANCELLED, - STATE_DIAGNOSTIC, - STATE_IDLE, - STATE_IDLE_PENDING, - - STATE_OFFLINE, - STATE_OFFLINE_PENDING, - STATE_ONLINE, - STATE_RECOVERY, - STATE_RUN, - - STATE_CONNECT, - STATE_DISCONNECT, - STATE_DISBAND_1, - STATE_DISBAND_2, - STATE_DISBAND_3, - STATE_DISBAND_4, - STATE_JOIN_1, - STATE_JOIN_2, - STATE_RESIGN_1, - STATE_RESIGN_2, - - STATE_RESIGN_3, - - STATE_LAST -} STATE; - -typedef enum { - VOLUME_TYPE_FIRST = 0, - VOLUME_TYPE_DIAGNOSTIC, - VOLUME_TYPE_STANDARD, - VOLUME_TYPE_DATA, - VOLUME_TYPE_SCRATCH, - VOLUME_TYPE_CLEAN, - VOLUME_TYPE_MVC, - VOLUME_TYPE_VTV, - VOLUME_TYPE_LAST -} VOLUME_TYPE; - -typedef enum { - LABEL_ATTRIBUTE_STANDARD = 0, - LABEL_ATTRIBUTE_VIRTUAL, - LABEL_ATTRIBUTE_LAST -} LABEL_ATTR; - -typedef enum { - CAP_MODE_FIRST = 0, - CAP_MODE_AUTOMATIC, - CAP_MODE_MANUAL, - CAP_MODE_SAME, - CAP_MODE_LAST -} CAP_MODE; - -typedef enum { - GROUP_TYPE_FIRST = 0, - GROUP_TYPE_VTSS, - GROUP_TYPE_LAST -} GROUP_TYPE; -typedef enum { - STATUS_SUCCESS = 0, - STATUS_ACS_FULL, - STATUS_ACS_NOT_IN_LIBRARY, - STATUS_ACS_OFFLINE, - STATUS_ACSLM_IDLE, - - STATUS_ACTIVITY_END, - STATUS_ACTIVITY_START, - STATUS_AUDIT_ACTIVITY, - STATUS_AUDIT_IN_PROGRESS, - STATUS_CANCELLED, - - STATUS_CAP_AVAILABLE, - STATUS_CAP_FULL, - STATUS_CAP_IN_USE, - STATUS_CELL_EMPTY, - STATUS_CELL_FULL, - - STATUS_CELL_INACCESSIBLE, - STATUS_CELL_RESERVED, - STATUS_CLEAN_DRIVE, - STATUS_COMMUNICATION_FAILED, - STATUS_CONFIGURATION_ERROR, - - STATUS_COUNT_TOO_SMALL, - STATUS_COUNT_TOO_LARGE, - STATUS_CURRENT, - STATUS_DATABASE_ERROR, - STATUS_DEGRADED_MODE, - - STATUS_DONE, - STATUS_DOOR_CLOSED, - STATUS_DOOR_OPENED, - STATUS_DRIVE_AVAILABLE, - STATUS_DRIVE_IN_USE, - - STATUS_DRIVE_NOT_IN_LIBRARY, - STATUS_DRIVE_OFFLINE, - STATUS_DRIVE_RESERVED, - STATUS_DUPLICATE_LABEL, - STATUS_EJECT_ACTIVITY, - - STATUS_ENTER_ACTIVITY, - STATUS_EVENT_LOG_FULL, - STATUS_IDLE_PENDING, - STATUS_INPUT_CARTRIDGES, - STATUS_INVALID_ACS, - - STATUS_INVALID_COLUMN, - STATUS_INVALID_COMMAND, - STATUS_INVALID_DRIVE, - STATUS_INVALID_LSM, - STATUS_INVALID_MESSAGE, - - STATUS_INVALID_OPTION, - STATUS_INVALID_PANEL, - STATUS_INVALID_PORT, - STATUS_INVALID_ROW, - STATUS_INVALID_STATE, - - STATUS_INVALID_SUBPANEL, - STATUS_INVALID_TYPE, - STATUS_INVALID_VALUE, - STATUS_INVALID_VOLUME, - STATUS_IPC_FAILURE, - - STATUS_LIBRARY_BUSY, - STATUS_LIBRARY_FAILURE, - STATUS_LIBRARY_NOT_AVAILABLE, - STATUS_LOCATION_OCCUPIED, - STATUS_LSM_FULL, - - STATUS_LSM_NOT_IN_LIBRARY, - STATUS_LSM_OFFLINE, - STATUS_MESSAGE_NOT_FOUND, - STATUS_MESSAGE_TOO_LARGE, - STATUS_MESSAGE_TOO_SMALL, - - STATUS_MISPLACED_TAPE, - STATUS_MULTI_ACS_AUDIT, - STATUS_NORMAL, - STATUS_NONE, - STATUS_NOT_IN_SAME_ACS, - - STATUS_ONLINE, - STATUS_OFFLINE, - STATUS_PENDING, - STATUS_PORT_NOT_IN_LIBRARY, - STATUS_PROCESS_FAILURE, - - STATUS_RECOVERY_COMPLETE, - STATUS_RECOVERY_FAILED, - STATUS_RECOVERY_INCOMPLETE, - STATUS_RECOVERY_STARTED, - STATUS_REMOVE_CARTRIDGES, - - STATUS_RETRY, - STATUS_STATE_UNCHANGED, - STATUS_TERMINATED, - STATUS_VALID, - STATUS_VALUE_UNCHANGED, - - STATUS_VARY_DISALLOWED, - STATUS_VOLUME_ADDED, - STATUS_VOLUME_EJECTED, - STATUS_VOLUME_ENTERED, - STATUS_VOLUME_FOUND, - - STATUS_VOLUME_HOME, - STATUS_VOLUME_IN_DRIVE, - STATUS_VOLUME_IN_TRANSIT, - STATUS_VOLUME_NOT_IN_DRIVE, - STATUS_VOLUME_NOT_IN_LIBRARY, - - STATUS_UNREADABLE_LABEL, - STATUS_UNSUPPORTED_OPTION, - STATUS_UNSUPPORTED_STATE, - STATUS_UNSUPPORTED_TYPE, - STATUS_VOLUME_IN_USE, - - STATUS_PORT_FAILURE, - STATUS_MAX_PORTS, - STATUS_PORT_ALREADY_OPEN, - STATUS_QUEUE_FAILURE, - STATUS_NI_FAILURE, - STATUS_RPC_FAILURE = STATUS_NI_FAILURE, - - STATUS_NI_TIMEDOUT, - STATUS_INVALID_COMM_SERVICE, - STATUS_COMPLETE, - STATUS_AUDIT_FAILED, - STATUS_NO_PORTS_ONLINE, - - STATUS_CARTRIDGES_IN_CAP, - STATUS_TRANSLATION_FAILURE, - STATUS_DATABASE_DEADLOCK, - STATUS_DIAGNOSTIC, - STATUS_DUPLICATE_IDENTIFIER, - - STATUS_EVENT_LOG_FAILURE, - STATUS_DISMOUNT_ACTIVITY, - STATUS_MOUNT_ACTIVITY, - STATUS_POOL_NOT_FOUND, - STATUS_POOL_NOT_EMPTY, - - STATUS_INVALID_RANGE, - STATUS_INVALID_POOL, - STATUS_POOL_HIGH_WATER, - STATUS_POOL_LOW_WATER, - STATUS_INVALID_VERSION, - - STATUS_MISSING_OPTION, - STATUS_INCORRECT_ATTRIBUTE, - STATUS_INVALID_LOCKID, - STATUS_VOLUME_AVAILABLE, - STATUS_READABLE_LABEL, - - STATUS_NO_CAP_AVAILABLE, - STATUS_LOCK_FAILED, - STATUS_DEADLOCK, - STATUS_LOCKID_NOT_FOUND, - STATUS_INCORRECT_LOCKID, - - STATUS_SCRATCH_NOT_AVAILABLE, - STATUS_CLEAN_DRIVE_COMPLETE, - STATUS_VOLUME_NOT_FOUND, - STATUS_CAP_DOOR_OPEN, - STATUS_CAP_INOPERATIVE, - - STATUS_DISK_FULL, - STATUS_CAP_NOT_IN_LIBRARY, - STATUS_CAP_OFFLINE, - STATUS_INVALID_CAP, - STATUS_INCORRECT_CAP_MODE, - - STATUS_INCORRECT_STATE, - STATUS_VARY_IN_PROGRESS, - STATUS_ACS_ONLINE, - STATUS_AUTOMATIC, - STATUS_MANUAL, - - STATUS_VOLUME_DELETED, - STATUS_INSERT_MAGAZINES, - STATUS_UNSUPPORTED_COMMAND, - STATUS_COMMAND_ACCESS_DENIED, - STATUS_VOLUME_ACCESS_DENIED, - - STATUS_OWNER_NOT_FOUND, - STATUS_INVALID_DRIVE_TYPE, - STATUS_INVALID_MEDIA_TYPE, - STATUS_INCOMPATIBLE_MEDIA_TYPE, - STATUS_DRIVE_FOUND, - - STATUS_CAP_DONE, - STATUS_INVALID_SUBSYSID, - STATUS_LSM_OFFLINE_PENDING, - STATUS_PORT_OFFLINE, - STATUS_COMMUNICATING, - - STATUS_NOT_COMMUNICATING, - STATUS_IDLE, - STATUS_OFFLINE_PENDING, - STATUS_SWITCHOVER_INITIATED, - STATUS_SWITCHOVER_RECOVERY_COMPLETE, - - STATUS_LMU_STATUS_CHANGE_NEW_MASTER, - STATUS_LMU_STATUS_CHANGE_STANDBY_COMM, - STATUS_LMU_STATUS_CHANGE_STANDBY_NOT_COMM, - STATUS_STANDBY_LMU_NO_PORTS, - STATUS_SWITCHOVER_IN_PROGRESS, - - STATUS_LAST_MASTER_PORT, - STATUS_NOT_CONFIGD_DUAL, - STATUS_DISALLOWED_ON_MASTER, - STATUS_LMU_TO_LMU_LINK_BAD, - STATUS_TOO_MANY_NAKS, - - STATUS_MASTER_NOT_RESPONDING, - STATUS_MOVE_ACTIVITY, - STATUS_VOLUME_MISSING, - STATUS_VOLUME_BEING_RECOVERED, - STATUS_INVALID_CLIENT, - - STATUS_VOLUME_REACTIVATED, - STATUS_VOLUME_ABSENT, - STATUS_UNIT_ATTENTION, - STATUS_READY, - STATUS_NOT_READY, - - STATUS_SERIAL_NUM_CHG, - STATUS_HARDWARE_ERROR, - STATUS_MONITOR_COMPLETE, - STATUS_PTP_NOT_FOUND, - STATUS_INVALID_EVENT_CLASS, - - STATUS_HAND_NOT_FOUND, - STATUS_LMU_NOT_FOUND, - STATUS_OPERATIVE, - STATUS_INOPERATIVE, - STATUS_MAINT_REQUIRED, - - STATUS_CAP_DOOR_CLOSED, - STATUS_LSM_TYPE_CHG, - STATUS_CONFIGURATION_CHANGED, - STATUS_DRIVE_TYPE_CHG, - STATUS_NI_TIMEOUT, - - STATUS_VOLUME_OVER_MAX_CLEAN, - STATUS_VOLUME_CLEAN_CART_SPENT, - STATUS_DRIVE_ADDED, - STATUS_DRIVE_REMOVED, - STATUS_LMU_TYPE_CHG, - - - STATUS_LMU_COMPAT_LVL_CHG, - STATUS_LMU_NOW_STANDALONE, - STATUS_LMU_NOW_MASTER, - STATUS_LMU_NOW_STANDBY, - STATUS_PANEL_NOT_IN_LIBRARY, - - - STATUS_PANEL_NOT_FOUND, - STATUS_STORAGE_CELL_MAP_CHANGED, - STATUS_NOT_A_DRIVE_PANEL, - STATUS_NO_DRIVES_FOUND, - STATUS_LKEY_INVALID, - - - STATUS_LKEY_EXPIRED, - STATUS_LKEY_DUE_TO_EXPIRE, - STATUS_LKEY_CAPACITY_EXCEEDED, - - STATUS_LAST -} STATUS; - -typedef enum { - MODE_FIRST = 0, - MODE_DUAL_LMU, - MODE_SINGLE_LMU, - MODE_SCSI_LMU, - MODE_NONE, - MODE_LAST -} MODE; - -typedef enum { - ROLE_FIRST = 0, - ROLE_MASTER_A, - ROLE_MASTER_B, - ROLE_STANDBY_A, - ROLE_STANDBY_B, - ROLE_NONE, - ROLE_LAST -} ROLE; - -typedef enum { - CHANGE_FIRST = 0, - CHANGE_INCREMENT, - CHANGE_DECREMENT, - CHANGE_LAST -} CHANGE_DIRECTION; - - -typedef enum { - EVENT_CLASS_FIRST = 0, - EVENT_CLASS_VOLUME, - EVENT_CLASS_RESOURCE, - EVENT_CLASS_DRIVE_ACTIVITY, - EVENT_CLASS_LAST -} EVENT_CLASS_TYPE; - -typedef enum { - EVENT_REPLY_FIRST = 0, - EVENT_REPLY_REGISTER, - EVENT_REPLY_UNREGISTER, - EVENT_REPLY_SUPERCEDED, - EVENT_REPLY_SHUTDOWN, - EVENT_REPLY_CLIENT_CHECK, - EVENT_REPLY_RESOURCE, - EVENT_REPLY_VOLUME, - EVENT_REPLY_DRIVE_ACTIVITY, - EVENT_REPLY_LAST -} EVENT_REPLY_TYPE; - - -typedef enum { - RESOURCE_FIRST = 0, - RESOURCE_ONLINE = 1, - RESOURCE_OFFLINE, - RESOURCE_OPERATIVE, - RESOURCE_INOPERATIVE, - RESOURCE_MAINT_REQUIRED, - RESOURCE_UNIT_ATTENTION, - RESOURCE_HARDWARE_ERROR, - RESOURCE_DEGRADED_MODE, - RESOURCE_SERIAL_NUM_CHG, - RESOURCE_DIAGNOSTIC, - RESOURCE_SERV_CONFIG_MISMATCH = 21, - RESOURCE_SERV_CONFIG_CHANGE, - RESOURCE_SERV_START, - RESOURCE_SERV_IDLE, - RESOURCE_SERV_IDLE_PENDING, - RESOURCE_SERV_FAILURE, - RESOURCE_SERV_LOG_FAILED, - RESOURCE_SERV_LOG_FILLED, - - RESOURCE_LMU_NEW_MASTER = 31, - RESOURCE_LMU_STBY_COMM, - RESOURCE_LMU_STBY_NOT_COMM, - RESOURCE_LMU_RECOVERY_COMPLETE, - RESOURCE_LMU_NOW_STANDBY, - RESOURCE_LMU_NOW_STANDALONE, - RESOURCE_LMU_TYPE_CHG, - RESOURCE_LMU_COMPAT_LVL_CHG, - - - RESOURCE_CAP_DOOR_OPEN = 41, - RESOURCE_CAP_DOOR_CLOSED, - RESOURCE_CARTRIDGES_IN_CAP, - RESOURCE_CAP_ENTER_START, - RESOURCE_CAP_ENTER_END, - RESOURCE_CAP_REMOVE_CARTRIDGES, - RESOURCE_NO_CAP_AVAILABLE, - RESOURCE_CAP_INSERT_MAGAZINES, - RESOURCE_CAP_INPUT_CARTRIDGES, - - RESOURCE_LSM_DOOR_OPENED = 51, - RESOURCE_LSM_DOOR_CLOSED, - RESOURCE_LSM_RECOVERY_INCOMPLETE, - RESOURCE_LSM_TYPE_CHG, - RESOURCE_LSM_ADDED, - RESOURCE_LSM_CONFIG_CHANGE, - RESOURCE_LSM_REMOVED, - - RESOURCE_DRIVE_CLEAN_REQUEST = 61, - RESOURCE_DRIVE_CLEANED, - RESOURCE_DRIVE_TYPE_CHG, - RESOURCE_DRIVE_ADDED, - RESOURCE_DRIVE_REMOVED, - - - RESOURCE_POOL_HIGHWATER = 71, - RESOURCE_POOL_LOWWATER, - - RESOURCE_ACS_ADDED = 81, - RESOURCE_ACS_CONFIG_CHANGE, - RESOURCE_ACS_REMOVED, - RESOURCE_ACS_PORTS_CHANGE, - - RESOURCE_CAP_ADDED = 91, - RESOURCE_CAP_CONFIG_CHANGE, - RESOURCE_CAP_REMOVED, - - RESOURCE_LAST = 99 -} RESOURCE_EVENT; - -typedef struct { - int category; - int code; -} SENSE_HLI; - -typedef struct { - unsigned char sense_key; - unsigned char asc; - unsigned char ascq; -} SENSE_SCSI; - -typedef struct { - char fsc[4]; -} SENSE_FSC; - -#define MAX_SERIAL_NUM_LENGTH 32 - -typedef struct { - char serial_nbr[MAX_SERIAL_NUM_LENGTH +1]; -} SERIAL_NUM; - -typedef int LSM_TYPE; - -#define RESOURCE_ALIGN_PAD_SIZE 64 - -#endif /* _DB_DEFS_API_ */ diff --git a/usr/src/common/mms/h/api/defs_api.h b/usr/src/common/mms/h/api/defs_api.h deleted file mode 100644 index e005c60d79..0000000000 --- a/usr/src/common/mms/h/api/defs_api.h +++ /dev/null @@ -1,267 +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 _DEFS_API_ -#define _DEFS_API_ -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -typedef unsigned int BOOLEAN; - -typedef void *ALIGNED_BYTES; - -#define MAX_MESSAGE_SIZE 4096 -#define MAX_MESSAGE_BLOCK (MAX_MESSAGE_SIZE / sizeof (ALIGNED_BYTES)) - -#define MAX_LINE_LEN 256 - - -#define MAX_ID 42 - - -#define MAX_DRG 20 - -#define MAX_SPN 20 -#define FORCE 0x01 -#define INTERMEDIATE 0x02 -#define ACKNOWLEDGE 0x04 -#define READONLY 0x08 -#define BYPASS 0x10 -#define VIRTAWARE 0x20 -#define SCRATCH 0x40 -#define SCRATCH 0x40 -#define EXTENDED 0x80 - -#define VTV_DUPLEX 0X20 -#define VTV_SCRATCH 0X40 - -#define WAIT 0x00000001 -#define RESET 0x00000002 -#define VIRTUAL 0x00000004 -#define CONTINUOUS 0x00000008 -#define RANGE 0x00000010 -#define DIAGNOSTIC 0x00000020 -#define BACKGROUND 0x10000000 -#define ALL_DRIVES 0x20000000 -#define AUTOMATIC 0x40000000 -#define CLEAN_DRIVE 0x80000000 -typedef unsigned short MESSAGE_ID; -#define MIN_MESSAGE 1 -#define MAX_MESSAGE 65535 - -#define MAX_LOG_MSG_SIZE 256 - -typedef enum { - COMMAND_FIRST = 0, - COMMAND_AUDIT, - COMMAND_CANCEL, - COMMAND_DISMOUNT, - COMMAND_EJECT, - - COMMAND_ENTER, - COMMAND_IDLE, - COMMAND_MOUNT, - COMMAND_QUERY, - COMMAND_RECOVERY, - - COMMAND_START, - COMMAND_VARY, - COMMAND_UNSOLICITED_EVENT, - COMMAND_TERMINATE, - COMMAND_ABORT, - - COMMAND_SET_SCRATCH, - COMMAND_DEFINE_POOL, - COMMAND_DELETE_POOL, - COMMAND_SET_CLEAN, - COMMAND_MOUNT_SCRATCH, - - COMMAND_UNLOCK, - COMMAND_LOCK, - COMMAND_CLEAR_LOCK, - COMMAND_QUERY_LOCK, - COMMAND_SET_CAP, - - COMMAND_LS_RES_AVAIL, - COMMAND_LS_RES_REM, - COMMAND_INIT, - COMMAND_SELECT, - COMMAND_SET_OWNER, - - COMMAND_DB_REQUEST, - COMMAND_MOUNT_PINFO, - COMMAND_MOVE, - COMMAND_RCVY, - COMMAND_SWITCH, - - COMMAND_DISPLAY, - COMMAND_REGISTER, - COMMAND_UNREGISTER, - COMMAND_CHECK_REGISTRATION, - COMMAND_MONITOR_EVENT, - - COMMAND_CONFIG, - COMMAND_CONFIRM_CONFIG, - - COMMAND_LAST -} COMMAND; - -typedef enum { - TYPE_FIRST = 0, - TYPE_ACS, - TYPE_AUDIT, - TYPE_CAP, - TYPE_CELL, - - TYPE_CP, - TYPE_CSI, - TYPE_DISMOUNT, - TYPE_EJECT, - TYPE_EL, - - TYPE_ENTER, - TYPE_DRIVE, - TYPE_IPC, - TYPE_LH, - TYPE_LM, - - TYPE_LSM, - TYPE_MOUNT, - TYPE_NONE, - TYPE_PANEL, - TYPE_PORT, - - TYPE_QUERY, - TYPE_RECOVERY, - TYPE_REQUEST, - TYPE_SA, - TYPE_SERVER, - - TYPE_SUBPANEL, - TYPE_VARY, - TYPE_VOLUME, - TYPE_PD, - TYPE_SET_SCRATCH, - - TYPE_DEFINE_POOL, - TYPE_DELETE_POOL, - TYPE_SCRATCH, - TYPE_POOL, - TYPE_MOUNT_SCRATCH, - - TYPE_VOLRANGE, - TYPE_CLEAN, - TYPE_LOCK_SERVER, - TYPE_SET_CLEAN, - TYPE_SV, - - TYPE_MT, - TYPE_IPC_CLEAN, - TYPE_SET_CAP, - TYPE_LOCK, - TYPE_CO_CSI, - - TYPE_DISK_FULL, - TYPE_CM, - TYPE_SET_OWNER, - TYPE_MIXED_MEDIA_INFO, - TYPE_MEDIA_TYPE, - - TYPE_SSI, - TYPE_DB_SERVER, - TYPE_DRIVE_GROUP, - TYPE_SUBPOOL_NAME, - TYPE_MOUNT_PINFO, - - TYPE_VTDID, - TYPE_MGMT_CLAS, - TYPE_JOB_NAME, - TYPE_STEP_NAME, - TYPE_MOUNT_SCRATCH_PINFO, - - TYPE_CONFIG, - TYPE_LMU, - TYPE_SWITCH, - TYPE_MV, - TYPE_ERRV, - - TYPE_FIN, - TYPE_CR, - TYPE_MVD, - TYPE_MISSING, - TYPE_ERRANT, - - TYPE_SURR, - TYPE_HAND, - TYPE_GETTYPES, - TYPE_PTP, - TYPE_DISP, - - TYPE_CLMON, - TYPE_DISPLAY, - TYPE_ERROR, - TYPE_MON, - TYPE_CAP_CELL, - - TYPE_DIAG_CELL, - TYPE_RECOV_CELL, - TYPE_DCONFIG, - - TYPE_LAST -} TYPE; - -typedef enum { - VERSION0 = 0, - VERSION1, - VERSION2, - VERSION3, - VERSION4, - VERSION_LAST -} VERSION; - -#define VERSION_MINIMUM_SUPPORTED VERSION1 - -typedef enum { - CLN_CART_FIRST = 0, - CLN_CART_NEVER, - - CLN_CART_INDETERMINATE, - - CLN_CART_ALWAYS, - CLN_CART_LAST -} CLN_CART_CAPABILITY; - -#define MM_MAX_COMPAT_TYPES 16 - - -#define MEDIA_TYPE_NAME_LEN 10 -#define DRIVE_TYPE_NAME_LEN 10 - -#endif /* _DEFS_API_ */ diff --git a/usr/src/common/mms/h/api/ident_api.h b/usr/src/common/mms/h/api/ident_api.h deleted file mode 100644 index a83c63c03d..0000000000 --- a/usr/src/common/mms/h/api/ident_api.h +++ /dev/null @@ -1,271 +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 _IDENT_API_H_ -#define _IDENT_API_H_ -#define IDENTIFIER_SIZE 64 -#define REGISTRATION_ID_SIZE 32 - -typedef struct { - ACS acs; - LSM lsm; -} LSMID; - -typedef LSMID V0_CAPID; -typedef LSMID V1_CAPID; - -typedef struct { - LSMID lsm_id; - CAP cap; -} CAPID; - -typedef struct { - ACS acs; - PORT port; -} PORTID; - -typedef struct { - LSMID lsm_id; - PANEL panel; -} PANELID; - -typedef struct { - ACS acs; - LSM master_lsm; - PANEL master_panel; - LSM slave_lsm; - PANEL slave_panel; -} PTPID; - -typedef struct { - PANELID panel_id; - ROW begin_row; - COL begin_col; - ROW end_row; - COL end_col; -} SUBPANELID; - -typedef struct { - PANELID panel_id; - DRIVE drive; -} DRIVEID; - -typedef struct { - PANELID panel_id; - ROW row; - COL col; -} CELLID; - -typedef struct { - char external_label[EXTERNAL_LABEL_SIZE + 1]; -} VOLID; - -typedef struct { - POOL pool; -} POOLID; - -typedef struct { - VOLID startvol; - VOLID endvol; -} VOLRANGE; - -typedef struct { - PANEL panel; - DRIVE drive; -} VIRTUAL_TAPE_DRIVE; - - -typedef struct { - ACS acs; - LSM lsm; - VIRTUAL_TAPE_DRIVE vtd; -} VTDID; - -typedef struct { - char mgmt_clas[MGMT_CLAS_SIZE + 1]; -} MGMT_CLAS; - -typedef struct { - char subpool_name[SUBPOOL_NAME_SIZE + 1]; -} SUBPOOL_NAME; - -typedef struct { - char job_name[JOB_NAME_SIZE + 1]; -} JOB_NAME; - -typedef struct { - char step_name[STEP_NAME_SIZE + 1]; -} STEP_NAME; - -typedef struct { - char dataset_name[DATASET_NAME_SIZE + 1]; -} DATASET_NAME; - -typedef struct { - char groupid[GROUPID_SIZE + 1]; -} GROUPID; - - -typedef struct { - char registration[REGISTRATION_ID_SIZE + 1]; -} REGISTRATION_ID; - -typedef enum { - EVENT_REGISTER_FIRST = 0, - EVENT_REGISTER_REGISTERED, - EVENT_REGISTER_UNREGISTERED, - EVENT_REGISTER_INVALID_CLASS, - EVENT_REGISTER_LAST -} EVENT_CLASS_REGISTER_RETURN; - -typedef struct { - EVENT_CLASS_TYPE event_class; - EVENT_CLASS_REGISTER_RETURN register_return; -} REGISTER_STATUS; - -typedef enum { - VOL_FIRST = 0, - VOL_ENTERED, - VOL_ADDED, - VOL_REACTIVATED, - VOL_EJECTED, - VOL_DELETED, - VOL_MARKED_ABSENT, - VOL_OVER_MAX_CLEAN, - VOL_CLEAN_CART_SPENT, - VOL_HOME_LSM_CHG, - VOL_OWNER_CHG, - VOL_LAST -} VOL_EVENT_TYPE; - -typedef struct { - VOL_EVENT_TYPE event_type; - VOLID vol_id; -} EVENT_VOLUME_STATUS; - -typedef struct { - PANELID panel_id; - HAND hand; -} HANDID; - -#define ALIGNMENT_PAD_SIZE 32 - -typedef union { - ACS acs_id; - V0_CAPID v0_cap_id; - V1_CAPID v1_cap_id; - CAPID cap_id; - CELLID cell_id; - DRIVEID drive_id; - LSMID lsm_id; - PANELID panel_id; - PORTID port_id; - SUBPANELID subpanel_id; - VOLID vol_id; - POOLID pool_id; - LOCKID lock_id; - char socket_name[SOCKET_NAME_SIZE]; - long request; - short lh_error; - MEDIA_TYPE media_type; - DRIVE_TYPE drive_type; - HANDID hand_id; - PTPID ptp_id; - VTDID vtd_id; - SUBPOOL_NAME subpool_name; - MGMT_CLAS mgmt_clas; - JOB_NAME job_name; - STEP_NAME step_name; - GROUPID groupid; - char alignment_size[ALIGNMENT_PAD_SIZE]; -} IDENTIFIER; - -typedef enum { - SENSE_TYPE_FIRST = 0, - SENSE_TYPE_NONE, - SENSE_TYPE_HLI, - SENSE_TYPE_SCSI, - SENSE_TYPE_FSC, - RESOURCE_CHANGE_SERIAL_NUM, - RESOURCE_CHANGE_LSM_TYPE, - RESOURCE_CHANGE_DRIVE_TYPE, - DRIVE_ACTIVITY_DATA_TYPE, - SENSE_TYPE_LAST -} RESOURCE_DATA_TYPE; - -typedef struct { - long start_time; - long completion_time; - VOLID vol_id; - VOLUME_TYPE volume_type; - DRIVEID drive_id; - POOLID pool_id; - CELLID home_location; -} DRIVE_ACTIVITY_DATA; - -typedef union { - SENSE_HLI sense_hli; - SENSE_SCSI sense_scsi; - SENSE_FSC sense_fsc; - SERIAL_NUM serial_num; - LSM_TYPE lsm_type; - DRIVE_TYPE drive_type; - DRIVE_ACTIVITY_DATA drive_activity_data; - char resource_align_pad[RESOURCE_ALIGN_PAD_SIZE]; -} RESOURCE_DATA; - -typedef struct { - TYPE resource_type; - IDENTIFIER resource_identifier; - RESOURCE_EVENT resource_event; - RESOURCE_DATA_TYPE resource_data_type; - RESOURCE_DATA resource_data; -} EVENT_RESOURCE_STATUS; - -typedef struct { - TYPE event_type; - RESOURCE_DATA_TYPE resource_data_type; - RESOURCE_DATA resource_data; -} EVENT_DRIVE_STATUS; - -#define MAX_EVENT_CLASS_TYPE 3 - -typedef struct { - REGISTRATION_ID registration_id; - unsigned short count; - REGISTER_STATUS register_status[MAX_EVENT_CLASS_TYPE]; -} EVENT_REGISTER_STATUS; - -#define EVENT_ALIGN_PAD_SIZE 128 - -typedef union { - EVENT_REGISTER_STATUS event_register_status; - EVENT_VOLUME_STATUS event_volume_status; - EVENT_RESOURCE_STATUS event_resource_status; - EVENT_DRIVE_STATUS event_drive_status; - char event_align_pad[EVENT_ALIGN_PAD_SIZE]; -} EVENT; - -#endif /* _IDENT_API_H_ */ diff --git a/usr/src/common/mms/h/api/ipc_hdr_api.h b/usr/src/common/mms/h/api/ipc_hdr_api.h deleted file mode 100644 index 4c08d772ea..0000000000 --- a/usr/src/common/mms/h/api/ipc_hdr_api.h +++ /dev/null @@ -1,47 +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 _IPC_HDR_API_ -#define _IPC_HDR_API_ - -#define HOSTID_SIZE 12 -typedef struct { - char name[HOSTID_SIZE]; -} HOSTID; - -typedef struct { - unsigned long byte_count; - TYPE module_type; - unsigned char options; - unsigned long seq_num; - char return_socket[SOCKET_NAME_SIZE]; - - unsigned int return_pid; - unsigned long ipc_identifier; - TYPE requestor_type; - HOSTID host_id; -} IPC_HEADER; - -#endif /* _IPC_HDR_API_ */ diff --git a/usr/src/common/mms/h/api/lm_structs_api.h b/usr/src/common/mms/h/api/lm_structs_api.h deleted file mode 100644 index 06644e2782..0000000000 --- a/usr/src/common/mms/h/api/lm_structs_api.h +++ /dev/null @@ -1,538 +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 _LM_STRUCTS_API_ -#define _LM_STRUCTS_API_ -typedef struct { - IPC_HEADER ipc_header; - MESSAGE_HEADER message_header; -} REQUEST_HEADER; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - MESSAGE_ID message_id; -} ACKNOWLEDGE_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - CAPID cap_id; - TYPE type; - unsigned short count; - union { - ACS acs_id[MAX_ID]; - LSMID lsm_id[MAX_ID]; - PANELID panel_id[MAX_ID]; - SUBPANELID subpanel_id[MAX_ID]; - } identifier; -} AUDIT_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - CAPID cap_id; - TYPE type; - unsigned short count; - union { - AU_ACS_STATUS acs_status[MAX_ID]; - AU_LSM_STATUS lsm_status[MAX_ID]; - AU_PNL_STATUS panel_status[MAX_ID]; - AU_SUB_STATUS subpanel_status[MAX_ID]; - } identifier_status; -} AUDIT_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - CAPID cap_id; - unsigned short count; - VOLUME_STATUS volume_status[MAX_ID]; -} EJECT_ENTER; - -typedef EJECT_ENTER EJECT_RESPONSE; -typedef EJECT_ENTER ENTER_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - CAPID cap_id; - unsigned short count; - VOLID vol_id[MAX_ID]; -} EJECT_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - CAPID cap_id; - unsigned short count; - VOLRANGE vol_range[MAX_ID]; -} EXT_EJECT_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - CAPID cap_id; -} ENTER_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - VOLID vol_id; - unsigned short count; - DRIVEID drive_id[MAX_ID]; -} MOUNT_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - VOLID vol_id; - DRIVEID drive_id; -} MOUNT_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - VOLID vol_id[MAX_ID]; - unsigned short count; - LSMID lsm; - -} MOVE_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - unsigned short count; - VOLUME_STATUS volume_status[MAX_ID]; -} MOVE_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - POOLID pool_id; - MEDIA_TYPE media_type; - unsigned short count; - DRIVEID drive_id[MAX_ID]; -} MOUNT_SCRATCH_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - POOLID pool_id; - DRIVEID drive_id; - VOLID vol_id; -} MOUNT_SCRATCH_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - VOLID vol_id; - DRIVEID drive_id; -} DISMOUNT_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - VOLID vol_id; - DRIVEID drive_id; -} DISMOUNT_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - TYPE type; - unsigned short count; - union { - VOLID vol_id[MAX_ID]; - DRIVEID drive_id[MAX_ID]; - } identifier; -} LOCK_REQUEST; - -typedef LOCK_REQUEST CLEAR_LOCK_REQUEST; -typedef LOCK_REQUEST QUERY_LOCK_REQUEST; -typedef LOCK_REQUEST UNLOCK_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - TYPE type; - unsigned short count; - union { - LO_VOL_STATUS volume_status[MAX_ID]; - LO_DRV_STATUS drive_status[MAX_ID]; - } identifier_status; -} LOCK_RESPONSE; - -typedef LOCK_RESPONSE CLEAR_LOCK_RESPONSE; -typedef LOCK_RESPONSE UNLOCK_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - TYPE type; - union { - QU_ACS_CRITERIA acs_criteria; - QU_LSM_CRITERIA lsm_criteria; - QU_CAP_CRITERIA cap_criteria; - QU_DRV_CRITERIA drive_criteria; - QU_VOL_CRITERIA vol_criteria; - QU_REQ_CRITERIA request_criteria; - QU_PRT_CRITERIA port_criteria; - QU_POL_CRITERIA pool_criteria; - QU_MSC_CRITERIA mount_scratch_criteria; - QU_LMU_CRITERIA lmu_criteria; - QU_DRG_CRITERIA drive_group_criteria; - QU_SPN_CRITERIA subpl_name_criteria; - QU_MSC_PINFO_CRITERIA mount_scratch_pinfo_criteria; - } select_criteria; -} QUERY_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - TYPE type; - union { - QU_SRV_RESPONSE server_response; - QU_ACS_RESPONSE acs_response; - QU_LSM_RESPONSE lsm_response; - QU_CAP_RESPONSE cap_response; - QU_CLN_RESPONSE clean_volume_response; - QU_DRV_RESPONSE drive_response; - QU_MNT_RESPONSE mount_response; - QU_VOL_RESPONSE volume_response; - QU_PRT_RESPONSE port_response; - QU_REQ_RESPONSE request_response; - QU_SCR_RESPONSE scratch_response; - QU_POL_RESPONSE pool_response; - QU_MSC_RESPONSE mount_scratch_response; - QU_MMI_RESPONSE mm_info_response; - QU_LMU_RESPONSE lmu_response; - QU_DRG_RESPONSE drive_group_response; - QU_SPN_RESPONSE subpl_name_response; - } status_response; -} QUERY_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - TYPE type; - unsigned short count; - union { - QL_VOL_STATUS volume_status[MAX_ID]; - QL_DRV_STATUS drive_status[MAX_ID]; - } identifier_status; -} QUERY_LOCK_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - STATE state; - TYPE type; - unsigned short count; - union { - ACS acs_id[MAX_ID]; - LSMID lsm_id[MAX_ID]; - DRIVEID drive_id[MAX_ID]; - PORTID port_id[MAX_ID]; - CAPID cap_id[MAX_ID]; - } identifier; -} VARY_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - STATE state; - TYPE type; - unsigned short count; - union { - VA_ACS_STATUS acs_status[MAX_ID]; - VA_LSM_STATUS lsm_status[MAX_ID]; - VA_DRV_STATUS drive_status[MAX_ID]; - VA_PRT_STATUS port_status[MAX_ID]; - VA_CAP_STATUS cap_status[MAX_ID]; - } device_status; -} VARY_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - CAPID cap_id; - unsigned short count; - VOLID vol_id[MAX_ID]; -} VENTER_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - unsigned long low_water_mark; - unsigned long high_water_mark; - unsigned long pool_attributes; - unsigned short count; - POOLID pool_id[MAX_ID]; -} DEFINE_POOL_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - unsigned long low_water_mark; - unsigned long high_water_mark; - unsigned long pool_attributes; - unsigned short count; - struct { - POOLID pool_id; - RESPONSE_STATUS status; - } pool_status[MAX_ID]; -} DEFINE_POOL_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - unsigned short count; - POOLID pool_id[MAX_ID]; -} DELETE_POOL_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - unsigned short count; - struct { - POOLID pool_id; - RESPONSE_STATUS status; - } pool_status[MAX_ID]; -} DELETE_POOL_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - CAP_PRIORITY cap_priority; - CAP_MODE cap_mode; - unsigned short count; - CAPID cap_id[MAX_ID]; -} SET_CAP_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - CAP_PRIORITY cap_priority; - CAP_MODE cap_mode; - unsigned short count; - struct { - CAPID cap_id; - RESPONSE_STATUS status; - } set_cap_status[MAX_ID]; -} SET_CAP_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - unsigned short max_use; - unsigned short count; - VOLRANGE vol_range[MAX_ID]; -} SET_CLEAN_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - unsigned short max_use; - unsigned short count; - struct { - VOLID vol_id; - RESPONSE_STATUS status; - } volume_status[MAX_ID]; -} SET_CLEAN_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - USERID owner_id; - TYPE type; - unsigned short count; - VOLRANGE vol_range[MAX_ID]; -} SET_OWNER_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - USERID owner_id; - TYPE type; - unsigned short count; - struct { - VOLID vol_id; - RESPONSE_STATUS status; - } volume_status[MAX_ID]; -} SET_OWNER_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - POOLID pool_id; - unsigned short count; - VOLRANGE vol_range[MAX_ID]; -} SET_SCRATCH_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - POOLID pool_id; - unsigned short count; - struct { - VOLID vol_id; - RESPONSE_STATUS status; - } scratch_status[MAX_ID]; -} SET_SCRATCH_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - MESSAGE_ID request; -} CANCEL_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - MESSAGE_ID request; -} CANCEL_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; -} START_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; -} START_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; -} IDLE_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; -} IDLE_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; -} INIT_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - STATE state; - TYPE type; - unsigned short count; - union { - ACS lmu_id[MAX_ID]; - } identifier; -} SWITCH_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - TYPE type; - unsigned short count; - union { - SW_LMU_STATUS lmu_status[MAX_ID]; - } device_status; -} SWITCH_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - TYPE request_type; - - VOLID vol_id; - TYPE location_type; - union { - CELLID cell_id; - DRIVEID drive_id; - } location; - char file_name[25]; - char routine_name[25]; -} RCVY_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - VOLUME_STATUS volume_status; -} RCVY_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - REGISTRATION_ID registration_id; - unsigned short count; - EVENT_CLASS_TYPE eventClass[MAX_ID]; -} REGISTER_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - EVENT_REPLY_TYPE event_reply_type; - EVENT_SEQUENCE event_sequence; - union { - EVENT_RESOURCE_STATUS event_resource_status; - EVENT_REGISTER_STATUS event_register_status; - EVENT_VOLUME_STATUS event_volume_status; - EVENT_DRIVE_STATUS event_drive_status; - } event; -} REGISTER_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - REGISTRATION_ID registration_id; - unsigned short count; - EVENT_CLASS_TYPE eventClass[MAX_ID]; -} UNREGISTER_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - EVENT_REGISTER_STATUS event_register_status; -} UNREGISTER_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - REGISTRATION_ID registration_id; -} CHECK_REGISTRATION_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - EVENT_REGISTER_STATUS event_register_status; -} CHECK_REGISTRATION_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - TYPE display_type; - DISPLAY_XML_DATA display_xml_data; -} DISPLAY_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - TYPE display_type; - DISPLAY_XML_DATA display_xml_data; -} DISPLAY_RESPONSE; - -typedef struct { - REQUEST_HEADER request_header; - VOLID vol_id; - POOLID pool_id; - MGMT_CLAS mgmt_clas; - MEDIA_TYPE media_type; - JOB_NAME job_name; - DATASET_NAME dataset_name; - STEP_NAME step_name; - DRIVEID drive_id; -} MOUNT_PINFO_REQUEST; - -typedef struct { - REQUEST_HEADER request_header; - RESPONSE_STATUS message_status; - POOLID pool_id; - DRIVEID drive_id; - VOLID vol_id; -} MOUNT_PINFO_RESPONSE; -#endif /* _LM_STRUCTS_API_ */ diff --git a/usr/src/common/mms/h/api/structs_api.h b/usr/src/common/mms/h/api/structs_api.h deleted file mode 100644 index 342dadd039..0000000000 --- a/usr/src/common/mms/h/api/structs_api.h +++ /dev/null @@ -1,483 +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 _STRUCTS_API_ -#define _STRUCTS_API_ - -#include "db_structs.h" -#include "defs.h" -#define QU_MAX_DRV_STATUS 165 - -#define MAX_VTD_MAP 490 - -typedef struct { - unsigned short packet_id; - COMMAND command; - unsigned char message_options; - VERSION version; - unsigned long extended_options; - LOCKID lock_id; - ACCESSID access_id; - unsigned char reserved[16]; -} MESSAGE_HEADER; - -typedef struct { - STATUS status; - TYPE type; - IDENTIFIER identifier; -} RESPONSE_STATUS; - -typedef struct { - VOLID vol_id; - RESPONSE_STATUS status; -} VOLUME_STATUS; - -typedef struct { - ACS acs_id; - RESPONSE_STATUS status; -} AU_ACS_STATUS; - -typedef struct { - LSMID lsm_id; - RESPONSE_STATUS status; -} AU_LSM_STATUS; - -typedef struct { - PANELID panel_id; - RESPONSE_STATUS status; -} AU_PNL_STATUS; - -typedef struct { - SUBPANELID subpanel_id; - RESPONSE_STATUS status; -} AU_SUB_STATUS; - -typedef struct { - VOLID vol_id; - RESPONSE_STATUS status; -} LO_VOL_STATUS; - -typedef struct { - DRIVEID drive_id; - RESPONSE_STATUS status; -} LO_DRV_STATUS; - -typedef enum { - AUDIT = 0, - MOUNT, - DISMOUNT, - ENTER, - EJECT, - MAX_COMMANDS -} QU_COMMANDS; - -typedef enum { - CURRENT = 0, - PENDING, - MAX_DISPOSITIONS -} QU_DISPOSITIONS; - -typedef struct { - MESSAGE_ID requests[MAX_COMMANDS][MAX_DISPOSITIONS]; -} REQ_SUMMARY; - -typedef struct { - unsigned short acs_count; - ACS acs_id[MAX_ID]; -} QU_ACS_CRITERIA; - -typedef struct { - unsigned short lsm_count; - LSMID lsm_id[MAX_ID]; -} QU_LSM_CRITERIA; - -typedef struct { - unsigned short cap_count; - CAPID cap_id[MAX_ID]; -} QU_CAP_CRITERIA; - -typedef struct { - unsigned short drive_count; - DRIVEID drive_id[MAX_ID]; -} QU_DRV_CRITERIA; - -typedef struct { - GROUP_TYPE group_type; - unsigned short drg_count; - GROUPID group_id[MAX_DRG]; -} QU_DRG_CRITERIA; - -typedef struct { - unsigned short volume_count; - VOLID volume_id[MAX_ID]; -} QU_VOL_CRITERIA; - -typedef struct { - unsigned short request_count; - MESSAGE_ID request_id[MAX_ID]; -} QU_REQ_CRITERIA; - -typedef struct { - unsigned short port_count; - PORTID port_id[MAX_ID]; -} QU_PRT_CRITERIA; - -typedef struct { - unsigned short pool_count; - POOLID pool_id[MAX_ID]; -} QU_POL_CRITERIA; - -typedef struct { - MEDIA_TYPE media_type; - unsigned short pool_count; - POOLID pool_id[MAX_ID]; -} QU_MSC_CRITERIA; - -typedef struct { - MEDIA_TYPE media_type; - unsigned short pool_count; - POOLID pool_id[MAX_ID]; - MGMT_CLAS mgmt_clas; -} QU_MSC_PINFO_CRITERIA; - -typedef struct { - unsigned short lmu_count; - ACS lmu_id[MAX_ID]; -} QU_LMU_CRITERIA; - -typedef struct { - unsigned short spn_count; - SUBPOOL_NAME subpl_name[MAX_SPN]; -} QU_SPN_CRITERIA; - -typedef struct { - ACS acs_id; - STATE state; - FREECELLS freecells; - REQ_SUMMARY requests; - STATUS status; -} QU_ACS_STATUS; - -typedef struct { - VOLID vol_id; - MEDIA_TYPE media_type; - CELLID home_location; - unsigned short max_use; - unsigned short current_use; - STATUS status; -} QU_CLN_STATUS; - -typedef struct { - CAPID cap_id; - STATUS status; - CAP_PRIORITY cap_priority; - unsigned short cap_size; - STATE cap_state; - CAP_MODE cap_mode; -} QU_CAP_STATUS; - -typedef struct { - DRIVEID drive_id; - VOLID vol_id; - DRIVE_TYPE drive_type; - STATE state; - STATUS status; -} QU_DRV_STATUS; - -typedef struct { - VOLID vol_id; - STATE state; - STATUS status; - DRIVEID drive_id; -} QU_VIRT_DRV_STATUS; - -typedef struct { - DRIVEID drive_id; - unsigned short drive_addr; -} QU_VIRT_DRV_MAP; - -typedef struct { - LSMID lsm_id; - STATE state; - FREECELLS freecells; - REQ_SUMMARY requests; - STATUS status; -} QU_LSM_STATUS; - -typedef struct { - VOLID vol_id; - STATUS status; - unsigned short drive_count; - QU_DRV_STATUS drive_status[QU_MAX_DRV_STATUS]; -} QU_MNT_STATUS; - -typedef struct { - PORTID port_id; - STATE state; - STATUS status; -} QU_PRT_STATUS; - -typedef struct { - MESSAGE_ID request; - COMMAND command; - STATUS status; -} QU_REQ_STATUS; - -typedef struct { - STATE state; - FREECELLS freecells; - REQ_SUMMARY requests; -} QU_SRV_STATUS; - -typedef struct { - VOLID vol_id; - MEDIA_TYPE media_type; - LOCATION location_type; - union { - CELLID cell_id; - DRIVEID drive_id; - } location; - STATUS status; -} QU_VOL_STATUS; - -typedef struct { - VOLID vol_id; - MEDIA_TYPE media_type; - CELLID home_location; - POOLID pool_id; - STATUS status; -} QU_SCR_STATUS; - -typedef struct { - POOLID pool_id; - unsigned long volume_count; - unsigned long low_water_mark; - unsigned long high_water_mark; - unsigned long pool_attributes; - STATUS status; -} QU_POL_STATUS; - -typedef struct { - SUBPOOL_NAME subpool_name; - POOLID pool_id; - STATUS status; -} QU_SUBPOOL_NAME_STATUS; - -typedef struct { - POOLID pool_id; - STATUS status; - unsigned short drive_count; - QU_DRV_STATUS drive_list[QU_MAX_DRV_STATUS]; -} QU_MSC_STATUS; - -typedef struct { - MEDIA_TYPE media_type; - char media_type_name[MEDIA_TYPE_NAME_LEN + 1]; - CLN_CART_CAPABILITY cleaning_cartridge; - int max_cleaning_usage; - unsigned short compat_count; - DRIVE_TYPE compat_drive_types[MM_MAX_COMPAT_TYPES]; -} QU_MEDIA_TYPE_STATUS; - -typedef struct { - DRIVE_TYPE drive_type; - char drive_type_name[DRIVE_TYPE_NAME_LEN + 1]; - unsigned short compat_count; - MEDIA_TYPE compat_media_types[MM_MAX_COMPAT_TYPES]; -} QU_DRIVE_TYPE_STATUS; - -typedef struct { - QU_SRV_STATUS server_status; -} QU_SRV_RESPONSE; - -typedef struct { - unsigned short acs_count; - QU_ACS_STATUS acs_status[MAX_ID]; -} QU_ACS_RESPONSE; - -typedef struct { - unsigned short lsm_count; - QU_LSM_STATUS lsm_status[MAX_ID]; -} QU_LSM_RESPONSE; - -typedef struct { - unsigned short cap_count; - QU_CAP_STATUS cap_status[MAX_ID]; -} QU_CAP_RESPONSE; - -typedef struct { - unsigned short volume_count; - QU_CLN_STATUS clean_volume_status[MAX_ID]; -} QU_CLN_RESPONSE; - -typedef struct { - unsigned short drive_count; - QU_DRV_STATUS drive_status[MAX_ID]; -} QU_DRV_RESPONSE; - -typedef struct { - GROUPID group_id; - GROUP_TYPE group_type; - unsigned short vir_drv_map_count; - QU_VIRT_DRV_MAP virt_drv_map[MAX_VTD_MAP]; -} QU_DRG_RESPONSE; - -typedef struct { - unsigned short mount_status_count; - QU_MNT_STATUS mount_status[MAX_ID]; -} QU_MNT_RESPONSE; - -typedef struct { - unsigned short volume_count; - QU_VOL_STATUS volume_status[MAX_ID]; -} QU_VOL_RESPONSE; - -typedef struct { - unsigned short port_count; - QU_PRT_STATUS port_status[MAX_ID]; -} QU_PRT_RESPONSE; - -typedef struct { - unsigned short request_count; - QU_REQ_STATUS request_status[MAX_ID]; -} QU_REQ_RESPONSE; - -typedef struct { - unsigned short volume_count; - QU_SCR_STATUS scratch_status[MAX_ID]; -} QU_SCR_RESPONSE; - -typedef struct { - unsigned short pool_count; - QU_POL_STATUS pool_status[MAX_ID]; -} QU_POL_RESPONSE; - -typedef struct { - unsigned short spn_status_count; - QU_SUBPOOL_NAME_STATUS subpl_name_status[MAX_ID]; -} QU_SPN_RESPONSE; - -typedef struct { - unsigned short msc_status_count; - QU_MSC_STATUS mount_scratch_status[MAX_ID]; -} QU_MSC_RESPONSE; - -typedef struct { - unsigned short media_type_count; - QU_MEDIA_TYPE_STATUS media_type_status[MAX_ID]; - unsigned short drive_type_count; - QU_DRIVE_TYPE_STATUS drive_type_status[MAX_ID]; -} QU_MMI_RESPONSE; - -typedef struct { - VOLID vol_id; - LOCKID lock_id; - unsigned long lock_duration; - unsigned int locks_pending; - USERID user_id; - STATUS status; -} QL_VOL_STATUS; - -typedef struct { - DRIVEID drive_id; - LOCKID lock_id; - unsigned long lock_duration; - unsigned int locks_pending; - USERID user_id; - STATUS status; -} QL_DRV_STATUS; - -typedef struct { - ACS acs_id; - RESPONSE_STATUS status; -} VA_ACS_STATUS; - -typedef struct { - DRIVEID drive_id; - RESPONSE_STATUS status; -} VA_DRV_STATUS; - -typedef struct { - LSMID lsm_id; - RESPONSE_STATUS status; -} VA_LSM_STATUS; - -typedef struct { - CAPID cap_id; - RESPONSE_STATUS status; -} VA_CAP_STATUS; - -typedef struct { - PORTID port_id; - RESPONSE_STATUS status; -} VA_PRT_STATUS; - -typedef struct { - PORT_RECORD prt_record; - ROLE role; - int compat_level; - STATE lmu_port_diag; -} LMU_PORT_RECORD; - -typedef struct { - STATUS status; - ACS acs_id; - STATE state; - int prt_count; - STATUS standby_status; - STATUS master_status; - MODE mode; - LMU_PORT_RECORD lmu_record[MAX_PORTS]; -} QU_LMU_STATUS; - -typedef struct { - unsigned short lmu_count; - QU_LMU_STATUS lmu_status[MAX_ID]; -} QU_LMU_RESPONSE; - -typedef struct { - STATUS status; - ACS lmu_id; -} SW_LMU_STATUS; - - -#define MAX_XML_DATA_SIZE (MAX_MESSAGE_SIZE- \ - ( \ - (sizeof (IPC_HEADER) +4) \ - + sizeof (MESSAGE_HEADER) \ - + (sizeof (STATUS) \ - + sizeof (TYPE) \ - + sizeof (IDENTIFIER)) \ - + sizeof (TYPE) \ - + sizeof (unsigned short))) - -typedef struct { - unsigned short length; - char xml_data[MAX_XML_DATA_SIZE]; -} DISPLAY_XML_DATA; - -#endif /* _STRUCTS_API_ */ diff --git a/usr/src/common/mms/h/apidef.h b/usr/src/common/mms/h/apidef.h deleted file mode 100644 index cd388d3774..0000000000 --- a/usr/src/common/mms/h/apidef.h +++ /dev/null @@ -1,50 +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 _APIDEF_H_ -#define _APIDEF_H_ - -typedef unsigned short SEQ_NO; -typedef MESSAGE_ID REQ_ID; - - -#define ACSAPI_PACKET_VERSION "ACSAPI_PACKET_VERSION" - -#define TEST_ACSLM "t_acslm" - -#define NUM_RECENT_VERSIONS 3 - -#define DRIVE_TYPE_4480 0 -#define MEDIA_TYPE_3480 0 - -typedef enum { - RT_FIRST, - RT_ACKNOWLEDGE, - RT_INTERMEDIATE, - RT_NONE, - RT_FINAL, - RT_LAST -} ACS_RESPONSE_TYPE; -#endif /* _APIDEF_H_ */ diff --git a/usr/src/common/mms/h/apipro.h b/usr/src/common/mms/h/apipro.h deleted file mode 100644 index eff752e207..0000000000 --- a/usr/src/common/mms/h/apipro.h +++ /dev/null @@ -1,384 +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 _APIPRO_H_ -#define _APIPRO_H_ - -STATUS acs_audit_acs( - SEQ_NO seqNumber, - ACS acs[MAX_ID], - CAPID capId, - unsigned short count); - -STATUS acs_audit_lsm( - SEQ_NO seqNumber, - LSMID lsmId[MAX_ID], - CAPID capId, - unsigned short count); - -STATUS acs_audit_panel( - SEQ_NO seqNumber, - PANELID panelId[MAX_ID], - CAPID capId, - unsigned short count); - -STATUS acs_audit_subpanel( - SEQ_NO seqNumber, - SUBPANELID subpanelId[MAX_ID], - CAPID capId, - unsigned short count); - -STATUS acs_audit_server -( - SEQ_NO seqNumber, - CAPID capId); - -STATUS acs_cancel( - SEQ_NO seqNumber, - REQ_ID reqId); - -STATUS acs_idle( - SEQ_NO seqNumber, - BOOLEAN force); - -STATUS acs_start( - SEQ_NO seqNumber); - -STATUS acs_set_access( - char *user_id); - - -STATUS acs_enter( - SEQ_NO seqNumber, - CAPID capId, - BOOLEAN continuous); - -STATUS acs_eject( - SEQ_NO seqNumber, - LOCKID lockId, - CAPID capId, - unsigned short count, - VOLID volumes[MAX_ID]); - -STATUS acs_venter( - SEQ_NO seqNumber, - CAPID capId, - unsigned short count, - VOLID volId[MAX_ID]); - -STATUS acs_xeject( - SEQ_NO seqNumber, - LOCKID lockId, - CAPID capId, - VOLRANGE volRange[MAX_ID], - unsigned short count); - -STATUS acs_clear_lock_drive( - SEQ_NO seqNumber, - DRIVEID driveId[MAX_ID], - unsigned short count); - -STATUS acs_clear_lock_volume( - SEQ_NO seqNumber, - VOLID volId[MAX_ID], - unsigned short count); - -STATUS acs_lock_drive( - SEQ_NO seqNumber, - LOCKID lockId, - USERID userId, - DRIVEID driveId[MAX_ID], - BOOLEAN wait, - unsigned short count); - -STATUS acs_lock_volume( - SEQ_NO seqNumber, - LOCKID lockId, - USERID userId, - VOLID volId[MAX_ID], - BOOLEAN wait, - unsigned short count); - -STATUS acs_unlock_drive( - SEQ_NO seqNumber, - LOCKID lockId, - DRIVEID driveId[MAX_ID], - unsigned short count); - -STATUS acs_unlock_volume( - SEQ_NO seqNumber, - LOCKID lockId, - VOLID volId[MAX_ID], - unsigned short count); - -STATUS acs_dismount( - SEQ_NO seqNumber, - LOCKID lockId, - VOLID volId, - DRIVEID driveId, - BOOLEAN force); - -STATUS acs_mount( - SEQ_NO seqNumber, - LOCKID lockId, - VOLID volId, - DRIVEID driveId, - BOOLEAN readonly, - BOOLEAN bypass); - -STATUS acs_mount_scratch( - SEQ_NO seqNumber, - LOCKID lockId, - POOL pool, - DRIVEID driveId, - MEDIA_TYPE mtype); - -STATUS acs_query_mount_scratch_pinfo( - SEQ_NO seqNumber, - POOL pool[MAX_ID], - unsigned short count, - MEDIA_TYPE media_type, - MGMT_CLAS mgmt_clas); - -STATUS acs_query_acs( - SEQ_NO seqNumber, - ACS acs[MAX_ID], - unsigned short count); - -STATUS acs_query_cap( - SEQ_NO seqNumber, - CAPID capId[MAX_ID], - unsigned short count); - -STATUS acs_query_clean( - SEQ_NO seqNumber, - VOLID volId[MAX_ID], - unsigned short count); - -STATUS acs_query_drive( - SEQ_NO seqNumber, - DRIVEID driveId[MAX_ID], - unsigned short count); - -STATUS acs_query_lock_drive( - SEQ_NO seqNumber, - DRIVEID driveId[MAX_ID], - LOCKID lockId, - unsigned short count); - -STATUS acs_query_lock_volume( - SEQ_NO seqNumber, - VOLID volId[MAX_ID], - LOCKID lockId, - unsigned short count); - -STATUS acs_query_lsm( - SEQ_NO seqNumber, - LSMID lsmId[MAX_ID], - unsigned short count); - -STATUS acs_query_mm_info(SEQ_NO seqNumber); - -STATUS acs_query_mount( - SEQ_NO seqNumber, - VOLID volId[MAX_ID], - unsigned short count); - -STATUS acs_query_mount_scratch( - SEQ_NO seqNumber, - POOL pool[MAX_ID], - unsigned short count, - MEDIA_TYPE media_type); - -STATUS acs_query_pool( - SEQ_NO seqNumber, - POOL pool[MAX_ID], - unsigned short count); - -STATUS acs_query_port( - SEQ_NO seqNumber, - PORTID portId[MAX_ID], - unsigned short count); - -STATUS acs_query_request( - SEQ_NO seqNumber, - REQ_ID reqId[MAX_ID], - unsigned short count); - -STATUS acs_query_scratch( - SEQ_NO seqNumber, - POOL pool[MAX_ID], - unsigned short count); - -STATUS acs_query_server( - SEQ_NO seqNumber); - -STATUS acs_query_subpool_name( - SEQ_NO seqNumber, - unsigned short count, - SUBPOOL_NAME subpoolName[MAX_SPN]); - -STATUS acs_query_volume( - SEQ_NO seqNumber, - VOLID volId[MAX_ID], - unsigned short count); - -STATUS acs_response( - int timeout, - SEQ_NO * seqNumber, - REQ_ID * reqId, - ACS_RESPONSE_TYPE * type, - ALIGNED_BYTES buffer); - -STATUS acs_set_cap( - SEQ_NO seqNumber, - CAP_PRIORITY capPriority, - CAP_MODE capMode, - CAPID capId[MAX_ID], - unsigned short count); - -STATUS acs_set_clean( - SEQ_NO seqNumber, - LOCKID lockId, - unsigned short maxUse, - VOLRANGE volRange[MAX_ID], - BOOLEAN on, - unsigned short count); - -STATUS acs_set_scratch( - SEQ_NO seqNumber, - LOCKID lockId, - POOL pool, - VOLRANGE volRange[MAX_ID], - BOOLEAN on, - unsigned short count); - -STATUS acs_define_pool( - SEQ_NO seqNumber, - unsigned long lwm, - unsigned long hwm, - unsigned long attributes, - POOL pool[MAX_ID], - unsigned short count); - -STATUS acs_delete_pool( - SEQ_NO seqNumber, - POOL pool[MAX_ID], - unsigned short count); - -STATUS acs_vary_acs( - SEQ_NO seqNumber, - ACS acs[MAX_ID], - STATE state, - BOOLEAN force, - unsigned short count); - -STATUS acs_vary_cap( - SEQ_NO seqNumber, - CAPID capId[MAX_ID], - STATE state, - unsigned short count); - -STATUS acs_vary_drive( - SEQ_NO seqNumber, - LOCKID lockId, - DRIVEID driveId[MAX_ID], - STATE state, - unsigned short count); - -STATUS acs_vary_lsm( - SEQ_NO seqNumber, - LSMID lsmId[MAX_ID], - STATE state, - BOOLEAN force, - unsigned short count); - -STATUS acs_vary_port( - SEQ_NO seqNumber, - PORTID portId[MAX_ID], - STATE state, - unsigned short count); - -STATUS acs_register( - SEQ_NO seqNumber, - REGISTRATION_ID registration_id, - EVENT_CLASS_TYPE eventClass[MAX_EVENT_CLASS_TYPE], - unsigned short count); - -STATUS acs_unregister( - SEQ_NO seqNumber, - REGISTRATION_ID registration_id, - EVENT_CLASS_TYPE eventClass[MAX_EVENT_CLASS_TYPE], - unsigned short count); - -STATUS acs_check_registration( - SEQ_NO seqNumber, - REGISTRATION_ID registration_id); - -STATUS acs_display( - SEQ_NO seqNumber, - TYPE display_type, - DISPLAY_XML_DATA display_xml_data); - -char *acs_type_response( - ACS_RESPONSE_TYPE rtype); - -STATUS acs_virtual_mount( - SEQ_NO seqNumber, - LOCKID lockId, - VOLID volId, - POOLID pool_id, - MGMT_CLAS mgmtClas, - MEDIA_TYPE mtype, - BOOLEAN scratch, - BOOLEAN readonly, - BOOLEAN bypass, - JOB_NAME jobName, - DATASET_NAME datasetName, - STEP_NAME stepName, - DRIVEID driveId); - -STATUS acs_virtual_query_drive( - SEQ_NO seqNumber, - DRIVEID driveId[MAX_ID], - unsigned short count, - BOOLEAN virt_aware); - -char *acs_type( - TYPE type); - -char *acs_status( - STATUS status); - -char *acs_state( - STATE state); - -char *acs_command( - COMMAND cmd); - -VERSION acs_get_packet_version( - void); - -#endif /* _APIPRO_H_ */ diff --git a/usr/src/common/mms/h/db_defs.h b/usr/src/common/mms/h/db_defs.h deleted file mode 100644 index b30891a6da..0000000000 --- a/usr/src/common/mms/h/db_defs.h +++ /dev/null @@ -1,81 +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 _DB_DEFS_ -#define _DB_DEFS_ -#ifndef _DB_DEFS_API_ -#include "api/db_defs_api.h" -#endif -#define DATA_BASE "lib5" -#define MIN_PANEL_TYPE -3 - -#define MIN_TAPE_USAGE 0 - -#define VOLUME_TABLE_FILLFACTOR 20 -#define VOLUME_TABLE_INDEXFILL 20 -#define VOLUME_TABLE_MAXINDEXFILL 24 - -#define VAC_TABLE_FILLFACTOR 26 -#define VAC_TABLE_INDEXFILL 26 -#define VAC_TABLE_MAXINDEXFILL 31 - - -#define CELL_TABLE_FILLFACTOR 46 -#define CELL_TABLE_INDEXFILL 20 -#define CELL_TABLE_MAXINDEXFILL 24 - -#define AUDIT_TABLE_FILLFACTOR 32 -#define AUDIT_TABLE_INDEXFILL 40 -#define AUDIT_TABLE_MAXINDEXFILL 46 - -#define LSM_TABLE_FILLFACTOR 1 - - -#define ACS_TABLE_FILLFACTOR 1 - - -#define DRIVE_TABLE_FILLFACTOR 1 - -#define LOCKID_TABLE_MINPAGES 280 -#define LOCKID_TABLE_FILLFACTOR 25 - - -#define CAP_TABLE_FILLFACTOR 1 - -#define POOL_TABLE_FILLFACTOR 20 -#define POOL_TABLE_INDEXFILL 20 -#define POOL_TABLE_MAXINDEXFILL 24 - -#define CSI_TABLE_FILLFACTOR 1 - -#define PORT_TABLE_FILLFACTOR 1 - -#define PANEL_TABLE_FILLFACTOR 20 -#define PANEL_TABLE_INDEXFILL 20 -#define PANEL_TABLE_MAXINDEXFILL 24 - - - -#endif /* _DB_DEFS_ */ diff --git a/usr/src/common/mms/h/db_structs.h b/usr/src/common/mms/h/db_structs.h deleted file mode 100644 index d88e904b7f..0000000000 --- a/usr/src/common/mms/h/db_structs.h +++ /dev/null @@ -1,134 +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 _DB_STRUCTS_ -#define _DB_STRUCTS_ - -#ifndef _IDENTIFIER_ -#include "identifier.h" -#endif - -typedef struct { - ACS acs; - STATE acs_state; -} ACS_RECORD; - -typedef struct { - LSMID lsm_id; - STATE lsm_state; - STATUS lsm_status; - int lsm_activity; - PANEL last_panel; - ROW last_row; - COL last_col; - LSM lsm_ptp_1; - LSM lsm_ptp_2; - LSM lsm_ptp_3; - LSM lsm_ptp_4; -} LSM_RECORD; - -typedef struct { - CAPID cap_id; - STATUS cap_status; - CAP_PRIORITY cap_priority; - STATE cap_state; - CAP_MODE cap_mode; - short cap_size; -} CAP_RECORD; - -typedef struct { - CELLID cell_id; - STATUS cell_status; -} CELL_RECORD; - -typedef struct { - DRIVEID drive_id; - STATUS drive_status; - STATE drive_state; - VOLID vol_id; - LOCKID lock_id; - long lock_time; - DRIVE_TYPE drive_type; -} DRIVE_RECORD; - -typedef struct { - PORTID port_id; - STATE port_state; - char port_name[PORT_NAME_SIZE + 1]; -} PORT_RECORD; - -typedef struct { - VOLID vol_id; - CELLID cell_id; - DRIVEID drive_id; - VOLUME_TYPE vol_type; - LABEL_ATTR label_attr; - POOLID pool_id; - STATUS vol_status; - long entry_date; - long access_date; - long access_count; - long max_use; - LOCKID lock_id; - long lock_time; - MEDIA_TYPE media_type; -} VOLUME_RECORD; - -typedef struct { - VOLID vol_id; - USERID owner_id; -} VAC_RECORD; - -typedef struct { - POOLID pool_id; - long low_water_mark; - long high_water_mark; - int pool_attributes; -} POOL_RECORD; - - -typedef struct { - char csi_name[CSI_NAME_LENGTH+1]; -} CSI_RECORD; - -typedef enum { - AVT_FIRST = 0, - AVT_FOUND, - AVT_NORMAL, - AVT_LAST -} AVT_STATUS; - -typedef struct { - short audit_pid; - VOLID vol_id; - AVT_STATUS avt_status; -} AVT_RECORD; - -typedef struct { - LOCKID lock_id; - USERID user_id; -} LOCKID_RECORD; - -#endif /* _DB_STRUCTS_ */ diff --git a/usr/src/common/mms/h/defs.h b/usr/src/common/mms/h/defs.h deleted file mode 100644 index ff18039c40..0000000000 --- a/usr/src/common/mms/h/defs.h +++ /dev/null @@ -1,330 +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 _DEFS_ -#define _DEFS_ - -#if ! defined(__sys_types_h) && ! defined(_H_TYPES) -#include <sys/types.h> -#endif - -#ifndef sun -#ifndef _H_SELECT -#include <sys/select.h> -#endif -#endif - -#ifndef _DB_DEFS_ -#include "db_defs.h" -#endif - -#ifndef _DEFS_API_ -#include "api/defs_api.h" -#endif - - -#ifndef SA_RESTART -#define SA_RESTART 0 -#endif - -#ifndef MAX -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif - -#define DEFAULT_TIME_FORMAT "%m-%d-%y %H:%M:%S" - - -typedef enum { - LH_ERR_FIRST = 0, - LH_ERR_ADDR_INACCESSIBLE, - LH_ERR_ADDR_TYPE_INVALID, - LH_ERR_ADDR_UNDEFINED, - LH_ERR_CANCEL_PENDING, - - LH_ERR_CANCEL_TOO_LATE, - LH_ERR_CAP_BUSY, - LH_ERR_CAP_FAILURE, - LH_ERR_DESTINATION_FULL, - LH_ERR_FIRST_EXCEEDS_LAST, - - LH_ERR_LH_BUSY, - LH_ERR_LH_FAILURE, - LH_ERR_LMU_FAILURE, - LH_ERR_LSM_FAILURE, - LH_ERR_LSM_OFFLINE, - - LH_ERR_LSM_OFFLINE_MTCE, - LH_ERR_MULTI_ACS, - LH_ERR_MULTI_LSM, - LH_ERR_MULTI_PANEL, - LH_ERR_MULTI_TYPE, - - LH_ERR_PATH_UNAVAILABLE, - LH_ERR_PORT_CONNECT, - LH_ERR_PORT_DISCONNECT, - LH_ERR_REQUEST_CANCELLED, - LH_ERR_REQUEST_INVALID, - - LH_ERR_REQUEST_NOT_ACTIVE, - LH_ERR_SOURCE_EMPTY, - LH_ERR_TRANSPORT_BUSY, - LH_ERR_TRANSPORT_FAILURE, - LH_ERR_UNABLE_TO_CANCEL, - - LH_ERR_VARY_OVERRIDDEN, - LH_ERR_VARY_PENDING, - LH_ERR_VSN_INVALID, - LH_ERR_VSN_VERIF_FAILED, - LH_ERR_ALREADY_RESERVED, - - LH_ERR_CAP_OPEN, - LH_ERR_LMU_LEVEL_INVALID, - LH_ERR_NO_ERROR, - LH_ERR_NOT_RESERVED, - LH_ERR_NO_MAGAZINE, - - LH_ERR_MEDIA_VERIF_FAIL, - LH_ERR_MEDIA_VSN_VERIF_FAIL, - LH_ERR_INCOMPATIBLE_MEDIA_DRIVE, - LH_ERR_MEDIA_TYPE_INVALID, - LH_ERR_LAST -} LH_ERR_TYPE; - -#define CAP_MSG_INTERVAL 120 -#define DATAGRAM_PATH "/tmp/" -#define MAX_ACSMT_PROCS 2 -#define MAX_CSI 20 -#define MAX_LSM_PTP 5 -#define MAX_PORTS 16 -#define MAX_RETRY 10 -#define RETRY_TIMEOUT 2 - - -#define RETRY 0x01 - -#define ACSEL "50001" -#define ACSLH "50002" -#define ACSLM "50003" -#define ACSSA "50004" -#define ACSSS "50005" -#define ACSPD "50006" -#define ACSLOCK "50007" -#define ACSSV "50008" -#define ACSCM "50009" -#define ACES "50010" -#define ACSMT "50100" -#define ANY_PORT "0" - -#define TRACE_ACSSS_DAEMON 0x00000100L -#define TRACE_CSI 0x00000200L -#define TRACE_ACSLM 0x00000400L -#define TRACE_MOUNT 0x00000800L -#define TRACE_DISMOUNT 0x00001000L -#define TRACE_ENTER 0x00002000L -#define TRACE_EJECT 0x00004000L -#define TRACE_AUDIT 0x00008000L -#define TRACE_QUERY 0x00010000L -#define TRACE_VARY 0x00020000L -#define TRACE_RECOVERY 0x00040000L -#define TRACE_ACSSA 0x00080000L -#define TRACE_CP 0x00100000L -#define TRACE_LIBRARY_HANDLER 0x00200000L -#define TRACE_EVENT_LOGGER 0x00400000L -#define TRACE_CSI_PACKETS 0x00800000L -#define TRACE_LOCK_SERVER 0x01000000L -#define TRACE_SET_CAP 0x02000000L -#define TRACE_SET_CLEAN 0x04000000L -#define TRACE_ACSCM 0x08000000L - - -#define TRACE(lev) \ -/ (trace_value != 0 && (trace_value & 0xff) >= lev) - -typedef void (*SIGFUNCP)(); - - -typedef enum { - CLM_FIRST = 0, - CLM_ABORT_TRANSITION, - CLM_ALLOC_ERROR, - CLM_ASSERTION, - CLM_CAT_TARGET_ERROR, - - CLM_DB_DEADLOCK, - CLM_DB_TIMEOUT, - CLM_DUP_TYPE_NUM, - CLM_DUP_TYPE_STR, - CLM_DESTINATION_FULL, - - CLM_FILE_PROBLEM, - CLM_FIXED_MEDIA_TYPE, - CLM_FIXED_VOLUME_TYPE, - CLM_FUNC_FAILED, - CLM_INC_TYPES, - - CLM_INV_ARG_NUM, - CLM_INV_ARG_STR, - CLM_INV_NUM_ARGS, - CLM_IPC_ATTACH, - CLM_IPC_OPEN, - - CLM_IPC_SEND, - CLM_KILL_ERROR, - CLM_LOCKED_VOL_DELETED, - CLM_MSG_TIMEOUT, - CLM_MSG_TOO_SMALL, - - CLM_NO_TYPES, - CLM_NOT_BOOLEAN, - CLM_NOT_DEFINED, - CLM_SIGNAL_ERROR, - CLM_SOURCE_EMPTY, - - CLM_TABLE_INCORRECT, - CLM_TOO_MANY_COMPAT, - CLM_TRACE_TRANSITION, - CLM_UNDEF_TRANSITION, - CLM_UNEXP_CAT_STATUS, - - CLM_UNEXP_COMMAND, - CLM_UNEXP_EVENT, - CLM_UNEXP_LD_STATUS, - CLM_UNEXP_LH_REQUEST, - CLM_UNEXP_LH_RESPONSE, - - CLM_UNEXP_MESSAGE, - CLM_UNEXP_ORIGINATOR, - CLM_UNEXP_REQUESTOR, - CLM_UNEXP_SIGNAL, - CLM_UNEXP_STATE, - - CLM_UNEXP_STATUS, - CLM_UNEXP_TYPE, - CLM_UNKNOWN_MEDIA_TYPE, - CLM_UNLINK_ERROR, - CLM_UNSUP_LH_ERROR, - - CLM_UNSUP_LH_REQUEST, - CLM_UNSUP_VERSION, - CLM_VOL_FOUND, - CLM_VOL_MISPLACED, - CLM_VOL_MOVED, - - CLM_VOL_NOT_FOUND, - CLM_LAST -} CL_MESSAGE; - -typedef enum { - FIELD_FIRST = 0, - FIELD_ACTIVITY, - FIELD_CAP_MODE, - FIELD_LOCKID, - FIELD_MAX_USE, - - FIELD_POOLID, - FIELD_PRIORITY, - FIELD_STATE, - FIELD_STATUS, - FIELD_VOLUME_TYPE, - - FIELD_LAST -} FIELD; - - -typedef enum { - LOG_OPTION_FIRST = 0, - LOG_OPTION_EVENT, - LOG_OPTION_TRACE, - LOG_OPTION_LAST -} LOG_OPTION; - -typedef enum { - QUERY_TYPE_FIRST = 0, - QUERY_TYPE_ALL, - QUERY_TYPE_ALL_ACS, - QUERY_TYPE_ALL_CELL, - QUERY_TYPE_ALL_DRIVE, - - QUERY_TYPE_ALL_LSM, - QUERY_TYPE_LSM_RESERVED, - QUERY_TYPE_NEXT, - QUERY_TYPE_ONE, - QUERY_TYPE_ONE_CELL, - - QUERY_TYPE_ONE_DRIVE, - QUERY_TYPE_LAST -} QUERY_TYPE; - -typedef enum { - SELECT_OPTION_FIRST = 0, - SELECT_OPTION_ACS, - SELECT_OPTION_LSM, - SELECT_OPTION_LAST -} SELECT_OPTION; - -typedef enum { - WRITE_MODE_FIRST = 0, - WRITE_MODE_CREATE, - WRITE_MODE_UPDATE, - WRITE_MODE_LAST -} WRITE_MODE; - -#define MEDIA_TYPE_LEN 3 -#define DRIVE_TYPE_LEN 3 - -#define MM_MAX_MEDIA_TYPES 36 -#define MM_MAX_DRIVE_TYPES 40 - -#define MM_MEDIA_DB_STR_LEN (MM_MAX_MEDIA_TYPES*(MEDIA_TYPE_LEN + 1))+1 -#define MM_DRIVE_DB_STR_LEN (MM_MAX_DRIVE_TYPES*(DRIVE_TYPE_LEN + 1))+1 - -#ifndef LINUX -extern char *sys_errlist[]; -extern char *sys_siglist[]; -#endif - - -extern char acsss_version[]; -extern int sd_in; -extern int n_fds; -extern int fd_list[FD_SETSIZE]; - -extern char my_sock_name[SOCKET_NAME_SIZE]; - -extern TYPE my_module_type; -extern TYPE requestor_type; -extern int restart_count; -extern MESSAGE_ID request_id; - -extern STATE process_state; -extern unsigned long trace_module; -extern unsigned long trace_value; - - -#endif /* _DEFS_ */ diff --git a/usr/src/common/mms/h/identifier.h b/usr/src/common/mms/h/identifier.h deleted file mode 100644 index c9ac150142..0000000000 --- a/usr/src/common/mms/h/identifier.h +++ /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. - */ - - -#ifndef _IDENTIFIER_ -#define _IDENTIFIER_ - -#ifndef _DB_DEFS_ -#include "db_defs.h" -#endif - -#ifndef _IDENT_API_H_ -#include "api/ident_api.h" -#endif -#endif /* _IDENTIFIER_ */ diff --git a/usr/src/common/mms/h/inclds.h b/usr/src/common/mms/h/inclds.h deleted file mode 100644 index 4064ff1018..0000000000 --- a/usr/src/common/mms/h/inclds.h +++ /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. - */ - - -#ifndef _INCLUDES_ -#define _INCLUDES_ - -#ifndef MAKEDEPEND -#include _DB_DEFS_API_HEADER_ -#include _DEFS_API_HEADER_ -#include _IDENT_API_HEADER_ -#include _IPC_HDR_API_HEADER_ -#include _STRUCTS_API_HEADER_ -#include _LMSTRUCTS_API_HEADER_ -#else -#include "api/db_defs_api.h" -#include "api/defs_api.h" -#include "api/ident_api.h" -#include "api/ipc_hdr_api.h" -#include "api/structs_api.h" -#include "api/lm_structs_api.h" -#endif - -#endif /* _INCLUDES_ */ diff --git a/usr/src/common/mms/mms/mms.h b/usr/src/common/mms/mms/mms.h deleted file mode 100644 index c24aa87d49..0000000000 --- a/usr/src/common/mms/mms/mms.h +++ /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 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - -#ifndef _MMS_H_ -#define _MMS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdio.h> -#include <errno.h> -#include <string.h> -#include <stdlib.h> -#include <pthread.h> -#include <unistd.h> -#include <mms_sym.h> -#include <mms_err.h> -#include <mms_strapp.h> -#include <mms_trace.h> -#include <mms_network.h> -#include <mms_list.h> -#include <mms_parser.h> -#include <mms_cat.h> -#include <mms_api.h> -#include <mms_api_msg.h> -#include <mms_dmd.h> - -#ifdef __cplusplus -} -#endif - -#endif /* _MMS_H_ */ diff --git a/usr/src/common/mms/mms/mms_api.h b/usr/src/common/mms/mms/mms_api.h deleted file mode 100644 index 74a572b93e..0000000000 --- a/usr/src/common/mms/mms/mms_api.h +++ /dev/null @@ -1,269 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - -#ifndef _MMS_API_H_ -#define _MMS_API_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#define MMS_API_VERSION 1000 - -#define MMS_API_RSP_UNACC 0 -#define MMS_API_RSP_ACC 1 -#define MMS_API_RSP_FINAL 2 -#define MMS_API_RSP_FINAL_INTR 3 -#define MMS_API_RSP_FINAL_ERR 4 -#define MMS_API_RSP_FINAL_CANC 5 -#define MMS_API_RSP_EVENT 7 - -#define MMS_API_NO 0 -#define MMS_API_YES 1 - -#define MMS_API_OK 0 -#define MMS_API_ERROR 1 - -#define MMS_API_UNCONFIG 0 -#define MMS_API_CONFIG 1 -#define MMS_API_FAILURE 2 - -#define MMS_API_ASYNC 1 -#define MMS_API_SYNC 2 - -typedef struct mms_event { - int mms_ev_code; - void *mms_ev_data; -} mms_event_t; - -typedef struct mms_ev_volume { - char *mms_ev_volume_name; - char *mms_ev_media_type; -} mms_ev_volume_t; - -typedef struct mms_ev_library { - char *mms_ev_inst_name; - char *mms_ev_lib_name; -} mms_ev_library_t; - -typedef struct mms_ev_dm { - char *mms_ev_inst_name; - char *mms_ev_drive_name; - char *mms_ev_host; -} mms_ev_dm_t; - -typedef struct mms_ev_message { - char *mms_ev_who; - char *mms_ev_id; - char *mms_ev_client; - char *mms_ev_inst; - char *mms_ev_level; - char *mms_ev_text; - char *mms_ev_msg; -} mms_ev_message_t; - -typedef struct mms_rsp_ele { - mms_list_node_t mms_rsp_next; - int mms_rsp_type; /* Type of response or */ - /* event type */ - char *mms_rsp_tid; /* Task id of response or */ - /* event tag */ - char *mms_rsp_str; /* Response or event string */ - mms_par_node_t *mms_rsp_cmd; /* Parse tree of string */ -} mms_rsp_ele_t; - -typedef struct mms_send_ele { - mms_list_node_t mms_send_next; - char *mms_send_tid; /* Task id of cmd to be sent */ - /* over a async connection */ - char *mms_send_cmd; /* Command to be sent */ -} mms_send_ele_t; - -typedef struct mms_cmd_ele { - mms_list_node_t mms_cmd_next; - int mms_cmd_type; /* Type of command async,sync */ - char *mms_cmd_tid; /* Task id of outstanding cmd */ - char *mms_cmd_cmd; /* Outstanding command */ - void (*mms_cmd_callbk)(void *arg, void *arg1); - /* If async cmd, callback */ - /* function to use for */ - /* response */ - void *mms_cmd_callbk_param; /* User param to be sent to */ - /* callback function */ -} mms_cmd_ele_t; - -typedef struct mms_callbk { - void (*mms_func)(void *arg); /* Callback */ - void *mms_param; /* Callback parameter */ -} mms_callbk_t; - -typedef struct mms_rsp_callbk { - void (*mms_func)(void *arg, void *arg1); - /* Callback */ - void *mms_param; /* Callback parameter */ -} mms_rsp_callbk_t; - -typedef struct mms_session { - mms_list_t mms_cmd_list; /* Outstanding command list */ - mms_list_t mms_rsp_list; /* Sync commands final */ - /* response list */ - mms_list_t mms_ev_list; /* List of events received */ - int mms_thrd_cnt; /* Number of outstanding */ - /* threads in session */ - int mms_api_state; /* Current state of the */ - /* connection, config, */ - /* unconfig, or error */ - int mms_api_mode; /* Type of connection, SYNC */ - /* or combination with ASYNC */ - int mms_api_errcode; /* If a internal processing */ - /* error occurs this get */ - /* set to show what caused */ - /* the error to happen */ - int mms_api_rstarted; /* For async mode, tells when */ - /* reader thread has started */ - char *mms_acc_tid; /* Task id of cmd waiting on */ - /* accept response */ - boolean_t mms_be_pending; /* begin-end sequence pending */ - char *cprefix; /* Set by the client to tag */ - /* who is using the API */ - void (*clog) (char *, char *); /* Function to use to log */ - /* API errors into the */ - /* clients log file */ - mms_rsp_ele_t *mms_acc_rsp; /* Pointer to the latest */ - /* accept/unaccept response */ - mms_t mms_conn; /* MMS socket connection */ - /* structure pointer */ - pthread_mutex_t mms_cnt_mutex; /* Controls access to */ - /* mms_thrd_cnt */ - pthread_cond_t mms_cnt_cv; /* Used for waking up thread */ - /* waiting to shutdown the */ - /* session when all */ - /* outstanding threads */ - /* to MM have stopped */ - pthread_mutex_t mms_cmd_mutex; /* Controls access to */ - /* mms_cmd_list */ - pthread_mutex_t mms_cacc_mutex; /* Stops other send cmds */ - /* from sending their cmds */ - /* until current cmd gets */ - /* acc/unacc response */ - pthread_mutex_t mms_acc_mutex; /* Stops the reader thread */ - /* and the thread waiting on */ - /* acc/unacc response from */ - /* accessing shared memory */ - /* at the same time */ - pthread_cond_t mms_acc_cv; /* Used for waking up thread */ - /* waiting on accept/unaccept */ - /* response */ - pthread_mutex_t mms_rsp_mutex; /* Controls access to sync */ - /* cmds response list */ - pthread_cond_t mms_rsp_cv; /* Used for waking up threads */ - /* waiting on a final rsp */ - pthread_mutex_t mms_conn_mutex; /* Controls socket access */ - /* to MMS */ - pthread_mutex_t mms_reading; /* Controls reading from MMS */ - /* socket */ - pthread_mutex_t mms_be_mutex; /* Controls begin-end's to */ - /* send */ - pthread_cond_t mms_be_cv; - /* thread in async mode */ - pthread_attr_t mms_reader_attr; /* Attribute for aysnc reader */ - /* thread */ - void (*mms_async_error)(void *arg); /* Used in case an internal */ - /* processing error is */ - /* encountered using a ASYNC */ - /* connection to notify the */ - /* client of the failure */ - void *mms_async_error_param; /* Error callback parameter */ - void (*mms_ev_callbk)(void *arg, void *arg1); - /* Event callback */ - void *mms_ev_callbk_param; /* Event callback parameter */ - pthread_mutex_t mms_ev_mutex; /* Controls access to event */ - /* list */ - pthread_cond_t mms_ev_cv; /* Used to wake up threads */ - /* waiting on events */ -} mms_session_t; - -int mms_init(void **, int *); -int mms_ainit(void **, int *, mms_callbk_t *, mms_rsp_callbk_t *); -int mms_hello(void *, char *, char *, char *, char *, char *, char *, char *, - void *); -int mms_hello_net(void *, mms_network_cfg_t *, char *, void *); - -int mms_goodbye(void *, int); -int mms_agoodbye(void *, int); - -void *mms_api_reader(void *); -void *mms_api_writer(void *); - -void mms_send_errmsg(mms_session_t *sp, int msgid, ...); -int mms_handle_err_rsp(void *, int *, int *, char **); - -int mms_send_cmd(void *, char *, void **); -int mms_send_acmd(void *, char *, void (*)(), void *); -int mms_read_response(void *, char *, void **); -int mms_obtain_response(mms_session_t *, char *, mms_rsp_ele_t **, int); - -int mms_read_event(void *, void **); -int mms_obtain_event(mms_session_t *, mms_rsp_ele_t **); -void mms_free_event(void *); - -void mms_free_rsp(void *); -void mms_free_cmd(mms_cmd_ele_t *); -void mms_free_send(mms_send_ele_t *); -char *mms_get_attribute(void *, char *, void **); - -mms_rsp_ele_t *mms_gen_err_rsp(char *, int, char *); - -void mms_serr(mms_trace_sev_t, char *, int, const char *, ...); - -extern char mms_empty_string[]; - -/* This may need to be part of a session to show which events a */ -/* session of the api has registered for */ -extern char *mms_notify[]; -extern char *mms_event[]; -extern char *mms_scope[]; -extern char *mms_api[]; - -/* MACROS */ - -#define mms_set_errlog(session, log) { \ - ((mms_session_t *)session)->clog = log; \ - } -#define mms_set_errpfx(session, prefix) { \ - ((mms_session_t *)session)->cprefix = strdup(prefix); \ - } -#define mms_rsp_type(rsp) ((mms_rsp_ele_t *)rsp)->mms_rsp_type -#define mms_event_type(rsp) ((mms_rsp_ele_t *)rsp)->mms_rsp_tid -#define mms_get_tree(rsp) ((mms_rsp_ele_t *)rsp)->mms_rsp_cmd -#define mms_get_str(rsp) ((mms_rsp_ele_t *)rsp)->mms_rsp_str -#define mms_state_failed(_sess) \ - ((mms_session_t *)(_sess))->mms_api_state != MMS_API_CONFIG - -#ifdef __cplusplus -} -#endif - -#endif /* _MMS_API_H_ */ diff --git a/usr/src/common/mms/mms/mms_api_msg.h b/usr/src/common/mms/mms/mms_api_msg.h deleted file mode 100644 index b198b58a33..0000000000 --- a/usr/src/common/mms/mms/mms_api_msg.h +++ /dev/null @@ -1,117 +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 __MMS_API_MSG_H -#define __MMS_API_MSG_H - -#include <libintl.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef MMS_API_MSG -#define MMS_API_MSG(n, s) -#endif - -/* API Messages 3000-3999 */ - -#define MMS_API_3000_MSG 3000 -MMS_API_MSG(MMS_API_3000_MSG, - gettext("MMS API session pointer is set to NULL.")) - -#define MMS_API_3001_MSG 3001 -MMS_API_MSG(MMS_API_3001_MSG, gettext("MMS API has encountered a previous " \ - "internal processing error, unable to process API commands.")) - -#define MMS_API_3002_MSG 3002 -MMS_API_MSG(MMS_API_3002_MSG, gettext("MMS API has encountered a thread " \ - "lock failure of $name$ mutex, errno - $errno$.")) - -#define MMS_API_3003_MSG 3003 -MMS_API_MSG(MMS_API_3003_MSG, gettext("MMS API has encountered a thread " \ - "unlock failure of $name$ mutex, errno - $errno$.")) - -#define MMS_API_3005_MSG 3005 -MMS_API_MSG(MMS_API_3005_MSG, gettext("MMS API encountered a socket write " \ - "failure trying to send command with task id $taskid$ to MMS.")) - -#define MMS_API_3006_MSG 3006 -MMS_API_MSG(MMS_API_3006_MSG, gettext("MMS API received an invalid response " \ - "from MMS for command with task id $taskid$.")) - -#define MMS_API_3008_MSG 3008 -MMS_API_MSG(MMS_API_3008_MSG, gettext("MMS API has encountered a taskid " \ - "mismatch on an accept-unaccept response, expected - $expected$, " \ - "received - $received$.")) - -#define MMS_API_3010_MSG 3010 -MMS_API_MSG(MMS_API_3010_MSG, - gettext("MMS API session socket to MMS is not open.")) - -#define MMS_API_3011_MSG 3011 -MMS_API_MSG(MMS_API_3011_MSG, gettext("MMS API encountered a select failure " \ - "on socket to MMS with errno - $errno$.")) - -#define MMS_API_3012_MSG 3012 -MMS_API_MSG(MMS_API_3012_MSG, - gettext("MMS API detected that MMS has disconnect from client.")) - -#define MMS_API_3013_MSG 3013 -MMS_API_MSG(MMS_API_3013_MSG, - gettext("MMS API encountered a response read failure.")) - -#define MMS_API_3014_MSG 3014 -MMS_API_MSG(MMS_API_3014_MSG, - gettext("MMS API encountered a missing $part$ in input from MMS.")) - -#define MMS_API_3015_MSG 3015 -MMS_API_MSG(MMS_API_3015_MSG, gettext("MMS API could not find and entry in " \ - "$list$ with taskid $taskid$.")) - -#define MMS_API_3017_MSG 3017 -MMS_API_MSG(MMS_API_3017_MSG, gettext("MMS API encountered a parse error on " \ - "input from MMS: $errmsg$.")) - -#define MMS_API_3018_MSG 3018 -MMS_API_MSG(MMS_API_3018_MSG, gettext("MMS API has been told to shutdown.")) - -#define MMS_API_3019_MSG 3019 -MMS_API_MSG(MMS_API_3019_MSG, gettext("MMS API session is configured in a " \ - "mode that does not support this API command.")) - -#define MMS_API_3051_MSG 3051 -MMS_API_MSG(MMS_API_3051_MSG, - gettext("MMS API failed to connect to MMS due to $error$ error.")) - -#define MMS_API_3052_MSG 3052 -MMS_API_MSG(MMS_API_3052_MSG, - gettext("MMS API goodbye command failed to be sent to MMS.")) - -#ifdef __cplusplus -} -#endif - -#endif /* __MMS_API_MSG_H */ diff --git a/usr/src/common/mms/mms/mms_cat.h b/usr/src/common/mms/mms/mms_cat.h deleted file mode 100644 index ce1680029b..0000000000 --- a/usr/src/common/mms/mms/mms_cat.h +++ /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. - */ - - -#ifndef __MMS_CAT_H -#define __MMS_CAT_H - -#ifdef __cplusplus -extern "C" { -#endif - -void mms_cat_open(void); -char *mms_get_cat_msg(int msgid); -char *mms_get_msg(mms_par_node_t *root); -char *mms_get_msgcl(int msgid, ...); -char *mms_buf_msgcl(char *buf, int len, int msgid, ...); -char *mms_bld_msgcl(int msgid, va_list args); -char *mms_get_locstr(int msgid, va_list args); - -#ifdef __cplusplus -} -#endif - -#endif /* __MMS_CAT_H */ diff --git a/usr/src/common/mms/mms/mms_dm_msg.h b/usr/src/common/mms/mms/mms_dm_msg.h deleted file mode 100644 index 79cf175597..0000000000 --- a/usr/src/common/mms/mms/mms_dm_msg.h +++ /dev/null @@ -1,126 +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 __MMS_DM_MSG_H -#define __MMS_DM_MSG_H - - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef DM_MSG -#define DM_MSG(n, s) -#endif - -/* DM Messages 6000-6999 */ - -#define DM_6500_MSG 6500 -DM_MSG(DM_6500_MSG, gettext("$dm$: syntax error: $error$")) - -#define DM_6501_MSG 6501 -DM_MSG(DM_6501_MSG, gettext("$dm$: activate $type$ failed: $error$")) - -#define DM_6502_MSG 6502 -DM_MSG(DM_6502_MSG, - gettext("$dm$: reserved. Preempt reservation? reply yes/no/retry.")) - -#define DM_6504_MSG 6504 -DM_MSG(DM_6504_MSG, gettext("$dm$: USCSICMD error: $error$")) - -#define DM_6505_MSG 6505 -DM_MSG(DM_6505_MSG, gettext("$dm$: no matching command: $error$")) - -#define DM_6506_MSG 6506 -DM_MSG(DM_6506_MSG, gettext("$dm$: internal error: $error$")) - -#define DM_6507_MSG 6507 -DM_MSG(DM_6507_MSG, gettext("$dm$: unknown capability: $error$")) - -#define DM_6508_MSG 6508 -DM_MSG(DM_6508_MSG, gettext("$dm$: attach error: $error$")) - -#define DM_6510_MSG 6510 -DM_MSG(DM_6510_MSG, gettext("$dm$: identify error: $error$")) - -#define DM_6511_MSG 6511 -DM_MSG(DM_6511_MSG, gettext("$dm$: detach error: $error$")) - -#define DM_6513_MSG 6513 -DM_MSG(DM_6513_MSG, gettext("$dm$: set blocksize error: $error$")) - -#define DM_6514_MSG 6514 -DM_MSG(DM_6514_MSG, gettext("$dm$: get blocksize error: $error$")) - -#define DM_6515_MSG 6515 -DM_MSG(DM_6515_MSG, gettext("$dm$: unsupported MTIOCTOP function: $error$")) - -#define DM_6516_MSG 6516 -DM_MSG(DM_6516_MSG, gettext("$dm$: open error: $error$")) - -#define DM_6517_MSG 6517 -DM_MSG(DM_6517_MSG, gettext("$dm$: load command error: $error$")) - -#define DM_6518_MSG 6518 -DM_MSG(DM_6518_MSG, gettext("$dm$: overwrite data on $pcl$? reply yes/no.")) - -#define DM_6519_MSG 6519 -DM_MSG(DM_6519_MSG, gettext("$dm$: switch label from $from$ to $to$ on " \ - "$pcl$? reply yes/no.")) - -#define DM_6520_MSG 6520 -DM_MSG(DM_6520_MSG, gettext("$dm$: switch label from $from$ to $to$ and " \ - "writeover data on $pcl$? reply yes/no.")) - -#define DM_6521_MSG 6521 -DM_MSG(DM_6521_MSG, gettext("$dm$: $drive$ is still opened by pid $pid$")) - -#define DM_6522_MSG 6522 -DM_MSG(DM_6522_MSG, gettext("$dm$: MTSEEK error: $error$")) - -#define DM_6523_MSG 6523 -DM_MSG(DM_6523_MSG, gettext("$dm$: MTTELL error: $error$")) - -#define DM_6524_MSG 6524 -DM_MSG(DM_6524_MSG, - gettext("$dm$: DM restarting because of attach error: $error$")) - -#define DM_6525_MSG 6525 -DM_MSG(DM_6525_MSG, gettext("$dm$: DM initialization error: $error$")) - -#define DM_6526_MSG 6526 -DM_MSG(DM_6526_MSG, gettext("$dm$: DM restarting: $error$")) - -#define DM_6527_MSG 6527 -DM_MSG(DM_6527_MSG, gettext("$dm$: mount command error: $error$")) - -#define DM_6529_MSG 6529 -DM_MSG(DM_6529_MSG, gettext("$dm$: make handle directory error: $error$")) - - -#ifdef __cplusplus -} -#endif - -#endif /* __MMS_DM_MSG_H */ diff --git a/usr/src/common/mms/mms/mms_dmd.h b/usr/src/common/mms/mms/mms_dmd.h deleted file mode 100644 index ce4afb4743..0000000000 --- a/usr/src/common/mms/mms/mms_dmd.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - -#ifndef _MMS_DMD_H_ -#define _MMS_DMD_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* Begin: 32-bit align copyin() structs for amd64 only due to 32-bit x86 ABI */ -#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 -#pragma pack(4) -#endif - -#define MMS_HDL_DIR "/var/mms/handle" -#define MMS_MAX_CMD (32 * 1024) /* Max cmd size to/from MMS */ - -#define MMS_SER_NUM_LEN 64 /* max size of ser number */ -#define MMS_READ_SER_NUM_BUF_LEN (MMS_SER_NUM_LEN + 4) - - -/* - * Struct to hold position - */ -typedef struct mms_pos { - uint64_t mms_pos; -} mms_pos_t; - -/* - * Density request - */ -typedef struct mms_density { - uint32_t mms_den; -} mms_density_t; - -/* - * Capacity request - */ -typedef struct mms_capacity { - /* - * Capacity is in megabytes (1048576) - */ - uint64_t mms_max; /* capacity of the cartridge */ - uint64_t mms_avail; /* amount available from EOD */ - uint32_t mms_pc_avail; /* percent available */ -} mms_capacity_t; - -/* - * Read block limit - */ -typedef struct mms_blk_limit { - uint64_t mms_max; /* Max blocksize */ - uint32_t mms_min; /* Min blocksize */ - uint32_t mms_gran; /* granularity */ -} mms_blk_limit_t; - -#define MMS_SIDE(num) "side " #num -#define MMS_PART(num) "Part" #num - -/* - * MMS ioctl's - */ -#define MMS_IOC (('S' << 24) | ('M' << 16) | ('M' << 8)) - -#define MMS_BLK_LIMIT (MMS_IOC | 1) /* read block limit */ -#define MMS_GET_POS (MMS_IOC | 2) /* get position */ -#define MMS_LOCATE (MMS_IOC | 3) /* locate to position */ -#define MMS_FILE_OPT (MMS_IOC | 4) /* return file options */ -#define MMS_GET_CAPACITY (MMS_IOC | 5) /* return capacity */ -#define MMS_UPDATE_CAPACITY (MMS_IOC | 6) /* update cartridge capacity */ - /* in database */ -#define MMS_SET_DENSITY (MMS_IOC | 7) /* set density */ -#define MMS_GET_DENSITY (MMS_IOC | 8) /* get density */ -#define MMS_INQUIRY (MMS_IOC | 9) /* get inquiry data */ - -/* - * MMS special pseudo sense key for beg of file and end of file. - * They are returned in mt_erreg. - */ -#define MMS_KEY_BOF 0xe0 /* At the beginning of file. */ -#define MMS_KEY_EOF 0xe1 /* At the end of file (not tapemark). */ - -/* - * SCSI error - */ -typedef struct mms_scsi_err { - uchar_t mms_sk; /* sense key */ - uchar_t mms_asc; /* additional sense code */ - uchar_t mms_ascq; /* additional sense code qual */ - char mms_text[256]; /* error text */ -} mms_scsi_err_t; - - - - -/* End: 32-bit align copyin() structs for amd64 only due to 32-bit x86 ABI */ -#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 -#pragma pack() -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* _MMS_DMD_H_ */ diff --git a/usr/src/common/mms/mms/mms_err.h b/usr/src/common/mms/mms/mms_err.h deleted file mode 100644 index 7f293528bc..0000000000 --- a/usr/src/common/mms/mms/mms_err.h +++ /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 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _MMS_ERR_H_ -#define _MMS_ERR_H_ - - -#ifdef __cplusplus -extern "C" { -#endif - -enum mms_err_type { - MMS_ERR_SYS = 1, /* errno */ - MMS_ERR_GAI, /* get address info error */ - MMS_ERR_SSL /* ssl error */ -}; -typedef enum mms_err_type mms_err_type_t; /* contents of error number */ - -typedef struct mms_err mms_err_t; -struct mms_err { - mms_err_type_t mms_type; /* which error string func to use */ - int mms_id; /* mms error code */ - ulong_t mms_num; /* errno or ssl error number */ -}; - -void mms_get_error_string(mms_err_t *err, char *ebuf, int ebuflen); - - -#ifdef __cplusplus -} -#endif - -#endif /* _MMS_ERR_H_ */ diff --git a/usr/src/common/mms/mms/mms_list.h b/usr/src/common/mms/mms/mms_list.h deleted file mode 100644 index 842a3515a7..0000000000 --- a/usr/src/common/mms/mms/mms_list.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - - - -#ifndef _MMS_LIST_H_ -#define _MMS_LIST_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <sys/types.h> -#include <assert.h> -#include <sys/list_impl.h> -#include <sys/list.h> -#include <stddef.h> - -typedef struct mms_list_node { - struct mms_list_node *list_next; - struct mms_list_node *list_prev; -} mms_list_node_t; - -typedef struct mms_list { - size_t list_size; - size_t list_offset; - struct mms_list_node list_head; -} mms_list_t; - -/* - * Generic doubly-linked list implementation - */ -#define MMS_LIST_NOT_MOVED(list) \ - ((mms_list_t *)((ptrdiff_t)((list)->list_head.list_next->list_prev) - \ - offsetof(mms_list_t, list_head)) == (list)) - -#define mms_list_d2l(a, obj) \ - ((mms_list_node_t *)((ptrdiff_t)((intptr_t)obj) + (a)->list_offset)) -#define mms_list_object(a, node) \ - ((void *)((ptrdiff_t)((intptr_t)node) - (a)->list_offset)) -#define mms_list_empty(a) ((a)->list_head.list_next == &(a)->list_head) - -/* - * Define and initailze a list - */ -#define MMS_LIST_CREATE(list, structname, link) \ - mms_list_t list = { \ - sizeof (structname), \ - offsetof(structname, link), \ - &list.list_head, \ - &list.list_head \ - } - -/* - * Some useful macros - */ -#define mms_list_foreach(list, obj) \ - for (obj = mms_list_head(list); obj != NULL; \ - obj = mms_list_next(list, obj)) - -/* - * Get name value string pairs. - */ -#define mms_list_pair_foreach(list, name, value) \ - for (name = mms_list_head(list), \ - value = (name != NULL ? mms_list_next(list, name) : NULL); \ - name != NULL && value != NULL; \ - name = mms_list_next(list, value), \ - value = (name != NULL ? mms_list_next(list, name) : NULL)) - - -/* - * Safe to remove the current object from the list. - */ -#define mms_list_foreach_safe(list, obj, next) \ - for (obj = mms_list_head(list); \ - ((next = obj != NULL ? mms_list_next(list, obj) : NULL), \ - obj != NULL); obj = next) - -void mms_list_create(mms_list_t *, size_t, size_t); -void mms_list_destroy(mms_list_t *); - -void mms_list_insert_after(mms_list_t *, void *, void *); -void mms_list_insert_before(mms_list_t *, void *, void *); -void mms_list_insert_head(mms_list_t *, void *); -void mms_list_insert_tail(mms_list_t *, void *); -void mms_list_remove(mms_list_t *, void *); -void mms_list_move_tail(mms_list_t *, mms_list_t *); - -void *mms_list_head(mms_list_t *); -void *mms_list_tail(mms_list_t *); -void *mms_list_next(mms_list_t *, void *); -void *mms_list_prev(mms_list_t *, void *); -void mms_list_create_like(mms_list_t *targ, mms_list_t *src); -void mms_list_move(mms_list_t *targ, mms_list_t *src); - -#ifdef __cplusplus -} -#endif - -#endif /* _MMS_LIST_H_ */ diff --git a/usr/src/common/mms/mms/mms_lm_msg.h b/usr/src/common/mms/mms/mms_lm_msg.h deleted file mode 100644 index 2f38dc94e2..0000000000 --- a/usr/src/common/mms/mms/mms_lm_msg.h +++ /dev/null @@ -1,384 +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 __MMS_LM_MSG_H -#define __MMS_LM_MSG_H - - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef LM_MSG -#define LM_MSG(n, s) -#endif - -/* LM Messages 7000-7999 */ - -#define LM_7000_MSG 7000 -LM_MSG(LM_7000_MSG, - gettext("LM was unable to obtain task id from $cmd$ command.")) - -#define LM_7001_MSG 7001 -LM_MSG(LM_7001_MSG, gettext("Current state of LM does not allow processing " \ - "a $cmd$ command.")) - -#define LM_7002_MSG 7002 -LM_MSG(LM_7002_MSG, gettext("LM received an invalid command - $cmd$.")) - -#define LM_7003_MSG 7003 -LM_MSG(LM_7003_MSG, gettext("LM received a $cmd$ command after being told " \ - "to shutdown, command aborted.")) - -#define LM_7004_MSG 7004 -LM_MSG(LM_7004_MSG, gettext("Internal processing error occurred while " \ - "processing LMPM $cmd$ command.")) - -#define LM_7005_MSG 7005 -LM_MSG(LM_7005_MSG, - gettext("Last LMPM $cmd$ command sent to LM contained a syntax error.")) - -#define LM_7006_MSG 7006 -LM_MSG(LM_7006_MSG, - gettext("LM received a signal to shutdown, exit code - $ecode$.")) - -#define LM_7007_MSG 7007 -LM_MSG(LM_7007_MSG, - gettext("LM is shutting down due to an internal processing error.")) - -#define LM_7009_MSG 7009 -LM_MSG(LM_7009_MSG, gettext("LMPM $cmd$ command has invalid or missing " \ - "arguments in area of $part$.")) - -#define LM_7010_MSG 7010 -LM_MSG(LM_7010_MSG, gettext("LMPM private command contains a unsupported " \ - "$type$-name of $name$.")) - -#define LM_7011_MSG 7011 -LM_MSG(LM_7011_MSG, gettext("LMPM private command's set-name $name$ has " \ - "a illegal set-value of $value$.")) - -#define LM_7013_MSG 7013 -LM_MSG(LM_7013_MSG, gettext("LM state is changing to $state$.")) - -#define LM_7014_MSG 7014 -LM_MSG(LM_7014_MSG, gettext("LM is active.")) - -#define LM_7015_MSG 7015 -LM_MSG(LM_7015_MSG, gettext("LM is deactivated.")) - -#define LM_7016_MSG 7016 -LM_MSG(LM_7016_MSG, gettext("LM is exiting.")) - -#define LM_7017_MSG 7017 -LM_MSG(LM_7017_MSG, gettext("LM is resetting.")) - -#define LM_7018_MSG 7018 -LM_MSG(LM_7018_MSG, - gettext("The library object $object$ or its value is missing.")) - -#define LM_7020_MSG 7020 -LM_MSG(LM_7020_MSG, gettext("Loading a $type$ library module of connection " \ - "type $conn$ failed.")) - -#define LM_7021_MSG 7021 -LM_MSG(LM_7021_MSG, gettext("LM is shutting down due to watcher going away.")) - -#define LM_7022_MSG 7022 -LM_MSG(LM_7022_MSG, gettext("LM completed partial reset.")) - -#define LM_7023_MSG 7023 -LM_MSG(LM_7023_MSG, gettext("LM encountered a lmpm_parser syntax error " \ - "on last LMPL response from MM.")) - -#define LM_7024_MSG 7024 -LM_MSG(LM_7024_MSG, gettext("LM encountered a lmpm_parser syntax error on " \ - "last input from MM, unable to determine if LMPM command or LMPL " \ - "response.")) - -#define LM_7025_MSG 7025 -LM_MSG(LM_7025_MSG, gettext("LM encountered a lmpm_parser no memory error.")) - -#define LM_7026_MSG 7026 -LM_MSG(LM_7026_MSG, - gettext("LM encountered a unrecoverable lmpm_parser error.")) - -#define LM_7027_MSG 7027 -LM_MSG(LM_7027_MSG, gettext("LMPM $cmd$ command is being aborted due to the " \ - "LM going inactive or being shutdown.")) - -#define LM_7030_MSG 7030 -LM_MSG(LM_7030_MSG, gettext("During processing of LMPM $cmd$ command, " \ - "LMPL $lmpl$ command received a $rsp$ response from MM.")) - -#define LM_7032_MSG 7032 -LM_MSG(LM_7032_MSG, gettext("During processing of LMPM $cmd$ command, " \ - "LMPL show command was not able to obtain serial number for " \ - "drive $drive$.")) - -#define LM_7033_MSG 7033 -LM_MSG(LM_7033_MSG, gettext("During activation of library, Library is " \ - "configured in MMS as type $type$, ACSLS says library is " \ - "type $a_type$.")) - -#define LM_7101_MSG 7101 -LM_MSG(LM_7101_MSG, gettext("LMPM $cmd$ command completed successfully.")) - -#define LM_7102_MSG 7102 -LM_MSG(LM_7102_MSG, gettext("Cartridge $cart$ is mounted in drive $drive$.")) - -#define LM_7103_MSG 7103 -LM_MSG(LM_7103_MSG, gettext("Cartridge $cart$ unmounted from drive $drive$.")) - -#define LM_7105_MSG 7105 -LM_MSG(LM_7105_MSG, - gettext("LMPM $cmd$ command is a NOP for a $type$ library.")) - -#define LM_7106_MSG 7106 -LM_MSG(LM_7106_MSG, gettext("Cartridge(s) $cart$ injected into library.")) - -#define LM_7107_MSG 7107 -LM_MSG(LM_7107_MSG, gettext("Cartridge(s) $cart$ ejected from library.")) - -#define LM_7108_MSG 7108 -LM_MSG(LM_7108_MSG, gettext("Port $port$ is a valid ACSLS CAP designation; " \ - "however, it is not physically configured.")) - -#define LM_7109_MSG 7109 -LM_MSG(LM_7109_MSG, gettext("There were cartridges in CAP, but none were " \ - "injected into library.")) - -#define LM_7110_MSG 7110 -LM_MSG(LM_7110_MSG, - gettext("Cartridge(s) $cart$ were not injected into library.")) - -#define LM_7111_MSG 7111 -LM_MSG(LM_7111_MSG, gettext("Cartridge(s) $cart$ were injected into " \ - "library; however, unable to locate a slot location.")) - -#define LM_7112_MSG 7112 -LM_MSG(LM_7112_MSG, - gettext("CAP was empty, No cartridges injected into library.")) - -#define LM_7113_MSG 7113 -LM_MSG(LM_7113_MSG, gettext("Too many cartridges specified to be ejected " \ - "from library, max CAP size is $num$.")) - -#define LM_7114_MSG 7114 -LM_MSG(LM_7114_MSG, - gettext("Cartridge(s) $cart$ were not ejected from library.")) - -#define LM_7115_MSG 7115 -LM_MSG(LM_7115_MSG, gettext("No cartridges ejected from library.")) - -#define LM_7116_MSG 7116 -LM_MSG(LM_7116_MSG, gettext("LMPM scan command does not support the " \ - "fromslot and toslot format for $type$ libraries.")) - -#define LM_7117_MSG 7117 -LM_MSG(LM_7117_MSG, - gettext("Port $port$ is not a valid ACSLS CAP designation.")) - -#define LM_7118_MSG 7118 -LM_MSG(LM_7118_MSG, gettext("Scan for cartridges $carts$ found cartridges " \ - "in slots of library.")) - -#define LM_7119_MSG 7119 -LM_MSG(LM_7119_MSG, gettext("Scan for cartridges $carts$ did not find " \ - "cartridges in slots of library.")) - -#define LM_7120_MSG 7120 -LM_MSG(LM_7120_MSG, gettext("Scan for cartridges did not find any " \ - "cartridges in slots of library.")) - -#define LM_7121_MSG 7121 -LM_MSG(LM_7121_MSG, - gettext("Scan of drive(s) with geometries $geom$ completed")) - -#define LM_7122_MSG 7122 -LM_MSG(LM_7122_MSG, gettext("Scan for drives(s) did not find any in library.")) - -#define LM_7123_MSG 7123 -LM_MSG(LM_7123_MSG, gettext("Scan for drive(s) with geometries $geom$ were " \ - "not found in library.")) - -#define LM_7124_MSG 7124 -LM_MSG(LM_7124_MSG, gettext("Scan of entire library completed.")) - -#define LM_7125_MSG 7125 -LM_MSG(LM_7125_MSG, gettext("Scan of drive(s) $list$ completed.")) - -#define LM_7126_MSG 7126 -LM_MSG(LM_7126_MSG, gettext("No ACSLS geometry found for drive $name$, " \ - "serial number - $serial$.")) - -#define LM_7200_MSG 7200 -LM_MSG(LM_7200_MSG, gettext("LMPM $cmd$ command failed, ACSLS command " \ - "$acsls$ returned a status of STATUS_LIBRARY_NOT_AVAILABLE, " \ - "state of ACSLS server - $state$.")) - -#define LM_7201_MSG 7201 -LM_MSG(LM_7201_MSG, gettext("LMPM $cmd$ command failed, ACSLS command " \ - "$acsls$ returned a status of STATUS_LIBRARY_NOT_AVAILABLE, " \ - "state of ACSLS server is non-determinable.")) - -#define LM_7202_MSG 7202 -LM_MSG(LM_7202_MSG, gettext("Received a STATUS_LIBRARY_NOT_AVAILABLE " \ - "from ACSLS server, state of server - \"state\", LM state being " \ - "switched to broken.")) - -#define LM_7203_MSG 7203 -LM_MSG(LM_7203_MSG, gettext("Communication problem with ACSLS server, " \ - "status returned from server - $status$, LM state being switched " \ - "to disconnected.")) - -#define LM_7204_MSG 7204 -LM_MSG(LM_7204_MSG, gettext("Library is currently performing an audit, " \ - "please retry LMPM $cmd$ command.")) - -#define LM_7205_MSG 7205 -LM_MSG(LM_7205_MSG, gettext("LMPM $cmd$ command failed, MMS does not have " \ - "permission to perform ACSLS command $acsls$.")) - -#define LM_7206_MSG 7206 -LM_MSG(LM_7206_MSG, gettext("Received a STATUS_LIBRARY_NOT_AVAILABLE from " \ - "ACSLS server, state of server is non-determinable, LM state being " \ - "switched to broken.")) - -#define LM_7207_MSG 7207 -LM_MSG(LM_7207_MSG, gettext("Internal problem with ACSLS server, received " \ - "a $status$ from server for ACSLS command $acsls$, LM state being " \ - "switched to broken.")) - -#define LM_7208_MSG 7208 -LM_MSG(LM_7208_MSG, gettext("LMPM $cmd$ command failed, ACSLS command " \ - "$acsls$ returned a status of $status$.")) - -#define LM_7209_MSG 7209 -LM_MSG(LM_7209_MSG, gettext("Library component failure, received a " \ - "STATUS_LIBRARY_FAILURE from ACSLS server for ACSLS command $acsls$.")) - -#define LM_7210_MSG 7210 -LM_MSG(LM_7210_MSG, gettext("Drive $drive$ is not accessible, drive state " \ - "is set to offline. Drive's ACSLS geometry is $geom$.")) - -#define LM_7211_MSG 7211 -LM_MSG(LM_7211_MSG, gettext("LSM $lsm$ is set to offline.")) - -#define LM_7212_MSG 7212 -LM_MSG(LM_7212_MSG, gettext("CAP $cap$ is busy, try again.")) - -#define LM_7213_MSG 7213 -LM_MSG(LM_7213_MSG, gettext("CAP $cap$ is set to automatic mode, cannot " \ - "enter cartridges manually through ACSLS command enter.")) - -#define LM_7214_MSG 7214 -LM_MSG(LM_7214_MSG, gettext("CAP $cap$ is set to offline, ACSLS command " \ - "$acsls$ cannot access CAP.")) - -#define LM_7215_MSG 7215 -LM_MSG(LM_7215_MSG, gettext("LMPM $cmd$ command failed, drive $drive$ " \ - "is empty. Cartridge $cart$ is marked as unusable.")) - -#define LM_7216_MSG 7216 -LM_MSG(LM_7216_MSG, gettext("LMPM $cmd$ command failed, ACS $acs$ is full.")) - -#define LM_7217_MSG 7217 -LM_MSG(LM_7217_MSG, - gettext("ACS $acs$ is not a valid ACS designation on ACSLS server.")) - -#define LM_7218_MSG 7218 -LM_MSG(LM_7218_MSG, - gettext("LSM $lsm$ is not a valid LSM designation on ACSLS server.")) - -#define LM_7219_MSG 7219 -LM_MSG(LM_7219_MSG, gettext("Drive $drive$ was not found in ACSLS library. " \ - "Drive's ACSLS geometry is $geom$.")) - -#define LM_7220_MSG 7220 -LM_MSG(LM_7220_MSG, gettext("Cartridge $cart$ was not found in drive, " \ - "drive $drive$ is empty. Drive's ACSLS geometry is $geom$.")) - -#define LM_7221_MSG 7221 -LM_MSG(LM_7221_MSG, gettext("Internal ACSLS communication problem on ACSLS " \ - "server, ACSLS command $acsls$ received a $status$ from server.")) - -#define LM_7222_MSG 7222 -LM_MSG(LM_7222_MSG, gettext("MMS does not have permission to perform ACSLS " \ - "command $acsls$, received a STATUS_COMMAND_ACCESS_DENIED from " \ - "ACSLS server.")) - -#define LM_7223_MSG 7223 -LM_MSG(LM_7223_MSG, gettext("Cartridge $wcart$ was actually unmounted from " \ - "drive $drive$, MMS expected cartridge $ecart$ to be in the drive.")) - -#define LM_7225_MSG 7225 -LM_MSG(LM_7225_MSG, gettext("LMPM $cmd$ command failed, Communication error " \ - "with ACSLS server, return status - $status$.")) - -#define LM_7226_MSG 7226 -LM_MSG(LM_7226_MSG, gettext("LMPM $cmd$ command failed, Communication error " \ - "response from ACSLS command $acsls$, return status - $status$.")) - -#define LM_7227_MSG 7227 -LM_MSG(LM_7227_MSG, gettext("LMPM $cmd$ command failed, Internal acsls " \ - "processing error, return status - $status$.")) - -#define LM_7228_MSG 7228 -LM_MSG(LM_7228_MSG, gettext("LMPM $cmd$ command failed, Internal ACSLS " \ - "processing error response from ACSLS command $acsls$, return " \ - "status - $status$.")) - -#define LM_7229_MSG 7229 -LM_MSG(LM_7229_MSG, gettext("LMPM $cmd$ command failed, Invalid ACSLS " \ - "status returned, return status - $status$.")) - -#define LM_7230_MSG 7230 -LM_MSG(LM_7230_MSG, gettext("LMPM $cmd$ command failed, Invalid ACSLS " \ - "response status from ACSLS command $acsls$, return " \ - "status - $status$.")) - -#define LM_7232_MSG 7232 -LM_MSG(LM_7232_MSG, gettext("LMPM $cmd$ command failed, ACSLS command " \ - "$acsls$ received a non-success response, return status - $status$.")) - -#define LM_7233_MSG 7233 -LM_MSG(LM_7233_MSG, gettext("LMPM $cmd$ command failed, ACSLS command " \ - "$acsls$ received an unexpected return type of $type$.")) - -#define LM_7234_MSG 7234 -LM_MSG(LM_7234_MSG, gettext("LMPM $cmd$ command failed, ACSLS command " \ - "$acsls$ received an unexpected state in acs_response(), " \ - "state is $state$.")) - -#define LM_7235_MSG 7235 -LM_MSG(LM_7235_MSG, gettext("$drive$ has a missing/incomplete drive " \ - "geometry, drive will be temporarily disabled, offline/online this " \ - "library and drive to clear the error state")) - -#ifdef __cplusplus -} -#endif - -#endif /* __MMS_LM_MSG_H */ diff --git a/usr/src/common/mms/mms/mms_mm_msg.h b/usr/src/common/mms/mms/mms_mm_msg.h deleted file mode 100644 index 37e95745e0..0000000000 --- a/usr/src/common/mms/mms/mms_mm_msg.h +++ /dev/null @@ -1,408 +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 __MMS_MM_MSG_H -#define __MMS_MM_MSG_H - - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef MM_MSG -#define MM_MSG(n, s) -#endif - -/* MM Operator Messages 1000-1100 */ - -#define MM_1000_MSG 1000 -MM_MSG(MM_1000_MSG, gettext("operator attended reply message, don't reuse")) - -#define MM_1001_MSG 1001 -MM_MSG(MM_1001_MSG, gettext("operator unattended reply message, don't reuse")) - - -/* MM Messages 5000-5999 */ - -#define MM_5000_MSG 5000 -MM_MSG(MM_5000_MSG, gettext("Parser error at line $line$, column $col$, " \ - "near token '$token$', error code $code$, $msg$")) - -#define MM_5001_MSG 5001 -MM_MSG(MM_5001_MSG, gettext("$msg$")) - -#define MM_5004_MSG 5004 -MM_MSG(MM_5004_MSG, gettext("No such CARTRIDGE.CartridgeID $cartid$.")) - -#define MM_5005_MSG 5005 -MM_MSG(MM_5005_MSG, gettext("No such CARTRIDGE.CartridgePCL $cartpcl$.")) - -#define MM_5006_MSG 5006 -MM_MSG(MM_5006_MSG, - gettext("CARTRIDGE.CartridgeID $cartid$ is a mount candidate.")) - -#define MM_5007_MSG 5007 -MM_MSG(MM_5007_MSG, gettext("Only one library is allowed for the eject " \ - "command. CARTRIDGE.CartridgeID $cartid1$ is in LIBRARY $lib1$ and " \ - "one or more cartridges are in LIBRARY $lib2$.")) - -#define MM_5008_MSG 5008 -MM_MSG(MM_5008_MSG, gettext("LIBRARY $lib$ doesn't have a configured LM.")) - -#define MM_5009_MSG 5009 -MM_MSG(MM_5009_MSG, gettext("LIBRARY $lib$ has more than one LM configured.")) - -#define MM_5010_MSG 5010 -MM_MSG(MM_5010_MSG, - gettext("SLOT not found for CARTRIDGE.CartridgeID $cartid$.")) - -#define MM_5011_MSG 5011 -MM_MSG(MM_5011_MSG, gettext("CARTRIDGE.CartridgeID $cartid$ not in SLOT.")) - -#define MM_5013_MSG 5013 -MM_MSG(MM_5013_MSG, gettext("Ready for client connections.")) - -#define MM_5018_MSG 5018 -MM_MSG(MM_5018_MSG, gettext("Error Mounting $cartridge$ in $drive$, " \ - "LM error message: $msg_rsp$")) - -#define MM_5019_MSG 5019 -MM_MSG(MM_5019_MSG, - gettext("No error message associated with this class/token")) - -#define MM_5021_MSG 5021 -MM_MSG(MM_5021_MSG, gettext("unrecoverable system error, $text$")) - -#define MM_5022_MSG 5022 -MM_MSG(MM_5022_MSG, gettext("Drive, $drive$ is temporarily disabled")) - -#define MM_5023_MSG 5023 -MM_MSG(MM_5023_MSG, gettext("Drive, $drive$ is permanently disabled")) - -#define MM_5024_MSG 5024 -MM_MSG(MM_5024_MSG, gettext("Drive, $drive$ is broken")) - -#define MM_5025_MSG 5025 -MM_MSG(MM_5025_MSG, gettext("Drive, $drive$ is not ready, try again later")) - -#define MM_5026_MSG 5026 -MM_MSG(MM_5026_MSG, - gettext("Drive, $drive$ is not accessible from the library")) - -#define MM_5027_MSG 5027 -MM_MSG(MM_5027_MSG, gettext("Application $app$ is not the exclusive app " \ - "for drive $drive$.")) - -#define MM_5028_MSG 5028 -MM_MSG(MM_5028_MSG, gettext("Drive $drive$ is loaded with non-MMS tape.")) - -#define MM_5029_MSG 5029 -MM_MSG(MM_5029_MSG, gettext("Drive $drive$ is offline.")) - -#define MM_5030_MSG 5030 -MM_MSG(MM_5030_MSG, - gettext("Application $app$ does not have access to drive $drive$.")) - -#define MM_5031_MSG 5031 -MM_MSG(MM_5031_MSG, - gettext("Drive $drive$ reported as not ready by DM $dm$.")) - -#define MM_5032_MSG 5032 -MM_MSG(MM_5032_MSG, - gettext("DM $dm$ for drive $drive$ is not connected to MM.")) - -#define MM_5033_MSG 5033 -MM_MSG(MM_5033_MSG, gettext("DM $dm$ for drive $drive$ is not connected.")) - -#define MM_5034_MSG 5034 -MM_MSG(MM_5034_MSG, - gettext("DM $dm$ for drive $drive$ is currently configuring.")) - -#define MM_5035_MSG 5035 -MM_MSG(MM_5035_MSG, gettext("DM $dm$ for drive $drive$ is not, " \ - "configured yet, DM may need to be activated.")) - -#define MM_5036_MSG 5036 -MM_MSG(MM_5036_MSG, gettext("DM $dm$ for drive $drive$ does not support the " \ - "accessmode contained in the accessmode clause.")) - -#define MM_5037_MSG 5037 -MM_MSG(MM_5037_MSG, gettext("Cartridge $cart$ has not been located in " \ - "the library, if this cartridge has been injected try cpscan.")) - -#define MM_5038_MSG 5038 -MM_MSG(MM_5038_MSG, gettext("Cartridge $cart$ is currently being used by " \ - "another client")) - -#define MM_5040_MSG 5040 -MM_MSG(MM_5040_MSG, gettext("Application $app$ does not have any volumes " \ - "allocated on cartridge $cart$.")) - -#define MM_5041_MSG 5041 -MM_MSG(MM_5041_MSG, gettext("Library $lib$ is currently offline.")) - -#define MM_5042_MSG 5042 -MM_MSG(MM_5042_MSG, gettext("Library $lib$ is temporarily disabled.")) - -#define MM_5043_MSG 5043 -MM_MSG(MM_5043_MSG, gettext("Library $lib$ is permanently disabled.")) - -#define MM_5044_MSG 5044 -MM_MSG(MM_5044_MSG, gettext("Library $lib$ is broken.")) - -#define MM_5045_MSG 5045 -MM_MSG(MM_5045_MSG, gettext("LM $lm$ reports the device state as not ready.")) - -#define MM_5046_MSG 5046 -MM_MSG(MM_5046_MSG, - gettext("LM $lm$ for library $lib$ is not connected to MM.")) - -#define MM_5047_MSG 5047 -MM_MSG(MM_5047_MSG, gettext("LM $lm$ for library $lib$ is not activated.")) - -#define MM_5048_MSG 5048 -MM_MSG(MM_5048_MSG, gettext("LM $lm$ is not connected to library $lib$.")) - -#define MM_5049_MSG 5049 -MM_MSG(MM_5049_MSG, - gettext("LM $lm$ for library $lib$ is currently configuring.")) - -#define MM_5050_MSG 5050 -MM_MSG(MM_5050_MSG, gettext("No DM configured on host $host$.")) - -#define MM_5051_MSG 5051 -MM_MSG(MM_5051_MSG, - gettext("Mount type must be one of: SIDE, PARTITION or VOLUME.")) - -#define MM_5052_MSG 5052 -MM_MSG(MM_5052_MSG, gettext("Could not find any candidate cartridges, " \ - "check match statement and application-cartridge access.")) - -#define MM_5053_MSG 5053 -MM_MSG(MM_5053_MSG, gettext("Error loading cartridge $cartridge$ in " \ - "drive $drive$, DM error message: $msg_rsp$")) - -#define MM_5054_MSG 5054 -MM_MSG(MM_5054_MSG, gettext("Error attaching to handle, cartridge " \ - "$cartridge$ in drive $drive$, DM error message: $msg_rsp$")) - -#define MM_5055_MSG 5055 -MM_MSG(MM_5055_MSG, gettext("Device manager communication error, " \ - "LM/DM error message: $msg_rsp$")) - -#define MM_5057_MSG 5057 -MM_MSG(MM_5057_MSG, gettext("Library command cannot have both an online " \ - "and offline clause.")) - -#define MM_5058_MSG 5058 -MM_MSG(MM_5058_MSG, gettext("No matching library exists.")) - -#define MM_5059_MSG 5059 -MM_MSG(MM_5059_MSG, gettext("Library $lib$ is already online.")) - -#define MM_5060_MSG 5060 -MM_MSG(MM_5060_MSG, gettext("No matching LM exists.")) - -#define MM_5061_MSG 5061 -MM_MSG(MM_5061_MSG, gettext("Library $lib$ is already offline.")) - -#define MM_5062_MSG 5062 -MM_MSG(MM_5062_MSG, gettext("Could not find clause/keyword in command.")) - -#define MM_5063_MSG 5063 -MM_MSG(MM_5063_MSG, gettext("No matching drive exists.")) - -#define MM_5064_MSG 5064 -MM_MSG(MM_5064_MSG, gettext("Drive $drive$ is already online.")) - -#define MM_5065_MSG 5065 -MM_MSG(MM_5065_MSG, gettext("Drive $drive$ has a cartridge mounted.")) - -#define MM_5066_MSG 5066 -MM_MSG(MM_5066_MSG, gettext("Drive $drive$ is already online.")) - -#define MM_5067_MSG 5067 -MM_MSG(MM_5067_MSG, gettext("Clause is missing a required argument, $text$")) - -#define MM_5068_MSG 5068 -MM_MSG(MM_5068_MSG, gettext("No matching cartridge found for eject.")) - -#define MM_5069_MSG 5069 -MM_MSG(MM_5069_MSG, gettext("No matching cartridge exists.")) - -#define MM_5070_MSG 5070 -MM_MSG(MM_5070_MSG, gettext("Too many matching cartridge found.")) - -#define MM_5071_MSG 5071 -MM_MSG(MM_5071_MSG, gettext("Couldn't find PCL $pcl$ in library.")) - -#define MM_5072_MSG 5072 -MM_MSG(MM_5072_MSG, gettext("No LM configured for library $lib$.")) - -#define MM_5073_MSG 5073 -MM_MSG(MM_5073_MSG, gettext("LM $lm$ is not in a ready state.")) - -#define MM_5074_MSG 5074 -MM_MSG(MM_5074_MSG, gettext("No DM configured.")) - -#define MM_5075_MSG 5075 -MM_MSG(MM_5075_MSG, gettext("No LM configured.")) - -#define MM_5076_MSG 5076 -MM_MSG(MM_5076_MSG, - gettext("Match statement matched more than one device manager.")) - -#define MM_5077_MSG 5077 -MM_MSG(MM_5077_MSG, gettext("DM $dm$ not connected to MM.")) - -#define MM_5078_MSG 5078 -MM_MSG(MM_5078_MSG, gettext("LM $lm$ not connected to MM.")) - -#define MM_5079_MSG 5079 -MM_MSG(MM_5079_MSG, gettext("Couldn't match any current device managers.")) - -#define MM_5080_MSG 5080 -MM_MSG(MM_5080_MSG, - gettext("Couldn't use match clause to find any configured LMs.")) - -#define MM_5082_MSG 5082 -MM_MSG(MM_5082_MSG, - gettext("Standard privilege client may not use the 'who' clause.")) - -#define MM_5083_MSG 5083 -MM_MSG(MM_5083_MSG, gettext("Syntax error found parsing the range clause.")) - -#define MM_5084_MSG 5084 -MM_MSG(MM_5084_MSG, gettext("Error counting new volumns in range.")) - -#define MM_5085_MSG 5085 -MM_MSG(MM_5085_MSG, gettext("Not enough partitions exist.")) - -#define MM_5086_MSG 5086 -MM_MSG(MM_5086_MSG, - gettext("Creation of PARTITION requires an existing CartridgePCL.")) - -#define MM_5087_MSG 5087 -MM_MSG(MM_5087_MSG, - gettext("Creation of PARTITION requires an existing LibraryName.")) - -#define MM_5088_MSG 5088 -MM_MSG(MM_5088_MSG, gettext("Client $client$ does not have cartridge " \ - "group access to PCL $pcl$.")) - -#define MM_5089_MSG 5089 -MM_MSG(MM_5089_MSG, gettext("Failed to change request state.")) - -#define MM_5090_MSG 5090 -MM_MSG(MM_5090_MSG, gettext("No matching task found.")) - -#define MM_5091_MSG 5091 -MM_MSG(MM_5091_MSG, gettext("More than one matching task found.")) - -#define MM_5092_MSG 5092 -MM_MSG(MM_5092_MSG, gettext("Match returned no results.")) - -#define MM_5093_MSG 5093 -MM_MSG(MM_5093_MSG, gettext("No matching request found.")) - -#define MM_5094_MSG 5094 -MM_MSG(MM_5094_MSG, gettext("No drives found for library $lib$.")) - -#define MM_5095_MSG 5095 -MM_MSG(MM_5095_MSG, gettext("No slot found for cartridge $cart$.")) - -#define MM_5096_MSG 5096 -MM_MSG(MM_5096_MSG, gettext("Drive $drive$ does not support the shape of " \ - "cartridge $cart$.")) - -#define MM_5097_MSG 5097 -MM_MSG(MM_5097_MSG, gettext("Drive does not support the cartridge type.")) - -#define MM_5098_MSG 5098 -MM_MSG(MM_5098_MSG, gettext("DM is still reserved, another client may be " \ - "writing to this tape with DM $dm$.")) - -#define MM_5099_MSG 5099 -MM_MSG(MM_5099_MSG, gettext("Failed to change $info$.")) - -#define MM_5100_MSG 5100 -MM_MSG(MM_5100_MSG, gettext("Client not connected.")) - -#define MM_5102_MSG 5102 -MM_MSG(MM_5102_MSG, - gettext("Drive $drive$ is currently unloading/loading, retry.")) - -#define MM_5103_MSG 5103 -MM_MSG(MM_5103_MSG, gettext("DM $dm$ does not support mount point.")) - -#define MM_5104_MSG 5104 -MM_MSG(MM_5104_MSG, gettext("Requested resources are temporarily unavailable.")) - -#define MM_5105_MSG 5105 -MM_MSG(MM_5105_MSG, gettext("No valid cartridge/library/drive found.")) - -#define MM_5106_MSG 5106 -MM_MSG(MM_5106_MSG, gettext("Old password does not match existing password.")) - -#define MM_5107_MSG 5107 -MM_MSG(MM_5107_MSG, - gettext("Unable to update hello command password file $file$.")) - -#define MM_5108_MSG 5108 -MM_MSG(MM_5108_MSG, gettext("Standard privilege client may not modify " \ - "object $object$ attribute $attribute$.")) - -#define MM_5109_MSG 5109 -MM_MSG(MM_5109_MSG, gettext("Administrator privilege client may not modify " \ - "object $object$ attribute $attribute$.")) - -#define MM_5110_MSG 5110 -MM_MSG(MM_5110_MSG, gettext("No solutions to this begin-end group, " \ - "one or more mounts cannot complete - $err_text$")) - -#define MM_5111_MSG 5111 -MM_MSG(MM_5111_MSG, gettext("The following libraries must be offline to be " \ - "deleted: $liblist$")) - -#define MM_5112_MSG 5112 -MM_MSG(MM_5112_MSG, gettext("Library delete failed, cartridge(s) exist that " \ - "are dependent on this library")) - -#define MM_5113_MSG 5113 -MM_MSG(MM_5113_MSG, gettext("Library delete failed, drive(s) exist that " \ - "are dependent on this library")) - -#define MM_5114_MSG 5114 -MM_MSG(MM_5114_MSG, gettext("Drive delete failed, drive(s) must be " \ - "offline to be deleted: $drvlist$")) - -#define MM_5115_MSG 5115 -MM_MSG(MM_5115_MSG, gettext("$objtype$: $objname$ delete failed, $objects$ " \ - "must be offline to be deleted: $objlist$")) - -#ifdef __cplusplus -} -#endif - -#endif /* __MMS_MM_MSG_H */ diff --git a/usr/src/common/mms/mms/mms_network.h b/usr/src/common/mms/mms/mms_network.h deleted file mode 100644 index ea71984f56..0000000000 --- a/usr/src/common/mms/mms/mms_network.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - -#ifndef _MMS_NETWORK_H_ -#define _MMS_NETWORK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <limits.h> -#include <netdb.h> -#include <mms_err.h> - -#define MMS_MMP_VERSION "1.0" -#define MMS_LMP_VERSION "1.0" -#define MMS_DMP_VERSION "1.0" -#define MMS_MMP_LANG "MMP"; -#define MMS_LMP_LANG "LMP"; -#define MMS_DMP_LANG "DMP"; - -typedef char mms_cli_host_t[MAXHOSTNAMELEN]; - -typedef struct mms_network_cfg mms_network_cfg_t; -struct mms_network_cfg { - char *cli_host; - char *cli_port; - char *cli_name; - char *cli_inst; - char *cli_lang; - char *cli_vers; - char *cli_pass; /* client hello command password */ - char *mm_pass; /* mm welcome response password */ - int ssl_enabled; /* ssl enabled */ - char *ssl_cert_file; /* cert, private key, cert chain */ - char *ssl_pass; /* private key password */ - char *ssl_pass_file; /* private key password file */ - char *ssl_crl_file; /* CRL file */ - char *ssl_cipher; /* SSL context cipher change */ - char *ssl_peer_file; /* client mm cert file */ -}; - -#define MMS_SERVICE "7151" /* default mms service port */ -#define MMS_BACKLOG 1024 /* socket listen backlog */ -#define MMS_EBUF_LEN 300 /* mms socket error string length, */ - /* must be 120 bytes min for ssl */ -#define MMS_SOCK_HDR_SIZE 16 /* socket message header size */ -#define MMS_MSG_MAGIC "SUNW-MMS" -#define MMS_MSG_MAGIC_LEN 8 - -typedef struct mms mms_t; -struct mms { /* socket connection */ - int mms_fd; /* socket file descriptor */ - mms_err_t mms_err; /* error information */ - void *mms_ssl; /* secure socket layer */ -}; - -#ifdef MMS_OPENSSL -int mms_ssl_client(mms_network_cfg_t *net, void **ssl_data, mms_err_t *err); -void mms_ssl_finish(void *ssl_data); -#define MMS_SSL -#else -#undef MMS_SSL -#endif /* MMS_OPENSSL */ - -int mms_connect(char *host, char *service, void *ssl_data, mms_t *cli_conn); -int mms_reader(mms_t *conn, char **buf); -int mms_writer(mms_t *conn, char *buf); -void mms_close(mms_t *conn); -int mms_net_cfg_read(mms_network_cfg_t *net, char *cfgfn); -void mms_net_cfg_free(mms_network_cfg_t *net); -int mms_mmconnect(mms_network_cfg_t *net, - void *ssl_data, - mms_t *conn, - int *err_code, - char *tag); -int mms_mmdisconnect(mms_t *conn); - -#ifdef __cplusplus -} -#endif - -#endif /* _MMS_NETWORK_H_ */ diff --git a/usr/src/common/mms/mms/mms_parser.h b/usr/src/common/mms/mms/mms_parser.h deleted file mode 100644 index 8fe852a541..0000000000 --- a/usr/src/common/mms/mms/mms_parser.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - -#ifndef _MMS_PARSER_H_ -#define _MMS_PARSER_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <mms_list.h> - -enum mms_pn_type { - MMS_PN_NONE = 0x0001, - MMS_PN_CMD = 0x0002, - MMS_PN_CLAUSE = 0x0004, - MMS_PN_OPS = 0x0008, - MMS_PN_OBJ = 0x0010, - MMS_PN_ATTR = 0x0020, - MMS_PN_STRING = 0x0040, - MMS_PN_KEYWORD = 0x0080, - MMS_PN_NUMERIC = 0x0100, - MMS_PN_RANGE = 0x0200, - MMS_PN_NULLSTR = 0x0400, - MMS_PN_CONFIG = 0x1000, - MMS_PN_SECTION = 0x2000, - MMS_PN_OPTION = 0x4000, - MMS_PN_MSGCAT = 0x8000, - MMS_PN_LIST = 0x010000, - MMS_PN_REGEX = 0x020000 -}; - -typedef struct mms_par_node { - mms_list_node_t pn_next; /* doubly linked list */ - mms_list_node_t pn_memnext; - int pn_flags; - mms_list_t pn_arglist; /* list of args of this node */ - mms_list_t pn_attrlist; /* Used by msg_parse only */ - mms_list_t pn_memlist; /* mem list, used by CMD only */ - uint64_t pn_type; - int pn_seq; - char *pn_string; - struct mms_par_node *pn_nonterm; /* Only used in yparse* */ - struct mms_par_node *pn_list; /* list this node is on */ -} mms_par_node_t; - -#define MMS_PN_MULTIOPS 0x01 -#define MMS_PN_UNARYOPS 0x02 -#define MMS_PN_ATTR_LIST 0x04 /* in attr list */ -#define MMS_PN_ARG_LIST 0x08 /* in arg list */ - -typedef struct mms_par_err { - mms_list_node_t pe_next; - int pe_code; - int pe_line; - int pe_col; - char *pe_token; - char *pe_msg; -} mms_par_err_t; - -#define MMS_PE_NOMEM 1 -#define MMS_PE_SYNTAX 2 -#define MMS_PE_MAX_LEVEL 3 -#define MMS_PE_INVAL_CALLBACK 4 -#define MMS_PE_USERABORT 5 - -#define mms_pn_token(node) (node->pn_string) - -#define mms_pn_type(node) (node->pn_type) - -#define MMS_PN_LOOKUP(result, node, str, type, work) { \ - result = mms_pn_lookup(node, str, type, work); \ - if (result == NULL) \ - goto not_found; \ - } - - -typedef void (*par_input_func)(char *, int *, int, void *); - -char *mms_par_text_sub(char *template, char *arg, char *text); -char *mms_pn_build_cmd_xml(mms_par_node_t *cmd); -int mms_pn_len_xml(mms_par_node_t *node, int level); -int mms_pn_cmd_len_xml(mms_par_node_t *top); -char *mms_pn_build_cmd_text(mms_par_node_t *top); -int mms_pn_build_cmd_text_aux(mms_par_node_t *top, char *buf, int len); -int mms_pn_cmd_len_text(mms_par_node_t *top); -int mms_pn_len_text(mms_par_node_t *node); -void mms_pe_destroy(mms_list_t *err); -void mms_pe_msg(char *); -void mms_pn_destroy(mms_par_node_t *node); -void mms_par_input(char *buf, int *result, int max, void *data); - -mms_par_node_t *mms_pn_lookup(mms_par_node_t *top, char *str, int type, - mms_par_node_t **prev); -mms_par_node_t *mms_pn_lookup_arg(mms_par_node_t *top, char *str, int type, - mms_par_node_t **prev); -void mms_pn_fini(mms_par_node_t *node); - - -int mms_mmp_parse(mms_par_node_t **cmd_node, - mms_list_t *msg_list, - char *buf); - -int mms_dmpm_parse(mms_par_node_t **cmd_node, - mms_list_t *msg_list, - char *buf); - -int mms_dmpd_parse(mms_par_node_t **cmd_node, - mms_list_t *msg_list, - char *buf); - -int mms_lmpm_parse(mms_par_node_t **cmd_node, - mms_list_t *msg_list, - char *buf); - -int mms_lmpl_parse(mms_par_node_t **cmd_node, - mms_list_t *msg_list, - char *buf); - -int mms_config_parse(mms_par_node_t **cmd_node, - mms_list_t *msg_list, - char *buf); - -void mms_mmsp_scan_string(char *); -void mms_mmsp_delete_buffer(); -void mms_mmsp_allow_quote(); - -void mms_cfg_scan_string(char *); -void mms_cfg_delete_buffer(); - -#ifdef __cplusplus -} -#endif - -#endif /* _MMS_PARSER_H_ */ diff --git a/usr/src/common/mms/mms/mms_strapp.h b/usr/src/common/mms/mms/mms_strapp.h deleted file mode 100644 index aec18d0e21..0000000000 --- a/usr/src/common/mms/mms/mms_strapp.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 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - -#ifndef _STRAPP_H_ -#define _STRAPP_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdarg.h> - -extern char *mms_strpar_undo_escape_sequence(char *); -extern char *mms_strpar_escape_sequence(char *); -extern char *mms_strnew(const char *, ...); -extern char *mms_strapp(char *, const char *, ...); -extern char *mms_vstrapp(char *, const char *, va_list); -extern char *mms_strnapp(char *str, int n, char *str2); - -#ifdef __cplusplus -} -#endif - -#endif /* _STRAPP_H_ */ diff --git a/usr/src/common/mms/mms/mms_sym.h b/usr/src/common/mms/mms/mms_sym.h deleted file mode 100644 index 8207dd924a..0000000000 --- a/usr/src/common/mms/mms/mms_sym.h +++ /dev/null @@ -1,479 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - -#ifndef _MMS_SYM_H_ -#define _MMS_SYM_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct mms_sym { - char *sym_token; - int sym_code; -} mms_sym_t; - -/* - * These are Numeric Error codes - * MMS error codes are biased by MMS_ERR_BIAS to avoid conflicting with - * error codes. - */ - -/* - * If you add a new error code, you must also update the error code table - * in mms_sym.c. - */ - - -#define MMS_ERR_BIAS 0x00ff0000 - -/* - * The following are error codes added by MMS for client API - */ - -/* - * The following are class codes - */ -#define MMS_COMPAT (MMS_ERR_BIAS + 1) -#define MMS_CONFIG (MMS_ERR_BIAS + 2) -#define MMS_EXIST (MMS_ERR_BIAS + 3) -#define MMS_EXPLICIT (MMS_ERR_BIAS + 4) -#define MMS_INTERNAL (MMS_ERR_BIAS + 5) -#define MMS_INVALID (MMS_ERR_BIAS + 6) -#define MMS_PERMPRIV (MMS_ERR_BIAS + 7) -#define MMS_RETRY (MMS_ERR_BIAS + 8) -#define MMS_SUBOP (MMS_ERR_BIAS + 9) -#define MMS_LANGUAGE (MMS_ERR_BIAS + 10) -#define MMS_STATE (MMS_ERR_BIAS + 11) -#define MMS_DM_C_INVALID (MMS_ERR_BIAS + 12) -#define MMS_DM_C_COMMAND (MMS_ERR_BIAS + 13) -#define MMS_LM_C_INVALID (MMS_ERR_BIAS + 14) -#define MMS_LM_C_COMMAND (MMS_ERR_BIAS + 15) -#define MMS_MM_C_INVALID (MMS_ERR_BIAS + 16) -#define MMS_MM_C_MANAGEMENT (MMS_ERR_BIAS + 17) - -/* - * The following are error codes - */ -#define MMS_UNKNOWN_CODE (MMS_ERR_BIAS + 50) - -#define MMS_E_NET_IO_ERR (MMS_ERR_BIAS + 51) -#define MMS_E_SYNTAX_ERR (MMS_ERR_BIAS + 52) -#define MMS_E_INVALID_RESPONSE (MMS_ERR_BIAS + 53) -#define MMS_E_UNKNOWN_ERR_STRING (MMS_ERR_BIAS + 54) -#define MMS_E_OUTOFMEMORY (MMS_ERR_BIAS + 55) -#define MMS_E_CONNECT_ERR (MMS_ERR_BIAS + 56) - -#define MMS_MALLOC_ERROR (MMS_ERR_BIAS + 57) -#define MMS_SELECT_ERROR (MMS_ERR_BIAS + 58) -#define MMS_UNACCEPTABLE_RSP (MMS_ERR_BIAS + 59) -#define MMS_INVALID_RSP (MMS_ERR_BIAS + 60) -#define MMS_INVALID_RSP_CODE (MMS_ERR_BIAS + 61) -#define MMS_MISSING_TASKID (MMS_ERR_BIAS + 62) -#define MMS_WRONG_TASKID (MMS_ERR_BIAS + 63) - -#define MMS_TRACE_FAILURE (MMS_ERR_BIAS + 64) -#define MMS_WRONG_API_MODE (MMS_ERR_BIAS + 65) -#define MMS_ASYNC_API_FAILURE (MMS_ERR_BIAS + 66) -#define MMS_API_ERR (MMS_ERR_BIAS + 67) -#define MMS_API_NOT_ERR_RSP (MMS_ERR_BIAS + 68) -#define MMS_CFG_FILE_ERR (MMS_ERR_BIAS + 69) -#define MMS_DUPLICATE_REG (MMS_ERR_BIAS + 70) -#define MMS_EV_REG_FAILED (MMS_ERR_BIAS + 71) -#define MMS_EV_UNREG_FAILED (MMS_ERR_BIAS + 72) -#define MMS_API_SHUTDOWN (MMS_ERR_BIAS + 73) -#define MMS_INVALID_REQ (MMS_ERR_BIAS + 74) - -#define MMS_E_SSL_CERT_CLAUSE (MMS_ERR_BIAS + 75) -#define MMS_E_WELCOME_PASSWORD (MMS_ERR_BIAS + 76) -#define MMS_E_NO_WELCOME_PASSWORD (MMS_ERR_BIAS + 77) -#define MMS_E_SSL_VERIFY (MMS_ERR_BIAS + 78) - -/* - * The following are error codes defined in the MMS spec. - */ -#define MMS_DM_E_AGAIN (MMS_ERR_BIAS + 503) -#define MMS_DM_E_BADHANDLE (MMS_ERR_BIAS + 504) -#define MMS_DM_E_BADVAL (MMS_ERR_BIAS + 505) -#define MMS_DM_E_CMDARGS (MMS_ERR_BIAS + 506) -#define MMS_DM_E_DEVADMINCLT (MMS_ERR_BIAS + 507) -#define MMS_DM_E_DEVCMD (MMS_ERR_BIAS + 508) -#define MMS_DM_E_DEVCMDABORT (MMS_ERR_BIAS + 509) -#define MMS_DM_E_DEVCMDILLEGAL (MMS_ERR_BIAS + 510) -#define MMS_DM_E_DEVCMDTEMEOUT (MMS_ERR_BIAS + 511) -#define MMS_DM_E_DEVCOMMERR (MMS_ERR_BIAS + 512) -#define MMS_DM_E_DEVDET (MMS_ERR_BIAS + 513) -#define MMS_DM_E_DEVEMPTY (MMS_ERR_BIAS + 514) -#define MMS_DM_E_DEVFULL (MMS_ERR_BIAS + 515) -#define MMS_DM_E_DEVNORESPONSE (MMS_ERR_BIAS + 516) -#define MMS_DM_E_DEVOPERATOR (MMS_ERR_BIAS + 517) -#define MMS_DM_E_DEVOVERFLOW (MMS_ERR_BIAS + 518) -#define MMS_DM_E_DEVPERM (MMS_ERR_BIAS + 519) -#define MMS_DM_E_DEVPREV (MMS_ERR_BIAS + 520) -#define MMS_DM_E_DEVRESET (MMS_ERR_BIAS + 521) -#define MMS_DM_E_DEVSYNCHERR (MMS_ERR_BIAS + 522) -#define MMS_DM_E_DRIVE (MMS_ERR_BIAS + 523) -#define MMS_DM_E_HANDLEBUSY (MMS_ERR_BIAS + 524) -#define MMS_DM_E_HANDLEINUSE (MMS_ERR_BIAS + 525) -#define MMS_DM_E_INTERNAL (MMS_ERR_BIAS + 526) -#define MMS_DM_E_LIBRARY (MMS_ERR_BIAS + 527) -#define MMS_DM_E_MODE (MMS_ERR_BIAS + 528) -#define MMS_DM_E_NOCANC (MMS_ERR_BIAS + 529) -#define MMS_DM_E_NOCART (MMS_ERR_BIAS + 530) -#define MMS_DM_E_NOELT (MMS_ERR_BIAS + 531) -#define MMS_DM_E_NOEXISTHANDLE (MMS_ERR_BIAS + 532) -#define MMS_DM_E_NOID (MMS_ERR_BIAS + 533) -#define MMS_DM_E_NOTASK (MMS_ERR_BIAS + 534) -#define MMS_DM_E_READY (MMS_ERR_BIAS + 535) -#define MMS_DM_E_UNKNOWN (MMS_ERR_BIAS + 536) -#define MMS_EACCHANDLESTILLINUSE (MMS_ERR_BIAS + 537) -#define MMS_EAPPACCESSTOCART (MMS_ERR_BIAS + 538) -#define MMS_EAPPCARTNOACC (MMS_ERR_BIAS + 539) -#define MMS_EAPPDMDIFFHOSTS (MMS_ERR_BIAS + 540) -#define MMS_EAPPDRVNOACC (MMS_ERR_BIAS + 541) -#define MMS_EAPPHASNOVOLS (MMS_ERR_BIAS + 542) -#define MMS_EAPPLIBNOACCESS (MMS_ERR_BIAS + 543) -#define MMS_EAPPMOUNTNOTIUSSUED (MMS_ERR_BIAS + 544) -#define MMS_EAPPSESS (MMS_ERR_BIAS + 545) -#define MMS_EAPPTASKNOTISSUED (MMS_ERR_BIAS + 546) -#define MMS_EAUTOCREATEFAILED (MMS_ERR_BIAS + 547) -#define MMS_ECANCELLED (MMS_ERR_BIAS + 548) -#define MMS_ECANCELNUMRANGEDISALLOWED (MMS_ERR_BIAS + 549) -#define MMS_ECANTCANCEL (MMS_ERR_BIAS + 550) -#define MMS_ECARTDRVNOTCOMPATIBLE (MMS_ERR_BIAS + 551) -#define MMS_ECARTDRVSLOTMISMATCH (MMS_ERR_BIAS + 552) -#define MMS_ECARTINSLOT (MMS_ERR_BIAS + 553) -#define MMS_ECARTINUSE (MMS_ERR_BIAS + 554) -#define MMS_ECARTMOUNTNOTINVOLVED (MMS_ERR_BIAS + 555) -#define MMS_ECARTNOACC (MMS_ERR_BIAS + 556) -#define MMS_ECARTNOCGA (MMS_ERR_BIAS + 557) -#define MMS_ECARTNOFREEPARTS (MMS_ERR_BIAS + 558) -#define MMS_ECARTNOTINSLOT (MMS_ERR_BIAS + 559) -#define MMS_ECARTNOTLOCATED (MMS_ERR_BIAS + 560) -#define MMS_ECARTNOTOWNEDBYAP (MMS_ERR_BIAS + 561) -#define MMS_ECARTNOTOWNEDBYAPP (MMS_ERR_BIAS + 562) -#define MMS_ECLAUSEMISSING (MMS_ERR_BIAS + 563) -#define MMS_ECLAUSEMUTEX (MMS_ERR_BIAS + 564) -#define MMS_ECLAUSENEEDSARG (MMS_ERR_BIAS + 565) -#define MMS_ECLAUSENOPRIVILEGE (MMS_ERR_BIAS + 566) -#define MMS_ECOMMANDBEINGSUBMITTED (MMS_ERR_BIAS + 567) -#define MMS_ECOMMANDFAILED (MMS_ERR_BIAS + 568) -#define MMS_ECOMMANDNOPRIVILEGE (MMS_ERR_BIAS + 569) -#define MMS_ECONNDELETE (MMS_ERR_BIAS + 570) -#define MMS_EDMCONFIG (MMS_ERR_BIAS + 571) -#define MMS_EDMNOTCONNECTED (MMS_ERR_BIAS + 572) -#define MMS_EDMNOTREADY (MMS_ERR_BIAS + 573) -#define MMS_EDMPATTACH (MMS_ERR_BIAS + 574) -#define MMS_EDMPDETACH (MMS_ERR_BIAS + 575) -#define MMS_EDMPLOAD (MMS_ERR_BIAS + 576) -#define MMS_EDMPUNLOAD (MMS_ERR_BIAS + 577) -#define MMS_EDMRECOVERING (MMS_ERR_BIAS + 578) -#define MMS_EDMSTATE (MMS_ERR_BIAS + 579) -#define MMS_EDMSTILLBOOTING (MMS_ERR_BIAS + 580) -#define MMS_EDRIVEEMPTY (MMS_ERR_BIAS + 581) -#define MMS_EDRIVESET (MMS_ERR_BIAS + 582) -#define MMS_EDRVBROKEN (MMS_ERR_BIAS + 583) -#define MMS_EDRVCARTNOTREADABLE (MMS_ERR_BIAS + 584) -#define MMS_EDRVDISABLEDPERM (MMS_ERR_BIAS + 585) -#define MMS_EDRVDISABLEDTEMP (MMS_ERR_BIAS + 586) -#define MMS_EDRVEJECTING (MMS_ERR_BIAS + 587) -#define MMS_EDRVINUSE (MMS_ERR_BIAS + 588) -#define MMS_EDRVLOADED (MMS_ERR_BIAS + 589) -#define MMS_EDRVMOUNTNOTINVOLVED (MMS_ERR_BIAS + 590) -#define MMS_EDRVNODMCONFIGURED (MMS_ERR_BIAS + 591) -#define MMS_EDRVNOTINBAY (MMS_ERR_BIAS + 592) -#define MMS_EDRVNOTLOADED (MMS_ERR_BIAS + 593) -#define MMS_EDRVSESSNOUSE (MMS_ERR_BIAS + 594) -#define MMS_EDRVTASKNOTREQUIRED (MMS_ERR_BIAS + 595) -#define MMS_EDRVUNKNOWN (MMS_ERR_BIAS + 596) -#define MMS_EHANDLEINUSE (MMS_ERR_BIAS + 597) -#define MMS_EHANDLENOTDESTROY (MMS_ERR_BIAS + 598) -#define MMS_EINVALCLAUSEARG (MMS_ERR_BIAS + 599) -#define MMS_ELANGNOTSUPPORTED (MMS_ERR_BIAS + 600) -#define MMS_ELIBBROKEN (MMS_ERR_BIAS + 601) -#define MMS_ELIBCARTNOCONTAINMENT (MMS_ERR_BIAS + 602) -#define MMS_ELIBDISABLEDPERM (MMS_ERR_BIAS + 603) -#define MMS_ELIBDISABLEDTEMP (MMS_ERR_BIAS + 604) -#define MMS_ELIBDRVNOCONTAINMENT (MMS_ERR_BIAS + 605) -#define MMS_ELIBINUSE (MMS_ERR_BIAS + 606) -#define MMS_ELIBNOLMCONFIGURED (MMS_ERR_BIAS + 607) -#define MMS_ELMADD (MMS_ERR_BIAS + 608) -#define MMS_ELMCARTBAYNOTACCESS (MMS_ERR_BIAS + 609) -#define MMS_ELMCONFIG (MMS_ERR_BIAS + 610) -#define MMS_ELMDMCOMMUNICATION (MMS_ERR_BIAS + 611) -#define MMS_ELMDRVBAYNOTACCESS (MMS_ERR_BIAS + 612) -#define MMS_ELMDRVNOTACCESS (MMS_ERR_BIAS + 613) -#define MMS_ELMNOTCONNECTED (MMS_ERR_BIAS + 614) -#define MMS_ELMNOTREADY (MMS_ERR_BIAS + 615) -#define MMS_ELMPMOUNT (MMS_ERR_BIAS + 616) -#define MMS_ELMPORTNOTREADY (MMS_ERR_BIAS + 617) -#define MMS_ELMPUNMOUNT (MMS_ERR_BIAS + 618) -#define MMS_ELMSLOTNOTACCESS (MMS_ERR_BIAS + 619) -#define MMS_ELMSTATE (MMS_ERR_BIAS + 620) -#define MMS_ELMSTILLBOOTING (MMS_ERR_BIAS + 621) -#define MMS_EMLOGCREATE (MMS_ERR_BIAS + 622) -#define MMS_EMLOGDELETE (MMS_ERR_BIAS + 623) -#define MMS_EMNTCARTPRES (MMS_ERR_BIAS + 624) -#define MMS_EMOUNTLIBNOTINVOLVED (MMS_ERR_BIAS + 625) -#define MMS_EMPCREATE (MMS_ERR_BIAS + 626) -#define MMS_EMPHYSDEL (MMS_ERR_BIAS + 627) -#define MMS_ENEWVOLEXISTS (MMS_ERR_BIAS + 628) -#define MMS_ENEWVOLNAMECOUNT (MMS_ERR_BIAS + 629) -#define MMS_ENOALLOCATABLEPARTS (MMS_ERR_BIAS + 630) -#define MMS_ENOCANCELLABLETASKS (MMS_ERR_BIAS + 631) -#define MMS_ENOCARTRIDGE (MMS_ERR_BIAS + 632) -#define MMS_ENOINSTANCE (MMS_ERR_BIAS + 633) -#define MMS_ENOMATCH (MMS_ERR_BIAS + 634) -#define MMS_ENOMEMORY (MMS_ERR_BIAS + 635) -#define MMS_ENOPRIVCHANGE (MMS_ERR_BIAS + 636) -#define MMS_ENOSESSION (MMS_ERR_BIAS + 637) -#define MMS_ENOSLOT (MMS_ERR_BIAS + 638) -#define MMS_ENOSOLUTIONS (MMS_ERR_BIAS + 639) -#define MMS_ENOSUCHCART (MMS_ERR_BIAS + 640) -#define MMS_ENOSUCHLANG (MMS_ERR_BIAS + 641) -#define MMS_ENOSUCHPRIV (MMS_ERR_BIAS + 642) -#define MMS_ENOSUCHREQ (MMS_ERR_BIAS + 643) -#define MMS_ENOSUCHSIDE (MMS_ERR_BIAS + 644) -#define MMS_ENOSUCHSORT (MMS_ERR_BIAS + 645) -#define MMS_ENOSUCHVOLUME (MMS_ERR_BIAS + 646) -#define MMS_EOBJATTRMODDISALLOWED (MMS_ERR_BIAS + 647) -#define MMS_EOBJATTRTOOMANY (MMS_ERR_BIAS + 648) -#define MMS_EOBJATTRVALNOTENUM (MMS_ERR_BIAS + 649) -#define MMS_EOBJATTRVALNOTNUM (MMS_ERR_BIAS + 650) -#define MMS_EOBJATTRVALNULLSTRING (MMS_ERR_BIAS + 651) -#define MMS_EOBJCREATEDISALLOWED (MMS_ERR_BIAS + 652) -#define MMS_EOBJCREATEINVALREPORT (MMS_ERR_BIAS + 653) -#define MMS_EOBJCREATESYSATTRREQUIRED (MMS_ERR_BIAS + 654) -#define MMS_EOBJDELDISALLOWED (MMS_ERR_BIAS + 655) -#define MMS_EOBJDELNUMRANGEDISALLOWED (MMS_ERR_BIAS + 656) -#define MMS_EOBJDEPENDNOEXIST (MMS_ERR_BIAS + 657) -#define MMS_EOBJKEYCHANGE (MMS_ERR_BIAS + 658) -#define MMS_EOBJKEYNOTUNIQUE (MMS_ERR_BIAS + 659) -#define MMS_EOBJNOTVISIBLE (MMS_ERR_BIAS + 660) -#define MMS_EOBJREFERENCES (MMS_ERR_BIAS + 661) -#define MMS_EOBJSYSATTRCREATEDISALLOWED (MMS_ERR_BIAS + 662) -#define MMS_EOBJSYSATTRMODDISALLOWED (MMS_ERR_BIAS + 663) -#define MMS_EOBJSYSATTRMODNOPRIV (MMS_ERR_BIAS + 664) -#define MMS_EOBJUSRATTRCREATEDISALLOWED (MMS_ERR_BIAS + 665) -#define MMS_EOBJUSRATTRCREATENOPRIV (MMS_ERR_BIAS + 666) -#define MMS_EPARTNOTALLOCABLE (MMS_ERR_BIAS + 667) -#define MMS_EPRIVCHANGEDISALLOWED (MMS_ERR_BIAS + 668) -#define MMS_ERENAMEDVOLEXISTS (MMS_ERR_BIAS + 669) -#define MMS_EREPLACEFAILED (MMS_ERR_BIAS + 670) -#define MMS_EREQACCEPTEDBYDIFFSESS (MMS_ERR_BIAS + 671) -#define MMS_EREQSTATECHANGEFAILED (MMS_ERR_BIAS + 672) -#define MMS_EREQUESTALREADYACCEPTED (MMS_ERR_BIAS + 673) -#define MMS_EREQUESTALREADYSATISFIED (MMS_ERR_BIAS + 674) -#define MMS_EREQUESTNOTACCEPTED (MMS_ERR_BIAS + 675) -#define MMS_ESESSCARTNOTUSED (MMS_ERR_BIAS + 676) -#define MMS_ESESSLIBNOTUSED (MMS_ERR_BIAS + 677) -#define MMS_ESESSMNTNOTISSUED (MMS_ERR_BIAS + 678) -#define MMS_ESESSTASKNOISSUED (MMS_ERR_BIAS + 679) -#define MMS_ESHUTDOWNFAILED (MMS_ERR_BIAS + 680) -#define MMS_ESLOTNOTOCCUPIED (MMS_ERR_BIAS + 681) -#define MMS_ESLOTOCCUPIED (MMS_ERR_BIAS + 682) -#define MMS_ESORTNOTSUPPORTED (MMS_ERR_BIAS + 683) -#define MMS_ESYSATTRUNSETDISALLOWED (MMS_ERR_BIAS + 684) -#define MMS_ESYSTEM (MMS_ERR_BIAS + 685) -#define MMS_ETABLELIMIT (MMS_ERR_BIAS + 686) -#define MMS_ETASKCARTNOUSE (MMS_ERR_BIAS + 687) -#define MMS_ETASKLIBNOUSE (MMS_ERR_BIAS + 688) -#define MMS_ETASKMNTNOUSE (MMS_ERR_BIAS + 689) -#define MMS_ETMPUNAVAIL (MMS_ERR_BIAS + 690) -#define MMS_ETOOMANY (MMS_ERR_BIAS + 691) -#define MMS_ETOOMANYCLAUSES (MMS_ERR_BIAS + 692) -#define MMS_ETRANSACTIONFAILED (MMS_ERR_BIAS + 693) -#define MMS_EUNKNOWNERROR (MMS_ERR_BIAS + 694) -#define MMS_EVOLEXISTS (MMS_ERR_BIAS + 695) -#define MMS_EVOLINUSE (MMS_ERR_BIAS + 696) -#define MMS_EVOLNAMEREWRITE (MMS_ERR_BIAS + 697) -#define MMS_EVOLNOTOWNEDBYAPP (MMS_ERR_BIAS + 698) -#define MMS_EWOULDDEADLOCK (MMS_ERR_BIAS + 699) -#define MMS_LM_E_ACCESS (MMS_ERR_BIAS + 702) -#define MMS_LM_E_AGAIN (MMS_ERR_BIAS + 703) -#define MMS_LM_E_BADVAL (MMS_ERR_BIAS + 704) -#define MMS_LM_E_CMDARGS (MMS_ERR_BIAS + 705) -#define MMS_LM_E_DESTFULL (MMS_ERR_BIAS + 706) -#define MMS_LM_E_DEVADMINCLT (MMS_ERR_BIAS + 707) -#define MMS_LM_E_DEVCMD (MMS_ERR_BIAS + 708) -#define MMS_LM_E_DEVCMDABORT (MMS_ERR_BIAS + 709) -#define MMS_LM_E_DEVCMDILLEGAL (MMS_ERR_BIAS + 710) -#define MMS_LM_E_DEVCMDTEMEOUT (MMS_ERR_BIAS + 711) -#define MMS_LM_E_DEVCOMMERR (MMS_ERR_BIAS + 712) -#define MMS_LM_E_DEVEJ (MMS_ERR_BIAS + 713) -#define MMS_LM_E_DEVINJ (MMS_ERR_BIAS + 714) -#define MMS_LM_E_DEVNORESPONSE (MMS_ERR_BIAS + 715) -#define MMS_LM_E_DEVOPERATOR (MMS_ERR_BIAS + 716) -#define MMS_LM_E_DEVOVERFLOW (MMS_ERR_BIAS + 717) -#define MMS_LM_E_DEVPREM (MMS_ERR_BIAS + 718) -#define MMS_LM_E_DEVPREV (MMS_ERR_BIAS + 719) -#define MMS_LM_E_DEVRESET (MMS_ERR_BIAS + 720) -#define MMS_LM_E_DEVSYNCHERR (MMS_ERR_BIAS + 721) -#define MMS_LM_E_DIRECTION (MMS_ERR_BIAS + 722) -#define MMS_LM_E_INTERNAL (MMS_ERR_BIAS + 723) -#define MMS_LM_E_LIBRARY (MMS_ERR_BIAS + 724) -#define MMS_LM_E_MOVE (MMS_ERR_BIAS + 725) -#define MMS_LM_E_NOCANC (MMS_ERR_BIAS + 726) -#define MMS_LM_E_NODRIVE (MMS_ERR_BIAS + 727) -#define MMS_LM_E_NOELT (MMS_ERR_BIAS + 728) -#define MMS_LM_E_NOPCL (MMS_ERR_BIAS + 729) -#define MMS_LM_E_NOSLOT (MMS_ERR_BIAS + 730) -#define MMS_LM_E_NOTASK (MMS_ERR_BIAS + 731) -#define MMS_LM_E_PCL (MMS_ERR_BIAS + 732) -#define MMS_LM_E_PORT (MMS_ERR_BIAS + 733) -#define MMS_LM_E_PORTDIR (MMS_ERR_BIAS + 734) -#define MMS_LM_E_READY (MMS_ERR_BIAS + 735) -#define MMS_LM_E_SCREMPTY (MMS_ERR_BIAS + 736) -#define MMS_LM_E_SHAPE (MMS_ERR_BIAS + 737) -#define MMS_LM_E_SLOTGROUP (MMS_ERR_BIAS + 738) -#define MMS_LM_E_UNKNOWN (MMS_ERR_BIAS + 739) -#define MMS_MM_E_AGAIN (MMS_ERR_BIAS + 742) -#define MMS_MM_E_BADVAL (MMS_ERR_BIAS + 743) -#define MMS_MM_E_CMDARGS (MMS_ERR_BIAS + 744) -#define MMS_MM_E_DEVCMD (MMS_ERR_BIAS + 745) -#define MMS_MM_E_DEVCMDABORT (MMS_ERR_BIAS + 746) -#define MMS_MM_E_DEVCMDILLEGAL (MMS_ERR_BIAS + 747) -#define MMS_MM_E_DEVCMDTEMEOUT (MMS_ERR_BIAS + 748) -#define MMS_MM_E_DEVOVERFLOW (MMS_ERR_BIAS + 749) -#define MMS_MM_E_DEVPREM (MMS_ERR_BIAS + 750) -#define MMS_MM_E_DEVPREV (MMS_ERR_BIAS + 751) -#define MMS_MM_E_INTERNAL (MMS_ERR_BIAS + 752) -#define MMS_MM_E_NOELT (MMS_ERR_BIAS + 753) -#define MMS_SSAI_E_PROTOCOL_ERROR (MMS_ERR_BIAS + 754) -#define MMS_SSAI_E_ACCESS_DENIED (MMS_ERR_BIAS + 755) -#define MMS_SSAI_E_DUPLICATE_SESSION (MMS_ERR_BIAS + 756) -#define MMS_SSAI_E_UNKNOWN_LANGUAGE (MMS_ERR_BIAS + 757) -#define MMS_SSAI_E_UNSUPPORTED_LANGUAGE (MMS_ERR_BIAS + 758) -#define MMS_LM_E_SUBCMDFAILED (MMS_ERR_BIAS + 759) -#define MMS_LM_E_CONFIG (MMS_ERR_BIAS + 760) -#define MMS_SSAI_E_SSL (MMS_ERR_BIAS + 761) - -/* - * Additional DM errors - */ -#define MMS_DM_E_ENABLED (MMS_ERR_BIAS + 1000) -#define MMS_DM_E_VIDMISMATCH (MMS_ERR_BIAS + 1001) -#define MMS_DM_E_COMMAND (MMS_ERR_BIAS + 1002) -#define MMS_DM_E_UNSUPPORTED (MMS_ERR_BIAS + 1003) -#define MMS_DM_E_IO (MMS_ERR_BIAS + 1004) -#define MMS_DM_E_COMMUNICATION (MMS_ERR_BIAS + 1005) -#define MMS_DM_E_MAKEHANDLE (MMS_ERR_BIAS + 1006) -#define MMS_DM_E_USER (MMS_ERR_BIAS + 1007) -#define MMS_DM_E_LOAD (MMS_ERR_BIAS + 1008) -#define MMS_DM_E_OPERATOR_ABORT (MMS_ERR_BIAS + 1009) -#define MMS_DM_E_VOLUME_ID (MMS_ERR_BIAS + 1010) -#define MMS_DM_E_DRIVE_SER_NUM (MMS_ERR_BIAS + 1011) -#define MMS_DM_E_DENSITY (MMS_ERR_BIAS + 1012) - -/* - * Additional MM errors - */ -#define MMS_ENOSUCHPCL (MMS_ERR_BIAS + 2000) -#define MMS_ELIBRARYNOEXIST (MMS_ERR_BIAS + 2001) -#define MMS_ELMNOEXIST (MMS_ERR_BIAS + 2002) -#define MMS_ELIBALREADYONLINE (MMS_ERR_BIAS + 2003) -#define MMS_ELIBALREADYOFFLINE (MMS_ERR_BIAS + 2004) -#define MMS_EDRIVENOEXIST (MMS_ERR_BIAS + 2005) -#define MMS_EDRIVEALREADYONLINE (MMS_ERR_BIAS + 2006) -#define MMS_EDRIVEALREADYOFFLINE (MMS_ERR_BIAS + 2007) -#define MMS_EDRIVEONLINE (MMS_ERR_BIAS + 2008) -#define MMS_EDRIVEOFFLINE (MMS_ERR_BIAS + 2009) -#define MMS_ELIBRARYONLINE (MMS_ERR_BIAS + 2010) -#define MMS_ELIBRARYOFFLINE (MMS_ERR_BIAS + 2011) -#define MMS_EDRVUNLOADING (MMS_ERR_BIAS + 2012) -#define MMS_EDMNOMOUNTPOINT (MMS_ERR_BIAS + 2013) -#define MMS_ETMPINUSE (MMS_ERR_BIAS + 2014) - -/* - * Label errors - */ -#define MMS_E_LABEL_NOT_PROCESSED (MMS_ERR_BIAS + 3000) -#define MMS_E_LABEL_MOUNT_SEND (MMS_ERR_BIAS + 3001) -#define MMS_E_LABEL_MOUNT_RSP (MMS_ERR_BIAS + 3002) -#define MMS_E_LABEL_HANDLE_NULL (MMS_ERR_BIAS + 3003) -#define MMS_E_LABEL_HANDLE_OPEN (MMS_ERR_BIAS + 3004) -#define MMS_E_LABEL_UNMOUNT_SEND (MMS_ERR_BIAS + 3005) -#define MMS_E_LABEL_UNMOUNT_RSP (MMS_ERR_BIAS + 3006) -#define MMS_E_LABEL_NO_CARTRIDGES (MMS_ERR_BIAS + 3007) -#define MMS_E_LABEL_NO_LIBRARY (MMS_ERR_BIAS + 3008) -#define MMS_E_LABEL_COMMANDS (MMS_ERR_BIAS + 3009) - -/* - * Sun MM System vendor-defined error codes. - */ -#define MMS_EDATABASE (MMS_ERR_BIAS + 4009) -#define MMS_ENOTFOUND (MMS_ERR_BIAS + 4010) -#define MMS_ESYNTAX (MMS_ERR_BIAS + 4011) -#define MMS_EPRIVNOTSMMSADMIN (MMS_ERR_BIAS + 4012) -#define MMS_MM_E_NOTASK (MMS_ERR_BIAS + 4013) -#define MMS_MM_E_TOOMANYTASKS (MMS_ERR_BIAS + 4014) -#define MMS_ENOTENOUGHPARTITIONS (MMS_ERR_BIAS + 4015) -#define MMS_EPARTITIONSTATECHANGE (MMS_ERR_BIAS + 4016) -#define MMS_ECARTRIDGESTATECHANGE (MMS_ERR_BIAS + 4017) -#define MMS_ESYSTEMCONFIGCHANGE (MMS_ERR_BIAS + 4018) -#define MMS_ENOTCONNECTED (MMS_ERR_BIAS + 4019) -#define MMS_ECOMMUNICATION (MMS_ERR_BIAS + 4020) - -/* - * Socket and SSL error codes. - */ -#define MMS_ERR_NONE (MMS_ERR_BIAS + 5000) -#define MMS_ERR_GETADDRINFO (MMS_ERR_BIAS + 5001) -#define MMS_ERR_SERVICE_NOT_FOUND (MMS_ERR_BIAS + 5002) -#define MMS_ERR_ACCEPT_FAILED (MMS_ERR_BIAS + 5003) -#define MMS_ERR_LISTEN (MMS_ERR_BIAS + 5004) -#define MMS_ERR_READ (MMS_ERR_BIAS + 5005) -#define MMS_ERR_WRITE (MMS_ERR_BIAS + 5006) -#define MMS_ERR_RES_NULL (MMS_ERR_BIAS + 5007) -#define MMS_ERR_GETHOSTNAME (MMS_ERR_BIAS + 5008) -#define MMS_ERR_NOMEM (MMS_ERR_BIAS + 5009) -#define MMS_ERR_SSL_CONNECT (MMS_ERR_BIAS + 5010) -#define MMS_ERR_SSL_FILE (MMS_ERR_BIAS + 5011) -#define MMS_ERR_SSL_CTX (MMS_ERR_BIAS + 5012) -#define MMS_ERR_SSL_CERT (MMS_ERR_BIAS + 5013) -#define MMS_ERR_SSL_NOCERT (MMS_ERR_BIAS + 5014) -#define MMS_ERR_SSL_KEY (MMS_ERR_BIAS + 5015) -#define MMS_ERR_SSL_DH (MMS_ERR_BIAS + 5016) -#define MMS_ERR_SSL_CIPHER (MMS_ERR_BIAS + 5017) -#define MMS_ERR_SSL_OP (MMS_ERR_BIAS + 5018) -#define MMS_ERR_SSL_STORE (MMS_ERR_BIAS + 5019) -#define MMS_ERR_SSL_VERIFY (MMS_ERR_BIAS + 5020) -#define MMS_ERR_NO_SSL (MMS_ERR_BIAS + 5021) - - - -int mms_sym_str_to_code(char *errstr); -char *mms_sym_code_to_str(int code); -void mms_sort_sym_token(mms_sym_t *tab, int num); -void mms_sort_sym_code(mms_sym_t *tab, int num); -mms_sym_t *mms_lookup_sym_token(char *mms_sym, mms_sym_t *tab, int num); -mms_sym_t *mms_lookup_sym_code(int code, mms_sym_t *tab, int num); -mms_sym_t *mms_lookup_sym_err_token(char *); - -#ifdef __cplusplus -} -#endif - -#endif /* _MMS_SYM_H_ */ diff --git a/usr/src/common/mms/mms/mms_trace.h b/usr/src/common/mms/mms/mms_trace.h deleted file mode 100644 index aa040ebae6..0000000000 --- a/usr/src/common/mms/mms/mms_trace.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - -#ifndef _TRACE_H_ -#define _TRACE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdarg.h> -#include <sys/types.h> - -/* - * mms_trace location define - */ -#define MMS_HERE _SrcFile, __LINE__ - -/* - * message severity - */ -enum mms_msg_sev { - MMS_MSG_SEV_EMERG, /* emergency */ - MMS_MSG_SEV_ALERT, /* alert */ - MMS_MSG_SEV_CRIT, /* critical */ - MMS_MSG_SEV_ERROR, /* error */ - MMS_MSG_SEV_WARN, /* warning */ - MMS_MSG_SEV_NOTICE, /* notice */ - MMS_MSG_SEV_INFO, /* information */ - MMS_MSG_SEV_DEBUG, /* debug */ - MMS_MSG_SEV_DEVP /* developer */ -}; -typedef enum mms_msg_sev mms_msg_sev_t; - -/* - * mms_trace severity - */ -enum mms_trace_sev { - MMS_SEV_EMERG, /* emergency */ - MMS_SEV_ALERT, /* alert */ - MMS_SEV_CRIT, /* critical */ - MMS_SEV_OPER, /* operational */ - MMS_SEV_ERROR, /* error */ - MMS_SEV_WARN, /* warning */ - MMS_SEV_NOTICE, /* notice */ - MMS_SEV_INFO, /* information */ - MMS_SEV_DEBUG, /* debug */ - MMS_SEV_DEVP /* developer */ -}; -typedef enum mms_trace_sev mms_trace_sev_t; - -/* - * mms_trace function defines - */ -#define MMS_EMERG MMS_SEV_EMERG, MMS_HERE /* emergency, file, line */ -#define MMS_ALERT MMS_SEV_ALERT, MMS_HERE /* alert, file, line */ -#define MMS_CRIT MMS_SEV_CRIT, MMS_HERE /* critical, file, line */ -#define MMS_OPER MMS_SEV_OPER, MMS_HERE /* operational, file, line */ -#define MMS_ERR MMS_SEV_ERROR, MMS_HERE /* error, file, line */ -#define MMS_WARN MMS_SEV_WARN, MMS_HERE /* warning, file, line */ -#define MMS_NOTICE MMS_SEV_NOTICE, MMS_HERE /* notice, file, line */ -#define MMS_INFO MMS_SEV_INFO, MMS_HERE /* information, file, line */ -#define MMS_DEBUG MMS_SEV_DEBUG, MMS_HERE /* debug, file, line */ -#define MMS_DEVP MMS_SEV_DEVP, MMS_HERE /* developer, file, line */ - -/* - * mms_trace component ids - */ -typedef enum mms_trace_id mms_trace_id_t; -enum mms_trace_id { - MMS_ID_MM, /* media manager */ - MMS_ID_LM, /* library manager */ - MMS_ID_DM, /* drive manager */ - MMS_ID_DMD, /* drive manager daemon */ - MMS_ID_WCR, /* watcher */ - MMS_ID_API, /* client api library */ - MMS_ID_ND, /* non daemon mode, use stderr */ - MMS_ID_CLI /* client application */ -}; - - -extern int mms_trace_open(char *, mms_trace_id_t, int, int64_t, - int, int); -extern int mms_trace_get_fd(void); -extern void mms_trace_set_id(mms_trace_id_t); -extern mms_trace_id_t mms_trace_get_id(void); -extern mms_trace_sev_t mms_trace_get_severity(void); -extern mms_msg_sev_t mms_msg_get_severity(char *); -extern void mms_trace(mms_trace_sev_t, char *, int, - const char *, ...); -extern void mms_trace_va(mms_trace_sev_t, char *, int, - const char *, va_list); -extern void mms_trace_close(void); -extern int mms_trace_filter(mms_trace_sev_t); -extern int mms_trace_str_filter(char *); -extern char *mms_trace_dump(char *, int, char *, int); -extern void mms_trace_flush(void); -extern int mms_trace_set_fsize(char *); -extern int mms_trace_str_to_fsize(char *string, uint64_t *size); -extern int mms_trace_str2sev(char *level, - mms_trace_sev_t *severity); -extern char *mms_trace_sev2str(mms_trace_sev_t severity); - -#define MMS_CHAR_PER_LINE 16 -#define MMS_NUM_LINES(len) (((len - 1) / MMS_CHAR_PER_LINE) + 1) -#define MMS_CHAR_OFFSET (6 + 9 * 4) -#define MMS_DUMP_LINE_SIZE (MMS_CHAR_OFFSET + MMS_CHAR_PER_LINE + 1) -#define MMS_DUMPBUF_SIZE(len) ((MMS_NUM_LINES(len) * MMS_LINE_SIZE) + 1) -#define MMS_LINE_SIZE 1000 -#define MMS_LOGADM "/usr/sbin/logadm" -#define MMS_LOGADM_CONF "/var/log/mms/mms_logadm.conf" - -#ifdef __cplusplus -} -#endif - -#endif /* _TRACE_H_ */ diff --git a/usr/src/common/mms/mms/mms_wcr_msg.h b/usr/src/common/mms/mms/mms_wcr_msg.h deleted file mode 100644 index 2cc0b49c61..0000000000 --- a/usr/src/common/mms/mms/mms_wcr_msg.h +++ /dev/null @@ -1,53 +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 __MMS_WCR_MSG_H -#define __MMS_WCR_MSG_H - - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef WCR_MSG -#define WCR_MSG(n, s) -#endif - -/* Watcher Messages 8000-8999 */ - -#define WCR_8000_MSG 8000 -WCR_MSG(WCR_8000_MSG, gettext("Conflicting ssi configuration on $wcr_host$, " \ - "Same SSI port configured for different ACSLS libraries: $lmname1$ " \ - "$ssiport1$ $ssihost1$, $lmname2$ $ssiport2$ $ssihost2$")) - -#define WCR_8001_MSG 8001 -WCR_MSG(WCR_8001_MSG, gettext("Error starting SSI, check that the path " \ - "$ssipath$ is correct and use cpstop/cpstart to restart the lm " \ - "service")) - -#ifdef __cplusplus -} -#endif - -#endif /* __MMS_WCR_MSG_H */ diff --git a/usr/src/lib/Makefile b/usr/src/lib/Makefile index 8e5e78f303..7a3af52feb 100644 --- a/usr/src/lib/Makefile +++ b/usr/src/lib/Makefile @@ -1,26 +1,4 @@ -# -# 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) 1989, 2010, Oracle and/or its affiliates. All rights reserved. -# include ../Makefile.master @@ -258,7 +236,6 @@ SUBDIRS += \ smbsrv \ libilb \ scsi \ - mms \ libima \ libsun_ima \ mpapi \ @@ -364,7 +341,6 @@ MSGSUBDIRS= \ libzonecfg \ lvm \ madv \ - mms \ mpss \ pam_modules \ pyzfs \ @@ -506,7 +482,6 @@ HDRSUBDIRS= \ libima \ libsun_ima \ mpapi \ - mms \ libreparse \ $($(MACH)_HDRSUBDIRS) diff --git a/usr/src/lib/libsecdb/auth_attr.txt b/usr/src/lib/libsecdb/auth_attr.txt index 7d5ef346c6..4fd399d7d0 100644 --- a/usr/src/lib/libsecdb/auth_attr.txt +++ b/usr/src/lib/libsecdb/auth_attr.txt @@ -1,25 +1,6 @@ -# -# 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 2010 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + + # # /etc/security/auth_attr # @@ -82,14 +63,6 @@ solaris.login.remote:::Remote Login::help=LoginRemote.html solaris.mail.:::Mail::help=MailHeader.html solaris.mail.mailq:::Mail Queue::help=MailQueue.html # -solaris.mms.:::Media Management System (MMS)::help=MMSHeader.html -solaris.mms.media:::MMS Media Import, Export, Label and Move::help=AuthMMSMedia.html -solaris.mms.request:::Handle MMS Device Manager Requests::help=AuthMMSRequest.html -solaris.mms.device.state:::Start and Stop MMS Device Managers::help=AuthMMSDeviceState.html -solaris.mms.device.log:::Change MMS Trace and Message Levels::help=AuthMMSDeviceLog.html -solaris.mms.io.read:::Read Permission for MMS Volumes::help=AuthMMSIORead.html -solaris.mms.io.write:::Read and Write Permission for MMS Volumes::help=AuthMMSIOWrite.html -# solaris.network.:::Network::help=NetworkHeader.html solaris.network.autoconf.read:::View Network Auto-Magic Config::help=NetworkAutoconfRead.html solaris.network.autoconf.select:::Enable/Disable Network Auto-Magic Config::help=NetworkAutoconfSelect.html @@ -204,8 +177,6 @@ solaris.system.sysevent.write:::Publish Sysevents::help=SysSyseventWrite.html # solaris.smf.modify.stmf:::Modify STMF Properties::help=SmfSTMFValue.html # -solaris.smf.manage.mms:::Manage MMS Service States::help=SmfManageMMS.html -solaris.smf.value.mms:::Change Values of MMS Service Properties::help=SmfValueMMS.html solaris.smf.manage.isns:::Manage iSNS Service States::help=isnsStates.html solaris.smf.value.isns:::Modify iSNS Service Property Values::help=isnsValue.html solaris.isnsmgr.write:::Modify iSNS configuration::help=AuthISNSmgrWrite.html diff --git a/usr/src/lib/libsecdb/exec_attr.txt b/usr/src/lib/libsecdb/exec_attr.txt index c469518383..585fc89e9f 100644 --- a/usr/src/lib/libsecdb/exec_attr.txt +++ b/usr/src/lib/libsecdb/exec_attr.txt @@ -1,25 +1,5 @@ -# -# 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 2010 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + # # /etc/security/exec_attr # @@ -155,10 +135,6 @@ Media Restore:suser:cmd:::/usr/bin/cpio:euid=0 Media Restore:suser:cmd:::/usr/bin/mt:euid=0 Media Restore:suser:cmd:::/usr/lib/fs/ufs/ufsrestore:euid=0 Media Restore:suser:cmd:::/usr/sbin/tar:euid=0 -MMS Administrator:solaris:cmd:::/usr/bin/mmsinit:uid=0 -MMS Administrator:solaris:cmd:::/usr/bin/mmsadm:uid=0 -MMS Operator:solaris:cmd:::/usr/bin/mmsadm:uid=0;privs=file_dac_read -MMS User:solaris:cmd:::/usr/bin/mmsmnt:uid=0;privs=file_dac_read Name Service Management:suser:cmd:::/usr/sbin/nscd:euid=0 Name Service Security:suser:cmd:::/usr/bin/chkey:euid=0 Name Service Security:suser:cmd:::/usr/sbin/ldapclient:uid=0 diff --git a/usr/src/lib/libsecdb/help/auths/AuthMMSDeviceLog.html b/usr/src/lib/libsecdb/help/auths/AuthMMSDeviceLog.html deleted file mode 100644 index 7e7c2726ad..0000000000 --- a/usr/src/lib/libsecdb/help/auths/AuthMMSDeviceLog.html +++ /dev/null @@ -1,37 +0,0 @@ -<HTML> -<!-- - 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. ---> -<HEAD> - <TITLE> </TITLE> - - -</HEAD> -<BODY> - -When Change MMS Trace and Message Levels is in the Authorizations Included column, it grants the authorization to control the engineering trace level and the user message level for each component in MMS. -<p> -If Change MMS Trace and Message Levels is grayed, then you are not entitled to Add or Remove this authorization. -<p> -</BODY> -</HTML> diff --git a/usr/src/lib/libsecdb/help/auths/AuthMMSDeviceState.html b/usr/src/lib/libsecdb/help/auths/AuthMMSDeviceState.html deleted file mode 100644 index 1f6fa09641..0000000000 --- a/usr/src/lib/libsecdb/help/auths/AuthMMSDeviceState.html +++ /dev/null @@ -1,37 +0,0 @@ -<HTML> -<!-- - 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. ---> -<HEAD> - <TITLE> </TITLE> - - -</HEAD> -<BODY> - -When Start and Stop MMS Device Managers is in the Authorizations Included column, it grants the authorization to control the device managers. -<p> -If Start and Stop MMS Device Managers is grayed, then you are not entitled to Add or Remove this authorization. -<p> -</BODY> -</HTML> diff --git a/usr/src/lib/libsecdb/help/auths/AuthMMSIORead.html b/usr/src/lib/libsecdb/help/auths/AuthMMSIORead.html deleted file mode 100644 index 475d559d68..0000000000 --- a/usr/src/lib/libsecdb/help/auths/AuthMMSIORead.html +++ /dev/null @@ -1,37 +0,0 @@ -<HTML> -<!-- - 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. ---> -<HEAD> - <TITLE> </TITLE> - - -</HEAD> -<BODY> - -When Read Permission for MMS Volumes is in the Authorizations Included column, it grants the authorization to read Media Management System (MMS) media. -<p> -If Read Permission for MMS Volumes is grayed, then you are not entitled to Add or Remove this authorization. -<p> -</BODY> -</HTML> diff --git a/usr/src/lib/libsecdb/help/auths/AuthMMSIOWrite.html b/usr/src/lib/libsecdb/help/auths/AuthMMSIOWrite.html deleted file mode 100644 index 43bb57112b..0000000000 --- a/usr/src/lib/libsecdb/help/auths/AuthMMSIOWrite.html +++ /dev/null @@ -1,37 +0,0 @@ -<HTML> -<!-- - 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. ---> -<HEAD> - <TITLE> </TITLE> - - -</HEAD> -<BODY> - -When Read and Write Permission for MMS Volumes is in the Authorizations Included column, it grants the authorization to read and write Media Management System (MMS) media. -<p> -If Read and Write Permission for MMS Volumes is grayed, then you are not entitled to Add or Remove this authorization. -<p> -</BODY> -</HTML> diff --git a/usr/src/lib/libsecdb/help/auths/AuthMMSMedia.html b/usr/src/lib/libsecdb/help/auths/AuthMMSMedia.html deleted file mode 100644 index 7dde931e56..0000000000 --- a/usr/src/lib/libsecdb/help/auths/AuthMMSMedia.html +++ /dev/null @@ -1,37 +0,0 @@ -<HTML> -<!-- - 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. ---> -<HEAD> - <TITLE> </TITLE> - - -</HEAD> -<BODY> - -When MMS Media Import, Export, Label and Move is in the Authorizations Included column, it grants the authorization to the media changer cap, slots, and the ability to label media. -<p> -If MMS Media Import, Export, Label and Move is grayed, then you are not entitled to Add or Remove this authorization. -<p> -</BODY> -</HTML> diff --git a/usr/src/lib/libsecdb/help/auths/AuthMMSRequest.html b/usr/src/lib/libsecdb/help/auths/AuthMMSRequest.html deleted file mode 100644 index 4f5a2ec1e2..0000000000 --- a/usr/src/lib/libsecdb/help/auths/AuthMMSRequest.html +++ /dev/null @@ -1,37 +0,0 @@ -<HTML> -<!-- - 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. ---> -<HEAD> - <TITLE> </TITLE> - - -</HEAD> -<BODY> - -When Handle MMS Device Manager Requests is in the Authorizations Included column, it grants the authorization to respond to device manager requests. -<p> -If Handle MMS Device Manager Requests is grayed, then you are not entitled to Add or Remove this authorization. -<p> -</BODY> -</HTML> diff --git a/usr/src/lib/libsecdb/help/auths/MMSHeader.html b/usr/src/lib/libsecdb/help/auths/MMSHeader.html deleted file mode 100644 index 20bcb28e20..0000000000 --- a/usr/src/lib/libsecdb/help/auths/MMSHeader.html +++ /dev/null @@ -1,34 +0,0 @@ -<HTML> -<!-- - 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. ---> -<HEAD> - <TITLE> </TITLE> - - -</HEAD> -<BODY> - -The authorizations allow users access and the ability to manage the Media Management System (MMS). -</BODY> -</HTML> diff --git a/usr/src/lib/libsecdb/help/auths/Makefile b/usr/src/lib/libsecdb/help/auths/Makefile index 6b1bb7737b..0cbb393e7a 100644 --- a/usr/src/lib/libsecdb/help/auths/Makefile +++ b/usr/src/lib/libsecdb/help/auths/Makefile @@ -1,25 +1,5 @@ -# -# 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 2010 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. +# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + # # lib/libsecdb/help/auths/Makefile # @@ -166,16 +146,7 @@ HTMLENTS = \ SysCpuPowerMgmt.html \ SysSyseventRead.html \ SysSyseventWrite.html \ - SmfManageZFSSnap.html \ - MMSHeader.html \ - AuthMMSDeviceLog.html \ - AuthMMSDeviceState.html \ - AuthMMSIORead.html \ - AuthMMSIOWrite.html \ - AuthMMSMedia.html \ - AuthMMSRequest.html \ - SmfManageMMS.html \ - SmfValueMMS.html + SmfManageZFSSnap.html HELPDIR=$(ROOT)/usr/lib/help AUTHDIR=$(HELPDIR)/auths diff --git a/usr/src/lib/libsecdb/help/auths/SmfManageMMS.html b/usr/src/lib/libsecdb/help/auths/SmfManageMMS.html deleted file mode 100644 index d35caedfcb..0000000000 --- a/usr/src/lib/libsecdb/help/auths/SmfManageMMS.html +++ /dev/null @@ -1,37 +0,0 @@ -<HTML> -<!-- - 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. ---> -<HEAD> - <TITLE> </TITLE> - - -</HEAD> -<BODY> - -When Manage MMS Service States is in the Authorizations Include column, it grants the authorization to enable, disable, or restart the mms service. -<p> -If Manage MMS Service States is grayed, then you are not entitled to Add or Remove this authorization. -<p> -</BODY> -</HTML> diff --git a/usr/src/lib/libsecdb/help/auths/SmfValueMMS.html b/usr/src/lib/libsecdb/help/auths/SmfValueMMS.html deleted file mode 100644 index 4c58a8f762..0000000000 --- a/usr/src/lib/libsecdb/help/auths/SmfValueMMS.html +++ /dev/null @@ -1,37 +0,0 @@ -<HTML> -<!-- - 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. ---> -<HEAD> - <TITLE> </TITLE> - - -</HEAD> -<BODY> - -When Change Values of MMS Service Properties is in the Authorizations Included column, it grants the the authorization to change MMS service property values. -<p> -If Change Values of MMS Service Properties is grayed, then you are not entitled to Add or Remove this authorization. -<p> -</BODY> -</HTML> diff --git a/usr/src/lib/libsecdb/help/profiles/Makefile b/usr/src/lib/libsecdb/help/profiles/Makefile index c996a0bd5c..5ef54cc1bb 100644 --- a/usr/src/lib/libsecdb/help/profiles/Makefile +++ b/usr/src/lib/libsecdb/help/profiles/Makefile @@ -1,28 +1,4 @@ -# -# 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 2010 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# lib/libsecdb/help/profiles/Makefile -# +# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. include ../../../../Makefile.master @@ -100,10 +76,7 @@ HTMLENTS = \ RtSysPowerMgmtSuspendtoDisk.html \ RtSysPowerMgmtSuspendtoRAM.html \ RtSysPowerMgmtBrightness.html \ - RtCPUPowerManagement.html \ - RtMMSAdmin.html \ - RtMMSOper.html \ - RtMMSUser.html + RtCPUPowerManagement.html HELPDIR = $(ROOT)/usr/lib/help PROFDIR = $(HELPDIR)/profiles diff --git a/usr/src/lib/libsecdb/help/profiles/RtMMSAdmin.html b/usr/src/lib/libsecdb/help/profiles/RtMMSAdmin.html deleted file mode 100644 index 06527cf2d1..0000000000 --- a/usr/src/lib/libsecdb/help/profiles/RtMMSAdmin.html +++ /dev/null @@ -1,37 +0,0 @@ -<HTML> -<!-- - 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. ---> -<HEAD> - <TITLE> </TITLE> - - -</HEAD> - -<BODY> -When MMS Administrator is in the Rights Included column, it grants the right to administer the Media Management System (MMS) service, device managers, configuration, and the ability to do MMS I/O. -<p> -If MMS Administrator is grayed, then you are not entitled to Add or Remove this right. -<p> -</BODY> -</HTML> diff --git a/usr/src/lib/libsecdb/help/profiles/RtMMSOper.html b/usr/src/lib/libsecdb/help/profiles/RtMMSOper.html deleted file mode 100644 index bf182fd9e4..0000000000 --- a/usr/src/lib/libsecdb/help/profiles/RtMMSOper.html +++ /dev/null @@ -1,37 +0,0 @@ -<HTML> -<!-- - 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. ---> -<HEAD> - <TITLE> </TITLE> - - -</HEAD> - -<BODY> -When MMS Operator is in the Rights Included column, it grants the right to administer the Media Management System service and device managers, but not the right to modify the MMS configuration or the ability to do MMS I/O. -<p> -If MMS Operator is grayed, then you are not entitled to Add or Remove this right. -<p> -</BODY> -</HTML> diff --git a/usr/src/lib/libsecdb/help/profiles/RtMMSUser.html b/usr/src/lib/libsecdb/help/profiles/RtMMSUser.html deleted file mode 100644 index da43bcda19..0000000000 --- a/usr/src/lib/libsecdb/help/profiles/RtMMSUser.html +++ /dev/null @@ -1,37 +0,0 @@ -<HTML> -<!-- - 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. ---> -<HEAD> - <TITLE> </TITLE> - - -</HEAD> - -<BODY> -When MMS User is in the Rights Included column, it grants the right to do Media Management System (MMS) I/O, but not the right to administer the MMS service, device managers, or configuration. -<p> -If MMS User is grayed, then you are not entitled to Add or Remove this right. -<p> -</BODY> -</HTML> diff --git a/usr/src/lib/libsecdb/prof_attr.txt b/usr/src/lib/libsecdb/prof_attr.txt index a1b5961d09..682f070ed5 100644 --- a/usr/src/lib/libsecdb/prof_attr.txt +++ b/usr/src/lib/libsecdb/prof_attr.txt @@ -1,28 +1,4 @@ -# -# 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 2010 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# +# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. # # /etc/security/prof_attr @@ -57,9 +33,6 @@ Maintenance and Repair:::Maintain and repair a system:auths=solaris.smf.manage.s Media Backup:::Backup files and file systems:profiles=NDMP Management;help=RtMediaBkup.html Media Catalog:::Catalog files and file systems:help=RtMediaCtlg.html Media Restore:::Restore files and file systems from backups:profiles=NDMP Management;help=RtMediaRestore.html -MMS Administrator:::MMS Media Manager Administrator:auths=solaris.smf.manage.mms,solaris.smf.value.mms,solaris.mms.*;help=RtMMSAdmin.html -MMS Operator:::MMS Media Manager Operator:auths=solaris.smf.manage.mms,solaris.mms.media.*,solaris.mms.request.*,solaris.mms.device.state.*,solaris.mms.device.log.*;help=RtMMSOper.html -MMS User:::MMS Tape User:auths=solaris.mms.io.*;help=RtMMSUser.html NDMP Management:::Manage the NDMP service:auths=solaris.smf.manage.ndmp,solaris.smf.value.ndmp,solaris.smf.read.ndmp;help=RtNdmpMngmnt.html Network Autoconf Admin:::Manage Network Auto-Magic configuration via nwamd:profiles=Network Autoconf User;auths=solaris.network.autoconf.write,solaris.smf.manage.location,solaris.smf.modify.application;help=RtNetAutoconfAdmin.html Network Autoconf User:::Network Auto-Magic User:auths=solaris.network.autoconf.read,solaris.network.autoconf.select,solaris.network.autoconf.wlan;help=RtNetAutoconfUser.html diff --git a/usr/src/lib/mms/Makefile b/usr/src/lib/mms/Makefile deleted file mode 100644 index d5fdf23e87..0000000000 --- a/usr/src/lib/mms/Makefile +++ /dev/null @@ -1,58 +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. -# -# - -include $(SRC)/lib/Makefile.lib - -SUBDIRS = \ - dm \ - lm \ - mgmt \ - pg - -.KEEP_STATE: - -.PARALLEL: - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -install_h := TARGET = install_h -lint := TARGET = lint -_msg := TARGET = _msg -check := TARGET = check - -all clean clobber install lint: $(SUBDIRS) - -install_h _msg check: mms - -$(SUBDIRS): mms - -$(SUBDIRS) mms: FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/dm/Makefile b/usr/src/lib/mms/dm/Makefile deleted file mode 100644 index b356510722..0000000000 --- a/usr/src/lib/mms/dm/Makefile +++ /dev/null @@ -1,59 +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. -# -# - -SUBDIRS = \ - libdefault \ - libDISK_ARCHIVING \ - libHP_Ultrium_3-SCSI \ - libIBM_ULTRIUM-TD1 \ - libIBM_ULTRIUM-TD2 \ - libIBM_ULTRIUM-TD3 \ - libIBM_ULTRIUM-TD4 \ - libQUANTUM_SDLT600 \ - libSEAGATE_ULTRIUM06242-XXX \ - libSTK_9840 \ - libSTK_T9840B \ - libSTK_T9840C \ - libSTK_T9940A \ - libSTK_T9940B - -.KEEP_STATE: - -.PARALLEL: - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/dm/Makefile.defs b/usr/src/lib/mms/dm/Makefile.defs deleted file mode 100644 index 2abd3b83e9..0000000000 --- a/usr/src/lib/mms/dm/Makefile.defs +++ /dev/null @@ -1,32 +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. -# -# - -ROOTLIBDIR = $(ROOT)/usr/lib/mms/dm - -ROOTLIBS = $(LIBS:%=$(ROOTLIBDIR)/%) - -DMLIBLINKS = $(DMLINKS:%=$(ROOTLIBDIR)/%) - diff --git a/usr/src/lib/mms/dm/Makefile.rootdirs b/usr/src/lib/mms/dm/Makefile.rootdirs deleted file mode 100644 index 7d95982217..0000000000 --- a/usr/src/lib/mms/dm/Makefile.rootdirs +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# Define the transitive set of rules to create a common module's install dir -# within the proto area. -# - -include ../../Makefile.defs -include $(SRC)/lib/Makefile.targ - -$(ROOTLIBDIR): - $(INS.dir) - -$(DMLIBLINKS): $(ROOTLIBDIR) - $(RM) $@ - $(SYMLINK) $(DYNLIB) $@ diff --git a/usr/src/lib/mms/dm/libDISK_ARCHIVING/Makefile b/usr/src/lib/mms/dm/libDISK_ARCHIVING/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/dm/libDISK_ARCHIVING/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/dm/libDISK_ARCHIVING/Makefile.com b/usr/src/lib/mms/dm/libDISK_ARCHIVING/Makefile.com deleted file mode 100644 index 768d04ffba..0000000000 --- a/usr/src/lib/mms/dm/libDISK_ARCHIVING/Makefile.com +++ /dev/null @@ -1,58 +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. -# -# - -LIBRARY = libSUNW_DISK_ARCHIVING.a -VERS = -OBJECTS = dm_SUNW_DISK_ARCHIVING.o - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -SRCS = $(OBJECTS:%.o=$(SRCDIR)/%.c) - -LDLIBS += -lc -LDLIBS += -L$(SRC)/lib/mms/mms/$(MACH) -lmms - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/dm/common -I../../../mms/common -CPPFLAGS += -I$(SRC)/uts/common/io/mms/dda -CPPFLAGS += -I$(SRC)/uts/common/io/mms/dmd - -.KEEP_STATE: - -all: $(LIBS) - -lint: $(LINTLIB) lintcheck - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) diff --git a/usr/src/lib/mms/dm/libDISK_ARCHIVING/common/dm_SUNW_DISK_ARCHIVING.c b/usr/src/lib/mms/dm/libDISK_ARCHIVING/common/dm_SUNW_DISK_ARCHIVING.c deleted file mode 100644 index fb1dee577d..0000000000 --- a/usr/src/lib/mms/dm/libDISK_ARCHIVING/common/dm_SUNW_DISK_ARCHIVING.c +++ /dev/null @@ -1,542 +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. - */ - - -#include <note.h> -#include <sys/types.h> -#include <syslog.h> -#include <sys/scsi/impl/uscsi.h> -#include <sys/scsi/generic/sense.h> -#include <sys/scsi/generic/status.h> -#include <sys/scsi/generic/commands.h> -#include <stdlib.h> -#include <stdio.h> -#include <ctype.h> -#include <fcntl.h> -#include <sys/types.h> -#include <sys/mkdev.h> -#include <sys/stat.h> -#include <sys/mntio.h> -#include <sys/mnttab.h> -#include <dlfcn.h> -#include <errno.h> -#include <pthread.h> -#include <string.h> -#include <unistd.h> -#include <stropts.h> -#include <sys/ioctl.h> -#include <sys/siginfo.h> -#include <sys/mtio.h> -#include <time.h> -#include <mms_dmd.h> -#include <mms_trace.h> -#include <dmd_impl.h> -#include <dm_impl.h> -#include <dm_drive.h> -#include <dm_msg.h> -#include <dm_proto.h> -#include <dda.h> -#include <mms_strapp.h> - -static char *_SrcFile = __FILE__; - -/* - * Specify whether the persistent reserve out command is supported or not. - * 0 - not supported - * 1 - supported - * - * If the persistent reserve out command is supported, then it will be used - * to reserve the drive. - * If the persistent reserve out command is not supported, then the reserve - * command will be used to reserve the drive. - */ -int drv_prsv_supported = 1; /* persistent reserve out supported */ - -/* - * specify timeouts for this drive. Time is specified in seconds. - */ -drv_timeout_t drv_timeout = { - (151 *60), /* For really long commands */ - (20 *60), /* Normal commands */ - (1 *60), /* short commands */ -}; - -/* - * Specify the drive type. - * Drive type must begin with "dt_" - */ -char drv_drive_type[] = "dt_disk"; - -/* - * Specify the directory in which this device can be found. - * e.g. /dev/rmt - * - * The DM will open each device in this directory and look for a device - * whose serial number matches the serial number specified in - * DRIVE.'DriveSerialNum'. - * If this is a null string, then the full pathname of the device is specified - * in DM.'DMTargetPath'. - */ -char drv_dev_dir[] = ""; - -/* - * drv_density[] - * - Specify density names with their density codes supported by this DM. - * - Densities must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Density names must start with "den_" to avoid conflict with other names. - */ - -mms_sym_t drv_density[] = { - "den_DISK", 0, - NULL -}; - -/* - * drv_shape[] - * - Specify shape names of cartridge types supported by this DM. - * - Shape names must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Shape name must be a well known and published name. - */ - -char *drv_shape[] = { - "DISK", - NULL -}; - -/* - * drv_shape_den[] - * Specify the shape of a cartridge and the density on it that can be - * written over by a readwrite density. - * All shape names and density names must have been specified in - * drv_density[] and drv_shape[]. - * Each entry of the array consists of: - * {shapename, density on cart, readwrite density}. - * If the density on cartridge is the same as the readwrite density, then - * the drive can read and write with that density. - * If the density on cartridge is read only, then the readwrite density - * is NULL. - * If the readwrite density is not NULL and it is different from the density - * on cartridge, then the drive is able to write over the existing data - * starting from the beginning of medium. - */ - -drv_shape_density_t drv_shape_den[] = { - "DISK", "den_DISK", "den_DISK", - NULL -}; - -/* - * Specify SCSI commands that a client may not issue using USCSI - */ -int drv_disallowed_cmds[] = { - SCMD_PROUT, /* persistent reserve out */ - SCMD_RESERVE, /* reserve */ - SCMD_RELEASE, /* release */ -}; -int drv_num_disallowed_cmds = - sizeof (drv_disallowed_cmds) / sizeof (int); - -/* - * Specify ioctl's that a client may not issue - */ -int drv_disallowed_ioctls[] = { - MTIOCRESERVE, - MTIOCRELEASE, - MTIOCFORCERESERVE, -}; -int drv_num_disallowed_ioctls = - sizeof (drv_disallowed_ioctls) / sizeof (int); - - -typedef struct drv_cart_mountpt { - int drv_state; - char *drv_mpoint; - pthread_t drv_tid; -} drv_cart_mountpt_t; - -/* - * Function name - * drv_init_dev(void) - * - * Parameters: - * none - * - * Description: - * initialize a DISK cartridge by getting opening the DISK library - * and unload the drive. - * - * Return code: - * none - * - * Note: - * - * - */ - -int -drv_init_dev(void) -{ - /* - * Get the library path - */ - - /* - * Read LIBRARYACCESS to get HostPath. - * If HostPath is set, then it is the path to access the - * library. - * If HostPath is not set, then read the default path - * in the LIBRARY and use it to access the library. - */ - if (dm_get_hostpath() != 0) { - TRACE((MMS_DEBUG, "Can't get hostpath")); - return (-1); - } - - if (drv->drv_disk_libpath == NULL) { - /* - * Host path is not set. - * Read the default lib path from LIBRARY - */ - if (dm_get_default_lib_path() != 0) { - TRACE((MMS_DEBUG, "Can't get default lib path")); - return (-1); - } - } - - /* - * Since there is no library to unload a dda tape drive, it has - * to be initialized by unload any loaded tape when the drive is - * activate enabled. - */ - - DRV_CALL(drv_unload, ()); - return (0); -} - -int64_t -drv_get_avail_capacity(void) -{ - mms_capacity_t cap; - - if (DRV_CALL(drv_get_capacity, (&cap)) < 0) { - return (-1); - } - return (cap.mms_avail); -} - -int -drv_get_capacity(mms_capacity_t *cap) -{ - dda_capacity_t dda_cap; - - if (ioctl(drv->drv_fd, DDA_CMD_CAPACITY, &dda_cap) < 0) { - return (-1); - } - - TRACE((MMS_DEBUG, "dda_capacity = %lld, dda_space = %lld", - dda_cap.dda_capacity, dda_cap.dda_space)); - - cap->mms_max = dda_cap.dda_capacity / (1024 * 1024); - cap->mms_avail = dda_cap.dda_space / (1024 * 1024); - cap->mms_pc_avail = - (dda_cap.dda_space * 100) / dda_cap.dda_capacity; - return (0); -} - - -/* - * drv_mode_sense - issue mode sense - * - page - page code - * - len - allocation length - * - * - always return block descriptor block - * - always get current value - */ - -/*ARGSUSED0*/ -int -drv_mode_sense(int page, int pc, int len) -{ - errno = ENOTSUP; - return (-1); -} - -/* - * drv_mode_select - issue mode select - * - pf - page format - 0, no page data, or 1, send page data - * - len - allocation length - */ -/*ARGSUSED0*/ -int -drv_mode_select(int pf, int len) -{ - errno = ENOTSUP; - return (-1); -} - -int -drv_inquiry(void) -{ - errno = ENOTSUP; - return (-1); -} - -int -drv_clrerr(void) -{ - errno = ENOTSUP; - return (-1); -} - -int -drv_tur(void) -{ - struct mtget mtget; - - if (ioctl(drv->drv_fd, MTIOCGET, &mtget) < 0) { - return (-1); - } - if (mtget.mt_fileno < 0) { - return (-1); - } - return (0); -} - -int -drv_load(void) -{ - char *path; - struct stat statbuf; - int err; - - TRACE((MMS_DEBUG, "Load/Retension")); - - /* - * Get path to cartridge. - * It is library-path/pcl - */ - path = mms_strnew("%s/%s", drv->drv_disk_libpath, mnt->mnt_pcl); - - /* - * If path does not exist - */ - while (stat(path, &statbuf) < 0) { - if (errno == EINTR) { - continue; - } - DM_MSG_ADD((MMS_EXIST, MMS_DM_E_NOCART, - "cartridge %s does not exist", path)); - - TRACE((MMS_DEBUG, "path %s does not exist", path)); - free(path); - return (-1); - } - - drv->drv_flags &= ~DRV_MOVE_FLAGS; - if (ioctl(drv->drv_fd, DDA_CMD_LOAD, path) < 0) { - err = errno; - DM_MSG_ADD((MMS_INTERNAL, MMS_DM_E_IO, - "load error: %s", strerror(err))); - - TRACE((MMS_DEBUG, "load error: %s", strerror(err))); - free(path); - return (-1); - } - - drv->drv_flags |= DRV_BOM; - TRACE((MMS_DEBUG, "Cartridge \"%s\" loaded, path = %s", - mnt->mnt_pcl, path)); - free(path); - return (0); -} - -int -drv_get_pos(tapepos_t *pos) -{ - if (ioctl(drv->drv_fd, MTIOCGETPOS, pos) != 0) { - return (-1); - } - TRACE((MMS_DEBUG, "Read position %lld", pos->lgclblkno)); - return (0); -} - -/*ARGSUSED0*/ -int -drv_log_sense(uchar_t *buf, int len, int page_control, int page_code) -{ - errno = ENOTSUP; - return (-1); -} - -int -drv_blk_limit(mms_blk_limit_t *lmt) -{ - dda_blklmt_t dda_blklmt; - - if (ioctl(drv->drv_fd, DDA_CMD_BLKLMT, &dda_blklmt) < 0) { - return (-1); - } - lmt->mms_max = dda_blklmt.dda_blkmax; - lmt->mms_min = dda_blklmt.dda_blkmin; - lmt->mms_gran = 0; - TRACE((MMS_DEBUG, "Read block limits max %d min %d", - lmt->mms_max, lmt->mms_min)); - return (0); -} - -int -drv_release(void) -{ - return (0); -} - -int -drv_prsv_register(void) -{ - return (0); -} - -int -drv_prsv_reserve(void) -{ - return (0); -} - -int -drv_prsv_release(void) -{ - return (0); -} - -/*ARGSUSED0*/ -int -drv_prsv_preempt(char *curkey) -{ - return (0); -} - -int -drv_prsv_clear(void) -{ - return (0); -} - -/*ARGSUSED0*/ -int -drv_prsv_read_keys(char *buf, int bufsize) -{ - errno = ENOTSUP; - return (-1); -} - -/*ARGSUSED0*/ -int -drv_prsv_read_rsv(char *buf, int bufsize) -{ - errno = ENOTSUP; - return (-1); -} - - -int -drv_reserve(void) -{ - return (0); -} - -/*ARGSUSED0*/ -int -drv_get_serial_num(char *ser) -{ - return (-1); -} - -int -drv_get_write_protect(int *wp) -{ - *wp = !ioctl(drv->drv_fd, DDA_CMD_WPROTECT, NULL); - TRACE((MMS_DEBUG, "Cartridge write protected is %s", - *wp ? "yes" : "no")); - return (0); -} - -/*ARGSUSED0*/ -int -drv_set_compression(int comp) -{ - return (0); -} - -void -drv_disallowed(void) -{ -} - -void -drv_mk_prsv_key(void) -{ -} - -int -drv_rebind_target(void) -{ - /* - * Target is already bound. - */ - return (0); -} - -/*ARGSUSED0*/ -int -drv_bind_raw_dev(int oflags) -{ - return (0); -} - -int -drv_get_statistics(void) -{ - return (-1); -} - -int -drv_get_density(int *den, int *comp) -{ - *den = 0; /* DISK density */ - if (comp) { - *comp = 0; - } - return (0); -} - -int -/* ARGSUSED */ -drv_set_density(int den) -{ - return (0); -} diff --git a/usr/src/lib/mms/dm/libDISK_ARCHIVING/common/mapfile-vers b/usr/src/lib/mms/dm/libDISK_ARCHIVING/common/mapfile-vers deleted file mode 100644 index f7a661b9a2..0000000000 --- a/usr/src/lib/mms/dm/libDISK_ARCHIVING/common/mapfile-vers +++ /dev/null @@ -1,104 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - drv_bind_raw_dev; - drv_blk_limit; - drv_clrerr; - drv_density; - drv_dev_dir; - drv_disallowed; - drv_disallowed_cmds; - drv_disallowed_ioctls; - drv_drive_type; - drv_get_avail_capacity; - drv_get_capacity; - drv_get_density; - drv_get_pos; - drv_get_serial_num; - drv_get_statistics; - drv_get_write_protect; - drv_init_dev; - drv_inquiry; - drv_load; - drv_log_sense; - drv_mk_prsv_key; - drv_mode_select; - drv_mode_sense; - drv_num_disallowed_cmds; - drv_num_disallowed_ioctls; - drv_prsv_clear; - drv_prsv_preempt; - drv_prsv_read_keys; - drv_prsv_read_rsv; - drv_prsv_register; - drv_prsv_release; - drv_prsv_reserve; - drv_prsv_supported; - drv_rebind_target; - drv_release; - drv_reserve; - drv_set_compression; - drv_set_density; - drv_shape; - drv_shape_den; - drv_timeout; - drv_tur; - - dm_get_attr_value = extern; - dm_get_default_lib_path = extern; - dm_get_hostpath = extern; - dm_msg_add = extern; - dm_msg_destroy = extern; - dm_show_mount_point = extern; - dm_show_virt_cart_path = extern; - dm_silent = extern; - dm_trace = extern; - drv = extern; - jtab = extern; - mnt = extern; - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/dm/libDISK_ARCHIVING/i386/Makefile b/usr/src/lib/mms/dm/libDISK_ARCHIVING/i386/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/dm/libDISK_ARCHIVING/i386/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libDISK_ARCHIVING/sparc/Makefile b/usr/src/lib/mms/dm/libDISK_ARCHIVING/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/dm/libDISK_ARCHIVING/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/Makefile b/usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/Makefile.com b/usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/Makefile.com deleted file mode 100644 index c87990e303..0000000000 --- a/usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/Makefile.com +++ /dev/null @@ -1,66 +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. -# -# - -LIBRARY = libHP_Ultrium_3-SCSI.a -VERS = -OBJS_COMMON = dm_HP_Ultrium_3-SCSI.o -OBJS_SHARED = dm_HP_LTO_common.o - -OBJECTS = $(OBJS_COMMON) $(OBJS_SHARED) - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -DMDIR = $(SRC)/lib/mms/dm/libcommon - -SRCS = $(OBJS_COMMON:%.o=$(SRCDIR)/%.c) \ - $(OBJS_SHARED:%.o=$(DMDIR)/%.c) - -LDLIBS += -lc - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/dm/common -I../../../mms/common -CPPFLAGS += -I$(SRC)/uts/common/io/mms/dmd - -.KEEP_STATE: - -all: $(LIBS) - -lint: $(LINTLIB) lintcheck - -pics/%.o: $(DMDIR)/%.c - $(COMPILE.c) -o $@ $< - $(POST_PROCESS_O) - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) diff --git a/usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/common/dm_HP_Ultrium_3-SCSI.c b/usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/common/dm_HP_Ultrium_3-SCSI.c deleted file mode 100644 index 3e6b67815b..0000000000 --- a/usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/common/dm_HP_Ultrium_3-SCSI.c +++ /dev/null @@ -1,120 +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/scsi/impl/uscsi.h> -#include <errno.h> -#include <mms_dmd.h> -#include <mms_trace.h> -#include <dmd_impl.h> -#include <dm_drive.h> -#include <mms_sym.h> - -/* LINTED: static not used */ -static char *_SrcFile = __FILE__; - -/* - * Specify whether the persistent reserve out command is supported or not. - * 0 - not supported - * 1 - supported - * - * If the persistent reserve out command is supported, then it will be used - * to reserve the drive. - * If the persistent reserve out command is not supported, then the reserve - * command will be used to reserve the drive. - */ -int drv_prsv_supported = 1; /* persistent reserve out supported */ - -/* - * specify timeouts for this drive. Time is specified in seconds. - */ -drv_timeout_t drv_timeout = { - (151 *60), /* For really long commands */ - (20 *60), /* Normal commands */ - (1 *60), /* short commands */ -}; - -/* - * Specify the drive type. - * Drive type must begin with "dt_" - */ -char drv_drive_type[] = "dt_LTO3"; - -/* - * drv_density[] - * - Specify density names with their density codes supported by this DM. - * - Densities must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Density names must start with "den_" to avoid conflict with other names. - */ -mms_sym_t drv_density[] = { - "den_LTO3", 0x44, - NULL /* Must be last entry */ -}; - -/* - * drv_shape[] - * - Specify shape names of cartridge types supported by this DM. - * - Shape names must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Shape name must be a well known and published name. - */ -char *drv_shape[] = { - "LTO3", - NULL /* Must be last entry */ -}; - -/* - * drv_shape_den[] - * Specify the shape of a cartridge and the density on it that can be - * written over by a readwrite density. - * All shape names and density names must have been specified in - * drv_density[] and drv_shape[]. - * Each entry of the array consists of: - * {shapename, density on cart, readwrite density}. - * If the density on cartridge is the same as the readwrite density, then - * the drive can read and write with that density. - * If the density on cartridge is read only, then the readwrite density - * is NULL. - * If the readwrite density is not NULL and it is different from the density - * on cartridge, then the drive is able to write over the existing data - * starting from the beginning of medium. - */ - -drv_shape_density_t drv_shape_den[] = { - /* shapename existing den readwrite density */ - /* - * Specify readwrite density - */ - "LTO3", "den_LTO3", "den_LTO3", - - /* - * Specify readonly density - */ - NULL /* Must be last entry */ -}; diff --git a/usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/common/mapfile-vers b/usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/common/mapfile-vers deleted file mode 100644 index 5408476d5b..0000000000 --- a/usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/common/mapfile-vers +++ /dev/null @@ -1,66 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - drv_density; - drv_drive_type; - drv_get_capacity; - drv_load; - drv_prsv_supported; - drv_shape; - drv_shape_den; - drv_timeout; - - char_to_uint32 = extern; - dm_silent = extern; - dm_trace = extern; - drv = extern; - jtab = extern; - mnt = extern; - serr = extern; - - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/i386/Makefile b/usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/i386/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/i386/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/sparc/Makefile b/usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/Makefile b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/Makefile.com b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/Makefile.com deleted file mode 100644 index e6b28330d4..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/Makefile.com +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -LIBRARY = libIBM_ULTRIUM-TD1.a -VERS = -OBJS_COMMON = dm_IBM_ULTRIUM-TD1.o -OBJS_SHARED = dm_IBM_LTO_common.o - -OBJECTS = $(OBJS_COMMON) $(OBJS_SHARED) - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -DMDIR = $(SRC)/lib/mms/dm/libcommon - -SRCS = $(OBJS_COMMON:%.o=$(SRCDIR)/%.c) \ - $(OBJS_SHARED:%.o=$(DMDIR)/%.c) - -LDLIBS += -lc - -CFLAGS += $(CCVERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/dm/common -I../../../mms/common -CPPFLAGS += -I$(SRC)/uts/common/io/mms/dmd - -.KEEP_STATE: - -all: $(LIBS) - -DMLINKS = libIBM_ULT3580-TD1.so libHP_Ultrium_1-SCSI.so - -lint: $(LINTLIB) lintcheck - -pics/%.o: $(DMDIR)/%.c - $(COMPILE.c) -o $@ $< - $(POST_PROCESS_O) - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) $(DMLIBLINKS) diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/common/dm_IBM_ULTRIUM-TD1.c b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/common/dm_IBM_ULTRIUM-TD1.c deleted file mode 100644 index 859a984c01..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/common/dm_IBM_ULTRIUM-TD1.c +++ /dev/null @@ -1,134 +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. - */ - - -#include <sys/types.h> -#include <sys/scsi/impl/uscsi.h> -#include <errno.h> -#include <strings.h> -#include <mms_dmd.h> -#include <mms_trace.h> -#include <dmd_impl.h> -#include <dm_drive.h> -#include <mms_sym.h> - -static char *_SrcFile = __FILE__; - -/* - * Specify whether the persistent reserve out command is supported or not. - * 0 - not supported - * 1 - supported - * - * If the persistent reserve out command is supported, then it will be used - * to reserve the drive. - * If the persistent reserve out command is not supported, then the reserve - * command will be used to reserve the drive. - */ -int drv_prsv_supported = 1; /* persistent reserve out supported */ - -/* - * specify timeouts for this drive. Time is specified in seconds. - */ -drv_timeout_t drv_timeout = { - (151 *60), /* For really long commands */ - (20 *60), /* Normal commands */ - (1 *60), /* short commands */ -}; - -/* - * Specify drive type of this drive - * drv_drive_type must be a string. - */ -char drv_drive_type[] = "dt_LTO1"; - -/* - * drv_density[] - * - Specify density names with their density codes supported by this DM. - * - Densities must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Density names must start with "den_" to avoid conflict with other names. - */ -mms_sym_t drv_density[] = { - "den_LTO1", 0x40, - NULL /* Must be last entry */ -}; - -/* - * drv_shape[] - * - Specify shape names of cartridge types supported by this DM. - * - Shape names must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Shape name must be a well known and published name. - */ -char *drv_shape[] = { - "LTO1", - NULL /* Must be last entry */ -}; - -/* - * drv_shape_den[] - * Specify the shape of a cartridge and the density on it that can be - * written over by a readwrite density. - * All shape names and density names must have been specified in - * drv_density[] and drv_shape[]. - * Each entry of the array consists of: - * {shapename, density on cart, readwrite density}. - * If the density on cartridge is the same as the readwrite density, then - * the drive can read and write with that density. - * If the density on cartridge is read only, then the readwrite density - * is NULL. - * If the readwrite density is not NULL and it is different from the density - * on cartridge, then the drive is able to write over the existing data - * starting from the beginning of medium. - */ - -drv_shape_density_t drv_shape_den[] = { - /* shapename existing den readwrite density */ - /* - * Specify readwrite density - */ - "LTO1", "den_LTO1", "den_LTO1", - - /* - * Specify readonly density - */ - NULL /* Must be last entry */ -}; - -#define DRV_ULT1 "Ultrium 1-SCSI" - -int -drv_init_dev(void) -{ - /* Turn off persistent reservation if HP ULTRUIM 1 drives */ - if (strncmp(drv->drv_vend, "HP", 2) == 0) { - if (strncmp(drv->drv_prod, DRV_ULT1, strlen(DRV_ULT1)) == 0) { - drv->drv_flags &= ~DRV_USE_PRSV; - TRACE((MMS_DEBUG, "Turned off persistent reservation")); - } - } - return (0); -} diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/common/mapfile-vers b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/common/mapfile-vers deleted file mode 100644 index 629b29483a..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/common/mapfile-vers +++ /dev/null @@ -1,66 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - drv_density; - drv_drive_type; - drv_get_capacity; - drv_init_dev; - drv_prsv_supported; - drv_shape; - drv_shape_den; - drv_timeout; - - char_to_uint32 = extern; - dm_silent = extern; - dm_trace = extern; - drv = extern; - jtab = extern; - mnt = extern; - serr = extern; - - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/i386/Makefile b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/i386/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/i386/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/sparc/Makefile b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/Makefile b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/Makefile.com b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/Makefile.com deleted file mode 100644 index 08fe266bf6..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/Makefile.com +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -LIBRARY = libIBM_ULTRIUM-TD2.a -VERS = -OBJS_COMMON = dm_IBM_ULTRIUM-TD2.o -OBJS_SHARED = dm_IBM_LTO_common.o - -OBJECTS = $(OBJS_COMMON) $(OBJS_SHARED) - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -DMDIR = $(SRC)/lib/mms/dm/libcommon - -SRCS = $(OBJS_COMMON:%.o=$(SRCDIR)/%.c) \ - $(OBJS_SHARED:%.o=$(DMDIR)/%.c) - -LDLIBS += -lc - -CFLAGS += $(CCVERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/dm/common -I../../../mms/common -CPPFLAGS += -I$(SRC)/uts/common/io/mms/dmd - -.KEEP_STATE: - -all: $(LIBS) - -DMLINKS = libIBM_ULT3580-TD2.so libHP_Ultrium_2-SCSI.so - -lint: $(LINTLIB) lintcheck - -pics/%.o: $(DMDIR)/%.c - $(COMPILE.c) -o $@ $< - $(POST_PROCESS_O) - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) $(DMLIBLINKS) diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/common/dm_IBM_ULTRIUM-TD2.c b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/common/dm_IBM_ULTRIUM-TD2.c deleted file mode 100644 index 2d7058a595..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/common/dm_IBM_ULTRIUM-TD2.c +++ /dev/null @@ -1,136 +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. - */ - - - -#include <sys/types.h> -#include <sys/scsi/impl/uscsi.h> -#include <errno.h> -#include <strings.h> -#include <mms_dmd.h> -#include <mms_trace.h> -#include <dmd_impl.h> -#include <dm_drive.h> -#include <mms_sym.h> - -static char *_SrcFile = __FILE__; - -/* - * Specify whether the persistent reserve out command is supported or not. - * 0 - not supported - * 1 - supported - * - * If the persistent reserve out command is supported, then it will be used - * to reserve the drive. - * If the persistent reserve out command is not supported, then the reserve - * command will be used to reserve the drive. - */ -int drv_prsv_supported = 1; /* persistent reserve out supported */ - -/* - * specify timeouts for this drive. Time is specified in seconds. - */ -drv_timeout_t drv_timeout = { - (151 *60), /* For really long commands */ - (20 *60), /* Normal commands */ - (1 *60), /* short commands */ -}; - -/* - * Specify the drive type. - * Drive type must begin with "dt_" - */ -char drv_drive_type[] = "dt_LTO2"; - -/* - * drv_density_rw[] - * Specify readwrite densities supported by this DM. - * drv_density_rw must be an array of mms_sym_t. - * Density names must start with "den_" to avoid conflict with other names. - */ -mms_sym_t drv_density[] = { - "den_LTO2", 0x42, - "den_LTO1", 0x40, - NULL /* Must be last entry */ -}; - -/* - * drv_shape[] - * - Specify shape names of cartridge types supported by this DM. - * - Shape names must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Shape name must be a well known and published name. - */ -char *drv_shape[] = { - "LTO2", - "LTO1", - NULL /* Must be last entry */ -}; - -/* - * drv_shape_den[] - * Specify the shape of a cartridge and the density on it that can be - * written over by a readwrite density. - * All shape names and density names must have been specified in - * drv_density[] and drv_shape[]. - * Each entry of the array consists of: - * {shapename, density on cart, readwrite density}. - * If the density on cartridge is the same as the readwrite density, then - * the drive can read and write with that density. - * If the density on cartridge is read only, then the readwrite density - * is NULL. - * If the readwrite density is not NULL and it is different from the density - * on cartridge, then the drive is able to write over the existing data - * starting from the beginning of medium. - */ - -drv_shape_density_t drv_shape_den[] = { - /* shapename existing den readwrite density */ - /* - * Specify readwrite density - */ - "LTO1", "den_LTO1", "den_LTO1", - "LTO2", "den_LTO2", "den_LTO2", - - /* - * Specify readonly density - */ - NULL /* Must be last entry */ -}; - -#define DRV_ULT2 "Ultrium 2-SCSI" - -int -drv_init_dev(void) -{ - /* Turn off persistent reservation if HP ULTRUIM 2 drives */ - if (strncmp(drv->drv_vend, "HP", 2) == 0) { - if (strncmp(drv->drv_prod, DRV_ULT2, strlen(DRV_ULT2)) == 0) { - drv->drv_flags &= ~DRV_USE_PRSV; - TRACE((MMS_DEBUG, "Turned off persistent reservation")); - } - } - return (0); -} diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/common/mapfile-vers b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/common/mapfile-vers deleted file mode 100644 index 84d879f282..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/common/mapfile-vers +++ /dev/null @@ -1,67 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - drv_density; - drv_drive_type; - drv_get_capacity; - drv_init_dev; - drv_prsv_supported; - drv_shape; - drv_shape_den; - drv_timeout; - - char_to_uint32 = extern; - dm_silent = extern; - dm_trace = extern; - drv = extern; - jtab = extern; - mnt = extern; - serr = extern; - - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/i386/Makefile b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/i386/Makefile deleted file mode 100644 index dae0edba27..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/i386/Makefile +++ /dev/null @@ -1,25 +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. -# -# -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/sparc/Makefile b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/Makefile b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/Makefile.com b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/Makefile.com deleted file mode 100644 index 349dc5675e..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/Makefile.com +++ /dev/null @@ -1,68 +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. -# -# - -LIBRARY = libIBM_ULTRIUM-TD3.a -VERS = -OBJS_COMMON = dm_IBM_ULTRIUM-TD3.o -OBJS_SHARED = dm_IBM_LTO_common.o - -OBJECTS = $(OBJS_COMMON) $(OBJS_SHARED) - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -DMDIR = $(SRC)/lib/mms/dm/libcommon - -SRCS = $(OBJS_COMMON:%.o=$(SRCDIR)/%.c) \ - $(OBJS_SHARED:%.o=$(DMDIR)/%.c) - -CFLAGS += $(CCVERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/dm/common -I../../../mms/common -CPPFLAGS += -I$(SRC)/uts/common/io/mms/dmd - -.KEEP_STATE: - -all: $(LIBS) - -DMLINKS = libIBM_ULT3580-TD3.so - -lint: $(LINTLIB) lintcheck - -pics/%.o: $(DMDIR)/%.c - $(COMPILE.c) -o $@ $< - $(POST_PROCESS_O) - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) $(DMLIBLINKS) diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/common/dm_IBM_ULTRIUM-TD3.c b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/common/dm_IBM_ULTRIUM-TD3.c deleted file mode 100644 index 0a65436cd8..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/common/dm_IBM_ULTRIUM-TD3.c +++ /dev/null @@ -1,125 +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/scsi/impl/uscsi.h> -#include <errno.h> -#include <mms_dmd.h> -#include <mms_trace.h> -#include <dmd_impl.h> -#include <dm_drive.h> -#include <mms_sym.h> - -/* LINTED: static unused */ -static char *_SrcFile = __FILE__; - -/* - * Specify whether the persistent reserve out command is supported or not. - * 0 - not supported - * 1 - supported - * - * If the persistent reserve out command is supported, then it will be used - * to reserve the drive. - * If the persistent reserve out command is not supported, then the reserve - * command will be used to reserve the drive. - */ -int drv_prsv_supported = 1; /* persistent reserve out supported */ - -/* - * specify timeouts for this drive. Time is specified in seconds. - */ -drv_timeout_t drv_timeout = { - (151 *60), /* For really long commands */ - (20 *60), /* Normal commands */ - (1 *60), /* short commands */ -}; - -/* - * Specify the drive type. - * Drive type must begin with "dt_" - */ -char drv_drive_type[] = "dt_LTO3"; - -/* - * drv_density[] - * - Specify density names with their density codes supported by this DM. - * - Densities must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Density names must start with "den_" to avoid conflict with other names. - */ -mms_sym_t drv_density[] = { - "den_LTO3", 0x44, - "den_LTO2", 0x42, - "den_LTO1", 0x40, - NULL /* Must be last entry */ -}; - -/* - * drv_shape[] - * - Specify shape names of cartridge types supported by this DM. - * - Shape names must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Shape name must be a well known and published name. - */ -char *drv_shape[] = { - "LTO3", - "LTO2", - "LTO1", - NULL /* Must be last entry */ -}; - -/* - * drv_shape_den[] - * Specify the shape of a cartridge and the density on it that can be - * written over by a readwrite density. - * All shape names and density names must have been specified in - * drv_density[] and drv_shape[]. - * Each entry of the array consists of: - * {shapename, density on cart, readwrite density}. - * If the density on cartridge is the same as the readwrite density, then - * the drive can read and write with that density. - * If the density on cartridge is read only, then the readwrite density - * is NULL. - * If the readwrite density is not NULL and it is different from the density - * on cartridge, then the drive is able to write over the existing data - * starting from the beginning of medium. - */ - -drv_shape_density_t drv_shape_den[] = { - /* shapename existing den readwrite density */ - /* - * Specify readwrite density - */ - "LTO3", "den_LTO3", "den_LTO3", - "LTO2", "den_LTO2", "den_LTO2", - - /* - * Specify readonly density - */ - "LTO1", "den_LTO1", NULL, - NULL /* Must be last entry */ -}; diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/common/mapfile-vers b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/common/mapfile-vers deleted file mode 100644 index 74bd71d505..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/common/mapfile-vers +++ /dev/null @@ -1,66 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - drv_density; - drv_drive_type; - drv_get_capacity; - drv_prsv_supported; - drv_shape; - drv_shape_den; - drv_timeout; - - char_to_uint32 = extern; - dm_silent = extern; - dm_trace = extern; - drv = extern; - jtab = extern; - mnt = extern; - serr = extern; - - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/i386/Makefile b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/i386/Makefile deleted file mode 100644 index d77b753d64..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/i386/Makefile +++ /dev/null @@ -1,26 +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. -# -# -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/sparc/Makefile b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/Makefile b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/Makefile.com b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/Makefile.com deleted file mode 100644 index 9c97b83370..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/Makefile.com +++ /dev/null @@ -1,68 +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. -# -# - -LIBRARY = libIBM_ULTRIUM-TD4.a -VERS = -OBJS_COMMON = dm_IBM_ULTRIUM-TD4.o -OBJS_SHARED = dm_IBM_LTO_common.o - -OBJECTS = $(OBJS_COMMON) $(OBJS_SHARED) - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -DMDIR = $(SRC)/lib/mms/dm/libcommon - -SRCS = $(OBJS_COMMON:%.o=$(SRCDIR)/%.c) \ - $(OBJS_SHARED:%.o=$(DMDIR)/%.c) - -CFLAGS += $(CCVERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/dm/common -I../../../mms/common -CPPFLAGS += -I$(SRC)/uts/common/io/mms/dmd - -.KEEP_STATE: - -all: $(LIBS) - -DMLINKS = libIBM_ULT3580-TD4.so libHP_Ultrium_4-SCSI.so - -lint: $(LINTLIB) lintcheck - -pics/%.o: $(DMDIR)/%.c - $(COMPILE.c) -o $@ $< - $(POST_PROCESS_O) - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) $(DMLIBLINKS) diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/common/dm_IBM_ULTRIUM-TD4.c b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/common/dm_IBM_ULTRIUM-TD4.c deleted file mode 100644 index 745b23e292..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/common/dm_IBM_ULTRIUM-TD4.c +++ /dev/null @@ -1,124 +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/scsi/impl/uscsi.h> -#include <errno.h> -#include <mms_dmd.h> -#include <mms_trace.h> -#include <dmd_impl.h> -#include <dm_drive.h> -#include <mms_sym.h> - -/* LINTED: static unused */ -static char *_SrcFile = __FILE__; - -/* - * Specify whether the persistent reserve out command is supported or not. - * 0 - not supported - * 1 - supported - * - * If the persistent reserve out command is supported, then it will be used - * to reserve the drive. - * If the persistent reserve out command is not supported, then the reserve - * command will be used to reserve the drive. - */ -int drv_prsv_supported = 1; /* persistent reserve out supported */ - -/* - * specify timeouts for this drive. Time is specified in seconds. - */ -drv_timeout_t drv_timeout = { - (151 *60), /* For really long commands */ - (20 *60), /* Normal commands */ - (1 *60), /* short commands */ -}; - -/* - * Specify the drive type. - * Drive type must begin with "dt_" - */ -char drv_drive_type[] = "dt_LTO4"; - -/* - * drv_density[] - * - Specify density names with their density codes supported by this DM. - * - Densities must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Density names must start with "den_" to avoid conflict with other names. - */ -mms_sym_t drv_density[] = { - "den_LTO4", 0x46, - "den_LTO3", 0x44, - "den_LTO2", 0x42, - NULL /* Must be last entry */ -}; - -/* - * drv_shape[] - * - Specify shape names of cartridge types supported by this DM. - * - Shape names must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Shape name must be a well known and published name. - */ -char *drv_shape[] = { - "LTO4", - "LTO3", - "LTO2", - NULL /* Must be last entry */ -}; - -/* - * drv_shape_den[] - * Specify the shape of a cartridge and the density on it that can be - * written over by a readwrite density. - * All shape names and density names must have been specified in - * drv_density[] and drv_shape[]. - * Each entry of the array consists of: - * {shapename, density on cart, readwrite density}. - * If the density on cartridge is the same as the readwrite density, then - * the drive can read and write with that density. - * If the density on cartridge is read only, then the readwrite density - * is NULL. - * If the readwrite density is not NULL and it is different from the density - * on cartridge, then the drive is able to write over the existing data - * starting from the beginning of medium. - */ - -drv_shape_density_t drv_shape_den[] = { - /* shapename existing den readwrite density */ - /* - * Specify readwrite density - */ - "LTO4", "den_LTO4", "den_LTO4", - "LTO3", "den_LTO3", "den_LTO3", - /* - * Specify readonly density - */ - "LTO2", "den_LTO2", NULL, - NULL /* Must be last entry */ -}; diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/common/mapfile-vers b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/common/mapfile-vers deleted file mode 100644 index 74bd71d505..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/common/mapfile-vers +++ /dev/null @@ -1,66 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - drv_density; - drv_drive_type; - drv_get_capacity; - drv_prsv_supported; - drv_shape; - drv_shape_den; - drv_timeout; - - char_to_uint32 = extern; - dm_silent = extern; - dm_trace = extern; - drv = extern; - jtab = extern; - mnt = extern; - serr = extern; - - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/i386/Makefile b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/i386/Makefile deleted file mode 100644 index d77b753d64..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/i386/Makefile +++ /dev/null @@ -1,26 +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. -# -# -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/sparc/Makefile b/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libQUANTUM_SDLT600/Makefile b/usr/src/lib/mms/dm/libQUANTUM_SDLT600/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/dm/libQUANTUM_SDLT600/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/dm/libQUANTUM_SDLT600/Makefile.com b/usr/src/lib/mms/dm/libQUANTUM_SDLT600/Makefile.com deleted file mode 100644 index d6c3a742dc..0000000000 --- a/usr/src/lib/mms/dm/libQUANTUM_SDLT600/Makefile.com +++ /dev/null @@ -1,59 +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. -# -# - -LIBRARY = libQUANTUM_SDLT600.a -VERS = -OBJECTS = dm_QUANTUM_SDLT600.o - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -SRCS = $(OBJECTS:%.o=$(SRCDIR)/%.c) - -LDLIBS += -lc -LDLIBS += -L$(SRC)/lib/mms/mms/$(MACH) -lmms - -CFLAGS += $(CCVERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/dm/common -I../../../mms/common -CPPFLAGS += -I$(SRC)/uts/common/io/mms/dmd - -.KEEP_STATE: - -all: $(LIBS) - -lint: $(LINTLIB) lintcheck - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) diff --git a/usr/src/lib/mms/dm/libQUANTUM_SDLT600/common/dm_QUANTUM_SDLT600.c b/usr/src/lib/mms/dm/libQUANTUM_SDLT600/common/dm_QUANTUM_SDLT600.c deleted file mode 100644 index c7b42f918d..0000000000 --- a/usr/src/lib/mms/dm/libQUANTUM_SDLT600/common/dm_QUANTUM_SDLT600.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - -#include <sys/types.h> -#include <sys/scsi/impl/uscsi.h> -#include <string.h> -#include <errno.h> -#include <mms_dmd.h> -#include <mms_trace.h> -#include <dmd_impl.h> -#include <dm_drive.h> -#include <mms_sym.h> - -static char *_SrcFile = __FILE__; - -/* - * Specify whether the persistent reserve out command is supported or not. - * 0 - not supported - * 1 - supported - * - * If the persistent reserve out command is supported, then it will be used - * to reserve the drive. - * If the persistent reserve out command is not supported, then the reserve - * command will be used to reserve the drive. - */ -int drv_prsv_supported = 1; /* persistent reserve out supported */ - -/* - * specify timeouts for this drive. Time is specified in seconds. - */ -drv_timeout_t drv_timeout = { - (151 *60), /* For really long commands */ - (20 *60), /* Normal commands */ - (1 *60), /* short commands */ -}; - -/* - * Specify drive type of this drive - * drv_drive_type must be a string. - */ -char drv_drive_type[] = "dt_SDLT600"; - -/* - * drv_density[] - * - Specify density names with their density codes supported by this DM. - * - Densities must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Density names must start with "den_" to avoid conflict with other names. - */ -mms_sym_t drv_density[] = { - "den_SDLT2", 0x4A, - "den_SDLT1_220", 0x48, - "den_SDLT1_320", 0x49, - "den_VStape_160", 0x50, - NULL /* Must be last entry */ -}; - -/* - * drv_shape[] - * - Specify shape names of cartridge types supported by this DM. - * - Shape names must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Shape name must be a well known and published name. - */ -char *drv_shape[] = { - "SDLT2", - "SDLT1", - "VStape1", - NULL /* Must be last entry */ -}; - -/* - * drv_shape_den[] - * Specify the shape of a cartridge and the density on it that can be - * written over by a readwrite density. - * All shape names and density names must have been specified in - * drv_density[] and drv_shape[]. - * Each entry of the array consists of: - * {shapename, density on cart, readwrite density}. - * If the density on cartridge is the same as the readwrite density, then - * the drive can read and write with that density. - * If the density on cartridge is read only, then the readwrite density - * is NULL. - * If the readwrite density is not NULL and it is different from the density - * on cartridge, then the drive is able to write over the existing data - * starting from the beginning of medium. - */ - -drv_shape_density_t drv_shape_den[] = { - /* shapename existing den readwrite density */ - /* - * Specify readwrite density - */ - "SDLT2", "den_SDLT2", "den_SDLT2", - - /* - * Specify readonly density - */ - "VStape1", "den_VStape_160", NULL, - "SDLT1", "den_SDLT1_220", NULL, - "SDLT1", "den_SDLT1_320", NULL, - NULL /* Must be last entry */ -}; - -int -drv_get_capacity(mms_capacity_t *cap) -{ - uchar_t buf[30]; - int off; - int i; - uint32_t code; - uint32_t max = 0; - uint32_t avail = 0; - - if (DRV_CALL(drv_read_attribute, - (buf, sizeof (buf), 0x00, 0x00)) != 0) { - return (EIO); - } - - for (i = 0; i < 2; i++) { - off = 4 + i * 13; - char_to_uint32(buf + off, 2, &code); - if (code == 0x0000) { /* capacity left */ - char_to_uint32(buf + off + 5, 8, &avail); - cap->mms_avail = avail; - break; - } - } - - for (i = 0; i < 2; i++) { - off = 4 + i * 13; - char_to_uint32(buf + off, 2, &code); - if (code == 0x0001) { /* Max capacity */ - char_to_uint32(buf + off + 5, 8, &max); - cap->mms_max = max; - break; - } - } - - if (max > 0) { - cap->mms_pc_avail = (avail * 100) / max; - if (cap->mms_pc_avail > 100) { - cap->mms_pc_avail = 100; - } - } else { - cap->mms_pc_avail = 0; - } - - TRACE((MMS_INFO, "Capacity: max %lld, avail %lld, avail %d%%", - cap->mms_max, cap->mms_avail, cap->mms_pc_avail)); - - return (0); -} - -int -drv_read_attribute(uchar_t *buf, int32_t len, int servact, int32_t attr) -{ - struct uscsi_cmd us; - uchar_t cdb[] = - { 0x8C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x64, 0x00, 0x00 }; - char dumpbuf[1024]; - - (void) memset(&us, 0, sizeof (us)); - us.uscsi_flags = USCSI_READ; - us.uscsi_cdb = (char *)cdb; - us.uscsi_cdblen = sizeof (cdb); - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - us.uscsi_bufaddr = (char *)buf; - us.uscsi_buflen = len; - - cdb[1] = (servact & 0x1F); - int32_to_char(len, cdb + 10, 4); - int32_to_char(attr, cdb + 8, 2); - - TRACE((MMS_DEBUG, "Read attribute")); - if (dm_uscsi(&us)) { - return (EIO); - } - if (serr->se_status != STATUS_GOOD) { - return (EIO); - } - (void) mms_trace_dump((char *)buf, len, dumpbuf, sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "read attribute data:\n%s", dumpbuf)); - - return (0); -} diff --git a/usr/src/lib/mms/dm/libQUANTUM_SDLT600/common/mapfile-vers b/usr/src/lib/mms/dm/libQUANTUM_SDLT600/common/mapfile-vers deleted file mode 100644 index 3759a8bba5..0000000000 --- a/usr/src/lib/mms/dm/libQUANTUM_SDLT600/common/mapfile-vers +++ /dev/null @@ -1,68 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - drv_density; - drv_drive_type; - drv_get_capacity; - drv_prsv_supported; - drv_read_attribute; - drv_shape; - drv_shape_den; - drv_timeout; - - char_to_uint32 = extern; - dm_silent = extern; - dm_trace = extern; - dm_uscsi = extern; - drv = extern; - int32_to_char = extern; - jtab = extern; - mnt = extern; - serr = extern; - - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/dm/libQUANTUM_SDLT600/i386/Makefile b/usr/src/lib/mms/dm/libQUANTUM_SDLT600/i386/Makefile deleted file mode 100644 index d77b753d64..0000000000 --- a/usr/src/lib/mms/dm/libQUANTUM_SDLT600/i386/Makefile +++ /dev/null @@ -1,26 +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. -# -# -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libQUANTUM_SDLT600/sparc/Makefile b/usr/src/lib/mms/dm/libQUANTUM_SDLT600/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/dm/libQUANTUM_SDLT600/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/Makefile b/usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/Makefile.com b/usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/Makefile.com deleted file mode 100644 index 0cefb650c3..0000000000 --- a/usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/Makefile.com +++ /dev/null @@ -1,66 +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. -# -# - -LIBRARY = libSEAGATE_ULTRIUM06242-XXX.a -VERS = -OBJS_COMMON = dm_SEAGATE_ULTRIUM06242-XXX.o -OBJS_SHARED = dm_SEAGATELTO_common.o - -OBJECTS = $(OBJS_COMMON) $(OBJS_SHARED) - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -DMDIR = $(SRC)/lib/mms/dm/libcommon - -SRCS = $(OBJS_COMMON:%.o=$(SRCDIR)/%.c) \ - $(OBJS_SHARED:%.o=$(DMDIR)/%.c) - -CFLAGS += $(CCVERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/dm/common -I../../../mms/common -CPPFLAGS += -I$(SRC)/uts/common/io/mms/dmd - -.KEEP_STATE: - -all: $(LIBS) - -lint: $(LINTLIB) lintcheck - -pics/%.o: $(DMDIR)/%.c - $(COMPILE.c) -o $@ $< - $(POST_PROCESS_O) - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) diff --git a/usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/common/dm_SEAGATE_ULTRIUM06242-XXX.c b/usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/common/dm_SEAGATE_ULTRIUM06242-XXX.c deleted file mode 100644 index fe165b3644..0000000000 --- a/usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/common/dm_SEAGATE_ULTRIUM06242-XXX.c +++ /dev/null @@ -1,119 +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/scsi/impl/uscsi.h> -#include <errno.h> -#include <mms_dmd.h> -#include <mms_trace.h> -#include <dmd_impl.h> -#include <dm_drive.h> -#include <mms_sym.h> - -/* LINTED: static unused */ -static char *_SrcFile = __FILE__; - -/* - * Specify whether the persistent reserve out command is supported or not. - * 0 - not supported - * 1 - supported - * - * If the persistent reserve out command is supported, then it will be used - * to reserve the drive. - * If the persistent reserve out command is not supported, then the reserve - * command will be used to reserve the drive. - */ -int drv_prsv_supported = 0; /* persistent reserve out supported */ - -/* - * specify timeouts for this drive. Time is specified in seconds. - */ -drv_timeout_t drv_timeout = { - (151 *60), /* For really long commands */ - (20 *60), /* Normal commands */ - (1 *60), /* short commands */ -}; - -/* - * Specify the drive type. - * Drive type must begin with "dt_" - */ -char drv_drive_type[] = "dt_LTO1"; - -/* - * drv_density[] - * - Specify density names with their density codes supported by this DM. - * - Densities must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Density names must start with "den_" to avoid conflict with other names. - */ -mms_sym_t drv_density[] = { - "den_LTO1", 0x00, - NULL, /* Must be the last entry */ -}; - -/* - * drv_shape[] - * - Specify shape names of cartridge types supported by this DM. - * - Shape names must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Shape name must be a well known and published name. - */ -char *drv_shape[] = { - "LTO1", - NULL /* Must be last entry */ -}; - -/* - * drv_shape_den[] - * Specify the shape of a cartridge and the density on it that can be - * written over by a readwrite density. - * All shape names and density names must have been specified in - * drv_density[] and drv_shape[]. - * Each entry of the array consists of: - * {shapename, density on cart, readwrite density}. - * If the density on cartridge is the same as the readwrite density, then - * the drive can read and write with that density. - * If the density on cartridge is read only, then the readwrite density - * is NULL. - * If the readwrite density is not NULL and it is different from the density - * on cartridge, then the drive is able to write over the existing data - * starting from the beginning of medium. - */ - -drv_shape_density_t drv_shape_den[] = { - /* shapename existing den readwrite density */ - /* - * Specify readwrite density - */ - "LTO1", "den_LTO1", "den_LTO1", - - /* - * Specify readonly density - */ - NULL /* Must be last entry */ -}; diff --git a/usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/common/mapfile-vers b/usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/common/mapfile-vers deleted file mode 100644 index 5abe25e99c..0000000000 --- a/usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/common/mapfile-vers +++ /dev/null @@ -1,65 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - drv_density; - drv_drive_type; - drv_get_capacity; - drv_prsv_supported; - drv_shape; - drv_shape_den; - drv_timeout; - - char_to_uint32 = extern; - dm_silent = extern; - dm_trace = extern; - drv = extern; - jtab = extern; - mnt = extern; - serr = extern; - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/i386/Makefile b/usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/i386/Makefile deleted file mode 100644 index d77b753d64..0000000000 --- a/usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/i386/Makefile +++ /dev/null @@ -1,26 +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. -# -# -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/sparc/Makefile b/usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libSTK_9840/Makefile b/usr/src/lib/mms/dm/libSTK_9840/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/dm/libSTK_9840/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/dm/libSTK_9840/Makefile.com b/usr/src/lib/mms/dm/libSTK_9840/Makefile.com deleted file mode 100644 index 9863ab98cc..0000000000 --- a/usr/src/lib/mms/dm/libSTK_9840/Makefile.com +++ /dev/null @@ -1,68 +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. -# -# - -LIBRARY = libSTK_9840.a -VERS = -OBJS_COMMON = dm_STK_9840.o -OBJS_SHARED = dm_9x40_common.o - -OBJECTS = $(OBJS_COMMON) $(OBJS_SHARED) - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -DMDIR = $(SRC)/lib/mms/dm/libcommon - -SRCS = $(OBJS_COMMON:%.o=$(SRCDIR)/%.c) \ - $(OBJS_SHARED:%.o=$(DMDIR)/%.c) - -LDLIBS += -lc - -CFLAGS += $(CCVERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/dm/common -I../../../mms/common -CPPFLAGS += -I$(SRC)/uts/common/io/mms/dmd - -.KEEP_STATE: - -all: $(LIBS) - -lint: $(LINTLIB) lintcheck - -pics/%.o: $(DMDIR)/%.c - $(COMPILE.c) -o $@ $< - $(POST_PROCESS_O) - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) diff --git a/usr/src/lib/mms/dm/libSTK_9840/common/dm_STK_9840.c b/usr/src/lib/mms/dm/libSTK_9840/common/dm_STK_9840.c deleted file mode 100644 index da4e92adec..0000000000 --- a/usr/src/lib/mms/dm/libSTK_9840/common/dm_STK_9840.c +++ /dev/null @@ -1,118 +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/scsi/impl/uscsi.h> -#include <errno.h> -#include <mms_dmd.h> -#include <mms_trace.h> -#include <dmd_impl.h> -#include <dm_drive.h> -#include <mms_sym.h> - -/* LINTED: static unused */ -static char *_SrcFile = __FILE__; - -/* - * Specify whether the persistent reserve out command is supported or not. - * 0 - not supported - * 1 - supported - * - * If the persistent reserve out command is supported, then it will be used - * to reserve the drive. - * If the persistent reserve out command is not supported, then the reserve - * command will be used to reserve the drive. - */ -int drv_prsv_supported = 1; /* persistent reserve out supported */ - -/* - * specify timeouts for this drive. Time is specified in seconds. - */ -drv_timeout_t drv_timeout = { - (151 *60), /* For really long commands */ - (20 *60), /* Normal commands */ - (1 *60), /* short commands */ -}; - -/* - * Specify the drive type. - * Drive type must begin with "dt_" - */ -char drv_drive_type[] = "dt_9840"; - -/* - * drv_density_rw[] - * Specify readwrite densities supported by this DM. - * drv_density_rw must be an array of mms_sym_t. - * Density names must start with "den_" to avoid conflict with other names. - */ -mms_sym_t drv_density[] = { - "den_9840", 0x42, - "den_T9840C", 0x45, - NULL /* Must be last entry */ -}; - -/* - * drv_shape[] - * - Specify shape names of cartridge types supported by this DM. - * - Shape names must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Shape name must be a well known and published name. - */ -char *drv_shape[] = { - "9840", - NULL /* Must be last entry */ -}; - -/* - * drv_shape_den[] - * Specify the shape of a cartridge and the density on it that can be - * written over by a readwrite density. - * All shape names and density names must have been specified in - * drv_density[] and drv_shape[]. - * Each entry of the array consists of: - * {shapename, density on cart, readwrite density}. - * If the density on cartridge is the same as the readwrite density, then - * the drive can read and write with that density. - * If the density on cartridge is read only, then the readwrite density - * is NULL. - * If the readwrite density is not NULL and it is different from the density - * on cartridge, then the drive is able to write over the existing data - * starting from the beginning of medium. - */ - -drv_shape_density_t drv_shape_den[] = { - /* shapename existing den readwrite density */ - /* - * Specify readwrite density - */ - "9840", "den_9840", "den_9840", - "9840", "den_T9840C", "den_9840", - /* - * Specify readonly density - */ - NULL /* Must be last entry */ -}; diff --git a/usr/src/lib/mms/dm/libSTK_9840/common/mapfile-vers b/usr/src/lib/mms/dm/libSTK_9840/common/mapfile-vers deleted file mode 100644 index 01fefa59e7..0000000000 --- a/usr/src/lib/mms/dm/libSTK_9840/common/mapfile-vers +++ /dev/null @@ -1,69 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - drv_density; - drv_drive_type; - drv_get_avail_capacity; - drv_get_capacity; - drv_load; - drv_prsv_supported; - drv_shape; - drv_shape_den; - drv_timeout; - - char_to_uint32 = extern; - dm_get_log_sense_parm = extern; - dm_silent = extern; - dm_trace = extern; - drv = extern; - jtab = extern; - mnt = extern; - serr = extern; - - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/dm/libSTK_9840/i386/Makefile b/usr/src/lib/mms/dm/libSTK_9840/i386/Makefile deleted file mode 100644 index d77b753d64..0000000000 --- a/usr/src/lib/mms/dm/libSTK_9840/i386/Makefile +++ /dev/null @@ -1,26 +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. -# -# -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libSTK_9840/sparc/Makefile b/usr/src/lib/mms/dm/libSTK_9840/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/dm/libSTK_9840/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libSTK_T9840B/Makefile b/usr/src/lib/mms/dm/libSTK_T9840B/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9840B/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/dm/libSTK_T9840B/Makefile.com b/usr/src/lib/mms/dm/libSTK_T9840B/Makefile.com deleted file mode 100644 index 4250f809a9..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9840B/Makefile.com +++ /dev/null @@ -1,68 +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. -# -# - -LIBRARY = libSTK_T9840B.a -VERS = -OBJS_COMMON = dm_STK_T9840B.o -OBJS_SHARED = dm_9x40_common.o - -OBJECTS = $(OBJS_COMMON) $(OBJS_SHARED) - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -DMDIR = $(SRC)/lib/mms/dm/libcommon - -SRCS = $(OBJS_COMMON:%.o=$(SRCDIR)/%.c) \ - $(OBJS_SHARED:%.o=$(DMDIR)/%.c) - -LDLIBS += -lc - -CFLAGS += $(CCVERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/dm/common -I../../../mms/common -CPPFLAGS += -I$(SRC)/uts/common/io/mms/dmd - -.KEEP_STATE: - -all: $(LIBS) - -lint: $(LINTLIB) lintcheck - -pics/%.o: $(DMDIR)/%.c - $(COMPILE.c) -o $@ $< - $(POST_PROCESS_O) - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) diff --git a/usr/src/lib/mms/dm/libSTK_T9840B/common/dm_STK_T9840B.c b/usr/src/lib/mms/dm/libSTK_T9840B/common/dm_STK_T9840B.c deleted file mode 100644 index 8e639716fb..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9840B/common/dm_STK_T9840B.c +++ /dev/null @@ -1,118 +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/scsi/impl/uscsi.h> -#include <errno.h> -#include <mms_dmd.h> -#include <mms_trace.h> -#include <dmd_impl.h> -#include <dm_drive.h> -#include <mms_sym.h> - -/* LINTED: static unused */ -static char *_SrcFile = __FILE__; - -/* - * Specify whether the persistent reserve out command is supported or not. - * 0 - not supported - * 1 - supported - * - * If the persistent reserve out command is supported, then it will be used - * to reserve the drive. - * If the persistent reserve out command is not supported, then the reserve - * command will be used to reserve the drive. - */ -int drv_prsv_supported = 1; /* persistent reserve out supported */ - -/* - * specify timeouts for this drive. Time is specified in seconds. - */ -drv_timeout_t drv_timeout = { - (151 *60), /* For really long commands */ - (20 *60), /* Normal commands */ - (1 *60), /* short commands */ -}; - -/* - * Specify the drive type. - * Drive type must begin with "dt_" - */ -char drv_drive_type[] = "dt_T9840B"; - -/* - * drv_density_rw[] - * Specify readwrite densities supported by this DM. - * drv_density_rw must be an array of mms_sym_t. - * Density names must start with "den_" to avoid conflict with other names. - */ -mms_sym_t drv_density[] = { - "den_9840", 0x42, - "den_T9840C", 0x45, - NULL /* Must be last entry */ -}; - -/* - * drv_shape[] - * - Specify shape names of cartridge types supported by this DM. - * - Shape names must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Shape name must be a well known and published name. - */ -char *drv_shape[] = { - "9840", - NULL /* Must be last entry */ -}; - -/* - * drv_shape_den[] - * Specify the shape of a cartridge and the density on it that can be - * written over by a readwrite density. - * All shape names and density names must have been specified in - * drv_density[] and drv_shape[]. - * Each entry of the array consists of: - * {shapename, density on cart, readwrite density}. - * If the density on cartridge is the same as the readwrite density, then - * the drive can read and write with that density. - * If the density on cartridge is read only, then the readwrite density - * is NULL. - * If the readwrite density is not NULL and it is different from the density - * on cartridge, then the drive is able to write over the existing data - * starting from the beginning of medium. - */ - -drv_shape_density_t drv_shape_den[] = { - /* shapename existing den readwrite density */ - /* - * Specify readwrite density - */ - "9840", "den_9840", "den_9840", - "9840", "den_T9840C", "den_9840", - /* - * Specify readonly density - */ - NULL /* Must be last entry */ -}; diff --git a/usr/src/lib/mms/dm/libSTK_T9840B/common/mapfile-vers b/usr/src/lib/mms/dm/libSTK_T9840B/common/mapfile-vers deleted file mode 100644 index 87f7b2e786..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9840B/common/mapfile-vers +++ /dev/null @@ -1,68 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - drv_density; - drv_drive_type; - drv_get_avail_capacity; - drv_get_capacity; - drv_load; - drv_prsv_supported; - drv_shape; - drv_shape_den; - drv_timeout; - - char_to_uint32 = extern; - dm_get_log_sense_parm = extern; - dm_silent = extern; - dm_trace = extern; - drv = extern; - jtab = extern; - mnt = extern; - serr = extern; - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/dm/libSTK_T9840B/i386/Makefile b/usr/src/lib/mms/dm/libSTK_T9840B/i386/Makefile deleted file mode 100644 index d77b753d64..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9840B/i386/Makefile +++ /dev/null @@ -1,26 +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. -# -# -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libSTK_T9840B/sparc/Makefile b/usr/src/lib/mms/dm/libSTK_T9840B/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9840B/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libSTK_T9840C/Makefile b/usr/src/lib/mms/dm/libSTK_T9840C/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9840C/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/dm/libSTK_T9840C/Makefile.com b/usr/src/lib/mms/dm/libSTK_T9840C/Makefile.com deleted file mode 100644 index 40eefa093f..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9840C/Makefile.com +++ /dev/null @@ -1,68 +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. -# -# - -LIBRARY = libSTK_T9840C.a -VERS = -OBJS_COMMON = dm_STK_T9840C.o -OBJS_SHARED = dm_9x40_common.o - -OBJECTS = $(OBJS_COMMON) $(OBJS_SHARED) - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -DMDIR = $(SRC)/lib/mms/dm/libcommon - -SRCS = $(OBJS_COMMON:%.o=$(SRCDIR)/%.c) \ - $(OBJS_SHARED:%.o=$(DMDIR)/%.c) - -LDLIBS += -lc - -CFLAGS += $(CCVERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/dm/common -I../../../mms/common -CPPFLAGS += -I$(SRC)/uts/common/io/mms/dmd - -.KEEP_STATE: - -all: $(LIBS) - -lint: $(LINTLIB) lintcheck - -pics/%.o: $(DMDIR)/%.c - $(COMPILE.c) -o $@ $< - $(POST_PROCESS_O) - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) diff --git a/usr/src/lib/mms/dm/libSTK_T9840C/common/dm_STK_T9840C.c b/usr/src/lib/mms/dm/libSTK_T9840C/common/dm_STK_T9840C.c deleted file mode 100644 index a18260d813..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9840C/common/dm_STK_T9840C.c +++ /dev/null @@ -1,125 +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/scsi/impl/uscsi.h> -#include <errno.h> -#include <mms_dmd.h> -#include <mms_trace.h> -#include <dmd_impl.h> -#include <dm_drive.h> -#include <mms_sym.h> - -/* LINTED: static unused */ -static char *_SrcFile = __FILE__; - -/* - * Specify whether the persistent reserve out command is supported or not. - * 0 - not supported - * 1 - supported - * - * If the persistent reserve out command is supported, then it will be used - * to reserve the drive. - * If the persistent reserve out command is not supported, then the reserve - * command will be used to reserve the drive. - */ -int drv_prsv_supported = 1; /* persistent reserve out supported */ - -/* - * specify timeouts for this drive. Time is specified in seconds. - */ -drv_timeout_t drv_timeout = { - (151 *60), /* For really long commands */ - (20 *60), /* Normal commands */ - (1 *60), /* short commands */ -}; - -/* - * Specify the drive type. - * Drive type must begin with "dt_" - */ -char drv_drive_type[] = "dt_T9840C"; - -/* - * drv_density[] - * - Specify density names with their density codes supported by this DM. - * - Densities must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Density names must start with "den_" to avoid conflict with other names. - */ -mms_sym_t drv_density[] = { - "den_T9840C", 0x45, - "den_9840", 0x42, - NULL, /* Must be the last entry */ -}; - -/* - * drv_shape[] - * - Specify shape names of cartridge types supported by this DM. - * - Shape names must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Shape name must be a well known and published name. - */ -char *drv_shape[] = { - "9840", - NULL /* Must be last entry */ -}; - - -/* - * drv_shape_den[] - * Specify the shape of a cartridge and the density on it that can be - * written over by a readwrite density. - * All shape names and density names must have been specified in - * drv_density[] and drv_shape[]. - * Each entry of the array consists of: - * {shapename, density on cart, readwrite density}. - * If the density on cartridge is the same as the readwrite density, then - * the drive can read and write with that density. - * If the density on cartridge is read only, then the readwrite density - * is NULL. - * If the readwrite density is not NULL and it is different from the density - * on cartridge, then the drive is able to write over the existing data - * starting from the beginning of medium. - */ - -drv_shape_density_t drv_shape_den[] = { - /* shapename existing den readwrite density */ - /* - * Specify readwrite density - */ - "9840", "den_T9840C", "den_T9840C", - /* - * Specify writeover density - */ - "9840", "den_9840", "den_T9840C", - /* - * Specify readonly density - */ - "9840", "den_9840", NULL, - NULL /* Must be last entry */ -}; diff --git a/usr/src/lib/mms/dm/libSTK_T9840C/common/mapfile-vers b/usr/src/lib/mms/dm/libSTK_T9840C/common/mapfile-vers deleted file mode 100644 index 87f7b2e786..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9840C/common/mapfile-vers +++ /dev/null @@ -1,68 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - drv_density; - drv_drive_type; - drv_get_avail_capacity; - drv_get_capacity; - drv_load; - drv_prsv_supported; - drv_shape; - drv_shape_den; - drv_timeout; - - char_to_uint32 = extern; - dm_get_log_sense_parm = extern; - dm_silent = extern; - dm_trace = extern; - drv = extern; - jtab = extern; - mnt = extern; - serr = extern; - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/dm/libSTK_T9840C/i386/Makefile b/usr/src/lib/mms/dm/libSTK_T9840C/i386/Makefile deleted file mode 100644 index d77b753d64..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9840C/i386/Makefile +++ /dev/null @@ -1,26 +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. -# -# -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libSTK_T9840C/sparc/Makefile b/usr/src/lib/mms/dm/libSTK_T9840C/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9840C/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libSTK_T9940A/Makefile b/usr/src/lib/mms/dm/libSTK_T9940A/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9940A/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/dm/libSTK_T9940A/Makefile.com b/usr/src/lib/mms/dm/libSTK_T9940A/Makefile.com deleted file mode 100644 index 08b1d66455..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9940A/Makefile.com +++ /dev/null @@ -1,68 +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. -# -# - -LIBRARY = libSTK_T9940A.a -VERS = -OBJS_COMMON = dm_STK_T9940A.o -OBJS_SHARED = dm_9x40_common.o - -OBJECTS = $(OBJS_COMMON) $(OBJS_SHARED) - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -DMDIR = $(SRC)/lib/mms/dm/libcommon - -SRCS = $(OBJS_COMMON:%.o=$(SRCDIR)/%.c) \ - $(OBJS_SHARED:%.o=$(DMDIR)/%.c) - -LDLIBS += -lc - -CFLAGS += $(CCVERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/dm/common -I../../../mms/common -CPPFLAGS += -I$(SRC)/uts/common/io/mms/dmd - -.KEEP_STATE: - -all: $(LIBS) - -lint: $(LINTLIB) lintcheck - -pics/%.o: $(DMDIR)/%.c - $(COMPILE.c) -o $@ $< - $(POST_PROCESS_O) - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) diff --git a/usr/src/lib/mms/dm/libSTK_T9940A/common/dm_STK_T9940A.c b/usr/src/lib/mms/dm/libSTK_T9940A/common/dm_STK_T9940A.c deleted file mode 100644 index eff47f06aa..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9940A/common/dm_STK_T9940A.c +++ /dev/null @@ -1,118 +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/scsi/impl/uscsi.h> -#include <errno.h> -#include <mms_dmd.h> -#include <mms_trace.h> -#include <dmd_impl.h> -#include <dm_drive.h> -#include <mms_sym.h> - -/* LINTED: static unused */ -static char *_SrcFile = __FILE__; - -/* - * Specify whether the persistent reserve out command is supported or not. - * 0 - not supported - * 1 - supported - * - * If the persistent reserve out command is supported, then it will be used - * to reserve the drive. - * If the persistent reserve out command is not supported, then the reserve - * command will be used to reserve the drive. - */ -int drv_prsv_supported = 1; /* persistent reserve out supported */ - -/* - * specify timeouts for this drive. Time is specified in seconds. - */ -drv_timeout_t drv_timeout = { - (151 *60), /* For really long commands */ - (20 *60), /* Normal commands */ - (1 *60), /* short commands */ -}; - -/* - * Specify the drive type. - * Drive type must begin with "dt_" - */ -char drv_drive_type[] = "dt_T9940A"; - -/* - * drv_density_rw[] - * Specify readwrite densities supported by this DM. - * drv_density_rw must be an array of mms_sym_t. - * Density names must start with "den_" to avoid conflict with other names. - */ -mms_sym_t drv_density[] = { - "den_T9940A", 0x43, - "den_T9940B", 0x44, - NULL /* Must be last entry */ -}; - -/* - * drv_shape[] - * - Specify shape names of cartridge types supported by this DM. - * - Shape names must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Shape name must be a well known and published name. - */ -char *drv_shape[] = { - "9940", - NULL /* Must be last entry */ -}; - -/* - * drv_shape_den[] - * Specify the shape of a cartridge and the density on it that can be - * written over by a readwrite density. - * All shape names and density names must have been specified in - * drv_density[] and drv_shape[]. - * Each entry of the array consists of: - * {shapename, density on cart, readwrite density}. - * If the density on cartridge is the same as the readwrite density, then - * the drive can read and write with that density. - * If the density on cartridge is read only, then the readwrite density - * is NULL. - * If the readwrite density is not NULL and it is different from the density - * on cartridge, then the drive is able to write over the existing data - * starting from the beginning of medium. - */ - -drv_shape_density_t drv_shape_den[] = { - /* shapename existing den readwrite density */ - /* - * Specify readwrite density - */ - "9940", "den_T9940A", "den_T9940A", - "9940", "den_T9940B", "den_T9940A", - /* - * Specify readonly density - */ - NULL /* Must be last entry */ -}; diff --git a/usr/src/lib/mms/dm/libSTK_T9940A/common/mapfile-vers b/usr/src/lib/mms/dm/libSTK_T9940A/common/mapfile-vers deleted file mode 100644 index 87f7b2e786..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9940A/common/mapfile-vers +++ /dev/null @@ -1,68 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - drv_density; - drv_drive_type; - drv_get_avail_capacity; - drv_get_capacity; - drv_load; - drv_prsv_supported; - drv_shape; - drv_shape_den; - drv_timeout; - - char_to_uint32 = extern; - dm_get_log_sense_parm = extern; - dm_silent = extern; - dm_trace = extern; - drv = extern; - jtab = extern; - mnt = extern; - serr = extern; - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/dm/libSTK_T9940A/i386/Makefile b/usr/src/lib/mms/dm/libSTK_T9940A/i386/Makefile deleted file mode 100644 index d77b753d64..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9940A/i386/Makefile +++ /dev/null @@ -1,26 +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. -# -# -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libSTK_T9940A/sparc/Makefile b/usr/src/lib/mms/dm/libSTK_T9940A/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9940A/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libSTK_T9940B/Makefile b/usr/src/lib/mms/dm/libSTK_T9940B/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9940B/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/dm/libSTK_T9940B/Makefile.com b/usr/src/lib/mms/dm/libSTK_T9940B/Makefile.com deleted file mode 100644 index 0789756a50..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9940B/Makefile.com +++ /dev/null @@ -1,68 +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. -# -# - -LIBRARY = libSTK_T9940B.a -VERS = -OBJS_COMMON = dm_STK_T9940B.o -OBJS_SHARED = dm_9x40_common.o - -OBJECTS = $(OBJS_COMMON) $(OBJS_SHARED) - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -DMDIR = $(SRC)/lib/mms/dm/libcommon - -SRCS = $(OBJS_COMMON:%.o=$(SRCDIR)/%.c) \ - $(OBJS_SHARED:%.o=$(DMDIR)/%.c) - -LDLIBS += -lc - -CFLAGS += $(CCVERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/dm/common -I../../../mms/common -CPPFLAGS += -I$(SRC)/uts/common/io/mms/dmd - -.KEEP_STATE: - -all: $(LIBS) - -lint: $(LINTLIB) lintcheck - -pics/%.o: $(DMDIR)/%.c - $(COMPILE.c) -o $@ $< - $(POST_PROCESS_O) - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) diff --git a/usr/src/lib/mms/dm/libSTK_T9940B/common/dm_STK_T9940B.c b/usr/src/lib/mms/dm/libSTK_T9940B/common/dm_STK_T9940B.c deleted file mode 100644 index b174d5aa82..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9940B/common/dm_STK_T9940B.c +++ /dev/null @@ -1,118 +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/scsi/impl/uscsi.h> -#include <errno.h> -#include <mms_dmd.h> -#include <mms_trace.h> -#include <dmd_impl.h> -#include <dm_drive.h> -#include <mms_sym.h> - -/* LINTED: static unused */ -static char *_SrcFile = __FILE__; - -/* - * Specify whether the persistent reserve out command is supported or not. - * 0 - not supported - * 1 - supported - * - * If the persistent reserve out command is supported, then it will be used - * to reserve the drive. - * If the persistent reserve out command is not supported, then the reserve - * command will be used to reserve the drive. - */ -int drv_prsv_supported = 1; /* persistent reserve out supported */ - -/* - * specify timeouts for this drive. Time is specified in seconds. - */ -drv_timeout_t drv_timeout = { - (151 *60), /* For really long commands */ - (20 *60), /* Normal commands */ - (1 *60), /* short commands */ -}; - -/* - * Specify the drive type. - * Drive type must begin with "dt_" - */ -char drv_drive_type[] = "dt_T9940B"; - -/* - * drv_density_rw[] - * Specify readwrite densities supported by this DM. - * drv_density_rw must be an array of mms_sym_t. - * Density names must start with "den_" to avoid conflict with other names. - */ -mms_sym_t drv_density[] = { - "den_T9940B", 0x44, - "den_T9940A", 0x43, - NULL /* Must be last entry */ -}; - -/* - * drv_shape[] - * - Specify shape names of cartridge types supported by this DM. - * - Shape names must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Shape name must be a well known and published name. - */ -char *drv_shape[] = { - "9940", - NULL /* Must be last entry */ -}; - -/* - * drv_shape_den[] - * Specify the shape of a cartridge and the density on it that can be - * written over by a readwrite density. - * All shape names and density names must have been specified in - * drv_density[] and drv_shape[]. - * Each entry of the array consists of: - * {shapename, density on cart, readwrite density}. - * If the density on cartridge is the same as the readwrite density, then - * the drive can read and write with that density. - * If the density on cartridge is read only, then the readwrite density - * is NULL. - * If the readwrite density is not NULL and it is different from the density - * on cartridge, then the drive is able to write over the existing data - * starting from the beginning of medium. - */ - -drv_shape_density_t drv_shape_den[] = { - /* shapename existing den readwrite density */ - /* - * Specify readwrite density - */ - "9940", "den_T9940B", "den_T9940B", - "9940", "den_T9940A", "den_T9940B", - /* - * Specify readonly density - */ - NULL /* Must be last entry */ -}; diff --git a/usr/src/lib/mms/dm/libSTK_T9940B/common/mapfile-vers b/usr/src/lib/mms/dm/libSTK_T9940B/common/mapfile-vers deleted file mode 100644 index 87f7b2e786..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9940B/common/mapfile-vers +++ /dev/null @@ -1,68 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - drv_density; - drv_drive_type; - drv_get_avail_capacity; - drv_get_capacity; - drv_load; - drv_prsv_supported; - drv_shape; - drv_shape_den; - drv_timeout; - - char_to_uint32 = extern; - dm_get_log_sense_parm = extern; - dm_silent = extern; - dm_trace = extern; - drv = extern; - jtab = extern; - mnt = extern; - serr = extern; - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/dm/libSTK_T9940B/i386/Makefile b/usr/src/lib/mms/dm/libSTK_T9940B/i386/Makefile deleted file mode 100644 index 95bf998d7d..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9940B/i386/Makefile +++ /dev/null @@ -1,28 +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. -# -# -include ../Makefile.com - -install: all $(ROOTLIBS) diff --git a/usr/src/lib/mms/dm/libSTK_T9940B/sparc/Makefile b/usr/src/lib/mms/dm/libSTK_T9940B/sparc/Makefile deleted file mode 100644 index 92a1313276..0000000000 --- a/usr/src/lib/mms/dm/libSTK_T9940B/sparc/Makefile +++ /dev/null @@ -1,29 +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. -# -# - -include ../Makefile.com - -install: all $(ROOTLIBS) diff --git a/usr/src/lib/mms/dm/libcommon/dm_9x40_common.c b/usr/src/lib/mms/dm/libcommon/dm_9x40_common.c deleted file mode 100644 index e063e61d1d..0000000000 --- a/usr/src/lib/mms/dm/libcommon/dm_9x40_common.c +++ /dev/null @@ -1,144 +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 <syslog.h> -#include <sys/scsi/impl/uscsi.h> -#include <sys/scsi/generic/sense.h> -#include <sys/scsi/generic/status.h> -#include <sys/scsi/generic/commands.h> -#include <stdlib.h> -#include <stdio.h> -#include <fcntl.h> -#include <ctype.h> -#include <sys/types.h> -#include <sys/mkdev.h> -#include <sys/stat.h> -#include <dlfcn.h> -#include <errno.h> -#include <string.h> -#include <unistd.h> -#include <stropts.h> -#include <sys/ioctl.h> -#include <sys/mtio.h> -#include <mms_dmd.h> -#include <mms_trace.h> -#include <dmd_impl.h> -#include <dm_drive.h> -#include <mms_sym.h> - -static char *_SrcFile = __FILE__; -static uint64_t drv_max_cap = (uint64_t)(-1); /* Cart max capacity */ - -int64_t -drv_get_avail_capacity(void) -{ - uchar_t iobuf[120]; - uchar_t *buf = iobuf; - uint64_t val; - int page_control = 1; /* return current value */ - - if (DRV_CALL(drv_log_sense, - (buf, sizeof (iobuf), page_control, 0x0c)) != 0) { - return (-1); - } - if (dm_get_log_sense_parm(buf, 0x8000, &val) != 0) { - return (-1); - } - TRACE((MMS_DEBUG, "log sense capacity = %lld", val)); - /* Avail capacity in mega unit */ - return ((val * 4096) / (1024 * 1024)); -} - -int -drv_get_capacity(mms_capacity_t *cap) -{ - int64_t avail; - tapepos_t pos; - - if (DRV_CALL(drv_get_pos, (&pos)) != 0) { - return (-1); - } - if (DRV_CALL(drv_eom, ()) != 0) { - DRV_CALL(drv_locate, (&pos)); - return (-1); - } - avail = DRV_CALL(drv_get_avail_capacity, ()); - if (DRV_CALL(drv_locate, (&pos)) != 0 || avail <= 0) { - return (-1); - } - - cap->mms_max = drv_max_cap; - cap->mms_avail = avail; - cap->mms_pc_avail = (avail * 100) / drv_max_cap; - - TRACE((MMS_INFO, "Capacity: max %lld, avail %lld, avail %d%%", - cap->mms_max, cap->mms_avail, cap->mms_pc_avail)); - - return (0); -} - -int -drv_load(void) -{ - struct uscsi_cmd us; - char cdb[6] = { 0x1b, 0x00, 0x00, 0x00, 0x03, 0x00 }; - int i; - - TRACE((MMS_DEBUG, "9840 Load/Retension")); - - for (i = 0; i < DRV_LOAD_TUR; i++) { - if (DRV_CALL(drv_tur, ()) != 0) { - (void) sleep(1); - continue; - } - (void) memset(&us, 0, sizeof (us)); - us.uscsi_cdb = cdb; - us.uscsi_cdblen = 6; - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - us.uscsi_bufaddr = NULL; - us.uscsi_buflen = 0; - TRACE((MMS_DEBUG, "Do LOAD")); - if (DRV_CALL(drv_rewind, ()) == 0 && - serr->se_dsreg == STATUS_GOOD) { - break; - } else { - /* Error doing load */ - return (-1); - } - } - if (i == DRV_LOAD_TUR) { - return (-1); - } - drv->drv_flags &= ~DRV_MOVE_FLAGS; - drv->drv_flags |= DRV_BOM; - /* - * You can only get max capacity of tape at BOM - */ - drv_max_cap = DRV_CALL(drv_get_avail_capacity, ()); - drv->drv_capacity = drv_max_cap; - TRACE((MMS_DEBUG, "Cartridge \"%s\" loaded", mnt->mnt_pcl)); - return (0); -} diff --git a/usr/src/lib/mms/dm/libcommon/dm_HP_LTO_common.c b/usr/src/lib/mms/dm/libcommon/dm_HP_LTO_common.c deleted file mode 100644 index 260596597e..0000000000 --- a/usr/src/lib/mms/dm/libcommon/dm_HP_LTO_common.c +++ /dev/null @@ -1,114 +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. - */ - - -#include <sys/types.h> -#include <sys/scsi/impl/uscsi.h> -#include <errno.h> -#include <unistd.h> -#include <mms_dmd.h> -#include <mms_trace.h> -#include <dmd_impl.h> -#include <dm_drive.h> -#include <mms_sym.h> - -static char *_SrcFile = __FILE__; - -int -drv_get_capacity(mms_capacity_t *cap) -{ - uchar_t buf[40]; - int off; - int i; - uint32_t code; - uint32_t max = 0; - uint32_t avail = 0; - int page_control = 1; /* return current value */ - - if (DRV_CALL(drv_log_sense, - (buf, sizeof (buf), page_control, 0x31)) != 0) { - return (EIO); - } - - for (i = 0; i < 4; i++) { - off = 4 + i * 8; - char_to_uint32(buf + off, 2, &code); - if (code == 1) { /* Max capacity */ - char_to_uint32(buf + off + 4, 4, &avail); - cap->mms_avail = avail; - break; - } - } - - for (i = 0; i < 4; i++) { - off = 4 + i * 8; - char_to_uint32(buf + off, 2, &code); - if (code == 3) { /* capacity left */ - char_to_uint32(buf + off + 4, 4, &max); - cap->mms_max = max; - break; - } - } - - if (max > 0) { - cap->mms_pc_avail = (avail * 100) / max; - if (cap->mms_pc_avail > 100) { - cap->mms_pc_avail = 100; - } - } else { - cap->mms_pc_avail = 0; - } - - TRACE((MMS_INFO, "Capacity: max %lld, avail %lld, avail %d%%", - cap->mms_max, cap->mms_avail, cap->mms_pc_avail)); - - return (0); -} - -int -drv_load(void) -{ - TRACE((MMS_DEBUG, "LOAD")); - - for (;;) { - if (DRV_CALL(drv_tur, ()) == 0) { - break; - } - if (serr->se_errcl == DRV_EC_NREADY_TO_READY) { - /* Drive became ready */ - break; - } - (void) sleep(2); - } - if (DRV_CALL(drv_rewind, ()) != 0) { - /* Load rewind to BOT */ - return (-1); - } - drv->drv_flags &= DRV_LOAD_FLAGS; - if (drv->drv_vid || drv->drv_vid[0] != '\0') { - TRACE((MMS_DEBUG, "Cartridge \"%s\" loaded", mnt->mnt_vid)); - } - return (0); - -} diff --git a/usr/src/lib/mms/dm/libcommon/dm_IBM_LTO_common.c b/usr/src/lib/mms/dm/libcommon/dm_IBM_LTO_common.c deleted file mode 100644 index f5683856a3..0000000000 --- a/usr/src/lib/mms/dm/libcommon/dm_IBM_LTO_common.c +++ /dev/null @@ -1,86 +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/scsi/impl/uscsi.h> -#include <errno.h> -#include <mms_dmd.h> -#include <mms_trace.h> -#include <dmd_impl.h> -#include <dm_drive.h> -#include <mms_sym.h> - -static char *_SrcFile = __FILE__; - -int -drv_get_capacity(mms_capacity_t *cap) -{ - uchar_t buf[40]; - int off; - int i; - uint32_t code; - uint32_t max = 0; - uint32_t avail = 0; - int page_control = 1; /* return current value */ - - if (DRV_CALL(drv_log_sense, - (buf, sizeof (buf), page_control, 0x31)) != 0) { - return (EIO); - } - - for (i = 0; i < 4; i++) { - off = 4 + i * 8; - char_to_uint32(buf + off, 2, &code); - if (code == 1) { /* Max capacity */ - char_to_uint32(buf + off + 4, 4, &avail); - cap->mms_avail = avail; - break; - } - } - - for (i = 0; i < 4; i++) { - off = 4 + i * 8; - char_to_uint32(buf + off, 2, &code); - if (code == 3) { /* capacity left */ - char_to_uint32(buf + off + 4, 4, &max); - cap->mms_max = max; - break; - } - } - - if (max > 0) { - cap->mms_pc_avail = (avail * 100) / max; - if (cap->mms_pc_avail > 100) { - cap->mms_pc_avail = 100; - } - } else { - cap->mms_pc_avail = 0; - } - - TRACE((MMS_INFO, "Capacity: max %lld, avail %lld, avail %d%%", - cap->mms_max, cap->mms_avail, cap->mms_pc_avail)); - - return (0); -} diff --git a/usr/src/lib/mms/dm/libcommon/dm_SEAGATELTO_common.c b/usr/src/lib/mms/dm/libcommon/dm_SEAGATELTO_common.c deleted file mode 100644 index f5683856a3..0000000000 --- a/usr/src/lib/mms/dm/libcommon/dm_SEAGATELTO_common.c +++ /dev/null @@ -1,86 +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/scsi/impl/uscsi.h> -#include <errno.h> -#include <mms_dmd.h> -#include <mms_trace.h> -#include <dmd_impl.h> -#include <dm_drive.h> -#include <mms_sym.h> - -static char *_SrcFile = __FILE__; - -int -drv_get_capacity(mms_capacity_t *cap) -{ - uchar_t buf[40]; - int off; - int i; - uint32_t code; - uint32_t max = 0; - uint32_t avail = 0; - int page_control = 1; /* return current value */ - - if (DRV_CALL(drv_log_sense, - (buf, sizeof (buf), page_control, 0x31)) != 0) { - return (EIO); - } - - for (i = 0; i < 4; i++) { - off = 4 + i * 8; - char_to_uint32(buf + off, 2, &code); - if (code == 1) { /* Max capacity */ - char_to_uint32(buf + off + 4, 4, &avail); - cap->mms_avail = avail; - break; - } - } - - for (i = 0; i < 4; i++) { - off = 4 + i * 8; - char_to_uint32(buf + off, 2, &code); - if (code == 3) { /* capacity left */ - char_to_uint32(buf + off + 4, 4, &max); - cap->mms_max = max; - break; - } - } - - if (max > 0) { - cap->mms_pc_avail = (avail * 100) / max; - if (cap->mms_pc_avail > 100) { - cap->mms_pc_avail = 100; - } - } else { - cap->mms_pc_avail = 0; - } - - TRACE((MMS_INFO, "Capacity: max %lld, avail %lld, avail %d%%", - cap->mms_max, cap->mms_avail, cap->mms_pc_avail)); - - return (0); -} diff --git a/usr/src/lib/mms/dm/libdefault/Makefile b/usr/src/lib/mms/dm/libdefault/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/dm/libdefault/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/dm/libdefault/Makefile.com b/usr/src/lib/mms/dm/libdefault/Makefile.com deleted file mode 100644 index 30262a61f3..0000000000 --- a/usr/src/lib/mms/dm/libdefault/Makefile.com +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -LIBRARY = libdm_default.a -VERS = -OBJECTS = dm_default.o - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -SRCS = $(OBJECTS:%.o=$(SRCDIR)/%.c) - -LDLIBS += -lc -LDLIBS += -L$(SRC)/lib/mms/mms/$(MACH) -lmms - -CFLAGS += $(CCVERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/dm/common -I../../../mms/common -CPPFLAGS += -I$(SRC)/uts/common/io/mms/dda -CPPFLAGS += -I$(SRC)/uts/common/io/mms/dmd -CPPFLAGS += -erroff=E_NON_CONST_INIT - -.KEEP_STATE: - -all: $(LIBS) - -lint: $(LINTLIB) lintcheck - - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) diff --git a/usr/src/lib/mms/dm/libdefault/common/dm_default.c b/usr/src/lib/mms/dm/libdefault/common/dm_default.c deleted file mode 100644 index 6f03c906e8..0000000000 --- a/usr/src/lib/mms/dm/libdefault/common/dm_default.c +++ /dev/null @@ -1,2227 +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. - */ - - -#include <sys/types.h> -#include <syslog.h> -#include <sys/scsi/impl/uscsi.h> -#include <sys/scsi/generic/sense.h> -#include <sys/scsi/generic/status.h> -#include <sys/scsi/generic/commands.h> -#include <stdlib.h> -#include <stdio.h> -#include <fcntl.h> -#include <ctype.h> -#include <sys/types.h> -#include <sys/mkdev.h> -#include <sys/stat.h> -#include <dlfcn.h> -#include <errno.h> -#include <string.h> -#include <unistd.h> -#include <stropts.h> -#include <sys/ioctl.h> -#include <sys/mtio.h> -#include <mms_dmd.h> -#include <mms_trace.h> -#include <dmd_impl.h> -#include <dm_drive.h> -#include <mms_sym.h> -#include <dda.h> - -static char *_SrcFile = __FILE__; - -/* - * specify timeouts for this drive. Time is specified in seconds. - */ -drv_timeout_t drv_timeout = { - (151 *60), /* For really long commands */ - (20 *60), /* Normal commands */ - (1 *60), /* short commands */ -}; - -/* - * Specify the drive type. - * Drive type must begin with "dt_" - */ -char drv_drive_type[] = "dt_XXXXX"; - -/* - * Specify the directory in which this device can be found. - * e.g. /dev/rmt - * - * The DM will open each device in this directory and look for a device - * whose serial number matches the serial number specified in - * DRIVE.'DriveSerialNum'. - * If this is a null string, then the full pathname of the device is specified - * in DM.'DMTargetPath'. - */ -char drv_dev_dir[] = "/dev/rmt"; - -/* - * drv_density[] - * - Specify density names with their density codes supported by this DM. - * - Densities must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Density names must start with "den_" to avoid conflict with other names. - */ -mms_sym_t drv_density[] = { - NULL, /* Must be the last entry */ -}; - -/* - * drv_shape[] - * - Specify shape names of cartridge types supported by this DM. - * - Shape names must be specified in the order of their selection priority. - * The ones at the beginning of the list will be selected before those - * at the end of the list. - * - Shape name must be a well known and published name. - */ -char *drv_shape[] = { - NULL /* Must be last entry */ -}; - - -/* - * drv_shape_den[] - * Specify the shape of a cartridge and the density on it that can be - * written over by a readwrite density. - * All shape names and density names must have been specified in - * drv_density[] and drv_shape[]. - * Each entry of the array consists of: - * {shapename, density on cart, readwrite density}. - * If the density on cartridge is the same as the readwrite density, then - * the drive can read and write with that density. - * If the density on cartridge is read only, then the readwrite density - * is NULL. - * If the readwrite density is not NULL and it is different from the density - * on cartridge, then the drive is able to write over the existing data - * starting from the beginning of medium. - */ - -drv_shape_density_t drv_shape_den[] = { - /* shapename existing den readwrite density */ - /* - * Specify readwrite density - */ - - /* - * Specify readonly density - */ - NULL /* Must be last entry */ -}; - -/* - * drv_mounted[] - * Specify mount points of disk files that emulate cartridges. - * Real cartridges do not have mount points. - */ -char *drv_mounted[] = { - "*none", /* Real cartridge has not mount point */ - NULL, /* Must be last entry */ -}; - -/* - * Specify SCSI commands that a client may not issue using USCSI - */ -int drv_disallowed_cmds[] = { - SCMD_PROUT, /* persistent reserve out */ - SCMD_RESERVE, /* reserve */ - SCMD_RELEASE, /* release */ -}; -int drv_num_disallowed_cmds = - sizeof (drv_disallowed_cmds) / sizeof (int); - -/* - * Specify ioctl's that a client may not issue - */ -int drv_disallowed_ioctls[] = { - MTIOCRESERVE, - MTIOCRELEASE, - MTIOCFORCERESERVE, -}; -int drv_num_disallowed_ioctls = - sizeof (drv_disallowed_ioctls) / sizeof (int); - -/* - * Sense key, asc and ascq table (skaa) - * 0xff matches any value in lookup operation. - */ -drv_skaa_t drv_skaa_tab[] = { - /* - * Error text must be less than or equal to 80 characters. - */ - 0xff, 0x00, 0x00, DRV_EC_NO_SENSE, - "no additional sense information", - 0xff, 0x00, 0x01, DRV_EC_TM, - "filemark detected", - 0xff, 0x00, 0x02, DRV_EC_EOM, - "end-of-partition/medium detected", - 0xff, 0x00, 0x03, DRV_EC_TM, - "setmark detected", - 0xff, 0x00, 0x04, DRV_EC_BOM, - "beginning-of-partition/medium detected", - 0xff, 0x00, 0x05, DRV_EC_EOD, - "end-of-data detected", - 0xff, 0x00, 0x06, DRV_EC_ERROR, - "I/O process terminated", - 0xff, 0x00, 0x16, DRV_EC_NOT_READY, - "operation in progress", - 0xff, 0x00, 0x17, DRV_EC_NEEDS_CLEANING, - "cleaning requested", - 0xff, 0x00, 0x18, DRV_EC_NOT_READY, - "erase operation in progress", - 0xff, 0x00, 0x19, DRV_EC_NOT_READY, - "locate operation in progress", - 0xff, 0x00, 0x1a, DRV_EC_NOT_READY, - "rewind operation in progress", - 0xff, 0x00, 0x1b, DRV_EC_NOT_READY, - "set capacity operation in progress", - 0xff, 0x00, 0x1c, DRV_EC_NOT_READY, - "verify operation in progress", - 0xff, 0x00, 0x1d, DRV_EC_ERROR, - "ATA pass through information available", - 0xff, 0x03, 0x00, DRV_EC_ERROR, - "peripheral device write fault", - 0xff, 0x03, 0x01, DRV_EC_ERROR, - "no write current", - 0xff, 0x03, 0x02, DRV_EC_ERROR, - "excessive write errors", - 0xff, 0x04, 0x00, DRV_EC_NOT_READY, - "logical unit not ready, cause not reportable", - 0xff, 0x04, 0x01, DRV_EC_NOT_READY, - "logical unit is in process of becoming ready", - 0xff, 0x04, 0x02, DRV_EC_ERROR, - "logical unit not ready, initializing command required", - 0xff, 0x04, 0x03, DRV_EC_NOT_READY, - "logical unit not ready, manual intervention required", - 0xff, 0x04, 0x04, DRV_EC_NOT_READY, - "logical unit not ready, format in progress", - 0xff, 0x04, 0x05, DRV_EC_NOT_READY, - "logical unit not ready, rebuild in progress", - 0xff, 0x04, 0x06, DRV_EC_NOT_READY, - "logical unit not ready, recalculation in progress", - 0xff, 0x04, 0x07, DRV_EC_NOT_READY, - "logical unit not ready, operation in progress", - 0xff, 0x04, 0x09, DRV_EC_NOT_READY, - "logical unit not ready, self-test in progress", - 0xff, 0x04, 0x0a, DRV_EC_ERROR, - "logical unit not accessible, asymmetric access state transition", - 0xff, 0x04, 0x0b, DRV_EC_ERROR, - "logical unit not accessible, target port in standby state", - 0xff, 0x04, 0x0c, DRV_EC_ERROR, - "logical unit not accessible, target port in unavailable state", - 0xff, 0x04, 0x10, DRV_EC_NOT_READY, - "logical unit not ready, auxiliary memory not accessible", - 0xff, 0x04, 0x11, DRV_EC_NOT_READY, - "logical unit not ready, notify (enable spinup) required", - 0xff, 0x05, 0x00, DRV_EC_ERROR, - "logical unit does not respond to selection", - 0xff, 0x07, 0x00, DRV_EC_ERROR, - "multiple peripheral devices selected", - 0xff, 0x08, 0x00, DRV_EC_ERROR, - "logical unit communication failure", - 0xff, 0x08, 0x01, DRV_EC_ERROR, - "logical unit communication time-out", - 0xff, 0x08, 0x02, DRV_EC_ERROR, - "logical unit communication parity error", - 0xff, 0x08, 0x03, DRV_EC_ERROR, - "logical unit communication crc error (ULTRA-DMA/32)", - 0xff, 0x08, 0x04, DRV_EC_ERROR, - "unreachable copy target", - 0xff, 0x09, 0x00, DRV_EC_ERROR, - "track following error", - 0xff, 0x09, 0x04, DRV_EC_ERROR, - "head select fault", - 0xff, 0x0a, 0x00, DRV_EC_ERROR, - "error log overflow", - 0xff, 0x0b, 0x00, DRV_EC_ERROR, - "warning", - 0xff, 0x0b, 0x01, DRV_EC_ERROR, - "warning - specified temperature exceeded", - 0xff, 0x0b, 0x02, DRV_EC_ERROR, - "warning - enclosure degraded", - 0xff, 0x0b, 0x03, DRV_EC_ERROR, - "warning - background self-test failed", - 0xff, 0x0b, 0x04, DRV_EC_ERROR, - "warning - background pre-scan detected medium error", - 0xff, 0x0b, 0x05, DRV_EC_ERROR, - "warning - background medium scan detected medium error", - 0xff, 0x0c, 0x00, DRV_EC_ERROR, - "write error", - 0xff, 0x0c, 0x04, DRV_EC_ERROR, - "compression check miscompare error", - 0xff, 0x0c, 0x05, DRV_EC_ERROR, - "data expansion occurred during compression", - 0xff, 0x0c, 0x06, DRV_EC_ERROR, - "block not compressible", - 0xff, 0x0c, 0x0b, DRV_EC_ERROR, - "auxiliary memory write error", - 0xff, 0x0c, 0x0c, DRV_EC_ERROR, - "write error - unexpected unsolicited data", - 0xff, 0x0c, 0x0d, DRV_EC_ERROR, - "write error - not enough unsolicited data", - 0xff, 0x0d, 0x00, DRV_EC_ERROR, - "error detected by third party temporary initiator", - 0xff, 0x0d, 0x01, DRV_EC_ERROR, - "third party device failure", - 0xff, 0x0d, 0x02, DRV_EC_ERROR, - "copy target device not reachable", - 0xff, 0x0d, 0x03, DRV_EC_ERROR, - "incorrect copy target device type", - 0xff, 0x0d, 0x04, DRV_EC_ERROR, - "copy target device data underrun", - 0xff, 0x0d, 0x05, DRV_EC_ERROR, - "copy target device data overrun", - 0xff, 0x0e, 0x00, DRV_EC_ERROR, - "invalid information unit", - 0xff, 0x0e, 0x01, DRV_EC_ERROR, - "information unit too short", - 0xff, 0x0e, 0x02, DRV_EC_ERROR, - "information unit too long", - 0xff, 0x0e, 0x03, DRV_EC_ERROR, - "invalid field in command information unit", - 0xff, 0x10, 0x01, DRV_EC_ERROR, - "logical block guard check failed", - 0xff, 0x10, 0x02, DRV_EC_ERROR, - "logical block application tag check failed", - 0xff, 0x10, 0x03, DRV_EC_ERROR, - "logical block reference tag check failed", - 0xff, 0x11, 0x00, DRV_EC_ERROR, - "unrecovered read error", - 0xff, 0x11, 0x01, DRV_EC_ERROR, - "read retries exhausted", - 0xff, 0x11, 0x02, DRV_EC_ERROR, - "error too long to correct", - 0xff, 0x11, 0x03, DRV_EC_ERROR, - "multiple read errors", - 0xff, 0x11, 0x08, DRV_EC_ERROR, - "incomplete block read", - 0xff, 0x11, 0x09, DRV_EC_ERROR, - "no gap found", - 0xff, 0x11, 0x0a, DRV_EC_ERROR, - "miscorrected error", - 0xff, 0x11, 0x0d, DRV_EC_ERROR, - "de-compression crc error", - 0xff, 0x11, 0x0e, DRV_EC_ERROR, - "cannot decompress using declared algorithm", - 0xff, 0x11, 0x12, DRV_EC_ERROR, - "auxiliary memory read error", - 0xff, 0x11, 0x13, DRV_EC_ERROR, - "read error - failed retransmission request", - 0xff, 0x14, 0x00, DRV_EC_ERROR, - "recorded entity not found", - 0xff, 0x14, 0x01, DRV_EC_ERROR, - "record not found", - 0xff, 0x14, 0x02, DRV_EC_ERROR, - "filemark or setmark not found", - 0xff, 0x14, 0x03, DRV_EC_ERROR, - "end-of-data not found", - 0xff, 0x14, 0x04, DRV_EC_ERROR, - "block sequence error", - 0xff, 0x14, 0x05, DRV_EC_ERROR, - "record not found - recommend reassignment", - 0xff, 0x14, 0x06, DRV_EC_ERROR, - "record not found - data auto-reallocated", - 0xff, 0x14, 0x07, DRV_EC_ERROR, - "locate operation failure", - 0xff, 0x15, 0x00, DRV_EC_ERROR, - "random positioning error", - 0xff, 0x15, 0x01, DRV_EC_ERROR, - "mechanical positioning error", - 0xff, 0x15, 0x02, DRV_EC_ERROR, - "positioning error detected by read of medium", - 0xff, 0x17, 0x00, DRV_EC_ERROR, - "recovered data with no error correction applied", - 0xff, 0x17, 0x01, DRV_EC_ERROR, - "recovered data with retries", - 0xff, 0x17, 0x02, DRV_EC_ERROR, - "recovered data with positive head offset", - 0xff, 0x17, 0x03, DRV_EC_ERROR, - "recovered data with negative head offset", - 0xff, 0x18, 0x00, DRV_EC_ERROR, - "recovered data with error correction applied", - 0xff, 0x1a, 0x00, DRV_EC_ERROR, - "parameter list length error", - 0xff, 0x1b, 0x00, DRV_EC_ERROR, - "synchronous data transfer error", - 0xff, 0x1d, 0x00, DRV_EC_ERROR, - "miscompare during verify operation", - 0xff, 0x20, 0x00, DRV_EC_ERROR, - "invalid command operation code", - 0xff, 0x20, 0x01, DRV_EC_ERROR, - "access denied - initiator pending-enrolled", - 0xff, 0x20, 0x02, DRV_EC_ERROR, - "access denied - no access rights", - 0xff, 0x20, 0x03, DRV_EC_ERROR, - "access denied - invalid mgmt id key", - 0xff, 0x20, 0x04, DRV_EC_ERROR, - "illegal command while in write capable state", - 0xff, 0x20, 0x05, DRV_EC_ERROR, - "obsolete", - 0xff, 0x20, 0x06, DRV_EC_ERROR, - "illegal command while in explicit mms_address mode", - 0xff, 0x20, 0x07, DRV_EC_ERROR, - "illegal command while in implicit mms_address mode", - 0xff, 0x20, 0x08, DRV_EC_ERROR, - "access denied - enrollment conflict", - 0xff, 0x20, 0x09, DRV_EC_ERROR, - "access denied - invalid lu identifier", - 0xff, 0x20, 0x0a, DRV_EC_ERROR, - "access denied - invalid proxy token", - 0xff, 0x20, 0x0b, DRV_EC_ERROR, - "access denied - acl lun conflict", - 0xff, 0x21, 0x00, DRV_EC_ERROR, - "logical block mms_address out of range", - 0xff, 0x21, 0x01, DRV_EC_ERROR, - "invalid element mms_address", - 0xff, 0x24, 0x00, DRV_EC_ERROR, - "invalid field in cdb", - 0xff, 0x24, 0x01, DRV_EC_ERROR, - "cdb decryption error", - 0xff, 0x24, 0x02, DRV_EC_ERROR, - "obsolete", - 0xff, 0x24, 0x03, DRV_EC_ERROR, - "obsolete", - 0xff, 0x25, 0x00, DRV_EC_ERROR, - "logical unit not supported", - 0xff, 0x26, 0x00, DRV_EC_ERROR, - "invalid field in parameter list", - 0xff, 0x26, 0x01, DRV_EC_ERROR, - "parameter not supported", - 0xff, 0x26, 0x02, DRV_EC_ERROR, - "parameter value invalid", - 0xff, 0x26, 0x03, DRV_EC_ERROR, - "threshold parameters not supported", - 0xff, 0x26, 0x04, DRV_EC_ERROR, - "invalid release of persistent reservation", - 0xff, 0x26, 0x05, DRV_EC_ERROR, - "data decryption error", - 0xff, 0x26, 0x06, DRV_EC_ERROR, - "too many target descriptors", - 0xff, 0x26, 0x07, DRV_EC_ERROR, - "unsupported target descriptor type code", - 0xff, 0x26, 0x08, DRV_EC_ERROR, - "too many segment descriptors", - 0xff, 0x26, 0x09, DRV_EC_ERROR, - "unsupported segment descriptor type code", - 0xff, 0x26, 0x0a, DRV_EC_ERROR, - "unexpected inexact segment", - 0xff, 0x26, 0x0b, DRV_EC_ERROR, - "inline data length exceeded", - 0xff, 0x26, 0x0c, DRV_EC_ERROR, - "invalid operation for copy source or destination", - 0xff, 0x26, 0x0d, DRV_EC_ERROR, - "copy segment granularity violation", - 0xff, 0x26, 0x0e, DRV_EC_ERROR, - "invalid parameter while port is enabled", - 0xff, 0x26, 0x10, DRV_EC_ERROR, - "data decryption key fail limit reached", - 0xff, 0x26, 0x11, DRV_EC_ERROR, - "incomplete key-associated data set", - 0xff, 0x26, 0x12, DRV_EC_ERROR, - "vendor specific key reference not found", - 0xff, 0x27, 0x00, DRV_EC_ERROR, - "write protected", - 0xff, 0x27, 0x01, DRV_EC_ERROR, - "hardware write protected", - 0xff, 0x27, 0x02, DRV_EC_ERROR, - "logical unit software write protected", - 0xff, 0x27, 0x03, DRV_EC_ERROR, - "associated write protect", - 0xff, 0x27, 0x04, DRV_EC_ERROR, - "persistent write protect", - 0xff, 0x27, 0x05, DRV_EC_ERROR, - "permanent write protect", - 0xff, 0x28, 0x00, DRV_EC_NREADY_TO_READY, - "not ready to ready change, medium may have changed", - 0xff, 0x28, 0x01, DRV_EC_ERROR, - "import or export element accessed", - 0xff, 0x29, 0x00, DRV_EC_RESET, - "power on, reset, or bus device reset occurred", - 0xff, 0x29, 0x01, DRV_EC_RESET, - "power on occurred", - 0xff, 0x29, 0x02, DRV_EC_RESET, - "scsi bus reset occurred", - 0xff, 0x29, 0x03, DRV_EC_RESET, - "bus device reset function occurred", - 0xff, 0x29, 0x04, DRV_EC_RESET, - "device internal reset", - 0xff, 0x29, 0x05, DRV_EC_ERROR, - "transceiver mode changed to single-ended", - 0xff, 0x29, 0x06, DRV_EC_ERROR, - "transceiver mode changed to lvd", - 0xff, 0x29, 0x07, DRV_EC_ERROR, - "i_t nexus loss occurred", - 0xff, 0x2a, 0x00, DRV_EC_ERROR, - "parameters changed", - 0xff, 0x2a, 0x01, DRV_EC_ERROR, - "mode parameters changed", - 0xff, 0x2a, 0x02, DRV_EC_ERROR, - "log parameters changed", - 0xff, 0x2a, 0x03, DRV_EC_LOST_PRSV, - "reservations preempted", - 0xff, 0x2a, 0x04, DRV_EC_LOST_PRSV, - "reservations released", - 0xff, 0x2a, 0x05, DRV_EC_LOST_PRSV, - "registrations preempted", - 0xff, 0x2a, 0x06, DRV_EC_ERROR, - "asymmetric access state changed", - 0xff, 0x2a, 0x07, DRV_EC_ERROR, - "implicit asymmetric access state transition failed", - 0xff, 0x2a, 0x08, DRV_EC_ERROR, - "priority changed", - 0xff, 0x2a, 0x10, DRV_EC_ERROR, - "timestamp changed", - 0xff, 0x2a, 0x11, DRV_EC_ERROR, - "data encryption parameters changed by another i_t nexus", - 0xff, 0x2a, 0x12, DRV_EC_ERROR, - "data encryption parameters changed by vendor specific event", - 0xff, 0x2a, 0x13, DRV_EC_ERROR, - "data encryption key instance counter has changed", - 0xff, 0x2b, 0x00, DRV_EC_ERROR, - "copy cannot execute since host cannot disconnect", - 0xff, 0x2c, 0x00, DRV_EC_ERROR, - "command sequence error", - 0xff, 0x2c, 0x07, DRV_EC_ERROR, - "previous busy status", - 0xff, 0x2c, 0x08, DRV_EC_ERROR, - "previous task set full status", - 0xff, 0x2c, 0x09, DRV_EC_ERROR, - "previous reservation conflict status", - 0xff, 0x2c, 0x0b, DRV_EC_ERROR, - "not reserved", - 0xff, 0x2d, 0x00, DRV_EC_ERROR, - "overwrite error on update in place", - 0xff, 0x2f, 0x00, DRV_EC_ERROR, - "commands cleared by another initiator", - 0xff, 0x2f, 0x02, DRV_EC_ERROR, - "commands cleared by device server", - 0xff, 0x30, 0x00, DRV_EC_ERROR, - "incompatible medium installed", - 0xff, 0x30, 0x01, DRV_EC_FORMAT, - "cannot read medium - unknown format", - 0xff, 0x30, 0x02, DRV_EC_FORMAT, - "cannot read medium - incompatible format", - 0xff, 0x30, 0x03, DRV_EC_FORMAT, - "cleaning cartridge installed", - 0xff, 0x30, 0x04, DRV_EC_FORMAT, - "cannot write medium - unknown format", - 0xff, 0x30, 0x05, DRV_EC_FORMAT, - "cannot write medium - incompatible format", - 0xff, 0x30, 0x06, DRV_EC_FORMAT, - "cannot format medium - incompatible medium", - 0xff, 0x30, 0x07, DRV_EC_ERROR, - "cleaning failure", - 0xff, 0x30, 0x0a, DRV_EC_ERROR, - "cleaning request rejected", - 0xff, 0x30, 0x0c, DRV_EC_ERROR, - "worm medium - overwrite attempted", - 0xff, 0x30, 0x0d, DRV_EC_ERROR, - "worm medium - integrity check", - 0xff, 0x31, 0x00, DRV_EC_ERROR, - "medium format corrupted", - 0xff, 0x33, 0x00, DRV_EC_ERROR, - "tape length error", - 0xff, 0x34, 0x00, DRV_EC_ERROR, - "enclosure failure", - 0xff, 0x35, 0x00, DRV_EC_ERROR, - "enclosure services failure", - 0xff, 0x35, 0x01, DRV_EC_ERROR, - "unsupported enclosure function", - 0xff, 0x35, 0x02, DRV_EC_ERROR, - "enclosure services unavailable", - 0xff, 0x35, 0x03, DRV_EC_ERROR, - "enclosure services transfer failure", - 0xff, 0x35, 0x04, DRV_EC_ERROR, - "enclosure services transfer refused", - 0xff, 0x35, 0x05, DRV_EC_ERROR, - "enclosure services checksum error", - 0xff, 0x37, 0x00, DRV_EC_ERROR, - "rounded parameter", - 0xff, 0x39, 0x00, DRV_EC_ERROR, - "saving parameters not supported", - 0xff, 0x3a, 0x00, DRV_EC_NOT_READY, - "medium not present", - 0xff, 0x3a, 0x01, DRV_EC_NOT_READY, - "medium not present - tray closed", - 0xff, 0x3a, 0x02, DRV_EC_NOT_READY, - "medium not present - tray open", - 0xff, 0x3a, 0x03, DRV_EC_NOT_READY, - "medium not present - loadable", - 0xff, 0x3a, 0x04, DRV_EC_NOT_READY, - "medium not present - medium auxiliary memory accessible", - 0xff, 0x3b, 0x00, DRV_EC_ERROR, - "sequential positioning error", - 0xff, 0x3b, 0x01, DRV_EC_ERROR, - "tape position error at beginning-of-medium", - 0xff, 0x3b, 0x02, DRV_EC_ERROR, - "tape position error at end-of-medium", - 0xff, 0x3b, 0x08, DRV_EC_ERROR, - "reposition error", - 0xff, 0x3b, 0x0c, DRV_EC_ERROR, - "position past beginning of medium", - 0xff, 0x3b, 0x0d, DRV_EC_ERROR, - "medium destination element full", - 0xff, 0x3b, 0x0e, DRV_EC_ERROR, - "medium source element empty", - 0xff, 0x3b, 0x11, DRV_EC_ERROR, - "medium magazine not accessible", - 0xff, 0x3b, 0x12, DRV_EC_ERROR, - "medium magazine removed", - 0xff, 0x3b, 0x13, DRV_EC_ERROR, - "medium magazine inserted", - 0xff, 0x3b, 0x14, DRV_EC_ERROR, - "medium magazine locked", - 0xff, 0x3b, 0x15, DRV_EC_ERROR, - "medium magazine unlocked", - 0xff, 0x3d, 0x00, DRV_EC_ERROR, - "invalid bits in identify message", - 0xff, 0x3e, 0x00, DRV_EC_ERROR, - "logical unit has not self-configured yet", - 0xff, 0x3e, 0x01, DRV_EC_ERROR, - "logical unit failure", - 0xff, 0x3e, 0x02, DRV_EC_ERROR, - "timeout on logical unit", - 0xff, 0x3e, 0x03, DRV_EC_ERROR, - "logical unit failed self-test", - 0xff, 0x3e, 0x04, DRV_EC_ERROR, - "logical unit unable to update self-test log", - 0xff, 0x3f, 0x00, DRV_EC_ERROR, - "target operating conditions have changed", - 0xff, 0x3f, 0x01, DRV_EC_ERROR, - "microcode has been changed", - 0xff, 0x3f, 0x02, DRV_EC_ERROR, - "changed operating definition", - 0xff, 0x3f, 0x03, DRV_EC_ERROR, - "inquiry data has changed", - 0xff, 0x3f, 0x04, DRV_EC_ERROR, - "component device attached", - 0xff, 0x3f, 0x05, DRV_EC_ERROR, - "device identifier changed", - 0xff, 0x3f, 0x06, DRV_EC_ERROR, - "redundancy group created or modified", - 0xff, 0x3f, 0x07, DRV_EC_ERROR, - "redundancy group deleted", - 0xff, 0x3f, 0x08, DRV_EC_ERROR, - "spare created or modified", - 0xff, 0x3f, 0x09, DRV_EC_ERROR, - "spare deleted", - 0xff, 0x3f, 0x0a, DRV_EC_ERROR, - "volume set created or modified", - 0xff, 0x3f, 0x0b, DRV_EC_ERROR, - "volume set deleted", - 0xff, 0x3f, 0x0c, DRV_EC_ERROR, - "volume set deassigned", - 0xff, 0x3f, 0x0d, DRV_EC_ERROR, - "volume set reassigned", - 0xff, 0x3f, 0x0e, DRV_EC_ERROR, - "reported luns data has changed", - 0xff, 0x3f, 0x0f, DRV_EC_ERROR, - "echo buffer overwritten", - 0xff, 0x3f, 0x10, DRV_EC_ERROR, - "medium loadable", - 0xff, 0x3f, 0x11, DRV_EC_ERROR, - "medium auxiliary memory accessible", - 0xff, 0x3f, 0x12, DRV_EC_ERROR, - "iscsi ip mms_address added", - 0xff, 0x3f, 0x13, DRV_EC_ERROR, - "iscsi ip mms_address removed", - 0xff, 0x3f, 0x14, DRV_EC_ERROR, - "iscsi ip mms_address changed", - 0xff, 0x40, 0xff, DRV_EC_ERROR, - "diagnostic failure on component nn (80h-ffh)", - 0xff, 0x43, 0x00, DRV_EC_ERROR, - "message error", - 0xff, 0x44, 0x00, DRV_EC_ERROR, - "internal target failure", - 0xff, 0x44, 0x71, DRV_EC_ERROR, - "ata device failed set features", - 0xff, 0x45, 0x00, DRV_EC_ERROR, - "select or reselect failure", - 0xff, 0x46, 0x00, DRV_EC_ERROR, - "unsuccessful soft reset", - 0xff, 0x47, 0x00, DRV_EC_ERROR, - "scsi parity error", - 0xff, 0x47, 0x01, DRV_EC_ERROR, - "data phase crc error detected", - 0xff, 0x47, 0x02, DRV_EC_ERROR, - "scsi parity error detected during st data phase", - 0xff, 0x47, 0x03, DRV_EC_ERROR, - "information unit iucrc error detected", - 0xff, 0x47, 0x04, DRV_EC_ERROR, - "asynchronous information protection error detected", - 0xff, 0x47, 0x05, DRV_EC_ERROR, - "protocol service crc error", - 0xff, 0x47, 0x06, DRV_EC_ERROR, - "phy test function in progress", - 0xff, 0x47, 0x7f, DRV_EC_ERROR, - "some commands cleared by iscsi protocol event", - 0xff, 0x48, 0x00, DRV_EC_ERROR, - "initiator detected error message received", - 0xff, 0x49, 0x00, DRV_EC_ERROR, - "invalid message error", - 0xff, 0x4a, 0x00, DRV_EC_ERROR, - "command phase error", - 0xff, 0x4b, 0x00, DRV_EC_ERROR, - "data phase error", - 0xff, 0x4b, 0x01, DRV_EC_ERROR, - "invalid target port transfer tag received", - 0xff, 0x4b, 0x02, DRV_EC_ERROR, - "too much write data", - 0xff, 0x4b, 0x03, DRV_EC_ERROR, - "ack/nak timeout", - 0xff, 0x4b, 0x04, DRV_EC_ERROR, - "nak received", - 0xff, 0x4b, 0x05, DRV_EC_ERROR, - "data offset error", - 0xff, 0x4b, 0x06, DRV_EC_ERROR, - "initiator response timeout", - 0xff, 0x4c, 0x00, DRV_EC_ERROR, - "logical unit failed self-configuration", - 0xff, 0x4d, 0xff, DRV_EC_ERROR, - "tagged overlapped commands (nn = task tag)", - 0xff, 0x4e, 0x00, DRV_EC_ERROR, - "overlapped commands attempted", - 0xff, 0x50, 0x00, DRV_EC_ERROR, - "write append error", - 0xff, 0x50, 0x01, DRV_EC_ERROR, - "write append position error", - 0xff, 0x50, 0x02, DRV_EC_ERROR, - "position error related to timing", - 0xff, 0x51, 0x00, DRV_EC_ERROR, - "erase failure", - 0xff, 0x52, 0x00, DRV_EC_ERROR, - "cartridge fault", - 0xff, 0x53, 0x00, DRV_EC_ERROR, - "media load or eject failed", - 0xff, 0x53, 0x01, DRV_EC_ERROR, - "unload tape failure", - 0xff, 0x53, 0x02, DRV_EC_ERROR, - "medium removal prevented", - 0xff, 0x53, 0x04, DRV_EC_ERROR, - "medium thread or unthread failure", - 0xff, 0x55, 0x02, DRV_EC_ERROR, - "insufficient reservation resources", - 0xff, 0x55, 0x03, DRV_EC_ERROR, - "insufficient resources", - 0xff, 0x55, 0x04, DRV_EC_ERROR, - "insufficient registration resources", - 0xff, 0x55, 0x05, DRV_EC_ERROR, - "insufficient access control resources", - 0xff, 0x55, 0x06, DRV_EC_ERROR, - "auxiliary memory out of space", - 0xff, 0x55, 0x08, DRV_EC_ERROR, - "maximum number of supplemental decryption keys exceeded", - 0xff, 0x5a, 0x00, DRV_EC_ERROR, - "operator request or state change input", - 0xff, 0x5a, 0x01, DRV_EC_ERROR, - "operator medium removal request", - 0xff, 0x5a, 0x02, DRV_EC_ERROR, - "operator selected write protect", - 0xff, 0x5a, 0x03, DRV_EC_ERROR, - "operator selected write permit", - 0xff, 0x5b, 0x00, DRV_EC_ERROR, - "log exception", - 0xff, 0x5b, 0x01, DRV_EC_ERROR, - "threshold condition met", - 0xff, 0x5b, 0x02, DRV_EC_ERROR, - "log counter at maximum", - 0xff, 0x5b, 0x03, DRV_EC_ERROR, - "log list codes exhausted", - 0xff, 0x5d, 0x00, DRV_EC_ERROR, - "failure prediction threshold exceeded", - 0xff, 0x5d, 0xff, DRV_EC_ERROR, - "failure prediction threshold exceeded (false)", - 0xff, 0x5e, 0x00, DRV_EC_ERROR, - "low power condition on", - 0xff, 0x5e, 0x01, DRV_EC_ERROR, - "idle condition activated by timer", - 0xff, 0x5e, 0x02, DRV_EC_ERROR, - "standby condition activated by timer", - 0xff, 0x5e, 0x03, DRV_EC_ERROR, - "idle condition activated by command", - 0xff, 0x5e, 0x04, DRV_EC_ERROR, - "standby condition activated by command", - 0xff, 0x65, 0x00, DRV_EC_ERROR, - "voltage fault", - 0xff, 0x67, 0x0a, DRV_EC_ERROR, - "set target port groups command failed", - 0xff, 0x67, 0x0b, DRV_EC_ERROR, - "ata device feature not enabled", - 0xff, 0x70, 0xff, DRV_EC_ERROR, - "decompression exception short algorithm id of nn", - 0xff, 0x71, 0x00, DRV_EC_ERROR, - "decompression exception long algorithm id", - 0xff, 0x74, 0x00, DRV_EC_ERROR, - "security error", - 0xff, 0x74, 0x01, DRV_EC_ERROR, - "unable to decrypt data", - 0xff, 0x74, 0x02, DRV_EC_ERROR, - "unencrypted data encountered while decrypting", - 0xff, 0x74, 0x03, DRV_EC_ERROR, - "incorrect data encryption key", - 0xff, 0x74, 0x04, DRV_EC_ERROR, - "cryptographic integrity validation failed", - 0xff, 0x74, 0x05, DRV_EC_ERROR, - "error decrypting data", - 0xff, 0x74, 0x06, DRV_EC_ERROR, - "unknown signature verification key", - 0xff, 0x74, 0x07, DRV_EC_ERROR, - "encryption parameters not useable", - 0xff, 0x74, 0x08, DRV_EC_ERROR, - "digital signature validation failure", - 0xff, 0x74, 0x09, DRV_EC_ERROR, - "encryption mode mismatch on read", - 0xff, 0x74, 0x0a, DRV_EC_ERROR, - "encrypted block not raw read enabled", - 0xff, 0x74, 0x0b, DRV_EC_ERROR, - "incorrect encryption parameters", - 0xff, 0x74, 0x71, DRV_EC_ERROR, - "logical unit access not authorized", - - /* - * Sense keys - */ - 0x00, 0xff, 0xff, DRV_EC_NO_SENSE, - "no sense", - 0x01, 0xff, 0xff, DRV_EC_RCVD_ERR, - "recovered error", - 0x02, 0xff, 0xff, DRV_EC_NOT_READY, - "not ready", - 0x03, 0xff, 0xff, DRV_EC_MEDIUM_ERR, - "medium error", - 0x04, 0xff, 0xff, DRV_EC_HW_ERR, - "hardware error", - 0x05, 0xff, 0xff, DRV_EC_ILLEGAL_REQ, - "illegal request", - 0x06, 0xff, 0xff, DRV_EC_UNIT_ATTN, - "unit attention", - 0x07, 0xff, 0xff, DRV_EC_DATA_PROTECT, - "data protect", - 0x08, 0xff, 0xff, DRV_EC_BLANK_CHECK, - "blank check", - 0x09, 0xff, 0xff, DRV_EC_VENDOR, - "vendor specific", - 0x0a, 0xff, 0xff, DRV_EC_COPY_ABORTED, - "copy aborted", - 0x0b, 0xff, 0xff, DRV_EC_ABORTED, - "aborted command", - 0x0d, 0xff, 0xff, DRV_EC_VOL_OVERFLOW, - "volume overflow", - 0x0e, 0xff, 0xff, DRV_EC_MISCOMPARE, - "data miscompare", - - /* - * This must be the last entry - */ - 0xff, 0xff, 0xff, DRV_EC_UNKNOWN_ERR, - "Unknown error", -}; - -/* - * Initialize device. - * Real drives don't use this. - */ -int -drv_init_dev(void) -{ - return (0); -} - -/* - * drv_set_blksize - set blocksize - */ -int -drv_set_blksize(uint64_t size) -{ - drv_req_t op; - int one = 1; - - TRACE((MMS_DEBUG, "Setting blocksize to %lld", size)); - op.drv_op = MTSRSZ; - op.drv_count = size; - if (dm_mtiocltop(&op) != 0) { - return (EIO); - } - - /* - * Supresse SILI - */ - if (size == 0) { - (void) dm_ioctl(MTIOCREADIGNOREILI, &one); - } - - return (0); -} - -/* - * drv_set_blksize - set blocksize - */ -int -drv_get_blksize(uint64_t *size) -{ - drv_req_t op; - - op.drv_op = MTGRSZ; - op.drv_count = -1; - if (dm_mtiocltop(&op) != 0) { - return (EIO); - } - *size = op.drv_count; - TRACE((MMS_DEBUG, "Current blocksize %lld", *size)); - return (0); -} - -int64_t -drv_get_avail_capacity(void) -{ - mms_capacity_t cap; - - if (DRV_CALL(drv_get_capacity, (&cap)) < 0) { - return (EIO); - } - return (cap.mms_avail); -} - -int -drv_get_capacity(mms_capacity_t *cap) -{ - uchar_t buf[40]; - int off; - int i; - uint32_t code; - uint32_t max = 0; - uint32_t avail = 0; - int page_control = 1; /* return current value */ - - if (DRV_CALL(drv_log_sense, - (buf, sizeof (buf), page_control, 0x31)) != 0) { - return (EIO); - } - - for (i = 0; i < 4; i++) { - off = 4 + i * 8; - char_to_uint32(buf + off, 2, &code); - if (code == 1) { /* Max capacity */ - char_to_uint32(buf + off + 4, 4, &avail); - cap->mms_avail = avail; - break; - } - } - - for (i = 0; i < 4; i++) { - off = 4 + i * 8; - char_to_uint32(buf + off, 2, &code); - if (code == 3) { /* capacity left */ - char_to_uint32(buf + off + 4, 4, &max); - cap->mms_max = max; - break; - } - } - - if (max > 0) { - cap->mms_pc_avail = ((avail * 1000) / max + 5) / 10; - if (cap->mms_pc_avail > 100) { - cap->mms_pc_avail = 100; - } else if ((int32_t)cap->mms_pc_avail < 0) { - cap->mms_pc_avail = 0; - } - } else { - cap->mms_pc_avail = 0; - } - - TRACE((MMS_DEBUG, "Capacity: max %lld, avail %lld, avail %d%%", - cap->mms_max, cap->mms_avail, cap->mms_pc_avail)); - - return (0); -} - - -/* - * drv_mode_sense - issue mode sense - * - page - page code - * - len - allocation length - * - * - always return block descriptor block - * - always get current value - */ -int -drv_mode_sense(int page, int pc, int len) -{ - struct uscsi_cmd us; - char cdb[6] = { 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00 }; - - cdb[2] = page; /* page code */ - cdb[4] = len; /* alloc length */ - cdb[2] |= (pc << 6); /* PC bits */ - - (void) memset(&us, 0, sizeof (us)); - us.uscsi_flags = USCSI_READ; - us.uscsi_cdb = cdb; - us.uscsi_cdblen = 6; - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - us.uscsi_bufaddr = (char *)drv->drv_iobuf; - us.uscsi_buflen = len; - - TRACE((MMS_DEBUG, "Mode sense")); - if (dm_uscsi(&us)) { - return (EIO); - } - if (serr->se_status != STATUS_GOOD) { - return (EIO); - } - return (0); -} - -/* - * drv_mode_select - issue mode select - * - pf - page format - 0, no page data, or 1, send page data - * - len - allocation length - */ -int -drv_mode_select(int pf, int len) -{ - struct uscsi_cmd us; - char cdb[6] = { 0x15, 0x00, 0x00, 0x00, 0x00, 0x00 }; - - drv->drv_iobuf[0] = 0; - drv->drv_iobuf[1] = 0; - drv->drv_iobuf[2] &= ~0x80; - drv->drv_iobuf[8] = 0; - - cdb[1] |= (pf << 4); - cdb[4] = len; - - (void) memset(&us, 0, sizeof (us)); - us.uscsi_flags = USCSI_WRITE; - us.uscsi_cdb = cdb; - us.uscsi_cdblen = 6; - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - us.uscsi_bufaddr = (char *)drv->drv_iobuf; - us.uscsi_buflen = len; - - TRACE((MMS_DEBUG, "Mode select")); - if (dm_uscsi(&us)) { - return (EIO); - } - if (serr->se_status != STATUS_GOOD) { - return (EIO); - } - return (0); -} - -int -drv_inquiry(void) -{ - struct uscsi_cmd us; - char cdb[6] = { 0x12, 0x00, 0x00, 0x00, DRV_INQ_LEN, 0 }; - - (void) memset(&us, 0, sizeof (us)); - us.uscsi_flags = USCSI_READ; - us.uscsi_cdb = cdb; - us.uscsi_cdblen = 6; - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - us.uscsi_bufaddr = (char *)drv->drv_iobuf; - us.uscsi_buflen = DRV_INQ_LEN; - - TRACE((MMS_DEBUG, "Read inquiry")); - if (dm_uscsi(&us)) { - return (EIO); - } - if (serr->se_status != STATUS_GOOD) { - return (EIO); - } - return (0); -} - -int -drv_req_sense(int len) -{ - struct uscsi_cmd us; - char cdb[6] = { 0x03, 0x00, 0x00, 0x00, 0, 0 }; - - cdb[4] = len; - (void) memset(&us, 0, sizeof (us)); - us.uscsi_flags = USCSI_READ; - us.uscsi_cdb = cdb; - us.uscsi_cdblen = 6; - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - us.uscsi_bufaddr = (char *)drv->drv_iobuf; - us.uscsi_buflen = len; - - TRACE((MMS_DEBUG, "Request sense")); - if (dm_uscsi(&us)) { - return (EIO); - } - if (serr->se_status != STATUS_GOOD) { - return (EIO); - } - return (0); -} - -int -drv_get_drivetype(void) -{ - struct mtdrivetype type; - struct mtdrivetype_request req = { 0, &type }; - - req.size = sizeof (type); - /* - * This is necessary because the MTIOCGETDRIVETYPE ioctl does not - * return the full length of the product id and we need the full - * product id. - */ - drv->drv_typename[0] = '\0'; - drv->drv_vend[0] = '\0'; - drv->drv_prod[0] = '\0'; - if (DRV_CALL(drv_inquiry, ()) == 0) { - (void) strncpy(drv->drv_vend, (char *)drv->drv_iobuf + 8, 8); - drv->drv_vend[8] = '\0'; - (void) strncpy(drv->drv_prod, (char *)drv->drv_iobuf + 16, 16); - drv->drv_prod[16] = '\0'; - } - - /* - * Try doing MTIOCGETDRIVETYPE - */ - if (dm_ioctl(MTIOCGETDRIVETYPE, &req) != 0) { - return (EIO); - } - (void) strncpy(drv->drv_typename, type.name, 64); - drv->drv_typename[64] = '\0'; - if (drv->drv_vend[0] == '\0') { - (void) strncpy(drv->drv_vend, type.vid, 8); - drv->drv_vend[8] = '\0'; - (void) strncpy(drv->drv_prod, type.vid + 8, 16); - drv->drv_prod[16] = '\0'; - } - TRACE((MMS_DEBUG, "typename \"%s\", vendor \"%s\", prod \"%s\"", - drv->drv_typename, drv->drv_vend, drv->drv_prod)); - return (0); -} - -int -drv_clrerr(void) -{ - int rc = 0; - - if (dm_ioctl(MTIOCLRERR, 0) < 0) { - rc = errno; - TRACE((MMS_ERR, "MTIOCLRERR error: %s", strerror(rc))); - } - return (rc); -} - -int -drv_read(char *buf, int len) -{ - int rc; - int err; - char dumpbuf[1024]; - - drv->drv_flags &= ~DRV_MOVE_FLAGS; - TRACE((MMS_DEBUG, "Reading %d bytes", len)); - (void) memset(serr, 0, sizeof (drv_scsi_err_t)); - rc = read(drv->drv_fd, buf, len); - if (rc <= 0) { - err = errno; - dm_get_mtstat(0); - dm_get_mt_error(err); - DRV_CALL(drv_proc_error, ()); - if (serr->se_senkey == KEY_HARDWARE_ERROR) { - /* set DriveBroken to "yes" */ - (void) dm_send_drive_broken(); - } else if (serr->se_senkey == KEY_MEDIUM_ERROR) { - /* Set CartridgeMediaError to "yes" */ - (void) dm_send_cartridge_media_error(); - } - errno = err; - } else { - (void) mms_trace_dump(buf, rc, dumpbuf, sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "Data read:\n%s", dumpbuf)); - } - - return (rc); -} - -int -drv_write(char *buf, int len) -{ - int rc = 0; - int err; - - drv->drv_flags &= ~DRV_MOVE_FLAGS; - TRACE((MMS_DEBUG, "Writing %d bytes", len)); - - while (rc == 0) { - rc = write(drv->drv_fd, buf, len); - /* - * If rc == 0, then we are in EOT and have to try again - */ - } - - if (rc != len) { - err = errno; - dm_get_mtstat(0); - dm_get_mt_error(err); - - if ((drv->drv_flags & DRV_EOM) && serr->se_resid == 0) { - /* at EOT and block was written */ - return (len); - } - DRV_CALL(drv_proc_error, ()); - - if (serr->se_senkey == KEY_HARDWARE_ERROR) { - /* set DriveBroken to "yes" */ -(void) dm_send_drive_broken(); - } else if (serr->se_senkey == KEY_MEDIUM_ERROR) { - /* Set CartridgeMediaError to "yes" */ -(void) dm_send_cartridge_media_error(); - } - errno = err; - } - - return (rc); -} - - - -/* - * drv_wtm - write tapemarks - * return residual - */ -int -drv_wtm(uint64_t count) -{ - drv_req_t op = { MTWEOF, 0 }; - int rc; - - op.drv_count = count; - - TRACE((MMS_DEBUG, "MTWEOF")); - - drv->drv_flags &= ~DRV_MOVE_FLAGS; - rc = dm_mtiocltop(&op); - drv->drv_flags &= ~DRV_MOVE_FLAGS; - if (count != serr->se_resid) { - drv->drv_flags |= (DRV_TERM_FILE | DRV_TM); - } - TRACE((MMS_DEBUG, "Wrote %lld tapemarks", count - serr->se_resid)); - if (rc == 0 && serr->se_resid == 0) { - rc = 0; - } - return (rc); -} - -int -drv_tur(void) -{ - struct uscsi_cmd us; - char cdb[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - - (void) memset(&us, 0, sizeof (us)); - us.uscsi_cdb = cdb; - us.uscsi_cdblen = 6; - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - us.uscsi_bufaddr = NULL; - us.uscsi_buflen = 0; - - TRACE((MMS_DEBUG, "TUR")); - for (;;) { - if (dm_uscsi(&us) != 0 || - serr->se_status != STATUS_GOOD) { - if (serr->se_status == STATUS_CHECK && - serr->se_senkey == KEY_UNIT_ATTENTION) { - /* ignore attention for now and try again */ - continue; - } - return (EIO); - } - break; - } - return (0); - -} - -int -drv_load(void) -{ - struct uscsi_cmd us; - char cdb[6] = { 0x1b, 0x00, 0x00, 0x00, 0x03, 0x00 }; - mms_capacity_t cap; - - TRACE((MMS_DEBUG, "Load/Retension")); - - drv->drv_flags &= ~DRV_MOVE_FLAGS; - (void) memset(&us, 0, sizeof (us)); - us.uscsi_cdb = cdb; - us.uscsi_cdblen = 6; - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - us.uscsi_bufaddr = NULL; - us.uscsi_buflen = 0; - TRACE((MMS_DEBUG, "LOAD")); - for (;;) { - if (dm_uscsi(&us) != 0) { - if (serr->se_errcl == DRV_EC_NREADY_TO_READY) { - /* Drive became ready */ - break; - } - if (serr->se_status != STATUS_GOOD) { - if (serr->se_status == STATUS_CHECK && - serr->se_senkey == KEY_UNIT_ATTENTION) { - /* ignore attention and try again */ - continue; - } - return (EIO); - } - } - break; - } - drv->drv_flags |= DRV_BOM; - DRV_CALL(drv_get_capacity, (&cap)); - drv->drv_capacity = cap.mms_max; - TRACE((MMS_DEBUG, "Cartridge \"%s\" loaded", mnt->mnt_pcl)); - return (0); -} - -int -drv_unload(void) -{ - drv_req_t op = { MTOFFL, 0 }; - - TRACE((MMS_DEBUG, "Unload/Offline")); - - if (dm_mtiocltop(&op) != 0) { - return (EIO); - } - drv->drv_flags &= DRV_LOAD_FLAGS; - if (drv->drv_vid || drv->drv_vid[0] != '\0') { - TRACE((MMS_DEBUG, "Cartridge \"%s\" unloaded", drv->drv_vid)); - } - return (0); -} - -int -drv_rewind(void) -{ - drv_req_t op = { MTREW, 0 }; - - TRACE((MMS_DEBUG, "Rewind")); - - drv->drv_flags &= ~DRV_MOVE_FLAGS; - if (dm_mtiocltop(&op) != 0) { - return (EIO); - } - drv->drv_flags |= DRV_BOM; - TRACE((MMS_DEBUG, "Cartridge rewound")); - - return (0); -} - -int -drv_seek(uint64_t count) -{ - drv_req_t op = { MTSEEK, 0 }; - - op.drv_count = count; - - TRACE((MMS_DEBUG, "Seek to logical block")); - drv->drv_flags &= ~DRV_MOVE_FLAGS; - if (dm_mtiocltop(&op) != 0) { - return (EIO); - } - TRACE((MMS_DEBUG, "Seeked to logical block %d", count)); - return (0); -} - -int -drv_tell(uint64_t *count) -{ - drv_req_t op = { MTTELL, 0 }; - - TRACE((MMS_DEBUG, "MTTELL")); - if (dm_mtiocltop(&op) != 0) { - return (EIO); - } - *count = op.drv_count; - TRACE((MMS_DEBUG, "MTTELL %lld", *count)); - return (0); -} - -int -drv_fsf(uint64_t count) -{ - drv_req_t op = { MTFSF, 0 }; - - op.drv_count = count; - - TRACE((MMS_DEBUG, "Forward space file")); - if (dm_mtiocltop(&op) != 0) { - return (EIO); - } - drv->drv_flags |= DRV_TM; - TRACE((MMS_DEBUG, "Forward spaced %lld files", - count - serr->se_resid)); - return (0); -} - -int -drv_bsf(uint64_t count) -{ - drv_req_t op = { MTBSF, 0 }; - - op.drv_count = count; - - TRACE((MMS_DEBUG, "Backward space file")); - drv->drv_flags &= ~DRV_MOVE_FLAGS; - if (dm_mtiocltop(&op) != 0) { - return (EIO); - } - drv->drv_flags |= DRV_TM; - TRACE((MMS_DEBUG, "Backward spaced %lld files", - count - serr->se_resid)); - return (0); -} - -int -drv_fsb(uint64_t count, int cross) -{ - drv_req_t op = { MTFSR, 0 }; - uint64_t resid; - int err = 0; - int rc = 0; - - op.drv_count = count; - - TRACE((MMS_DEBUG, "Forward space blocks")); - drv->drv_flags &= ~DRV_MOVE_FLAGS; - if (dm_mtiocltop(&op) != 0) { - err = errno; - if (drv->drv_flags & DRV_TM) { - /* Hit a tapemark */ - resid = serr->se_resid; - if (cross == DRV_LOGICAL_CROSS_TM) { - DRV_CALL(drv_fsf, (1)); - } - serr->se_resid = resid; - } - rc = EIO; - } - TRACE((MMS_DEBUG, "Forward spaced %lld blocks", - count - serr->se_resid)); - errno = err; - return (rc); -} - -int -drv_bsb(uint64_t count, int cross) -{ - drv_req_t op = { MTBSR, 0 }; - uint64_t resid; - int err = 0; - int rc = 0; - - op.drv_count = count; - TRACE((MMS_DEBUG, "Backward space blocks")); - drv->drv_flags &= ~DRV_MOVE_FLAGS; - if (dm_mtiocltop(&op) != 0) { - err = errno; - if (drv->drv_flags & DRV_TM) { - /* Hit a tapemark */ - resid = serr->se_resid; - if (cross == DRV_LOGICAL_CROSS_TM) { - DRV_CALL(drv_bsf, (1)); - } - serr->se_resid = resid; - } - rc = EIO; - } - TRACE((MMS_DEBUG, "Backward spaced %lld blocks", - count - serr->se_resid)); - errno = err; - return (rc); -} - -int -drv_eom(void) -{ - drv_req_t op = { MTEOM, 0 }; - - TRACE((MMS_DEBUG, "Goto EOM")); - drv->drv_flags &= ~DRV_MOVE_FLAGS; - if (dm_mtiocltop(&op) != 0) { - return (EIO); - } - return (0); -} - -int -drv_get_pos(tapepos_t *pos) -{ -#if 1 - if (dm_ioctl(MTIOCGETPOS, pos) != 0) { - return (EIO); - } - TRACE((MMS_DEBUG, "Read position %lld", pos->lgclblkno)); - return (0); -#else - int rc; - struct uscsi_cmd us; - uchar_t cdb[10] = - { 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - - (void) memset(&us, 0, sizeof (us)); - us.uscsi_flags = USCSI_READ; - us.uscsi_cdb = (char *)cdb; - us.uscsi_cdblen = sizeof (cdb); - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - us.uscsi_bufaddr = (char *)drv->drv_iobuf; - us.uscsi_buflen = 20; - - TRACE((MMS_DEBUG, "Read position")); - if (dm_uscsi(&us)) { - return (EIO); - } - if (serr->se_status != STATUS_GOOD) { - return (EIO); - } - - (void) memset(pos, 0, sizeof (tapepos_t)); - char_to_uint64(drv->drv_iobuf + 4, 4, &pos->lgclblkno); - TRACE((MMS_DEBUG, "Read position %lld", pos->lgclblkno)); - return (0); -#endif -} - -int -drv_locate(tapepos_t *pos) -{ -#if 1 - drv->drv_flags &= ~DRV_MOVE_FLAGS; - if (dm_ioctl(MTIOCRESTPOS, pos) < 0) { - return (EIO); - } - TRACE((MMS_DEBUG, "Located to %lld", pos->lgclblkno)); - return (0); -#else - int rc; - struct uscsi_cmd us; - uchar_t cdb[10] = - { 0x2b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - - if (pos->mms_type != MMS_LBLKN) { - return (EIO); - } - (void) memset(&us, 0, sizeof (us)); - us.uscsi_flags |= 0; - us.uscsi_cdb = (char *)cdb; - us.uscsi_cdblen = sizeof (cdb); - us.uscsi_timeout = drv->drv_timeout->drv_timeout; - us.uscsi_bufaddr = NULL; - us.uscsi_buflen = 0; - - int64_to_char(pos->mms_pos, cdb + 3, 4); - - drv->drv_flags &= ~DRV_MOVE_FLAGS; - TRACE((MMS_DEBUG, "Locate")); - if (dm_uscsi(&us)) { - return (EIO); - } - if (serr->se_status != STATUS_GOOD) { - return (EIO); - } - TRACE((MMS_DEBUG, "Located to %lld", pos->mms_pos)); - return (0); -#endif -} - -int -drv_log_sense(uchar_t *buf, int len, int page_control, int page_code) -{ - struct uscsi_cmd us; - uchar_t cdb[] = - { 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - char dumpbuf[1024]; - - (void) memset(&us, 0, sizeof (us)); - us.uscsi_flags = USCSI_READ; - us.uscsi_cdb = (char *)cdb; - us.uscsi_cdblen = sizeof (cdb); - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - us.uscsi_bufaddr = (char *)buf; - us.uscsi_buflen = len; - - cdb[2] = (page_control << 6) | page_code; - int32_to_char(len, cdb + 7, 2); - - TRACE((MMS_DEBUG, "Log sense")); - if (dm_uscsi(&us)) { - return (EIO); - } - if (serr->se_status != STATUS_GOOD) { - return (EIO); - } - (void) mms_trace_dump((char *)buf, len, dumpbuf, sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "log sense data:\n%s", dumpbuf)); - - return (0); -} - -int -drv_blk_limit(mms_blk_limit_t *lmt) -{ - uchar_t buf[6]; - struct uscsi_cmd us; - uchar_t cdb[] = { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00 }; - - - (void) memset(&us, 0, sizeof (us)); - us.uscsi_flags = USCSI_READ; - us.uscsi_cdb = (char *)cdb; - us.uscsi_cdblen = sizeof (cdb); - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - us.uscsi_bufaddr = (char *)buf; - us.uscsi_buflen = sizeof (buf); - - TRACE((MMS_DEBUG, "Read block limit")); - if (dm_uscsi(&us)) { - return (EIO); - } - if (serr->se_status != STATUS_GOOD) { - return (EIO); - } - - char_to_uint64(buf + 1, 3, &lmt->mms_max); - char_to_uint32(buf + 4, 2, &lmt->mms_min); - lmt->mms_gran = 2; - - return (0); -} - -int -drv_release(void) -{ - struct uscsi_cmd us; - uchar_t cdb[] = { 0x17, 0x00, 0x00, 0x00, 0x00, 0x00 }; - - - (void) memset(&us, 0, sizeof (us)); - - us.uscsi_cdb = (char *)cdb; - us.uscsi_cdblen = sizeof (cdb); - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - - TRACE((MMS_DEBUG, "Release unit")); - if (dm_uscsi(&us)) { - return (EIO); - } - if (serr->se_status != STATUS_GOOD) { - return (EIO); - } - - return (0); -} - -int -drv_prsv_register(void) -{ - struct uscsi_cmd us; - uchar_t cdb[] = /* register & ignore */ - { 0x5f, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00 }; - char parm[24]; - uint64_t key; - - (void) memset(&us, 0, sizeof (us)); - us.uscsi_flags = USCSI_WRITE; - us.uscsi_cdb = (char *)cdb; - us.uscsi_cdblen = sizeof (cdb); - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - us.uscsi_bufaddr = parm; - us.uscsi_buflen = sizeof (parm); - - (void) memset(parm, 0, sizeof (parm)); - (void) memcpy(parm + 8, DRV_PRSV_KEY, 8); - char_to_uint64((uchar_t *)DRV_PRSV_KEY, 8, &key); - TRACE((MMS_DEBUG, "Registering PRSV key: %16.16llx", key)); - - if (dm_uscsi(&us)) { - return (EIO); - } - if (serr->se_status != STATUS_GOOD) { - return (EIO); - } - - return (0); -} - -int -drv_prsv_reserve(void) -{ - struct uscsi_cmd us; - uchar_t cdb[] = - { 0x5f, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00 }; - char parm[24]; - - (void) memset(&us, 0, sizeof (us)); - us.uscsi_flags = USCSI_WRITE; - us.uscsi_cdb = (char *)cdb; - us.uscsi_cdblen = sizeof (cdb); - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - us.uscsi_bufaddr = parm; - us.uscsi_buflen = sizeof (parm); - - /* - * Set reservation key - */ - (void) memset(parm, 0, sizeof (parm)); - (void) memcpy(parm, DRV_PRSV_KEY, 8); - - if (dm_uscsi(&us)) { - return (EIO); - } - if (serr->se_status != STATUS_GOOD) { - return (EIO); - } - drv->drv_flags |= DRV_RESERVED; - TRACE((MMS_DEBUG, "Drive reserved")); - return (0); -} - -int -drv_prsv_release(void) -{ - struct uscsi_cmd us; - uchar_t cdb[] = - { 0x5f, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00 }; - char parm[24]; - - (void) memset(&us, 0, sizeof (us)); - us.uscsi_flags = USCSI_WRITE; - us.uscsi_cdb = (char *)cdb; - us.uscsi_cdblen = sizeof (cdb); - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - us.uscsi_bufaddr = parm; - us.uscsi_buflen = sizeof (parm); - - /* - * Set reservation key - */ - (void) memset(parm, 0, sizeof (parm)); - (void) memcpy(parm, DRV_PRSV_KEY, 8); - - if (dm_uscsi(&us)) { - return (EIO); - } - if (serr->se_status != STATUS_GOOD) { - return (EIO); - } - drv->drv_flags &= ~DRV_RESERVED; - TRACE((MMS_DEBUG, "Drive released")); - return (0); -} - -int -drv_prsv_preempt(char *curkey) -{ - struct uscsi_cmd us; - uchar_t cdb[] = - { 0x5f, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00 }; - char parm[24]; - - (void) memset(&us, 0, sizeof (us)); - us.uscsi_flags = USCSI_WRITE; - us.uscsi_cdb = (char *)cdb; - us.uscsi_cdblen = sizeof (cdb); - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - us.uscsi_bufaddr = parm; - us.uscsi_buflen = sizeof (parm); - - /* - * Set reservation key - */ - (void) memset(parm, 0, sizeof (parm)); - (void) memcpy(parm, DRV_PRSV_KEY, 8); - (void) memcpy(parm + 8, curkey, 8); - - if (dm_uscsi(&us)) { - return (EIO); - } - if (serr->se_status != STATUS_GOOD) { - return (EIO); - } - drv->drv_flags |= DRV_RESERVED; - TRACE((MMS_DEBUG, "Drive reserved: preempt")); - return (0); -} - -int -drv_prsv_clear(void) -{ - struct uscsi_cmd us; - uchar_t cdb[] = - { 0x5f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00 }; - char parm[24]; - - (void) memset(&us, 0, sizeof (us)); - us.uscsi_flags = USCSI_WRITE; - us.uscsi_cdb = (char *)cdb; - us.uscsi_cdblen = sizeof (cdb); - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - us.uscsi_bufaddr = parm; - us.uscsi_buflen = sizeof (parm); - - /* - * Set reservation key - */ - (void) memset(parm, 0, sizeof (parm)); - (void) memcpy(parm, DRV_PRSV_KEY, 8); - - if (dm_uscsi(&us)) { - return (EIO); - } - if (serr->se_status != STATUS_GOOD) { - return (EIO); - } - drv->drv_flags &= ~DRV_RESERVED; - TRACE((MMS_DEBUG, "Drive released: clear")); - return (0); -} - -int -drv_prsv_read_keys(char *buf, int bufsize) -{ - struct uscsi_cmd us; - uchar_t cdb[] = - { 0x5e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - - (void) memset(&us, 0, sizeof (us)); - (void) memset(buf, 0, bufsize); - int32_to_char(bufsize, cdb + 7, 2); - us.uscsi_flags |= (USCSI_RQENABLE | USCSI_READ); - us.uscsi_cdb = (char *)cdb; - us.uscsi_cdblen = sizeof (cdb); - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - us.uscsi_bufaddr = buf; - us.uscsi_buflen = bufsize; - - if (dm_uscsi(&us)) { - return (EIO); - } - if (serr->se_status != STATUS_GOOD) { - return (EIO); - } - - return (0); -} - -int -drv_prsv_read_rsv(char *buf, int bufsize) -{ - struct uscsi_cmd us; - uchar_t cdb[] = - { 0x5e, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - - (void) memset(&us, 0, sizeof (us)); - (void) memset(buf, 0, bufsize); - int32_to_char(bufsize, cdb + 7, 2); - us.uscsi_flags |= (USCSI_RQENABLE | USCSI_READ); - us.uscsi_cdb = (char *)cdb; - us.uscsi_cdblen = sizeof (cdb); - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - us.uscsi_bufaddr = buf; - us.uscsi_buflen = bufsize; - - if (dm_uscsi(&us)) { - return (EIO); - } - if (serr->se_status != STATUS_GOOD) { - return (EIO); - } - - return (0); -} - -int -drv_reserve(void) -{ - struct uscsi_cmd us; - uchar_t cdb[] = { 0x16, 0x00, 0x00, 0x00, 0x00, 0x00 }; - - - (void) memset(&us, 0, sizeof (us)); - - us.uscsi_cdb = (char *)cdb; - us.uscsi_cdblen = sizeof (cdb); - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - - TRACE((MMS_DEBUG, "Reserve unit")); - if (dm_uscsi(&us)) { - return (EIO); - } - if (serr->se_status != STATUS_GOOD) { - return (EIO); - } - - return (0); -} - -int -drv_get_serial_num(char *ser) -{ - int i; - int len; - struct uscsi_cmd us; - uchar_t cdb[] = - { 0x12, 0x01, 0x80, 0x00, MMS_READ_SER_NUM_BUF_LEN, 0x00 }; - - (void) memset(&us, 0, sizeof (us)); - us.uscsi_flags = USCSI_READ; - us.uscsi_cdb = (char *)cdb; - us.uscsi_cdblen = sizeof (cdb); - us.uscsi_timeout = drv->drv_timeout->drv_short_timeout; - us.uscsi_bufaddr = (char *)drv->drv_iobuf; - us.uscsi_buflen = MMS_READ_SER_NUM_BUF_LEN; - - TRACE((MMS_DEBUG, "Inquiry - Serial number")); - if (dm_uscsi(&us)) { - return (EIO); - } - if (serr->se_status != STATUS_GOOD) { - return (EIO); - } - - (void) memset(ser, 0, MMS_SER_NUM_LEN + 1); - len = drv->drv_iobuf[3]; - (void) strncpy(ser, (char *)drv->drv_iobuf + 4, len); - ser[len] = '\0'; - for (i = len - 1; i >= 0; i--) { - if (ser[i] == ' ' || ser[i] == '\0') { - ser[i] = '\0'; - } else { - break; - } - } - return (0); -} - -int -drv_get_write_protect(int *wp) -{ - char dumpbuf[512]; - char *buf = (char *)drv->drv_iobuf; - - /* - * Read mode sense data - */ - if (DRV_CALL(drv_mode_sense, (0x00, 0, 4)) != 0) { - return (EIO); - } - (void) mms_trace_dump(buf, 4, dumpbuf, sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "Mode sense data:\n%s", dumpbuf)); - *wp = buf[2] & 0x80 ? 1 : 0; - TRACE((MMS_DEBUG, "Cartridge write protected is %s", - *wp ? "yes" : "no")); - return (0); -} - -int -drv_set_compression(int comp) -{ - char dumpbuf[512]; - char buf[28 + 16]; - int len; - - /* - * Read mode sense data and switch to desired density - */ - if (DRV_CALL(drv_mode_sense, (0x0f, 0x00, 28)) != 0) { - return (EIO); - } - (void) mms_trace_dump((char *)drv->drv_iobuf, 28, dumpbuf, - sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "Mode sense data:\n%s", dumpbuf)); - - /* - * Set compression - */ - if (comp) { - drv->drv_iobuf[14] |= 0x80; /* enable compression */ - } else { - drv->drv_iobuf[14] &= ~0x80; /* disable compression */ - } - - (void) mms_trace_dump((char *)drv->drv_iobuf, 28, dumpbuf, - sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "Mode select data:\n%s", dumpbuf)); - (void) memcpy(buf, (char *)drv->drv_iobuf, 28); - len = 28; - - /* - * If enabling compression, set select data compression algorithm - * in sequencial access device config page (0x10) to 1 - */ - if (comp) { - if (DRV_CALL(drv_mode_sense, (0x10, 0x00, 28)) != 0) { - return (EIO); - } - (void) mms_trace_dump((char *)drv->drv_iobuf, 28, dumpbuf, - sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "Mode sense data:\n%s", dumpbuf)); - - drv->drv_iobuf[26] = 1; - drv->drv_iobuf[0] = 0; - drv->drv_iobuf[1] = 0; - (void) mms_trace_dump((char *)drv->drv_iobuf, 28, dumpbuf, - sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "Mode select data:\n%s", dumpbuf)); - (void) memcpy(buf + 28, (char *)drv->drv_iobuf + 12, 16); - len += 16; - } - - (void) memcpy((char *)drv->drv_iobuf, buf, len); - if (DRV_CALL(drv_mode_select, (1, len)) != 0) { - return (EIO); - } - - TRACE((MMS_DEBUG, "Compression %s", - (comp != 0) ? "enabled" : "disabled")); - - return (0); -} - -void -drv_disallowed(void) -{ - dm_disallowed(); -} - -void -drv_mk_prsv_key(void) -{ - dm_mk_prsv_key(); -} - -int -drv_rebind_target(void) -{ - return (dm_rebind_target()); -} - -int -drv_bind_raw_dev(int oflags) -{ - return (dm_bind_raw_dev(oflags)); -} - -void -drv_proc_error(void) -{ - /* - * Check SCSI command status - */ - if (serr->se_status == STATUS_CHECK) { - /* - * Handle USCSI error - */ - switch (serr->se_errcl) { - - - case DRV_EC_ERROR : - break; - case DRV_EC_NOT_READY : - break; - case DRV_EC_NO_SENSE : - break; - case DRV_EC_TM : - serr->se_senkey = SUN_KEY_EOF; - break; - case DRV_EC_EOD : - serr->se_senkey = KEY_BLANK_CHECK; - break; - case DRV_EC_EOM : - serr->se_senkey = SUN_KEY_EOT; - break; - case DRV_EC_BOM : - serr->se_senkey = SUN_KEY_BOT; - break; - case DRV_EC_NEEDS_CLEANING : - (void) dm_send_clean_request(); - break; - case DRV_EC_FORMAT : - break; - case DRV_EC_INTER_REQ : - break; - case DRV_EC_RESET : - break; - case DRV_EC_UNIT_ATTN : - break; - case DRV_EC_LOST_PRSV : - break; - case DRV_EC_RCVD_ERR : - break; - case DRV_EC_MEDIUM_ERR : - break; - case DRV_EC_HW_ERR : - break; - case DRV_EC_ILLEGAL_REQ : - break; - case DRV_EC_DATA_PROTECT : - break; - case DRV_EC_BLANK_CHECK : - break; - case DRV_EC_VENDOR : - break; - case DRV_EC_COPY_ABORTED : - break; - case DRV_EC_ABORTED : - break; - case DRV_EC_VOL_OVERFLOW : - break; - case DRV_EC_MISCOMPARE : - break; - case DRV_EC_NREADY_TO_READY : - break; - default : - break; - - } - } -} - -int -drv_get_statistics(void) -{ - uchar_t buf[80]; - char dumpbuf[1024]; - uint64_t val; - - (void) memset(buf, 0xff, sizeof (buf)); - /* - * log sense pages needed 0x02, 0x03, 0x0c - */ - /* - * write error counts - */ - DRV_CALL(drv_log_sense, (buf, 80, 1, 0x02)); - (void) mms_trace_dump((char *)buf, sizeof (buf), dumpbuf, - sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "log sense page 0x02:\n%s", dumpbuf)); - - (void) dm_get_log_sense_parm(buf, 0x0003, &val); - dca->dca_rcvd_write_err = val; - (void) dm_get_log_sense_parm(buf, 0x0006, &val); - dca->dca_write_err = val; - - DRV_CALL(drv_log_sense, (buf, 80, 1, 0x03)); - (void) mms_trace_dump((char *)buf, sizeof (buf), dumpbuf, - sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "log sense page 0x03:\n%s", dumpbuf)); - - (void) dm_get_log_sense_parm(buf, 0x0003, &val); - dca->dca_rcvd_read_err = val; - (void) dm_get_log_sense_parm(buf, 0x0006, &val); - dca->dca_read_err = val; - - DRV_CALL(drv_log_sense, (buf, 80, 1, 0x0c)); - (void) mms_trace_dump((char *)buf, sizeof (buf), dumpbuf, - sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "log sense page 0x0c:\n%s", dumpbuf)); - - (void) dm_get_log_sense_parm(buf, 0x0000, &val); - dca->dca_bytes_written = val; - (void) dm_get_log_sense_parm(buf, 0x0001, &val); - dca->dca_bytes_written_med = val; - - (void) dm_get_log_sense_parm(buf, 0x0003, &val); - dca->dca_bytes_read = val; - (void) dm_get_log_sense_parm(buf, 0x0002, &val); - dca->dca_bytes_read_med = val; - - return (0); -} - - -int -drv_get_density(int *den, int *comp) -{ - char dumpbuf[512]; - char *buf = (char *)drv->drv_iobuf; - int cmp; - - /* - * Read mode sense data and switch to desired density - */ - if (DRV_CALL(drv_mode_sense, (0x0f, 0, 28)) != 0) { - return (EIO); - } - (void) mms_trace_dump(buf, 28, dumpbuf, sizeof (dumpbuf)); - *den = buf[4]; - cmp = (buf[14] & 0x80) ? 1 : 0; - if (comp != NULL) { - *comp = cmp; - } - TRACE((MMS_DEBUG, "Mode sense data:\n%s", dumpbuf)); - TRACE((MMS_DEBUG, "Drive current density = %2.2x, compression is %s", - *den, cmp ? "enabled" : "disabled")); - - return (0); -} - - -int -drv_set_density(int den) -{ - char dumpbuf[512]; - - /* - * Read mode sense data and switch to desired density - */ - if (DRV_CALL(drv_mode_sense, (0x00, 0x00, 12)) != 0) { - return (EIO); - } - (void) mms_trace_dump((char *)drv->drv_iobuf, 12, dumpbuf, - sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "Mode sense data:\n%s", dumpbuf)); - - /* - * Set density - */ - drv->drv_iobuf[4] = den; - drv->drv_iobuf[0] = 0; - drv->drv_iobuf[1] = 0; - (void) mms_trace_dump((char *)drv->drv_iobuf, 12, dumpbuf, - sizeof (dumpbuf)); - TRACE((MMS_DEBUG, "Mode select data:\n%s", dumpbuf)); - - if (DRV_CALL(drv_mode_select, (0, 12)) != 0) { - return (EIO); - } - drv->drv_cur_den = den; /* save current den */ - TRACE((MMS_DEBUG, "Old density %2.2x: New density %2.2x", - mnt->mnt_bitformat->sym_code, den)); - - return (0); -} diff --git a/usr/src/lib/mms/dm/libdefault/common/mapfile-vers b/usr/src/lib/mms/dm/libdefault/common/mapfile-vers deleted file mode 100644 index 5abfcf82bf..0000000000 --- a/usr/src/lib/mms/dm/libdefault/common/mapfile-vers +++ /dev/null @@ -1,132 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - drv_bind_raw_dev; - drv_blk_limit; - drv_bsb; - drv_bsf; - drv_clrerr; - drv_density; - drv_dev_dir; - drv_disallowed; - drv_disallowed_cmds; - drv_disallowed_ioctls; - drv_drive_type; - drv_eom; - drv_fsb; - drv_fsf; - drv_get_avail_capacity; - drv_get_blksize; - drv_get_capacity; - drv_get_density; - drv_get_drivetype; - drv_get_pos; - drv_get_serial_num; - drv_get_statistics; - drv_get_write_protect; - drv_init_dev; - drv_inquiry; - drv_load; - drv_locate; - drv_log_sense; - drv_mk_prsv_key; - drv_mode_select; - drv_mode_sense; - drv_mounted; - drv_num_disallowed_cmds; - drv_num_disallowed_ioctls; - drv_proc_error; - drv_prsv_clear; - drv_prsv_preempt; - drv_prsv_read_keys; - drv_prsv_read_rsv; - drv_prsv_register; - drv_prsv_release; - drv_prsv_reserve; - drv_read; - drv_rebind_target; - drv_release; - drv_req_sense; - drv_reserve; - drv_rewind; - drv_seek; - drv_set_blksize; - drv_set_compression; - drv_set_density; - drv_shape; - drv_shape_den; - drv_skaa_tab; - drv_tell; - drv_timeout; - drv_tur; - drv_unload; - drv_write; - drv_wtm; - - char_to_uint32 = extern; - char_to_uint64 = extern; - dca = extern; - dm_bind_raw_dev = extern; - dm_disallowed = extern; - dm_get_log_sense_parm = extern; - dm_get_mt_error = extern; - dm_get_mtstat = extern; - dm_ioctl = extern; - dm_mk_prsv_key = extern; - dm_mtiocltop = extern; - dm_rebind_target = extern; - dm_send_cartridge_media_error = extern; - dm_send_clean_request = extern; - dm_send_drive_broken = extern; - dm_silent = extern; - dm_trace = extern; - dm_uscsi = extern; - drv = extern; - int32_to_char = extern; - jtab = extern; - mnt = extern; - serr = extern; - - local: - *; -}; diff --git a/usr/src/lib/mms/dm/libdefault/i386/Makefile b/usr/src/lib/mms/dm/libdefault/i386/Makefile deleted file mode 100644 index d77b753d64..0000000000 --- a/usr/src/lib/mms/dm/libdefault/i386/Makefile +++ /dev/null @@ -1,26 +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. -# -# -include ../Makefile.com diff --git a/usr/src/lib/mms/dm/libdefault/sparc/Makefile b/usr/src/lib/mms/dm/libdefault/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/dm/libdefault/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/lm/Makefile b/usr/src/lib/mms/lm/Makefile deleted file mode 100644 index 6c7cd9e1e5..0000000000 --- a/usr/src/lib/mms/lm/Makefile +++ /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 -# - -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -SUBDIRS = \ - libdisk \ - libl180 \ - libl500 \ - libl700 \ - libsl3000 \ - libsl8500 - -.KEEP_STATE: - -.PARALLEL: - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -all clean clobber lint: $(SUBDIRS) - -install: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/lm/Makefile.defs b/usr/src/lib/mms/lm/Makefile.defs deleted file mode 100644 index 41c10d9bba..0000000000 --- a/usr/src/lib/mms/lm/Makefile.defs +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -ROOTLIBDIR = $(ROOT)/usr/lib/mms/lm - -ROOTLIBS = $(LIBS:%=$(ROOTLIBDIR)/%) - -LMLIBLINKS = $(LMLINKS:%=$(ROOTLIBDIR)/%) - -ACSLSH = $(SRC)/common/mms/h diff --git a/usr/src/lib/mms/lm/Makefile.rootdirs b/usr/src/lib/mms/lm/Makefile.rootdirs deleted file mode 100644 index 9c3b2632e9..0000000000 --- a/usr/src/lib/mms/lm/Makefile.rootdirs +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# Define the transitive set of rules to create a common module's install dir -# within the proto area. -# - -include ../../Makefile.defs -include $(SRC)/lib/Makefile.targ - -$(ROOTLIBDIR): - $(INS.dir) - -$(LMLIBLINKS): $(ROOTLIBDIR) - $(RM) $@ - $(SYMLINK) $(DYNLIB) $@ - diff --git a/usr/src/lib/mms/lm/libcommon/lm_acs.h b/usr/src/lib/mms/lm/libcommon/lm_acs.h deleted file mode 100644 index 4c6ec8738d..0000000000 --- a/usr/src/lib/mms/lm/libcommon/lm_acs.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef __LM_ACS_H -#define __LM_ACS_H - - -#ifdef __cplusplus -extern "C" { -#endif - -#include <lm.h> -#include <lm_proto.h> -#include <acssys.h> -#include <acsapi.h> -#include <identifier.h> - - /* The following define the ACSLS sequence numbers */ - /* that are used by the different ACSLS commands */ - /* These cannot overlap because of the use of */ - /* threads within the LM. They should be 50 between */ - /* the different numbers. These are in acs_common.c */ -#define ACS_ENTER_SEQ 100 -#define ACS_EJECT_SEQ 150 -#define ACS_MOUNT_SEQ 200 -#define ACS_DISMOUNT_SEQ 250 -#define ACS_Q_DRIVE_SEQ 300 -#define ACS_Q_MOUNT_SEQ 350 -#define ACS_Q_VOL_SEQ 400 -#define ACS_Q_CAP_SEQ 450 -#define ACS_Q_SERVER_SEQ 500 -#define ACS_DISPLAY_SEQ 550 - - /* The following are ACSLS sequence numbers used */ - /* in lm_lcom.c */ -#define LM_EVENT_SEQ 1000 -#define LM_Q_SERVER_SEQ 1050 -#define LM_Q_LSM_SEQ 1100 -#define LM_Q_VOL_SEQ 1150 -#define LM_Q_VOL2_SEQ 1200 -#define LM_Q_DRIVE_SEQ 1250 - -#define SLOT_CFG_SIZE 75 /* The number of bytes in one slot */ - /* definition of a config slot LMPL */ - /* command */ -#define MAX_CONFIG_CARTS 420 /* Max number of cartridges that can */ - /* be processed into one config slot */ - /* LMPL command */ -#define DRIVE_CFG_SIZE 75 /* The number of bytes in one drive */ - /* definition of a config drive LMPL */ - /* command */ -#define MAX_CONFIG_DRIVES 400 /* Max number of drives that can */ - /* be processed into one config slot */ - /* LMPL command */ -#define ACS_RESPONSE 42 /* The number of cartridges or drives */ - /* that can be part of a acs response */ - /* This is the MAX_ID in the ACSLS api */ - /* code */ - -#define MAX_BAD_ACS_PKT 100 - -#define MAX_CAP_SIZE 10 -#define MAX_L180_CAPS 1 -#define MAX_L180_CAP_SIZE 10 -#define MAX_L500_CAPS 1 -#define MAX_L500_CAP_SIZE 5 -#define MAX_L700_CAPS 2 -#define MAX_L700_CAP_SIZE 20 -#define MAX_SL3000_CAPS 4 -#define MAX_SL3000_CAP_SIZE 26 -#define MAX_SL8500_CAPS 3 -#define MAX_SL8500_CAP_SIZE 39 - -typedef struct acs_rsp_ele { - mms_list_node_t acs_rsp_next; - SEQ_NO acs_seq_nmbr; - STATUS acs_status; - ACS_RESPONSE_TYPE acs_type; - REQ_ID acs_req_id; - ALIGNED_BYTES acs_rbuf[MAX_MESSAGE_SIZE / - sizeof (ALIGNED_BYTES)]; -} acs_rsp_ele_t; - -typedef struct acs_rsp { - mms_list_t acs_queue; - pthread_mutex_t acs_mutex; - pthread_cond_t acs_cv; - int acs_reading; -} acs_rsp_t; - -typedef struct acs_cap { - int cap_config; - int cap_size; - int cap_capid; - char cap_name[MAX_CAP_SIZE + 1]; -} acs_cap_t; - -typedef struct acs_drive { - int acs_max_drive; - int acs_cnt_drive; -} acs_drive_t; - -int lm_acs_init(); -acs_rsp_ele_t *lm_obtain_acs_response(SEQ_NO, char *, char *, char *); -void lm_handle_acs_cmd_error(STATUS, char *, char *, char *); -void lm_handle_acsls_error(STATUS, char *, char *, char *, char *); -void lm_handle_acsls_state(STATE, char *, char *, char *, char *); -void lm_handle_query_vol_error(STATUS, char *, char *, char *); -void lm_handle_query_mount_error(STATUS, char *, char *, char *); -void lm_handle_mount_error(STATUS, char *, char *, char *, int, int, char *, - char *, char *); -void lm_handle_dismount_error(STATUS, char *, char *, char *, char *, int, int, - char *, char *, char *); -void lm_handle_enter_error(STATUS, char *, int, char *, char *, char *); -void lm_handle_eject_error(STATUS, char *, int, char *, char *, char *); - -int lm_validate_private(mms_par_node_t *, char *, char *); -int lm_library_config_non_comm(int, char *, char *, char *); - -int lm_drive_serial_num(char *, char *, char *); -int lm_obtain_serial_num(char *, char **, char *, char *, char *); -int lm_obtain_geometry(char *, char **, char *, char *, char *); -int lm_lib_type(int, char *, char *); -int lm_num_panels(int, char *, char *); -int lm_num_vols(int *, int, char *, char *); -void lm_set_drive_disabled(char *, char *); -int lm_acs_mount(acs_rsp_ele_t **, VOLID, DRIVEID, char *, char *, char *); -int lm_acs_dismount(acs_rsp_ele_t **, VOLID, DRIVEID, char *, char *, char *); -int lm_acs_query_volume(acs_rsp_ele_t **, VOLID [], int, char *, char *, - char *); -int lm_acs_query_drive(acs_rsp_ele_t **, DRIVEID [], int, char *, char *, - char *); -int lm_acs_query_mount(acs_rsp_ele_t **, VOLID [], int, char *, char *, - char *); -int lm_acs_display(acs_rsp_ele_t **, DISPLAY_XML_DATA, char *, char *, char *); -int lm_acs_enter(acs_rsp_ele_t **, CAPID, char *, char *, char *); -int lm_acs_eject(acs_rsp_ele_t **, CAPID, VOLID [], int, char *, char *, - char *); -int lm_acs_query_server(acs_rsp_ele_t **, char *, char *, char *); -int lm_acs_query_cap(acs_rsp_ele_t **, CAPID [], char *, char *, char *); - -#ifdef __cplusplus -} -#endif - -#endif /* __LM_ACS_H */ diff --git a/usr/src/lib/mms/lm/libcommon/lm_acs_common.c b/usr/src/lib/mms/lm/libcommon/lm_acs_common.c deleted file mode 100644 index 80d72857fb..0000000000 --- a/usr/src/lib/mms/lm/libcommon/lm_acs_common.c +++ /dev/null @@ -1,2448 +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 "lm_acs.h" - -acs_rsp_t acs_rsp; - -static char *_SrcFile = __FILE__; - -int -lm_acs_init() -{ - mms_list_create(&acs_rsp.acs_queue, sizeof (acs_rsp_ele_t), - offsetof(acs_rsp_ele_t, acs_rsp_next)); - - if (pthread_mutex_init(&acs_rsp.acs_mutex, NULL) != 0) { - lm_serr(MMS_CRIT, "lm_acs_init: acs_mutex init failed, errno - " - "%s", strerror(errno)); - return (LM_ERROR); - } - - if (pthread_cond_init(&acs_rsp.acs_cv, NULL) != 0) { - lm_serr(MMS_CRIT, "lm_acs_init: acs_cv init failed, errno - %s", - strerror(errno)); - (void) pthread_mutex_destroy(&acs_rsp.acs_mutex); - return (LM_ERROR); - } - return (LM_OK); -} - -/* - * lm_handle_acs_cmd_error() - * - * Parameters: - * - status The status that was returned from ACSLS for the - * the acsls command. - * - cmd The LMPM command that is being processed. - * - tid The task id of the LMPM command that is responsible for - * the acsls command being executed. - * - msg Contains the error response that is generated. - * - * Description: - * This function is called when a ACSLS command returns something - * other than STATUS_SUCCESS. The possible return status for - * ACSLS commands are the following: - * - STATUS_IPC_FAILURE - * There was a fatal communications failure in the IPC layer. - * Most likely two internal components were unable to - * communicate. Another possible cause could be that SSI - * has failed. - * - STATUS_PROCESS_FAILURE - * The ACSLM was not able to spawn the request or the ACSLM - * received a process failure from a spawned task. - * If a status other than those above is returned, this function - * returns the error code of MMS_LM_E_INTERNAL to indicate that - * there is an internal processing error. - * - * For a STATUS_IPC_FAILURE, this routine will send a "alert" message - * to the operator interface to notify the operator that the LM has - * encountered a communication problem with ACSLS. It also will send - * a "ready disconnected" to MM, as well as set the internal state of - * the LM to "disconnected". - * - * Return Values: - * None - * - */ -void -lm_handle_acs_cmd_error(STATUS status, char *cmd, char *tid, char *msg) -{ - int class = MMS_INTERNAL; - int code; - char msg_str[1024]; - - class = MMS_INTERNAL; - - if (status == STATUS_IPC_FAILURE) { - /* Change state of LM to "disconnected" */ - if (lm_common_ready(LM_DISCONN, tid, msg) != LM_OK) - mms_trace(MMS_ERR, "lm_handle_acs_cmd_error: Failure " - "encountered while issueing ready disconnect " - "command to MM."); - lm_state = LM_DISCONNECTED; - /* Send message to operator indicating issue */ - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7203_MSG, "status", acs_status(status), NULL); - /* No need to check return status */ - lm_message("operator", "alert", msg_str); - /* Create error message for LMPM command */ - code = MMS_LM_E_DEVCOMMERR; - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7225_MSG, "cmd", cmd, "status", acs_status(status), - NULL); - } else if (status == STATUS_PROCESS_FAILURE) { - code = MMS_LM_E_DEVCMD; - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7227_MSG, "cmd", cmd, "status", acs_status(status), - NULL); - } else { - code = MMS_LM_E_INTERNAL; - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7229_MSG, "cmd", cmd, "status", acs_status(status), - NULL); - } - - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, mms_sym_code_to_str(class), - mms_sym_code_to_str(code), msg_str); -} - -/* - * lm_handle_acsls_rsp_error() - * - * Parameters: - * - status The status that was returned from acs_response(). - * - acsls The acsls command the response was for. - * - cmd The LMPM command that is being processed. - * - tid The task id of the LMPM command that is responsible for - * the acsls command being executed. - * - msg Contains the error response that is generated. - * - * - * Description: - * This function is called when acs_response() returns something - * other than STATUS_SUCCESS. The possible return status for - * acs_response are the following: - * - STATUS_IPC_FAILURE - * There was a fatal communications failure in the IPC layer. - * Most likely two internal components were unable to - * communicate. - * - STATUS_PENDING - * The ACS response will return this status when there is no - * input from the SSI. - * - STATUS_PROCESS_FAILURE - * The ACSLM was not able to spawn the request or the ACSLM - * received a process failure from a spawned task. - * If a status other than those above is returned, this function - * returns the error code of MMS_LM_E_INTERNAL to indicate that - * there is an internal processing error. - * - * For STATUS_IPC_FAILURE and STATUS_PENDING, this routine will send - * a "alert" message to the operator interface to notify the operator - * that the LM has encountered a communication problem with ACSLS. It - * also will send a "ready disconnected" to MM, as well as set the - * internal state of the LM to "disconnected". - * - * Return Values: - * None - */ -void -lm_handle_acsls_rsp_error(STATUS status, char *acsls, char *cmd, char *tid, -char *msg) -{ - int class = MMS_INTERNAL; - int code; - char msg_str[1024]; - - if (status == STATUS_IPC_FAILURE || status == STATUS_PENDING) { - /* Change state of LM to "disconnected" */ - if (lm_common_ready(LM_DISCONN, tid, msg) != LM_OK) - mms_trace(MMS_ERR, "lm_handle_acsls_rsp_error: Failure " - "encountered while issueing ready disconnect " - "command to MM."); - lm_state = LM_DISCONNECTED; - /* Send message to operator indicating issue */ - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7203_MSG, "status", acs_status(status), NULL); - /* No need to check return status */ - lm_message("operator", "alert", msg_str); - /* Create error message for LMPM command */ - code = MMS_LM_E_DEVCOMMERR; - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7226_MSG, "cmd", cmd, "acsls", acsls, - "status", acs_status(status), NULL); - } else if (status == STATUS_PROCESS_FAILURE) { - code = MMS_LM_E_DEVCMD; - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7228_MSG, "cmd", cmd, "acsls", acsls, - "status", acs_status(status), NULL); - } else { - code = MMS_LM_E_INTERNAL; - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7230_MSG, "cmd", cmd, "acsls", acsls, - "status", acs_status(status), NULL); - } - - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, mms_sym_code_to_str(class), - mms_sym_code_to_str(code), msg_str); -} - -/* - * lm_handle_acsls_status_error() - * - * Parameters: - * - class The class of error used in error response. - * - code The code of error used in error response. - * - status The ACSLS error status being handled. - * - acsls The ACSLS command that returned this error. - * - cmd The LMPM command being processed. - * - tid The task id of the LMPM command. - * - msg Will contain the error response for the LMPM command. - * - * Description: - * This function is invoked when the response status to an ACSLS command - * is one of the status that are not usually seen. This set of error - * status should not be seen and if seen, possible changes to this - * code may be needed in order to handle the error status in a - * more approiate manner. This function purpose is to log these - * response and generate an error response for the LMPM command. - * - * Return Value: - * None - * - */ -static void -lm_handle_acsls_status_error(int class, int code, STATUS status, char *acsls, -char *cmd, char *tid, char *msg) -{ - - char msg_str[1024]; - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7208_MSG, "cmd", cmd, "acsls", acsls, - "status", acs_status(status), NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, mms_sym_code_to_str(class), - mms_sym_code_to_str(code), msg_str); - -} - -/* - * lm_handle_drive_offline_error() - * - * Parameters: - * - drive The name of the drive in the LMPM command - * - geometry The geometry of the drive in the ACSLS library - * - cart If the LMPM command is a unmount, it contains the - * cartridge barcode. If the LMPM command is mount, it - * contains an empty string. - * - panel The ACSLS panel number of the drive. - * - acsls The ACSLS command that returned this error. - * - cmd The LMPM command being processed. - * - tid The task id of the LMPM command. - * - msg Will contain the error response for the LMPM command. - * - * Description: - * This function is invoked when the response status to an ACSLS command - * is STATUS_DRIVE_OFFLINE. - * - * Return Value: - * None - * - */ -static void -lm_handle_drive_offline_error(char *drive, char *serialnum, char *geometry, -char *cart, int panel, char *acsls, char *cmd, char *tid, char *msg) -{ - int rc; - int lmpl_tid; - - char msg_str[1024]; - char drive_spec[1024]; - - lmpl_rsp_ele_t *ele; - - /* Send alert message to operator indicating */ - /* that a drive was found to be offline in */ - /* ACSLS library */ - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7210_MSG, "drive", drive, "geom", serialnum, NULL); - lm_message("operator", "alert", msg_str); - - /* Generate LMPL config drive command to update */ - /* state of drive to not accessible in MM's database */ - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, "lm_handle_drive_offline_error: " - "lm_obtain_task_id failed trying to generate LMPL config " - "drive command"); - } else { - if (strcmp(acsls, "acs_mount") == 0) - (void) snprintf(drive_spec, sizeof (drive_spec), - "config task[\"%d\"] scope[partial]" - " drive [\"%s\" \"%s\" \"panel %d\" \"none\" false " - "false];", lmpl_tid, serialnum, geometry, panel); - else - (void) snprintf(drive_spec, sizeof (drive_spec), - "config task[\"%d\"] scope[partial]" - " drive [\"%s\" \"%s\" \"panel %d\" \"%s\" true " - "false];", - lmpl_tid, serialnum, geometry, panel, cart); - - mms_trace(MMS_DEBUG, "lm_handle_drive_offline_error: " - "DRIVE_SPEC:\n%s", drive_spec); - - if ((rc = lm_gen_lmpl_cmd(drive_spec, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_handle_drive_offline_error: " - "Internal processing error encountered while " - "processing LMPL config drive command"); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, "lm_handle_drive_offline_error: Did " - "not receive a success response for LMPL config " - "drive command"); - } else { - mms_trace(MMS_DEBUG, "lm_handle_drive_offline_error: " - "Got successful response for LMPL config drive " - "command"); - } - lm_remove_lmpl_cmd(lmpl_tid, ele); - } - - /* Generate error response for LMPM command */ - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7208_MSG, "cmd", cmd, "acsls", acsls, - "status", "STATUS_DRIVE_OFFLINE", NULL); - - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_READY), msg_str); -} - -/* - * lm_handle_drive_not_in_lib_error() - * - * Parameters: - * - drive The name of the drive in the LMPM command - * - geometry The geometry of the drive in the ACSLS library - * - cart If the LMPM command is a unmount, it contains the - * cartridge barcode. If the LMPM command is mount, it - * contains an empty string. - * - panel The ACSLS panel number of the drive. - * - acsls The ACSLS command that returned this error. - * - cmd The LMPM command being processed. - * - tid The task id of the LMPM command. - * - msg Will contain the error response for the LMPM command. - * - * Description: - * This function is invoked when the response status to an ACSLS command - * is STATUS_DRIVE_NOT_IN_LIBRARY. - * - * Return Value: - * None - * - */ -static void -lm_handle_drive_not_in_lib_error(char *drive, char *serialnum, char *geometry, -char *cart, int panel, char *acsls, char *cmd, char *tid, char *msg) -{ - int rc; - int lmpl_tid; - - char msg_str[1024]; - char drive_spec[1024]; - - lmpl_rsp_ele_t *ele; - - /* Send alert message to operator indicating */ - /* that a drive was not found in ACSLS library */ - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7219_MSG, "drive", drive, "geom", serialnum, NULL); - lm_message("operator", "alert", msg_str); - - /* Generate LMPL config drive command to update */ - /* state of drive to not accessible in MM's database */ - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, "lm_handle_drive_not_in_lib_error: " - "lm_obtain_task_id failed trying to generate LMPL config " - "drive command"); - } else { - - if (strcmp(acsls, "acs_mount") == 0) - (void) snprintf(drive_spec, sizeof (drive_spec), - "config task[\"%d\"] scope[partial]" - " drive [\"%s\" \"%s\" \"panel %d\" \"none\" false " - "false];", lmpl_tid, serialnum, geometry, panel); - else - (void) snprintf(drive_spec, sizeof (drive_spec), - "config task[\"%d\"] scope[partial]" - " drive [\"%s\" \"%s\" \"panel %d\" \"%s\" true " - "false];", - lmpl_tid, serialnum, geometry, panel, cart); - - mms_trace(MMS_DEBUG, "lm_handle_drive_not_in_lib_error: " - "DRIVE_SPEC:\n%s", drive_spec); - - if ((rc = lm_gen_lmpl_cmd(drive_spec, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_handle_drive_not_in_lib_error: " - "Internal processing error encountered while " - "processing LMPL config drive command"); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, "lm_handle_drive_not_in_lib_error: " - "Did not receive a success response for LMPL " - "config drive command"); - } else { - mms_trace(MMS_DEBUG, - "lm_handle_drive_not_in_lib_error: " - "Got successful response for LMPL config drive " - "command"); - } - lm_remove_lmpl_cmd(lmpl_tid, ele); - } - - /* Generate error response for LMPM command */ - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7208_MSG, "cmd", cmd, "acsls", acsls, - "status", "STATUS_DRIVE_NOT_IN_LIBRARY", NULL); - - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_READY), msg_str); -} - -/* - * lm_handle_drive_available_error() - * - * Parameters: - * - drive The name of the drive in the LMPM command - * - geometry The geometry of the drive in the ACSLS library - * - cart The cartridge name that was suppose to be in drive. - * - panel The ACSLS panel number of the drive. - * - acsls The ACSLS command that returned this error. - * - cmd The LMPM command being processed. - * - tid The task id of the LMPM command. - * - msg Will contain the error response for the LMPM command. - * - * Description: - * This function is invoked when the response status to an ACSLS command - * is STATUS_DRIVE_AVAILABLE. - * - * Return Value: - * None - * - */ -static void -lm_handle_drive_available_error(char *drive, char *serialnum, char *geometry, -/* LINTED argument unused in function: acsls */ -char *cart, int panel, char *acsls, char *cmd, char *tid, char *msg) -{ - int rc; - int lmpl_tid; - - char msg_str[1024]; - char drive_spec[1024]; - - lmpl_rsp_ele_t *ele; - - /* Send alert message to operator indicating */ - /* that a drive was found to be empty in the */ - /* ACSLS library */ - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7220_MSG, "cart", cart, "drive", drive, "geom", serialnum, NULL); - lm_message("operator", "alert", msg_str); - - /* Generate LMPL config drive command to update */ - /* state of drive to accessible in MM's database */ - /* as well as delete the SLOT for the cartridge */ - /* that was suppose to be in drive */ - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, "lm_handle_drive_available_error: " - "lm_obtain_task_id failed trying to generate LMPL config " - "drive and delslot command"); - } else { - - (void) snprintf(drive_spec, sizeof (drive_spec), - "config task[\"%d\"] scope[partial] drive " - "[\"%s\" \"%s\" \"panel %d\" \"none\" false true] delslots " - "[\"%s\"];", lmpl_tid, serialnum, geometry, panel, cart); - - mms_trace(MMS_DEBUG, "lm_handle_drive_available_error: " - "DRIVE_SPEC:\n%s", drive_spec); - - if ((rc = lm_gen_lmpl_cmd(drive_spec, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_handle_drive_available_error: " - "Internal processing error encountered while " - "processing LMPL config drive and delslot " - "command"); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, "lm_handle_drive_available_error: " - "Did not receive a success response for LMPL " - "config drive and delslot command"); - } else { - mms_trace(MMS_DEBUG, - "lm_handle_drive_available_error: Got " - "successful response for LMPL config drive " - "and delslot command"); - } - lm_remove_lmpl_cmd(lmpl_tid, ele); - } - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7215_MSG, "cmd", cmd, "drive", drive, "cart", cart, NULL); - - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_SCREMPTY), msg_str); -} - -/* - * lm_handle_lsm_offline() - * - * Parameters: - * - acsls The ACSLS command that returned this error. - * - cmd The LMPM command being processed. - * - tid The task id of the LMPM command. - * - msg Will contain the error response for the LMPM command. - * - * Description: - * This function is invoked when the response status to an ACSLS command - * is STATUS_LSM_OFFLINE. - * - * Return Value: - * None - * - */ -static void -lm_handle_lsm_offline(int lsm, char *acsls, char *cmd, char *tid, char *msg) -{ - char msg_str[1024]; - char buf[30]; - - /* If only one lsm in library set state of */ - /* library to broken */ - if (lm.lm_lsms == 1) { - if (lm_common_ready(LM_BROKE, tid, msg) != LM_OK) { - mms_trace(MMS_ERR, "lm_handle_lsm_offline_error: " - "Failure while issueing ready command to MM. " - "Unable to set state of LM to broken in MM's " - "database."); - } - lm_state = LM_BROKEN; - } - - /* Send alert message to operator indicating */ - /* that the lsm is set to offline on the */ - /* ACSLS server */ - (void) snprintf(buf, sizeof (buf), "%d,%d", lm.lm_acs, lsm); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7211_MSG, "lsm", buf, NULL); - lm_message("operator", "alert", msg_str); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7208_MSG, "cmd", cmd, "acsls", acsls, - "status", "STATUS_LSM_OFFLINE", NULL); - - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_READY), msg_str); -} - -/* - * lm_handle_database_error() - * - * Parameters: - * - acsls The ACSLS command that returned this error. - * - cmd The LMPM command being processed. - * - tid The task id of the LMPM command. - * - msg Will contain the error response for the LMPM command. - * - * Description: - * This function is invoked when the response status to an ACSLS command - * is STATUS_DATABASE_ERROR. - * - * Return Value: - * None - * - */ -static void -lm_handle_database_error(char *acsls, char *cmd, char *tid, char *msg) -{ - char msg_str[1024]; - - /* Switch state of library to broken */ - if (lm_common_ready(LM_BROKE, tid, msg) != LM_OK) { - mms_trace(MMS_ERR, "lm_handle_database_error: Failure while " - "issueing ready command to MM. Unable to set " - "state of LM to broken in MM's database."); - } - lm_state = LM_BROKEN; - - /* Send alert message to operator indicating */ - /* that the ACSLS database is generating an error */ - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7207_MSG, - "status", "STATUS_DATABASE_ERROR", "acsls", acsls, NULL); - lm_message("operator", "alert", msg_str); - - /* Create error response for LMPM command */ - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7208_MSG, "cmd", cmd, "acsls", acsls, - "status", "STATUS_DATABASE_ERROR", NULL); - - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_LIBRARY), msg_str); -} - -/* - * lm_handle_configuration_error() - * - * Parameters: - * - acsls The ACSLS command that returned this error. - * - cmd The LMPM command being processed. - * - tid The task id of the LMPM command. - * - msg Will contain the error response for the LMPM command. - * - * Description: - * This function is invoked when the response status to an ACSLS command - * is STATUS_CONFIGURATION_ERROR. - * - * Return Value: - * None - * - */ -static void -lm_handle_configuration_error(char *acsls, char *cmd, char *tid, char *msg) -{ - char msg_str[1024]; - - /* Switch state of library to broken */ - if (lm_common_ready(LM_BROKE, tid, msg) != LM_OK) { - mms_trace(MMS_ERR, - "lm_handle_configuration_error: Failure while " - "issueing ready command to MM. Unable to set " - "state of LM to broken in MM's database."); - } - lm_state = LM_BROKEN; - - /* Send alert message to operator indicating */ - /* that the ACSLS server has a configuration */ - /* issue */ - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7207_MSG, - "status", "STATUS_CONFIGURATION_ERROR", "acsls", acsls, NULL); - lm_message("operator", "alert", msg_str); - - /* Create error response for LMPM command */ - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7208_MSG, "cmd", cmd, "acsls", acsls, - "status", "STATUS_CONFIGURATION_ERROR", NULL); - - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_LIBRARY), msg_str); -} - -/* - * lm_handle_library_not_available() - * - * Parameters: - * - acsls The ACSLS command that returned this error. - * - cmd The LMPM command being processed. - * - tid The task id of the LMPM command. - * - msg Will contain the error response for the LMPM command. - * - * Description: - * This function is invoked when the response status to an ACSLS command - * is STATUS_LIBRARY_NOT_AVAILABLE. - * - * Return Value: - * None - * - */ -static void -lm_handle_library_not_available(char *acsls, char *cmd, char *tid, char *msg) -{ - char msg_str[1024]; - - acs_rsp_ele_t *acs_rsp; - ACS_QUERY_SRV_RESPONSE *srv_qp; - QU_SRV_STATUS *srv_sp; - - if (lm_common_ready(LM_BROKE, tid, msg) != LM_OK) { - mms_trace(MMS_ERR, "lm_handle_library_not_available: Failure " - "while issueing ready command to MM. Unable to set " - "state of LM to broken in MM's database."); - } - lm_state = LM_BROKEN; - - /* Obtain the state of the ACSLS server */ - if (lm_acs_query_server(&acs_rsp, cmd, tid, msg) != LM_ERROR) { - srv_qp = (ACS_QUERY_SRV_RESPONSE *)acs_rsp->acs_rbuf; - if (srv_qp->query_srv_status == STATUS_SUCCESS) { - srv_sp = &srv_qp->srv_status[0]; - /* Send alert message to operator with */ - /* state of server */ - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7202_MSG, "state", acs_state(srv_sp->state), - NULL); - lm_message("operator", "alert", msg_str); - - /* Create error response with state of server */ - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7200_MSG, "cmd", cmd, "acsls", acsls, - "state", acs_state(srv_sp->state), NULL); - } else { - /* Send alert message to operator without */ - /* state of server */ - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7206_MSG, NULL); - lm_message("operator", "alert", msg_str); - - /* Create error response without the state */ - /* of the server */ - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7201_MSG, "cmd", cmd, "acsls", acsls, NULL); - } - } else { - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7201_MSG, "cmd", cmd, "acsls", acsls, NULL); - } - - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_READY), msg_str); -} - -void -lm_handle_acsls_error(STATUS status, char *acsls, char *cmd, char *tid, -char *msg) -{ - - char msg_str[1024]; - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7232_MSG, "cmd", cmd, "acsls", acsls, - "status", acs_status(status), NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_INTERNAL), msg_str); - -} - -void -lm_handle_query_vol_error(STATUS status, char *cmd, char *tid, char *msg) -{ - int class; - int code; - - char msg_str[512]; - - switch (status) { - case STATUS_AUDIT_IN_PROGRESS: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7204_MSG, "cmd", cmd, NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_RETRY), - mms_sym_code_to_str(MMS_LM_E_AGAIN), msg_str); - return; - - case STATUS_COMMAND_ACCESS_DENIED: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7222_MSG, "acsls", "acs_query_volume", NULL); - lm_message("operator", "alert", msg_str); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7205_MSG, "cmd", cmd, - "acsls", "acs_query_volume", - NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_DEVPREM), msg_str); - return; - - case STATUS_DATABASE_ERROR: - lm_handle_database_error("acs_query_volume", cmd, tid, - msg); - return; - - case STATUS_LIBRARY_NOT_AVAILABLE: - lm_handle_library_not_available("acs_query_volume", - cmd, tid, msg); - return; - - case STATUS_PROCESS_FAILURE: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7221_MSG, "acsls", "acs_query_volume", - "status", acs_status(status), NULL); - lm_message("operator", "alert", msg_str); - class = MMS_INTERNAL; - code = MMS_LM_E_DEVCOMMERR; - break; - - /* Non of the following status should be returned */ - /* as a response for a query_volume */ - case STATUS_CANCELLED: - case STATUS_COUNT_TOO_LARGE: - case STATUS_COUNT_TOO_SMALL: - case STATUS_INVALID_OPTION: - case STATUS_INVALID_TYPE: - case STATUS_INVALID_VERSION: - case STATUS_LOCKID_NOT_FOUND: - case STATUS_MESSAGE_TOO_LARGE: - case STATUS_MESSAGE_TOO_SMALL: - case STATUS_MISSING_OPTION: - case STATUS_UNSUPPORTED_OPTION: - case STATUS_UNSUPPORTED_TYPE: - default: - class = MMS_INTERNAL; - code = MMS_LM_E_INTERNAL; - break; - } - - lm_handle_acsls_status_error(class, code, status, "acs_query_volume", - cmd, tid, msg); -} - -void -lm_handle_query_mount_error(STATUS status, char *cmd, char *tid, char *msg) -{ - int class; - int code; - - char msg_str[512]; - - switch (status) { - case STATUS_AUDIT_IN_PROGRESS: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7204_MSG, "cmd", cmd, NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_RETRY), - mms_sym_code_to_str(MMS_LM_E_AGAIN), msg_str); - return; - - case STATUS_COMMAND_ACCESS_DENIED: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7222_MSG, "acsls", "acs_query_mount", NULL); - lm_message("operator", "alert", msg_str); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7205_MSG, "cmd", cmd, - "acsls", "acs_query_mount", - NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_DEVPREM), msg_str); - return; - - case STATUS_DATABASE_ERROR: - lm_handle_database_error("acs_query_mount", cmd, tid, - msg); - return; - - case STATUS_LIBRARY_NOT_AVAILABLE: - lm_handle_library_not_available("acs_query_mount", - cmd, tid, msg); - return; - - case STATUS_PROCESS_FAILURE: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7221_MSG, "acsls", "acs_query_mount", - "status", acs_status(status), NULL); - lm_message("operator", "alert", msg_str); - class = MMS_INTERNAL; - code = MMS_LM_E_DEVCOMMERR; - break; - - /* Non of the following status should be returned */ - /* as a response for a query_volume */ - case STATUS_CANCELLED: - case STATUS_COUNT_TOO_LARGE: - case STATUS_COUNT_TOO_SMALL: - case STATUS_INVALID_OPTION: - case STATUS_INVALID_TYPE: - case STATUS_INVALID_VERSION: - case STATUS_LOCKID_NOT_FOUND: - case STATUS_MESSAGE_TOO_LARGE: - case STATUS_MESSAGE_TOO_SMALL: - case STATUS_MISSING_OPTION: - case STATUS_UNSUPPORTED_OPTION: - case STATUS_UNSUPPORTED_TYPE: - default: - class = MMS_INTERNAL; - code = MMS_LM_E_INTERNAL; - break; - } - - lm_handle_acsls_status_error(class, code, status, "acs_query_mount", - cmd, tid, msg); -} - -void -lm_handle_mount_error(STATUS status, char *drive, char *serialnum, -char *geometry, int lsm, int panel, char *cmd, char *tid, char *msg) -{ - int class; - int code; - - char msg_str[512]; - char nbuf[20]; - - switch (status) { - case STATUS_AUDIT_IN_PROGRESS: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7204_MSG, "cmd", cmd, NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_RETRY), - mms_sym_code_to_str(MMS_LM_E_AGAIN), msg_str); - return; - - case STATUS_COMMAND_ACCESS_DENIED: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7222_MSG, "acsls", "acs_mount", NULL); - lm_message("operator", "alert", msg_str); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7205_MSG, "cmd", cmd, - "acsls", "acs_mount", NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_DEVPREM), msg_str); - return; - - case STATUS_DATABASE_ERROR: - lm_handle_database_error("acs_mount", cmd, tid, - msg); - return; - - case STATUS_LIBRARY_NOT_AVAILABLE: - lm_handle_library_not_available("acs_mount", - cmd, tid, msg); - return; - - case STATUS_LIBRARY_BUSY: - case STATUS_PROCESS_FAILURE: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7221_MSG, "acsls", "acs_mount", - "status", acs_status(status), NULL); - lm_message("operator", "alert", msg_str); - class = MMS_INTERNAL; - code = MMS_LM_E_DEVCOMMERR; - break; - - case STATUS_ACS_NOT_IN_LIBRARY: - (void) snprintf(nbuf, sizeof (nbuf), "%d", lm.lm_acs); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7217_MSG, "acs", nbuf, NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_UNKNOWN), msg_str); - return; - - case STATUS_LSM_NOT_IN_LIBRARY: - (void) snprintf(nbuf, sizeof (nbuf), - "%d,%d", lm.lm_acs, 0); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7218_MSG, "lsm", nbuf, NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_UNKNOWN), msg_str); - return; - - case STATUS_LSM_OFFLINE: - lm_handle_lsm_offline(lsm, "acs_mount", cmd, tid, msg); - return; - - case STATUS_DRIVE_OFFLINE: - lm_handle_drive_offline_error(drive, serialnum, - geometry, "", panel, "acs_mount", cmd, tid, msg); - return; - - case STATUS_DRIVE_IN_USE: - class = MMS_STATE; - code = MMS_LM_E_DESTFULL; - break; - - case STATUS_DRIVE_NOT_IN_LIBRARY: - lm_handle_drive_not_in_lib_error(drive, serialnum, - geometry, "", panel, "acs_mount", cmd, tid, msg); - return; - - case STATUS_INCOMPATIBLE_MEDIA_TYPE: - class = MMS_INVALID; - code = MMS_LM_E_SHAPE; - break; - - case STATUS_LIBRARY_FAILURE: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7209_MSG, "acsls", "acs_mount", NULL); - lm_message("operator", "alert", msg_str); - class = MMS_INTERNAL; - code = MMS_LM_E_LIBRARY; - break; - - case STATUS_VOLUME_IN_DRIVE: - class = MMS_STATE; - code = MMS_LM_E_ACCESS; - break; - - case STATUS_VOLUME_NOT_IN_LIBRARY: - case STATUS_VOLUME_MISSING: - case STATUS_VOLUME_ABSENT: - class = MMS_EXIST; - code = MMS_LM_E_NOPCL; - break; - - /* Non of the following status should be returned */ - /* as a response for a mount */ - case STATUS_CANCELLED: - case STATUS_COUNT_TOO_LARGE: - case STATUS_COUNT_TOO_SMALL: - case STATUS_INVALID_ACS: - case STATUS_INVALID_DRIVE: - case STATUS_INVALID_DRIVE_TYPE: - case STATUS_INVALID_LSM: - case STATUS_INVALID_MEDIA_TYPE: - case STATUS_INVALID_OPTION: - case STATUS_INVALID_TYPE: - case STATUS_INVALID_VERSION: - case STATUS_LOCKID_NOT_FOUND: - case STATUS_MESSAGE_TOO_LARGE: - case STATUS_MESSAGE_TOO_SMALL: - case STATUS_MISPLACED_TAPE: - case STATUS_MISSING_OPTION: - case STATUS_NOT_IN_SAME_ACS: - case STATUS_UNSUPPORTED_OPTION: - case STATUS_UNSUPPORTED_TYPE: - default: - class = MMS_INTERNAL; - code = MMS_LM_E_INTERNAL; - break; - } - - lm_handle_acsls_status_error(class, code, status, "acs_mount", cmd, - tid, msg); -} - -void -lm_handle_dismount_error(STATUS status, char *drive, char *serialnum, -char *geometry, char *cart, int lsm, int panel, char *cmd, char *tid, char *msg) -{ - int class; - int code; - - char msg_str[512]; - char nbuf[20]; - - switch (status) { - case STATUS_AUDIT_IN_PROGRESS: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7204_MSG, "cmd", cmd, NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_RETRY), - mms_sym_code_to_str(MMS_LM_E_AGAIN), msg_str); - return; - - case STATUS_COMMAND_ACCESS_DENIED: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7222_MSG, "acsls", "acs_dismount", NULL); - lm_message("operator", "alert", msg_str); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7205_MSG, "cmd", cmd, - "acsls", "acs_dismount", - NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_DEVPREM), msg_str); - return; - - case STATUS_ACS_FULL: - (void) snprintf(nbuf, sizeof (nbuf), "%d", lm.lm_acs); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7216_MSG, "cmd", cmd, "acs", nbuf, NULL); - lm_message("operator", "alert", msg_str); - - class = MMS_STATE; - code = MMS_LM_E_DEVPREM; - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(class), - mms_sym_code_to_str(code), msg_str); - return; - - case STATUS_DRIVE_AVAILABLE: - lm_handle_drive_available_error(drive, serialnum, - geometry, cart, - panel, "acs_dismount", cmd, tid, msg); - return; - - case STATUS_DATABASE_ERROR: - lm_handle_database_error("acs_dismount", cmd, tid, - msg); - return; - - case STATUS_LIBRARY_NOT_AVAILABLE: - lm_handle_library_not_available("acs_dismount", - cmd, tid, msg); - return; - - case STATUS_LIBRARY_BUSY: - case STATUS_PROCESS_FAILURE: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7221_MSG, "acsls", "acs_dismount", - "status", acs_status(status), NULL); - lm_message("operator", "alert", msg_str); - class = MMS_INTERNAL; - code = MMS_LM_E_DEVCOMMERR; - break; - - case STATUS_ACS_NOT_IN_LIBRARY: - (void) snprintf(nbuf, sizeof (nbuf), "%d", lm.lm_acs); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7217_MSG, "acs", nbuf, NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_UNKNOWN), msg_str); - return; - - case STATUS_LSM_NOT_IN_LIBRARY: - (void) snprintf(nbuf, sizeof (nbuf), - "%d,%d", lm.lm_acs, 0); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7218_MSG, "lsm", nbuf, NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_UNKNOWN), msg_str); - return; - - case STATUS_LSM_OFFLINE: - lm_handle_lsm_offline(lsm, "acs_dismount", cmd, tid, - msg); - return; - - case STATUS_DRIVE_OFFLINE: - lm_handle_drive_offline_error(drive, serialnum, - geometry, cart, - panel, "acs_dismount", cmd, tid, msg); - return; - - case STATUS_DRIVE_IN_USE: - class = MMS_STATE; - code = MMS_LM_E_DESTFULL; - break; - - case STATUS_DRIVE_NOT_IN_LIBRARY: - lm_handle_drive_not_in_lib_error(drive, serialnum, - geometry, cart, - panel, "acs_dismount", cmd, tid, msg); - return; - - case STATUS_LIBRARY_FAILURE: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7209_MSG, "acsls", "acs_dismount", NULL); - lm_message("operator", "alert", msg_str); - class = MMS_INTERNAL; - code = MMS_LM_E_LIBRARY; - break; - - case STATUS_VOLUME_NOT_IN_DRIVE: - class = MMS_INVALID; - code = MMS_LM_E_PCL; - break; - - case STATUS_VOLUME_NOT_IN_LIBRARY: - class = MMS_EXIST; - code = MMS_LM_E_NOPCL; - break; - - case STATUS_VOLUME_ACCESS_DENIED: - class = MMS_PERMPRIV; - code = MMS_LM_E_DEVPREM; - break; - - case STATUS_UNREADABLE_LABEL: - class = MMS_INVALID; - code = MMS_LM_E_NOPCL; - break; - - /* Non of the following status should be returned */ - /* as a response for a dismount */ - case STATUS_CANCELLED: - case STATUS_COUNT_TOO_LARGE: - case STATUS_COUNT_TOO_SMALL: - case STATUS_INVALID_ACS: - case STATUS_INVALID_DRIVE: - case STATUS_INVALID_LSM: - case STATUS_INVALID_OPTION: - case STATUS_INVALID_VERSION: - case STATUS_INVALID_VOLUME: - case STATUS_LOCKID_NOT_FOUND: - case STATUS_MESSAGE_TOO_LARGE: - case STATUS_MESSAGE_TOO_SMALL: - case STATUS_MISPLACED_TAPE: - case STATUS_UNSUPPORTED_OPTION: - default: - class = MMS_INTERNAL; - code = MMS_LM_E_INTERNAL; - break; - } - - lm_handle_acsls_status_error(class, code, status, "acs_mount", cmd, - tid, msg); -} - -void -lm_handle_enter_error(STATUS status, char *cap, int lsm, char *cmd, char *tid, -char *msg) -{ - int class; - int code; - - char msg_str[512]; - char nbuf[20]; - - switch (status) { - - case STATUS_CAP_IN_USE: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7212_MSG, "cap", cap, NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_RETRY), - mms_sym_code_to_str(MMS_LM_E_AGAIN), msg_str); - return; - - case STATUS_CAP_NOT_IN_LIBRARY: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7117_MSG, "port", cap, NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INVALID), - mms_sym_code_to_str(MMS_LM_E_PORT), msg_str); - return; - - case STATUS_CAP_OFFLINE: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7214_MSG, "cap", cap, "acsls", "enter", NULL); - lm_message("operator", "alert", msg_str); - - class = MMS_STATE; - code = MMS_LM_E_READY; - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_READY), msg_str); - return; - - case STATUS_INCORRECT_CAP_MODE: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7213_MSG, "cap", cap, NULL); - lm_message("operator", "alert", msg_str); - - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_DEVPREV), msg_str); - return; - - case STATUS_COMMAND_ACCESS_DENIED: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7222_MSG, "acsls", "acs_enter", NULL); - lm_message("operator", "alert", msg_str); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7205_MSG, "cmd", cmd, "acsls", "acs_enter", - NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_DEVPREM), msg_str); - return; - - case STATUS_DATABASE_ERROR: - lm_handle_database_error("acs_enter", cmd, tid, - msg); - return; - - case STATUS_CONFIGURATION_ERROR: - lm_handle_configuration_error("acs_enter", cmd, - tid, msg); - return; - - case STATUS_LIBRARY_NOT_AVAILABLE: - lm_handle_library_not_available("acs_enter", - cmd, tid, msg); - return; - - case STATUS_LIBRARY_BUSY: - case STATUS_PROCESS_FAILURE: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7221_MSG, "acsls", "acs_enter", - "status", acs_status(status), NULL); - lm_message("operator", "alert", msg_str); - class = MMS_INTERNAL; - code = MMS_LM_E_DEVCOMMERR; - break; - - case STATUS_ACS_NOT_IN_LIBRARY: - (void) snprintf(nbuf, sizeof (nbuf), "%d", lm.lm_acs); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7217_MSG, "acs", nbuf, NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_UNKNOWN), msg_str); - return; - - case STATUS_LSM_NOT_IN_LIBRARY: - (void) snprintf(nbuf, sizeof (nbuf), - "%d,%d", lm.lm_acs, 0); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7218_MSG, "lsm", nbuf, NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_UNKNOWN), msg_str); - return; - - case STATUS_LIBRARY_FAILURE: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7209_MSG, "acsls", "acs_enter", NULL); - lm_message("operator", "alert", msg_str); - class = MMS_INTERNAL; - code = MMS_LM_E_LIBRARY; - break; - - case STATUS_LSM_OFFLINE: - lm_handle_lsm_offline(lsm, "acs_enter", cmd, tid, msg); - return; - - /* Non of the following status should be returned */ - /* as a response for a enter */ - case STATUS_CANCELLED: - case STATUS_COUNT_TOO_LARGE: - case STATUS_COUNT_TOO_SMALL: - case STATUS_INVALID_ACS: - case STATUS_INVALID_CAP: - case STATUS_INVALID_LSM: - case STATUS_INVALID_MEDIA_TYPE: - case STATUS_INVALID_OPTION: - case STATUS_INVALID_VERSION: - case STATUS_LOCKID_NOT_FOUND: - case STATUS_MESSAGE_TOO_LARGE: - case STATUS_MESSAGE_TOO_SMALL: - case STATUS_UNSUPPORTED_OPTION: - default: - class = MMS_INTERNAL; - code = MMS_LM_E_INTERNAL; - break; - } - - lm_handle_acsls_status_error(class, code, status, "acs_enter", cmd, - tid, msg); -} - -void -lm_handle_eject_error(STATUS status, char *cap, int lsm, char *cmd, char *tid, -char *msg) -{ - int class; - int code; - - char msg_str[512]; - char nbuf[20]; - - switch (status) { - - case STATUS_CAP_IN_USE: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7212_MSG, "cap", cap, NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_RETRY), - mms_sym_code_to_str(MMS_LM_E_AGAIN), msg_str); - return; - - case STATUS_CAP_NOT_IN_LIBRARY: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7117_MSG, "port", cap, NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INVALID), - mms_sym_code_to_str(MMS_LM_E_PORT), msg_str); - return; - - case STATUS_CAP_OFFLINE: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7214_MSG, "cap", cap, "acsls", "eject", NULL); - lm_message("operator", "alert", msg_str); - - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_READY), msg_str); - return; - - case STATUS_COMMAND_ACCESS_DENIED: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7222_MSG, "acsls", "acs_eject", NULL); - lm_message("operator", "alert", msg_str); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7205_MSG, "cmd", cmd, "acsls", "acs_eject", - NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_DEVPREM), msg_str); - return; - - case STATUS_DATABASE_ERROR: - lm_handle_database_error("acs_eject", cmd, tid, - msg); - return; - - case STATUS_CONFIGURATION_ERROR: - lm_handle_configuration_error("acs_eject", cmd, - tid, msg); - return; - - case STATUS_LIBRARY_NOT_AVAILABLE: - lm_handle_library_not_available("acs_eject", - cmd, tid, msg); - return; - - case STATUS_LIBRARY_BUSY: - case STATUS_PROCESS_FAILURE: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7221_MSG, "acsls", "acs_eject", - "status", acs_status(status), NULL); - lm_message("operator", "alert", msg_str); - class = MMS_INTERNAL; - code = MMS_LM_E_DEVCOMMERR; - break; - - case STATUS_ACS_NOT_IN_LIBRARY: - (void) snprintf(nbuf, sizeof (nbuf), "%d", lm.lm_acs); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7217_MSG, "acs", nbuf, NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_UNKNOWN), msg_str); - return; - - case STATUS_LSM_NOT_IN_LIBRARY: - (void) snprintf(nbuf, sizeof (nbuf), - "%d,%d", lm.lm_acs, 0); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7218_MSG, "lsm", nbuf, NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_UNKNOWN), msg_str); - return; - - case STATUS_LIBRARY_FAILURE: - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7209_MSG, "acsls", "acs_eject", NULL); - lm_message("operator", "alert", msg_str); - class = MMS_INTERNAL; - code = MMS_LM_E_LIBRARY; - break; - - case STATUS_LSM_OFFLINE: - lm_handle_lsm_offline(lsm, "acs_eject", cmd, tid, msg); - return; - - /* Non of the following status should be returned */ - /* as a response for a eject */ - case STATUS_CANCELLED: - case STATUS_COUNT_TOO_LARGE: - case STATUS_COUNT_TOO_SMALL: - case STATUS_INVALID_ACS: - case STATUS_INVALID_CAP: - case STATUS_INVALID_LSM: - case STATUS_INVALID_OPTION: - case STATUS_INVALID_RANGE: - case STATUS_INVALID_VERSION: - case STATUS_LOCKID_NOT_FOUND: - case STATUS_MESSAGE_TOO_LARGE: - case STATUS_MESSAGE_TOO_SMALL: - case STATUS_UNSUPPORTED_OPTION: - case STATUS_VOLUME_ACCESS_DENIED: - default: - class = MMS_INTERNAL; - code = MMS_LM_E_INTERNAL; - break; - } - - lm_handle_acsls_status_error(class, code, status, "acs_eject", cmd, - tid, msg); -} - -void -lm_handle_acsls_state(STATE state, char *acsls, char *cmd, char *tid, char *msg) -{ - - int class; - int code; - char msg_str[1024]; - - class = MMS_INTERNAL; - code = MMS_LM_E_DEVCMD; - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7234_MSG, - "cmd", cmd, "acsls", acsls, "status", acs_state(state), NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, mms_sym_code_to_str(class), - mms_sym_code_to_str(code), msg_str); - -} - -acs_rsp_ele_t * -lm_obtain_acs_response(SEQ_NO seq, char *cmd, char *tid, char *msg) -{ - - int rc; - int not_timeout; - int acs_bad_pkt = 0; - - char msg_str[1024]; - - struct timespec timeout; - - acs_rsp_ele_t *ele; - acs_rsp_ele_t *next; - acs_rsp_ele_t *new_rsp; - - /* Lock acs response queue */ - if ((rc = pthread_mutex_lock(&acs_rsp.acs_mutex)) != 0) { - lm_serr(MMS_CRIT, "lm_obtain_acs_response: Lock of acs " - "response queue's mutex failed with errno " - "- %s", strerror(errno)); - return (NULL); - } - while (!lm_internal_error) { - - /* Go through queue to see if a response for seq */ - /* already exists */ - mms_list_foreach_safe(&acs_rsp.acs_queue, ele, next) { - if (ele->acs_seq_nmbr == seq) { - mms_trace(MMS_DEBUG, - "ele->acs_seq_nmbr: Thread " - "found a acs response for itself, seq " - "number - %d", seq); - /* Found a reponse, remove from list */ - mms_list_remove(&acs_rsp.acs_queue, ele); - /* Unlock response queue */ - if ((rc = pthread_mutex_unlock( - &acs_rsp.acs_mutex)) != 0) { - lm_serr(MMS_CRIT, - "lm_obtain_acs_response: " - "Unlock of acs response " - "queue's mutex failed with " - "errno - %s", - strerror(errno)); - return (NULL); - } - /* Return response */ - return (ele); - } - } - - /* Did not find a response for thread */ - mms_trace(MMS_DEBUG, - "lm_obtain_acs_response: acs_rsp.acs_reading - " - "%d", acs_rsp.acs_reading); - if (acs_rsp.acs_reading) { - mms_trace(MMS_DEBUG, - "lm_obtain_acs_response: Reader thread " - "already exists, going into wait, seq number " - "- %d", seq); - - not_timeout = 1; - while (not_timeout) { - timeout.tv_sec = time(NULL) + LM_THREAD_WAIT; - timeout.tv_nsec = 0; - rc = pthread_cond_timedwait(&acs_rsp.acs_cv, - &acs_rsp.acs_mutex, &timeout); - if (rc == ETIMEDOUT) - if (!lm_internal_error) - continue; - else - break; - else if (rc != 0) { - lm_serr(MMS_CRIT, - "lm_obtain_acs_response: " - "Unable to wait on acs response " - "queue's condition variable, " - "errno - %s", strerror(errno)); - (void) pthread_mutex_unlock( - &acs_rsp.acs_mutex); - return (NULL); - } - not_timeout = 0; - } - mms_trace(MMS_DEBUG, - "lm_obtain_acs_response: Thread woke up " - "by broadcast from reader thread, seq number - " - "%d", seq); - } else { - /* No acs reader, become reader */ - break; - } - } - - if (lm_internal_error) - return (NULL); - - mms_trace(MMS_DEBUG, - "lm_obtain_acs_response: Thread becoming acs_response " - "reader, seq number - %d", seq); - acs_rsp.acs_reading = 1; - while (!lm_internal_error) { - /* Unlock acs's response mutex so other threads */ - /* can look at response queue, Need to relock it */ - /* when a acs response is obtained */ - if ((rc = pthread_mutex_unlock(&acs_rsp.acs_mutex)) != 0) { - lm_serr(MMS_CRIT, - "lm_obtain_acs_response: Unlock of acs " - "response queue's mutex failed with errno " - "- %s", strerror(errno)); - return (NULL); - } - - /* Obtain next response from acsls ssi */ - if ((new_rsp = (acs_rsp_ele_t *)malloc(sizeof (acs_rsp_ele_t))) - == NULL) { - lm_serr(MMS_CRIT, "lm_obtain_acs_response: Unable to " - "malloc space for new acs response, seq num " - "- %d, errno - %s", seq, strerror(errno)); - return (NULL); - } - (void) memset(new_rsp, 0, sizeof (acs_rsp_ele_t)); - /* XXX NEED TO CHANGE THIS TO DO A TIMEOUT */ - /* CURRENTLY BLOCK FOR EVER, MAKE SURE CHECK */ - /* STATUS FOR PENDING */ - mms_trace(MMS_DEBUG, - "lm_obtain_acs_response: Read next response from " - "acsls server, seq number - %d", seq); - - /* This is done so that if type is not set */ - /* by acsls code below is insured to work */ -/* - * new_rsp->acs_type = RT_NONE; - */ - - do { - new_rsp->acs_status = acs_response(-1, - &new_rsp->acs_seq_nmbr, &new_rsp->acs_req_id, - &new_rsp->acs_type, new_rsp->acs_rbuf); - if (new_rsp->acs_type == RT_NONE) { - mms_trace(MMS_WARN, "lm_obtain_acs_response: " - "acs_response() returned a RT_NONE " - "response, status - %s", - acs_status(new_rsp->acs_status)); - if (new_rsp->acs_status == STATUS_NI_FAILURE) { - mms_trace(MMS_CRIT, - "lm_obtain_acs_response: " - "lost connection to the CSI " - "on the ACSLS server"); - if ((rc = lm_common_ready(LM_DISCONN, - tid, msg)) != LM_OK) - mms_trace(MMS_ERR, - "lm_obtain_acs_response: " - "Failure encountered while " - "issueing ready disconnect " - "command to MM."); - lm_state = LM_DISCONNECTED; - /* Send message to operator */ - /* indicating issue */ - (void) mms_buf_msgcl(msg_str, - sizeof (msg_str), - LM_7203_MSG, "status", - acs_status(new_rsp->acs_status), - NULL); - /* No need to check return */ - /* status */ - lm_message("operator", "alert", - msg_str); - /* Create error message for */ - /* LMPM command */ - (void) mms_buf_msgcl(msg_str, - sizeof (msg_str), - LM_7225_MSG, "cmd", cmd, "status", - acs_status(new_rsp->acs_status), - NULL); - (void) snprintf(msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str( - MMS_LM_E_DEVCOMMERR), msg_str); - return (NULL); - } - if (++acs_bad_pkt > MAX_BAD_ACS_PKT) { - /* XXX ADDITIONAL CHECKS CAN */ - /* BE DONE TO VERIFY THAT THE */ - /* LIBRARY IS STILL ACTIVE */ - lm_serr(MMS_CRIT, - "lm_obtain_acs_response: " - "acsls returned multiple " - "RT_NONE response packets that " - "exceed threshold"); -/* - * LEAVING FOR WHEN RECOVERY IS ADDED TO - * CHECK FOR LIBRARY. WHEN DONE LM WILL - * SWITCH LIBRARY TO BROKEN STATE - * *class = MMS_INTERNAL; - * *code = MMS_LM_E_LIBRARY; - * sprintf(msg_str, LM_7231_MSG); - * free(new_rsp); - */ - return (NULL); - } - } - } while (new_rsp->acs_type == RT_NONE); - - acs_bad_pkt = 0; - - /* Lock acs's response mutex */ - if ((rc = pthread_mutex_lock(&acs_rsp.acs_mutex)) != 0) { - lm_serr(MMS_CRIT, "lm_obtain_acs_response: Lock of acs " - "response queue's mutex failed with errno " - "- %s", strerror(errno)); - return (NULL); - } - - /* See if response is for this thread or another */ - if (new_rsp->acs_seq_nmbr == seq) { - mms_trace(MMS_DEBUG, - "lm_obtain_acs_response: Reader thread " - "found a response for itself, seq number - %d" - ", %d", seq, acs_rsp.acs_reading); - acs_rsp.acs_reading = 0; - /* Wake up any other threads waiting for a */ - /* acs_response so one of them can take over */ - /* as the reader */ - if ((rc = pthread_cond_broadcast(&acs_rsp.acs_cv)) - != 0) { - lm_serr(MMS_CRIT, "lm_obtain_acs_response: " - "broadcast to wake up threads waiting " - "for a acs_response failed with errno " - "- %s", strerror(errno)); - return (NULL); - } - if ((rc = pthread_mutex_unlock(&acs_rsp.acs_mutex)) - != 0) { - lm_serr(MMS_CRIT, - "lm_obtain_acs_response: Unlock " - "of acs response queue's mutex failed " - "with errno - %s", strerror(errno)); - return (NULL); - } - return (new_rsp); - } - - mms_trace(MMS_DEBUG, - "lm_obtain_acs_response: Reader thread received " - "a acs response that does not belong to it, seq " - "number for response - %d", new_rsp->acs_seq_nmbr); - /* Add new response to acs response queue */ - mms_list_insert_tail(&acs_rsp.acs_queue, new_rsp); - - /* Broadcast to other threads waiting on responses */ - if ((rc = pthread_cond_broadcast(&acs_rsp.acs_cv)) != 0) { - lm_serr(MMS_CRIT, - "lm_obtain_acs_response: broadcast to " - "wake up threads waiting for a acs_response " - "failed with errno - %s", strerror(errno)); - (void) pthread_mutex_unlock(&acs_rsp.acs_mutex); - return (NULL); - } - } - - /* If we get here then LM has detected an internal processing */ - /* error and all threads should exit as quickly as possible */ - return (NULL); -} - -int -lm_acs_enter(acs_rsp_ele_t **ret_rsp, CAPID cap_id, char *cmd, char *tid, - char *ret_msg) -{ - char msg_str[256]; - - STATUS status; - SEQ_NO s; - acs_rsp_ele_t *acs_rsp; - - s = (SEQ_NO)(ACS_ENTER_SEQ + pthread_self()); - - if ((status = acs_enter(s, cap_id, 0)) != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_acs_enter() failed while processing " - "inject command, status - %s", acs_status(status)); - lm_handle_acs_cmd_error(status, cmd, tid, ret_msg); - return (LM_ERROR); - } - - do { - if ((acs_rsp = lm_obtain_acs_response(s, cmd, tid, ret_msg)) - == NULL) - /* Internal error encountered */ - return (LM_ERROR); - if (acs_rsp->acs_status != STATUS_SUCCESS) { - mms_trace(MMS_CRIT, "acs_response() for acs_inject() " - "failed, status - %s", acs_status(status)); - lm_handle_acsls_rsp_error(acs_rsp->acs_status, - "acs_enter", cmd, tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - if (acs_rsp->acs_type == RT_ACKNOWLEDGE) { - mms_trace(MMS_DEBUG, - "Received acknowledge response for " - "acs_enter while processing inject commad"); - free(acs_rsp); - } else if (acs_rsp->acs_type != RT_FINAL) { - mms_trace(MMS_ERR, "Received unexpected response type " - "for acs_enter() while processing %s cmd, " - "type - %s", cmd, - acs_type_response(acs_rsp->acs_type)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7233_MSG, "cmd", cmd, "acsls", "enter", - "type", acs_type_response(acs_rsp->acs_type), - NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_DEVCOMMERR), - msg_str); - free(acs_rsp); - return (LM_ERROR); - } - } while (acs_rsp->acs_type != RT_FINAL); - - *ret_rsp = acs_rsp; - return (LM_OK); -} - -int -lm_acs_eject(acs_rsp_ele_t **ret_rsp, CAPID cap_id, VOLID vols[MAX_ID], - int cnt, char *cmd, char *tid, char *ret_msg) -{ - char msg_str[256]; - - STATUS status; - LOCKID lock_id = NO_LOCK_ID; - SEQ_NO s; - acs_rsp_ele_t *acs_rsp; - - s = (SEQ_NO)(ACS_EJECT_SEQ + pthread_self()); - - if ((status = acs_eject(s, lock_id, cap_id, cnt, vols)) - != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_acs_eject() failed while processing " - "eject command, status - %s", acs_status(status)); - lm_handle_acs_cmd_error(status, cmd, tid, ret_msg); - return (LM_ERROR); - } - - do { - if ((acs_rsp = lm_obtain_acs_response(s, cmd, tid, ret_msg)) - == NULL) - /* Internal error encountered */ - return (LM_ERROR); - if (acs_rsp->acs_status != STATUS_SUCCESS) { - mms_trace(MMS_CRIT, "acs_response() for acs_eject() " - "failed, status - %s", acs_status(status)); - lm_handle_acsls_rsp_error(acs_rsp->acs_status, - "acs_eject", cmd, tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - if (acs_rsp->acs_type == RT_ACKNOWLEDGE) { - mms_trace(MMS_DEBUG, - "Received acknowledge response for " - "acs_eject while processing eject command"); - free(acs_rsp); - } else if (acs_rsp->acs_type != RT_FINAL) { - mms_trace(MMS_ERR, "Received unexpected response type " - "for acs_eject() while processing %s cmd, " - "type - %s", cmd, - acs_type_response(acs_rsp->acs_type)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7233_MSG, "cmd", cmd, "acsls", "eject", - "type", acs_type_response(acs_rsp->acs_type), - NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_DEVCOMMERR), - msg_str); - free(acs_rsp); - return (LM_ERROR); - } - } while (acs_rsp->acs_type != RT_FINAL); - - *ret_rsp = acs_rsp; - return (LM_OK); -} - -int -lm_acs_mount(acs_rsp_ele_t **ret_rsp, VOLID vol_id, DRIVEID drive_id, - char *cmd, char *tid, char *ret_msg) -{ - char msg_str[256]; - - STATUS status; - LOCKID lock_id = NO_LOCK_ID; - SEQ_NO s; - - acs_rsp_ele_t *acs_rsp; - - s = (SEQ_NO)(ACS_MOUNT_SEQ + pthread_self()); - - if ((status = acs_mount(s, lock_id, vol_id, drive_id, FALSE, FALSE)) - != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_acs_mount() failed while processing " - "%s command, status - %s", cmd, acs_status(status)); - lm_handle_acs_cmd_error(status, cmd, tid, ret_msg); - return (LM_ERROR); - } - - do { - if ((acs_rsp = lm_obtain_acs_response(s, cmd, tid, ret_msg)) - == NULL) - /* Internal error encountered */ - return (LM_ERROR); - if (acs_rsp->acs_status != STATUS_SUCCESS) { - mms_trace(MMS_CRIT, "acs_response() for acs_mount() " - "failed while processing %s cmd, status - %s", - cmd, acs_status(acs_rsp->acs_status)); - lm_handle_acsls_rsp_error(acs_rsp->acs_status, - "acs_mount", cmd, tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - if (acs_rsp->acs_type == RT_ACKNOWLEDGE) { - mms_trace(MMS_DEBUG, - "Received acknowledge response for " - "acs_mount while processing %s command", cmd); - free(acs_rsp); - } else if (acs_rsp->acs_type != RT_FINAL) { - mms_trace(MMS_ERR, "Received unexpected response type " - "for acs_mount() while processing %s cmd, type " - "- %s", cmd, acs_type_response(acs_rsp->acs_type)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7233_MSG, "cmd", cmd, "acsls", "mount", - "type", acs_type_response(acs_rsp->acs_type), - NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_DEVCOMMERR), - msg_str); - free(acs_rsp); - return (LM_ERROR); - } - } while (acs_rsp->acs_type != RT_FINAL); - - *ret_rsp = acs_rsp; - return (LM_OK); -} - -int -lm_acs_dismount(acs_rsp_ele_t **ret_rsp, VOLID vol_id, DRIVEID drive_id, - char *cmd, char *tid, char *ret_msg) -{ - char msg_str[256]; - - STATUS status; - LOCKID lock_id = NO_LOCK_ID; - SEQ_NO s; - - acs_rsp_ele_t *acs_rsp; - - s = (SEQ_NO)(ACS_DISMOUNT_SEQ + pthread_self()); - - if ((status = acs_dismount(s, lock_id, vol_id, drive_id, TRUE)) - != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_acs_dismount() failed while processing " - "%s command, status - %s", cmd, acs_status(status)); - lm_handle_acs_cmd_error(status, cmd, tid, ret_msg); - return (LM_ERROR); - } - - do { - if ((acs_rsp = lm_obtain_acs_response(s, cmd, tid, ret_msg)) - == NULL) - /* Internal error encountered */ - return (LM_ERROR); - if (acs_rsp->acs_status != STATUS_SUCCESS) { - mms_trace(MMS_CRIT, "acs_response() for acs_dismount() " - "failed while processing %s cmd, status - %s", - cmd, acs_status(status)); - lm_handle_acsls_rsp_error(acs_rsp->acs_status, - "acs_dismount", cmd, tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - if (acs_rsp->acs_type == RT_ACKNOWLEDGE) { - mms_trace(MMS_DEBUG, - "Received acknowledge response for " - "acs_dismount while processing %s command", cmd); - free(acs_rsp); - } else if (acs_rsp->acs_type != RT_FINAL) { - mms_trace(MMS_ERR, "Received unexpected response type " - "for acs_dismount() while processing %s cmd, type " - "- %s", cmd, acs_type_response(acs_rsp->acs_type)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7233_MSG, "cmd", cmd, "acsls", "unmount", - "type", acs_type_response(acs_rsp->acs_type), - NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_DEVCOMMERR), - msg_str); - free(acs_rsp); - return (LM_ERROR); - } - } while (acs_rsp->acs_type != RT_FINAL); - - *ret_rsp = acs_rsp; - return (LM_OK); -} - -int -lm_acs_query_drive(acs_rsp_ele_t **ret_rsp, DRIVEID drive_id[MAX_ID], - int count, char *cmd, char *tid, char *ret_msg) -{ - char msg_str[256]; - - STATUS status; - SEQ_NO s; - - acs_rsp_ele_t *acs_rsp; - - s = (SEQ_NO)(ACS_Q_DRIVE_SEQ + pthread_self()); - - if ((status = acs_query_drive(s, drive_id, count)) - != STATUS_SUCCESS) { - mms_trace(MMS_ERR, - "lm_acs_query_drive() failed while processing " - "%s command, status - %s", cmd, acs_status(status)); - lm_handle_acs_cmd_error(status, cmd, tid, ret_msg); - return (LM_ERROR); - } - do { - if ((acs_rsp = lm_obtain_acs_response(s, cmd, tid, ret_msg)) - == NULL) - /* Internal error encountered */ - return (LM_ERROR); - if (acs_rsp->acs_status != STATUS_SUCCESS) { - mms_trace(MMS_CRIT, - "acs_response() for acs_query_drive() " - "failed while processing %s cmd, status - %s", - cmd, acs_status(acs_rsp->acs_status)); - lm_handle_acsls_rsp_error(acs_rsp->acs_status, - "acs_query_drive", cmd, tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - /* Query drives < MAX_ID should never get an */ - /* intermidate response */ - if (acs_rsp->acs_type == RT_ACKNOWLEDGE) { - mms_trace(MMS_DEBUG, "Received acknowledge response for" - "acs_query_drive while processing %s " - "command", cmd); - free(acs_rsp); - } else if (acs_rsp->acs_type != RT_FINAL) { - mms_trace(MMS_ERR, "Received unexpected response type " - "for acs_query_drive() while processing %s " - "command, type - %s", cmd, - acs_type_response(acs_rsp->acs_type)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7233_MSG, "cmd", cmd, "acsls", "query_drive", - "type", acs_type_response(acs_rsp->acs_type), - NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_DEVCOMMERR), - msg_str); - free(acs_rsp); - return (LM_ERROR); - } - } while (acs_rsp->acs_type != RT_FINAL); - - *ret_rsp = acs_rsp; - return (LM_OK); -} - -int -lm_acs_query_mount(acs_rsp_ele_t **ret_rsp, VOLID vol_id_list[MAX_ID], - int count, char *cmd, char *tid, char *ret_msg) -{ - char msg_str[256]; - - STATUS status; - SEQ_NO s; - - acs_rsp_ele_t *acs_rsp; - - s = (SEQ_NO)(ACS_Q_MOUNT_SEQ + pthread_self()); - - if ((status = acs_query_mount(s, vol_id_list, count)) - != STATUS_SUCCESS) { - mms_trace(MMS_ERR, - "lm_acs_query_mount() failed while processing " - "%s command, status - %s", cmd, acs_status(status)); - lm_handle_acs_cmd_error(status, cmd, tid, ret_msg); - return (LM_ERROR); - } - - acs_rsp = NULL; - do { - if (acs_rsp != NULL) - free(acs_rsp); - if ((acs_rsp = lm_obtain_acs_response(s, cmd, tid, ret_msg)) - == NULL) - /* Internal error encountered */ - return (LM_ERROR); - if (acs_rsp->acs_status != STATUS_SUCCESS) { - mms_trace(MMS_CRIT, - "acs_response() for acs_query_mount() " - "failed while processing %s cmd, status - %s", - cmd, acs_status(acs_rsp->acs_status)); - lm_handle_acsls_rsp_error(acs_rsp->acs_status, - "acs_query_mount", cmd, tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - if (acs_rsp->acs_type == RT_ACKNOWLEDGE) { - mms_trace(MMS_DEBUG, "Received acknowledge response for" - "acs_query_mount while processing %s " - "command", cmd); - continue; - } else if (acs_rsp->acs_type == RT_FINAL) { - mms_trace(MMS_DEBUG, "Received final response for " - "acs_query_mount while processing %s command", - cmd); - } else { - mms_trace(MMS_ERR, "Received unexpected response type " - "for acs_query_mount() while processing %s " - "command, type - %s", cmd, - acs_type_response(acs_rsp->acs_type)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7233_MSG, "cmd", cmd, "acsls", "query_volume", - "type", acs_type_response(acs_rsp->acs_type), - NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_DEVCOMMERR), - msg_str); - free(acs_rsp); - return (LM_ERROR); - } - } while (acs_rsp->acs_type != RT_FINAL); - free(acs_rsp); - - *ret_rsp = acs_rsp; - return (LM_OK); -} - -int -lm_acs_query_volume(acs_rsp_ele_t **ret_rsp, VOLID vol_id_list[MAX_ID], - int count, char *cmd, char *tid, char *ret_msg) -{ - char msg_str[256]; - - STATUS status; - SEQ_NO s; - - acs_rsp_ele_t *acs_rsp; - - s = (SEQ_NO)(ACS_Q_VOL_SEQ + pthread_self()); - - if ((status = acs_query_volume(s, vol_id_list, count)) - != STATUS_SUCCESS) { - mms_trace(MMS_ERR, - "lm_acs_query_volume() failed while processing " - "%s command, status - %s", cmd, acs_status(status)); - lm_handle_acs_cmd_error(status, cmd, tid, ret_msg); - return (LM_ERROR); - } - - do { - if ((acs_rsp = lm_obtain_acs_response(s, cmd, tid, ret_msg)) - == NULL) - /* Internal error encountered */ - return (LM_ERROR); - if (acs_rsp->acs_status != STATUS_SUCCESS) { - mms_trace(MMS_CRIT, - "acs_response() for acs_query_volume() " - "failed while processing %s cmd, status - %s", - cmd, acs_status(acs_rsp->acs_status)); - lm_handle_acsls_rsp_error(acs_rsp->acs_status, - "acs_query_volume", cmd, tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - /* Query volumes < MAX_ID should never get an */ - /* intermidate response */ - if (acs_rsp->acs_type == RT_ACKNOWLEDGE) { - mms_trace(MMS_DEBUG, "Received acknowledge response for" - "acs_query_volume while processing %s " - "command", cmd); - free(acs_rsp); - } else if (acs_rsp->acs_type != RT_FINAL) { - mms_trace(MMS_ERR, "Received unexpected response type " - "for acs_query_volume() while processing %s " - "command, type - %s", cmd, - acs_type_response(acs_rsp->acs_type)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7233_MSG, "cmd", cmd, "acsls", "query_volume", - "type", acs_type_response(acs_rsp->acs_type), - NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_DEVCOMMERR), - msg_str); - free(acs_rsp); - return (LM_ERROR); - } - } while (acs_rsp->acs_type != RT_FINAL); - - *ret_rsp = acs_rsp; - return (LM_OK); -} - -int -lm_acs_query_cap(acs_rsp_ele_t **ret_rsp, CAPID capid[MAX_ID], char *cmd, - char *tid, char *ret_msg) -{ - char msg_str[256]; - - STATUS status; - SEQ_NO s; - unsigned short count = 0; - - acs_rsp_ele_t *acs_rsp; - - s = (SEQ_NO)(ACS_Q_CAP_SEQ + pthread_self()); - - if ((status = acs_query_cap(s, capid, count)) != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_acs_query_cap() failed while processing " - "%s command, status - %s", cmd, acs_status(status)); - lm_handle_acs_cmd_error(status, cmd, tid, ret_msg); - return (LM_ERROR); - } - - do { - if ((acs_rsp = lm_obtain_acs_response(s, cmd, tid, ret_msg)) - == NULL) - /* Internal error encountered */ - return (LM_ERROR); - if (acs_rsp->acs_status != STATUS_SUCCESS) { - mms_trace(MMS_CRIT, - "acs_response() for acs_query_cap() " - "failed while processing %s cmd, status - %s", - cmd, acs_status(status)); - lm_handle_acsls_rsp_error(acs_rsp->acs_status, - "acs_query_cap", cmd, tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - /* Query cap should never get an */ - /* intermidate response */ - if (acs_rsp->acs_type == RT_ACKNOWLEDGE) { - mms_trace(MMS_DEBUG, - "Received acknowledge response for" - "acs_query_cap while processing %s " - "command", cmd); - free(acs_rsp); - } else if (acs_rsp->acs_type != RT_FINAL) { - mms_trace(MMS_ERR, "Received unexpected response type " - "for acs_query_cap() while processing %s " - "command, type - %s", cmd, - acs_type_response(acs_rsp->acs_type)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7233_MSG, "cmd", cmd, "acsls", "query_cap", - "type", acs_type_response(acs_rsp->acs_type), - NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_DEVCOMMERR), - msg_str); - free(acs_rsp); - return (LM_ERROR); - } - } while (acs_rsp->acs_type != RT_FINAL); - - *ret_rsp = acs_rsp; - return (LM_OK); -} - -int -lm_acs_query_server(acs_rsp_ele_t **ret_rsp, char *cmd, char *tid, -char *ret_msg) -{ - STATUS status; - SEQ_NO s; - - acs_rsp_ele_t *acs_rsp; - - s = (SEQ_NO)(ACS_Q_SERVER_SEQ + pthread_self()); - - if ((status = acs_query_server(s)) != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_acs_query_server() failed while " - "processing %s command, status - %s", - cmd, acs_status(status)); - return (LM_ERROR); - } - - do { - if ((acs_rsp = lm_obtain_acs_response(s, cmd, tid, ret_msg)) - == NULL) - /* Internal error encountered */ - return (LM_ERROR); - if (acs_rsp->acs_status != STATUS_SUCCESS) { - mms_trace(MMS_CRIT, "acs_response() " - "for acs_query_server() " - "failed while processing %s cmd, status - %s", - cmd, acs_status(status)); - free(acs_rsp); - return (LM_ERROR); - } - - /* Query server should never get an */ - /* intermidate response */ - if (acs_rsp->acs_type == RT_ACKNOWLEDGE) { - mms_trace(MMS_DEBUG, "Received acknowledge response " - "for acs_query_server while processing %s " - "command", cmd); - free(acs_rsp); - } else if (acs_rsp->acs_type != RT_FINAL) { - mms_trace(MMS_ERR, "Received unexpected response type " - "for acs_query_server() while processing %s " - "command, type - %d", cmd, acs_rsp->acs_type); - free(acs_rsp); - return (LM_ERROR); - } - } while (acs_rsp->acs_type != RT_FINAL); - - *ret_rsp = acs_rsp; - return (LM_OK); -} - -int -lm_acs_display(acs_rsp_ele_t **ret_rsp, DISPLAY_XML_DATA display_xml_data, - char *cmd, char *tid, char *ret_msg) -{ - char msg_str[256]; - - STATUS status; - TYPE display_type; - SEQ_NO s; - - acs_rsp_ele_t *acs_rsp; - - s = (SEQ_NO)(ACS_DISPLAY_SEQ + pthread_self()); - display_type = TYPE_DISPLAY; - - if ((status = acs_display(s, display_type, display_xml_data)) - != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_acs_display_drive() failed while " - "processing %s command, status - %s", cmd, - acs_status(status)); - lm_handle_acs_cmd_error(status, cmd, tid, ret_msg); - return (LM_ERROR); - } - - do { - if ((acs_rsp = lm_obtain_acs_response(s, cmd, tid, ret_msg)) - == NULL) - /* Internal error encountered */ - return (LM_ERROR); - if (acs_rsp->acs_status != STATUS_SUCCESS) { - mms_trace(MMS_CRIT, "acs_response() for acs_display() " - "failed while processing %s cmd, status - %s", - cmd, acs_status(status)); - lm_handle_acsls_rsp_error(acs_rsp->acs_status, - "acs_display_drive", cmd, tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - /* Query one volume should never get an */ - /* intermidate response */ - if (acs_rsp->acs_type == RT_ACKNOWLEDGE) { - mms_trace(MMS_DEBUG, "Received acknowledge response for" - "acs_display while processing %s " - "command", cmd); - free(acs_rsp); - } else if (acs_rsp->acs_type == RT_INTERMEDIATE) { - mms_trace(MMS_DEBUG, "Received intermediate response " - "for acs_dispaly while processing %s commmand", - cmd); - } else if (acs_rsp->acs_type != RT_FINAL) { - mms_trace(MMS_ERR, "Received unexpected response type " - "for acs_display() while processing %s " - "command, type - %s", cmd, - acs_type_response(acs_rsp->acs_type)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7233_MSG, "cmd", cmd, "acsls", "display", - "type", acs_type_response(acs_rsp->acs_type), - NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_DEVCOMMERR), - msg_str); - free(acs_rsp); - return (LM_ERROR); - } - } while (acs_rsp->acs_type != RT_FINAL); - - *ret_rsp = acs_rsp; - return (LM_OK); -} diff --git a/usr/src/lib/mms/lm/libcommon/lm_acs_display.c b/usr/src/lib/mms/lm/libcommon/lm_acs_display.c deleted file mode 100644 index 5593b98942..0000000000 --- a/usr/src/lib/mms/lm/libcommon/lm_acs_display.c +++ /dev/null @@ -1,749 +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 "lm_acs.h" -#include <lm.h> - -static char *_SrcFile = __FILE__; - -#define Ptrdiff(a, b) ((((char *)(a) - (char *)(b)) > 0) ? \ - ((char *)(a) - (char *)(b)) : 0) - -int -lm_drive_geometry(ACS_DISPLAY_RESPONSE *from_server, char **geometry) -{ - - char xml_buf[MAX_MESSAGE_SIZE]; - char *p, *pp, *qq, *ppp, *qqq; - - char tmp_str[128]; - - int j; - int acs, lsm, panel, drive; - int p_diff; - - mms_trace(MMS_DEVP, "In lm_drive_geometry"); - - mms_trace(MMS_DEBUG, "lm_drive_geometry: Type is %s", - acs_type(from_server->display_type)); - mms_trace(MMS_DEBUG, "lm_drive_geometry: XML length is %d", - from_server->display_xml_data.length); - mms_trace(MMS_DEBUG, "lm_drive_geometry: Data is \n%s", - from_server->display_xml_data.xml_data); - - (void) memset(xml_buf, 0, sizeof (xml_buf)); - (void) strncpy(xml_buf, from_server->display_xml_data.xml_data, - from_server->display_xml_data.length); - - qq = &xml_buf[0]; - while ((pp = strstr(qq, "</r>")) != NULL) { - p_diff = Ptrdiff(pp, qq); - *(qq + p_diff) = '\0'; - qqq = qq; - j = 0; - while ((ppp = strstr(qqq, "</f>")) != NULL) { - p_diff = Ptrdiff(ppp, qqq); - *(qqq + p_diff) = '\0'; - p = strrchr(qqq, '>') + 1; - if (j == 0) { - acs = atoi(p); - mms_trace(MMS_DEBUG, "acs - %d", acs); - } - if (j == 1) { - lsm = atoi(p); - mms_trace(MMS_DEBUG, "lsm - %d", lsm); - } - if (j == 2) { - panel = atoi(p); - mms_trace(MMS_DEBUG, "panel - %d", panel); - } - if (j == 3) { - drive = atoi(p); - mms_trace(MMS_DEBUG, "drive - %d", drive); - } - j++; - qqq = ppp + 4; - } - qq = pp + 4; - - } - - (void) snprintf(tmp_str, sizeof (tmp_str), "%d,%d,%d,%d", acs, lsm, - panel, drive); - *geometry = strdup(tmp_str); - return (LM_OK); -} - -int -lm_obtain_geometry(char *serial, char **geometry, char *cmd, char *tid, - char *ret_msg) -{ - ACS_DISPLAY_RESPONSE *from_server; - DISPLAY_XML_DATA display_xml_data; - acs_rsp_ele_t *acs_rsp; - - char dExample[MAX_XML_DATA_SIZE]; - char dBegin[] = - "<request type=\"DISPLAY\"><display><token>display</token>"; - char dEnd[] = "</display></request>"; - char dTokBegin[] = "<token>"; - char dTokEnd[] = "</token>"; - char token[100]; - - (void) memset(dExample, 0, MAX_XML_DATA_SIZE); - (void) strcat(dExample, dBegin); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, "drive", - dTokEnd); - (void) strcat(dExample, token); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, "*", - dTokEnd); - (void) strcat(dExample, token); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, "-serial", - dTokEnd); - (void) strcat(dExample, token); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, serial, - dTokEnd); - (void) strcat(dExample, token); - - (void) strcat(dExample, dEnd); - - display_xml_data.length = strlen(dExample); - (void) strcpy(display_xml_data.xml_data, dExample); - - if ((lm_acs_display(&acs_rsp, display_xml_data, cmd, tid, - ret_msg)) == LM_ERROR) - return (LM_ERROR); - - mms_trace(MMS_DEBUG, "lm_obtain_geometry: obtained final response from " - "display of drive serial number"); - - from_server = (ACS_DISPLAY_RESPONSE *)acs_rsp->acs_rbuf; - if (from_server->display_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, - "lm_obtain_geometry: response display status " - "failed - %s", acs_status(from_server->display_status)); - lm_handle_acsls_error(from_server->display_status, - "acs_display", cmd, tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - if (lm_drive_geometry(from_server, geometry) != LM_OK) { - mms_trace(MMS_ERR, "lm_obtain_geometry: obtaining " - "drive geometry from acs_display failed"); - free(acs_rsp); - return (LM_ERROR); - } - - free(acs_rsp); - mms_trace(MMS_DEBUG, "lm_obtain_geometry: ACSLS says drive with " - "serial number %s has a geometry of %s", serial, *geometry); - - return (LM_OK); -} - -int -lm_drive_serial(ACS_DISPLAY_RESPONSE *from_server, char **serial) -{ - - char xml_buf[MAX_MESSAGE_SIZE]; - char *p, *pp, *qq, *ppp, *qqq; - int j; - int acs, lsm, panel, drive; - int p_diff; - - mms_trace(MMS_DEVP, "In lm_drive_serial"); - - mms_trace(MMS_DEBUG, "lm_drive_serial: Type is %s", - acs_type(from_server->display_type)); - mms_trace(MMS_DEBUG, "lm_drive_serial: XML length is %d", - from_server->display_xml_data.length); - mms_trace(MMS_DEBUG, "lm_drive_serial: Data is \n%s", - from_server->display_xml_data.xml_data); - - (void) memset(xml_buf, 0, sizeof (xml_buf)); - (void) strncpy(xml_buf, from_server->display_xml_data.xml_data, - from_server->display_xml_data.length); - - qq = &xml_buf[0]; - while ((pp = strstr(qq, "</r>")) != NULL) { - p_diff = Ptrdiff(pp, qq); - *(qq + p_diff) = '\0'; - qqq = qq; - j = 0; - while ((ppp = strstr(qqq, "</f>")) != NULL) { - p_diff = Ptrdiff(ppp, qqq); - *(qqq + p_diff) = '\0'; - p = strrchr(qqq, '>') + 1; - if (j == 0) { - acs = atoi(p); - mms_trace(MMS_DEBUG, "acs - %d", acs); - } - if (j == 1) { - lsm = atoi(p); - mms_trace(MMS_DEBUG, "lsm - %d", lsm); - } - if (j == 2) { - panel = atoi(p); - mms_trace(MMS_DEBUG, "panel - %d", panel); - } - if (j == 3) { - drive = atoi(p); - mms_trace(MMS_DEBUG, "drive - %d", drive); - } - if (j == 4) { - *serial = strdup(p); - mms_trace(MMS_DEBUG, - "serial num - %s", *serial); - } - j++; - qqq = ppp + 4; - } - qq = pp + 4; - - } - return (LM_OK); -} - -int -lm_obtain_serial_num(char *geometry, char **serial, char *cmd, char *tid, - char *ret_msg) -{ - ACS_DISPLAY_RESPONSE *from_server; - DISPLAY_XML_DATA display_xml_data; - acs_rsp_ele_t *acs_rsp; - - char dExample[MAX_XML_DATA_SIZE]; - char dBegin[] = - "<request type=\"DISPLAY\"><display><token>display</token>"; - char dEnd[] = "</display></request>"; - char dTokBegin[] = "<token>"; - char dTokEnd[] = "</token>"; - char token[100]; - - (void) memset(dExample, 0, MAX_XML_DATA_SIZE); - (void) strcat(dExample, dBegin); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, "drive", - dTokEnd); - (void) strcat(dExample, token); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, geometry, - dTokEnd); - (void) strcat(dExample, token); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, "-f", - dTokEnd); - (void) strcat(dExample, token); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, - "serial_num", dTokEnd); - (void) strcat(dExample, token); - - (void) strcat(dExample, dEnd); - - display_xml_data.length = strlen(dExample); - (void) strcpy(display_xml_data.xml_data, dExample); - - if ((lm_acs_display(&acs_rsp, display_xml_data, cmd, tid, - ret_msg)) == LM_ERROR) - return (LM_ERROR); - - mms_trace(MMS_DEBUG, - "lm_obtain_serial_num: obtained final response from " - "display of drive serial number"); - - from_server = (ACS_DISPLAY_RESPONSE *)acs_rsp->acs_rbuf; - if (from_server->display_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, - "lm_obtain_serial_num: response display status " - "failed - %s", acs_status(from_server->display_status)); - lm_handle_acsls_error(from_server->display_status, - "acs_display", cmd, tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - if (lm_drive_serial(from_server, serial) != LM_OK) { - mms_trace(MMS_ERR, "lm_obtain_serial_num: obtaining " - "drive serial numbers from acs_display failed"); - free(acs_rsp); - return (LM_ERROR); - } - - free(acs_rsp); - mms_trace(MMS_DEBUG, - "lm_obtain_serial_num: ACSLS %s drive's serial number " - "is %s", geometry, *serial); - - return (LM_OK); -} - -int -lm_set_drive_serial(ACS_DISPLAY_RESPONSE *from_server, char *tid, char *ret_msg) -{ - - char xml_buf[4096]; - char str1[4096]; - char *p, *pp, *qq; - char *serial; - - char strs[20][4096]; - char strss[20][4096]; - char cmd_str[1024]; - - int rc; - int lmpl_tid; - int i, ii, j; - int acs, lsm, panel, drive; - int p_diff; - - lmpl_rsp_ele_t *ele; - - mms_trace(MMS_DEVP, "in display_drive_info"); - - mms_trace(MMS_DEBUG, "Type is %s", acs_type(from_server->display_type)); - mms_trace(MMS_DEBUG, "XML length is %d", - from_server->display_xml_data.length); - mms_trace(MMS_DEBUG, "Data is \n%s", - from_server->display_xml_data.xml_data); - - (void) memset(xml_buf, 0, sizeof (xml_buf)); - (void) strncpy(xml_buf, from_server->display_xml_data.xml_data, - from_server->display_xml_data.length); - - (void) strcpy(str1, xml_buf); - i = 0; - qq = &xml_buf[0]; - while ((pp = strstr(qq, "</r>")) != NULL) { - (void) strcpy(strs[i], qq); - p_diff = Ptrdiff(pp, qq); - strs[i][p_diff] = '\0'; - qq = pp + 4; - i++; - } - - for (ii = 0; ii < i; ii++) { - qq = &strs[ii][0]; - j = 0; - while ((pp = strstr(qq, "</f>")) != NULL) { - (void) strcpy(strss[j], qq); - p_diff = Ptrdiff(pp, qq); - strss[j][p_diff] = '\0'; - qq = pp + 4; - p = strrchr(strss[j], '>') + 1; - if (j == 0) { - acs = atoi(p); - mms_trace(MMS_DEBUG, "acs - %d", atoi(p)); - } - if (j == 1) { - lsm = atoi(p); - mms_trace(MMS_DEBUG, "lsm - %d", atoi(p)); - } - if (j == 2) { - panel = atoi(p); - mms_trace(MMS_DEBUG, "panel - %d", atoi(p)); - } - if (j == 3) { - drive = atoi(p); - mms_trace(MMS_DEBUG, "drive - %d", atoi(p)); - } - if (j == 4) { - serial = p; - mms_trace(MMS_DEBUG, "serial num - %s", p); - } - j++; - } - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, - "lm_set_drive_serial: lm_obtain_task_id " - "failed trying to generate attribute command"); - return (LM_ERROR); - } - (void) snprintf(cmd_str, sizeof (cmd_str), LM_DRIVE_SERIAL, - lmpl_tid, lm.lm_net_cfg.cli_name, acs, lsm, panel, drive, - serial); - mms_trace(MMS_DEBUG, "lm_set_drive_serial: Attribute cmd: %s", - cmd_str); - - if ((rc = lm_gen_lmpl_cmd(cmd_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_set_drive_serial: Internal " - "processing error encountered while processing " - "lmpl attribute command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_DEBUG, - "lm_set_drive_serial: Attribute cmd " - "did not get a success final response"); - handle_lmpl_cmd_error(rc, "activate", "attribute", - tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - mms_trace(MMS_DEBUG, "lm_set_drive_serial: Attribute cmd " - "got sucess final response"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - } - return (LM_OK); -} - -int -lm_drive_serial_num(char *drive, char *tid, char *ret_msg) -{ - ACS_DISPLAY_RESPONSE *from_server; - DISPLAY_XML_DATA display_xml_data; - - acs_rsp_ele_t *acs_rsp; - - char dExample[MAX_XML_DATA_SIZE]; - char dBegin[] = - "<request type=\"DISPLAY\"><display><token>display</token>"; - char dEnd[] = "</display></request>"; - char dTokBegin[] = "<token>"; - char dTokEnd[] = "</token>"; - char token[100]; - - (void) memset(dExample, 0, MAX_XML_DATA_SIZE); - (void) strcat(dExample, dBegin); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, "drive", - dTokEnd); - (void) strcat(dExample, token); - - if (drive == NULL) - (void) snprintf(token, sizeof (token), "%s%d%s%s", dTokBegin, - lm.lm_acs, ",*,*,*", dTokEnd); - else - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, - drive, dTokEnd); - - (void) strcat(dExample, token); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, "-f", - dTokEnd); - (void) strcat(dExample, token); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, - "serial_num", dTokEnd); - (void) strcat(dExample, token); - - (void) strcat(dExample, dEnd); - - display_xml_data.length = strlen(dExample); - (void) strcpy(display_xml_data.xml_data, dExample); - if ((lm_acs_display(&acs_rsp, display_xml_data, "activate", tid, - ret_msg)) == LM_ERROR) - return (LM_ERROR); - - mms_trace(MMS_DEBUG, "lm_drive_serial_num: " - "obtained final response from " - "display of drive serial numbers"); - - from_server = (ACS_DISPLAY_RESPONSE *)acs_rsp->acs_rbuf; - if (from_server->display_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, - "lm_drive_serial_num: response display status " - "failed - %s", acs_status(from_server->display_status)); - lm_handle_acsls_error(from_server->display_status, - "acs_display", "activate", tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - (void) lm_set_drive_serial(from_server, tid, ret_msg); - mms_trace(MMS_DEVP, "lm_drive_serial_num: Done with set_drive_serial"); - return (LM_OK); -} - -int -lm_get_type_info(ACS_DISPLAY_RESPONSE *from_server, char *tid, char *ret_msg) -{ - - char xml_buf[4096]; - char str1[4096]; - char *p, *pp, *qq; - char msg_str[1024]; - int p_diff; - - mms_trace(MMS_DEVP, "in display_lsm_info"); - - mms_trace(MMS_DEBUG, "Type is %s", acs_type(from_server->display_type)); - mms_trace(MMS_DEBUG, "XML length is %d", - from_server->display_xml_data.length); - (void) memset(xml_buf, 0, sizeof (xml_buf)); - (void) strncpy(xml_buf, from_server->display_xml_data.xml_data, - from_server->display_xml_data.length); - xml_buf[from_server->display_xml_data.length] = '\0'; - mms_trace(MMS_DEBUG, "Data is \n%s", xml_buf); - - (void) strcpy(str1, xml_buf); - qq = &xml_buf[0]; - pp = strstr(qq, "</r>"); - p_diff = Ptrdiff(pp, qq); - xml_buf[p_diff] = '\0'; - - qq = &xml_buf[0]; - pp = strrchr(qq, '<'); - p_diff = Ptrdiff(pp, qq); - xml_buf[p_diff] = '\0'; - p = strrchr(xml_buf, '>') + 1; - - mms_trace(MMS_DEBUG, "Library Type is %s", p); - - if (strcmp(lm.lm_type, p) != 0) { - mms_trace(MMS_ERR, "Library %s is suppose to be of type %s, " - "but ACSLS says library with ACSLS cordinates of %d,%d " - "is of type %s", lm.lm_name, lm.lm_type, lm.lm_acs, 0, p); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7033_MSG, - "type", lm.lm_type, "a_type", p, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INVALID), - mms_sym_code_to_str(MMS_LM_E_UNKNOWN), msg_str); - return (LM_ERROR); - } - - return (LM_OK); -} - -int -lm_lib_type(int lsm, char *tid, char *ret_msg) -{ - int rc; - - ACS_DISPLAY_RESPONSE *from_server; - DISPLAY_XML_DATA display_xml_data; - - acs_rsp_ele_t *acs_rsp; - - char dExample[MAX_XML_DATA_SIZE]; - char dBegin[] = - "<request type=\"DISPLAY\"><display><token>display</token>"; - char dEnd[] = "</display></request>"; - char dTokBegin[] = "<token>"; - char dTokEnd[] = "</token>"; - char token[100]; - - (void) memset(dExample, 0, MAX_XML_DATA_SIZE); - (void) strcat(dExample, dBegin); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, "lsm", - dTokEnd); - (void) strcat(dExample, token); - (void) snprintf(token, sizeof (token), "%s%d,%d%s", dTokBegin, - lm.lm_acs, lsm, dTokEnd); - (void) strcat(dExample, token); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, "-f", - dTokEnd); - (void) strcat(dExample, token); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, "type", - dTokEnd); - (void) strcat(dExample, token); - - (void) strcat(dExample, dEnd); - - display_xml_data.length = strlen(dExample); - (void) strcpy(display_xml_data.xml_data, dExample); - if ((lm_acs_display(&acs_rsp, display_xml_data, "activate", tid, - ret_msg)) == LM_ERROR) - return (LM_ERROR); - - mms_trace(MMS_DEBUG, "lm_lib_type: obtained final response from " - "display of lsm type"); - - from_server = (ACS_DISPLAY_RESPONSE *)acs_rsp->acs_rbuf; - if (from_server->display_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_lib_type: response display status " - "failed - %s", acs_status(from_server->display_status)); - lm_handle_acsls_error(from_server->display_status, - "acs_display", "activate", tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - rc = lm_get_type_info(from_server, tid, ret_msg); - - mms_trace(MMS_DEVP, "lm_lib_type: Done with get_lsm_info"); - - if (rc != LM_OK) - return (LM_ERROR); - return (LM_OK); -} - -int -lm_get_display_cnt(ACS_DISPLAY_RESPONSE *from_server) -{ - - char xml_buf[4096]; - char str1[4096]; - char *p, *pp, *qq; - - int rc; - int p_diff; - - mms_trace(MMS_DEVP, "in lm_get_display_cnt"); - - mms_trace(MMS_DEBUG, "Type is %s", acs_type(from_server->display_type)); - mms_trace(MMS_DEBUG, "lm_get_display_cnt: XML length is %d", - from_server->display_xml_data.length); - mms_trace(MMS_DEBUG, "lm_get_display_cnt: Data is \n%s", - from_server->display_xml_data.xml_data); - - (void) memset(xml_buf, 0, sizeof (xml_buf)); - (void) strncpy(xml_buf, from_server->display_xml_data.xml_data, - from_server->display_xml_data.length); - - (void) strcpy(str1, xml_buf); - qq = &xml_buf[0]; - pp = strstr(qq, "</r>"); - p_diff = Ptrdiff(pp, qq); - xml_buf[p_diff] = '\0'; - - qq = &xml_buf[0]; - pp = strrchr(qq, '<'); - p_diff = Ptrdiff(pp, qq); - xml_buf[p_diff] = '\0'; - p = strrchr(xml_buf, '>') + 1; - - rc = atoi(p); - mms_trace(MMS_DEBUG, "lm_get_display_cnt: count is %s, %d", p, rc); - return (rc); -} - -int -lm_num_panels(int lsm, char *tid, char *ret_msg) -{ - ACS_DISPLAY_RESPONSE *from_server; - DISPLAY_XML_DATA display_xml_data; - - acs_rsp_ele_t *acs_rsp; - - char dExample[MAX_XML_DATA_SIZE]; - char dBegin[] = - "<request type=\"DISPLAY\"><display><token>display</token>"; - char dEnd[] = "</display></request>"; - char dTokBegin[] = "<token>"; - char dTokEnd[] = "</token>"; - char token[100]; - - (void) memset(dExample, 0, MAX_XML_DATA_SIZE); - (void) strcat(dExample, dBegin); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, "panel", - dTokEnd); - (void) strcat(dExample, token); - (void) snprintf(token, sizeof (token), "%s%d,%d,%s%s", dTokBegin, - lm.lm_acs, lsm, "*", dTokEnd); - (void) strcat(dExample, token); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, "-c", - dTokEnd); - (void) strcat(dExample, token); - - (void) strcat(dExample, dEnd); - - display_xml_data.length = strlen(dExample); - (void) strcpy(display_xml_data.xml_data, dExample); - if ((lm_acs_display(&acs_rsp, display_xml_data, "activate", tid, - ret_msg)) == LM_ERROR) - return (LM_ERROR); - - mms_trace(MMS_DEBUG, "lm_num_panels: obtained final response from " - "display of count of panels"); - - from_server = (ACS_DISPLAY_RESPONSE *)acs_rsp->acs_rbuf; - if (from_server->display_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_num_panels: response display status " - "failed - %s", acs_status(from_server->display_status)); - lm_handle_acsls_error(from_server->display_status, - "acs_display", "activate", tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - lm.lm_panels = lm_get_display_cnt(from_server); - mms_trace(MMS_DEVP, "lm_num_panels: Number of panels is %d", - lm.lm_panels); - return (LM_OK); -} - -int -lm_num_vols(int *num_vols, int lsm, char *tid, char *ret_msg) -{ - ACS_DISPLAY_RESPONSE *from_server; - DISPLAY_XML_DATA display_xml_data; - - acs_rsp_ele_t *acs_rsp; - - char dExample[MAX_XML_DATA_SIZE]; - char dBegin[] = - "<request type=\"DISPLAY\"><display><token>display</token>"; - char dEnd[] = "</display></request>"; - char dTokBegin[] = "<token>"; - char dTokEnd[] = "</token>"; - char token[100]; - - (void) memset(dExample, 0, MAX_XML_DATA_SIZE); - (void) strcat(dExample, dBegin); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, "volume", - dTokEnd); - (void) strcat(dExample, token); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, "*", - dTokEnd); - (void) strcat(dExample, token); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, "-home", - dTokEnd); - (void) strcat(dExample, token); - (void) snprintf(token, sizeof (token), "%s%d,%d,*,*,*%s", dTokBegin, - lm.lm_acs, lsm, dTokEnd); - (void) strcat(dExample, token); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, "-c", - dTokEnd); - (void) strcat(dExample, token); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, "-status", - dTokEnd); - (void) strcat(dExample, token); - (void) snprintf(token, sizeof (token), "%s%s%s", dTokBegin, "home", - dTokEnd); - (void) strcat(dExample, token); - (void) strcat(dExample, dEnd); - - display_xml_data.length = strlen(dExample); - (void) strcpy(display_xml_data.xml_data, dExample); - if ((lm_acs_display(&acs_rsp, display_xml_data, "activate", tid, - ret_msg)) == LM_ERROR) { - mms_trace(MMS_DEBUG, "lm_num_vols: lm_acs_display failed"); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_lib_type: obtained final response from " - "acs_display for number of volumes with status of home"); - - from_server = (ACS_DISPLAY_RESPONSE *)acs_rsp->acs_rbuf; - if (from_server->display_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_num_vols: response display status " - "failed - %s", acs_status(from_server->display_status)); - lm_handle_acsls_error(from_server->display_status, - "acs_display", "activate", tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - *num_vols = lm_get_display_cnt(from_server); - mms_trace(MMS_DEVP, "lm_num_vols: Number of volumes in slots - %d", - *num_vols); - return (LM_OK); -} diff --git a/usr/src/lib/mms/lm/libcommon/lm_comm.c b/usr/src/lib/mms/lm/libcommon/lm_comm.c deleted file mode 100644 index fbb33e422a..0000000000 --- a/usr/src/lib/mms/lm/libcommon/lm_comm.c +++ /dev/null @@ -1,231 +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 "lm.h" -#include <lm_proto.h> - -static char *_SrcFile = __FILE__; - -char *lm_priv_set[] = { - "LMMessageLevel", - "TraceLevel", - "TraceFileSize", - "SystemDiskMountTimeout", - NULL }; - -char *lm_priv_unset[] = { - "LMMessageLevel", - "Tracelevel", - "TraceFileSize", - "SystemDiskMountTimeout", - NULL }; - -char *lm_priv_get[] = { - NULL }; - -/* - * lm_validate_private() - * - * Parameters: - * - cmd LMPM private command being processed. - * - tid Task id of private command being processed. - * - ret_msg Ptr to final response string. If an error message is - * to be sent to MM for the private command because of - * a failure, the response is copied here. - * - * Globals: - * - lm_priv_set The set-name values allowed in a LMPM private cmd. - * - lm_priv_get The get-name values allowed in a LMPM private cmd. - * - lm_priv_unset The unset-name values allowed in a LMPM private cmd. - * - * This function validates that all the set-name, get-name, and unset-name - * are valid. If the private command contains a name that is not known by - * LM, a error final response is sent in response the the LMPM private cmd. - * This function does not validate that the set-value is valid, while the - * set-name is being processed, the value needs to be validated. - * - * Return Values: - * - LM_OK If all names are valid LM_OK is returned. - * - LM_ERROR If a name is encountered that is not know, LM_ERROR - * is returned and ret_msg is updated to reflect the - * error final response for the LMPM private cmd. - */ -int -lm_validate_private(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - int i; - mms_par_node_t *loc = NULL; - mms_par_node_t *loc1; - char msg_str[256]; - - mms_par_node_t *clause; - mms_par_node_t *name; - mms_par_node_t *value; - - for (clause = mms_pn_lookup(cmd, "get", MMS_PN_CLAUSE, &loc); - clause != NULL; clause = mms_pn_lookup(cmd, "get", - MMS_PN_CLAUSE, &loc)) { - - mms_trace(MMS_DEBUG, "lm_v_private:, Validating a get clause"); - - loc1 = NULL; - for (name = mms_pn_lookup(clause, NULL, MMS_PN_STRING, - &loc1); name != NULL; name = mms_pn_lookup(clause, NULL, - MMS_PN_STRING, &loc1)) { - - for (i = 0; lm_priv_get[i] != NULL; i++) { - if (strcmp(mms_pn_token(name), - lm_priv_get[i]) == 0) { - mms_trace(MMS_DEBUG, - "lm_v_private: private " - "get contains %s get-name", - mms_pn_token(name)); - break; - } - } - - if (lm_priv_get[i] == NULL) { - mms_trace(MMS_ERR, - "lm_v_private: private command " - "contains a unsupport get-name - %s", - mms_pn_token(name)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7010_MSG, "type", "get", - "name", mms_pn_token(name), NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_EXIST), - mms_sym_code_to_str(MMS_LM_E_NOELT), - msg_str); - return (LM_ERROR); - } - - } - } - - loc = NULL; - for (clause = mms_pn_lookup(cmd, "set", MMS_PN_CLAUSE, &loc); - clause != NULL; clause = mms_pn_lookup(cmd, "set", - MMS_PN_CLAUSE, &loc)) { - - mms_trace(MMS_DEBUG, "lm_v_private:, Validating a set clause"); - - loc1 = NULL; - for (name = mms_pn_lookup(clause, NULL, MMS_PN_STRING, - &loc1); name != NULL; name = mms_pn_lookup(clause, NULL, - MMS_PN_STRING, &loc1)) { - - for (i = 0; lm_priv_set[i] != NULL; i++) { - if (strcmp(mms_pn_token(name), - lm_priv_set[i]) == 0) { - mms_trace(MMS_DEBUG, - "lm_v_private: private " - "set contains %s set-name", - mms_pn_token(name)); - break; - } - } - - if (lm_priv_set[i] == NULL) { - mms_trace(MMS_ERR, - "lm_v_private: private command " - "contains a unsupport set-name - %s", - mms_pn_token(name)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7010_MSG, "type", "set", - "name", mms_pn_token(name), NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_EXIST), - mms_sym_code_to_str(MMS_LM_E_NOELT), - msg_str); - return (LM_ERROR); - } - - /* For set clauses, the values asssociated */ - /* with the set-name are validated when */ - /* the set is acutally being processed, */ - /* here just skip them to get next set-name */ - MMS_PN_LOOKUP(value, clause, NULL, MMS_PN_STRING, - &loc1); - } - } - - loc = NULL; - for (clause = mms_pn_lookup(cmd, "unset", MMS_PN_CLAUSE, &loc); - clause != NULL; clause = mms_pn_lookup(cmd, "unset", - MMS_PN_CLAUSE, &loc)) { - - mms_trace(MMS_DEBUG, - "lm_v_private:, Validating a unset clause"); - - loc1 = NULL; - for (name = mms_pn_lookup(clause, NULL, MMS_PN_STRING, - &loc1); name != NULL; name = mms_pn_lookup(clause, NULL, - MMS_PN_STRING, &loc1)) { - - for (i = 0; lm_priv_unset[i] != NULL; i++) { - if (strcmp(mms_pn_token(name), - lm_priv_unset[i]) == 0) { - mms_trace(MMS_DEBUG, - "lm_v_private: private " - "unset contains %s unset-name", - mms_pn_token(name)); - break; - } - } - - if (lm_priv_unset[i] == NULL) { - mms_trace(MMS_ERR, - "lm_v_private: private command " - "contains a unsupport unset-name - %s", - mms_pn_token(name)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7010_MSG, "type", "unset", - "name", mms_pn_token(name), NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_EXIST), - mms_sym_code_to_str(MMS_LM_E_NOELT), - msg_str); - return (LM_ERROR); - } - - } - } - - return (LM_OK); - -not_found: - mms_trace(MMS_ERR, "lm_v_private: LMPM private command has a " - "missing value for a set-name:\n%s", - mms_pn_build_cmd_text(cmd)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7009_MSG, "cmd", "private", "part", "set", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INVALID), - mms_sym_code_to_str(MMS_LM_E_CMDARGS), msg_str); - return (LM_ERROR); -} diff --git a/usr/src/lib/mms/lm/libcommon/lm_lcom.c b/usr/src/lib/mms/lm/libcommon/lm_lcom.c deleted file mode 100644 index 72b221a63a..0000000000 --- a/usr/src/lib/mms/lm/libcommon/lm_lcom.c +++ /dev/null @@ -1,3349 +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 "lm_acs.h" - -int lm_library_config(char *, char *, char *); - -#define ACS_PKT_VER 4 /* ACSLS packet version LM supports */ - -#define CFG_SLOT "slot [\"%s\" \"panel %d\" \"group %d\" \ -\"%s\" \"%s\" true true] " - -#define DELE_SLOT "delslots [\"%s\"] " - -/* The following command formats differ from those in the IEEE */ -/* spec in the drive name. The reason this was done is that when the */ -/* LM is activated initally, it does not know what the logical */ -/* names are for the drives in the library, it only knows a geometry */ -/* from the acsls perspective. Thus during the inital activation config */ -/* LM sends up the acsls geometry and MM matches this with the geoemetry */ -/* attribute of a drive. This same scheme was carried over for the */ -/* partial configs assocatied when mounts and unmounts are done, even though */ -/* LM knows the logical name at that time. */ - -#define TEXT_CART "\"%s\" " -#define CFG_DRIVE "drive [\"%s\" \"%d,%d,%d,%d\" \"panel %d\" \"%s\" %s %s] " - -#define CONFIG_MOUNT "config task [\"%d\"] scope [partial] \ -slot [\"%s\" \"panel %d\" \"group %d\" \"none\" \"%s\" false true] \ -drive [\"%s\" \"%d,%d,%d,%d\" \"panel %d\" \"%s\" true true]; " - -#define CONFIG_UNMOUNT "config task [\"%d\"] scope [partial] \ -slot [\"%s\" \"panel %d\" \"group %d\" \"%s\" \"%s\" true true] \ -drive [\"%s\" \"%d,%d,%d,%d\" \"panel %d\" \"none\" false true]; " - -#define CONFIG_CART_EVENT "config task [\"%d\"] scope [partial] \ -slot [\"%s\" \"panel %d\" \"group %d\" \"%s\" \"%s\" true true]; " - -#define CONFIG_DRIVE_EVENT "config task [\"%d\"] scope [partial] \ -drive [\"%s\" \"%d,%d,%d,%d\" \"panel %d\" \"%s\" %s %s]; " - -#define LM_SHOW_SERIAL "show task [\"%d\"] \ -match [streq(DRIVE.\"DriveName\" \"%s\")] \ -report[DRIVE.\"DriveSerialNum\"] reportmode[namevalue]; " - -static char *_SrcFile = __FILE__; - -int -/* LINTED argument unused in function */ -lm_exit(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - - mms_trace(MMS_DEVP, "lm_exit: Entering ACSLS exit process"); - return (LM_OK); - -} - -int -lm_mount(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - ACS_MOUNT_RESPONSE *mp; - ACS_QUERY_VOL_RESPONSE *vol_qp; - QU_VOL_STATUS *vol_sp; - VOLID vol_id_list[MAX_ID]; - VOLID vol_id; - DRIVEID drive_id; - - ACS_QUERY_MNT_RESPONSE *mnt_qp; - QU_MNT_STATUS *mnt_sp; - QU_DRV_STATUS *drv_sp; - - acs_rsp_ele_t *acs_rsp; - - int i; - int j; - int rc; - int lmpl_tid; - int panel; - char *kw; - char *cptr; - char *cptr1; - char *pptr; - char *serial; - char *geometry; - char drive_name[20]; - char msg_str[256]; - char text_str[1024]; - char cfg_str[1024]; - char drive_list[1024]; - - lmpl_rsp_ele_t *ele; - lmpl_rsp_node_t *node; - - mms_par_node_t *loc = NULL; - mms_par_node_t *drive; - mms_par_node_t *slot; - mms_par_node_t *value; - mms_par_node_t *slot_name; - mms_par_node_t *cartridge; - mms_par_node_t *side; - mms_par_node_t *rsp; - mms_par_node_t *clause; - mms_par_node_t *attribute; - - mms_trace(MMS_DEVP, "Entering lm_mount"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7004_MSG, "cmd", "mount", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_INTERNAL), msg_str); - - if ((clause = mms_pn_lookup(cmd, "query", MMS_PN_KEYWORD, NULL)) - != NULL) { - mms_trace(MMS_DEBUG, "lm_mount: query mount requested"); - - loc = NULL; - MMS_PN_LOOKUP(slot, cmd, kw = "slot", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(slot_name, slot, NULL, MMS_PN_STRING, &loc); - MMS_PN_LOOKUP(cartridge, slot, NULL, MMS_PN_STRING, &loc); - MMS_PN_LOOKUP(side, slot, NULL, MMS_PN_STRING, &loc); - - mms_trace(MMS_DEBUG, - "lm_mount: Query mount on Cartridge PCL - %s", - mms_pn_token(cartridge)); - - (void) strncpy(vol_id_list[0].external_label, - mms_pn_token(cartridge), EXTERNAL_LABEL_SIZE); - vol_id_list[0].external_label[EXTERNAL_LABEL_SIZE] = '\0'; - if (lm_acs_query_mount(&acs_rsp, vol_id_list, 1, "mount", tid, - ret_msg) == LM_ERROR) { - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_mount: Recevied final response for " - "query_mount()"); - - mnt_qp = (ACS_QUERY_MNT_RESPONSE *)acs_rsp->acs_rbuf; - if (mnt_qp->query_mnt_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_mount: response from " - "query_mount() failed, status - %s", - acs_status(mnt_qp->query_mnt_status)); - lm_handle_query_mount_error(mnt_qp->query_mnt_status, - "mount", tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - mnt_sp = &mnt_qp->mnt_status[0]; - if (mnt_sp->status != STATUS_VOLUME_HOME) { - mms_trace(MMS_ERR, - "lm_mount: volume %s not found in slot " - "prior to query mount, status - %s", - mms_pn_token(cartridge), - acs_status(mnt_sp->status)); - lm_handle_acsls_error(mnt_sp->status, "acs_query_mount", - "mount", tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - drive_list[0] = '\0'; - - for (i = 0, j = 0; i < (int)mnt_sp->drive_count; i++) { - drv_sp = &mnt_sp->drive_status[i]; - if (drv_sp->status != STATUS_DRIVE_AVAILABLE) { - mms_trace(MMS_DEBUG, - "lm_mount: drive %d,%d,%d,%d " - "not available for mount, status - %s", - drv_sp->drive_id.panel_id.lsm_id.acs, - drv_sp->drive_id.panel_id.lsm_id.lsm, - drv_sp->drive_id.panel_id.panel, - drv_sp->drive_id.drive, - acs_status(drv_sp->status)); - continue; - } - - if (j != 0) - (void) strcat(drive_list, " "); - j++; - (void) snprintf(drive_name, sizeof (drive_name), - "\"%d,%d,%d,%d\"", - drv_sp->drive_id.panel_id.lsm_id.acs, - drv_sp->drive_id.panel_id.lsm_id.lsm, - drv_sp->drive_id.panel_id.panel, - drv_sp->drive_id.drive); - (void) strcat(drive_list, drive_name); - } - free(acs_rsp); - - (void) snprintf(text_str, sizeof (text_str), LM_TEXT_CLS, - drive_list); - (void) snprintf(ret_msg, RMBUFSIZE, LM_SUC_FINAL, tid, - text_str, ""); - return (LM_OK); - } - - MMS_PN_LOOKUP(drive, cmd, kw = "drive", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, drive, NULL, MMS_PN_STRING, NULL); - - mms_trace(MMS_DEBUG, "lm_mount: Drive for mount cmd - %s", - mms_pn_token(value)); - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, "lm_mount: lm_obtain_task_id failed " - "trying to generate show command for event"); - return (LM_ERROR); - } - (void) snprintf(cfg_str, sizeof (cfg_str), LM_SHOW_SERIAL, lmpl_tid, - mms_pn_token(value)); - - mms_trace(MMS_DEBUG, "lm_mount: drive show cmd:\n%s", cfg_str); - - if ((rc = lm_gen_lmpl_cmd(cfg_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_mount: Internal processing error " - "encountered while processing LMPL show cmd"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, "lm_mount: show cmd did not receive " - "a successful response"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_mount: show cmd got sucess final response"); - node = mms_list_head(&ele->lmpl_rsp_list); - rsp = node->lmpl_rsp_tree; - - loc = NULL; - if ((clause = mms_pn_lookup(rsp, "DriveSerialNum", MMS_PN_STRING, - &loc)) == NULL) { - mms_trace(MMS_CRIT, "lm_mount: No DriveSerialNum " - "attribute found in response to show cmd"); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7032_MSG, - "cmd", "mount", "drive", mms_pn_token(value), NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_SUBCMDFAILED), msg_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - if ((attribute = mms_pn_lookup(clause, NULL, MMS_PN_STRING, - &loc)) == NULL) { - mms_trace(MMS_CRIT, "lm_mount: No DriveSerialNum value " - "found in response to show cmd"); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7032_MSG, - "cmd", "mount", "drive", mms_pn_token(value), NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_SUBCMDFAILED), msg_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_mount: Drive %s has a serial number of %s", - mms_pn_token(value), mms_pn_token(attribute)); - - loc = NULL; - MMS_PN_LOOKUP(slot, cmd, kw = "slot", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(slot_name, slot, NULL, MMS_PN_STRING, &loc); - - mms_trace(MMS_DEBUG, "lm_mount: Slot for mount cmd - %s", - mms_pn_token(slot_name)); - - MMS_PN_LOOKUP(cartridge, slot, NULL, MMS_PN_STRING, &loc); - - mms_trace(MMS_DEBUG, "lm_mount: Cartridge PCL for mount cmd - %s", - mms_pn_token(cartridge)); - - MMS_PN_LOOKUP(side, slot, NULL, MMS_PN_STRING, &loc); - - mms_trace(MMS_DEBUG, "lm_mount: Side for mount cmd - %s", - mms_pn_token(side)); - - (void) strncpy(vol_id_list[0].external_label, mms_pn_token(cartridge), - EXTERNAL_LABEL_SIZE); - vol_id_list[0].external_label[EXTERNAL_LABEL_SIZE] = '\0'; - if ((lm_acs_query_volume(&acs_rsp, vol_id_list, 1, "mount", tid, - ret_msg)) == LM_ERROR) { - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_mount: Recevied final response for " - "query_volume()"); - - vol_qp = (ACS_QUERY_VOL_RESPONSE *)acs_rsp->acs_rbuf; - if (vol_qp->query_vol_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_mount: response from " - "query_volume() failed, status - %s", - acs_status(vol_qp->query_vol_status)); - lm_handle_query_vol_error(vol_qp->query_vol_status, - "mount", tid, ret_msg); - free(acs_rsp); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - vol_sp = &vol_qp->vol_status[0]; - if (vol_sp->status != STATUS_VOLUME_HOME) { - mms_trace(MMS_ERR, "lm_mount: volume %s not found in slot " - "prior to mount, status - %s", - mms_pn_token(cartridge), acs_status(vol_sp->status)); - lm_handle_acsls_error(vol_sp->status, "acs_query_vol", "mount", - tid, ret_msg); - free(acs_rsp); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_mount: vol %s is in location %d,%d,%d,%d,%d " - "prior to mount", vol_sp->vol_id.external_label, - vol_sp->location.cell_id.panel_id.lsm_id.acs, - vol_sp->location.cell_id.panel_id.lsm_id.lsm, - vol_sp->location.cell_id.panel_id.panel, - vol_sp->location.cell_id.row, - vol_sp->location.cell_id.col); - - panel = vol_sp->location.cell_id.panel_id.panel; - free(acs_rsp); - - serial = strdup(mms_pn_token(attribute)); - - if (lm_obtain_geometry(serial, &geometry, "mount", tid, ret_msg) - != LM_OK) { - mms_trace(MMS_ERR, "lm_mount: Trying to obtain geometry " - "for drive with serial number %s failed", serial); - /* Error return message set in function */ - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(serial); - return (LM_ERROR); - } - if (strcmp(geometry, "") == 0) { - mms_trace(MMS_ERR, "lm_mount: No geometry found for drive " - "with serial number of %s", serial); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7126_MSG, - "name", mms_pn_token(value), "serial", serial, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_DEVCMD), msg_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(serial); - free(geometry); - return (LM_ERROR); - } - - cptr = cptr1 = strdup(geometry); - pptr = strstr(cptr, ","); - *pptr = '\0'; - drive_id.panel_id.lsm_id.acs = atoi(cptr); - cptr = pptr + 1; - pptr = strstr(cptr, ","); - *pptr = '\0'; - drive_id.panel_id.lsm_id.lsm = atoi(cptr); - cptr = pptr + 1; - pptr = strstr(cptr, ","); - *pptr = '\0'; - drive_id.panel_id.panel = atoi(cptr); - cptr = pptr + 1; - drive_id.drive = atoi(cptr); - free(cptr1); - - - mms_trace(MMS_DEBUG, "lm_mount: Drive geometry - %d,%d,%d,%d", - drive_id.panel_id.lsm_id.acs, drive_id.panel_id.lsm_id.lsm, - drive_id.panel_id.panel, drive_id.drive); - - (void) strncpy(vol_id.external_label, mms_pn_token(cartridge), - EXTERNAL_LABEL_SIZE); - vol_id.external_label[EXTERNAL_LABEL_SIZE] = '\0'; - mms_trace(MMS_DEBUG, "lm_mount: Volume to mount %s", - vol_id.external_label); - - if ((lm_acs_mount(&acs_rsp, vol_id, drive_id, "mount", tid, - ret_msg)) == LM_ERROR) { - free(serial); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(geometry); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, - "lm_mount: Received final response for acs_mount()"); - - mp = (ACS_MOUNT_RESPONSE *)acs_rsp->acs_rbuf; - if (mp->mount_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, - "lm_mount: response from acs_mount() failed, " - "status - %s", acs_status(mp->mount_status)); - lm_handle_mount_error(mp->mount_status, mms_pn_token(value), - mms_pn_token(attribute), geometry, - drive_id.panel_id.lsm_id.lsm, - drive_id.panel_id.panel, "mount", tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(acs_rsp); - free(serial); - free(geometry); - return (LM_ERROR); - } - - free(geometry); - - /* Clean up from drive show command */ - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(acs_rsp); - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, "lm_mount: lm_obtain_task_id failed trying " - "to generate config command for mount"); - free(serial); - return (LM_ERROR); - } - - (void) snprintf(cfg_str, sizeof (cfg_str), CONFIG_MOUNT, lmpl_tid, - mms_pn_token(cartridge), panel, panel, lm.lm_type, serial, - drive_id.panel_id.lsm_id.acs, drive_id.panel_id.lsm_id.lsm, - drive_id.panel_id.panel, drive_id.drive, drive_id.panel_id.panel, - mms_pn_token(cartridge)); - - free(serial); - - mms_trace(MMS_DEBUG, "lm_mount: config for mount:\n%s", cfg_str); - - if ((rc = lm_gen_lmpl_cmd(cfg_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_mount: Internal processing error " - "encountered while processing lmpl config command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - /* unmount cartridge and send error response */ - if ((lm_acs_dismount(&acs_rsp, vol_id, drive_id, "mount", tid, - ret_msg)) == LM_ERROR) - mms_trace(MMS_ERR, "lm_mount: Unable to unmount " - "cartridge %s after mount's config failed", - mms_pn_token(cartridge)); - else { - mms_trace(MMS_ERR, "lm_mount: Unmounted cartridge %s " - "due to mount's config failure", - mms_pn_token(cartridge)); - free(acs_rsp); - } - handle_lmpl_cmd_error(rc, "mount", "config", tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_mount: Got successful response for mount " - "config command"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7102_MSG, - "cart", mms_pn_token(cartridge), "drive", mms_pn_token(value), - NULL); - (void) snprintf(text_str, sizeof (text_str), LM_TEXT_MNT, - mms_pn_token(value), mms_pn_token(slot_name), - mms_pn_token(cartridge), mms_pn_token(side)); - (void) snprintf(ret_msg, RMBUFSIZE, LM_SUC_FINAL, tid, text_str, - msg_str); - - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_OK); - -not_found: - mms_trace(MMS_ERR, "LMPM command %s encounterd an invalid or missing " - "%s clause:\n%s", "mount", kw, mms_pn_build_cmd_text(cmd)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7009_MSG, "cmd", "mount", "part", kw, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INVALID), - mms_sym_code_to_str(MMS_LM_E_CMDARGS), msg_str); - return (LM_ERROR); -} - -int -lm_unmount(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - ACS_DISMOUNT_RESPONSE *mp; - ACS_QUERY_VOL_RESPONSE *vol_qp; - QU_VOL_STATUS *vol_sp; - VOLID vol_id_list[MAX_ID]; - VOLID vol_id; - DRIVEID drive_id; - - acs_rsp_ele_t *acs_rsp; - - int i; - int rc; - int lmpl_tid; - int panel; - - char *kw; - char *cptr; - char *cptr1; - char *pptr; - char *serial; - char *geometry; - char msg_str[256]; - char text_str[256]; - char cfg_str[1024]; - - lmpl_rsp_ele_t *ele; - lmpl_rsp_node_t *node; - - mms_par_node_t *loc = NULL; - mms_par_node_t *drive; - mms_par_node_t *slot; - mms_par_node_t *value; - mms_par_node_t *slot_name; - mms_par_node_t *cartridge; - mms_par_node_t *side; - mms_par_node_t *rsp; - mms_par_node_t *clause; - mms_par_node_t *attribute; - - mms_trace(MMS_DEVP, "Entering lm_unmount"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7004_MSG, "cmd", "unmount", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_INTERNAL), msg_str); - - MMS_PN_LOOKUP(drive, cmd, kw = "drive", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, drive, NULL, MMS_PN_STRING, NULL); - - mms_trace(MMS_DEBUG, "lm_unmount: Drive for unmount cmd - %s", - mms_pn_token(value)); - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, "lm_unmount: lm_obtain_task_id failed " - "trying to generate show command for event"); - return (LM_ERROR); - } - (void) snprintf(cfg_str, sizeof (cfg_str), LM_SHOW_SERIAL, lmpl_tid, - mms_pn_token(value)); - - mms_trace(MMS_DEBUG, "lm_unmount: drive show cmd:\n%s", cfg_str); - - if ((rc = lm_gen_lmpl_cmd(cfg_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_unmount: Internal processing error " - "encountered while processing LMPL show cmd"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, "lm_unmount: show cmd did not receive " - "a successful response"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_unmount: show cmd got sucess final response"); - node = mms_list_head(&ele->lmpl_rsp_list); - rsp = node->lmpl_rsp_tree; - - loc = NULL; - if ((clause = mms_pn_lookup(rsp, "DriveSerialNum", - MMS_PN_STRING, &loc)) == NULL) { - mms_trace(MMS_CRIT, "lm_unmount: No DriveSerialNum " - "attribute found in response to show cmd"); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7032_MSG, - "cmd", "unmount", "drive", mms_pn_token(value), NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_SUBCMDFAILED), msg_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - if ((attribute = mms_pn_lookup(clause, NULL, MMS_PN_STRING, - &loc)) == NULL) { - mms_trace(MMS_CRIT, "lm_unmount: No DriveSerialNum value " - "found in response to show cmd"); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7032_MSG, - "cmd", "unmount", "drive", mms_pn_token(value), NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_SUBCMDFAILED), msg_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_unmount: Drive %s has a serial number of %s", - mms_pn_token(value), mms_pn_token(attribute)); - - loc = NULL; - MMS_PN_LOOKUP(slot, cmd, kw = "fromslot", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(slot_name, slot, NULL, MMS_PN_STRING, &loc); - mms_trace(MMS_DEBUG, "lm_unmount: From Slot for unmount cmd - %s", - mms_pn_token(slot_name)); - - MMS_PN_LOOKUP(cartridge, slot, NULL, MMS_PN_STRING, &loc); - mms_trace(MMS_DEBUG, "lm_unmount: From Cartridge PCL for cmd - %s", - mms_pn_token(cartridge)); - - MMS_PN_LOOKUP(side, slot, NULL, MMS_PN_STRING, &loc); - mms_trace(MMS_DEBUG, "lm_unmount: From Side for unmount cmd - %s", - mms_pn_token(side)); - - loc = NULL; - MMS_PN_LOOKUP(slot, cmd, kw = "toslot", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(slot_name, slot, NULL, MMS_PN_STRING, &loc); - mms_trace(MMS_DEBUG, "lm_unmount: To Slot for unmount cmd - %s", - mms_pn_token(slot_name)); - - MMS_PN_LOOKUP(cartridge, slot, NULL, MMS_PN_STRING, &loc); - mms_trace(MMS_DEBUG, "lm_unmount: To Cartridge PCL for cmd - %s", - mms_pn_token(cartridge)); - - MMS_PN_LOOKUP(side, slot, NULL, MMS_PN_STRING, &loc); - mms_trace(MMS_DEBUG, "lm_unmount: To Side for unmount cmd - %s", - mms_pn_token(side)); - - serial = strdup(mms_pn_token(attribute)); - - if (lm_obtain_geometry(serial, &geometry, "unmount", tid, ret_msg) - != LM_OK) { - mms_trace(MMS_ERR, "lm_mount: Trying to obtain geometry " - "for drive with serial number %s failed", serial); - /* Error return message set in function */ - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(serial); - return (LM_ERROR); - } - if (strcmp(geometry, "") == 0) { - mms_trace(MMS_ERR, "lm_mount: No geometry found for drive " - "with serial number of %s", serial); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7126_MSG, - "name", mms_pn_token(value), "serial", serial, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_DEVCMD), msg_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(serial); - free(geometry); - return (LM_ERROR); - } - - cptr = cptr1 = strdup(geometry); - pptr = strstr(cptr, ","); - *pptr = '\0'; - drive_id.panel_id.lsm_id.acs = atoi(cptr); - cptr = pptr + 1; - pptr = strstr(cptr, ","); - *pptr = '\0'; - drive_id.panel_id.lsm_id.lsm = atoi(cptr); - cptr = pptr + 1; - pptr = strstr(cptr, ","); - *pptr = '\0'; - drive_id.panel_id.panel = atoi(cptr); - cptr = pptr + 1; - drive_id.drive = atoi(cptr); - free(cptr1); - - - mms_trace(MMS_DEBUG, "lm_unmount: Drive geometry - %d,%d,%d,%d", - drive_id.panel_id.lsm_id.acs, drive_id.panel_id.lsm_id.lsm, - drive_id.panel_id.panel, drive_id.drive); - - (void) strncpy(vol_id.external_label, mms_pn_token(cartridge), - EXTERNAL_LABEL_SIZE); - vol_id.external_label[EXTERNAL_LABEL_SIZE] = '\0'; - mms_trace(MMS_DEBUG, "lm_unmount: Volume to unmount %s", - vol_id.external_label); - - if ((lm_acs_dismount(&acs_rsp, vol_id, drive_id, "unmount", tid, - ret_msg)) == LM_ERROR) { - free(serial); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(geometry); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_unmount: Received final response for " - "acs_dismount()"); - - mp = (ACS_DISMOUNT_RESPONSE *)acs_rsp->acs_rbuf; - if (mp->dismount_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_unmount: response from acs_dismount() " - "failed, status - %s", - acs_status(mp->dismount_status)); - lm_handle_dismount_error(mp->dismount_status, - mms_pn_token(value), mms_pn_token(attribute), - geometry, - mms_pn_token(cartridge), drive_id.panel_id.lsm_id.lsm, - drive_id.panel_id.panel, "unmount", tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(acs_rsp); - free(serial); - free(geometry); - return (LM_ERROR); - } - free(geometry); - - if (strcmp(mms_pn_token(cartridge), mp->vol_id.external_label) != 0) { - mms_trace(MMS_OPER, "lm_unmount: While dismounting %s from " - "drive %s (geometry - %s), the acs_dismount() " - "shows that actually cartridge %s was unmounted from " - "the drive", mms_pn_token(cartridge), - mms_pn_token(value), mms_pn_token(attribute), - mp->vol_id.external_label); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7223_MSG, - "wcart", mp->vol_id.external_label, - "drive", mms_pn_token(value), - "ecart", mms_pn_token(cartridge), - NULL); - lm_message("operator", "alert", msg_str); - } - /* Clean up from drive show command */ - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(acs_rsp); - - i = 0; -unmount_retry: - - (void) strncpy(vol_id_list[0].external_label, mms_pn_token(cartridge), - EXTERNAL_LABEL_SIZE); - vol_id_list[0].external_label[EXTERNAL_LABEL_SIZE] = '\0'; - if ((lm_acs_query_volume(&acs_rsp, vol_id_list, 1, "unmount", tid, - ret_msg)) == LM_ERROR) - return (LM_ERROR); - - mms_trace(MMS_DEBUG, "lm_unmount: Recevied final response for " - "query_volume()"); - - vol_qp = (ACS_QUERY_VOL_RESPONSE *)acs_rsp->acs_rbuf; - if (vol_qp->query_vol_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_unmount: response from " - "query_volume() failed, status - %s", - acs_status(vol_qp->query_vol_status)); - lm_handle_query_vol_error(vol_qp->query_vol_status, - "unmount", tid, ret_msg); - free(acs_rsp); - free(serial); - return (LM_ERROR); - } - vol_sp = &vol_qp->vol_status[0]; - if (vol_sp->status != STATUS_VOLUME_HOME) { - if (vol_sp->status == STATUS_VOLUME_IN_TRANSIT) { - mms_trace(MMS_DEBUG, - "lm_unmount: volume %s is in transit " - "retrying acs_query_volume()", - mms_pn_token(cartridge)); - free(acs_rsp); - (void) sleep(2); - if (i < 5) { - i++; - goto unmount_retry; - } - mms_trace(MMS_DEBUG, - "lm_unmount: volume %s seems to be " - "stuck in transit sending back error " - "response"); - } - mms_trace(MMS_ERR, "lm_unmount: volume %s not found in cell, " - "status is %s", mms_pn_token(cartridge), - acs_status(vol_sp->status)); - lm_handle_acsls_error(vol_sp->status, "acs_query_vol", - "unmount", tid, ret_msg); - free(acs_rsp); - free(serial); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, - "lm_unmount: vol %s is now in location %d,%d,%d,%d,%d " - "after unmount", vol_sp->vol_id.external_label, - vol_sp->location.cell_id.panel_id.lsm_id.acs, - vol_sp->location.cell_id.panel_id.lsm_id.lsm, - vol_sp->location.cell_id.panel_id.panel, - vol_sp->location.cell_id.row, - vol_sp->location.cell_id.col); - - panel = vol_sp->location.cell_id.panel_id.panel; - - free(acs_rsp); - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, - "lm_unmount: lm_obtain_task_id failed trying " - "to generate config command for unmount"); - free(serial); - return (LM_ERROR); - } - - (void) snprintf(cfg_str, sizeof (cfg_str), CONFIG_UNMOUNT, lmpl_tid, - mms_pn_token(cartridge), panel, panel, mms_pn_token(cartridge), - lm.lm_type, serial, drive_id.panel_id.lsm_id.acs, - drive_id.panel_id.lsm_id.lsm, drive_id.panel_id.panel, - drive_id.drive, drive_id.panel_id.panel); - - mms_trace(MMS_DEBUG, "lm_unmount: config for unmount:\n%s", cfg_str); - free(serial); - - if ((rc = lm_gen_lmpl_cmd(cfg_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_unmount: Internal processing error " - "encountered while processing lmpl config command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - if ((lm_acs_mount(&acs_rsp, vol_id, drive_id, "unmount", - tid, ret_msg)) == LM_ERROR) - mms_trace(MMS_ERR, "lm_unmount: Unable to mount " - "cartridge %s after unmount's config failed", - mms_pn_token(cartridge)); - else { - mms_trace(MMS_ERR, "lm_unmount: Mounted cartridge %s " - "due to unmount's config failure", - mms_pn_token(cartridge)); - free(acs_rsp); - } - handle_lmpl_cmd_error(rc, "unmount", "config", tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_unmount: Got successful response for unmount " - "config command"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7103_MSG, - "cart", mms_pn_token(cartridge), "drive", mms_pn_token(value), - NULL); - (void) snprintf(text_str, sizeof (text_str), LM_TEXT_MNT, - mms_pn_token(value), mms_pn_token(slot_name), - mms_pn_token(cartridge), mms_pn_token(side)); - (void) snprintf(ret_msg, RMBUFSIZE, LM_SUC_FINAL, tid, text_str, - msg_str); - - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_OK); - -not_found: - mms_trace(MMS_ERR, "LMPM command %s encounterd an invalid or missing " - "%s clause:\n%s", "unmount", kw, mms_pn_build_cmd_text(cmd)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7009_MSG, "cmd", "unmount", "part", kw, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INVALID), - mms_sym_code_to_str(MMS_LM_E_CMDARGS), msg_str); - return (LM_ERROR); -} - -int -/* LINTED argument unused in function */ -lm_move(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - char msg_str[256]; - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7105_MSG, "cmd", "move", "type", lm.lm_type, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_SUC_FINAL, tid, msg_str, ""); - return (LM_OK); -} - -int -lm_inject(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - int i; - int j; - int rc; - int lmpl_tid; - int slot_spec_size; - - char *kw; - char *slot_spec; - char msg_str[256]; - char text_str[256]; - char cfg_str[1024]; - char carts[2048]; - char err_carts[2048]; - char text_cart[12]; - char text_carts[2048]; - - CAPID cap_id; - ACS_ENTER_RESPONSE *ep; - ACS_QUERY_VOL_RESPONSE *vol_qp; - QU_VOL_STATUS *vol_sp; - VOLID *vol_id; - VOLID vol_id_list[MAX_ID]; - - mms_par_node_t *sltgrp; - mms_par_node_t *value; - acs_rsp_ele_t *acs_rsp; - lmpl_rsp_ele_t *ele; - - acs_cap_t *acs_cap; - - /* Create default final error response due to */ - /* internal processing error */ - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7004_MSG, "cmd", "inject", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_INTERNAL), msg_str); - - carts[0] = '\0'; - - /* Obtain slotgroup (Name of cap to use) */ - MMS_PN_LOOKUP(sltgrp, cmd, kw = "slotgroup", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, sltgrp, NULL, MMS_PN_STRING, NULL); - - cap_id.lsm_id.acs = lm.lm_acs; - /* If more than one lsm can exist within the acs, */ - /* the lsm will need to be determined */ - cap_id.lsm_id.lsm = lm.lm_lsm; - - acs_cap = (acs_cap_t *)lm.lm_port; - for (i = 0; i < lm.lm_caps; i++) { - if (strcmp(acs_cap->cap_name, mms_pn_token(value)) == 0) { - mms_trace(MMS_DEBUG, "Physical cap associated with " - "slotgroup %s found", acs_cap->cap_name); - /* Make sure that the cap actually exists in */ - /* the library, some libraries have optional */ - /* caps */ - if (!acs_cap->cap_config) { - mms_trace(MMS_ERR, - "Physcial cap associated with " - "slotgroup %s is not available in" - "the library - %s", acs_cap->cap_name); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7108_MSG, "port", mms_pn_token(value), - NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INVALID), - mms_sym_code_to_str(MMS_LM_E_PORT), - msg_str); - return (LM_ERROR); - } - break; - } - } - if (i == lm.lm_caps) { - mms_trace(MMS_ERR, "lm_inject: Did not find a physical cap " - "associated with slotgroup - %s", - mms_pn_token(value)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7117_MSG, - "port", mms_pn_token(value), NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INVALID), - mms_sym_code_to_str(MMS_LM_E_PORT), msg_str); - return (LM_ERROR); - } - - cap_id.cap = acs_cap->cap_capid; - - mms_trace(MMS_DEBUG, "lm_inject: Cap group name for inject - %s, %d", - acs_cap->cap_name, acs_cap->cap_capid); - - if ((lm_acs_enter(&acs_rsp, cap_id, "inject", tid, ret_msg)) == - LM_ERROR) { - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, - "lm_inject: Received final response for acs_enter()"); - - ep = (ACS_ENTER_RESPONSE *)acs_rsp->acs_rbuf; - if (ep->enter_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, - "lm_inject: response for acs_enter() failed, " - "status - %s", acs_status(ep->enter_status)); - lm_handle_enter_error(ep->enter_status, acs_cap->cap_name, - cap_id.lsm_id.lsm, "inject", tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - /* Check status of each cartridge that was in the cap */ - j = 0; - for (i = 0; i < (int)ep->count; i++) { - vol_id = &ep->vol_id[i]; - if (ep->vol_status[i] != STATUS_SUCCESS) { - mms_trace(MMS_OPER, "lm_inject: volume %s failed " - "enter with status - %s", vol_id->external_label, - acs_status(ep->vol_status[i])); - (void) strcat(err_carts, vol_id->external_label); - (void) strcat(err_carts, " "); - continue; - } - mms_trace(MMS_OPER, "lm_inject: volume %s entered into " - "library", vol_id->external_label); - (void) strncpy(vol_id_list[j].external_label, - vol_id->external_label, EXTERNAL_LABEL_SIZE); - vol_id_list[j++].external_label[EXTERNAL_LABEL_SIZE] = '\0'; - } - - /* There were cartridges in CAP, but none were */ - /* successfully injected into the library */ - if (j == 0 && ep->count != 0) { - mms_trace(MMS_OPER, - "lm_inject: Cartridges %s were not injected " - "into library"); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7109_MSG, - NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_DEVINJ), msg_str); - free(acs_rsp); - return (LM_ERROR); - } - - /* Some of the cartridges in the CAP did not get */ - /* injected */ - if (j != ep->count) { - err_carts[strlen(err_carts)-1] = '\0'; - mms_trace(MMS_OPER, "lm_inject: Send LMPL message to indicate " - "not all cartridges were injected into the library"); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7110_MSG, - "cart", err_carts, NULL); - /* Ignore return value from lm_message */ - lm_message("operator", "notice", msg_str); - } - - free(acs_rsp); - - /* Determine if any cartridges were added to the cap */ - if (j != 0) { - slot_spec_size = 100 * j; - if ((slot_spec = (char *)malloc(slot_spec_size)) == NULL) { - lm_serr(MMS_CRIT, "lm_inject: Unable to malloc space " - "for slot spec definitions"); - return (LM_ERROR); - } - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, - "lm_inject: lm_obtain_task_id failed " - "trying to generate config cmd for slot creation"); - return (LM_ERROR); - } - - (void) snprintf(slot_spec, slot_spec_size, - "config task[\"%d\"] scope[partial] ", - lmpl_tid); - - if ((lm_acs_query_volume(&acs_rsp, vol_id_list, j, "inject", - tid, ret_msg)) == LM_ERROR) { - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - err_carts[0] = '\0'; - text_carts[0] = '\0'; - - vol_qp = (ACS_QUERY_VOL_RESPONSE *)acs_rsp->acs_rbuf; - if (vol_qp->query_vol_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_inject: response from " - "query_volume() failed, status - %s", - acs_status(vol_qp->query_vol_status)); - lm_handle_query_vol_error(vol_qp->query_vol_status, - "inject", tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(acs_rsp); - return (LM_ERROR); - } - if (vol_qp->count != j) { - mms_trace(MMS_ERR, "lm_inject: count of response for " - "query_volume() - %d does not equal number of " - "cartridges injected - %d", vol_qp->count, j); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(acs_rsp); - return (LM_ERROR); - } - for (i = 0; i < (int)vol_qp->count; i++) { - vol_sp = &vol_qp->vol_status[i]; - if (vol_sp->location_type != LOCATION_CELL) { - mms_trace(MMS_ERR, "lm_inject: volume " - "%s not found in slot", - &vol_sp->vol_id.external_label[0]); - (void) strcat(err_carts, - vol_sp->vol_id.external_label); - (void) strcat(err_carts, " "); - continue; - } - - (void) snprintf(cfg_str, sizeof (cfg_str), CFG_SLOT, - vol_sp->vol_id.external_label, - vol_sp->location.cell_id.panel_id.panel, - vol_sp->location.cell_id.panel_id.panel, - vol_sp->vol_id.external_label, - lm.lm_type); - mms_trace(MMS_DEBUG, - "lm_inject: Slot spec - %s", cfg_str); - (void) strcat(slot_spec, cfg_str); - (void) strcat(carts, vol_sp->vol_id.external_label); - (void) strcat(carts, " "); - (void) snprintf(text_cart, sizeof (text_cart), - TEXT_CART, vol_sp->vol_id.external_label); - (void) strcat(text_carts, text_cart); - } - - free(acs_rsp); - - (void) strcat(slot_spec, ";"); - - mms_trace(MMS_DEBUG, "lm_inject: SLOT_SPEC:\n%s", slot_spec); - if ((rc = lm_gen_lmpl_cmd(slot_spec, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, - "lm_inject: Internal processing error " - "encountered while processing lmpl config command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - handle_lmpl_cmd_error(rc, "inject", "config", tid, - ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - if (err_carts[0] != '\0') { - err_carts[strlen(err_carts)-1] = '\0'; - /* Some cartridges that were successfully */ - /* injected into library could not be found */ - /* in a slot of the library */ - mms_trace(MMS_OPER, "Cartridges %s were injected into " - "library, but were not found in a slot of the " - "library", err_carts); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7111_MSG, "cart", err_carts, NULL); - lm_message("operator", "notice", msg_str); - } - - mms_trace(MMS_DEBUG, "lm_inject: Got successful response for " - "slot creation config command"); - - free(slot_spec); - lm_remove_lmpl_cmd(lmpl_tid, ele); - - carts[strlen(carts)-1] = '\0'; - if (text_carts[0] != '\0') { - text_carts[strlen(text_carts)-1] = '\0'; - (void) snprintf(text_str, sizeof (text_str), - LM_TEXT_CLS, text_carts); - } else { - text_str[0] = '\0'; - } - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7106_MSG, - "cart", carts, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_SUC_FINAL, tid, text_str, - msg_str); - - } else { - mms_trace(MMS_OPER, - "CAP was empty, No cartridges injected into library"); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7112_MSG, - NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_SUC_FINAL, tid, - msg_str, ""); - } - - mms_trace(MMS_DEVP, "Exiting lm_inject"); - return (LM_OK); - - -not_found: - mms_trace(MMS_ERR, "lm_inject: LMPM command %s encounterd an invalid " - "or missing %s clause:\n%s", "inject", kw, - mms_pn_build_cmd_text(cmd)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7009_MSG, "cmd", "inject", "part", kw, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INVALID), - mms_sym_code_to_str(MMS_LM_E_CMDARGS), msg_str); - return (LM_ERROR); -} - -int -lm_scan(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - int i, j; - int rc; - int lmpl_tid; - int accessible = 0; - int occupied = 0; - int slot_spec_size; - int drive_spec_size; - - char *drv_geometry = NULL; - char *kw = NULL; - char *slot_spec = NULL; - char *drive_spec = NULL; - const char *spec_form = NULL; - char *cptr = NULL; - char *pptr = NULL; - char *serial = NULL; - char carts[2048]; - char err_carts[2048]; - char msg_str[256]; - char cfg_str[1024]; - char cmd_str[1024]; - char geometry[128]; - char *err_buf = NULL; - - lmpl_rsp_ele_t *ele = NULL; - lmpl_rsp_node_t *node = NULL; - - mms_par_node_t *loc = NULL; - mms_par_node_t *loc1 = NULL; - mms_par_node_t *slot = NULL; - mms_par_node_t *fslot = NULL; - mms_par_node_t *tslot = NULL; - mms_par_node_t *dname = NULL; - mms_par_node_t *rsp = NULL; - mms_par_node_t *clause = NULL; - mms_par_node_t *attribute = NULL; - - VOLID vol_id_list[MAX_ID]; - ACS_QUERY_VOL_RESPONSE *vol_qp = NULL; - QU_VOL_STATUS *vol_sp = NULL; - ACS_QUERY_DRV_RESPONSE *drv_qp = NULL; - QU_DRV_STATUS *drv_sp = NULL; - DRIVEID drive_id[MAX_ID]; - - acs_rsp_ele_t *acs_rsp = NULL; - - mms_trace(MMS_DEVP, "Entering lm_scan"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7004_MSG, "cmd", "scan", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_INTERNAL), msg_str); - - loc = NULL; - /* See if scan is for cartridge(s) */ - if ((clause = mms_pn_lookup(cmd, kw = "slot", MMS_PN_CLAUSE, &loc)) - != NULL) { - /* Generate list of cartridges to scan for */ - for (i = 0; clause != NULL; clause = mms_pn_lookup(cmd, - "slot", MMS_PN_CLAUSE, &loc)) { - /* Obtain slot-name */ - MMS_PN_LOOKUP(slot, clause, NULL, MMS_PN_STRING, - NULL); - if (i == MAX_ID) { - mms_trace(MMS_OPER, - "lm_scan: Number of slots to " - "scan exceeded the max of %d, skipping " - "cartridge %s", MAX_ID, - mms_pn_token(slot)); - } else { - mms_trace(MMS_DEBUG, - "lm_scan: scan for cartridge " - "%s", mms_pn_token(slot)); - - (void) strncpy(vol_id_list[i].external_label, - mms_pn_token(slot), - EXTERNAL_LABEL_SIZE); - vol_id_list[i++].external_label[ - EXTERNAL_LABEL_SIZE] = '\0'; - } - } - - /* Query for cartridges in library */ - if ((lm_acs_query_volume(&acs_rsp, vol_id_list, i, "scan", - tid, ret_msg)) == LM_ERROR) - return (LM_ERROR); - - mms_trace(MMS_DEBUG, - "lm_scan: Recevied sucess final response for " - "query_volume()"); - - vol_qp = (ACS_QUERY_VOL_RESPONSE *)acs_rsp->acs_rbuf; - if (vol_qp->query_vol_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_scan: response from " - "query_volume() failed, status - %s", - acs_status(vol_qp->query_vol_status)); - lm_handle_query_vol_error(vol_qp->query_vol_status, - "scan", tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - slot_spec_size = 100 * i; - if ((slot_spec = (char *)malloc(100 * i)) == NULL) { - lm_serr(MMS_CRIT, "lm_scan: Unable to malloc space " - "for slot spec definitions"); - free(acs_rsp); - return (LM_ERROR); - } - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, "lm_scan: lm_obtain_task_id failed " - "trying to generate config command for scan"); - free(acs_rsp); - free(slot_spec); - return (LM_ERROR); - } - - /* Setup to send partial config for any cartridges */ - /* found in a cell of the library */ - (void) snprintf(slot_spec, slot_spec_size, - "config task[\"%d\"] scope[partial] ", - lmpl_tid); - - carts[0] = '\0'; - err_carts[0] = '\0'; - - /* Check each cartridge to see if it is in a cell */ - /* of the library, only those in a cell can be */ - /* configed */ - for (j = 0; j < (int)vol_qp->count; j++) { - vol_sp = &vol_qp->vol_status[j]; - if (vol_sp->location_type != LOCATION_CELL) { - mms_trace(MMS_ERR, "lm_scan: cartridge %s not " - "found in a cell, status - %s", - vol_sp->vol_id.external_label, - acs_status(vol_sp->status)); - (void) strcat(err_carts, - vol_sp->vol_id.external_label); - (void) strcat(err_carts, " "); - continue; - } - (void) snprintf(cfg_str, sizeof (cfg_str), CFG_SLOT, - vol_sp->vol_id.external_label, - vol_sp->location.cell_id.panel_id.panel, - vol_sp->location.cell_id.panel_id.panel, - vol_sp->vol_id.external_label, - lm.lm_type); - mms_trace(MMS_DEBUG, - "lm_scan: Slot spec - %s", cfg_str); - (void) strcat(slot_spec, cfg_str); - (void) strcat(carts, vol_sp->vol_id.external_label); - (void) strcat(carts, " "); - } - - free(acs_rsp); - /* Send LMPL config command to define */ - /* any cartridges that were found in */ - /* slots of the library */ - if (carts[0] != '\0') { - (void) strcat(slot_spec, ";"); - mms_trace(MMS_DEBUG, - "lm_scan: SLOT_SPEC:\n%s", slot_spec); - /* Send LMPL config command for cartridge(s) */ - /* found in a cell of the library */ - if ((rc = lm_gen_lmpl_cmd(slot_spec, ele, 0)) - == LM_ERROR) { - mms_trace(MMS_ERR, - "lm_scan: Internal processing " - "error encountered while processing lmpl " - "config command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(slot_spec); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, "lm_scan: Did not receive a " - "success response for lmpl config command " - "while processing scan command"); - handle_lmpl_cmd_error(rc, "scan", "config", tid, - ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(slot_spec); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_scan: Got successful response " - "for scan config command"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7118_MSG, "carts", carts, NULL); - } else { - /* Since no config was sent clean up */ - /* for the taskid that was not used */ - mms_trace(MMS_DEBUG, - "lm_scan: No cartridges were found " - "in slots of the library"); - if ((rc = pthread_mutex_unlock(&lm_acc_mutex)) != 0) - mms_trace(MMS_CRIT, "lm_scan: Unlock of " - "accept/unaccept mutex failed with errno " - "- %s", strerror(errno)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7120_MSG, NULL); - } - lm_remove_lmpl_cmd(lmpl_tid, ele); - - if (err_carts[0] != '\0') { - err_carts[strlen(err_carts)-1] = '\0'; - mms_trace(MMS_OPER, "lm_scan: Send LMPL message to " - "indicate not all cartridges were found to " - "be present in the library, %s", err_carts); - (void) mms_buf_msgcl(cfg_str, sizeof (cfg_str), - LM_7119_MSG, "carts", err_carts, NULL); - lm_message("operator", "notice", cfg_str); - } - free(slot_spec); - } - - else if ((clause = mms_pn_lookup(cmd, kw = "fromslot", - MMS_PN_CLAUSE, NULL)) != NULL) { - loc = NULL; - MMS_PN_LOOKUP(fslot, clause, NULL, MMS_PN_STRING, &loc); - - MMS_PN_LOOKUP(clause, cmd, kw = "toslot", MMS_PN_CLAUSE, - NULL); - loc = NULL; - MMS_PN_LOOKUP(tslot, clause, NULL, MMS_PN_STRING, &loc); - mms_trace(MMS_DEBUG, - "lm_scan: scan for cartridges from %s to %s", - mms_pn_token(fslot), mms_pn_token(tslot)); - mms_trace(MMS_OPER, "lm_scan: scan for a range of slots is not " - "supported on a ACSLS controlled library, sending error " - "response for scan command"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7116_MSG, - "type", lm.lm_type, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_INTERNAL), msg_str); - return (LM_ERROR); - - } else if ((clause = mms_pn_lookup(cmd, kw = "drive", - MMS_PN_CLAUSE, &loc1)) != NULL) { - for (i = 0; clause != NULL; clause = mms_pn_lookup(cmd, - "drive", MMS_PN_CLAUSE, &loc1)) { - MMS_PN_LOOKUP(dname, clause, NULL, MMS_PN_STRING, - NULL); - mms_trace(MMS_DEBUG, "lm_scan: scan for drive %s", - mms_pn_token(dname)); - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, - "lm_scan: lm_obtain_task_id " - "failed trying to generate show command " - "for scan"); - return (LM_ERROR); - } - (void) snprintf(cmd_str, sizeof (cmd_str), - LM_SHOW_SERIAL, lmpl_tid, mms_pn_token(dname)); - - mms_trace(MMS_DEBUG, - "lm_scan: show cmd for scan drive:\n%s", cmd_str); - if ((rc = lm_gen_lmpl_cmd(cmd_str, ele, 0)) == - LM_ERROR) { - mms_trace(MMS_ERR, - "lm_scan: Internal processing " - "error encountered while processing LMPL " - "show cmd"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, "lm_scan: show cmd did not " - "receive a successful response, unable " - "to get drive %s's serialnumber", - mms_pn_token(dname)); - lm_remove_lmpl_cmd(lmpl_tid, ele); - continue; - } - mms_trace(MMS_DEBUG, - "lm_scan: show cmd got sucess final response"); - node = mms_list_head(&ele->lmpl_rsp_list); - rsp = node->lmpl_rsp_tree; - - loc = NULL; - if ((clause = mms_pn_lookup(rsp, "DriveSerialNum", - MMS_PN_STRING, &loc)) == NULL) { - mms_trace(MMS_CRIT, - "lm_scan: No DriveSerialNum " - "attribute found in response to show cmd " - "for drive %s", mms_pn_token(dname)); - lm_remove_lmpl_cmd(lmpl_tid, ele); - continue; - } - - if ((attribute = mms_pn_lookup(clause, NULL, - MMS_PN_STRING, &loc)) == NULL) { - mms_trace(MMS_ERR, - "lm_scan: No DriveSerialNum value" - " found in response to show cmd for drive " - "%s", mms_pn_token(dname)); - lm_remove_lmpl_cmd(lmpl_tid, ele); - continue; - } - /* Pull apart geometry string for DRIVEID */ - /* structure used in query_drive */ - - /* Set err_buf for drive geometry */ - err_buf = mms_strapp(err_buf, - mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7235_MSG, "drive", mms_pn_token(dname), - NULL)); - - if ((cptr = mms_pn_token(attribute)) == NULL) { - mms_trace(MMS_ERR, - "lm_scan: missing drive geometry for" - "drive %s"); - (void) - lm_set_drive_disabled(mms_pn_token(dname), - "temporary"); - lm_message("operator", "error", - err_buf); - free(err_buf); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, - "lm_scan:, Drive %s has a serialnum of " - "%s, convert to geometry", mms_pn_token(dname), - cptr); - - if (lm_obtain_geometry(cptr, - &drv_geometry, "scan", tid, ret_msg) - != LM_OK) { - mms_trace(MMS_ERR, - "lm_scan: Trying to obtain geometry " - "for drive with serial " - "number %s failed", serial); - /* Error return message set in function */ - lm_set_drive_disabled(mms_pn_token(dname), - "temporary"); - lm_message("operator", "error", - err_buf); - free(err_buf); - return (LM_ERROR); - } - cptr = drv_geometry; - - if ((pptr = strstr(cptr, ",")) == NULL) { - mms_trace(MMS_ERR, - "lm_scan: missing/incomplete" - " drive geometry for" - "drive %s, geometry = %s", - mms_pn_token(dname), - drv_geometry); - lm_set_drive_disabled(mms_pn_token(dname), - "temporary"); - lm_message("operator", "error", - err_buf); - free(err_buf); - free(drv_geometry); - return (LM_ERROR); - } - *pptr = '\0'; - drive_id[i].panel_id.lsm_id.acs = atoi(cptr); - cptr = pptr + 1; - if ((pptr = strstr(cptr, ",")) == NULL) { - mms_trace(MMS_ERR, - "lm_scan: missing/incomplete" - " drive geometry for" - "drive %s, geometry = %s", - mms_pn_token(dname), - drv_geometry); - lm_set_drive_disabled(mms_pn_token(dname), - "temporary"); - lm_message("operator", "error", - err_buf); - free(err_buf); - free(drv_geometry); - return (LM_ERROR); - } - *pptr = '\0'; - drive_id[i].panel_id.lsm_id.lsm = atoi(cptr); - cptr = pptr + 1; - if ((pptr = strstr(cptr, ",")) == NULL) { - lm_serr(MMS_CRIT, - "lm_scan: missing/incomplete" - " drive geometry for" - "drive %s, geometry = %s", - mms_pn_token(dname), - drv_geometry); - lm_set_drive_disabled(mms_pn_token(dname), - "temporary"); - lm_message("operator", "error", - err_buf); - free(err_buf); - free(drv_geometry); - return (LM_ERROR); - } - *pptr = '\0'; - drive_id[i].panel_id.panel = atoi(cptr); - cptr = pptr + 1; - drive_id[i].drive = atoi(cptr); - /* free the err_buf for drive geometry */ - free(drv_geometry); - free(err_buf); - err_buf = NULL; - - - mms_trace(MMS_DEBUG, "lm_scan: Drive %s query_drive(), " - "%d,%d,%d,%d", mms_pn_token(dname), - drive_id[i].panel_id.lsm_id.acs, - drive_id[i].panel_id.lsm_id.lsm, - drive_id[i].panel_id.panel, - drive_id[i].drive); - - lm_remove_lmpl_cmd(lmpl_tid, ele); - if (++i == MAX_ID) { - mms_trace(MMS_OPER, - "lm_scan: Number of drives to " - "scan exceeded the max allowed of %d", - MAX_ID); - break; - } - } - - /* Query for drives in library */ - if ((lm_acs_query_drive(&acs_rsp, drive_id, i, "scan", tid, - ret_msg)) == LM_ERROR) - return (LM_ERROR); - - mms_trace(MMS_DEBUG, "lm_scan: Received final response for " - "query_drive"); - - drv_qp = (ACS_QUERY_DRV_RESPONSE *)acs_rsp->acs_rbuf; - if (drv_qp->query_drv_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_scan: final response from " - "query_drive() failed, status - %s", - acs_status(drv_qp->query_drv_status)); - lm_handle_acsls_error(drv_qp->query_drv_status, - "acs_query_drive", "scan", tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - drive_spec_size = 100 * i; - if ((drive_spec = (char *)malloc(drive_spec_size)) == NULL) { - lm_serr(MMS_CRIT, "lm_scan: Unable to malloc space " - "for drive spec definitions"); - return (LM_ERROR); - } - - - /* Setup to send partial config for any drives */ - /* found in library */ - (void) strcpy(drive_spec, - "config task[\"%d\"] scope[partial] "); - - carts[0] = '\0'; - err_carts[0] = '\0'; - /* Check each drive to see if it is found in */ - /* the library, also verify if is online and if */ - /* a cartridge exists in the drive */ - for (j = 0; j < (int)drv_qp->count; j++) { - drv_sp = &drv_qp->drv_status[j]; - if (drv_sp->status == STATUS_DRIVE_IN_USE) - occupied = 1; - else if (drv_sp->status == STATUS_DRIVE_AVAILABLE) - occupied = 0; - else { - mms_trace(MMS_ERR, "lm_scan: drive %d,%d,%d,%d " - "failed query_drive with a status - %s", - drv_sp->drive_id.panel_id.lsm_id.acs, - drv_sp->drive_id.panel_id.lsm_id.lsm, - drv_sp->drive_id.panel_id.panel, - drv_sp->drive_id.drive, - acs_status(drv_sp->status)); - (void) snprintf(cmd_str, sizeof (cmd_str), - "%d,%d,%d,%d", - drv_sp->drive_id.panel_id.lsm_id.acs, - drv_sp->drive_id.panel_id.lsm_id.lsm, - drv_sp->drive_id.panel_id.panel, - drv_sp->drive_id.drive); - (void) strcat(err_carts, cmd_str); - (void) strcat(err_carts, " "); - continue; - } - if (drv_sp->state == STATE_ONLINE) - accessible = 1; - - (void) snprintf(geometry, sizeof (geometry), - "%d,%d,%d,%d", - drv_sp->drive_id.panel_id.lsm_id.acs, - drv_sp->drive_id.panel_id.lsm_id.lsm, - drv_sp->drive_id.panel_id.panel, - drv_sp->drive_id.drive); - if (lm_obtain_serial_num(geometry, &serial, - "scan", tid, ret_msg) != LM_OK) { - mms_trace(MMS_ERR, "lm_scan: " - "Trying to obtain serial number " - "for drive with ACSLS geometry %s " - "failed", geometry); - return (LM_ERROR); - } - if (strcmp(serial, "") == 0) { - mms_trace(MMS_ERR, "lm_library_config: " - "No serial number found for drive " - "with ACSLS geometry of %s", - geometry); - } - (void) snprintf(cfg_str, sizeof (cfg_str), CFG_DRIVE, - serial, - drv_sp->drive_id.panel_id.lsm_id.acs, - drv_sp->drive_id.panel_id.lsm_id.lsm, - drv_sp->drive_id.panel_id.panel, - drv_sp->drive_id.drive, - drv_sp->drive_id.panel_id.panel, - occupied ? drv_sp->vol_id.external_label : "none", - occupied ? "true" : "false", - accessible ? "true" : "false"); - - mms_trace(MMS_DEBUG, - "lm_scan: Drive Spec - %s", cfg_str); - (void) strcat(drive_spec, cfg_str); - (void) snprintf(cmd_str, sizeof (cmd_str), - "%d,%d,%d,%d", - drv_sp->drive_id.panel_id.lsm_id.acs, - drv_sp->drive_id.panel_id.lsm_id.lsm, - drv_sp->drive_id.panel_id.panel, - drv_sp->drive_id.drive); - (void) strcat(carts, cmd_str); - (void) strcat(carts, " "); - accessible = 0; - if ((lm_drive_serial_num(cmd_str, tid, ret_msg)) - != LM_OK) { - mms_trace(MMS_ERR, - "lm_scan: Unable to get serial " - "number for drive %s", cmd_str); - free(drive_spec); - free(acs_rsp); - return (LM_ERROR); - } - } - free(acs_rsp); - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, "lm_scan: lm_obtain_task_id failed " - "trying to generate config command for scan"); - free(acs_rsp); - free(drive_spec); - return (LM_ERROR); - } - - spec_form = strdup(drive_spec); - (void) snprintf(drive_spec, - drive_spec_size, - spec_form, - lmpl_tid); - free((char *)spec_form); - - /* Send LMPL config command to define */ - /* any drives that were found in library */ - if (carts[0] != '\0') { - (void) strcat(drive_spec, ";"); - mms_trace(MMS_DEBUG, - "lm_scan: DRIVE_SPEC:\n%s", drive_spec); - - if ((rc = lm_gen_lmpl_cmd(drive_spec, ele, 0)) - == LM_ERROR) { - mms_trace(MMS_ERR, - "lm_scan: Internal processing " - "error encountered while processing lmpl " - "config cmd"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(drive_spec); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, "lm_scan: Did not receive a " - "success response for lmpl config command " - "while processing scan command"); - handle_lmpl_cmd_error(rc, "scan", "config", tid, - ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(drive_spec); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_scan: Got successful response " - "for scan config drive command"); - - carts[strlen(err_carts)-1] = '\0'; - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7121_MSG, "geom", carts, NULL); - } else { - /* Since no config was sent clean up */ - /* for the taskid that was not used */ - mms_trace(MMS_DEBUG, "lm_scan: No drives were found in " - "in library"); - if ((rc = pthread_mutex_unlock(&lm_acc_mutex)) != 0) - mms_trace(MMS_CRIT, "lm_scan: Unlock of " - "accept/unaccept mutex failed with errno " - "- %s", strerror(errno)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7122_MSG, NULL); - } - lm_remove_lmpl_cmd(lmpl_tid, ele); - - if (err_carts[0] != '\0') { - err_carts[strlen(err_carts)-1] = '\0'; - mms_trace(MMS_OPER, "lm_scan: Send LMPL message to " - "indicate not all drives were found to be " - "present in the library, %s", err_carts); - (void) mms_buf_msgcl(cfg_str, sizeof (cfg_str), - LM_7123_MSG, "geom", err_carts, NULL); - lm_message("operator", "notice", cfg_str); - } - free(drive_spec); - - } else { - mms_trace(MMS_DEBUG, "lm_scan: rescan entire library"); - - if ((rc = lm_common_ready(LM_NOT, tid, ret_msg)) != LM_OK) { - mms_trace(MMS_ERR, "lm_scan: Failure of ready command " - "to MM. Unable to set state to not ready"); - } - lm_state = LM_NOT_READY; - - mms_trace(MMS_OPER, "lm_scan: library state set to NOT_READY"); - - if ((rc = lm_library_config("scan", tid, ret_msg)) != LM_OK) { - mms_trace(MMS_ERR, "lm_scan: lm_library_config failed"); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, - "lm_scan: rescan of entire library completed"); - - if ((rc = lm_common_ready(LM_READY, tid, ret_msg)) != LM_OK) { - mms_trace(MMS_ERR, "lm_scan: Failure of ready command " - "to MM. Unable to set state to ready"); - return (LM_ERROR); - } - lm_state = LM_ACTIVE; - - mms_trace(MMS_OPER, "lm_scan: library sate set to READY"); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7124_MSG, - NULL); - } - - (void) snprintf(ret_msg, RMBUFSIZE, LM_SUC_FINAL, tid, msg_str, ""); - mms_trace(MMS_DEVP, "Exiting lm_scan"); - return (LM_OK); - -not_found: - mms_trace(MMS_ERR, "LMPM command %s encountered an invalid or missing " - "%s clause:\n%s", "scan", kw, mms_pn_build_cmd_text(cmd)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7009_MSG, "cmd", "scan", "part", kw, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INVALID), - mms_sym_code_to_str(MMS_LM_E_CMDARGS), msg_str); - return (LM_ERROR); -} -/* - * lm_activate()() - * - * Parameters: - * - cmd Parse tree of LMPM activate command being processed. - * - tid Task id of LMPM activate command being processed. - * - ret_msg Ptr to final response string. If an error message is - * to be sent to MM for the activate command because of - * a failure, the error response is created here. - * - * This function executes the necessary steps that are ACSLS library specific - * for the LM to process the activate command. This routine is responsible - * for establishing the connection to the ACSLS SSI process and doing - * the entire library configuration portion during an LM activation. - * - * Return Values: - * - LM_OK If function completed successfully - * - LM_ERROR If function detected something that does not - * allow the LM to become active. In some cases - * depending on the error, ret_msg may be updated to - * reflect the error that was encountered as to why - * the LM cannot become active. - */ -int -/* LINTED argument unused in function */ -lm_activate(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - - int rc; - int pkt_ver; - int lmpl_tid; - - char cmd_str[512]; - char msg_str[256]; - char env_ssi_port[128]; - - mms_par_node_t *loc = NULL; - mms_par_node_t *pri_rsp; - mms_par_node_t *clause; - mms_par_node_t *attribute; - - STATUS status; - SEQ_NO s; - - acs_rsp_ele_t *acs_rsp; - lmpl_rsp_ele_t *ele; - lmpl_rsp_node_t *node; - - mms_trace(MMS_DEVP, "Entering ACSLS %s lm_activate", lm.lm_type); - - - if ((rc = lm_acs_init()) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_activate: lm_acs_init failed"); - return (LM_ERROR); - } - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, "lm_activate: Unable to get a task id " - "for private command to obtain libraries ACS number"); - return (LM_ERROR); - } - - (void) snprintf(cmd_str, sizeof (cmd_str), PRIVATE_CMD, lmpl_tid, - PRI_GET_ACSLS); - - mms_trace(MMS_DEBUG, - "lm_activate: Obtain library acs cmd - \n%s", cmd_str); - - if ((rc = lm_gen_lmpl_cmd(cmd_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_activate: Internal " - "processing error encountered while processing " - "private command to obtain library acs"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_CRIT, - "lm_activate: Error encountered while sending " - "private command to obtain library acs"); - handle_lmpl_cmd_error(rc, "activate", "private", - tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - node = mms_list_head(&ele->lmpl_rsp_list); - pri_rsp = node->lmpl_rsp_tree; - - mms_trace(MMS_DEBUG, - "lm_activate: Private cmd got success final response"); - - - if ((clause = mms_pn_lookup(pri_rsp, "text", MMS_PN_CLAUSE, NULL)) - == NULL) { - mms_trace(MMS_CRIT, - "lm_activate: No text clause found in finial " - "success response of private command to obtain library " - "ACS"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - if ((attribute = mms_pn_lookup(clause, "LibraryACS", MMS_PN_STRING, - &loc)) == NULL) { - mms_trace(MMS_CRIT, - "lm_activate: No ACS attribute found in final " - "success response of private command to obtain library " - "ACS"); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7018_MSG, "object", "LibraryACS", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_CONFIG), msg_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - if ((attribute = mms_pn_lookup(clause, NULL, MMS_PN_STRING, - &loc)) == NULL) { - mms_trace(MMS_CRIT, "lm_activate: No ACS value found in final " - "response of private command to obtain library ACS"); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7018_MSG, "object", "LibraryACS", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_CONFIG), msg_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - lm.lm_acs = atoi(mms_pn_token(attribute)); - - /* Set LibraryLSM */ - if ((attribute = mms_pn_lookup(clause, "LibraryLSM", MMS_PN_STRING, - &loc)) == NULL) { - mms_trace(MMS_CRIT, - "lm_activate: No LSM attribute found in final " - "success response of private command to obtain library " - "ACS/LSM"); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7018_MSG, "object", "LibraryLSM", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_CONFIG), msg_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - if ((attribute = mms_pn_lookup(clause, NULL, MMS_PN_STRING, - &loc)) == NULL) { - mms_trace(MMS_CRIT, "lm_activate: No LSM value found in final " - "response of private command to obtain library LSM"); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7018_MSG, "object", "LibraryLSM", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_CONFIG), msg_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - lm.lm_lsm = atoi(mms_pn_token(attribute)); - - /* Set SSI Port number */ - if ((attribute = mms_pn_lookup(clause, "LMSSIPort", MMS_PN_STRING, - &loc)) == NULL) { - mms_trace(MMS_CRIT, - "lm_activate: No SSI Port found in final " - "success response of private command to obtain library " - "info "); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7018_MSG, "object", "LMSSIPort", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_CONFIG), msg_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - if ((attribute = mms_pn_lookup(clause, NULL, MMS_PN_STRING, - &loc)) == NULL) { - mms_trace(MMS_CRIT, "lm_activate: No SSI Port" - " value found in final " - "response of private command to obtain library info"); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7018_MSG, "object", "LMSSIPort", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_STATE), - mms_sym_code_to_str(MMS_LM_E_CONFIG), msg_str); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - lm.lm_ssiport = atoi(mms_pn_token(attribute)); - - mms_trace(MMS_DEBUG, - "ACSAPI_SSI_SOCKET=%d", - lm.lm_ssiport); - (void) snprintf(env_ssi_port, sizeof (env_ssi_port), - "ACSAPI_SSI_SOCKET=%d", lm.lm_ssiport); - (void) putenv(env_ssi_port); - - mms_trace(MMS_DEBUG, "lm_activate: Library ACS - %d, Library LSM - %d", - lm.lm_acs, lm.lm_lsm); - - lm_remove_lmpl_cmd(lmpl_tid, ele); - - /* See if SSI is running by query acsls server */ - s = (SEQ_NO)(LM_Q_SERVER_SEQ + pthread_self()); - if ((status = acs_query_server(s)) != STATUS_SUCCESS) { - mms_trace(MMS_CRIT, "lm_activate: acs_query_server() failed, " - "status - %s, check to make sure SSI is running", - acs_status(status)); - lm_handle_acs_cmd_error(status, "activate", tid, ret_msg); - return (LM_ERROR); - } - - /* Obtain response for query_server() */ - acs_rsp = NULL; - do { - if (acs_rsp != NULL) - free(acs_rsp); - if ((acs_rsp = lm_obtain_acs_response(s, "activate", - tid, ret_msg)) == NULL) - /* Internal error encountered */ - return (LM_ERROR); - if (acs_rsp->acs_status != STATUS_SUCCESS) { - mms_trace(MMS_CRIT, "lm_activate: acs_response() " - "for query_server failed %s", - acs_status(status)); - lm_handle_acs_cmd_error(status, "activate", tid, - ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - if (acs_rsp->acs_type == RT_ACKNOWLEDGE) { - mms_trace(MMS_DEBUG, "lm_activate: Received " - "acknowledge response for query_server()"); - continue; - } else if (acs_rsp->acs_type == RT_FINAL) { - mms_trace(MMS_DEBUG, "lm_activate: Recevied final " - "response for query_server()"); - } else if (acs_rsp->acs_type == RT_INTERMEDIATE) { - mms_trace(MMS_DEBUG, "lm_activate: Received " - "intermediate response for query_server()"); - } else { - mms_trace(MMS_ERR, "lm_activate: Received unknow " - "response type for query_server() - %d", - acs_rsp->acs_type); - continue; - } - } while (acs_rsp->acs_type != RT_FINAL); - - - if ((pkt_ver = acs_get_packet_version()) != ACS_PKT_VER) { - mms_trace(MMS_CRIT, "ACSLS server is using a packet version " - "of %d and LM is using a version of %d. LM and ACSLS " - "server are incompatiable", pkt_ver, ACS_PKT_VER); - return (LM_ERROR); - } - - if ((rc = lm_lib_type(lm.lm_lsm, tid, ret_msg)) != LM_OK) { - mms_trace(MMS_ERR, "lm_activate: lm_lib_type failed"); - return (LM_ERROR); - } - - if ((rc = lm_library_config("activate", tid, ret_msg)) != LM_OK) { - mms_trace(MMS_ERR, "lm_activate: lm_library_config failed"); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "ACSLS %s lm_activate succeeded", lm.lm_type); - - return (LM_OK); -} - -int -/* LINTED argument unused in function */ -lm_reset(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - - - mms_trace(MMS_DEVP, "lm_reset: Entering ACSLS reset process"); - - if (mms_pn_lookup(cmd, "partial", MMS_PN_KEYWORD, NULL) == NULL) { - mms_trace(MMS_DEBUG, "lm_reset: Nothing defined to do for a " - "full reset of an ACSLS library"); - return (LM_OK); - } - - mms_trace(MMS_DEBUG, - "lm_reset: Nothing defined to do for a partial reset " - "of an ACSLS library"); - - return (LM_OK); - -} - -int -lm_eject(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - int i = 0; - int j; - int rc; - int lmpl_tid; - int slot_spec_size; - - char *kw; - char *slot_spec; - char msg_str[256]; - char text_str[256]; - char tmp_str[256]; - char dele_str[1024]; - char carts[2048]; - char err_carts[2048]; - char text_cart[12]; - char text_carts[2048]; - - VOLID volid_list[MAX_ID]; - VOLID *vol_id; - CAPID cap_id; - ACS_EJECT_RESPONSE *ep; - - mms_par_node_t *loc = NULL; - mms_par_node_t *loc1 = NULL; - mms_par_node_t *clause; - mms_par_node_t *value; - mms_par_node_t *value1; - - acs_rsp_ele_t *acs_rsp; - acs_cap_t *acs_cap; - lmpl_rsp_ele_t *ele; - - char nbuf[20]; - - /* Create default final error response due to */ - /* internal processing error */ - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7004_MSG, "cmd", "eject", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_INTERNAL), msg_str); - - /* Obtain slotgroup (Name of cap to use) */ - MMS_PN_LOOKUP(clause, cmd, kw = "slotgroup", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, clause, NULL, MMS_PN_STRING, NULL); - - cap_id.lsm_id.acs = lm.lm_acs; - /* If more than one lsm can exist within the acs, */ - /* the lsm will need to be determined */ - cap_id.lsm_id.lsm = lm.lm_lsm; - - acs_cap = (acs_cap_t *)lm.lm_port; - for (i = 0; i < lm.lm_caps; i++) { - if (strcmp(acs_cap->cap_name, mms_pn_token(value)) == 0) { - mms_trace(MMS_DEBUG, - "lm_eject: Physical cap associated " - "with slotgroup %s found", acs_cap->cap_name); - /* Make sure that the cap actually exists in */ - /* the library, some libraries have optional */ - /* caps */ - if (!acs_cap->cap_config) { - mms_trace(MMS_ERR, "lm_eject: Physcial cap " - "associated with slotgroup %s is not " - "available in the library - %s", - acs_cap->cap_name); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7108_MSG, "port", mms_pn_token(value), - NULL); - (void) snprintf(ret_msg, RMBUFSIZE, - LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INVALID), - mms_sym_code_to_str(MMS_LM_E_PORT), - msg_str); - return (LM_ERROR); - } - break; - } - } - if (i == lm.lm_caps) { - mms_trace(MMS_ERR, "lm_eject: Did not find a physical cap " - "associated with slotgroup - %s", - mms_pn_token(value)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7117_MSG, - "port", mms_pn_token(value), NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INVALID), - mms_sym_code_to_str(MMS_LM_E_PORT), msg_str); - return (LM_ERROR); - } - - cap_id.cap = acs_cap->cap_capid; - - mms_trace(MMS_DEBUG, "lm_eject: Cap group name for eject - %s, %d", - acs_cap->cap_name, acs_cap->cap_capid); - - /* NOTE The number of cartridges that can be ejected cannot exceed */ - /* the size of the CAP, Currently the ACSLS libraries that we */ - /* support CAP size's do not exceed what can be contained in one */ - /* VOLID[MAX_ID]. If the CAP hardware is larger than MAX_ID (43) */ - /* then the code needs to be able to break the eject into multiple */ - /* acs_eject commands */ - - i = 0; - for (clause = mms_pn_lookup(cmd, kw = "slot", MMS_PN_CLAUSE, &loc); - clause != NULL; - clause = mms_pn_lookup(cmd, "slot", MMS_PN_CLAUSE, &loc)) { - loc1 = NULL; - MMS_PN_LOOKUP(value, clause, NULL, MMS_PN_STRING, &loc1); - MMS_PN_LOOKUP(value1, clause, NULL, MMS_PN_STRING, &loc1); - - mms_trace(MMS_DEBUG, - "lm_eject: eject cartridge %s from slot %s", - mms_pn_token(value1), mms_pn_token(value)); - - (void) strncpy(volid_list[i].external_label, - mms_pn_token(value1), EXTERNAL_LABEL_SIZE); - volid_list[i++].external_label[EXTERNAL_LABEL_SIZE] = '\0'; - - if (i == acs_cap->cap_size) { - mms_trace(MMS_ERR, "lm_eject: Trying to ejecting more " - "cartridges than the cap can hold, max is %d " - "for a %s library", acs_cap->cap_size, - lm.lm_type); - (void) snprintf(nbuf, sizeof (nbuf), "%d", - acs_cap->cap_size); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7113_MSG, "num", nbuf, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_DEVCMD), - msg_str); - return (LM_ERROR); - } - } - - if ((lm_acs_eject(&acs_rsp, cap_id, volid_list, i, "eject", tid, - ret_msg)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_eject:, acs_eject() failed"); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, - "lm_eject: Received final response for acs_eject()"); - - ep = (ACS_EJECT_RESPONSE *)acs_rsp->acs_rbuf; - if (ep->eject_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, - "lm_eject: response from ace_eject() failed, " - "status - %s", acs_status(ep->eject_status)); - lm_handle_eject_error(ep->eject_status, acs_cap->cap_name, - cap_id.lsm_id.lsm, "eject", tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - if (ep->count != i) { - mms_trace(MMS_ERR, - "lm_eject: response from ace_eject() does not " - "include the correct number of cartridges " - "to be ejected, expected %d, actual %d", i, - ep->count); - } - - slot_spec_size = 100 * ep->count; - if ((slot_spec = (char *)malloc(slot_spec_size)) == NULL) { - lm_serr(MMS_CRIT, "lm_eject: Unable to malloc space " - "for delete slot definitions"); - free(acs_rsp); - return (LM_ERROR); - } - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, "lm_eject: lm_obtain_task_id failed " - "trying to generate config cmd for slot deletion"); - free(acs_rsp); - free(slot_spec); - return (LM_ERROR); - } - - (void) snprintf(slot_spec, slot_spec_size, - "config task[\"%d\"] scope[partial] ", lmpl_tid); - - carts[0] = '\0'; - err_carts[0] = '\0'; - text_carts[0] = '\0'; - for (j = 0; j < ep->count; j++) { - vol_id = &ep->vol_id[j]; - if (ep->vol_status[j] != STATUS_SUCCESS) { - mms_trace(MMS_OPER, - "lm_eject: Ejection of cartridge %s " - "failed, status - %s", vol_id->external_label, - acs_status(ep->vol_status[j])); - (void) strcat(err_carts, vol_id->external_label); - (void) strcat(err_carts, " "); - } else { - mms_trace(MMS_DEBUG, - "lm_eject: Cartridge %s was ejected " - "from library", vol_id->external_label); - (void) snprintf(dele_str, sizeof (dele_str), - DELE_SLOT, vol_id->external_label); - (void) strcat(slot_spec, dele_str); - (void) strcat(carts, vol_id->external_label); - (void) strcat(carts, " "); - (void) snprintf(text_cart, sizeof (text_cart), - TEXT_CART, vol_id->external_label); - (void) strlcat(text_carts, text_cart, - sizeof (text_carts)); - } - } - - free(acs_rsp); - - if (carts[0] != '\0') { - (void) strcat(slot_spec, ";"); - mms_trace(MMS_DEBUG, "lm_eject: SLOT_SPEC:\n%s", slot_spec); - - if ((rc = lm_gen_lmpl_cmd(slot_spec, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, - "lm_eject: Internal processing error " - "encountered while processing lmpl config " - "command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(slot_spec); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - handle_lmpl_cmd_error(rc, "eject", "config", tid, - ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(slot_spec); - return (LM_ERROR); - } - - mms_trace(MMS_OPER, "lm_eject: Got successful response for " - "slot deletion config command for cartridges - %s", carts); - free(slot_spec); - lm_remove_lmpl_cmd(lmpl_tid, ele); - carts[strlen(carts)-1] = '\0'; - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7107_MSG, - "cart", carts, NULL); - } else { - free(slot_spec); - lm_remove_lmpl_cmd(lmpl_tid, ele); - mms_trace(MMS_OPER, - "lm_eject:, No cartridges were successfully ejected"); - mms_trace(MMS_DEBUG, "Free up accept mutex"); - if ((rc = pthread_mutex_unlock(&lm_acc_mutex)) != 0) { - lm_serr(MMS_CRIT, - "lm_eject: Unable to unlock acc/unacc " - "mutex, errno - %s", strerror(errno)); - return (LM_ERROR); - } - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7115_MSG, - NULL); - } - - if (err_carts[0] != '\0') { - err_carts[strlen(err_carts)-1] = '\0'; - /* Some cartridges did not successfully get ejected */ - mms_trace(MMS_OPER, - "Cartridges %s were not ejected from library", - err_carts); - (void) mms_buf_msgcl(tmp_str, sizeof (tmp_str), LM_7114_MSG, - "cart", err_carts, NULL); - lm_message("operator", "notice", tmp_str); - } - - if (text_carts[0] != '\0') { - text_carts[strlen(text_carts)-1] = '\0'; - (void) snprintf(text_str, sizeof (text_str), LM_TEXT_CLS, - text_carts); - } else { - text_str[0] = '\0'; - } - (void) snprintf(ret_msg, RMBUFSIZE, LM_SUC_FINAL, tid, text_str, - msg_str); - mms_trace(MMS_DEVP, "Exiting lm_eject"); - return (LM_OK); - -not_found: - mms_trace(MMS_ERR, "lm_eject: LMPM command %s encounterd an invalid " - "or missing %s clause:\n%s", "eject", kw, - mms_pn_build_cmd_text(cmd)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7009_MSG, "cmd", "eject", "part", kw, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INVALID), - mms_sym_code_to_str(MMS_LM_E_CMDARGS), msg_str); - return (LM_ERROR); -} - -int -/* LINTED argument unused in function */ -lm_barrier(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - char msg_str[256]; - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7101_MSG, - "cmd", "barrier", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_SUC_FINAL, tid, msg_str, ""); - return (LM_OK); -} - -/* - * lm_private()() - * - * Parameters: - * - cmd Parse tree of LMPM private command being processed. - * - tid Task id of LMPM private command being processed. - * - ret_msg Ptr to final response string. If an error message is - * to be sent to MM for the private command because of - * a failure, the error response is created here. - * - * This function executes the necessary steps that are ACSLS library specific - * for the LM to process the private command. This routine is responsible - * for calling lm_validate_private(), which validates that all data - * elements in the get, set, and unset clauses are valid names. - * - * Return Values: - * - LM_OK If function completed successfully - * - LM_ERROR If function detected something that does not - * allow the LM to become active. In some cases - * depending on the error, ret_msg may be updated to - * reflect the error that was encountered as to why - * the LM cannot successfully process the command. - */ -int -lm_private(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - - mms_trace(MMS_DEVP, "Entering ACSLS lm_private"); - - if (lm_validate_private(cmd, tid, ret_msg) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_private: lm_validate_private() failed"); - return (LM_ERROR); - } - - /* No get-name operations for ACSLS libraries, return a */ - /* empty string */ - (void) strcpy(ret_msg, ""); - - mms_trace(MMS_DEVP, "Exiting ACSLS lm_private"); - - return (LM_OK); -} - -int -/* LINTED argument unused in function */ -lm_cancel(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - char msg_str[512]; - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7101_MSG, - "cmd", "cancel", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_SUC_FINAL, tid, msg_str, ""); - return (LM_OK); -} - -int -lm_event(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - - ACS_QUERY_VOL_RESPONSE *vol_qp; - QU_VOL_STATUS *vol_sp; - ACS_QUERY_DRV_RESPONSE *drv_qp; - QU_DRV_STATUS *drv_sp; - VOLID vol_id_list[MAX_ID]; - DRIVEID drive_id[MAX_ID]; - - SEQ_NO s; - STATUS status; - acs_rsp_ele_t *acs_rsp; - lmpl_rsp_ele_t *ele; - lmpl_rsp_node_t *node; - - int rc; - int panel; - int lmpl_tid; - int count; - int accessible = 0; - int occupied = 0; - - char *geometry = NULL; - - mms_par_node_t *loc = NULL; - mms_par_node_t *clause; - mms_par_node_t *object; - mms_par_node_t *attribute; - mms_par_node_t *library; - mms_par_node_t *rsp; - - char *cptr; - char *pptr; - char *obj_val; - char cmd_str[1024]; - char cfg_str[1024]; - - mms_trace(MMS_DEVP, "Entering lm_event"); - - if ((clause = mms_pn_lookup(cmd, NULL, MMS_PN_CLAUSE, NULL)) - == NULL) { - return (LM_ERROR); - } - - MMS_PN_LOOKUP(object, clause, NULL, MMS_PN_STRING, &loc); - obj_val = mms_pn_token(object); - - MMS_PN_LOOKUP(library, clause, NULL, MMS_PN_STRING, &loc); - if (strcmp(lm.lm_net_cfg.cli_name, mms_pn_token(library)) != 0) { - mms_trace(MMS_OPER, - "lm_event: Event %s is for library %s, skipping", - mms_pn_token(object), mms_pn_token(library)); - return (LM_OK); - } else { - mms_trace(MMS_OPER, - "lm_event: Event %s is for this library, %s", - mms_pn_token(object), mms_pn_token(library)); - } - - if (strcmp(mms_pn_token(clause), "newdrive") == 0) { - mms_trace(MMS_DEBUG, "lm_event:, Config new drive %s", obj_val); - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, - "lm_event: lm_obtain_task_id failed " - "trying to generate config command for event"); - return (LM_ERROR); - } - (void) snprintf(cmd_str, sizeof (cmd_str), LM_SHOW_SERIAL, - lmpl_tid, obj_val); - - mms_trace(MMS_DEBUG, "lm_event: show cmd for drive event:\n%s", - cmd_str); - - if ((rc = lm_gen_lmpl_cmd(cmd_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, - "lm_event: Internal processing error " - "encountered while processing LMPL show cmd"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, "lm_event: show cmd did not receive " - "a successful response"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, - "lm_event: show cmd got sucess final response"); - node = mms_list_head(&ele->lmpl_rsp_list); - rsp = node->lmpl_rsp_tree; - - loc = NULL; - if ((clause = mms_pn_lookup(rsp, "DriveSerialNum", - MMS_PN_STRING, &loc)) == NULL) { - mms_trace(MMS_CRIT, "lm_event: No DriveSerialNum " - "attribute found in response to show cmd"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - if ((attribute = mms_pn_lookup(clause, NULL, MMS_PN_STRING, - &loc)) == NULL) { - mms_trace(MMS_CRIT, - "lm_event:, No DriveSerialNum value " - "found in response to show cmd"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_event: Drive %s has a " - "serialnum of %s, convert to geometry", - obj_val, mms_pn_token(attribute)); - - cptr = mms_pn_token(attribute); - - if (lm_obtain_geometry(cptr, - &geometry, "event", tid, ret_msg) - != LM_OK) { - mms_trace(MMS_ERR, - "lm_event: Trying to obtain geometry " - "for drive with serial " - "number %s failed", cptr); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - cptr = geometry; - - pptr = strstr(cptr, ","); - *pptr = '\0'; - drive_id[0].panel_id.lsm_id.acs = atoi(cptr); - cptr = pptr + 1; - pptr = strstr(cptr, ","); - *pptr = '\0'; - drive_id[0].panel_id.lsm_id.lsm = atoi(cptr); - cptr = pptr + 1; - pptr = strstr(cptr, ","); - *pptr = '\0'; - drive_id[0].panel_id.panel = atoi(cptr); - cptr = pptr + 1; - drive_id[0].drive = atoi(cptr); - free(geometry); - - mms_trace(MMS_DEBUG, "lm_event: Drive %s query_drive(), " - "%d,%d,%d,%d", obj_val, drive_id[0].panel_id.lsm_id.acs, - drive_id[0].panel_id.lsm_id.lsm, - drive_id[0].panel_id.panel, - drive_id[0].drive); - - lm_remove_lmpl_cmd(lmpl_tid, ele); - - s = (SEQ_NO)(LM_EVENT_SEQ + pthread_self()); - count = 1; - if ((status = acs_query_drive(s, drive_id, count)) - != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_event: acs_query_drive() failed " - "status - %s", acs_status(status)); - return (LM_ERROR); - } - - do { - if ((acs_rsp = lm_obtain_acs_response(s, "event", tid, - ret_msg)) == NULL) - /* Internal error encountered */ - return (LM_ERROR); - if (acs_rsp->acs_status != STATUS_SUCCESS) { - mms_trace(MMS_CRIT, "lm_event: acs_response() " - "for query_drive failed, status " - "- %s", acs_status(status)); - free(acs_rsp); - return (LM_ERROR); - } - if (acs_rsp->acs_type == RT_ACKNOWLEDGE) { - mms_trace(MMS_DEBUG, "lm_event: Received " - "acknowledge response for query_drive"); - continue; - } else if (acs_rsp->acs_type != RT_FINAL) { - mms_trace(MMS_DEBUG, - "lm_event: Received unknown " - "response type of query_drive - %d", - acs_rsp->acs_type); - continue; - } - - } while (acs_rsp->acs_type != RT_FINAL); - - mms_trace(MMS_DEBUG, "lm_event: Received final response for " - "query_drive"); - - drv_qp = (ACS_QUERY_DRV_RESPONSE *)acs_rsp->acs_rbuf; - if (drv_qp->query_drv_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_event: response from " - "query_drive() failed, status is %s", - acs_status(drv_qp->query_drv_status)); - free(acs_rsp); - return (LM_ERROR); - } - - drv_sp = &drv_qp->drv_status[0]; - if (drv_sp->status == STATUS_DRIVE_IN_USE) - occupied = 1; - if (drv_sp->state == STATE_ONLINE) - accessible = 1; - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, - "lm_event: lm_obtain_task_id failed " - "trying to generate config command for event"); - return (LM_ERROR); - } - (void) snprintf(cfg_str, sizeof (cfg_str), CONFIG_DRIVE_EVENT, - lmpl_tid, - drv_sp->drive_id.panel_id.lsm_id.acs, - drv_sp->drive_id.panel_id.lsm_id.lsm, - drv_sp->drive_id.panel_id.panel, - drv_sp->drive_id.drive, - drv_sp->drive_id.panel_id.panel, - occupied ? drv_sp->vol_id.external_label : "none", - occupied ? "true" : "false", - accessible ? "true" : "false"); - - free(acs_rsp); - - } else - - if (strcmp(mms_pn_token(clause), "newcartridge") == 0) { - mms_trace(MMS_DEBUG, - "lm_event: Config new cartridge %s", obj_val); - - (void) strncpy(vol_id_list[0].external_label, obj_val, - EXTERNAL_LABEL_SIZE); - vol_id_list[0].external_label[EXTERNAL_LABEL_SIZE] = '\0'; - if ((lm_acs_query_volume(&acs_rsp, vol_id_list, 1, "event", tid, - ret_msg)) == LM_ERROR) - return (LM_ERROR); - mms_trace(MMS_DEBUG, "lm_event: Recevied final response for " - "query_volume()"); - - vol_qp = (ACS_QUERY_VOL_RESPONSE *)acs_rsp->acs_rbuf; - if (vol_qp->query_vol_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_event: response from " - "query_volume() failed, status - %s", - acs_status(vol_qp->query_vol_status)); - free(acs_rsp); - return (LM_ERROR); - } - vol_sp = &vol_qp->vol_status[0]; - - if (vol_sp->status != STATUS_VOLUME_HOME) { - mms_trace(MMS_ERR, "lm_event: Unable to send a config " - "for cartridge %s, cartridge status - %s", - obj_val, acs_status(vol_sp->status)); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_event: vol %s is in location " - "%d,%d,%d,%d,%d", vol_sp->vol_id.external_label, - vol_sp->location.cell_id.panel_id.lsm_id.acs, - vol_sp->location.cell_id.panel_id.lsm_id.lsm, - vol_sp->location.cell_id.panel_id.panel, - vol_sp->location.cell_id.row, - vol_sp->location.cell_id.col); - - panel = vol_sp->location.cell_id.panel_id.panel; - - free(acs_rsp); - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, - "lm_event: lm_obtain_task_id failed " - "trying to generate config command for event"); - return (LM_ERROR); - } - - (void) snprintf(cfg_str, sizeof (cfg_str), CONFIG_CART_EVENT, - lmpl_tid, obj_val, panel, panel, obj_val, lm.lm_type); - } else { - mms_trace(MMS_ERR, "lm_event: Unsupported event type %s", - mms_pn_token(clause)); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_event: config for event:\n%s", cfg_str); - - if ((rc = lm_gen_lmpl_cmd(cfg_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_event: Internal processing error " - "encountered while processing lmpl config command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, "lm_event: LMPL config command failed while " - "processing LMPM event command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - mms_trace(MMS_DEBUG, - "lm_event: Got successful response for event config command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_OK); - -not_found: - mms_trace(MMS_ERR, - "LMPM command event encountered an invalid or missing " - "%s clause, cmd:\n%s", mms_pn_token(clause), - mms_pn_build_cmd_text(cmd)); - return (LM_ERROR); -} - -int -lm_library_config(char *cmd, char *tid, char *ret_msg) -{ - int rc; - int i; - int count; - int lmpl_tid; - int freecells = 0; - int cell_size; - int accessible; - int occupied; - int rsp_cnt; - int spec_stop; - int loop_stop = 0; - - char cfg_str[1024]; - char full_str[FSBUFSIZE]; - char geometry[128]; - char *slot_spec; - char *drive_spec; - char *serial; - - lmpl_rsp_ele_t *ele; - acs_rsp_ele_t *acs_rsp; - acs_drive_t *acs_drives; - - SEQ_NO s; - STATUS status; - - ACS_QUERY_LSM_RESPONSE *lsm_qp; - QU_LSM_STATUS *lsm_sp; - LSMID lsm_id[MAX_ID]; - - ACS_QUERY_VOL_RESPONSE *vol_qp; - QU_VOL_STATUS *vol_sp; - VOLID vol_id[MAX_ID]; - - ACS_QUERY_DRV_RESPONSE *drv_qp; - QU_DRV_STATUS *drv_sp; - DRIVEID drive_id[MAX_ID]; - - mms_trace(MMS_DEVP, "Entering lm_library_config"); - - s = (SEQ_NO)(LM_Q_LSM_SEQ + pthread_self()); - - lsm_id[0].acs = lm.lm_acs; - lsm_id[0].lsm = lm.lm_lsm; /* Since there is no pass throughs */ - /* for L180, L500, or L700, libraries */ - /* lsm is always set to 0 */ - count = 1; - if ((status = acs_query_lsm(s, lsm_id, count)) != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "acs_query_lsm for acs %s failed %s", - lm.lm_acs, acs_status(status)); - lm_handle_acs_cmd_error(status, "activate", tid, ret_msg); - return (LM_ERROR); - } - /* obtain number of freecells */ - acs_rsp = NULL; - do { - if (acs_rsp != NULL) - free(acs_rsp); - if ((acs_rsp = lm_obtain_acs_response(s, "activate", - tid, ret_msg)) == NULL) - /* Internal error encountered */ - return (LM_ERROR); - if (acs_rsp->acs_status != STATUS_SUCCESS) { - mms_trace(MMS_CRIT, "lm_library_config: acs_response() " - "for query_lsm failed, status - %s", - acs_status(status)); - lm_handle_acs_cmd_error(status, "activate", tid, - ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - - if (acs_rsp->acs_type == RT_ACKNOWLEDGE) { - mms_trace(MMS_DEBUG, "lm_library_config: Received " - "acknowledge response for query_lsm"); - continue; - } else if (acs_rsp->acs_type != RT_FINAL) { - mms_trace(MMS_DEBUG, - "lm_library_config: Received unknown " - "response type for query_lsm() - %d", - acs_rsp->acs_type); - continue; - } - - } while (acs_rsp->acs_type != RT_FINAL); - - mms_trace(MMS_DEBUG, "lm_library_config: Received final response for " - "query_lsm"); - - /* Get number of free cells in lsm */ - lsm_qp = (ACS_QUERY_LSM_RESPONSE *)acs_rsp->acs_rbuf; - if (lsm_qp->query_lsm_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_library_config: Final response " - "for query_lsm not success status is %s", - acs_status(lsm_qp->query_lsm_status)); - lm_handle_acsls_error(lsm_qp->query_lsm_status, "acs_query_lsm", - "activate", tid, ret_msg); - free(acs_rsp); - return (LM_ERROR); - } - lsm_sp = &lsm_qp->lsm_status[0]; - if (lsm_sp->state != STATE_ONLINE) { - mms_trace(MMS_ERR, "lm_library_config: State of lsm is not " - "online, state - %s", acs_state(lsm_sp->state)); - lm_handle_acsls_state(lsm_sp->state, "acs_query_lsm", - "activate", tid, ret_msg); - free(acs_rsp); - if ((rc = lm_common_ready(LM_BROKE, tid, ret_msg)) != LM_OK) { - mms_trace(MMS_ERR, "lm_activate: Failed to issue " - "ready broken command to MM."); - } - lm_state = LM_BROKEN; - return (LM_ERROR); - } - freecells = lsm_sp->freecells; - free(acs_rsp); - - mms_trace(MMS_DEBUG, "lm_library_config: Free cells for acs %d - %d", - lm.lm_acs, freecells); - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, - "lm_library_config: lm_obtain_task_id failed " - "trying to generate config command for bay creation"); - return (LM_ERROR); - } - - - if (lm_library_config_non_comm(lmpl_tid, &full_str[0], tid, ret_msg) - == LM_ERROR) { - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - if ((rc = lm_gen_lmpl_cmd(full_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, - "lm_library_config: Internal processing error " - "encountered while processing lmpl config command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - handle_lmpl_cmd_error(rc, "activate", "config", tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_library_config: Got successful response for " - "full config command"); - - mms_trace(MMS_DEBUG, "TASK ID - %d", lmpl_tid); - lm_remove_lmpl_cmd(lmpl_tid, ele); - - cell_size = MAX_CONFIG_CARTS * SLOT_CFG_SIZE; - - if ((slot_spec = (char *)malloc(cell_size)) == NULL) { - lm_serr(MMS_CRIT, "lm_library_config: Unable to malloc space " - "for slotp spec definitions"); - return (LM_ERROR); - } - - s = (SEQ_NO)(LM_Q_VOL2_SEQ + pthread_self()); - count = 0; - if ((status = acs_query_volume(s, vol_id, count)) != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_library_config: acs_query_volume2() " - "failed, status - %s", acs_status(status)); - lm_handle_acs_cmd_error(status, "activate", tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(slot_spec); - return (LM_ERROR); - } - - do { - mms_trace(MMS_DEBUG, "lm_library_config: Configuring slot spec " - "loop"); - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, - "lm_library_config: lm_obtain_task_id " - "failed trying to generate config cmd for slot " - "creation"); - free(slot_spec); - return (LM_ERROR); - } - - (void) snprintf(slot_spec, cell_size, - "config task[\"%d\"] scope[partial] ", lmpl_tid); - - rsp_cnt = 0; - spec_stop = 0; - acs_rsp = NULL; - do { - if (acs_rsp != NULL) - free(acs_rsp); - if ((acs_rsp = lm_obtain_acs_response(s, "activate", - tid, ret_msg)) == NULL) { - /* Internal error encountered */ - free(slot_spec); - return (LM_ERROR); - } - if (acs_rsp->acs_status != STATUS_SUCCESS) { - mms_trace(MMS_CRIT, "lm_library_config: " - "acs_response() for query_volume2 failed, " - "status - %s", acs_status(status)); - lm_handle_acs_cmd_error(status, "activate", tid, - ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(acs_rsp); - free(slot_spec); - return (LM_ERROR); - } - - if (acs_rsp->acs_type == RT_ACKNOWLEDGE) { - mms_trace(MMS_DEBUG, - "lm_library_config: Received " - "acknowledge response for query_volume2()"); - continue; - } else if (acs_rsp->acs_type == RT_FINAL) { - mms_trace(MMS_DEBUG, - "lm_library_config: Recevied " - "final response for query_volume2()"); - } else if (acs_rsp->acs_type == RT_INTERMEDIATE) { - mms_trace(MMS_DEBUG, - "lm_library_config: Received " - "intermediate response for " - "query_volume2()"); - } else { - mms_trace(MMS_ERR, - "lm_library_config: Received " - "unknow response type for query_volume2() " - "- %d", acs_rsp->acs_type); - continue; - } - - vol_qp = (ACS_QUERY_VOL_RESPONSE *)acs_rsp->acs_rbuf; - if (vol_qp->query_vol_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, - "lm_library_config: response " - "from query_volume2() failed, status is %s", - acs_status(vol_qp->query_vol_status)); - lm_handle_acsls_error(vol_qp->query_vol_status, - "acs_query_vol", "activate", tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(acs_rsp); - free(slot_spec); - return (LM_ERROR); - } - mms_trace(MMS_DEBUG, - "lm_library_config: count of response " - "for query_volume2() - %d", vol_qp->count); - for (i = 0; i < (int)vol_qp->count; i++) { - vol_sp = &vol_qp->vol_status[i]; - if (vol_sp->location_type != LOCATION_CELL) { - mms_trace(MMS_DEBUG, - "lm_library_config: " - "volume %s found in drive", - &vol_sp->vol_id.external_label[0]); - continue; - } - - if (vol_sp->location.cell_id.panel_id.lsm_id.acs - != lm.lm_acs) { - mms_trace(MMS_DEBUG, - "lm_library_config: " - "Skip volume %s, wrong ACS", - &vol_sp->vol_id.external_label[0]); - continue; - } - (void) snprintf(cfg_str, sizeof (cfg_str), - CFG_SLOT, - vol_sp->vol_id.external_label, - vol_sp->location.cell_id.panel_id.panel, - vol_sp->location.cell_id.panel_id.panel, - vol_sp->vol_id.external_label, - lm.lm_type); - mms_trace(MMS_DEBUG, "lm_library_config: " - "Slot spec - %s", cfg_str); - (void) strcat(slot_spec, cfg_str); - rsp_cnt++; - } - /* See if we should stop processing */ - /* query vol responses */ - if ((rsp_cnt + ACS_RESPONSE) > MAX_CONFIG_CARTS) - spec_stop = 1; - } while (acs_rsp->acs_type != RT_FINAL && spec_stop != 1); - - if (acs_rsp->acs_type == RT_FINAL) - loop_stop = 1; - - free(acs_rsp); - - (void) strcat(slot_spec, ";"); - - mms_trace(MMS_DEBUG, "\nlm_library_config: SLOT_SPEC:\n%s\n", - slot_spec); - if ((rc = lm_gen_lmpl_cmd(slot_spec, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_library_config: Internal " - "processing error encountered while processing " - "lmpl config command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(slot_spec); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - handle_lmpl_cmd_error(rc, "activate", "config", tid, - ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(slot_spec); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_library_config: " - "Got successful response " - "for slot creation config command"); - - lm_remove_lmpl_cmd(lmpl_tid, ele); - - } while (loop_stop != 1); - - free(slot_spec); - - acs_drives = (acs_drive_t *)lm.lm_drive; - if (acs_drives->acs_max_drive > MAX_CONFIG_DRIVES) - cell_size = MAX_CONFIG_DRIVES * DRIVE_CFG_SIZE; - else - cell_size = acs_drives->acs_max_drive * DRIVE_CFG_SIZE; - - if ((drive_spec = (char *)malloc(cell_size)) == NULL) { - lm_serr(MMS_CRIT, "lm_library_config: Unable to malloc space " - "for drive spec definitions, errno - %d", - strerror(errno)); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - s = (SEQ_NO)(LM_Q_DRIVE_SEQ + pthread_self()); - count = 0; - if ((status = acs_query_drive(s, drive_id, count)) != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_library_config: acs_query_drive() " - "failed, status - %s", acs_status(status)); - lm_handle_acs_cmd_error(status, "activate", tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(drive_spec); - return (LM_ERROR); - } - - loop_stop = 0; - do { - - mms_trace(MMS_DEBUG, "lm_library_config: " - "Configuring drive spec loop"); - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, - "lm_library_config: lm_obtain_task_id " - "failed trying to generate config command for " - "drive creation"); - free(drive_spec); - return (LM_ERROR); - } - - (void) snprintf(drive_spec, cell_size, - "config task[\"%d\"] scope[partial] ", lmpl_tid); - - rsp_cnt = 0; - spec_stop = 0; - acs_rsp = NULL; - do { - if (acs_rsp != NULL) - free(acs_rsp); - if ((acs_rsp = lm_obtain_acs_response(s, "activate", - tid, ret_msg)) == NULL) { - /* Internal error encountered */ - free(drive_spec); - return (LM_ERROR); - } - if (acs_rsp->acs_status != STATUS_SUCCESS) { - mms_trace(MMS_CRIT, "lm_library_config: " - "acs_response() for query_drive failed, " - "status - %s", acs_status(status)); - lm_handle_acs_cmd_error(status, "activate", tid, - ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(acs_rsp); - free(drive_spec); - return (LM_ERROR); - } - - if (acs_rsp->acs_type == RT_ACKNOWLEDGE) { - mms_trace(MMS_DEBUG, - "lm_library_config: Received " - "acknowledge response for query_drive()"); - continue; - } else if (acs_rsp->acs_type == RT_FINAL) { - mms_trace(MMS_DEBUG, - "lm_library_config: Recevied " - "final response for query_drive()"); - } else if (acs_rsp->acs_type == RT_INTERMEDIATE) { - mms_trace(MMS_DEBUG, - "lm_library_config: Received " - "intermediate response for query_drive()"); - } else { - mms_trace(MMS_ERR, - "lm_library_config: Received " - "unknow response type for query_drive() " - "- %d", acs_rsp->acs_type); - continue; - } - drv_qp = (ACS_QUERY_DRV_RESPONSE *)acs_rsp->acs_rbuf; - if (drv_qp->query_drv_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, - "lm_library_config: response " - "from query_drive() failed, status is %s", - acs_status(drv_qp->query_drv_status)); - lm_handle_acsls_error(drv_qp->query_drv_status, - "acs_query_drive", "activate", tid, - ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(acs_rsp); - free(drive_spec); - return (LM_ERROR); - } - mms_trace(MMS_DEBUG, - "lm_library_config: count of response " - "for query_drive() - %d", drv_qp->count); - for (i = 0; i < (int)drv_qp->count; i++) { - occupied = 0; - accessible = 0; - drv_sp = &drv_qp->drv_status[i]; - if (drv_sp->drive_id.panel_id.lsm_id.acs - != lm.lm_acs) { - mms_trace(MMS_DEBUG, - "lm_library_config: " - "Skip drive, Wrong ACS -%d", - drv_sp->drive_id.panel_id.lsm_id. - acs); - continue; - } - if (drv_sp->status == STATUS_DRIVE_IN_USE) { - (void) snprintf(cfg_str, - sizeof (cfg_str), - CFG_SLOT, - drv_sp->vol_id.external_label, - drv_sp->drive_id.panel_id.panel, - drv_sp->drive_id.panel_id.panel, - drv_sp->vol_id.external_label, - lm.lm_type); - (void) strcat(drive_spec, cfg_str); - rsp_cnt++; - occupied = 1; - } - if (drv_sp->state == STATE_ONLINE) { - accessible = 1; - } - (void) snprintf(geometry, sizeof (geometry), - "%d,%d,%d,%d", - drv_sp->drive_id.panel_id.lsm_id.acs, - drv_sp->drive_id.panel_id.lsm_id.lsm, - drv_sp->drive_id.panel_id.panel, - drv_sp->drive_id.drive); - if (lm_obtain_serial_num(geometry, &serial, - cmd, tid, ret_msg) != LM_OK) { - mms_trace(MMS_ERR, "lm_library_config: " - "Trying to obtain serial number " - "for drive with ACSLS geometry %s " - "failed", geometry); - return (LM_ERROR); - } - if (strcmp(serial, "") == 0) { - mms_trace(MMS_ERR, "lm_library_config: " - "No serial number found for drive " - "with ACSLS geometry of %s", - geometry); - } - (void) snprintf(cfg_str, sizeof (cfg_str), - CFG_DRIVE, - serial, - drv_sp->drive_id.panel_id.lsm_id.acs, - drv_sp->drive_id.panel_id.lsm_id.lsm, - drv_sp->drive_id.panel_id.panel, - drv_sp->drive_id.drive, - drv_sp->drive_id.panel_id.panel, - occupied ? - drv_sp->vol_id.external_label : "none", - occupied ? "true" : "false", - accessible ? "true" : "false"); - mms_trace(MMS_DEBUG, "lm_library_config: " - "drive spec - %s", cfg_str); - (void) strcat(drive_spec, cfg_str); - rsp_cnt++; - } - if ((rsp_cnt + ACS_RESPONSE) > MAX_CONFIG_DRIVES) - spec_stop = 1; - } while (acs_rsp->acs_type != RT_FINAL && spec_stop != 1); - - if (acs_rsp->acs_type == RT_FINAL) - loop_stop = 1; - - free(acs_rsp); - - (void) strcat(drive_spec, ";"); - - mms_trace(MMS_DEBUG, "\nlm_library_config: DRIVE_SPEC:\n%s\n", - drive_spec); - if ((rc = lm_gen_lmpl_cmd(drive_spec, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_library_config: Internal " - "processing error encountered while processing " - "lmpl config command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(drive_spec); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - handle_lmpl_cmd_error(rc, "activate", "config", tid, - ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(drive_spec); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_library_config: " - "Got successful response " - "for drive creation config command"); - - lm_remove_lmpl_cmd(lmpl_tid, ele); - - } while (loop_stop != 1); - - free(drive_spec); - - return (LM_OK); -} diff --git a/usr/src/lib/mms/lm/libdisk/Makefile b/usr/src/lib/mms/lm/libdisk/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/lm/libdisk/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/lm/libdisk/Makefile.com b/usr/src/lib/mms/lm/libdisk/Makefile.com deleted file mode 100644 index 7fb862ba8b..0000000000 --- a/usr/src/lib/mms/lm/libdisk/Makefile.com +++ /dev/null @@ -1,58 +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. -# -# - -LIBRARY = libDISK.a -VERS = -OBJECTS = lm_disk.o - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -SRCS = $(OBJECTS:%.o=$(SRCDIR)/%.c) - -LDLIBS += -lc -LDLIBS += -L$(SRC)/lib/mms/mms/$(MACH) -lmms - -CFLAGS += $(CCVERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/lm/common -I../../../mms/common - -.KEEP_STATE: - -all: $(LIBS) - -lint: $(LINTLIB) lintcheck - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) diff --git a/usr/src/lib/mms/lm/libdisk/common/lm_disk.c b/usr/src/lib/mms/lm/libdisk/common/lm_disk.c deleted file mode 100644 index 6a8c8894a0..0000000000 --- a/usr/src/lib/mms/lm/libdisk/common/lm_disk.c +++ /dev/null @@ -1,1639 +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 "lm_disk.h" -#include <lm.h> - -static char *_SrcFile = __FILE__; - -/* - * lm_activate() - * - * Parameters: - * - cmd Parse tree of LMPM activate command being processed. - * - tid Task id of LMPM activate command being processed. - * - ret_msg Ptr to final response string. If an error message is - * to be sent to MM for the activate command because of - * a failure, the error response is created here. - * - * This function executes the necessary steps that are disk archiving specific - * for the LM to process the activate command. This routine is responsible - * for establishing that the LM can access each file system and cartridge - * defined within that file system. - * - * Return Values: - * - LM_OK If function completed successfully - * - LM_ERROR If function detected something that does not - * allow the LM to become active. In some cases - * depending on the error, ret_msg may be updated to - * reflect the error that was encountered as to why - * the LM cannot become active. - */ -int -/* LINTED argument unused in function */ -lm_activate(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - int rc; - - mms_trace(MMS_DEVP, "Entering Disk lm_activate"); - - if ((rc = lm_library_config("activate", tid, ret_msg)) != LM_OK) { - mms_trace(MMS_ERR, - "lm_activate: lm_library_config failed, rc %d", rc); - return (LM_ERROR); - } - - mms_trace(MMS_DEVP, "Disk lm_activate succeeded"); - - return (LM_OK); -} - -/* - * lm_mount() - * - * Parameters: - * - cmd Parse tree of LMPM mount command being processed. - * - tid Task id of LMPM mount command being processed. - * - ret_msg Ptr to final response string. If an error message is - * to be sent to MM for the mount command because of - * a failure, the error response is created here. - * - * This function executes the necessary steps that are disk archiving specific - * for the LM to process the mount command. This routine is responsible - * for performing the mounting operations necessary to reflect a cartridge - * mounted in a drive within a disk archiving library. - * - * Return Values: - * - LM_OK If function completed successfully - * - LM_ERROR If function detected something that does not - * allow the LM to mount a cartridge. In some cases - * depending on the error, ret_msg may be updated to - * reflect the error that was encountered as to why - * the LM cannot mount a cartridge. - */ -int -lm_mount(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - int rc; - int lmpl_tid; - - char *kw; - char msg_str[256]; - char text_str[256]; - char cfg_str[1024]; - - lmpl_rsp_ele_t *ele; - - mms_par_node_t *loc = NULL; - mms_par_node_t *drive; - mms_par_node_t *slot; - mms_par_node_t *value; - mms_par_node_t *slot_name; - mms_par_node_t *cartridge; - mms_par_node_t *side; - - mms_trace(MMS_DEVP, "Entering lm_mount"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7004_MSG, "cmd", "mount", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_INTERNAL), msg_str); - - MMS_PN_LOOKUP(drive, cmd, kw = "drive", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, drive, NULL, MMS_PN_STRING, NULL); - - mms_trace(MMS_DEBUG, "lm_mount: Drive for mount cmd - %s", - mms_pn_token(value)); - - MMS_PN_LOOKUP(slot, cmd, kw = "slot", MMS_PN_CLAUSE, NULL); - loc = NULL; - MMS_PN_LOOKUP(slot_name, slot, NULL, MMS_PN_STRING, &loc); - MMS_PN_LOOKUP(cartridge, slot, NULL, MMS_PN_STRING, &loc); - MMS_PN_LOOKUP(side, slot, NULL, MMS_PN_STRING, &loc); - - mms_trace(MMS_DEBUG, "lm_mount: Mount cartridge %s, side %s, from " - "slot %s", mms_pn_token(slot_name), mms_pn_token(cartridge), - mms_pn_token(side)); - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, "lm_mount: lm_obtain_task_id failed trying " - "to generate config command for mount"); - return (LM_ERROR); - } - - (void) snprintf(cfg_str, sizeof (cfg_str), CONFIG_MOUNT, lmpl_tid, - mms_pn_token(cartridge), mms_pn_token(value), - mms_pn_token(cartridge)); - - mms_trace(MMS_DEBUG, "lm_mount: config for mount:\n%s", cfg_str); - - if ((rc = lm_gen_lmpl_cmd(cfg_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_mount: Internal processing error " - "encountered while processing lmpl config command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, "lm_mount: config command did not receive " - "a successful response"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_mount: Got successful response for mount " - "config command"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7102_MSG, - "cart", mms_pn_token(cartridge), "drive", mms_pn_token(value), - NULL); - (void) snprintf(text_str, sizeof (text_str), LM_TEXT_MNT, - mms_pn_token(value), mms_pn_token(slot_name), - mms_pn_token(cartridge), mms_pn_token(side)); - (void) snprintf(ret_msg, RMBUFSIZE, LM_SUC_FINAL, tid, text_str, - msg_str); - - lm_remove_lmpl_cmd(lmpl_tid, ele); - - mms_trace(MMS_DEVP, "Exiting lm_mount"); - return (LM_OK); - -not_found: - mms_trace(MMS_ERR, "LMPM command %s encounterd an invalid or missing " - "%s clause:\n%s", "mount", kw, mms_pn_build_cmd_text(cmd)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7009_MSG, "cmd", "mount", "part", kw, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INVALID), - mms_sym_code_to_str(MMS_LM_E_CMDARGS), msg_str); - - mms_trace(MMS_DEVP, "Exiting lm_mount"); - return (LM_ERROR); -} - -/* - * lm_unmount() - * - * Parameters: - * - cmd Parse tree of LMPM unmount command being processed. - * - tid Task id of LMPM unmount command being processed. - * - ret_msg Ptr to final response string. If an error message is - * to be sent to MM for the unmount command because of - * a failure, the error response is created here. - * - * This function executes the necessary steps that are disk archiving specific - * for the LM to process the unmount command. This routine is responsible - * for performing the unmount operations necessary to reflect a cartridge - * unmounted from a drive within a disk archiving library. - * - * Return Values: - * - LM_OK If function completed successfully - * - LM_ERROR If function detected something that does not - * allow the LM to unmount a cartridge. In some cases - * depending on the error, ret_msg may be updated to - * reflect the error that was encountered as to why - * the LM cannot unmount a cartridge. - */ -int -lm_unmount(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - int rc; - int lmpl_tid; - - char *kw; - char msg_str[256]; - char text_str[256]; - char cfg_str[1024]; - - lmpl_rsp_ele_t *ele; - - mms_par_node_t *loc = NULL; - mms_par_node_t *drive; - mms_par_node_t *slot; - mms_par_node_t *value; - mms_par_node_t *slot_name; - mms_par_node_t *cartridge; - mms_par_node_t *side; - - mms_trace(MMS_DEVP, "Entering lm_unmount"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7004_MSG, "cmd", "unmount", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_INTERNAL), msg_str); - - MMS_PN_LOOKUP(drive, cmd, kw = "drive", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(value, drive, NULL, MMS_PN_STRING, NULL); - - mms_trace(MMS_DEBUG, "lm_unmount: Drive for unmount cmd - %s", - mms_pn_token(value)); - - MMS_PN_LOOKUP(slot, cmd, kw = "fromslot", MMS_PN_CLAUSE, NULL); - loc = NULL; - MMS_PN_LOOKUP(slot_name, slot, NULL, MMS_PN_STRING, &loc); - MMS_PN_LOOKUP(cartridge, slot, NULL, MMS_PN_STRING, &loc); - MMS_PN_LOOKUP(side, slot, NULL, MMS_PN_STRING, &loc); - - mms_trace(MMS_DEBUG, "lm_mount: fromslot cartridge %s, side %s, slot " - "%s", mms_pn_token(slot_name), mms_pn_token(side), - mms_pn_token(cartridge)); - - MMS_PN_LOOKUP(slot, cmd, kw = "toslot", MMS_PN_CLAUSE, NULL); - loc = NULL; - MMS_PN_LOOKUP(slot_name, slot, NULL, MMS_PN_STRING, &loc); - MMS_PN_LOOKUP(cartridge, slot, NULL, MMS_PN_STRING, &loc); - MMS_PN_LOOKUP(side, slot, NULL, MMS_PN_STRING, &loc); - - mms_trace(MMS_DEBUG, "lm_mount: toslot cartridge %s, side %s, slot " - "%s", mms_pn_token(slot_name), mms_pn_token(side), - mms_pn_token(cartridge)); - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, - "lm_unmount: lm_obtain_task_id failed trying " - "to generate config command for unmount"); - return (LM_ERROR); - } - - (void) snprintf(cfg_str, sizeof (cfg_str), CONFIG_UNMOUNT, lmpl_tid, - mms_pn_token(cartridge), mms_pn_token(cartridge), - mms_pn_token(value)); - - mms_trace(MMS_DEBUG, "lm_unmount: config for unmount:\n%s", cfg_str); - - if ((rc = lm_gen_lmpl_cmd(cfg_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_unmount: Internal processing error " - "encountered while processing lmpl config command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, "lm_unmount: config command did not receive " - "a successful response"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_unmount: Got successful response for unmount " - "config command"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7103_MSG, - "cart", mms_pn_token(cartridge), "drive", mms_pn_token(value), - NULL); - (void) snprintf(text_str, sizeof (text_str), LM_TEXT_MNT, - mms_pn_token(value), mms_pn_token(slot_name), - mms_pn_token(cartridge), mms_pn_token(side)); - (void) snprintf(ret_msg, RMBUFSIZE, LM_SUC_FINAL, tid, text_str, - msg_str); - - lm_remove_lmpl_cmd(lmpl_tid, ele); - - mms_trace(MMS_DEVP, "Exiting lm_unmount"); - return (LM_OK); - -not_found: - mms_trace(MMS_ERR, "LMPM command %s encounterd an invalid or missing " - "%s clause:\n%s", "unmount", kw, mms_pn_build_cmd_text(cmd)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7009_MSG, "cmd", "unmount", "part", kw, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INVALID), - mms_sym_code_to_str(MMS_LM_E_CMDARGS), msg_str); - - mms_trace(MMS_DEVP, "Exiting lm_unmount"); - return (LM_ERROR); -} - -/* - * lm_move() - * - * Parameters: - * - cmd Parse tree of LMPM move command being processed. - * - tid Task id of LMPM move command being processed. - * - ret_msg Ptr to final response string. If an error message is - * to be sent to MM for the move command because of - * a failure, the error response is created here. - * - * This function executes the necessary steps that are disk archiving specific - * for the LM to process the move command. This routine does not currently - * perform any real move type operations within the disk archiving - * environment. - * - * Return Values: - * - LM_OK If function completed successfully - * - LM_ERROR If function detected something that does not - * allow the LM to move a cartridge . In some cases - * depending on the error, ret_msg may be updated to - * reflect the error that was encountered as to why - * the LM cannot move a cartridge - */ -int -/* LINTED argument unused in function */ -lm_move(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - char msg_str[256]; - - mms_trace(MMS_DEVP, "Entering lm_move"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7105_MSG, "cmd", "move", "type", lm.lm_type, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_SUC_FINAL, tid, msg_str, ""); - - mms_trace(MMS_DEVP, "Exiting lm_move"); - - return (LM_OK); -} -/* - * lm_inject() - * - * Parameters: - * - cmd Parse tree of LMPM ctivate command being processed. - * - tid Task id of LMPM ctivate command being processed. - * - ret_msg Ptr to final response string. If an error message is - * to be sent to MM for the ctivate command because of - * a failure, the error response is created here. - * - * This function executes the necessary steps that are disk archiving specific - * for the LM to process the ctivate command. This routine is responsible - * for performing the inject operations necessary to reflect a cartridge - * injected into a disk archiving library. - * - * Return Values: - * - LM_OK If function completed successfully - * - LM_ERROR If function detected something that does not - * allow the LM to inject a cartridge . In some cases - * depending on the error, ret_msg may be updated to - * reflect the error that was encountered as to why - * the LM cannot inject a cartridge. - */ -int -/* LINTED argument unused in function */ -lm_inject(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - char msg_str[256]; - - mms_trace(MMS_DEVP, "Entering lm_inject"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7105_MSG, "cmd", "inject", "type", lm.lm_type, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_SUC_FINAL, tid, msg_str, ""); - - mms_trace(MMS_DEVP, "Exiting lm_inject"); - - return (LM_OK); -} - -/* - * lm_scan() - * - * Parameters: - * - cmd Parse tree of LMPM scan command being processed. - * - tid Task id of LMPM scan command being processed. - * - ret_msg Ptr to final response string. If an error message is - * to be sent to MM for the scan command because of - * a failure, the error response is created here. - * - * This function executes the necessary steps that are disk archiving specific - * for the LM to process the scan command. This routine is responsible - * for performaing a scan operation on a cartridge, drive, or library within - * a disk archiving library. - * - * Return Values: - * - LM_OK If function completed successfully - * - LM_ERROR If function detected something that does not - * allow the LM to scan. In some cases - * depending on the error, ret_msg may be updated to - * reflect the error that was encountered as to why - * the LM cannot scan. - */ -int -lm_scan(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - int i; - int rc; - int lmpl_tid; - char *kw; - char *spec_str = NULL; - char *dev_list = NULL; - char *config_buf = NULL; - char msg_str[512]; - char cfg_str[512]; - char cmd_str[1024]; - - mms_par_node_t *loc = NULL; - mms_par_node_t *loc1 = NULL; - mms_par_node_t *resp_loc = NULL; - mms_par_node_t *clause; - mms_par_node_t *resp_clause; - mms_par_node_t *pcl; - mms_par_node_t *occ; - mms_par_node_t *fslot; - mms_par_node_t *tslot; - mms_par_node_t *dname; - mms_par_node_t *rsp; - - - lmpl_rsp_ele_t *show_ele; - lmpl_rsp_ele_t *config_ele; - lmpl_rsp_node_t *node; - - mms_trace(MMS_DEVP, "Entering lm_scan"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7004_MSG, "cmd", "scan", NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_INTERNAL), msg_str); - - loc = NULL; - /* See if scan is for cartridge(s) */ - if ((clause = mms_pn_lookup(cmd, kw = "slot", MMS_PN_CLAUSE, &loc)) - != NULL) { - - if (dev_list != NULL) { - free(dev_list); - } - if (spec_str != NULL) { - free(spec_str); - } - dev_list = NULL; - spec_str = NULL; - spec_str = mms_strapp(spec_str, " "); - dev_list = mms_strapp(dev_list, " "); - - /* Generate list of cartridges to scan for */ - for (i = 0; clause != NULL; clause = mms_pn_lookup(cmd, - "slot", MMS_PN_CLAUSE, &loc)) { - /* Obtain slot-name */ - if ((pcl = mms_pn_lookup(clause, NULL, - MMS_PN_STRING, NULL)) == NULL) { - mms_trace(MMS_ERR, - "lm_scan: No pcl string found " - "in text clause of cartridge scan"); - free(spec_str); - free(dev_list); - return (LM_ERROR); - } - if (i == MAX_CONFIG_CARTS) { - mms_trace(MMS_OPER, "lm_scan: Number of slots " - "to scan exceeded the max allowed of " - "%d, skipping cartridge %s", - MAX_CONFIG_CARTS, mms_pn_token(pcl)); - } else { - if (i != 0) - (void) strcat(dev_list, " "); - - mms_trace(MMS_DEBUG, - "lm_scan: scan for cartridge " - "%s", mms_pn_token(pcl)); - - if (lm_obtain_task_id(&lmpl_tid, &show_ele) - != LM_OK) { - mms_trace(MMS_CRIT, - "lm_scan: Unable to " - "get a task id for show slot " - "occupied command"); - free(spec_str); - free(dev_list); - return (LM_ERROR); - } - (void) snprintf(cmd_str, sizeof (cmd_str), - LM_SHOW_OCC, lmpl_tid, lm.lm_name, - mms_pn_token(pcl)); - - if ((rc = lm_gen_lmpl_cmd(cmd_str, - show_ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_scan: Internal " - "processing error encountered " - "while processing LMPL show " - "slot occupied command"); - lm_remove_lmpl_cmd(lmpl_tid, show_ele); - free(spec_str); - free(dev_list); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, "lm_scan: show cmd " - "did not receive a successful " - "response, unable to get pcl " - "%s's occupied state", - mms_pn_token(pcl)); - lm_remove_lmpl_cmd(lmpl_tid, show_ele); - free(spec_str); - free(dev_list); - return (LM_ERROR); - } - - node = mms_list_head(&show_ele->lmpl_rsp_list); - rsp = node->lmpl_rsp_tree; - resp_loc = NULL; - resp_clause = NULL; - - if ((resp_clause = mms_pn_lookup(rsp, "text", - MMS_PN_CLAUSE, &resp_loc)) == NULL) { - mms_trace(MMS_ERR, "lm_scan: No text " - "clause found in show occupied for " - "pcl %s", mms_pn_token(pcl)); - lm_remove_lmpl_cmd(lmpl_tid, show_ele); - free(spec_str); - free(dev_list); - return (LM_ERROR); - } - - if ((occ = mms_pn_lookup(resp_clause, NULL, - MMS_PN_STRING, &resp_loc)) == NULL) { - mms_trace(MMS_ERR, - "lm_scan: No occupied " - "string found in show occupied for " - "pcl %s", mms_pn_token(pcl)); - lm_remove_lmpl_cmd(lmpl_tid, show_ele); - free(spec_str); - free(dev_list); - return (LM_ERROR); - } - mms_trace(MMS_DEBUG, - "lm_scan: pcl %s occupied is " - "%s", mms_pn_token(pcl), - mms_pn_token(occ)); - if (strcmp("true", mms_pn_token(occ)) == 0) - (void) snprintf(cfg_str, - sizeof (cfg_str), CFG_SLOT, - mms_pn_token(pcl), - mms_pn_token(pcl), lm.lm_type, - "false"); - else - (void) snprintf(cfg_str, - sizeof (cfg_str), CFG_SLOT, - mms_pn_token(pcl), - mms_pn_token(pcl), lm.lm_type, - "true"); - mms_trace(MMS_DEBUG, "lm_scan: Slot spec - %s", - cfg_str); - spec_str = mms_strapp(spec_str, cfg_str); - dev_list = mms_strapp(dev_list, - mms_pn_token(pcl)); - lm_remove_lmpl_cmd(lmpl_tid, show_ele); - } - } - spec_str = mms_strapp(spec_str, ";"); - - if (lm_obtain_task_id(&lmpl_tid, &config_ele) != LM_OK) { - mms_trace(MMS_CRIT, "lm_scan: Unable to get a task " - "id for config slot command"); - free(spec_str); - free(dev_list); - return (LM_ERROR); - } - - if (config_buf != NULL) - free(config_buf); - config_buf = NULL; - config_buf = mms_strapp(config_buf, - "config task[\"%d\"] scope[partial] %s", - lmpl_tid, spec_str); - - if ((rc = lm_gen_lmpl_cmd(config_buf, - config_ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_scan: Internal processing " - "error encountered while processing lmpl " - "config slot command"); - lm_remove_lmpl_cmd(lmpl_tid, config_ele); - free(config_buf); - free(spec_str); - free(dev_list); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, "lm_scan: Did not receive a " - "success response for lmpl config slot " - "command"); - handle_lmpl_cmd_error(rc, "scan", "config", tid, - ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, config_ele); - free(config_buf); - free(spec_str); - free(dev_list); - return (LM_ERROR); - } - mms_trace(MMS_DEBUG, "lm_scan: Got successful response " - "for scan config slot command"); - - lm_remove_lmpl_cmd(lmpl_tid, config_ele); - free(spec_str); - free(config_buf); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7118_MSG, - "carts", dev_list, NULL); - free(dev_list); - } else if ((clause = mms_pn_lookup(cmd, kw = "fromslot", - MMS_PN_CLAUSE, NULL)) != NULL) { - loc = NULL; - MMS_PN_LOOKUP(fslot, clause, NULL, MMS_PN_STRING, &loc); - - MMS_PN_LOOKUP(clause, cmd, kw = "toslot", MMS_PN_CLAUSE, - NULL); - loc = NULL; - MMS_PN_LOOKUP(tslot, clause, NULL, MMS_PN_STRING, &loc); - mms_trace(MMS_DEBUG, - "lm_scan: scan for cartridges from %s to %s", - mms_pn_token(fslot), mms_pn_token(tslot)); - mms_trace(MMS_OPER, "lm_scan: scan for a range of slots is not " - "supported on a DiskArchiving library, sending error " - "response for scan command"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7116_MSG, - "type", lm.lm_type, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INTERNAL), - mms_sym_code_to_str(MMS_LM_E_INTERNAL), msg_str); - return (LM_ERROR); - - } else if ((clause = mms_pn_lookup(cmd, kw = "drive", - MMS_PN_CLAUSE, &loc1)) != NULL) { - - if (dev_list != NULL) { - free(dev_list); - } - if (spec_str != NULL) { - free(spec_str); - } - dev_list = NULL; - spec_str = NULL; - spec_str = mms_strapp(spec_str, " "); - dev_list = mms_strapp(dev_list, " "); - - /* Setup to send partial config for drives */ - for (i = 0; clause != NULL; clause = mms_pn_lookup(cmd, - "drive", MMS_PN_CLAUSE, &loc1)) { - - if ((dname = mms_pn_lookup(clause, NULL, - MMS_PN_STRING, NULL)) == NULL) { - mms_trace(MMS_ERR, - "lm_scan: No drive name string " - "found in text clause of drive scan"); - free(spec_str); - free(dev_list); - return (LM_ERROR); - } - if (i == MAX_CONFIG_DRIVES) { - mms_trace(MMS_OPER, "lm_scan: Number of drives " - "to scan exceeded the max allowed of " - "%d, skipping drive %s", - MAX_CONFIG_DRIVES, mms_pn_token(dname)); - } else { - if (i != 0) - dev_list = mms_strapp(dev_list, " "); - - mms_trace(MMS_DEBUG, "lm_scan: scan for drive " - "%s", mms_pn_token(dname)); - - if (lm_obtain_task_id(&lmpl_tid, - &show_ele) != LM_OK) { - mms_trace(MMS_CRIT, - "lm_scan: Unable to get a task id " - "for config drive command"); - return (LM_ERROR); - } - - (void) snprintf(cmd_str, sizeof (cmd_str), - LM_SHOW_DRIVE, lmpl_tid, lm.lm_name, - mms_pn_token(dname)); - if ((rc = lm_gen_lmpl_cmd(cmd_str, - show_ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_scan: Internal " - "processing error encountered " - "while processing LMPL show cmd"); - lm_remove_lmpl_cmd(lmpl_tid, show_ele); - lm_remove_lmpl_cmd(lmpl_tid, - config_ele); - free(spec_str); - free(dev_list); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, "lm_scan: show cmd " - "did not receive a successful " - "response, unable to get drive " - "%s's drive name", - mms_pn_token(dname)); - lm_remove_lmpl_cmd(lmpl_tid, show_ele); - lm_remove_lmpl_cmd(lmpl_tid, - config_ele); - free(spec_str); - free(dev_list); - return (LM_ERROR); - } - - node = mms_list_head(&show_ele->lmpl_rsp_list); - rsp = node->lmpl_rsp_tree; - resp_loc = NULL; - resp_clause = NULL; - - if ((resp_clause = mms_pn_lookup(rsp, "text", - MMS_PN_CLAUSE, &resp_loc)) == NULL) { - mms_trace(MMS_ERR, "lm_scan: No text " - "clause found in show pcl for " - "drive %s", mms_pn_token(dname)); - lm_remove_lmpl_cmd(lmpl_tid, show_ele); - lm_remove_lmpl_cmd(lmpl_tid, - config_ele); - free(spec_str); - free(dev_list); - return (LM_ERROR); - } - if ((pcl = mms_pn_lookup(resp_clause, NULL, - MMS_PN_STRING, &resp_loc)) == NULL) { - mms_trace(MMS_ERR, "lm_scan: No pcl " - "string found in show pcl for " - "drive %s", mms_pn_token(dname)); - lm_remove_lmpl_cmd(lmpl_tid, show_ele); - lm_remove_lmpl_cmd(lmpl_tid, - config_ele); - free(spec_str); - free(dev_list); - return (LM_ERROR); - } - mms_trace(MMS_DEBUG, - "lm_scan: drive %s pcl is %s", - mms_pn_token(dname), mms_pn_token(pcl)); - if (strlen(mms_pn_token(pcl)) == 0) { - (void) snprintf(cfg_str, - sizeof (cfg_str), CFG_DRIVE, - mms_pn_token(dname), "none", - "false", "true"); - } else { - (void) snprintf(cfg_str, - sizeof (cfg_str), CFG_DRIVE, - mms_pn_token(dname), - mms_pn_token(pcl), "true", - "true"); - } - mms_trace(MMS_DEVP, "lm_scan: Drive spec: %s", - cfg_str); - spec_str = mms_strapp(spec_str, cfg_str); - dev_list = mms_strapp(dev_list, - mms_pn_token(dname)); - lm_remove_lmpl_cmd(lmpl_tid, show_ele); - } - } - spec_str = mms_strapp(spec_str, ";"); - - if (lm_obtain_task_id(&lmpl_tid, &config_ele) != LM_OK) { - mms_trace(MMS_CRIT, "lm_scan: Unable to get a task id " - "for config drive command"); - return (LM_ERROR); - } - - if (config_buf != NULL) - free(config_buf); - config_buf = NULL; - config_buf = mms_strapp(config_buf, - "config task[\"%d\"] scope[partial] %s", - lmpl_tid, spec_str); - - if ((rc = lm_gen_lmpl_cmd(config_buf, config_ele, 0)) - == LM_ERROR) { - mms_trace(MMS_ERR, "lm_scan: Internal processing " - "error encountered while processing lmpl " - "config drive command"); - lm_remove_lmpl_cmd(lmpl_tid, config_ele); - free(config_buf); - free(spec_str); - free(dev_list); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_ERR, "lm_scan: Did not receive a " - "success response for lmpl config drive " - "command"); - handle_lmpl_cmd_error(rc, "scan", "config", tid, - ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, config_ele); - free(spec_str); - free(config_buf); - free(dev_list); - return (LM_ERROR); - } - mms_trace(MMS_DEBUG, "lm_scan: Got successful response " - "for scan config drive command"); - free(spec_str); - free(config_buf); - - lm_remove_lmpl_cmd(lmpl_tid, config_ele); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7125_MSG, - "list", dev_list, NULL); - free(dev_list); - - } else { - mms_trace(MMS_DEBUG, "lm_scan: rescan entire library"); - - if ((rc = lm_common_ready(LM_NOT, tid, ret_msg)) != LM_OK) { - mms_trace(MMS_ERR, "lm_scan: Failure of ready command " - "to MM. Unable to set state to not ready"); - } - lm_state = LM_NOT_READY; - - mms_trace(MMS_OPER, "lm_scan: library state set to NOT_READY"); - - if ((rc = lm_library_config("scan", tid, ret_msg)) != LM_OK) { - mms_trace(MMS_ERR, "lm_scan: lm_library_config failed"); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, - "lm_scan: rescan of entire library completed"); - - if ((rc = lm_common_ready(LM_READY, tid, ret_msg)) != LM_OK) { - mms_trace(MMS_ERR, "lm_scan: Failure of ready command " - "to MM. Unable to set state to ready"); - return (LM_ERROR); - } - lm_state = LM_ACTIVE; - - mms_trace(MMS_OPER, "lm_scan: library sate set to READY"); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), LM_7124_MSG, - NULL); - } - - (void) snprintf(ret_msg, RMBUFSIZE, LM_SUC_FINAL, tid, msg_str, ""); - - mms_trace(MMS_DEVP, "Exiting lm_scan"); - return (LM_OK); - -not_found: - mms_trace(MMS_ERR, "lm_scan: Encountered an invalid or missing " - "%s clause:\n%s", kw, mms_pn_build_cmd_text(cmd)); - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7009_MSG, "cmd", "scan", "part", kw, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_ERR_FINAL, tid, - mms_sym_code_to_str(MMS_INVALID), - mms_sym_code_to_str(MMS_LM_E_CMDARGS), msg_str); - return (LM_ERROR); -} - -/* - * lm_reset() - * - * Parameters: - * - cmd Parse tree of LMPM ctivate command being processed. - * - tid Task id of LMPM ctivate command being processed. - * - ret_msg Ptr to final response string. If an error message is - * to be sent to MM for the ctivate command because of - * a failure, the error response is created here. - * - * This function executes the necessary steps that are disk archiving specific - * for the LM to process the ctivate command. This routine is responsible - * for performing either a partial or full reset on a disk archving library. - * - * Return Values: - * - LM_OK If function completed successfully - * - LM_ERROR If function detected something that does not - * allow the LM to reset. In some cases - * depending on the error, ret_msg may be updated to - * reflect the error that was encountered as to why - * the LM cannot reset the library. - */ -int -/* LINTED argument unused in function */ -lm_reset(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - mms_trace(MMS_DEVP, "Entering DISK reset process"); - - if (mms_pn_lookup(cmd, "partial", MMS_PN_KEYWORD, NULL) == NULL) { - mms_trace(MMS_DEBUG, "lm_reset: Nothing defined to do for a " - "full reset of an DISK library"); - } - - mms_trace(MMS_DEBUG, - "lm_reset: Nothing defined to do for a partial reset " - "of a DISK library"); - - return (LM_OK); -} - -/* - * lm_eject() - * - * Parameters: - * - cmd Parse tree of LMPM eject command being processed. - * - tid Task id of LMPM eject command being processed. - * - ret_msg Ptr to final response string. If an error message is - * to be sent to MM for the eject command because of - * a failure, the error response is created here. - * - * This function executes the necessary steps that are disk archiving specific - * for the LM to process the eject command. This routine is responsible - * for performing the eject operations necessary to reflect a cartridge - * being ejected from a disk archiving library. - * - * Return Values: - * - LM_OK If function completed successfully - * - LM_ERROR If function detected something that does not - * allow the LM to eject a cartridge. In some cases - * depending on the error, ret_msg may be updated to - * reflect the error that was encountered as to why - * the LM cannot eject a cartridge. - */ -int -/* LINTED argument unused in function */ -lm_eject(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - char msg_str[256]; - - mms_trace(MMS_DEVP, "Entering lm_eject"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7105_MSG, "cmd", "eject", "type", lm.lm_type, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_SUC_FINAL, tid, msg_str, ""); - - mms_trace(MMS_DEVP, "Exiting lm_eject"); - - return (LM_OK); -} - -/* - * lm_barrier() - * - * Parameters: - * - cmd Parse tree of LMPM barrier command being processed. - * - tid Task id of LMPM barrier command being processed. - * - ret_msg Ptr to final response string. If an error message is - * to be sent to MM for the barrier command because of - * a failure, the error response is created here. - * - * This function executes the necessary steps that are disk archiving specific - * for the LM to process the barrier command. This routine does not currently - * perform any real barrier type operations within the disk archiving - * environment. - * - * Return Values: - * - LM_OK If function completed successfully - * - LM_ERROR If function detected something that does not - * allow the LM to set a barrier. In some cases - * depending on the error, ret_msg may be updated to - * reflect the error that was encountered as to why - * the LM cannot set a barrier. - */ -int -/* LINTED argument unused in function */ -lm_barrier(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - char msg_str[256]; - - mms_trace(MMS_DEVP, "Entering lm_barrier"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7105_MSG, "cmd", "barrier", "type", lm.lm_type, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_SUC_FINAL, tid, msg_str, ""); - - mms_trace(MMS_DEVP, "Exiting lm_barrier"); - - return (LM_OK); -} - -/* - * lm_private() - * - * Parameters: - * - cmd Parse tree of LMPM private command being processed. - * - tid Task id of LMPM private command being processed. - * - ret_msg Ptr to final response string. If an error message is - * to be sent to MM for the private command because of - * a failure, the error response is created here. - * - * This function executes the necessary steps that are disk archiving specific - * for the LM to process the private command. This routine is responsible - * for handling the get, set, unset of any specific disk library - * variables. - * - * Return Values: - * - LM_OK If function completed successfully - * - LM_ERROR If function detected something that does not - * allow the LM to handle a private command. In some - * cases depending on the error, ret_msg may be updated - * to reflect the error that was encountered as to why - * the LM cannot handle a private command. - */ - -int -/* LINTED argument unused in function */ -lm_private(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - char msg_str[256]; - - mms_trace(MMS_DEVP, "Entering lm_private"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7105_MSG, "cmd", "private", "type", lm.lm_type, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_SUC_FINAL, tid, msg_str, ""); - - mms_trace(MMS_DEVP, "Exiting lm_private"); - return (LM_OK); -} - -/* - * lm_cancel() - * - * Parameters: - * - cmd Parse tree of LMPM activate command being processed. - * - tid Task id of LMPM activate command being processed. - * - ret_msg Ptr to final response string. If an error message is - * to be sent to MM for the activate command because of - * a failure, the error response is created here. - * - * This function executes the necessary steps that are disk archiving specific - * for the LM to process the cancel command. This routine does not do - * anything. The cancel of a LMPM command is only available in the - * common library code. The commad can only be cancelled if processing of - * it has not yet started. - * - * Return Values: - * - LM_OK Always - */ -int -/* LINTED argument unused in function */ -lm_cancel(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - char msg_str[512]; - - mms_trace(MMS_DEVP, "Entering DISK lm_cancel"); - - (void) mms_buf_msgcl(msg_str, sizeof (msg_str), - LM_7105_MSG, "cmd", "barrier", "type", lm.lm_type, NULL); - (void) snprintf(ret_msg, RMBUFSIZE, LM_SUC_FINAL, tid, msg_str, ""); - - mms_trace(MMS_DEVP, "Exiting DISK lm_cancel"); - return (LM_OK); -} - -/* - * lm_exit() - * - * Parameters: - * - cmd Parse tree of LMPM exit command being processed. - * - tid Task id of LMPM exit command being processed. - * - ret_msg Ptr to final response string. If an error message is - * to be sent to MM for the exit command because of - * a failure, the error response is created here. - * - * This function executes the necessary steps that are disk archiving specific - * for the LM to process the exit command. This routine does nothing. The - * LM exit is handled in the common exit library code only. - * - * Return Values: - * - LM_OK Always - */ -int -/* LINTED argument unused in function */ -lm_exit(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - mms_trace(MMS_DEVP, "Entering DISK lm_exit"); - - mms_trace(MMS_DEVP, "Exiting DISK lm_exit"); - return (LM_OK); -} -/* - * lm_event() - * - * Parameters: - * - cmd Parse tree of LMPM event command being processed. - * - tid Task id of LMPM event command being processed. - * - ret_msg Ptr to final response string. If an error message is - * to be sent to MM for the event command because of - * a failure, the error response is created here. - * - * This function executes the necessary steps that are disk archiving specific - * for the LM to process the event command. There are currently no events - * that a disk archiving library will register for. This routine does - * nothing. - * - * Return Values: - * - LM_OK Always - */ -int -/* LINTED argument unused in function */ -lm_event(mms_par_node_t *cmd, char *tid, char *ret_msg) -{ - mms_trace(MMS_DEVP, "Entering DISK lm_event"); - mms_trace(MMS_DEVP, "Exiting DISK lm_event"); - return (LM_OK); -} - -/* - * lm_library_config()() - * - * Parameters: - * - cmd The command that needs a full config (activate or - * full library scan) - * - tid Task id of LMPM activate command being processed. - * - ret_msg Ptr to final response string. If an error message is - * to be sent to MM for the activate command because of - * a failure, the error response is created here. - * - * This function executes the necessary steps that are required to do a - * full config on a disk specific library. It creates the bay-spec, - * slotgrp-spec, slot-spec, and drive-spec as defined in the LMPL - * config command. - * - * Return Values: - * - LM_OK If function completed successfully - * - LM_ERROR If function detected something that does not - * allow the LM to complete the full config command. - * In some cases depending on the error, ret_msg may - * be updated to reflect the error that was encountered. - */ -int -lm_library_config(char *cmd, char *tid, char *ret_msg) -{ - int rc; - int lmpl_tid; - int cfg_tid; - int num_carts; - int num_drives; - int cell_size; - int rsp_cnt; - - char *kw; - char cmd_str[1024]; - char cfg_str[512]; - char *slot_spec; - char *drive_spec; - char *fmt; - - mms_par_node_t *loc = NULL; - mms_par_node_t *loc1 = NULL; - mms_par_node_t *rsp; - mms_par_node_t *clause; - mms_par_node_t *num; - mms_par_node_t *dname; - mms_par_node_t *pcl; - mms_par_node_t *occ; - - lmpl_rsp_ele_t *ele; - lmpl_rsp_ele_t *cfg_ele; - lmpl_rsp_node_t *node; - - mms_trace(MMS_DEVP, "Entering lm_library_config"); - - /* Configure bays and slot groups */ - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, "lm_library_config: Unable to get a task " - "id for full config command to set bays and groups"); - return (LM_ERROR); - } - - /* There are no real bays, caps, free slots for a disk */ - /* archive library, create a generic set to conform to */ - /* IEEE spec */ - (void) snprintf(cmd_str, sizeof (cmd_str), DISK_CONFIG, lmpl_tid); - mms_trace(MMS_DEVP, "lm_library_config: bay and slot group config:\n%s", - cmd_str); - - if ((rc = lm_gen_lmpl_cmd(cmd_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_library_config: Internal " - "processing error encountered while processing " - "full config command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_CRIT, - "lm_library_config: Error encountered while " - "sending full config command"); - handle_lmpl_cmd_error(rc, cmd, "config", tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_library_config: Got successful response for " - "full creation config command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - - /* Obtain the number of cartridges in library */ - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, - "lm_library_config: Unable to get a task id " - "for show command to obtain number of cartridges in " - "disk library"); - return (LM_ERROR); - } - - (void) snprintf(cmd_str, sizeof (cmd_str), LM_SHOW_CART_NUM, lmpl_tid, - lm.lm_name); - mms_trace(MMS_DEVP, "lm_library_config: Obtain number of cartridges in " - "libary:\n%s", cmd_str); - - if ((rc = lm_gen_lmpl_cmd(cmd_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_library_config: Internal " - "processing error encountered while processing " - "show command to get number of cartridges in library"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_CRIT, - "lm_library_config: Error encountered while " - "sending show command to get number of cartridges in " - "disk library"); - handle_lmpl_cmd_error(rc, cmd, "show", tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - node = mms_list_head(&ele->lmpl_rsp_list); - rsp = node->lmpl_rsp_tree; - - MMS_PN_LOOKUP(clause, rsp, kw = "text", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(num, clause, NULL, MMS_PN_STRING, NULL); - num_carts = atoi(mms_pn_token(num)); - - mms_trace(MMS_DEBUG, "lm_library_config: %d cartridges in disk library " - "%s", num_carts, lm.lm_name); - - lm_remove_lmpl_cmd(lmpl_tid, ele); - - if (num_carts == 0) - goto skip_carts; - - if (num_carts > MAX_CONFIG_CARTS) - cell_size = MAX_CONFIG_CARTS * SLOT_CFG_SIZE + SLOT_MIN; - else - cell_size = num_carts * SLOT_CFG_SIZE + SLOT_MIN; - - if ((slot_spec = (char *)malloc(cell_size)) == NULL) { - lm_serr(MMS_CRIT, "lm_library_config: Unable to malloc space " - "for slot spec definitions, errno - %s", - strerror(errno)); - return (LM_ERROR); - } - - /* Create slot configs for each cartridge */ - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, - "lm_library_config: Unable to get a task id " - "for show command to obtain list of cartridges"); - free(slot_spec); - return (LM_ERROR); - } - - (void) snprintf(cmd_str, sizeof (cmd_str), LM_SHOW_CARTS, lmpl_tid, - lm.lm_name); - - mms_trace(MMS_DEBUG, "lm_library_config: Obtain list of cartridges in " - "%s library:\n%s", lm.lm_name, cmd_str); - - if ((rc = lm_gen_lmpl_cmd(cmd_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_library_config: Internal " - "processing error encountered while processing " - "for show command to obtain list of cartridges"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(slot_spec); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_CRIT, - "lm_library_config: Error encountered while " - "sending show command to obtain list of cartridges in " - "disk library"); - handle_lmpl_cmd_error(rc, cmd, "show", tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(slot_spec); - return (LM_ERROR); - } - - node = mms_list_head(&ele->lmpl_rsp_list); - rsp = node->lmpl_rsp_tree; - loc = NULL; - - do { - (void) memset(slot_spec, 0, cell_size); - (void) strcpy(slot_spec, "config task[\"%d\"] scope[partial] "); - - rsp_cnt = 0; - do { - if ((clause = mms_pn_lookup(rsp, "text", - MMS_PN_CLAUSE, &loc)) != NULL) { - - mms_trace(MMS_DEBUG, - "lm_lib_config:, Validating a " - "text clause"); - - loc1 = NULL; - if ((pcl = mms_pn_lookup(clause, NULL, - MMS_PN_STRING, &loc1)) == NULL) { - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(slot_spec); - return (LM_ERROR); - } - if ((occ = mms_pn_lookup(clause, NULL, - MMS_PN_STRING, &loc1)) == NULL) { - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(slot_spec); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, - "lm_lib_config: cartridge pcl " - "is %s, occ is %s", mms_pn_token(pcl), - mms_pn_token(occ)); - - if (strcmp("true", mms_pn_token(occ)) == 0) - (void) snprintf(cfg_str, - sizeof (cmd_str), CFG_SLOT, - mms_pn_token(pcl), - mms_pn_token(pcl), lm.lm_type, - "false"); - else - (void) snprintf(cfg_str, - sizeof (cfg_str), CFG_SLOT, - mms_pn_token(pcl), - mms_pn_token(pcl), lm.lm_type, - "true"); - mms_trace(MMS_DEBUG, "lm_lib_config: Slot " - "spec - %s", cfg_str); - (void) strcat(slot_spec, cfg_str); - rsp_cnt++; - } else { - node = mms_list_next(&ele->lmpl_rsp_list, node); - if (node != NULL) { - rsp = node->lmpl_rsp_tree; - loc = NULL; - } - } - } while ((rsp_cnt < MAX_CONFIG_CARTS) && (node != NULL)); - - (void) strcat(slot_spec, ";"); - - if (lm_obtain_task_id(&cfg_tid, &cfg_ele) != LM_OK) { - mms_trace(MMS_CRIT, - "lm_library_config: Unable to get a " - "task id for config slot command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(slot_spec); - return (LM_ERROR); - } - - fmt = mms_strnew(slot_spec, cfg_tid); - free(slot_spec); - slot_spec = fmt; - - mms_trace(MMS_DEBUG, - "lm_lib_config: SLOT_SPEC:\n%s", slot_spec); - - if ((rc = lm_gen_lmpl_cmd(slot_spec, cfg_ele, 0)) - == LM_ERROR) { - mms_trace(MMS_ERR, "lm_library_config: Internal " - "processing error encountered while processing " - "lmpl config slot command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - lm_remove_lmpl_cmd(cfg_tid, cfg_ele); - free(slot_spec); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_CRIT, - "lm_activate: Error encountered while " - "sending lmpl config slot command"); - handle_lmpl_cmd_error(rc, "activate", "config", - tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - lm_remove_lmpl_cmd(cfg_tid, cfg_ele); - free(slot_spec); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_lib_config: Got successful response " - "for slot creation config command"); - - lm_remove_lmpl_cmd(cfg_tid, cfg_ele); - - } while (node != NULL); - - free(slot_spec); - lm_remove_lmpl_cmd(lmpl_tid, ele); - -skip_carts: - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, - "lm_library_config: Unable to get a task id " - "for show command to obtain number of drives in " - "library"); - return (LM_ERROR); - } - - (void) snprintf(cmd_str, sizeof (cmd_str), LM_SHOW_DRIVE_NUM, lmpl_tid, - lm.lm_name); - mms_trace(MMS_DEVP, "lm_library_config: Obtain number of drives in " - "disk libary:\n%s", cmd_str); - - if ((rc = lm_gen_lmpl_cmd(cmd_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_library_config: Internal " - "processing error encountered while processing " - "show command to get number of drives in library"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_CRIT, - "lm_library_config: Error encountered while " - "sending show command to get number of drives in library"); - handle_lmpl_cmd_error(rc, cmd, "show", tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - node = mms_list_head(&ele->lmpl_rsp_list); - rsp = node->lmpl_rsp_tree; - - MMS_PN_LOOKUP(clause, rsp, kw = "text", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(num, clause, NULL, MMS_PN_STRING, NULL); - num_drives = atoi(mms_pn_token(num)); - - mms_trace(MMS_DEBUG, "lm_library_config: Number of drives in library " - "- %d", num_drives); - - lm_remove_lmpl_cmd(lmpl_tid, ele); - - /* If no drives to process return */ - if (num_drives == 0) - return (LM_OK); - - if (num_drives > MAX_CONFIG_DRIVES) - cell_size = MAX_CONFIG_DRIVES * DRIVE_CFG_SIZE + DRIVE_MIN; - else - cell_size = num_drives * DRIVE_CFG_SIZE + DRIVE_MIN; - - if ((drive_spec = (char *)malloc(cell_size)) == NULL) { - lm_serr(MMS_CRIT, "lm_library_config: Unable to malloc space " - "for drive spec definitions, errno - %s", - strerror(errno)); - lm_remove_lmpl_cmd(lmpl_tid, ele); - return (LM_ERROR); - } - - if (lm_obtain_task_id(&lmpl_tid, &ele) != LM_OK) { - mms_trace(MMS_CRIT, - "lm_library_config: Unable to get a task id " - "for show command to obtain list of drives"); - free(drive_spec); - return (LM_ERROR); - } - - (void) snprintf(cmd_str, sizeof (cmd_str), LM_SHOW_DRIVES, lmpl_tid, - lm.lm_name); - - mms_trace(MMS_DEBUG, "lm_activate: Obtain list of drives in " - "%s libary:\n%s", lm.lm_name, cmd_str); - - if ((rc = lm_gen_lmpl_cmd(cmd_str, ele, 0)) == LM_ERROR) { - mms_trace(MMS_ERR, "lm_library_config: Internal " - "processing error encountered while processing " - "for show command to obtain list of drives"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(drive_spec); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_CRIT, - "lm_library_config: Error encountered while " - "sending show command to obtain list of drives in " - "disk library"); - handle_lmpl_cmd_error(rc, cmd, "show", tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(drive_spec); - return (LM_ERROR); - } - - node = mms_list_head(&ele->lmpl_rsp_list); - rsp = node->lmpl_rsp_tree; - loc = NULL; - - do { - - (void) memset(drive_spec, 0, cell_size); - (void) strcpy(drive_spec, - "config task[\"%d\"] scope[partial] "); - rsp_cnt = 0; - - do { - if ((clause = mms_pn_lookup(rsp, "text", - MMS_PN_CLAUSE, &loc)) != NULL) { - - mms_trace(MMS_DEVP, "lm_lib_config: " - "Validating a text clause"); - - loc1 = NULL; - if ((dname = mms_pn_lookup(clause, NULL, - MMS_PN_STRING, &loc1)) == NULL) { - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(drive_spec); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_lib_config: " - "drive name is %s", mms_pn_token(dname)); - - if ((pcl = mms_pn_lookup(clause, NULL, - MMS_PN_STRING, &loc1)) == NULL) { - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(drive_spec); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_lib_config: " - "drive pcl is %s", mms_pn_token(pcl)); - - if (strlen(mms_pn_token(pcl)) == 0) { - (void) snprintf(cfg_str, - sizeof (cfg_str), CFG_DRIVE, - mms_pn_token(dname), "none", - "false", "true"); - mms_trace(MMS_DEVP, "lm_lib_config: " - "Drive spec - %s", cfg_str); - } else { - (void) snprintf(cfg_str, - sizeof (cfg_str), CFG_DRIVE, - mms_pn_token(dname), - mms_pn_token(pcl), "true", - "true"); - mms_trace(MMS_DEVP, "lm_lib_config: " - "Drive spec - %s", cfg_str); - } - (void) strcat(drive_spec, cfg_str); - rsp_cnt++; - } else { - node = mms_list_next(&ele->lmpl_rsp_list, node); - if (node != NULL) { - rsp = node->lmpl_rsp_tree; - loc = NULL; - } - } - } while ((rsp_cnt < MAX_CONFIG_DRIVES) && (node != NULL)); - - (void) strcat(drive_spec, ";"); - - if (lm_obtain_task_id(&cfg_tid, &cfg_ele) != LM_OK) { - mms_trace(MMS_CRIT, - "lm_lib_config: Unable to get a task id " - "for config drive command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - free(drive_spec); - return (LM_ERROR); - } - - fmt = mms_strnew(drive_spec, cfg_tid); - free(drive_spec); - drive_spec = fmt; - - mms_trace(MMS_DEBUG, "lm_lib_config: DRIVE_SPEC:\n%s", - drive_spec); - - if ((rc = lm_gen_lmpl_cmd(drive_spec, cfg_ele, 0)) - == LM_ERROR) { - mms_trace(MMS_ERR, "lm_lib_config: Internal " - "processing error encountered while processing " - "lmpl config drive command"); - lm_remove_lmpl_cmd(lmpl_tid, ele); - lm_remove_lmpl_cmd(cfg_tid, cfg_ele); - free(drive_spec); - return (LM_ERROR); - } else if (rc != LMPL_FINAL_OK) { - mms_trace(MMS_CRIT, - "lm_lib_config: Error encountered while " - "sending lmpl config drive command"); - handle_lmpl_cmd_error(rc, cmd, "config", tid, ret_msg); - lm_remove_lmpl_cmd(lmpl_tid, ele); - lm_remove_lmpl_cmd(cfg_tid, cfg_ele); - free(drive_spec); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_lib_config: Got successful response " - "for drive creation config command"); - - lm_remove_lmpl_cmd(cfg_tid, cfg_ele); - - } while (node != NULL); - - free(drive_spec); - lm_remove_lmpl_cmd(lmpl_tid, ele); - - return (LM_OK); - -not_found: - lm_remove_lmpl_cmd(lmpl_tid, ele); - mms_trace(MMS_ERR, "lm_library_config: LMPL command has an invalid or " - "missing %s clause:\n%s", kw, mms_pn_build_cmd_text(rsp)); - return (LM_ERROR); -} diff --git a/usr/src/lib/mms/lm/libdisk/common/lm_disk.h b/usr/src/lib/mms/lm/libdisk/common/lm_disk.h deleted file mode 100644 index 8e520a284c..0000000000 --- a/usr/src/lib/mms/lm/libdisk/common/lm_disk.h +++ /dev/null @@ -1,136 +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 __LM_DISK_H -#define __LM_DISK_H - - -#include <lm.h> -#include <lm_proto.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define SLOT_MIN 50 /* If no carts the min of space needed */ -#define PCL_LEN 10 /* Max length of a disk cartridge PCL */ -#define SLOT_CFG_SIZE 75 /* The number of bytes in one slot */ - /* definition of a config slot LMPL */ - /* command */ -#define MAX_CONFIG_CARTS 420 /* Max number of cartridges that can */ - /* be processed into one config slot */ - /* LMPL command */ -#define DRIVE_MIN 50 /* If no drives the min of space needed */ -#define DNAME_LEN 20 -#define DRIVE_CFG_SIZE 75 /* The number of bytes in one drive */ - /* definition of a config drive LMPL */ - /* command */ -#define MAX_CONFIG_DRIVES 400 /* Max number of drives that can */ - /* be processed into one config slot */ - /* LMPL command */ - -#define CFG_SLOT "slot [\"%s\" \"panel 0\" \"group 0\" \ -\"%s\" \"%s\" %s true] " - -#define DELE_SLOT "delslots [\"%s\"] " - -/* The following command formats differ from those in the IEEE */ -/* spec in the drive name. The reason this was done is that when the */ -/* LM is activated initally, it does not know what the logical */ -/* names are for the drives in the library, it only knows a geometry */ -/* from the acsls perspective. Thus during the inital activation config */ -/* LM sends up the acsls geometry and MM matches this with the geoemetry */ -/* attribute of a drive. This same scheme was carried over for the */ -/* partial configs assocatied when mounts and unmounts are done, even though */ -/* LM knows the logical name at that time. */ - -#define TEXT_CART "\"%s\" " -#define CFG_DRIVE "drive [\"\" \"%s\" \"panel 0\" \"%s\" %s %s] " - -#define CONFIG_MOUNT "config task [\"%d\"] scope [partial] \ -slot [\"%s\" \"panel 0\" \"group 0\" \"none\" \"DISK\" false true] \ -drive [\"\" \"%s\" \"panel 0\" \"%s\" true true]; " - -#define CONFIG_UNMOUNT "config task [\"%d\"] scope [partial] \ -slot [\"%s\" \"panel 0\" \"group 0\" \"%s\" \"DISK\" true true] \ -drive [\"\" \"%s\" \"panel 0\" \"none\" false true]; " - -#define CONFIG_SCAN "config task [\"%d\"] scope [partial] \ -slot [\"%s\" \"panel %d\" \"group %d\" \"%s\" \"%s\" true true]; " - -#define CONFIG_CART_EVENT "config task [\"%d\"] scope [partial] \ -slot [\"%s\" \"panel %d\" \"group %d\" \"%s\" \"%s\" true true]; " - -#define CONFIG_DRIVE_EVENT "config task [\"%d\"] scope [partial] \ -drive [\"\" \"%d,%d,%d,%d\" \"panel %d\" \"%s\" %s %s]; " - -#define LM_SHOW_OCC "show task [\"%d\"] \ -match [and(streq(LIBRARY.\"LibraryName\" \"%s\") \ -streq(CARTRIDGE.\"CartridgePCL\" \"%s\"))] \ -report[CARTRIDGE.\"CartridgeDriveOccupied\"] \ -reportmode[value]; " - -#define LM_SHOW_CARTS "show task [\"%d\"] \ -match [streq(LIBRARY.\"LibraryName\" \"%s\")] \ -report[CARTRIDGE.\"CartridgePCL\" CARTRIDGE.\"CartridgeDriveOccupied\"] \ -reportmode[value]; " - -#define LM_SHOW_CART_NUM "show task [\"%d\"] \ -match [streq(LIBRARY.\"LibraryName\" \"%s\")] \ -report[CARTRIDGE] \ -reportmode[number]; " - -#define LM_SHOW_DRIVE "show task [\"%d\"] \ -match [and(streq(LIBRARY.\"LibraryName\" \"%s\") \ -streq(DRIVE.\"DriveName\" \"%s\"))] \ -report[DRIVE.\"CartridgePCL\"] \ -reportmode[value]; " - -#define LM_SHOW_DRIVES "show task [\"%d\"] \ -match [streq(LIBRARY.\"LibraryName\" \"%s\")] \ -report[DRIVE.\"DriveName\" DRIVE.\"CartridgePCL\"] \ -reportmode[value]; " - -#define LM_SHOW_DRIVE_NUM "show task [\"%d\"] \ -match [streq(LIBRARY.\"LibraryName\" \"%s\")] \ -report[DRIVE] \ -reportmode[number]; " - -#define DISK_CONFIG "config task [\"%d\"] scope [partial] \ -bay [\"panel 0\" true] \ -slotgroup [\"group 0\" \"panel 0\" none \"ordinary\"] \ -slotgroup [\"group cap0\" \"panel 0\" both \"port\"]; " - -#define FREE_1 "freeslots [\"panel 0\" \"L180\" \"%d\"] \ -freeslots [\"panel 1\" \"L180\" \"%d\"] \ -freeslots [\"panel 2\" \"L180\" \"%d\"]" - -int lm_library_config(char *, char *, char *); - -#ifdef __cplusplus -} -#endif - -#endif /* __LM_DISK_H */ diff --git a/usr/src/lib/mms/lm/libdisk/common/mapfile-vers b/usr/src/lib/mms/lm/libdisk/common/mapfile-vers deleted file mode 100644 index 115db15c2f..0000000000 --- a/usr/src/lib/mms/lm/libdisk/common/mapfile-vers +++ /dev/null @@ -1,71 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - lm_activate; - lm_barrier; - lm_cancel; - lm_eject; - lm_event; - lm_exit; - lm_inject; - lm_mount; - lm_move; - lm_private; - lm_reset; - lm_scan; - lm_unmount; - - handle_lmpl_cmd_error = extern; - lm = extern; - lm_common_ready = extern; - lm_gen_lmpl_cmd = extern; - lm_obtain_task_id = extern; - lm_remove_lmpl_cmd = extern; - lm_serr = extern; - lm_state = extern; - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/lm/libdisk/i386/Makefile b/usr/src/lib/mms/lm/libdisk/i386/Makefile deleted file mode 100644 index d77b753d64..0000000000 --- a/usr/src/lib/mms/lm/libdisk/i386/Makefile +++ /dev/null @@ -1,26 +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. -# -# -include ../Makefile.com diff --git a/usr/src/lib/mms/lm/libdisk/sparc/Makefile b/usr/src/lib/mms/lm/libdisk/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/lm/libdisk/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/lm/libl180/Makefile b/usr/src/lib/mms/lm/libl180/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/lm/libl180/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/lm/libl180/Makefile.com b/usr/src/lib/mms/lm/libl180/Makefile.com deleted file mode 100644 index 3f356a094d..0000000000 --- a/usr/src/lib/mms/lm/libl180/Makefile.com +++ /dev/null @@ -1,69 +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. -# -# - -LIBRARY = libL180_net.a -VERS = -OBJS_COMMON = lm_l180.o -OBJS_SHARED = lm_acs_common.o lm_acs_display.o lm_comm.o lm_lcom.o - -OBJECTS = $(OBJS_COMMON) $(OBJS_SHARED) - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -LMDIR = $(SRC)/lib/mms/lm/libcommon - -SRCS = $(OBJS_COMMON:%.o=$(SRCDIR)/%.c) \ - $(OBJS_SHARED:%.o=$(LMDIR)/%.c) - -LDLIBS += -lc -LDLIBS += -L$(SRC)/lib/mms/mms/$(MACH) -lmms - -CFLAGS += $(CCVERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/lm/common -I../../../mms/common -CPPFLAGS += -I../../libcommon -I$(ACSLSH) -CPPFLAGS += -erroff=E_IMPLICIT_DECL_FUNC_RETURN_INT - -.KEEP_STATE: - -all: $(LIBS) - -lint: $(LINTLIB) lintcheck - -pics/%.o: $(LMDIR)/%.c - $(COMPILE.c) -o $@ $< - $(POST_PROCESS_O) - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) diff --git a/usr/src/lib/mms/lm/libl180/common/lm_l180.c b/usr/src/lib/mms/lm/libl180/common/lm_l180.c deleted file mode 100644 index 71f86d8574..0000000000 --- a/usr/src/lib/mms/lm/libl180/common/lm_l180.c +++ /dev/null @@ -1,73 +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 "lm_acs.h" - -#define L180_84 84 -#define L180_84_R 90 -#define L180_140 140 -#define L180_140_R 146 -#define L180_180 174 -#define L180_180_R 180 - -#define L180_MAX_DRIVE 10 - -#define L180_CONFIG "config task [\"%d\"] scope [full] \ -bay [\"panel 0\" true] \ -bay [\"panel 1\" true] \ -bay [\"panel 2\" true] %s; " - -#define L180_GROUP "slotgroup [\"group 0\" \"panel 0\" none \"ordinary\"] \ -slotgroup [\"group 1\" \"panel 1\" none \"ordinary\"] \ -slotgroup [\"group 2\" \"panel 2\" none \"ordinary\"] \ -slotgroup [\"group cap0\" \"panel 1\" both \"port\"]" - -static char *_SrcFile = __FILE__; - -static acs_cap_t acs_caps; -static acs_drive_t acs_drives; - -/*ARGSUSED2*/ -int -lm_library_config_non_comm(int cmd_tid, char *full_str, char *tid, - char *ret_msg) -{ - acs_caps.cap_size = MAX_L180_CAP_SIZE; - acs_caps.cap_capid = 0; - (void) strcpy(acs_caps.cap_name, "group cap0"); - acs_caps.cap_config = 1; - lm.lm_port = (void *)&acs_caps; - lm.lm_caps = 1; - lm.lm_lsms = 1; - - acs_drives.acs_max_drive = L180_MAX_DRIVE; - lm.lm_drive = (void *)&acs_drives; - - (void) snprintf(full_str, FSBUFSIZE, - L180_CONFIG, cmd_tid, L180_GROUP); - mms_trace(MMS_DEBUG, "lm_library_config_non_comm: Bay, Group - " - "%s", full_str); - return (LM_OK); -} diff --git a/usr/src/lib/mms/lm/libl180/common/mapfile-vers b/usr/src/lib/mms/lm/libl180/common/mapfile-vers deleted file mode 100644 index 339bfdb17d..0000000000 --- a/usr/src/lib/mms/lm/libl180/common/mapfile-vers +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - lm_activate; - lm_barrier; - lm_cancel; - lm_eject; - lm_event; - lm_exit; - lm_inject; - lm_mount; - lm_move; - lm_private; - lm_reset; - lm_scan; - lm_unmount; - - acs_dismount = extern; - acs_display = extern; - acs_eject = extern; - acs_enter = extern; - acs_get_packet_version = extern; - acs_mount = extern; - acs_query_cap = extern; - acs_query_drive = extern; - acs_query_lsm = extern; - acs_query_mount = extern; - acs_query_server = extern; - acs_query_volume = extern; - acs_response = extern; - acs_state = extern; - acs_status = extern; - acs_type = extern; - acs_type_response = extern; - handle_lmpl_cmd_error = extern; - lm = extern; - lm_acc_mutex = extern; - lm_common_ready = extern; - lm_gen_lmpl_cmd = extern; - lm_internal_error = extern; - lm_message = extern; - lm_obtain_task_id = extern; - lm_remove_lmpl_cmd = extern; - lm_serr = extern; - lm_set_drive_disabled = extern; - lm_state = extern; - - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/lm/libl180/i386/Makefile b/usr/src/lib/mms/lm/libl180/i386/Makefile deleted file mode 100644 index d77b753d64..0000000000 --- a/usr/src/lib/mms/lm/libl180/i386/Makefile +++ /dev/null @@ -1,26 +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. -# -# -include ../Makefile.com diff --git a/usr/src/lib/mms/lm/libl180/sparc/Makefile b/usr/src/lib/mms/lm/libl180/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/lm/libl180/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/lm/libl500/Makefile b/usr/src/lib/mms/lm/libl500/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/lm/libl500/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/lm/libl500/Makefile.com b/usr/src/lib/mms/lm/libl500/Makefile.com deleted file mode 100644 index b1c839f111..0000000000 --- a/usr/src/lib/mms/lm/libl500/Makefile.com +++ /dev/null @@ -1,71 +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. -# -# - -LIBRARY = libL500_net.a -VERS = -OBJS_COMMON = lm_l500.o -OBJS_SHARED = lm_acs_common.o lm_acs_display.o lm_comm.o lm_lcom.o - -OBJECTS = $(OBJS_COMMON) $(OBJS_SHARED) - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -LMDIR = $(SRC)/lib/mms/lm/libcommon - -SRCS = $(OBJS_COMMON:%.o=$(SRCDIR)/%.c) \ - $(OBJS_SHARED:%.o=$(LMDIR)/%.c) - -LDLIBS += -lc -LDLIBS += -L$(SRC)/lib/mms/mms/$(MACH) -lmms - -CFLAGS += $(CCVERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/lm/common -I../../../mms/common -CPPFLAGS += -I../../libcommon -I$(ACSLSH) -CPPFLAGS += -erroff=E_IMPLICIT_DECL_FUNC_RETURN_INT - -.KEEP_STATE: - -all: $(LIBS) - -LMLINKS = libSL500_net.so - -lint: $(LINTLIB) lintcheck - -pics/%.o: $(LMDIR)/%.c - $(COMPILE.c) -o $@ $< - $(POST_PROCESS_O) - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) $(LMLIBLINKS) diff --git a/usr/src/lib/mms/lm/libl500/common/lm_l500.c b/usr/src/lib/mms/lm/libl500/common/lm_l500.c deleted file mode 100644 index 67e4814c09..0000000000 --- a/usr/src/lib/mms/lm/libl500/common/lm_l500.c +++ /dev/null @@ -1,146 +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 "lm_acs.h" - -#define L500_30 30 -#define L500_50 50 - -#define L500_MAX_DRIVE 18 - -#define L500_CONFIG "config task [\"%d\"] scope [full] \ -%s %s;" - -#define L500_GROUP "slotgroup [\"group 1\" \"panel 1\" none \"ordinary\"] " - -static char *_SrcFile = __FILE__; - -static acs_cap_t acs_caps[MAX_L500_CAPS]; -static acs_drive_t acs_drives; - -/*ARGSUSED2*/ -int -lm_library_config_non_comm(int cmd_tid, char *full_str, char *tid, - char *ret_msg) -{ - int i; - int num_caps; - char cap_name[MAX_CAP_SIZE]; - char *bay_str = NULL; - char *grp_str = NULL; - - CAPID capid[MAX_ID]; - QU_CAP_STATUS *cs; - ACS_QUERY_CAP_RESPONSE *cp; - acs_rsp_ele_t *acs_rsp; - - lm.lm_caps = num_caps = 1; - lm.lm_lsms = 1; - - if (lm_num_panels(0, tid, ret_msg) != LM_OK) { - mms_trace(MMS_ERR, "lm_library_config: Unable to obtain " - "number of panels in L500/SL500 library"); - return (LM_ERROR); - } - - if ((lm_acs_query_cap(&acs_rsp, capid, "activate", tid, ret_msg)) == - LM_ERROR) { - mms_trace(MMS_ERR, "lm_library_config: query of number of caps " - "in L500/SL500 library failed"); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_library_config: Received final response for " - "acs_query_cap"); - - cp = (ACS_QUERY_CAP_RESPONSE *)acs_rsp->acs_rbuf; - if (cp->query_cap_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_library_config: response from " - "acs_query_cap() failed, defaulting to one cap " - ", status - %s", acs_status(cp->query_cap_status)); - return (LM_ERROR); - } - - for (num_caps = 0, i = 0; i < cp->count; i++) { - cs = &cp->cap_status[i]; - if (cs->cap_id.lsm_id.acs == lm.lm_acs) - num_caps++; - } - lm.lm_caps = num_caps; - - for (i = 0; i < MAX_L500_CAPS; i++) { - acs_caps[i].cap_size = MAX_L500_CAP_SIZE; - acs_caps[i].cap_capid = i; - (void) snprintf(cap_name, sizeof (cap_name), - "group cap%d", i); - (void) strlcpy(acs_caps[i].cap_name, cap_name, - sizeof (acs_caps[i].cap_name)); - if (i < num_caps) - acs_caps[i].cap_config = 1; - else - acs_caps[i].cap_config = 0; - } - - lm.lm_port = (void *)&acs_caps[0]; - - mms_trace(MMS_DEBUG, "lm_library_config: Number of caps for L500/SL500 " - "library - %d", num_caps); - - for (i = 1; i < lm.lm_panels; i++) - bay_str = mms_strapp(bay_str, "bay [\"panel %d\" true] ", i); - - for (i = 1; i < lm.lm_panels; i++) { - grp_str = mms_strapp(grp_str, "slotgroup [\"group %d\" " - "\"panel %d\" none \"ordinary\"] ", i, i); - if (i == 1) - grp_str = mms_strapp(grp_str, "slotgroup [\"group " - "cap0\" \"panel 1\" both \"port\"] "); - } - - acs_drives.acs_max_drive = L500_MAX_DRIVE; - lm.lm_drive = (void *)&acs_drives; - - free(acs_rsp); - - if ((bay_str && grp_str) != NULL) { - if ((snprintf(full_str, FSBUFSIZE, - L500_CONFIG, cmd_tid, bay_str, grp_str)) > FSBUFSIZE) { - mms_trace(MMS_ERR, "lm_library_config: buffer size"); - free(bay_str); - free(grp_str); - return (LM_ERROR); - } - } else { - mms_trace(MMS_ERR, "lm_library_config: bay_str and grp_str " - "null"); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_library_config: Bay, Group - %s", full_str); - - free(bay_str); - free(grp_str); - return (LM_OK); -} diff --git a/usr/src/lib/mms/lm/libl500/common/mapfile-vers b/usr/src/lib/mms/lm/libl500/common/mapfile-vers deleted file mode 100644 index 339bfdb17d..0000000000 --- a/usr/src/lib/mms/lm/libl500/common/mapfile-vers +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - lm_activate; - lm_barrier; - lm_cancel; - lm_eject; - lm_event; - lm_exit; - lm_inject; - lm_mount; - lm_move; - lm_private; - lm_reset; - lm_scan; - lm_unmount; - - acs_dismount = extern; - acs_display = extern; - acs_eject = extern; - acs_enter = extern; - acs_get_packet_version = extern; - acs_mount = extern; - acs_query_cap = extern; - acs_query_drive = extern; - acs_query_lsm = extern; - acs_query_mount = extern; - acs_query_server = extern; - acs_query_volume = extern; - acs_response = extern; - acs_state = extern; - acs_status = extern; - acs_type = extern; - acs_type_response = extern; - handle_lmpl_cmd_error = extern; - lm = extern; - lm_acc_mutex = extern; - lm_common_ready = extern; - lm_gen_lmpl_cmd = extern; - lm_internal_error = extern; - lm_message = extern; - lm_obtain_task_id = extern; - lm_remove_lmpl_cmd = extern; - lm_serr = extern; - lm_set_drive_disabled = extern; - lm_state = extern; - - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/lm/libl500/i386/Makefile b/usr/src/lib/mms/lm/libl500/i386/Makefile deleted file mode 100644 index d77b753d64..0000000000 --- a/usr/src/lib/mms/lm/libl500/i386/Makefile +++ /dev/null @@ -1,26 +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. -# -# -include ../Makefile.com diff --git a/usr/src/lib/mms/lm/libl500/sparc/Makefile b/usr/src/lib/mms/lm/libl500/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/lm/libl500/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/lm/libl700/Makefile b/usr/src/lib/mms/lm/libl700/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/lm/libl700/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/lm/libl700/Makefile.com b/usr/src/lib/mms/lm/libl700/Makefile.com deleted file mode 100644 index 357a4e1d1f..0000000000 --- a/usr/src/lib/mms/lm/libl700/Makefile.com +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -LIBRARY = libL700_net.a -VERS = -OBJS_COMMON = lm_l700.o -OBJS_SHARED = lm_acs_common.o lm_acs_display.o lm_comm.o lm_lcom.o - -OBJECTS = $(OBJS_COMMON) $(OBJS_SHARED) - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -LMDIR = $(SRC)/lib/mms/lm/libcommon - -SRCS = $(OBJS_COMMON:%.o=$(SRCDIR)/%.c) \ - $(OBJS_SHARED:%.o=$(LMDIR)/%.c) - -LDLIBS += -lc -LDLIBS += -L$(SRC)/lib/mms/mms/$(MACH) -lmms - -CFLAGS += $(CCVERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/lm/common -I../../../mms/common -CPPFLAGS += -I../../libcommon -I$(ACSLSH) -CPPFLAGS += -erroff=E_IMPLICIT_DECL_FUNC_RETURN_INT - -.KEEP_STATE: - -all: $(LIBS) - -lint: $(LINTLIB) lintcheck - -pics/%.o: $(LMDIR)/%.c - $(COMPILE.c) -o $@ $< - $(POST_PROCESS_O) - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) diff --git a/usr/src/lib/mms/lm/libl700/common/lm_l700.c b/usr/src/lib/mms/lm/libl700/common/lm_l700.c deleted file mode 100644 index 365805ba27..0000000000 --- a/usr/src/lib/mms/lm/libl700/common/lm_l700.c +++ /dev/null @@ -1,188 +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 "lm_acs.h" - -#define L700_156 156 -#define L700_156_R 168 -#define L700_216 216 -#define L700_216_R 228 -#define L700_324 324 -#define L700_324_R 336 -#define L700_384 384 -#define L700_384_R 396 -#define L700_618 618 -#define L700_618_R 630 -#define L700_678 678 -#define L700_678_R 690 - -#define L700_MAX_DRIVE 40 - -#define L700_CONFIG_1 "config task [\"%d\"] scope [full] \ -bay [\"panel 0\" true] \ -bay [\"panel 1\" true] \ -bay [\"panel 2\" true] %s; " - -#define L700_CONFIG_2 "config task [\"%d\"] scope [full] \ -bay [\"panel 0\" true] \ -bay [\"panel 1\" true] \ -bay [\"panel 2\" true] \ -bay [\"panel 3\" true] %s; " - -#define L700_GROUP_1 "slotgroup [\"group 0\" \"panel 0\" none \"ordinary\"] \ -slotgroup [\"group 1\" \"panel 1\" none \"ordinary\"] \ -slotgroup [\"group 2\" \"panel 2\" none \"ordinary\"] \ -slotgroup [\"group cap0\" \"panel 1\" both \"port\"]" - -#define L700_GROUP_1A "slotgroup [\"group 0\" \"panel 0\" none \"ordinary\"] \ -slotgroup [\"group 1\" \"panel 1\" none \"ordinary\"] \ -slotgroup [\"group 2\" \"panel 2\" none \"ordinary\"] \ -slotgroup [\"group cap0\" \"panel 1\" both \"port\"] \ -slotgroup [\"group cap1\" \"panel 1\" both \"port\"]" - -#define L700_GROUP_2 "slotgroup [\"group 0\" \"panel 0\" none \"ordinary\"] \ -slotgroup [\"group 1\" \"panel 1\" none \"ordinary\"] \ -slotgroup [\"group 2\" \"panel 2\" none \"ordinary\"] \ -slotgroup [\"group 3\" \"panel 3\" none \"ordinary\"] \ -slotgroup [\"group cap0\" \"panel 1\" both \"port\"]" - -#define L700_GROUP_2A "slotgroup [\"group 0\" \"panel 0\" none \"ordinary\"] \ -slotgroup [\"group 1\" \"panel 1\" none \"ordinary\"] \ -slotgroup [\"group 2\" \"panel 2\" none \"ordinary\"] \ -slotgroup [\"group 3\" \"panel 3\" none \"ordinary\"] \ -slotgroup [\"group cap0\" \"panel 1\" both \"port\"] \ -slotgroup [\"group cap1\" \"panel 1\" both \"port\"]" - -static char *_SrcFile = __FILE__; - -static acs_cap_t acs_caps[MAX_L700_CAPS]; -static acs_drive_t acs_drives; - -int -lm_library_config_non_comm(int cmd_tid, char *full_str, char *tid, - char *ret_msg) -{ - - int i; - int num_caps; - char cap_name[MAX_CAP_SIZE]; - const char *bay_str; - char *grp_str; - - CAPID capid[MAX_ID]; - QU_CAP_STATUS *cs; - ACS_QUERY_CAP_RESPONSE *cp; - acs_rsp_ele_t *acs_rsp; - - lm.lm_caps = num_caps = 1; - lm.lm_lsms = 1; - - if (lm_num_panels(0, tid, ret_msg) != LM_OK) { - mms_trace(MMS_ERR, "lm_library_config: Unable to obtain " - "number of panels in L700 library"); - return (LM_ERROR); - } - - if ((lm_acs_query_cap(&acs_rsp, capid, "activate", tid, ret_msg)) == - LM_ERROR) { - mms_trace(MMS_ERR, "lm_library_config: query of number of caps " - "in L700 library failed"); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_library_config: Received final response for " - "acs_query_cap"); - - cp = (ACS_QUERY_CAP_RESPONSE *)acs_rsp->acs_rbuf; - if (cp->query_cap_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_library_config: response from " - "acs_query_cap() failed, defaulting to one cap " - ", status - %s", acs_status(cp->query_cap_status)); - return (LM_ERROR); - } - - for (num_caps = 0, i = 0; i < cp->count; i++) { - cs = &cp->cap_status[i]; - if (cs->cap_id.lsm_id.acs == lm.lm_acs) - num_caps++; - } - lm.lm_caps = num_caps; - - for (i = 0; i < MAX_L700_CAPS; i++) { - acs_caps[i].cap_size = MAX_L700_CAP_SIZE; - acs_caps[i].cap_capid = i; - (void) snprintf(cap_name, sizeof (cap_name), - "group cap%d", i); - (void) strlcpy(acs_caps[i].cap_name, cap_name, - sizeof (acs_caps[i].cap_name)); - if (i < num_caps) - acs_caps[i].cap_config = 1; - else - acs_caps[i].cap_config = 0; - } - - lm.lm_port = (void *)&acs_caps[0]; - - mms_trace(MMS_DEBUG, "lm_library_config: Number of caps for L700 " - "library - %d", num_caps); - - if (lm.lm_panels <= 3) { - bay_str = L700_CONFIG_1; - if (num_caps == 1) - grp_str = L700_GROUP_1; - else if (num_caps == 2) - grp_str = L700_GROUP_1A; - else { - mms_trace(MMS_ERR, "lm_library_config: " - "invalid number of " - "caps in a L700 library - %d", cp->count); - lm.lm_caps = 1; - grp_str = L700_GROUP_1; - } - } else { - bay_str = L700_CONFIG_2; - if (num_caps == 1) - grp_str = L700_GROUP_2; - else if (num_caps == 2) - grp_str = L700_GROUP_2A; - else { - mms_trace(MMS_ERR, "lm_library_config: " - "invalid number of " - "caps in a L700 library - %d", cp->count); - lm.lm_caps = 1; - grp_str = L700_GROUP_1; - } - } - - acs_drives.acs_max_drive = L700_MAX_DRIVE; - lm.lm_drive = (void *)&acs_drives; - - free(acs_rsp); - - (void) snprintf(full_str, FSBUFSIZE, - bay_str, cmd_tid, grp_str); - mms_trace(MMS_DEBUG, "lm_library_config: Bay, Group - %s", full_str); - return (LM_OK); -} diff --git a/usr/src/lib/mms/lm/libl700/common/mapfile-vers b/usr/src/lib/mms/lm/libl700/common/mapfile-vers deleted file mode 100644 index 339bfdb17d..0000000000 --- a/usr/src/lib/mms/lm/libl700/common/mapfile-vers +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - lm_activate; - lm_barrier; - lm_cancel; - lm_eject; - lm_event; - lm_exit; - lm_inject; - lm_mount; - lm_move; - lm_private; - lm_reset; - lm_scan; - lm_unmount; - - acs_dismount = extern; - acs_display = extern; - acs_eject = extern; - acs_enter = extern; - acs_get_packet_version = extern; - acs_mount = extern; - acs_query_cap = extern; - acs_query_drive = extern; - acs_query_lsm = extern; - acs_query_mount = extern; - acs_query_server = extern; - acs_query_volume = extern; - acs_response = extern; - acs_state = extern; - acs_status = extern; - acs_type = extern; - acs_type_response = extern; - handle_lmpl_cmd_error = extern; - lm = extern; - lm_acc_mutex = extern; - lm_common_ready = extern; - lm_gen_lmpl_cmd = extern; - lm_internal_error = extern; - lm_message = extern; - lm_obtain_task_id = extern; - lm_remove_lmpl_cmd = extern; - lm_serr = extern; - lm_set_drive_disabled = extern; - lm_state = extern; - - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/lm/libl700/i386/Makefile b/usr/src/lib/mms/lm/libl700/i386/Makefile deleted file mode 100644 index d77b753d64..0000000000 --- a/usr/src/lib/mms/lm/libl700/i386/Makefile +++ /dev/null @@ -1,26 +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. -# -# -include ../Makefile.com diff --git a/usr/src/lib/mms/lm/libl700/sparc/Makefile b/usr/src/lib/mms/lm/libl700/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/lm/libl700/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/lm/libsl3000/Makefile b/usr/src/lib/mms/lm/libsl3000/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/lm/libsl3000/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/lm/libsl3000/Makefile.com b/usr/src/lib/mms/lm/libsl3000/Makefile.com deleted file mode 100644 index 93046e8cdc..0000000000 --- a/usr/src/lib/mms/lm/libsl3000/Makefile.com +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -LIBRARY = libSL3000_net.a -VERS = -OBJS_COMMON = lm_sl3000.o -OBJS_SHARED = lm_acs_common.o lm_acs_display.o lm_comm.o lm_lcom.o - -OBJECTS = $(OBJS_COMMON) $(OBJS_SHARED) - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -LMDIR = $(SRC)/lib/mms/lm/libcommon - -SRCS = $(OBJS_COMMON:%.o=$(SRCDIR)/%.c) \ - $(OBJS_SHARED:%.o=$(LMDIR)/%.c) - -LDLIBS += -lc -LDLIBS += -L$(SRC)/lib/mms/mms/$(MACH) -lmms - -CFLAGS += $(CCVERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/lm/common -I../../../mms/common -CPPFLAGS += -I../../libcommon -I$(ACSLSH) -CPPFLAGS += -erroff=E_IMPLICIT_DECL_FUNC_RETURN_INT - -.KEEP_STATE: - -all: $(LIBS) - -lint: $(LINTLIB) lintcheck - -pics/%.o: $(LMDIR)/%.c - $(COMPILE.c) -o $@ $< - $(POST_PROCESS_O) - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) diff --git a/usr/src/lib/mms/lm/libsl3000/common/lm_sl3000.c b/usr/src/lib/mms/lm/libsl3000/common/lm_sl3000.c deleted file mode 100644 index 5b688950df..0000000000 --- a/usr/src/lib/mms/lm/libsl3000/common/lm_sl3000.c +++ /dev/null @@ -1,146 +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. - */ - - -#include "lm_acs.h" - -#define SL3000_30 30 -#define SL3000_50 50 - -#define SL3000_MAX_DRIVE 32 - -#define SL3000_CONFIG "config task [\"%d\"] scope [full] \ -%s %s;" - -#define SL3000_GROUP "slotgroup [\"group 1\" \"panel 1\" none \"ordinary\"] " - -static char *_SrcFile = __FILE__; - -static acs_cap_t acs_caps[MAX_SL3000_CAPS]; -static acs_drive_t acs_drives; - -/*ARGSUSED2*/ -int -lm_library_config_non_comm(int cmd_tid, char *full_str, char *tid, - char *ret_msg) -{ - int i; - int num_caps; - char cap_name[MAX_CAP_SIZE]; - char *bay_str = NULL; - char *grp_str = NULL; - - CAPID capid[MAX_ID]; - QU_CAP_STATUS *cs; - ACS_QUERY_CAP_RESPONSE *cp; - acs_rsp_ele_t *acs_rsp; - - lm.lm_caps = num_caps = 1; - lm.lm_lsms = 1; - - if (lm_num_panels(0, tid, ret_msg) != LM_OK) { - mms_trace(MMS_ERR, "lm_library_config: Unable to obtain " - "number of panels in SL3000 library"); - return (LM_ERROR); - } - - if ((lm_acs_query_cap(&acs_rsp, capid, "activate", tid, ret_msg)) == - LM_ERROR) { - mms_trace(MMS_ERR, "lm_library_config: query of number of caps " - "in SL3000 library failed"); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_library_config: Received final response for " - "acs_query_cap"); - - cp = (ACS_QUERY_CAP_RESPONSE *)acs_rsp->acs_rbuf; - if (cp->query_cap_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_library_config: response from " - "acs_query_cap() failed, defaulting to one cap " - ", status - %s", acs_status(cp->query_cap_status)); - return (LM_ERROR); - } - - for (num_caps = 0, i = 0; i < cp->count; i++) { - cs = &cp->cap_status[i]; - if (cs->cap_id.lsm_id.acs == lm.lm_acs) - num_caps++; - } - lm.lm_caps = num_caps; - - for (i = 0; i < MAX_SL3000_CAPS; i++) { - acs_caps[i].cap_size = MAX_SL3000_CAP_SIZE; - acs_caps[i].cap_capid = i; - (void) snprintf(cap_name, sizeof (cap_name), - "group cap%d", i); - (void) strlcpy(acs_caps[i].cap_name, cap_name, - sizeof (acs_caps[i].cap_name)); - if (i < num_caps) - acs_caps[i].cap_config = 1; - else - acs_caps[i].cap_config = 0; - } - - lm.lm_port = (void *)&acs_caps[0]; - - mms_trace(MMS_DEBUG, "lm_library_config: Number of caps for SL3000 " - "library - %d", num_caps); - - for (i = 1; i < lm.lm_panels; i++) - bay_str = mms_strapp(bay_str, "bay [\"panel %d\" true] ", i); - - for (i = 1; i < lm.lm_panels; i++) { - grp_str = mms_strapp(grp_str, "slotgroup [\"group %d\" " - "\"panel %d\" none \"ordinary\"] ", i, i); - if (i == 1) - grp_str = mms_strapp(grp_str, "slotgroup [\"group " - "cap0\" \"panel 1\" both \"port\"] "); - } - - acs_drives.acs_max_drive = SL3000_MAX_DRIVE; - lm.lm_drive = (void *)&acs_drives; - - free(acs_rsp); - - if ((bay_str && grp_str) != NULL) { - if ((snprintf(full_str, FSBUFSIZE, - SL3000_CONFIG, cmd_tid, bay_str, grp_str)) > FSBUFSIZE) { - mms_trace(MMS_ERR, "lm_library_config: buffer size"); - free(bay_str); - free(grp_str); - return (LM_ERROR); - } - } else { - mms_trace(MMS_ERR, "lm_library_config: bay_str and grp_str " - "null"); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_library_config: Bay, Group - %s", full_str); - - free(bay_str); - free(grp_str); - return (LM_OK); -} diff --git a/usr/src/lib/mms/lm/libsl3000/common/mapfile-vers b/usr/src/lib/mms/lm/libsl3000/common/mapfile-vers deleted file mode 100644 index 7774f583c0..0000000000 --- a/usr/src/lib/mms/lm/libsl3000/common/mapfile-vers +++ /dev/null @@ -1,79 +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. -# -# - -SUNWprivate_1.1 { - global: - lm_activate; - lm_barrier; - lm_cancel; - lm_eject; - lm_event; - lm_exit; - lm_inject; - lm_mount; - lm_move; - lm_private; - lm_reset; - lm_scan; - lm_unmount; - - acs_dismount = extern; - acs_display = extern; - acs_eject = extern; - acs_enter = extern; - acs_get_packet_version = extern; - acs_mount = extern; - acs_query_cap = extern; - acs_query_drive = extern; - acs_query_lsm = extern; - acs_query_mount = extern; - acs_query_server = extern; - acs_query_volume = extern; - acs_response = extern; - acs_state = extern; - acs_status = extern; - acs_type = extern; - acs_type_response = extern; - handle_lmpl_cmd_error = extern; - lm = extern; - lm_acc_mutex = extern; - lm_common_ready = extern; - lm_gen_lmpl_cmd = extern; - lm_internal_error = extern; - lm_message = extern; - lm_obtain_task_id = extern; - lm_remove_lmpl_cmd = extern; - lm_serr = extern; - lm_set_drive_disabled = extern; - lm_state = extern; - - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/lm/libsl3000/i386/Makefile b/usr/src/lib/mms/lm/libsl3000/i386/Makefile deleted file mode 100644 index d77b753d64..0000000000 --- a/usr/src/lib/mms/lm/libsl3000/i386/Makefile +++ /dev/null @@ -1,26 +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. -# -# -include ../Makefile.com diff --git a/usr/src/lib/mms/lm/libsl3000/sparc/Makefile b/usr/src/lib/mms/lm/libsl3000/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/lm/libsl3000/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/lm/libsl8500/Makefile b/usr/src/lib/mms/lm/libsl8500/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/lm/libsl8500/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/lm/libsl8500/Makefile.com b/usr/src/lib/mms/lm/libsl8500/Makefile.com deleted file mode 100644 index ad0066ab62..0000000000 --- a/usr/src/lib/mms/lm/libsl8500/Makefile.com +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -LIBRARY = libSL8500_net.a -VERS = -OBJS_COMMON = lm_sl8500.o -OBJS_SHARED = lm_acs_common.o lm_acs_display.o lm_comm.o lm_lcom.o - -OBJECTS = $(OBJS_COMMON) $(OBJS_SHARED) - -include $(SRC)/lib/Makefile.lib - -LIBLINKS = - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -LMDIR = $(SRC)/lib/mms/lm/libcommon - -SRCS = $(OBJS_COMMON:%.o=$(SRCDIR)/%.c) \ - $(OBJS_SHARED:%.o=$(LMDIR)/%.c) - -LDLIBS += -lc -LDLIBS += -L$(SRC)/lib/mms/mms/$(MACH) -lmms - -CFLAGS += $(CCVERBOSE) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/cmd/mms/lm/common -I../../../mms/common -CPPFLAGS += -I../../libcommon -I$(ACSLSH) -CPPFLAGS += -erroff=E_IMPLICIT_DECL_FUNC_RETURN_INT - -.KEEP_STATE: - -all: $(LIBS) - -lint: $(LINTLIB) lintcheck - -pics/%.o: $(LMDIR)/%.c - $(COMPILE.c) -o $@ $< - $(POST_PROCESS_O) - -include ../../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) diff --git a/usr/src/lib/mms/lm/libsl8500/common/lm_sl8500.c b/usr/src/lib/mms/lm/libsl8500/common/lm_sl8500.c deleted file mode 100644 index 5e3261eec9..0000000000 --- a/usr/src/lib/mms/lm/libsl8500/common/lm_sl8500.c +++ /dev/null @@ -1,146 +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. - */ - - -#include "lm_acs.h" - -#define SL8500_30 30 -#define SL8500_50 50 - -#define SL8500_MAX_DRIVE 2048 - -#define SL8500_CONFIG "config task [\"%d\"] scope [full] \ -%s %s;" - -#define SL8500_GROUP "slotgroup [\"group 1\" \"panel 1\" none \"ordinary\"] " - -static char *_SrcFile = __FILE__; - -static acs_cap_t acs_caps[MAX_SL8500_CAPS]; -static acs_drive_t acs_drives; - -/*ARGSUSED2*/ -int -lm_library_config_non_comm(int cmd_tid, char *full_str, char *tid, - char *ret_msg) -{ - int i; - int num_caps; - char cap_name[MAX_CAP_SIZE]; - char *bay_str = NULL; - char *grp_str = NULL; - - CAPID capid[MAX_ID]; - QU_CAP_STATUS *cs; - ACS_QUERY_CAP_RESPONSE *cp; - acs_rsp_ele_t *acs_rsp; - - lm.lm_caps = num_caps = 1; - lm.lm_lsms = 1; - - if (lm_num_panels(0, tid, ret_msg) != LM_OK) { - mms_trace(MMS_ERR, "lm_library_config: Unable to obtain " - "number of panels in SL8500 library"); - return (LM_ERROR); - } - - if ((lm_acs_query_cap(&acs_rsp, capid, "activate", tid, ret_msg)) == - LM_ERROR) { - mms_trace(MMS_ERR, "lm_library_config: query of number of caps " - "in SL8500 library failed"); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_library_config: Received final response for " - "acs_query_cap"); - - cp = (ACS_QUERY_CAP_RESPONSE *)acs_rsp->acs_rbuf; - if (cp->query_cap_status != STATUS_SUCCESS) { - mms_trace(MMS_ERR, "lm_library_config: response from " - "acs_query_cap() failed, defaulting to one cap " - ", status - %s", acs_status(cp->query_cap_status)); - return (LM_ERROR); - } - - for (num_caps = 0, i = 0; i < cp->count; i++) { - cs = &cp->cap_status[i]; - if (cs->cap_id.lsm_id.acs == lm.lm_acs) - num_caps++; - } - lm.lm_caps = num_caps; - - for (i = 0; i < MAX_SL8500_CAPS; i++) { - acs_caps[i].cap_size = MAX_SL8500_CAP_SIZE; - acs_caps[i].cap_capid = i; - (void) snprintf(cap_name, sizeof (cap_name), - "group cap%d", i); - (void) strlcpy(acs_caps[i].cap_name, cap_name, - sizeof (acs_caps[i].cap_name)); - if (i < num_caps) - acs_caps[i].cap_config = 1; - else - acs_caps[i].cap_config = 0; - } - - lm.lm_port = (void *)&acs_caps[0]; - - mms_trace(MMS_DEBUG, "lm_library_config: Number of caps for SL8500 " - "library - %d", num_caps); - - for (i = 1; i < lm.lm_panels; i++) - bay_str = mms_strapp(bay_str, "bay [\"panel %d\" true] ", i); - - for (i = 1; i < lm.lm_panels; i++) { - grp_str = mms_strapp(grp_str, "slotgroup [\"group %d\" " - "\"panel %d\" none \"ordinary\"] ", i, i); - if (i == 1) - grp_str = mms_strapp(grp_str, "slotgroup [\"group " - "cap0\" \"panel 1\" both \"port\"] "); - } - - acs_drives.acs_max_drive = SL8500_MAX_DRIVE; - lm.lm_drive = (void *)&acs_drives; - - free(acs_rsp); - - if ((bay_str && grp_str) != NULL) { - if ((snprintf(full_str, FSBUFSIZE, - SL8500_CONFIG, cmd_tid, bay_str, grp_str)) > FSBUFSIZE) { - mms_trace(MMS_ERR, "lm_library_config: buffer size"); - free(bay_str); - free(grp_str); - return (LM_ERROR); - } - } else { - mms_trace(MMS_ERR, "lm_library_config: bay_str and grp_str " - "null"); - return (LM_ERROR); - } - - mms_trace(MMS_DEBUG, "lm_library_config: Bay, Group - %s", full_str); - - free(bay_str); - free(grp_str); - return (LM_OK); -} diff --git a/usr/src/lib/mms/lm/libsl8500/common/mapfile-vers b/usr/src/lib/mms/lm/libsl8500/common/mapfile-vers deleted file mode 100644 index f5cbdde046..0000000000 --- a/usr/src/lib/mms/lm/libsl8500/common/mapfile-vers +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - lm_activate; - lm_barrier; - lm_cancel; - lm_eject; - lm_event; - lm_exit; - lm_inject; - lm_mount; - lm_move; - lm_private; - lm_reset; - lm_scan; - lm_unmount; - - acs_dismount = extern; - acs_display = extern; - acs_eject = extern; - acs_enter = extern; - acs_get_packet_version = extern; - acs_mount = extern; - acs_query_cap = extern; - acs_query_drive = extern; - acs_query_lsm = extern; - acs_query_mount = extern; - acs_query_server = extern; - acs_query_volume = extern; - acs_response = extern; - acs_state = extern; - acs_status = extern; - acs_type = extern; - acs_type_response = extern; - handle_lmpl_cmd_error = extern; - lm = extern; - lm_acc_mutex = extern; - lm_common_ready = extern; - lm_gen_lmpl_cmd = extern; - lm_internal_error = extern; - lm_message = extern; - lm_obtain_task_id = extern; - lm_remove_lmpl_cmd = extern; - lm_serr = extern; - lm_set_drive_disabled = extern; - lm_state = extern; - - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/lm/libsl8500/i386/Makefile b/usr/src/lib/mms/lm/libsl8500/i386/Makefile deleted file mode 100644 index d77b753d64..0000000000 --- a/usr/src/lib/mms/lm/libsl8500/i386/Makefile +++ /dev/null @@ -1,26 +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. -# -# -include ../Makefile.com diff --git a/usr/src/lib/mms/lm/libsl8500/sparc/Makefile b/usr/src/lib/mms/lm/libsl8500/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/lm/libsl8500/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/mgmt/Makefile b/usr/src/lib/mms/mgmt/Makefile deleted file mode 100644 index d94d0f267f..0000000000 --- a/usr/src/lib/mms/mgmt/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -include $(SRC)/lib/Makefile.lib -include ./Makefile.defs - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: - -include Makefile.rootdirs -include $(SRC)/lib/Makefile.targ diff --git a/usr/src/lib/mms/mgmt/Makefile.com b/usr/src/lib/mms/mgmt/Makefile.com deleted file mode 100644 index c9f5d37299..0000000000 --- a/usr/src/lib/mms/mgmt/Makefile.com +++ /dev/null @@ -1,75 +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. -# -# - -include $(SRC)/lib/Makefile.lib -include ../Makefile.defs - -LIBRARY = libmmsadm.a -VERS = .1 - -OBJECTS = mgmt_lib.o mgmt_media.o mgmt_dsk.o \ - mgmt_mmp.o mgmt_mmsdb.o mgmt_probe.o \ - mgmt_util.o mgmt_acsls.o mgmt_mm.o - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -SRCS = $(OBJECTS:%.o=$(SRCDIR)/%.c) - -LDLIBS += -lsocket -lc -LDLIBS += -lscf -lgen -lnvpair -lsecdb -LDLIBS += -L$(SRC)/lib/mms/mms/$(MACH) -lmms - -CFLAGS += $(CTF_FLAGS) $(CCVERBOSE) -CFLAGS += $(C_BIGPICFLAGS) - -DEBUGFORMAT = - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/lib/mms/mms/common -CPPFLAGS += -I$(SRC)/uts/common/io/mms/dda -CPPFLAGS += -I$(ACSLSH) -CPPFLAGS += -D_POSIX_PTHREAD_SEMANTICS - -C99MODE = $(C99_ENABLE) - -.KEEP_STATE: - -all: $(LIBS) $(LIBLINKS) - -lint: $(LINTLIB) lintcheck - -$(LIBLINKS): FRC - $(RM) $@; $(SYMLINK) $(DYNLIB) $@ - -FRC: - -include $(SRC)/lib/Makefile.targ -include ../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) $(ROOTLINKS) diff --git a/usr/src/lib/mms/mgmt/Makefile.defs b/usr/src/lib/mms/mgmt/Makefile.defs deleted file mode 100644 index 829f91a32f..0000000000 --- a/usr/src/lib/mms/mgmt/Makefile.defs +++ /dev/null @@ -1,28 +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. -# - -ROOTLIBDIR = $(ROOT)/usr/lib/mms - -ACSLSH = $(SRC)/common/mms/h diff --git a/usr/src/lib/mms/mgmt/Makefile.rootdirs b/usr/src/lib/mms/mgmt/Makefile.rootdirs deleted file mode 100644 index 5b19b1335d..0000000000 --- a/usr/src/lib/mms/mgmt/Makefile.rootdirs +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# Define the transitive set of rules to create a common module's install dir -# within the proto area. -# - -$(ROOTLIBDIR): - $(INS.dir) - diff --git a/usr/src/lib/mms/mgmt/common/mapfile-vers b/usr/src/lib/mms/mgmt/common/mapfile-vers deleted file mode 100644 index 10f086f6a3..0000000000 --- a/usr/src/lib/mms/mgmt/common/mapfile-vers +++ /dev/null @@ -1,109 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - create_mm_clnt; - free_acslib_list; - mgmt_db_dump; - mgmt_db_restore; - mgmt_find_local_drives; - mgmt_opt_to_var; - mgmt_set_str_or_arr; - mgmt_var_to_array; - mmp_get_nvattrs; - mms_add_drive; - mms_add_library; - mms_add_object; - mms_client_handle_rsp; - mms_gen_taskid; - mms_get_drive; - mms_list_free_and_destroy; - mms_mgmt_accept_request; - mms_mgmt_add_application; - mms_mgmt_add_cartridges; - mms_mgmt_add_dkvol; - mms_mgmt_add_dpool; - mms_mgmt_add_mpool; - mms_mgmt_add_voltype; - mms_mgmt_discover_libraries; - mms_mgmt_discover_media; - mms_mgmt_get_errstr; - mms_mgmt_get_opts; - mms_mgmt_get_pwd; - mms_mgmt_init_host; - mms_mgmt_label_multi; - mms_mgmt_list_drives; - mms_mgmt_list_libraries; - mms_mgmt_list_vols; - mms_mgmt_modify_application; - mms_mgmt_modify_dpool; - mms_mgmt_modify_mpool; - mms_mgmt_modify_voltype; - mms_mgmt_mount_vol; - mms_mgmt_reject_request; - mms_mgmt_remove_application; - mms_mgmt_remove_cartridges; - mms_mgmt_remove_dpool; - mms_mgmt_remove_mpool; - mms_mgmt_remove_partition; - mms_mgmt_remove_voltype; - mms_mgmt_send_cmd; - mms_mgmt_set_opts; - mms_mgmt_set_pass; - mms_mgmt_set_state; - mms_mgmt_set_vol_mode; - mms_mgmt_show_apps; - mms_mgmt_show_cartridge_type; - mms_mgmt_show_dpool; - mms_mgmt_show_mpool; - mms_mgmt_show_requests; - mms_mgmt_uninitialize; - mms_mgmt_unmount_vol; - mms_modify_drive; - mms_modify_library; - mms_remove_drive; - mms_remove_library; - val_objtype; - - local: - *; -}; diff --git a/usr/src/lib/mms/mgmt/common/mgmt_acsls.c b/usr/src/lib/mms/mgmt/common/mgmt_acsls.c deleted file mode 100644 index e7f56089e2..0000000000 --- a/usr/src/lib/mms/mgmt/common/mgmt_acsls.c +++ /dev/null @@ -1,839 +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. - */ - - -#include <errno.h> -#include <fcntl.h> -#include <libgen.h> -#include <netdb.h> -#include <procfs.h> -#include <pthread.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <ctype.h> -#include <dlfcn.h> - -#include "mgmt_acsls.h" -#include "mgmt_library.h" -#include "mgmt_media.h" -#include "mms_cfg.h" - -static char *_SrcFile = __FILE__; /* Using __FILE__ makes duplicate strings */ - -/* - * This code represents a ACS client application and communicates with the ACS - * library via the ACSAPI interface. ACSAPI procedures communicate via IPC - * with the SSI process running on this same client machine. Each client app - * can send multiple requests to the ACS Library Manager via this SSI. The SSI - * receives requests from one or more clients, places them on a queue, and sends - * the requests to the CSI to relay them to the ACS Library Manager. Multiple - * heterogeneous clients can communicate and manage the ACSLS Library via the - * same SSI. The SSI also relays the responses back to the appropriate client - * application. The CSI and SSI talk to each other via RPC. The same RPC program - * number is used for all instances of SSI and CSI connections. So there is a - * limitation that a client cannot connect to multiple ACSLS. - * - * The ACSAPI resides on the client machine as a set of three C language library - * object modules to be linked with a client application. These modules are the - * formal interface, and the functions that carry out the IPC for requests and - * responses. - * - */ - -static int acs_dlsym(void); - -pthread_mutex_t acs_mutex = PTHREAD_MUTEX_INITIALIZER; -static boolean_t acs_init = B_FALSE; -static STATUS (*dl_acs_display)(SEQ_NO, TYPE, DISPLAY_XML_DATA) = NULL; -static STATUS (*dl_acs_response)(int, SEQ_NO *, REQ_ID *, ACS_RESPONSE_TYPE *, - ALIGNED_BYTES) = NULL; - -/* Display configuration and status */ -static int acs_display_info(int query_type, char *cmdarg, mms_list_t *lst); -static int parse_drv_resp(void *buf, mms_list_t *lst); -static int parse_lsm_resp(void *buf, mms_list_t *lst); -static int parse_vol_resp(void *buf, mms_list_t *vol_list); -static int parse_f(char *f, char *s, size_t len); -static int parse_f_int(char *f, uint32_t *s); -static int parse_f_date(char *f, time_t *t); - -static acs_query_cmdresp_t acs_query_cmdresp_tbl[] = { - {ACS_DISPLAY_CAP, ACS_XMLREQ_CAP, NULL}, - {ACS_DISPLAY_CELL, ACS_XMLREQ_CELL, NULL}, - {ACS_DISPLAY_DRIVE, ACS_XMLREQ_DRIVE, parse_drv_resp}, - {ACS_DISPLAY_LOCK, ACS_XMLREQ_LOCK, NULL}, - {ACS_DISPLAY_LSM, ACS_XMLREQ_LSM, parse_lsm_resp}, - {ACS_DISPLAY_PANEL, ACS_XMLREQ_PANEL, NULL}, - {ACS_DISPLAY_POOL, ACS_XMLREQ_POOL, NULL}, - {ACS_DISPLAY_VOL, ACS_XMLREQ_VOL, parse_vol_resp}, - {ACS_DISPLAY_VOL_BY_MEDIA, ACS_XMLREQ_VOL_BY_MEDIA, NULL}, - {ACS_DISPLAY_VOL_CLEANING, ACS_XMLREQ_VOL_CLEANING, NULL}, - {ACS_DISPLAY_VOL_ACCESSED, ACS_XMLREQ_VOL_ACCESSED, NULL}, - {ACS_DISPLAY_VOL_ENTERED, ACS_XMLREQ_VOL_ENTERED, NULL}, - {ACS_DISPLAY_UNSUPPORTED, "", NULL} -}; - - -/* - * As ACSLS is a separate product, all functions must be retrieved - * using dlopen/dlsym(). Do it once for the duration of the exe. - */ -static int -acs_dlsym(void) -{ - int st = 0; - void *hdl = NULL; - char buf[2048]; - char acspath[2048]; - - st = mms_cfg_getvar(MMS_CFG_LIBAPI_PATH, acspath); - if (st != 0) { - return (st); - } - - (void) pthread_mutex_lock(&acs_mutex); - if (!acs_init) { - (void) snprintf(buf, sizeof (buf), "%s/%s", - acspath, "libapi.so"); - hdl = dlopen(buf, RTLD_LAZY); - if (hdl == NULL) { - /* not there, try the normal locations */ - hdl = dlopen("libapi.so", RTLD_LAZY); - if (hdl == NULL) { /* still no luck */ - (void) pthread_mutex_unlock(&acs_mutex); - return (MMS_MGMT_ACSLS_NOT_FOUND); - } - } - dl_acs_display = (STATUS (*)(SEQ_NO, TYPE, DISPLAY_XML_DATA)) - dlsym(hdl, "acs_display"); - - dl_acs_response = (STATUS (*)(int, SEQ_NO *, REQ_ID *, - ACS_RESPONSE_TYPE *, ALIGNED_BYTES))dlsym(hdl, - "acs_response"); - - if ((!dl_acs_display) || (!dl_acs_response)) { - st = MMS_MGMT_ACSLS_NOT_FOUND; - } else { - acs_init = B_TRUE; - } - } - (void) pthread_mutex_unlock(&acs_mutex); - - return (st); -} - -/* - * Interface to control the lifecycle of the SSI process and its children - * - * Any priviledged client of ACSLS can start the SSI process. The same process - * is to be used by all ACS clients on this machine to communicate within the - * ACSLS library. Do not start multiple SSI process. - * - * The envva ACSAPI_SSI_SOCKET is the local port number of the SSI - */ -int -acs_start_ssi(char *acshost, char *ssiport) -{ - int st; - mms_list_t proclist; - pid_t pid; - char env_acshost[NI_MAXHOST + 13]; /* CSI_HOSTNAME=<hostname> */ - char env_acsport[128]; - int status; - char acspath[2048]; - char ssibuf[1024]; - char sockbuf[1024]; - char *cmd[3]; - char *hostport; - - if (acshost == NULL) { - return (MMS_MGMT_NOARG); - } - - st = mms_cfg_getvar(MMS_CFG_SSI_PATH, acspath); - if (st != 0) { - return (st); - } - - (void) snprintf(ssibuf, sizeof (ssibuf), "%s/%s", acspath, "ssi"); - if (find_process(ssibuf, &proclist) == 0) { - if (!mms_list_empty(&proclist)) { - mms_list_free_and_destroy(&proclist, free); - return (0); - } - } - - (void) snprintf(env_acshost, sizeof (env_acshost), "CSI_HOSTNAME=%s", - acshost); - hostport = strrchr(env_acshost, ':'); - if (hostport != NULL) { - *hostport = '\0'; - hostport++; - /* don't set if we're using the default port */ - if (strcmp(hostport, "50004") == 0) { - hostport = NULL; - } - } - - if (hostport != NULL) { - (void) snprintf(env_acsport, sizeof (env_acsport), - "CSI_HOSTPORT=%s", hostport); - } - - (void) snprintf(ssibuf, sizeof (ssibuf), "MMS_SSI_PATH=%s", acspath); - - if (ssiport != NULL) { - (void) snprintf(sockbuf, sizeof (sockbuf), - "ACSAPI_SSI_SOCKET=%s", ssiport); - } else { - (void) snprintf(sockbuf, sizeof (sockbuf), - "ACSAPI_SSI_SOCKET=%s", "50004"); - } - - /* set required envvars */ - (void) putenv(env_acshost); - if (hostport != NULL) { - (void) putenv(env_acsport); - } - (void) putenv(sockbuf); - (void) putenv(ssibuf); - - cmd[0] = "/usr/bin/mmsssi.sh"; - cmd[1] = "1"; - cmd[2] = NULL; - - pid = exec_mgmt_cmd(NULL, NULL, 0, 0, B_TRUE, cmd); - mms_trace(MMS_DEBUG, "exec_mgmt_cmd: %s %s", cmd[0], cmd[1]); - - status = check_exit(pid, NULL); - - if (status != 0) { - mms_trace(MMS_ERR, - "Could not start ACSLS client daemon, exec status = %d", - status); - } - - return (status); -} - - -/* - * get the configuration of the acs library, given the name of the acsls - * hostname and port. - * - * If get_drives is TRUE, get information about drives as well as libraries - */ -int -get_acs_library_cfg( - char *acshost, - boolean_t get_drives, - mms_list_t *lsm_list -) -{ - int st; - char location[128]; - mms_acslib_t *lsm = NULL; - - if ((acshost == NULL) || (lsm_list == NULL)) { - return (MMS_MGMT_NOARG); - } - - mms_list_create(lsm_list, sizeof (mms_acslib_t), - offsetof(mms_acslib_t, lib_link)); - - /* check if the acsls host is accessible and start if it not */ - if (acs_start_ssi(acshost, NULL) != 0) { - return (MMS_MGMT_ERR_EXEC_SSI); - } - - /* get all the acs-lsm */ - st = acs_display_info(ACS_DISPLAY_LSM, NULL, lsm_list); - if (st != 0) { - return (st); - } - - if (get_drives) { - mms_list_foreach(lsm_list, lsm) { - /* get the drives in each library */ - (void) snprintf(location, sizeof (location), - "%d,%d,*,*", lsm->acs, lsm->lsm); - - st = acs_display_info(ACS_DISPLAY_DRIVE, location, - &lsm->drive_list); - if (st != 0) { - break; - } - } - } - - return (st); -} - -static int -wait_for_response( - int seq, - int (*parse_acs_resp)(void *, mms_list_t *), - mms_list_t *lst) -{ - - STATUS st; - SEQ_NO rseq; - REQ_ID reqid; - int ret; - ALIGNED_BYTES rbuf[MAX_MESSAGE_SIZE / sizeof (ALIGNED_BYTES)]; - ACS_RESPONSE_TYPE type; - - if ((parse_acs_resp == NULL) || (lst == NULL)) { - return (MMS_MGMT_NOARG); - } - - /* - * call acs_response() repeatedly until the FINAL packet for this - * request has been received - */ - do { - (void) memset(rbuf, 0, sizeof (rbuf)); - - st = dl_acs_response( - 10, /* Block for 10 seconds */ - &rseq, - &reqid, - &type, - rbuf); - - if (st == STATUS_IPC_FAILURE) { - return (MMS_MGMT_ERR_ACSLS_RSP); - } - - if (rseq != seq) { - mms_trace(MMS_ERR, "Invalid ACS Sequence number, %d", - rseq); - return (MMS_MGMT_ERR_ACSLS_RSP); - } - - if ((type == RT_INTERMEDIATE) || (type == RT_FINAL)) { - ret = parse_acs_resp(rbuf, lst); - if (ret != 0) { - ret = MMS_MGMT_ERR_ACSLS_PARSE; - break; - } - } - } while (type != RT_FINAL); - - return (ret); -} - - -/* - * To get the configuration of the components in an ACSLS library, or their - * status, use the 'display' command to create complex or detailed queries - * using XML as the Query language. The XML request is then sent to the SSI - * using the acs_display() ACSAPI and the responses are awaited and parsed. - * - * The SSI process must be running before this API can be used. - */ -int -acs_display_info( - int query_type, /* type of query */ - char *cmdarg, /* arguments for the XML request */ - mms_list_t *lst) /* response parsed as a list */ -{ - - int st = 0; - SEQ_NO seq; - DISPLAY_XML_DATA cmd; - char *s = "*"; - size_t len; - - if (lst == NULL) { - return (MMS_MGMT_NOARG); - } - - st = acs_dlsym(); - if (st != 0) { - return (st); - } - - if (cmdarg && (strlen(cmdarg) > 0)) { - s = cmdarg; - } - - /* LINTED [E_SEC_PRINTF_VAR_FMT] */ - len = snprintf(cmd.xml_data, sizeof (cmd.xml_data), - acs_query_cmdresp_tbl[query_type].xmlreq, s); - mms_trace(MMS_INFO, "DISPLAY cmd:\n%s", cmd.xml_data); - cmd.length = strlen(cmd.xml_data); - - if (len > MAX_XML_DATA_SIZE) { - return (ENAMETOOLONG); - } - - /* - * generate a sequence number, this uniquely identifies the response - * with the request. SEQ_NO is defined as a short int. - */ - seq = (SEQ_NO)(time(NULL)); - - if ((dl_acs_display(seq, TYPE_DISPLAY, cmd)) != STATUS_SUCCESS) { - return (MMS_MGMT_ERR_ACSLS_PARSE); - } - - st = wait_for_response(seq, (int (*)(void *, mms_list_t *)) - acs_query_cmdresp_tbl[query_type].parse_resp, lst); - - if (st != 0) { - mms_trace(MMS_INFO, "get acs display info failed %d", st); - return (st); - } else { - mms_trace(MMS_INFO, "get acs display info success"); - } - - return (st); -} - - -/* - * parse_drive_resp() assumes the format of the data response, the - * following information is expected in the drive data: - * acs, lsm, panel, drive, type, status, state and serial number - */ -static int -parse_drv_resp( - void *buf, - mms_list_t *drive_list) -{ - - ACS_DISPLAY_RESPONSE *res; - size_t l; - char *ptr1, *ptr2; - mms_drive_t *drive; - char junkbuf[1024]; - char xml_buf[MAX_MESSAGE_SIZE + 1]; - int len; - - if ((buf == NULL) || (drive_list == NULL)) { - return (MMS_MGMT_NOARG); - } - - res = (ACS_DISPLAY_RESPONSE *)buf; - if (res->display_status != STATUS_SUCCESS) { - return (MMS_MGMT_ERR_ACSLS_RSP); - } - - len = res->display_xml_data.length; - (void) strncpy(xml_buf, res->display_xml_data.xml_data, - len); - xml_buf[len] = '\0'; - mms_trace(MMS_INFO, "Display DRV response len = %d :\n%s", - len, xml_buf); - ptr1 = xml_buf; - - ptr2 = strstr(ptr1, "</data></display></response>"); - if (ptr2 != NULL) { - *ptr2 = NULL; - }; - - /* - * <r> marks the start of a drive entry, <f> marks the start of a field - * - * <r> - * <f maxlen="3">acs</f> - * <f maxlen="3">lsm</f> - * <f maxlen="5">panel</f> - * <f maxlen="5">drive</f> - * <f maxlen="9">status</f> - * <f maxlen="10">state</f> - * <f maxlen="6">volume</f> - * <f maxlen="9">type</f> - * <f maxlen="5">lock</f> - * <f maxlen="32">serial_num</f> - * <f maxlen="14">condition</f> - * </r> - */ - - if ((ptr2 = strstr(ptr1, "<data>")) != NULL) { - - if (drive_list->list_size == 0) { - mms_list_create(drive_list, sizeof (mms_drive_t), - offsetof(mms_drive_t, drive_link)); - } - - while ((ptr2 = strstr(ptr1, "<r>")) != NULL) { - - drive = calloc(1, sizeof (mms_drive_t)); - if (drive == NULL) { - return (ENOMEM); - } - - /* extract string from <f ....>..</f> */ - ptr2 += 3; /* skip past <r> */ - l = parse_f_int(ptr2, &drive->acs); - ptr2 += l; - l = parse_f_int(ptr2, &drive->lsm); - ptr2 += l; - l = parse_f_int(ptr2, &drive->panel); - ptr2 += l; - l = parse_f_int(ptr2, &drive->drive); - ptr2 += l; - /* properly convert flags and provide for volume */ - /* status */ - l = parse_f(ptr2, junkbuf, sizeof (junkbuf)); - ptr2 += l; - /* state */ - l = parse_f(ptr2, junkbuf, sizeof (junkbuf)); - ptr2 += l; - /* volume */ - l = parse_f(ptr2, drive->volid, sizeof (drive->volid)); - ptr2 += l; - l = parse_f(ptr2, drive->type, sizeof (drive->type)); - ptr2 += l; - /* lock */ - l = parse_f(ptr2, junkbuf, sizeof (junkbuf)); - ptr2 += l; - l = parse_f(ptr2, drive->serialnum, - sizeof (drive->serialnum)); - ptr2 += l; - /* condition */ - l = parse_f(ptr2, junkbuf, sizeof (junkbuf)); - ptr2 += l; - - mms_list_insert_tail(drive_list, drive); - - ptr2 += 4; /* advance to the start of the next drive */ - ptr1 = ptr2; - } - } - return (0); -} - - -/* - * parse_vol_resp() assumes the format of the data response, the - * following information is expected in the volume data: - * vol_id, acs, lsm, panel, row, column, pool, status, media, and type - */ -static int -parse_vol_resp(void *buf, mms_list_t *vol_list) -{ - - ACS_DISPLAY_RESPONSE *res; - size_t l; - char *ptr1, *ptr2; - mms_acscart_t *vol; - char junkbuf[1024]; - char xml_buf[MAX_MESSAGE_SIZE + 1]; - int len; - - if ((buf == NULL) || (vol_list == NULL)) { - return (MMS_MGMT_NOARG); - } - - res = (ACS_DISPLAY_RESPONSE *)buf; - if (res->display_status != STATUS_SUCCESS) { - return (MMS_MGMT_ERR_ACSLS_RSP); - } - - len = res->display_xml_data.length; - (void) strncpy(xml_buf, res->display_xml_data.xml_data, - len); - xml_buf[len] = '\0'; - mms_trace(MMS_INFO, "Display VOL response len = %d :\n%s", - len, xml_buf); - ptr1 = xml_buf; - - ptr2 = strstr(ptr1, "</data></display></response>"); - if (ptr2 != NULL) { - *ptr2 = NULL; - }; - if ((ptr2 = strstr(ptr1, "<data>")) != NULL) { - - /* only create the list if it's the first time through */ - if (vol_list->list_size == 0) { - mms_list_create(vol_list, sizeof (mms_acscart_t), - offsetof(mms_acscart_t, next)); - } - - while ((ptr2 = strstr(ptr1, "<r>")) != NULL) { - vol = calloc(1, sizeof (mms_acscart_t)); - if (vol == NULL) { - return (ENOMEM); - } - /* extract string from <f ....>..</f> */ - ptr2 += 3; /* skip past <r> */ - - l = parse_f(ptr2, vol->label, sizeof (vol->label)); - ptr2 += l; - l = parse_f_int(ptr2, (uint32_t *)&vol->libacs); - ptr2 += l; - l = parse_f_int(ptr2, (uint32_t *)&vol->liblsm); - ptr2 += l; - /* drive */ - l = parse_f(ptr2, junkbuf, sizeof (junkbuf)); - ptr2 += l; - /* type - cleaning|data */ - l = parse_f(ptr2, junkbuf, sizeof (junkbuf)); - ptr2 += l; - l = parse_f(ptr2, vol->mtype, sizeof (vol->mtype)); - ptr2 += l; - /* status */ - l = parse_f(ptr2, junkbuf, sizeof (junkbuf)); - ptr2 += l; - l = parse_f_date(ptr2, &vol->access); - ptr2 += l; - - mms_list_insert_tail(vol_list, vol); - - /* advance to the start of the next volume */ - ptr2 = strstr(ptr2, "</r>"); - if (ptr2 == NULL) { - /* malformed response */ - break; - } - ptr1 = ptr2 + 4; - } - } - return (0); -} - - -/* - * parse_lsm_resp() parses the response data assuming a particular - * format for the data. The following information is expected in the - * response:- acs, lsm, status, state and serial number - * - */ -static int -parse_lsm_resp( - void *buf, - mms_list_t *lsm_list) -{ - ACS_DISPLAY_RESPONSE *res; - size_t l; - char *ptr1, *ptr2; - mms_acslib_t *lsm; - char status[1024]; - char state[1024]; - char xml_buf[MAX_MESSAGE_SIZE + 1]; - int len; - - if ((buf == NULL) || (lsm_list == NULL)) { - return (MMS_MGMT_NOARG); - } - - res = (ACS_DISPLAY_RESPONSE *)buf; - if (res->display_status != STATUS_SUCCESS) { - return (MMS_MGMT_ERR_ACSLS_RSP); - } - - len = res->display_xml_data.length; - (void) strncpy(xml_buf, res->display_xml_data.xml_data, - len); - xml_buf[len] = '\0'; - mms_trace(MMS_INFO, "Display LSM response len = %d :\n%s", - len, xml_buf); - ptr1 = xml_buf; - - ptr2 = strstr(ptr1, "</data></display></response>"); - if (ptr2 != NULL) { - *ptr2 = NULL; - }; - - if ((ptr2 = strstr(ptr1, "<data>")) != NULL) { - if (lsm_list->list_size == 0) { - mms_list_create(lsm_list, sizeof (mms_acslib_t), - offsetof(mms_acslib_t, lib_link)); - } - - while ((ptr2 = strstr(ptr1, "<r>")) != NULL) { - - lsm = calloc(1, sizeof (mms_acslib_t)); - if (lsm == NULL) { - return (ENOMEM); - } - - ptr2 += 3; /* skip past <r> */ - l = parse_f_int(ptr2, &lsm->acs); - ptr2 += l; - l = parse_f_int(ptr2, &lsm->lsm); - ptr2 += l; - /* parse status and state to flags */ - l = parse_f(ptr2, status, sizeof (status)); - ptr2 += l; - l = parse_f(ptr2, state, sizeof (state)); - ptr2 += l; - l = parse_f(ptr2, lsm->serialnum, - sizeof (lsm->serialnum)); - ptr2 += l; - l = parse_f(ptr2, lsm->type, sizeof (lsm->type)); - ptr2 += l; - - mms_list_insert_tail(lsm_list, lsm); - - /* advance to the start of the next drive */ - ptr2 = strstr(ptr2, "</r>"); - if (ptr2 == NULL) { - /* malformed response */ - break; - } - ptr1 = ptr2 + 4; - } - } - return (0); -} - -static int /* return number of characters parsed */ -parse_f(char *f, char *s, size_t len) { - - size_t n; - char *ptr; - - if (f == NULL || strlen(f) == 0) { - return (0); - } - - ptr = strstr(f, "</f>"); - if (ptr != NULL) { - *ptr = '\0'; - } - n = strlen(f); - - ptr = strchr(f, '>'); - if (ptr == NULL) { - return (0); - } - - ptr++; - - (void) strlcpy(s, ptr, len); - - return (n + 4); -} - -/* parse just a single char */ -static int -parse_f_int(char *f, uint32_t *i) -{ - char *ptr; - char *ptr2; - size_t n; - char buf[4]; - int j; - - if (!f || !i) { - return (0); - } - - ptr = strchr(f, '>'); - if (ptr == NULL) { - return (0); - } - - ptr++; - - for (j = 0; j < 4; j++, ptr++) { - if (!isdigit(*ptr)) { - break; - } - buf[j] = *ptr; - } - buf[j] = '\0'; - ptr2 = strchr(ptr, '>'); - if (ptr2 == NULL) { - return (0); - } - n = (++ptr2 - f); - - *i = atoi(buf); - - return (n); -} - -static int -parse_f_date(char *f, time_t *t) -{ - struct tm tm; - char *ptr; - size_t n; - - if (!f || !t) { - return (0); - } - - ptr = strchr(f, '>'); - if (ptr == NULL) { - return (0); - } - - ptr++; - - ptr = strptime(ptr, "%Y-%m-%d %T", &tm); - - ptr = strstr(ptr, "</f>"); - if (ptr == NULL) { - return (0); - } - ptr += 4; - - n = ptr - f; - - *t = mktime(&tm); -return (n); -} - -/* - * get volumes from an acs library, given the name of the acsls - * hostname and port. - * - * in_vols is optional, allows the requester to ask for only - * those volumes he/she is interested in. - * - */ -int -get_acs_volumes( - char *acshost, - char *in_vols, - mms_list_t *vol_list -) -{ - int st; - - if ((acshost == NULL) || (vol_list == NULL)) { - return (MMS_MGMT_NOARG); - } - - /* check if the acsls host is accessible and start if it not */ - if (acs_start_ssi(acshost, NULL) != 0) { - return (MMS_MGMT_ERR_EXEC_SSI); - } - - st = acs_display_info(ACS_DISPLAY_VOL, in_vols, vol_list); - if (st != 0) { - return (st); - } - - return (st); -} diff --git a/usr/src/lib/mms/mgmt/common/mgmt_acsls.h b/usr/src/lib/mms/mgmt/common/mgmt_acsls.h deleted file mode 100644 index 9e71c31978..0000000000 --- a/usr/src/lib/mms/mgmt/common/mgmt_acsls.h +++ /dev/null @@ -1,181 +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 _MMS_MGMT_ACSLS_H -#define _MMS_MGMT_ACSLS_H - - -#include <stdio.h> -#include <sys/nvpair.h> - -#include "mms.h" -#include "mgmt_util.h" -#include "acssys.h" -#include "acsapi.h" - -/* - * Comunication with the library and media that are controlled by the STK ACSLS - * software is done via the ACSAPI interface. ACSAPI procedures communicate via - * IPC with the SSI process running on the client machine. Each client can send - * multiple requests to the ACS Library Manager via this SSI. The SSI receives - * requests from one or more clients, places them on a queue, and sends these - * requests to the CSI to relay them to the ACS Library Manager. Multiple - * heterogeneous clients can communicate and manage the ACSLS Library via the - * same SSI. The SSI also relays the responses back to the appropriate client - * application. The CSI and SSI talk to each other via RPC. The same RPC program - * number is used for all instances of SSI and CSI connections. So there is a - * limitation that a client cannot connect to multiple ACSLS. - * - * The client code has to be compiled with the ACS header files and linked with - * -lapi - */ - -/* - * ---------------------------------------------------------------------------- - * STK ACSLS PROCESS COMMUNICATION - * ---------------------------------------------------------------------------- - */ - -/* - * acs_start_ssi() - * - * Parameters: - * - acs_host host:port on which the ACSLS software is installed - * - ssiport optional, specify the local port for the SSI daemon - * to listen on for requests. - * - * This function starts the STK ACSLS daemon (ssi) to communicate remotely with - * the ACSLS software that is controlling the library and media - */ -int acs_start_ssi(char *acs_host, char *ssiport); - -/* - * ---------------------------------------------------------------------------- - * STK ACSLS DISPLAY CONFIGURATION AND STATUS - * ---------------------------------------------------------------------------- - */ -typedef enum { - ACS_DISPLAY_CAP = 0, - ACS_DISPLAY_CELL = 1, - ACS_DISPLAY_DRIVE = 2, - ACS_DISPLAY_LOCK = 3, - ACS_DISPLAY_LSM = 4, - ACS_DISPLAY_PANEL = 5, - ACS_DISPLAY_POOL = 6, - ACS_DISPLAY_VOL = 7, - ACS_DISPLAY_VOL_BY_MEDIA = 8, - ACS_DISPLAY_VOL_CLEANING = 9, - ACS_DISPLAY_VOL_ACCESSED = 10, - ACS_DISPLAY_VOL_ENTERED = 11, - ACS_DISPLAY_UNSUPPORTED = 12 -} acs_query_type_t; - -#define ACS_XMLREQ_CAP "<request type='DISPLAY'><display>" \ - "<token>display</token><token>cap</token><token>%s</token>" \ - "<token>-f</token><token>acs</token><token>lsm</token>" \ - "<token>cap</token>" \ - "</display></request>" - -#define ACS_XMLREQ_CELL "<request type='DISPLAY'><display>" \ - "<token>display</token><token>cell</token><token>%s</token>" \ - "<token>-f</token><token>status</token>" \ - "</display></request>" - -#define ACS_XMLREQ_DRIVE "<request type='DISPLAY'><display>" \ - "<token>display</token><token>drive</token><token>%s</token>" \ - "<token>-f</token><token>status</token><token>state</token>" \ - "<token>volume</token><token>type</token><token>lock</token>" \ - "<token>serial_num</token><token>condition</token>" \ - "</display></request>" - -#define ACS_XMLREQ_LOCK "<request type='DISPLAY'><display>" \ - "<token>display</token><token>lock</token><token>%s</token>" \ - "</display></request>" - -#define ACS_XMLREQ_LSM "<request type='DISPLAY'><display>" \ - "<token>display</token><token>lsm</token><token>%s</token>" \ - "<token>-f</token><token>status</token><token>state</token>" \ - "<token>serial_num</token><token>type</token>" \ - "</display></request>" - -#define ACS_XMLREQ_PANEL "<request type='DISPLAY'><display>" \ - "<token>display</token><token>panel</token><token>%s</token>" \ - "</display></request>" - -#define ACS_XMLREQ_POOL "<request type='DISPLAY'><display>" \ - "<token>display</token><token>pool</token><token>%s</token>" \ - "</display></request>" - -#define ACS_XMLREQ_VOL "<request type='DISPLAY'><display>" \ - "<token>display</token><token>volume</token><token>%s</token>" \ - "<token>-f</token><token>vol_id</token><token>acs</token>" \ - "<token>lsm</token><token>drive</token><token>type</token>" \ - "<token>media</token><token>status</token><token>access_date</token>" \ - "</display></request>" - -#define ACS_XMLREQ_VOL_BY_MEDIA "<request type='DISPLAY'><display>" \ - "<token>display</token><token>volume</token><token>*</token>" \ - "<token>-media</token><token>%s</token>" \ - "</display></request>" - -#define ACS_XMLREQ_VOL_CLEANING "<request type='DISPLAY'><display>" \ - "<token>display</token><token>volume</token><token>%s</token>" \ - "<token>-clean</token>" \ - "</display></request>" - -#define ACS_XMLREQ_VOL_ACCESSED "<request type='DISPLAY'><display>" \ - "<token>display</token><token>volume</token><token>*</token>" \ - "<token>-access</token><token>%s</token>" \ - "</display></request>" - -#define ACS_XMLREQ_VOL_ENTERED "<request type='DISPLAY'><display>" \ - "<token>display</token><token>volume</token><token>*</token>" \ - "<token>-entry</token><token>%s</token>" \ - "</display></request>" - -typedef struct acs_query_cmdresp_s { - int query_type; - char *xmlreq; - int (*parse_resp)(void *, mms_list_t *); -} acs_query_cmdresp_t; - - -typedef struct acs_param { - char hostname[MAXHOSTNAMELEN]; - int32_t port; - char user[MAXNAMELEN]; - char ssi_hostname[MAXHOSTNAMELEN]; - int32_t ssi_port; - char csi_hostname[MAXHOSTNAMELEN]; - int32_t csi_port; - int32_t id; /* acs number */ -} acs_param_t; - -int -get_acs_library_cfg(char *acshost, boolean_t get_drives, mms_list_t *lib_list); - -int -get_acs_volumes(char *acshost, char *in_vols, mms_list_t *vol_list); - -#endif /* _MMS_MGMT_ACSLS_H */ diff --git a/usr/src/lib/mms/mgmt/common/mgmt_dsk.c b/usr/src/lib/mms/mgmt/common/mgmt_dsk.c deleted file mode 100644 index a02d3f0bf4..0000000000 --- a/usr/src/lib/mms/mgmt/common/mgmt_dsk.c +++ /dev/null @@ -1,1214 +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. - */ - - -#include <libgen.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/nvpair.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <dirent.h> -#include <sys/param.h> - -#include "mms_mgmt.h" -#include "mmp_defs.h" -#include "mgmt_sym.h" -#include "mgmt_util.h" -#include "mms_cfg.h" -#include "dda.h" - -static char *_SrcFile = __FILE__; -#define HERE _SrcFile, __LINE__ - -extern mms_mgmt_setopt_t dklibopts[]; - -static int -mgmt_create_dkvol(char *path, uint64_t volsz, nvlist_t *errs); - -static int -mgmt_get_dklibname(void *session, char *libname, nvlist_t **lib) -{ - int st; - void *sess = NULL; - void *sessp = session; - void *response; - char tid[64]; - char cmd[8192]; - - if (!lib) { - return (MMS_MGMT_NOARG); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - *lib = NULL; - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] " - "match[and( " - "streq(LIBRARY.'LibraryName' '%s') " - "streq(LIBRARY.'LibraryType' 'DISK'))] " - "report[LIBRARY.'LibraryName' LIBRARY.'DefaultLibraryPath'] " - "reportmode[namevalue]; ", tid, libname); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "mgmt_get_lib", - &response); - if (st == 0) { - st = mmp_get_nvattrs("LibraryName", B_FALSE, response, - lib); - mms_free_rsp(response); - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -/* - * mms_mgmt_add_dklib() - * - * Single library for _all_ disk volumes. Added automatically - * the first time a disk virtual drive or disk volume is created. - * - */ -int -mms_mgmt_create_dklib(void *session, nvlist_t *lib, nvlist_t *errs) -{ - int st; - void *sess = NULL; - void *sessp = session; - void *response; - char tid[64]; - char cmd[8192]; - int len = sizeof (cmd); - char buf[1024]; - char libpath[PATH_MAX]; - nvlist_t *dklib = NULL; - nvlist_t *nva = NULL; - char mmhost[NI_MAXHOST + NI_MAXSERV + 2]; /* ':' + nul */ - char *libname = NULL; - char *dfltpath = NULL; - char **altpath = NULL; - char *pp = NULL; - int i; - int j; - int count = 0; - char *host = NULL; - - if (!mgmt_chk_auth("solaris.mms.create")) { - return (EACCES); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - st = mms_cfg_getvar(MMS_CFG_MGR_HOST, mmhost); - if (st == 0) { - if (mgmt_compare_hosts(mmhost, "localhost") == 0) { - st = gethostname(mmhost, sizeof (mmhost)); - } - } - if (st != 0) { - st = MMS_MGMT_NO_MMHOST; - return (st); - } - - /* - * Get dkpath of library - */ - st = nvlist_lookup_string(lib, "dkpath", &dfltpath); - if (st != 0) { - MGMT_ADD_OPTERR(errs, "dkpath", st); - return (st); - } - if (dfltpath[0] != '/') { - st = MMS_MGMT_INVALID_PATH; - return (st); - } - for (j = strlen(dfltpath) - 1; j > 0 && dfltpath[j] == '/'; j--) { - dfltpath[j] = '\0'; - } - - /* - * Get library name - */ - st = nvlist_lookup_string(lib, O_NAME, &libname); - if (st != 0) { - /* No libraryname */ - if (st == ENOENT) { - st = MMS_MGMT_ERR_REQUIRED; - MGMT_ADD_OPTERR(errs, "library", st); - } - return (st); - } - /* - * Find connection - where the LM is going to run - */ - st = nvlist_lookup_string(lib, O_HOST, &host); - if (st != 0) { - /* host not specified, default to mmhost */ - host = mmhost; - } - - st = mgmt_get_dklibname(sessp, libname, &dklib); - if (st != 0) { - return (st); - } - - if (nvlist_exists(dklib, libname)) { - /* already there, tell caller */ - st = MMS_MGMT_LIB_EXISTS; - return (st); - } - - /* - * Build librarypath - */ - - (void) snprintf(libpath, sizeof (libpath), - "%s/%s", dfltpath, libname); - - st = create_mmp_clause("LIBRARY", dklibopts, lib, errs, cmd, len); - if (st != 0) { - goto done; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "create task['%s'] type[LIBRARY] " - "set[LIBRARY.'LibraryName' '%s'] " - "set[LIBRARY.'DefaultLibraryPath' '%s'] " - "set[LIBRARY.'LibraryType' 'DISK'];", - tid, libname, libpath); - st = mms_mgmt_send_cmd(sessp, tid, cmd, "add disk library", - &response); - - if (st != 0) { - goto done; - } - - (void) snprintf(buf, sizeof (buf), "LM_%s", libname); - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "create task['%s'] type[LM] " - "set[LM.'LMName' '%s'] " - "set[LM.'LibraryName' '%s'] " - "set[LM.'LMTargetHost' '%s'];", - tid, buf, libname, host); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "add disk LM", - &response); - if (st != 0) { - goto done; - } - - /* - * Add LIBRARYACCESS with altpaths - */ - - /* - * altpath specifies a list of one or more host and path specs. - */ - altpath = mgmt_var_to_array(lib, "dkaltpath", &count); - for (i = 0; i < count; i++) { - /* Break each entry into hostname and path */ - if ((pp = strchr(altpath[i], '@')) == NULL) { - /* Not hostname@path */ - st = MMS_MGMT_INV_HOSTPATH; - goto done; - } - pp[0] = '\0'; - pp++; - if (pp[0] != '/') { - /* Not hostname@path */ - st = MMS_MGMT_INV_HOSTPATH; - goto done; - } - for (j = strlen(pp) - 1; j > 0 && pp[j] == '/'; j--) { - pp[j] = '\0'; - } - - /* append libname to path */ - (void) snprintf(libpath, sizeof (libpath), - "%s/%s", pp, libname); - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "create task['%s'] " - "type[LIBRARYACCESS] " - "set[LIBRARYACCESS.'LibraryName' '%s'] " - "set[LIBRARYACCESS.'HostName' '%s'] " - "set[LIBRARYACCESS.'LibraryPath' '%s'] " - ";", - tid, libname, altpath[i], libpath); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, - "add disk library", - &response); - if (st != 0) { - goto done; - } - } - - if (st == 0) { - /* online this library */ - st = nvlist_alloc(&nva, NV_UNIQUE_NAME, 0); - if (st != 0) { - goto done1; - } - (void) nvlist_add_string(nva, O_OBJSTATE, "online"); - (void) nvlist_add_string(nva, O_OBJTYPE, "library"); - (void) nvlist_add_string(nva, O_NAME, libname); - - st = mms_mgmt_set_state(sessp, nva, errs); - nvlist_free(nva); - if (st != 0) { - goto done1; - } - } - -done: - if (st != 0) { - /* had an error */ - (void) mms_remove_library(sessp, lib, errs); - } -done1: - if (sess) { - (void) mms_goodbye(sess, 0); - } - return (st); -} - -int -mgmt_get_drvgrp(void *session, char *grpname, nvlist_t **drvgrp) -{ - int st; - void *sess = NULL; - void *sessp = session; - void *response; - char tid[64]; - char cmd[8192]; - - if (!drvgrp) { - return (MMS_MGMT_NOARG); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - *drvgrp = NULL; - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] " - "match[streq(DRIVEGROUP.'DriveGroupName' '%s')] " - "report[DRIVEGROUP.'DriveGroupName'] " - "reportmode[namevalue]; ", tid, grpname); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "get drivegroup", - &response); - if (st == 0) { - st = mmp_get_nvattrs("DriveGroupName", B_FALSE, response, - drvgrp); - mms_free_rsp(response); - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -void -mms_mgmt_add_vol_cleanup(void *session, char *pcl, char *lib) -{ - void *sess = NULL; - void *sessp = session; - void *response; - char cmd[8192]; - char tid[64]; - int st; - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return; - } - sessp = sess; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] " - "match[and (streq(CARTRIDGE.'CartridgePCL' '%s') " - "streq(CARTRIDGE.'LibraryName' '%s'))] " - "type[PARTITION];", - tid, pcl, lib); - (void) mms_mgmt_send_cmd(sessp, tid, cmd, - "delete partition", - &response); - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] " - "match[and (streq(CARTRIDGE.'CartridgePCL' '%s') " - "streq(CARTRIDGE.'LibraryName' '%s'))] " - "type[CARTRIDGE];", - tid, pcl, lib); - (void) mms_mgmt_send_cmd(sessp, tid, cmd, - "delete cartridge", - &response); - - if (sess) { - (void) mms_goodbye(sess, 0); - } - -} - -int -mms_mgmt_add_dkvol(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - void *sess = NULL; - void *sessp = session; - void *response; - char tid[64]; - char cmd[8192]; - char *val = NULL; - char **pclarr = NULL; - uint64_t sz = 0; - char *libname = NULL; - char *mpool = NULL; - char volpath[MAXPATHLEN + 1]; - nvlist_t *dklib = NULL; - nvlist_t *lib = NULL; - nvlist_t *cg = NULL; - char thishost[1024]; - char *dfltpath = NULL; - int count = 0; - int i; - int st_save = 0; - char *rwmode = "readwrite"; - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - mms_trace(MMS_DEBUG, "add dkvol"); - - if (!mgmt_chk_auth("solaris.mms.create")) { - return (EACCES); - } - - st = nvlist_lookup_string(nvl, O_NAME, &mpool); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - st = nvlist_lookup_string(nvl, O_SIZE, &val); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_SIZE, st); - return (st); - } - - st = do_val_mms_size(val, &sz); - if ((st == 0) && (sz == 0)) { - st = EINVAL; - } else if (sz < 1024 * 1024) { - sz = 1024 * 1024; - } - - st = nvlist_lookup_string(nvl, "readonly", &rwmode); - if (st == 0) { - if (strcmp(rwmode, "true") == 0) { - rwmode = "readonly"; - } else if (strcmp(rwmode, "false") == 0) { - rwmode = "readwrite"; - } else { - st = MMS_MGMT_INVALID_READONLY; - MGMT_ADD_OPTERR(errs, "readonly", st); - return (st); - } - } - - pclarr = mgmt_var_to_array(nvl, O_VOLUMES, &count); - if (pclarr == NULL) { - st = ENOENT; - MGMT_ADD_OPTERR(errs, O_VOLUMES, st); - return (st); - } - - st = gethostname(thishost, sizeof (thishost)); - if (st != 0) { - st = errno; - MGMT_ADD_ERR(errs, "hostname", st); - return (st); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - st = mgmt_get_cgname(sessp, mpool, &cg); - if (st != 0) { - goto done; - } - - if (!nvlist_exists(cg, mpool)) { - st = MMS_MGMT_CG_NOT_EXIST; - goto done; - } - - (void) nvlist_lookup_string(nvl, O_MMSLIB, &libname); - if (!libname) { - goto done; - } - - st = mgmt_get_dklibname(sessp, libname, &dklib); - if (st != 0) { - goto done; - } - - if (!nvlist_exists(dklib, libname)) { - st = MMS_MGMT_LIB_NOT_EXIST; - goto done; - } - - st = nvlist_lookup_nvlist(dklib, libname, &lib); - if (st != 0) { - st = MMS_MGMT_LIB_NOT_EXIST; - goto done; - } - st = nvlist_lookup_string(lib, "DefaultLibraryPath", &dfltpath); - if (st != 0) { - st = MMS_MGMT_DFLTPATH_ERR; - goto done; - } - - for (i = 0; i < count; i++) { - /* add the cartridge to MMS */ - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "create task['%s'] type[CARTRIDGE] " - "set[CARTRIDGE.'CartridgePCL' '%s'] " - "set[CARTRIDGE.'CartridgeTypeName' 'DISK'] " - "set[CARTRIDGE.'CartridgeGroupName' '%s'] " - "set[CARTRIDGE.'LibraryName' '%s'] " - ";", - tid, pclarr[i], mpool, libname); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "create dkvol", - &response); - - if (st != 0) { - /* can't do this one */ - MGMT_ADD_ERR(errs, pclarr[i], st); - st_save = MMS_MGMT_CREATE_CART_ERR; - continue; - } - - /* create the partition */ - st = mms_mgmt_create_partition(sessp, - pclarr[i], sz, libname, rwmode, errs); - if (st != 0) { - MGMT_ADD_ERR(errs, pclarr[i], st); - st_save = MMS_MGMT_CREATE_PART_ERR; - mms_mgmt_add_vol_cleanup(sessp, pclarr[i], libname); - continue; - } - - /* Create the disk files */ - (void) snprintf(volpath, sizeof (volpath), "%s/%s", - dfltpath, pclarr[i]); - st = mgmt_create_dkvol(volpath, sz, errs); - if (st != 0) { - mms_mgmt_add_vol_cleanup(sessp, pclarr[i], libname); - continue; - } - } - -done: - if (sess) { - (void) mms_goodbye(sess, 0); - } - - if (dklib) { - nvlist_free(dklib); - } - - return (st_save == 0 ? st : st_save); -} - -static int -mgmt_create_dkvol(char *fname, uint64_t volsz, nvlist_t *errs) -{ - int st; - int fd = -1; - char dname[MAXPATHLEN + 1]; - dda_metadata_t metadata; - dda_metadata_t out_metadata; - dda_index_t idx; - dda_index_t out_idx; - struct stat64 sbuf; - struct statvfs64 vbuf; - char pbuf[MAXPATHLEN + 1]; - size_t rlen; - - if (!fname || (volsz == 0)) { - return (MMS_MGMT_NOARG); - } - - (void) memset(&metadata, 0, sizeof (dda_metadata_t)); - (void) memset(&idx, 0, sizeof (dda_index_t)); - (void) memset(pbuf, 0, sizeof (pbuf)); - - st = stat64(fname, &sbuf); - if (st == 0) { - st = EEXIST; - MGMT_ADD_ERR(errs, fname, st); - return (st); - } - - st = stat64(fname, &sbuf); - if (st == 0) { - if (!S_ISDIR(sbuf.st_mode)) { - st = ENOTDIR; - } - } else if ((st = errno) == ENOENT) { - st = mkdirp(fname, 0740); - if (st == 0) { - /* TODO: set to root:bin for now */ - (void) realpath(fname, pbuf); - if (pbuf[0] == NULL) { - st = errno; - } else { - st = chown(fname, 0, 2); - } - } - } - if (st != 0) { - MGMT_ADD_ERR(errs, fname, st); - return (st); - } - - st = statvfs64(fname, &vbuf); - if (st == 0) { - if (volsz > (vbuf.f_bsize * vbuf.f_bfree)) { - st = ENOSPC; - } - } else { - st = errno; - } - - if (st != 0) { - MGMT_ADD_ERR(errs, fname, st); - return (st); - } - - /* - * Create the data file. TODO: reserve space?? - */ - (void) snprintf(dname, sizeof (dname), "%s/%s", fname, DDA_DATA_FNAME); - fd = open64(dname, O_CREAT|O_EXCL|O_RDWR|O_LARGEFILE, 0640); - if (fd == -1) { - st = errno; - MGMT_ADD_ERR(errs, dname, st); - return (st); - } - - (void) directio(fd, DIRECTIO_ON); - /* TODO: Fix this ownership too */ - (void) fchown(fd, 0, 2); - (void) close(fd); - - /* - * Create the metadata file - */ - metadata.dda_version.dda_major = DDA_MAJOR_VERSION; - metadata.dda_version.dda_minor = DDA_MINOR_VERSION; - metadata.dda_capacity = volsz; - /* always adjust data file offset for direct I/O */ - metadata.dda_sector = DEV_BSIZE; - - DDA_BE_METADATA(metadata, out_metadata); /* to big endian */ - - (void) snprintf(dname, sizeof (dname), "%s/%s", fname, - DDA_METADATA_FNAME); - fd = open64(dname, O_CREAT|O_EXCL|O_RDWR, 0640); - if (fd == -1) { - st = errno; - MGMT_ADD_ERR(errs, dname, st); - return (st); - } - (void) fchown(fd, 0, 2); - - rlen = write_buf(fd, &out_metadata, sizeof (dda_metadata_t)); - if (rlen != sizeof (dda_metadata_t)) { - st = EIO; - MGMT_ADD_ERR(errs, dname, st); - (void) close(fd); - return (st); - } - (void) close(fd); - - /* Create the index file containing one empty record */ - (void) snprintf(dname, sizeof (dname), "%s/%s", fname, DDA_INDEX_FNAME); - fd = open(dname, O_CREAT|O_EXCL|O_RDWR, 0640); - if (fd == -1) { - st = errno; - MGMT_ADD_ERR(errs, dname, st); - return (st); - } - (void) fchown(fd, 0, 2); - - DDA_BE_INDEX(idx, out_idx); /* convert to big endian */ - rlen = write_buf(fd, &out_idx, sizeof (dda_index_t)); - if (rlen != sizeof (dda_index_t)) { - st = EIO; - MGMT_ADD_ERR(errs, dname, st); - (void) close(fd); - return (st); - } - - return (0); -} - -int -mms_mgmt_create_dkdrive(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - void *sess = NULL; - void *sessp = session; - void *response; - char tid[64]; - char cmd[8192]; - char buf[1024]; - DIR *dirp = NULL; - struct dirent *ent; - char thishost[1024]; - char *dname = NULL; - char ddadev[1024]; - nvlist_t *drvs = NULL; - nvlist_t *dklib = NULL; - nvlist_t *dg = NULL; - char *libname = NULL; - char *dgname = NULL; - char *val = NULL; - char **apps = NULL; - int count = 0; - - if (!mgmt_chk_auth("solaris.mms.create")) { - return (EACCES); - } - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - st = nvlist_lookup_string(nvl, O_NAME, &dname); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - (void) nvlist_lookup_string(nvl, O_MMSLIB, &libname); - if (!libname) { - MGMT_ADD_OPTERR(errs, "library", st); - goto done; - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - goto done; - } - sessp = sess; - } - - st = mgmt_get_dklibname(sessp, libname, &dklib); - if (st != 0) { - goto done; - } - - if (!nvlist_exists(dklib, libname)) { - st = MMS_MGMT_LIB_NOT_EXIST; - goto done; - } - - (void) nvlist_lookup_string(nvl, O_DPOOL, &dgname); - if (!dgname) { - MGMT_ADD_OPTERR(errs, "dpool", st); - goto done; - } - - st = mgmt_get_dgname(sessp, dgname, &dg); - if (st != 0) { - goto done; - } - - if (!nvlist_exists(dg, dgname)) { - st = MMS_MGMT_DG_NOT_EXIST; - goto done; - } - - dirp = opendir("/dev/dda"); - if (dirp == NULL) { - st = errno; - goto done; - } - - st = gethostname(thishost, sizeof (thishost)); - if (st != 0) { - st = errno; - MGMT_ADD_ERR(errs, "hostname", st); - (void) closedir(dirp); - goto done; - } - - /* fetch dkdrives already configured, if any */ - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] " - "report[DM.'DMTargetPath' DM.'DMTargetHost' " - "DRIVE.'DriveName'] " - "match[streq(DM.'DMTargetHost' '%s')];", - tid, thishost); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "lookup drive devs", - &response); - if (st == 0) { - st = mmp_get_nvattrs("DMTargetPath", B_FALSE, response, - &drvs); - mms_free_rsp(response); - } - - ddadev[0] = '\0'; - - ent = NULL; - while ((ent = readdir(dirp)) != NULL) { - if (ent->d_name[0] == '.') { - continue; - } - - (void) snprintf(ddadev, sizeof (ddadev), "/dev/dda/%s", - ent->d_name); - - if (nvlist_exists(drvs, ddadev)) { - /* already used */ - ddadev[0] = '\0'; - continue; - } - - break; - } - (void) closedir(dirp); - - if (ddadev[0] == '\0') { - st = ENODEV; - goto done; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "create task['%s'] type[DRIVE] " - "set[DRIVE.'DriveName' '%s'] " - "set[DRIVE.'DriveGroupName' '%s'] " - "set[DRIVE.'LibraryName' '%s'] " - "set[DRIVE.'ReserveDrive' 'no'] " - "set[DRIVE.'DriveGeometry' '%s']", - tid, dname, dgname, libname, dname); - - st = nvlist_lookup_string(nvl, O_MSGLEVEL, &val); - if (st == 0) { - (void) snprintf(buf, sizeof (buf), - " set[DRIVE.'MessageLevel' '%s']", - val); - (void) strlcat(cmd, buf, sizeof (cmd)); - } - st = nvlist_lookup_string(nvl, O_TRACELEVEL, &val); - if (st == 0) { - (void) snprintf(buf, sizeof (buf), - " set[DRIVE.'TraceLevel' '%s']", - val); - (void) strlcat(cmd, buf, sizeof (cmd)); - } - st = nvlist_lookup_string(nvl, O_TRACESZ, &val); - if (st == 0) { - st = val_mms_size(val); - if (st == 0) { - (void) snprintf(buf, sizeof (buf), - " set[DRIVE.'TraceFileSize' '%s']", - val); - (void) strlcat(cmd, buf, sizeof (cmd)); - } else { - MGMT_ADD_OPTERR(errs, O_TRACESZ, st); - } - } - st = nvlist_lookup_string(nvl, O_UNLOADTM, &val); - if (st == 0) { - (void) snprintf(buf, sizeof (buf), - " set[DRIVE.'UnloadTime' '%s']", - val); - (void) strlcat(cmd, buf, sizeof (cmd)); - } - (void) strlcat(cmd, ";", sizeof (cmd)); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "create drive", - &response); - if (st != 0) { - goto done; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "create task['%s'] type[DM] " - "set[DM.'DMName' 'DM_%s'] " - "set[DM.'DriveName' '%s'] " - "set[DM.'DMTargetHost' '%s'] " - "set[DM.'DMTargetPath' '%s'];", - tid, dname, dname, thishost, ddadev); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "create drive", - &response); - if (st != 0) { - goto done; - } - - if (st == 0) { - if (!nvlist_exists(nvl, O_OBJSTATE)) { - (void) nvlist_add_string(nvl, O_OBJSTATE, "online"); - } - st = mms_mgmt_set_state(sessp, nvl, errs); - } - -done: - if (sess) { - (void) mms_goodbye(sess, 0); - } - - if (apps) { - mgmt_free_str_arr(apps, count); - } - - if (drvs) { - nvlist_free(drvs); - } - - if (dklib) { - nvlist_free(dklib); - } - - return (st); -} - -int -mms_mgmt_set_vol_mode(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - void *sess = NULL; - void *sessp = session; - void *response; - char tid[64]; - char cmd[8192]; - char buf[1024]; - char thishost[1024]; - char *libname = NULL; - char *vol = NULL; - nvlist_t *nva = NULL; - nvlist_t *attrs = NULL; - nvpair_t *nvp; - int fd = -1; - dda_metadata_t metadata; - dda_metadata_t out_metadata; - char *readonly = "false"; - flock64_t flk; - char *rwmode = NULL; - char *type = NULL; - char *libpath = NULL; - - if (!mgmt_chk_auth("solaris.mms.media")) { - return (EACCES); - } - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - st = nvlist_lookup_string(nvl, O_NAME, &vol); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - st = nvlist_lookup_string(nvl, O_MMSLIB, &libname); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_MMSLIB, st); - return (st); - } - - st = gethostname(thishost, sizeof (thishost)); - if (st != 0) { - st = errno; - MGMT_ADD_ERR(errs, "hostname", st); - return (st); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] " - "report[LIBRARY] " - "reportmode[namevalue] " - "match[and( streq(CARTRIDGE.'CartridgePCL' '%s') " - "streq(LIBRARY.'LibraryName' '%s'))];", - tid, vol, libname); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "get dkvol", - &response); - if (st == 0) { - st = mmp_get_nvattrs("CartridgePCL", B_FALSE, response, - &attrs); - mms_free_rsp(response); - } - - if (st != 0) { - goto done; - } - if (attrs == NULL) { - st = ENOENT; - goto done; - } - - /* - * If changing readonly mode - */ - st = nvlist_lookup_string(nvl, "readonly", &rwmode); - if (st == 0) { - if (strcmp(rwmode, "true") == 0) { - rwmode = "readonly"; - } else if (strcmp(rwmode, "false") == 0) { - rwmode = "readwrite"; - } else { - st = MMS_MGMT_INVALID_READONLY; - MGMT_ADD_OPTERR(errs, "readonly", st); - return (st); - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "attribute task['%s'] " - "match[and( streq(CARTRIDGE.'CartridgePCL' '%s') " - "streq(LIBRARY.'LibraryName' '%s'))] " - "set[PARTITION.'PartitionRWMode' '%s'] " - ";", - tid, vol, libname, rwmode); - st = mms_mgmt_send_cmd(sessp, tid, cmd, "get dkvol", - &response); - if (st != 0) { - goto done; - } - mms_free_rsp(response); - } - - nvp = nvlist_next_nvpair(attrs, NULL); - (void) nvpair_value_nvlist(nvp, &nva); - - st = nvlist_lookup_string(nva, "LibraryType", &type); - if (st != 0) { - goto done; - } - if (strcmp(type, "DISK")) { - /* Not DISK library, then we are done */ - goto done; - } - - /* - * DISK volume, set the DISK cartridge mode - */ - (void) nvlist_lookup_string(nva, "DefaultLibraryPath", &libpath); - (void) snprintf(buf, sizeof (buf), "%s/%s/%s", libpath, vol, - DDA_METADATA_FNAME); - - fd = open64(buf, O_RDWR); - if (fd == -1) { - st = errno; - MGMT_ADD_ERR(errs, "open cartridge", st); - goto done; - } - - /* - * Preclude acting on an in-use cartridge. Try to - * lock it -- if it's busy, DDA will hold the lock - * so we should fail back to the user. - */ - (void) memset(&flk, 0, sizeof (flock64_t)); - flk.l_type = F_WRLCK; - flk.l_whence = 1; - flk.l_start = 0; - flk.l_len = 0; - if (fcntl(fd, F_SETLK64, &flk)) { - st = MMS_MGMT_CARTRIDGE_INUSE; - MGMT_ADD_ERR(errs, O_NAME, st); - goto done; - } - - if (read(fd, &out_metadata, sizeof (dda_metadata_t)) != - sizeof (dda_metadata_t)) { - st = errno; - MGMT_ADD_ERR(errs, "read index", st); - goto done; - } - DDA_BE_METADATA(out_metadata, metadata); /* to big endian */ - - if (strcasecmp(readonly, "true") == 0) { - metadata.dda_flags |= DDA_FLAG_WPROTECT; - } else { - metadata.dda_flags &= ~DDA_FLAG_WPROTECT; - } - - if (lseek(fd, SEEK_SET, 0) == -1) { - st = errno; - MGMT_ADD_ERR(errs, "write index", st); - goto done; - } - - DDA_BE_METADATA(metadata, out_metadata); /* to big endian */ - if (write_buf(fd, &out_metadata, sizeof (dda_metadata_t)) != - sizeof (dda_metadata_t)) { - st = errno; - MGMT_ADD_ERR(errs, "write index", st); - } - -done: - - if (fd > 0) { - (void) close(fd); - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - if (attrs) { - nvlist_free(attrs); - } - - return (st); -} - -int -mgmt_delete_dkvol(char *volpath, nvlist_t *errs) -{ - int st; - struct stat64 sbuf; - char buf[1024]; - - if (!volpath) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.media")) { - return (EACCES); - } - - if (*volpath != '/') { - st = EINVAL; - MGMT_ADD_ERR(errs, volpath, st); - return (st); - } - - st = stat64(volpath, &sbuf); - if (st != 0) { - st = errno; - if (st == ENOENT) { - /* not a failure, already removed */ - return (0); - } - MGMT_ADD_ERR(errs, volpath, st); - return (st); - } - - (void) snprintf(buf, sizeof (buf), "%s/%s", volpath, DDA_DATA_FNAME); - if (stat64(buf, &sbuf) == 0) { - (void) unlink(buf); - } - - (void) snprintf(buf, sizeof (buf), "%s/%s", volpath, - DDA_METADATA_FNAME); - if (stat64(buf, &sbuf) == 0) { - (void) unlink(buf); - } - - (void) snprintf(buf, sizeof (buf), "%s/%s", volpath, DDA_INDEX_FNAME); - if (stat64(buf, &sbuf) == 0) { - (void) unlink(buf); - } - - st = rmdir(volpath); - if (st != 0) { - st = errno; - if (st == ENOENT) { - /* again, not a failure if already gone */ - st = 0; - } else { - MGMT_ADD_ERR(errs, volpath, st); - } - } - - return (st); -} diff --git a/usr/src/lib/mms/mgmt/common/mgmt_lib.c b/usr/src/lib/mms/mgmt/common/mgmt_lib.c deleted file mode 100644 index a4b38d715d..0000000000 --- a/usr/src/lib/mms/mgmt/common/mgmt_lib.c +++ /dev/null @@ -1,2969 +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 <libgen.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/nvpair.h> - -#include "mms_mgmt.h" -#include "mgmt_acsls.h" -#include "mmp_defs.h" -#include "mgmt_library.h" -#include "mgmt_sym.h" -#include "mgmt_util.h" - -static char *_SrcFile = __FILE__; -#define HERE _SrcFile, __LINE__ - -/* - * Cannot set to online during create - * {O_ONLINE, "LibraryOnline", "true", B_FALSE, val_truefalse}, - */ -static mms_mgmt_setopt_t libopts[] = { - {O_NAME, "LibraryName", NULL, B_TRUE, NULL}, - {O_TYPE, "LibraryType", NULL, B_TRUE, NULL}, - {O_ACSHOST, "LibraryIP", NULL, B_TRUE, NULL}, - {O_ACSNUM, "LibraryACS", NULL, B_TRUE, val_numonly}, - {O_LSMNUM, "LibraryLSM", NULL, B_TRUE, val_numonly}, - {O_LIBCONN, "LibraryConnection", "network", B_TRUE, NULL}, - {O_SERIALNO, "LibrarySerialNumber", NULL, B_TRUE, NULL}, - {O_ACSPORT, NULL, NULL, B_FALSE, val_numonly}, - {NULL, NULL, NULL, B_FALSE, NULL} -}; -#define LIBOPT_COUNT sizeof (libopts) / sizeof (mms_mgmt_setopt_t) - -mms_mgmt_setopt_t dklibopts[] = { - {O_NAME, "LibraryName", NULL, B_TRUE, NULL}, - {O_TYPE, "LibraryType", NULL, B_TRUE, NULL}, - {O_DFLTPATH, "DefaultLibraryPath", NULL, B_TRUE, NULL}, - {NULL, NULL, NULL, B_FALSE, NULL} -}; -#define DKLIBOPT_COUNT sizeof (dklibopts) / sizeof (mms_mgmt_setopt_t) - -static mms_mgmt_setopt_t lmopts[] = { - {O_LMNAME, "LMName", NULL, B_TRUE, NULL}, - {O_NAME, "LibraryName", NULL, B_TRUE, NULL}, - {O_DEVCONN, "LMTargetHost", NULL, B_TRUE, NULL}, - {O_MSGLEVEL, "LMMessageLevel", "error", B_FALSE, val_level}, - {O_TRACELEVEL, "TraceLevel", "debug", B_FALSE, val_level}, - {O_TRACESZ, "TraceFileSize", "10M", B_FALSE, val_mms_size}, - {O_OBJSTATE, "LMDisabled", "false", B_FALSE, val_truefalse}, - {NULL, NULL, NULL, B_FALSE, NULL} -}; -#define LMOPT_COUNT sizeof (lmopts) / sizeof (mms_mgmt_setopt_t) - -/* - * Cannot set to online during create - * {O_ONLINE, "DriveOnline", "true", B_FALSE, val_truefalse}, - */ -static mms_mgmt_setopt_t driveopts[] = { - {O_NAME, "DriveName", NULL, B_TRUE, NULL}, - {O_TYPE, "DriveType", NULL, B_TRUE, NULL}, - {O_SERIALNO, "DriveSerialNum", NULL, B_TRUE, NULL}, - {O_MMSLIB, "LibraryName", NULL, B_TRUE, NULL}, - {O_DPOOL, "DriveGroupName", NULL, B_TRUE, NULL}, - {O_RESERVE, "ReserveDrive", "yes", B_FALSE, val_yesno}, - {NULL, NULL, NULL, B_FALSE, NULL} -}; -#define DRVOPT_COUNT sizeof (driveopts) / sizeof (mms_mgmt_setopt_t) - -/* - * Note that O_DEVCONN (string array) is required for DM. Add a DM - * for each host specified in the array. - */ -static mms_mgmt_setopt_t dmopts[] = { - {O_DMNAME, "DMName", NULL, B_TRUE, NULL}, - {O_NAME, "DriveName", NULL, B_TRUE, NULL}, - {O_DEVCONN, "DMTargetHost", NULL, B_TRUE, NULL}, - {O_MSGLEVEL, "DMMessageLevel", "error", B_FALSE, val_level}, - {O_TRACELEVEL, "TraceLevel", "debug", B_FALSE, val_level}, - {O_TRACESZ, "TraceFileSize", "10M", B_FALSE, val_mms_size}, - {O_DISABLED, "DMDisabled", "false", B_FALSE, val_truefalse}, - {NULL, NULL, NULL, B_FALSE, NULL} -}; -#define DMOPT_COUNT sizeof (dmopts) / sizeof (mms_mgmt_setopt_t) - -static mms_mgmt_setopt_t drvgrpopts[] = { - {O_NAME, "DriveGroupName", NULL, B_TRUE, NULL}, - {O_UNLOADTM, "DriveGroupUnloadTime", "60", B_FALSE, NULL}, - {NULL, NULL, NULL, B_FALSE, NULL} -}; -#define DGOPT_COUNT sizeof (drvgrpopts) / sizeof (mms_mgmt_setopt_t) - -/* - * Note that O_APPS (string array) is required for DriveGroupApplication. - * Add a DGA for each application specified in the array. - * {O_APPS, "ApplicationName", NULL, B_FALSE, NULL}, - */ -static mms_mgmt_setopt_t drvgrpappopts[] = { - {O_NAME, "DriveGroupName", NULL, B_TRUE, NULL}, - {O_APPS, "ApplicationName", NULL, B_TRUE, NULL}, - {NULL, NULL, NULL, B_FALSE, NULL} -}; -#define DGAOPT_COUNT sizeof (drvgrpappopts) / sizeof (mms_mgmt_setopt_t) - -static int -mms_remove_libaccess(void *session, char *libname); - -static int -mms_remove_slotgroup(void *session, char *libname); - -static int -mms_remove_lm(void *session, char *libname); - -static int -mms_remove_dm(void *session, nvlist_t *nvl, nvlist_t *errs); - -static int -mms_remove_dg(void *session, char *dgname); - -static int -mms_create_drive(void *session, nvlist_t *nvl, nvlist_t *errs); - -static int -update_DMs(void *session, char *drive, nvlist_t **olddms, int count, - nvlist_t *nvl, nvlist_t *errs); - -static int -update_DGAs(void *session, char *dgname, nvlist_t **old, int count, - nvlist_t *nvl, nvlist_t *errs); - -/* - * mms_mgmt_discover_libraries() - * - * Finds ACSLS libraries, and optionally associated drives. - */ -int -mms_mgmt_discover_libraries( - char *acshost, boolean_t getdrives, mms_list_t *liblist) -{ - int st; - mms_acslib_t *lsm = NULL; - mms_acslib_t *mlsm = NULL; - mms_drive_t *drv = NULL; - mms_drive_t *mdrv = NULL; - mms_list_t mlist; - void *session = NULL; - - if (!acshost || !liblist) { - return (MMS_MGMT_NOARG); - } - - (void) memset(&mlist, 0, sizeof (mms_list_t)); - - mms_list_create(liblist, sizeof (mms_acslib_t), - offsetof(mms_acslib_t, lib_link)); - - st = get_acs_library_cfg(acshost, getdrives, liblist); - if (st != 0) { - return (st); - } - - st = create_mm_clnt(NULL, NULL, NULL, NULL, &session); - if (st == 0) { - st = mms_get_library(session, getdrives, &mlist); - (void) mms_goodbye(session, 0); - } - - if (st != 0) { - free_acslib_list(liblist); - liblist->list_size = 0; - return (st); - } - - mms_list_foreach(liblist, lsm) { - if (mlist.list_size == 0) { - continue; - } - - mms_list_foreach(&mlist, mlsm) { - if ((strcmp(lsm->serialnum, mlsm->serialnum) != 0) || - (strcmp(lsm->type, mlsm->type) != 0)) { - continue; - } - - (void) strlcpy(lsm->name, mlsm->name, - sizeof (lsm->name)); - - if (getdrives) { - if (lsm->drive_list.list_size == 0) { - break; - } - mms_list_foreach(&lsm->drive_list, drv) { - if (mlsm->drive_list.list_size == 0) { - break; - } - mms_list_foreach(&mlsm->drive_list, - mdrv) { - if ((strcmp(drv->serialnum, - mdrv->serialnum) != 0) || - (strcmp(drv->type, - mdrv->type) != 0)) { - continue; - } - (void) strlcpy(drv->name, - mdrv->name, - sizeof (drv->name)); - - break; - } - } - } - break; - } - } - - free_acslib_list(&mlist); - - return (0); -} - -/* - * The mms_get_library() function lists all the libraries that are controlled - * by MM. The LM(s) and the drives in each library alongwith the the respective - * DM(s) information for each drive are also obtained. - * - * The session argument should be provided if an existing connection to the - * MM server is to be reused. If this argument is NULL, a new connection to - * MM will be created and destroyed before returning. - * - * PARAM - * session - IN - MM session information - * get_drives - IN - whether the drives should also be returned - * acslib_list - OUT - list of mms_acslib_t - * - * RETURN - * Upon successful completion, a value of 0 is returned. If errors are - * encountered, an appropriate error number is returned - * - */ -int -mms_get_library( - void *session, - boolean_t get_drives, - mms_list_t *acslib_list) -{ - void *response; - mms_acslib_t *acslib; - int st; - char cmd[1024]; - char tid[64]; - void *sess = NULL; - void** sessp = session; - - mms_trace(MMS_DEBUG, "mms_get_library() start"); - - if (session == NULL) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - (void) mms_gen_taskid(tid); - - /* - * generate command to query the MM for all the libraries and their - * associated LM(s) - */ - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] report[LIBRARY] reportmode[namevalue];", tid); - - mms_trace(MMS_DEBUG, "mms_get_library() request command: %s", cmd); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "mms_get_library()", &response); - if (st != 0) { - goto done; - } - - (void) mmp_parse_library_rsp(response, acslib_list); - - mms_free_rsp(response); - - for (acslib = mms_list_head(acslib_list); acslib; - acslib = mms_list_next(acslib_list, acslib)) { - /* Get the LMs for each library */ - st = mms_get_lm(sessp, acslib->name, &(acslib->lm_list)); - if (st != 0) { - break; - } - - /* Get the drives in the each library */ - if (get_drives) { - st = mms_get_drives_for_lib( - sessp, acslib->name, &acslib->drive_list); - if (st != 0) { - break; - } - } - } - - mms_trace(MMS_DEBUG, "mms_get_library() completed, return[%d]", st); - -done: - if (sess) { - (void) mms_goodbye(sess, 0); - } - return (st); -} - - -/* - * The mms_get_lm() function gets information about all the LM(s) for a - * particular library. The LM name and hostname are filled in the structure - * mms_lm_t - */ -int -mms_get_lm(void *session, char *libname, mms_list_t *lm_list) -{ - void *response; - int st; - char tid[64]; - char cmd[8192]; - - if ((session == NULL) || (libname == NULL) || (lm_list == NULL)) { - return (MMS_MGMT_NOARG); - } - - mms_trace(MMS_DEBUG, "mms_get_lm() for library[%s]", libname); - - (void) mms_gen_taskid(tid); - - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] match[ streq(LM.'LibraryName' '%s')]" - " report[LM] reportmode[namevalue];", tid, libname); - - mms_trace(MMS_DEBUG, "Send command[%s]", cmd); - - st = mms_mgmt_send_cmd(session, tid, cmd, "mms_get_lm()", &response); - if (st == 0) { - st = mmp_parse_lm_rsp(response, lm_list); - } - - mms_trace(MMS_DEBUG, "mms_get_lm() completed, return[%d]", st); - - mms_free_rsp(response); - return (st); - -} - - -/* - * The mms_get_dm() function gets information about all the dms for a - * particular drive. The DM name, drive path, hostname and status are - * filled in the structure mms_dm_t - * - */ -int -mms_get_dm(void *session, char *drivename, mms_list_t *dm_list) -{ - void *response; - int st; - char tid[64]; - char cmd[8192]; - - if ((session == NULL) || (drivename == NULL) || (dm_list == NULL)) { - return (MMS_MGMT_NOARG); - } - - mms_trace(MMS_DEBUG, "mms_get_dm() for drive[%s]", drivename); - - (void) mms_gen_taskid(tid); - - /* why not just a standard report? */ - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] match[ streq(DM.'DriveName' '%s')] " - "report[DM] reportmode[namevalue];", - tid, drivename); - - mms_trace(MMS_DEBUG, "mms_get_dm() request command[%s]", cmd); - - st = mms_mgmt_send_cmd(session, tid, cmd, "mms_get_dm()", &response); - if (st == 0) { - st = mmp_parse_dm_rsp(response, dm_list); - } - - mms_trace(MMS_DEBUG, "mms_get_dm() completed, return[%d]", st); - - mms_free_rsp(response); - return (st); - -} - -/* - * The mms_get_drives_for_lib() function returns information about the - * drives hosted by a particular library (in the MM configuration) - * - * PARAM - * session - IN - connection to MM - * libname - IN - name of library - * drive_list - OUT - A list of drives in the given library - * - * RETURN - * upon successful completion, a value of 0 is returned to indicate success and - * drives is updated with a list of drives - * If the request cannot be completed, an appropriate error number is returned - * to signify the error - * - * MMS_ERR - * MMS Connection errors - */ -int -mms_get_drives_for_lib(void *session, char *libname, mms_list_t *drive_list) -{ - void *response; - int st; - char tid[64]; - char cmd[8192]; - - if ((session == NULL) || (libname == NULL) || (drive_list == NULL)) { - return (MMS_MGMT_NOARG); - } - - mms_trace(MMS_DEBUG, "mms_get_drives_for_lib(%s)", libname); - - (void) mms_gen_taskid(tid); - - /* this command is suspect too, if there's a drive but no DM */ - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] match[ streq(DRIVE.'LibraryName' '%s')]" - " report[DRIVE DM] reportmode[namevalue];", - tid, libname); - - mms_trace(MMS_DEBUG, "mms_get_drives_for_lib() request command %s", - cmd); - - st = mms_mgmt_send_cmd(session, tid, cmd, "mms_get_drives_for_lib()", - &response); - if (st == 0) { - st = mmp_parse_drive_rsp(response, drive_list); - } - - mms_free_rsp(response); - - mms_trace(MMS_DEBUG, - "mms_get_drives_for_lib() completed, return[%d]", st); - - return (st); -} - -int -mms_get_drive(void *session, char *drivename, mms_drive_t **drive) -{ - void *response; - int st; - void *sess = NULL; - void *sessp = session; - char tid[64]; - char cmd[8192]; - mms_list_t drive_list; - - if (!drivename || !drive) { - return (MMS_MGMT_NOARG); - } - - *drive = NULL; - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - mms_trace(MMS_DEBUG, "mms_get_drives(%s)", drivename); - - (void) mms_gen_taskid(tid); - - /* this command is suspect too, if there's a drive but no DM */ - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] match[ streq(DRIVE.'DriveName' '%s')]" - " report[DRIVE DM] reportmode[namevalue];", - tid, drivename); - - mms_trace(MMS_DEBUG, "mms_get_drive() request command %s", cmd); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "mms_get_drive()", - &response); - if (st == 0) { - st = mmp_parse_drive_rsp(response, &drive_list); - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - if (st == 0) { - *drive = mms_list_head(&drive_list); - } - - mms_free_rsp(response); - - mms_list_destroy(&drive_list); - - mms_trace(MMS_DEBUG, "mms_get_drive() completed, return[%d]", st); - - return (st); -} - -/* - * The mms_add_library() function is used to add a library to the MM - * configuration. The following steps are taken: - * - * 1. A Library object is created and associated with its network IP (ACSLS) - * 2. the Library object is associated with a Library Manager - * 3. Library is brought online - * - * ARGUMENTS: - * session MM session information. If this argument is - * NULL, a new session is created. - * lib library attributes - * - * RETURN VALUES: - * 0 Success - * >0 Failure - * - * ERRORS - * MMS_MGMT_NOARG One or more required arguments is missing - * ENOENT One or more required options is missing - * ENOMEM Out of memory - * TBD Could not communicate with MM - * TBD Other MMP errors - * - * Notes: - * MMS defines a Library Manager(LM) to manage each Library object. - * While the MMS spec supports a library to be managed by multiple - * LMs (without any upper limit), multiple LMs are only required for - * switchover or failover purposes. As such, for the first release of - * the MMS api, the hostname of the LM is defaulted to the MM host. - * - * If not specified, the library name is derived from library type and - * serial number. - */ -int -mms_add_library(void *session, nvlist_t *lib, nvlist_t *errs) -{ - int st; - char *ltype; - - - if (!lib) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.create")) { - return (EACCES); - } - - /* type is required */ - st = nvlist_lookup_string(lib, O_TYPE, <ype); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_TYPE, st); - return (st); - } - - /* - * If adding DISK type library, then call add dklib function - */ - if (strcmp(ltype, "DISK") == 0) { - /* Adding DISK library */ - st = mms_mgmt_create_dklib(session, lib, errs); - } else { - /* Adding a real library */ - st = mms_create_library(session, lib, errs); - } - return (st); -} - -int -mms_create_library(void *session, nvlist_t *lib, nvlist_t *errs) -{ - void *response; - int st; - char tid[64]; - char cmd[8192]; - char buf[1024]; - char libname[1024]; - char *namep = NULL; - char *val; - size_t len = sizeof (cmd); - char *cmdp; - void *sess; - void *sessp = session; - char *ltype = NULL; - - mms_trace(MMS_DEBUG, "mms_add_library"); - - /* type is required */ - st = nvlist_lookup_string(lib, O_TYPE, <ype); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_TYPE, st); - return (st); - } - - st = nvlist_lookup_string(lib, O_NAME, &namep); - if (st != 0) { - if (st != ENOENT) { - MGMT_ADD_ERR(errs, O_NAME, st); - return (st); - } - } - - if (namep == NULL) { - /* Create library name */ - st = nvlist_lookup_string(lib, O_SERIALNO, &val); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_SERIALNO, st); - return (st); - } - (void) snprintf(libname, sizeof (libname), "LIB_%s_%s", - ltype, val); - (void) nvlist_add_string(lib, O_NAME, libname); - namep = libname; - } - - /* Create LM name */ - (void) snprintf(buf, sizeof (buf), "LM_%s", namep); - (void) nvlist_add_string(lib, O_LMNAME, buf); - - /* - * MMS defines a Library Manager(LM) to manage each Library object. - * While the MMS spec supports a library to be managed by multiple LMs - * (without any upper limit), multiple LMs are only required for - * switchover or failover purposes. As such, for the first release of - * the MMS api, the hostname of the LM for ACSLS libraries defaults to - * the hostname running MM. - */ -#ifdef MGMT_VAR_CFG - st = nvlist_lookup_string(lib, O_DEVCONN, &val); - if (st != 0) { - if (st != ENOENT) { - MGMT_ADD_ERR(errs, O_DEVCONN, st); - return (st); - } - - st = mms_cfg_getvar(MMS_CFG_MGR_HOST, buf); - if (st != 0) { - return (MMS_MGMT_NO_MMHOST); - } - (void) nvlist_add_string(lib, O_DEVCONN, buf); - } -#else - /* always set to this host */ - st = gethostname(buf, sizeof (buf)); - if (st != 0) { - MGMT_ADD_ERR(errs, "cannot determine hostname", st); - return (st); - } - (void) nvlist_add_string(lib, O_DEVCONN, buf); -#endif /* MGMT_VAR_CFG */ - - /* create LIBRARY object */ - st = create_mmp_clause("LIBRARY", libopts, lib, errs, cmd, len); - - if (st != 0) { - return (st); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "mms_add_library()", &response); - if (st != 0) { - MGMT_ADD_ERR(errs, namep, st); - if (sess) { - (void) mms_goodbye(sess, 0); - } - return (st); - } - - /* move ahead in the cmdbuf */ - cmdp = cmd + strlen(cmd); - len -= strlen(cmd); - - /* Build the LM object */ - st = create_mmp_clause("LM", lmopts, lib, errs, cmdp, len); - - if (st == 0) { - st = mms_mgmt_send_cmd(sessp, tid, cmdp, "mms_add_library()", - &response); - } - - /* online the library */ - if (st == 0) { - if (!nvlist_exists(lib, O_OBJSTATE)) { - (void) nvlist_add_string(lib, O_OBJSTATE, "online"); - } - st = mms_mgmt_set_state(sessp, lib, errs); - } - - if (st != 0) { - MGMT_ADD_ERR(errs, namep, st); - (void) mms_remove_library(sessp, lib, errs); - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -int -mms_add_drive(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - char *type; - int st = 0; - - st = nvlist_lookup_string(nvl, O_TYPE, &type); - if (st != 0) { - st = MMS_MGMT_NO_HWTYPE; - MGMT_ADD_OPTERR(errs, "O_TYPE", st); - return (st); - } - - if (strcmp(type, "DISK") == 0) { - st = mms_mgmt_create_dkdrive(session, nvl, errs); - } else { - st = mms_create_drive(session, nvl, errs); - } - return (st); -} - -static int -mgmt_get_libname(void *session, char *libname, nvlist_t **lib) -{ - int st; - void *sess = NULL; - void *sessp = session; - void *response; - char tid[64]; - char cmd[8192]; - - if (!lib) { - return (MMS_MGMT_NOARG); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - *lib = NULL; - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] " - "match[streq(LIBRARY.'LibraryName' '%s')] " - "report[LIBRARY.'LibraryName'] " - "reportmode[namevalue]; ", tid, libname); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "mgmt_get_lib", - &response); - if (st == 0) { - st = mmp_get_nvattrs("LibraryName", B_FALSE, response, - lib); - mms_free_rsp(response); - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -static int -mms_create_drive(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char buf[2048]; - void *sess = NULL; - void *sessp = session; - char *val; - char drvnm[1024]; - char *namep; - char **saved = NULL; - char *dgname = NULL; - char *libname = NULL; - nvlist_t *lib = NULL; - nvlist_t *dg = NULL; - int count = 0; - char hostbuf[1024]; - int i; - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.create")) { - return (EACCES); - } - - st = gethostname(hostbuf, sizeof (hostbuf)); - if (st != 0) { - st = errno; - MGMT_ADD_ERR(errs, "could not determine hostname", st); - return (st); - } - - /* Library asssociation and connection are required */ - st = nvlist_lookup_string(nvl, O_MMSLIB, &libname); - if (st != 0) { - MGMT_ADD_OPTERR(errs, "library", st); - goto done; - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - goto done; - } - sessp = sess; - } - - st = mgmt_get_libname(sessp, libname, &lib); - if (st != 0) { - goto done; - } - - if (!nvlist_exists(lib, libname)) { - st = MMS_MGMT_LIB_NOT_EXIST; - goto done; - } - -#ifdef MMS_VAR_CFG - if (!nvlist_exists(nvl, O_DEVCONN)) { - st = ENOENT; - MGMT_ADD_OPTERR(errs, O_DEVCONN, st); - return (st); - } -#else - /* must always be the same as MM server */ - st = nvlist_lookup_string(nvl, O_DEVCONN, &val); - if (st == 0) { - st = mgmt_compare_hosts(val, hostbuf); - if (st != 0) { - st = MMS_MGMT_REMOTE_NOT_SUPP; - MGMT_ADD_OPTERR(errs, val, st); - return (st); - } - } else { - (void) nvlist_add_string(nvl, O_DEVCONN, hostbuf); - } -#endif /* MMS_VAR_CFG */ - - (void) nvlist_lookup_string(nvl, O_DPOOL, &dgname); - if (!dgname) { - MGMT_ADD_OPTERR(errs, "dpool", st); - goto done; - } - - st = mgmt_get_dgname(sessp, dgname, &dg); - if (st != 0) { - goto done; - } - - if (!nvlist_exists(dg, dgname)) { - st = MMS_MGMT_DG_NOT_EXIST; - goto done; - } - - st = nvlist_lookup_string(nvl, O_NAME, &val); - if (st == 0) { - /* name provided */ - namep = val; - } else { - if (st != ENOENT) { - MGMT_ADD_ERR(errs, O_NAME, st); - return (st); - } - - st = nvlist_lookup_string(nvl, O_SERIALNO, &val); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_SERIALNO, st); - return (st); - } - - (void) snprintf(drvnm, sizeof (drvnm), "DRV_%s", val); - (void) nvlist_add_string(nvl, O_NAME, drvnm); - namep = drvnm; - } - - /* - * Ready to create the objects. On failure, unwind the list and - * remove what was added. Order is DRIVE, - * foreach host add DM. - */ - - st = mms_add_object(sessp, "DRIVE", driveopts, nvl, errs); - if (st != 0) { - MGMT_ADD_ERR(errs, namep, st); - goto done; - } - - /* For each host specified in O_DEVCONN, create a DM */ - saved = mgmt_var_to_array(nvl, O_DEVCONN, &count); - if (saved == NULL) { - /* should never happen since we checked earlier */ - goto done; - } - for (i = 0; i < count; i++) { - /* create DM Name */ - (void) snprintf(buf, sizeof (buf), "DM_%s_%d", namep, i + 1); - (void) nvlist_add_string(nvl, O_DMNAME, buf); - (void) nvlist_add_string(nvl, O_DEVCONN, saved[i]); - st = mms_add_object(sessp, "DM", dmopts, nvl, errs); - if (st != 0) { - (void) snprintf(buf, sizeof (buf), - "%s = %s", O_DEVCONN, saved[i]); - MGMT_ADD_ERR(errs, buf, st); - break; - } - } - /* put back the original array */ - (void) nvlist_add_string_array(nvl, O_DEVCONN, saved, count); - mgmt_free_str_arr(saved, count); - - if (st != 0) { - goto done; - } - - /* online the drive */ - if (st == 0) { - if (!nvlist_exists(nvl, O_OBJSTATE)) { - (void) nvlist_add_string(nvl, O_OBJSTATE, "online"); - } - st = mms_mgmt_set_state(sessp, nvl, errs); - } - -done: - if (lib) { - nvlist_free(lib); - } - if (dg != NULL) { - nvlist_free(dg); - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - mms_trace(MMS_DEBUG, "mms_add_drive() completed, return[%d]", st); - return (st); -} - -void -free_acslib_list(void *arg) -{ - mms_list_t *lst = arg; - mms_acslib_t *lsm; - - if (!lst || (lst->list_size == 0)) { - return; - } - - mms_list_foreach(lst, lsm) { - free_drive_list(&lsm->drive_list); - mms_list_free_and_destroy(&lsm->lm_list, free); - } - mms_list_free_and_destroy(lst, free); -} - -void -free_drive_list(void *arg) -{ - mms_list_t *lst = arg; - mms_drive_t *drv; - - if (!lst || (lst->list_size == 0)) { - return; - } - - mms_list_foreach(lst, drv) { - mms_list_free_and_destroy(&drv->dm_list, free); - mms_list_free_and_destroy(&drv->app_list, free); - } - - mms_list_free_and_destroy(lst, free); -} - -int -mms_remove_library(void *session, nvlist_t *lib, nvlist_t *errs) -{ - int st; - char *val; - void *sessp = session; - void *sess = NULL; - void *response; - char cmd[8192]; - char tid[64]; - - if (!lib) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.delete")) { - return (EACCES); - } - - st = nvlist_lookup_string(lib, O_NAME, &val); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - /* TODO: Add checks for library dependencies in cartridgegroups */ - /* TODO: Add checks for drives in this library */ - - /* Attempt to delete LMs if they have been created */ - (void) mms_remove_lm(sessp, val); - - /* Attempt to delete LIBRARYACCESS if they have been created */ - (void) mms_remove_libaccess(sessp, val); - - if (st == 0) { - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[LIBRARY] " - "match[streq (LIBRARY.'%s' '%s')];", - tid, "LibraryName", val); - - mms_trace(MMS_DEBUG, "mms_remove_library() request command: %s", - cmd); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "mms_remove_library()", - &response); - - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - if (st != 0) { - MGMT_ADD_ERR(errs, val, st); - } - - return (st); -} - -static int -mms_remove_slotgroup(void *session, char *libname) -{ - int st; - void *sess = NULL; - void *sessp = session; - char cmd[2048]; - char tid[64]; - void *response; - - if (!libname) { - return (MMS_MGMT_NOARG); - } - - (void) mms_gen_taskid(tid); - - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[SLOTGROUP] " - "match[streq (SLOTGROUP.'LibraryName' '%s')];", - tid, libname); - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "mms_remove_slotgroup()", - &response); - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -static int -mms_remove_lm(void *session, char *libname) -{ - int st; - void *sess = NULL; - void *sessp = session; - char cmd[2048]; - char tid[64]; - void *response; - - if (!libname) { - return (MMS_MGMT_NOARG); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - (void) mms_remove_slotgroup(sessp, libname); - - (void) mms_gen_taskid(tid); - - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[LM] match[streq (LM.'LibraryName' '%s')];", - tid, libname); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "mms_remove_lm()", &response); - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -int -mms_remove_libaccess(void *session, char *libname) -{ - int st; - void *sess = NULL; - void *sessp = session; - char cmd[2048]; - char tid[64]; - void *response; - - if (!libname) { - return (MMS_MGMT_NOARG); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - (void) mms_gen_taskid(tid); - - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[LIBRARYACCESS] " - "match[streq (LIBRARYACCESS.'LibraryName' '%s')];", - tid, libname); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "mms_remove_libaccess()", - &response); - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -static int -mms_remove_dg(void *session, char *dgname) -{ - int st; - void *sess = NULL; - void *sessp = session; - void *response = NULL; - char tid[64]; - char cmd[1024]; - - if (!dgname) { - return (MMS_MGMT_NOARG); - } - - /* - * remove DRIVEGROUPAPPLICATIONs associated with this - * DRIVEGROUP too. - */ - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[DRIVEGROUPAPPLICATION]" - " match[streq (DRIVEGROUP.'DriveGroupName' '%s')];", - tid, dgname); - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "mms_remove_dga", &response); - - if (st == 0) { - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[DRIVEGROUP] " - "match[streq(DRIVEGROUP.'DriveGroupName' '%s')];", - tid, dgname); - st = mms_mgmt_send_cmd(sessp, tid, cmd, "mms_remove_dg", - &response); - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -static int -mms_remove_dm(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - void *sess = NULL; - void *sessp = session; - void *response = NULL; - mms_list_t dmlist; - char *drive; - mms_dm_t *dm; - char tid[64]; - char cmd[1024]; - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - st = nvlist_lookup_string(nvl, O_NAME, &drive); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - /* Find the list of DMs to be removed */ - st = mms_get_dm(sessp, drive, &dmlist); - if (st != 0) { - if (sess) { - (void) mms_goodbye(sess, 0); - } - return (st); - } - - mms_list_foreach(&dmlist, dm) { - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[DM] " - "match[streq (DM.'%s' '%s')];", - tid, "DMName", dm->name); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "mms_remove_dm()", - &response); - if (st != 0) { - MGMT_ADD_ERR(errs, dm->name, st); - mms_trace(MMS_ERR, "Error removing DM %s, status = %d", - dm->name, st); - break; - } - } - - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - mms_list_free_and_destroy(&dmlist, free); - - return (st); -} - -int -mms_remove_drive(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - void *sess = NULL; - void *sessp = session; - void *response = NULL; - char *drivename; - char tid[64]; - char cmd[1024]; - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.delete")) { - return (EACCES); - } - - st = nvlist_lookup_string(nvl, O_NAME, &drivename); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - st = mms_remove_dm(sessp, nvl, errs); - if (st == 0) { - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] " - "type[DRIVE] match[streq (DRIVE.'%s' '%s')];", - tid, "DriveName", drivename); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "mms_remove_dm()", - &response); - } - - if (st == 0) { - (void) snprintf(cmd, sizeof (cmd), "DG_%s", drivename); - st = mms_remove_dg(sessp, cmd); - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -/* MODIFY functions */ -int -mms_modify_library(void *session, nvlist_t *nvl, nvlist_t *errs) -{ -#define CARRAY_COUNT \ - (LIBOPT_COUNT > DKLIBOPT_COUNT ? LIBOPT_COUNT : DKLIBOPT_COUNT) - - int st; - char *fnam = "mms_modify_library()"; - char *libname; - void *sess = NULL; - void *sessp = session; - char tid[64]; - char cmd[8192]; - char lmcmd[8192]; - nvlist_t *libattrs = NULL; - void *response = NULL; - int count = 0; - int lmcount = 0; - char *carray[CARRAY_COUNT]; - char *lmarray[LMOPT_COUNT]; - nvpair_t *nvp; - nvlist_t *nva; - char *type = NULL; - mms_mgmt_setopt_t *libopts_p; - char *path = NULL; - char libpath[8192]; - int i; - - if (!mgmt_chk_auth("solaris.mms.modify")) { - return (EACCES); - } - - (void) memset(&carray, 0, sizeof (carray)); - (void) memset(&lmarray, 0, sizeof (lmarray)); - - /* get existing attrs for LIBRARY, LM */ - /* see what changed, if anything */ - /* update the objects */ - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - st = nvlist_lookup_string(nvl, O_NAME, &libname); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - /* - * Read LIBRARY and see what type it is - */ - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] match[streq (LIBRARY.'%s' '%s')] " - "reportmode[namevalue] report[LIBRARY];", tid, - "LibraryName", libname); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, fnam, &response); - if (st == 0) { - st = mmp_get_nvattrs("LibraryName", B_FALSE, response, - &libattrs); - mms_free_rsp(response); - } - if (st != 0) { - goto done; - } - - st = nvlist_lookup_nvlist(libattrs, libname, &nva); - if (st == 0) { - st = nvlist_lookup_string(nva, "LibraryType", &type); - if (st != 0) { - goto done; - } - } - - /* see if there are LIBRARY attrs to be changed. Skip over O_NAME. */ - if (strcmp(type, "DISK") == 0) { - /* - * If dkpath is to be set, the library name must be appended - * to the path specified. - */ - if (nvlist_lookup_string(nvl, "dkpath", &path) == 0) { - if (path[0] != '/') { - st = MMS_MGMT_INVALID_PATH; - goto done; - } - for (i = strlen(path) - 1; - i > 0 && path[i] == '/'; - i--) { - path[i] = '\0'; - } - (void) snprintf(libpath, sizeof (libpath), - "%s/%s", path, libname); - (void) nvlist_remove_all(nvl, "dkpath"); - (void) nvlist_add_string(nvl, "dkpath", libpath); - } - libopts_p = dklibopts; - } else { - libopts_p = libopts; - } - st = mgmt_find_changed_attrs("LIBRARY", libopts_p, - nvl, carray, &count, errs); - - /* - * see if there are LM attrs to be changed. - * Skip over O_NAME and O_LMNAME. - */ - st = mgmt_find_changed_attrs("LM", lmopts, nvl, lmarray, &lmcount, - errs); - if (st != 0) { - goto done; - } - - (void) mms_gen_taskid(tid); - - (void) snprintf(lmcmd, sizeof (lmcmd), - "show task['%s'] match[streq (LM.'%s' '%s')] " - "reportmode[namevalue] report[LM];", tid, "LibraryName", libname); - - if ((count == 0) && (lmcount == 0)) { - /* nothing to do */ - st = MMS_MGMT_NOARG; - goto done; - } - - if (count > 0) { - st = nvlist_lookup_nvlist(libattrs, libname, &nva); - if (st == 0) { - cmp_mmp_opts(libopts_p, carray, nva, &count); - } - } - - - if (lmcount > 0) { - st = mms_mgmt_send_cmd(sessp, tid, lmcmd, fnam, &response); - if (st == 0) { - st = mmp_get_nvattrs("LMName", B_FALSE, response, - &libattrs); - mms_free_rsp(response); - } - if (st != 0) { - goto done; - } - - nvp = nvlist_next_nvpair(libattrs, NULL); - if (nvp) { - cmp_mmp_opts(lmopts, lmarray, nva, &lmcount); - nvlist_free(libattrs); - } else { - /* something is very wrong. no LM returned */ - lmcount = 0; - } - } - - /* if we have any attrs left to set, do it */ - if (count > 0) { - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "attribute task['%s'] " - "match[streq (LIBRARY.'LibraryName' '%s')] ", - tid, libname); - - mk_set_clause("LIBRARY", libopts_p, carray, cmd, sizeof (cmd)); - (void) strlcat(cmd, ";", sizeof (cmd)); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, fnam, &response); - if (st != 0) { - goto done; - } - } - - if (lmcount > 0) { - (void) mms_gen_taskid(tid); - (void) snprintf(lmcmd, sizeof (lmcmd), - "attribute task['%s'] " - "match[streq (LM.'LibraryName' '%s')] ", - tid, libname); - - mk_set_clause("LM", lmopts, lmarray, lmcmd, sizeof (lmcmd)); - (void) strlcat(lmcmd, ";", sizeof (lmcmd)); - - st = mms_mgmt_send_cmd(sessp, tid, lmcmd, fnam, &response); - } - -done: - if (libattrs) { - nvlist_free(libattrs); - } - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -int -mms_modify_drive(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char *fnam = "mms_modify_drive()"; - char *drvname; - void *sess = NULL; - void *sessp = session; - char tid[64]; - char cmd[8192]; - char dmcmd[8192]; - char dgcmd[8192]; - char dgacmd[8192]; - nvlist_t *drvattrs = NULL; - nvlist_t *dgattrs = NULL; - nvlist_t *dgaattrs = NULL; - nvlist_t *dmattrs = NULL; - void *response = NULL; - int count = 0; - int dgcount = 0; - int dmcount = 0; - char *carray[DRVOPT_COUNT]; - char *dgarray[DGOPT_COUNT]; - char *dmarray[DMOPT_COUNT]; - nvpair_t *nvp; - nvlist_t *nva; - boolean_t dodg = B_FALSE; - boolean_t dodga = B_FALSE; - char *dgname = NULL; - int numdms = 0; - nvlist_t *olddm[10]; /* should never need more than 2 */ - int numdga = 0; - nvlist_t *olddga[10]; - - if (!mgmt_chk_auth("solaris.mms.modify")) { - return (EACCES); - } - - (void) memset(&carray, 0, sizeof (carray)); - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - st = nvlist_lookup_string(nvl, O_NAME, &drvname); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - } - - /* only get the DRIVEGROUP if we need it */ - if (nvlist_exists(nvl, O_APPS)) { - dodg = B_TRUE; - dodga = B_TRUE; - } else if (nvlist_exists(nvl, O_UNLOADTM)) { - dodg = B_TRUE; - } - - /* see if there are DRIVE attrs to be changed. */ - (void) mms_gen_taskid(tid); - - /* figure out what things are changing */ - st = mgmt_find_changed_attrs("DRIVE", driveopts, nvl, carray, &count, - errs); - - if (st != 0) { - return (st); - } - - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] match[streq (DRIVE.'%s' '%s')] " - "reportmode[namevalue] report[DRIVE];", tid, "DriveName", drvname); - - /* DM */ - st = mgmt_find_changed_attrs("DM", dmopts, nvl, dmarray, &dmcount, - errs); - - if (st != 0) { - return (st); - } - - (void) mms_gen_taskid(tid); - - if (nvlist_exists(nvl, O_DEVCONN)) { - /* need to make sure we've got info about all the DMs */ - (void) snprintf(dmcmd, sizeof (dmcmd), - "show task['%s'] " - "match[streq(DM.'DriveName' '%s')] " - "reportmode[namevalue] report[DM];", tid, drvname); - dmcount++; - } - if (st != 0) { - return (st); - } - - /* connect to MM */ - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - /* fetch the drive attributes */ - st = mms_mgmt_send_cmd(sessp, tid, cmd, fnam, &response); - if (st == 0) { - st = mmp_get_nvattrs("DriveName", B_FALSE, response, - &drvattrs); - mms_free_rsp(response); - } - if (st != 0) { - goto done; - } - - /* DRIVEGROUP */ - if (dodg) { - st = nvlist_lookup_nvlist(drvattrs, drvname, &nva); - if (nva == NULL) { - /* uh oh */ - st = ENOENT; - } else { - if (st == 0) { - st = nvlist_lookup_string(nva, "DriveGroupName", - &dgname); - } - } - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - goto done; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(dgcmd, sizeof (dgcmd), - "show task['%s'] " - "match[streq(DRIVEGROUP.'DriveGroupName' '%s')] " - "reportmode[namevalue] report[DRIVEGROUP];", tid, dgname); - } - - if (dodga) { - /* - * get all of them. We need to make sure all apps - * in O_APPS are represented. - */ - - (void) mms_gen_taskid(tid); - (void) snprintf(dgacmd, sizeof (dgacmd), - "show task['%s'] report[DRIVEGROUPAPPLICATION] " - "match[streq(DRIVEGROUPAPPLICATION.'DriveGroupName' '%s')]" - " reportmode[namevalue];", tid, dgname); - } - - if ((count == 0) && (dmcount == 0) && !dodg && !dodga) { - /* nothing to do */ - goto done; - } - - if (dodg) { - st = mms_mgmt_send_cmd(sessp, tid, dgcmd, fnam, &response); - if (st == 0) { - st = mmp_get_nvattrs("DriveGroupName", B_FALSE, - response, &dgattrs); - mms_free_rsp(response); - } - if (st != 0) { - goto done; - } - } - - if (dmcount > 0) { - st = mms_mgmt_send_cmd(sessp, tid, dmcmd, fnam, &response); - if (st == 0) { - st = mmp_get_nvattrs("DMName", B_FALSE, response, - &dmattrs); - mms_free_rsp(response); - } - if (st != 0) { - goto done; - } - } - - if (dodga) { - st = mms_mgmt_send_cmd(sessp, tid, dgacmd, fnam, &response); - if (st == 0) { - st = mmp_get_nvattrs("ApplicationName", B_FALSE, - response, &dgaattrs); - } - if (st != 0) { - goto done; - } - } - - st = nvlist_lookup_nvlist(drvattrs, drvname, &nva); - if (st == 0) { - cmp_mmp_opts(driveopts, carray, nva, &count); - if (count > 0) { - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "attribute task['%s'] " - "match[streq (DRIVE.'DriveName' '%s')] ", - tid, drvname); - - mk_set_clause("DRIVE", driveopts, carray, cmd, - sizeof (cmd)); - (void) strlcat(cmd, ";", sizeof (cmd)); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, fnam, - &response); - if (st != 0) { - goto done; - } - } - } - - st = nvlist_lookup_nvlist(dgattrs, dgname, &nva); - if (st == 0) { - cmp_mmp_opts(drvgrpopts, dgarray, nva, &dgcount); - if (dgcount > 0) { - (void) mms_gen_taskid(tid); - (void) snprintf(dgcmd, sizeof (dgcmd), - "attribute task['%s'] " - "match[streq (DRIVEGROUP.'DriveGroupName' '%s')] ", - tid, dgname); - - mk_set_clause("DRIVEGROUP", drvgrpopts, dgarray, dgcmd, - sizeof (dgcmd)); - (void) strlcat(dgcmd, ";", sizeof (dgcmd)); - - st = mms_mgmt_send_cmd(sessp, tid, dgcmd, fnam, - &response); - if (st != 0) { - goto done; - } - } - } - - nvp = NULL; - while ((nvp = nvlist_next_nvpair(dmattrs, nvp)) != NULL) { - st = nvpair_value_nvlist(nvp, &nva); - if (!nva) { - continue; - } - - /* be more robust here. If it > 2, that's surprising */ - if (numdms < 10) { - olddm[numdms++] = nva; - } - } - - /* Update the DMs */ - st = update_DMs(sessp, drvname, olddm, numdms, nvl, errs); - if (st != 0) { - goto done; - } - - nvp = NULL; - while ((nvp = nvlist_next_nvpair(dgaattrs, nvp)) != NULL) { - if ((nvpair_value_nvlist(nvp, &nva)) != 0) { - continue; - } - - /* - * For DRIVEGROUPAPPLICATION, need to check - * current DGAs. Remove any not reflected in - * app list, add new - */ - if (numdga < 10) { - olddga[numdga++] = nva; - } - } - - /* Update the DriveGroupApplications */ - st = update_DGAs(sessp, dgname, olddga, numdga, nvl, errs); - -done: - if (sess) { - (void) mms_goodbye(sess, 0); - } - - if (drvattrs) { - nvlist_free(drvattrs); - } - if (dmattrs) { - nvlist_free(dmattrs); - } - if (dgattrs) { - nvlist_free(dgattrs); - } - if (dgaattrs) { - nvlist_free(dgaattrs); - } - - return (st); -} - -static int -update_DGAs(void *session, char *dgname, nvlist_t **old, int count, - nvlist_t *nvl, nvlist_t *errs) -{ - int st; - int vcount; - char **varray = NULL; - int i; - int j; - char *val; - char cmd[8192]; - char tid[64]; - void *response; - int rst = 0; - - if (!session || !dgname || !old || !nvl) { - return (MMS_MGMT_NOARG); - } - - vcount = 0; - varray = mgmt_var_to_array(nvl, O_APPS, &vcount); - - for (i = 0; i < count; i++) { - val = NULL; - - (void) nvlist_lookup_string(old[i], "ApplicationName", &val); - if (!val) { - continue; - } - - for (j = 0; j < vcount; j++) { - if (!varray[j]) { - continue; - } - if (strcmp(val, varray[j]) == 0) { - /* match, keep this one */ - free(varray[j]); - varray[j] = NULL; - break; - } - } - - if (j == vcount) { - /* Remove this DGA */ - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[DRIVEGROUPAPPLICATION] " - "match[ and (" - "streq(DRIVEGROUPAPPLICATION.'DriveGroupName' " - "'%s') " - "streq(DRIVEGROUPAPPLICATION.'ApplicationName' " - "'%s')" - ") ];", tid, dgname, val); - - st = mms_mgmt_send_cmd(session, tid, cmd, "removeDGA", - &response); - if (st != 0) { - if (rst == 0) { - rst = st; - } - MGMT_ADD_ERR(errs, val, st); - } - } - } - - /* add any remaining */ - for (i = 0; i < vcount; i++) { - if (!varray[i] || (strlen(varray[i]) == 0) || - (strcasecmp(varray[i], "none") == 0) || - (strcasecmp(varray[i], "all") == 0)) { - continue; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "create task['%s'] type[DRIVEGROUPAPPLICATION] " - "set[DRIVEGROUPAPPLICATION.'DriveGroupName' '%s'] " - "set[DRIVEGROUPAPPLICATION.'ApplicationName' '%s'];", - tid, dgname, varray[i]); - - st = mms_mgmt_send_cmd(session, tid, cmd, "add DGA", - &response); - if (st != 0) { - if (rst == 0) { - rst = st; - } - MGMT_ADD_ERR(errs, val, st); - } - } - - mgmt_free_str_arr(varray, vcount); - - return (rst); -} - -static int -update_DMs(void *session, char *drive, nvlist_t **olddms, int count, - nvlist_t *nvl, nvlist_t *errs) -{ - int st; - int rst = 0; - int i; - int j; - int vcount; - char **varray = NULL; - char *val = NULL; - char *val2 = NULL; - char *msglevel = NULL; - char *trclevel = NULL; - char *trcsz = NULL; - boolean_t updated = B_FALSE; - void *sess = NULL; - void *sessp = session; - char cmd[8192]; - char tid[64]; - void *response = NULL; - int highid = 0; - char buf[1024]; - char *bufp; - - if (!drive || !olddms || !nvl) { - return (MMS_MGMT_NOARG); - } - - (void) nvlist_lookup_string(nvl, O_MSGLEVEL, &msglevel); - (void) nvlist_lookup_string(nvl, O_TRACELEVEL, &trclevel); - (void) nvlist_lookup_string(nvl, O_TRACESZ, &trcsz); - - (void) snprintf(buf, sizeof (buf), "DM_%s_", drive); - - vcount = 0; - varray = mgmt_var_to_array(nvl, O_DEVCONN, &vcount); - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - for (i = 0; i < count; i++) { - /* save away existing values in case we need to add a DM */ - if (!msglevel) { - (void) nvlist_lookup_string(olddms[i], "DMMessagelevel", - &msglevel); - } - if (!trclevel) { - (void) nvlist_lookup_string(olddms[i], "TraceLevel", - &trclevel); - } - if (!trcsz) { - (void) nvlist_lookup_string(olddms[i], "TraceFileSize", - &trcsz); - } - - (void) nvlist_lookup_string(olddms[i], "DMTargetHost", &val); - (void) nvlist_lookup_string(olddms[i], "DMName", &val2); - - for (j = 0; j < vcount; j++) { - if (!varray[j]) { - continue; - } - bufp = val2; - - if (mgmt_compare_hosts(varray[i], val) != 0) { - continue; - } - /* this DM can stay. */ - if (strncmp(buf, val2, strlen(buf)) == 0) { - bufp += strlen(buf); - st = atoi(bufp); - if (st > highid) { - highid = st; - } - st = 0; - } - free(varray[j]); - varray[j] = NULL; - break; - } - if ((vcount > 1) && (j == vcount)) { - /* This DM needs to be removed */ - if (st != 0) { - if (rst == 0) { - rst = st; - } - (void) snprintf(cmd, sizeof (cmd), - "%s = %s", O_DEVCONN, val); - MGMT_ADD_ERR(errs, cmd, EINVAL); - continue; - } - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[DM] " - "match[ streq(DM.'DMName' '%s')];", - tid, val2); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "removeDM", - &response); - if (st != 0) { - if (rst == 0) { - rst = st; - } - MGMT_ADD_ERR(errs, val2, st); - continue; - } - } - } - - /* - * unused DMs are gone. Add any new ones, and update all with - * new values if any - */ - for (i = 0; i < vcount; i++) { - if (!varray[i]) { - continue; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "create task['%s'] type[DM] " - "set[DM.'DMName' 'DM_%s_%d'] " - "set[DM.'DriveName' '%s'] " - "set[DM.'DMTargetHost' '%s'] ", - tid, drive, ++highid, drive, varray[i]); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "addDM", - &response); - if (st != 0) { - if (rst == 0) { - rst = st; - } - MGMT_ADD_ERR(errs, varray[i], st); - } - free(varray[i]); - } - /* done with the new DMs */ - free(varray); - - /* update any existing DMs with the new values, if any */ - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "attribute task['%s'] " - "match[ streq(DM.'DriveName' '%s')]", tid, drive); - - if (msglevel) { - (void) snprintf(buf, sizeof (buf), - " set[DM.'DMMessageLevel' '%s']", msglevel); - (void) strlcat(cmd, buf, sizeof (cmd)); - updated = B_TRUE; - } - if (trclevel) { - (void) snprintf(buf, sizeof (buf), - " set[DM.'TraceLevel' '%s']", trclevel); - (void) strlcat(cmd, buf, sizeof (cmd)); - updated = B_TRUE; - } - if (trcsz) { - (void) snprintf(buf, sizeof (buf), - " set[DM.'TraceFileSize' '%s']", trcsz); - (void) strlcat(cmd, buf, sizeof (cmd)); - updated = B_TRUE; - } - (void) strlcat(cmd, ";", sizeof (cmd)); - - if (updated) { - st = mms_mgmt_send_cmd(sessp, tid, cmd, "updateDM", - &response); - if (st != 0) { - if (rst == 0) { - rst = st; - } - } - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (rst); -} - -/* Online/Offline functions */ -int -mms_mgmt_set_state(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char *fnam = "mms_mgmt_set_state()"; - char *otype; - char *name; - char cmd[8192]; - char tid[64]; - void *sess = NULL; - void *sessp = session; - void *response = NULL; - char *state = NULL; - char *val; - char buf[1024]; - nvlist_t *attrs = NULL; - nvpair_t *nvp; - nvlist_t *nva; - char *key = NULL; - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.device.state")) { - return (EACCES); - } - - st = nvlist_lookup_string(nvl, O_OBJTYPE, &otype); - if (st == 0) { - if ((strcmp(otype, "drive") != 0) && - (strcmp(otype, "library") != 0)) { - st = EINVAL; - } - } - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_OBJTYPE, st); - return (st); - } - - st = nvlist_lookup_string(nvl, O_OBJSTATE, &state); - if (st == 0) { - if ((strcmp(state, "online") != 0) && - (strcmp(state, "offline") != 0)) { - st = EINVAL; - } - } - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_OBJSTATE, st); - return (st); - } - - st = nvlist_lookup_string(nvl, O_NAME, &name); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - /* get LM or DM names */ - (void) mms_gen_taskid(tid); - if (*otype == 'l') { - key = "LMName"; - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] " - "match[streq(LM.'LibraryName' '%s')] " - "report[LM.'LMName'];", - tid, name); - } else { - key = "DMName"; - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] " - "match[streq(DM.'DriveName' '%s')] " - "report[DM.'DMName' DM.'DMTargetHost'];", - tid, name); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - st = mms_mgmt_send_cmd(sessp, tid, cmd, fnam, &response); - if (st == 0) { - st = mmp_get_nvattrs(key, B_FALSE, response, &attrs); - mms_free_rsp(response); - } - if (st != 0) { - if (sess) { - (void) mms_goodbye(sess, 0); - } - return (st); - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "%s task['%s'] %s['%s'", otype, tid, state, name); - - nvp = NULL; - - /* LM required for lib online, but must not be sent for offline */ - if ((strcmp(otype, "library") == 0) && - (strcmp(state, "online") == 0)) { - while ((nvp = nvlist_next_nvpair(attrs, nvp)) != NULL) { - st = nvpair_value_nvlist(nvp, &nva); - if (st != 0) { - continue; - } - st = nvlist_lookup_string(nva, "LMName", &val); - if (st == 0) { - (void) snprintf(buf, sizeof (buf), - " '%s'", val); - (void) strlcat(cmd, buf, sizeof (cmd)); - } - } - st = 0; - } - (void) strlcat(cmd, "];", sizeof (cmd)); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, fnam, &response); - /* not a failure if already in requested state */ - if ((st == MMS_ELIBALREADYONLINE) || - (st == MMS_EDRIVEALREADYONLINE) || - (st == MMS_ELIBALREADYOFFLINE) || - (st == MMS_EDRIVEALREADYOFFLINE)) { - st = 0; - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -int -mms_mgmt_list_drives(void *session, nvlist_t *nvl, nvlist_t *errs, - nvlist_t **drvs) -{ - int st; - void *sessp = session; - void *sess = NULL; - void *response = NULL; - char tid[64]; - char cmd[8192]; - nvlist_t *drvattrs = NULL; - nvpair_t *nvp = NULL; - nvlist_t *drv; - char *val; - char *conn[10]; /* should never be more than 2 */ - char *apps[10]; /* fix this to be dynamic */ - nvlist_t *oattrs = NULL; - nvpair_t *dvp; - nvlist_t *dva; - char *dval; - int i; - boolean_t first; - int count = 0; - char **varray = NULL; - char buf[2048]; - - if (!drvs) { - return (MMS_MGMT_NOARG); - } - - if (*drvs == NULL) { - st = nvlist_alloc(drvs, 0, 0); - if (st != 0) { - MGMT_ADD_ERR(errs, "internal error", st); - return (st); - } - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - /* primary filter on name */ - varray = mgmt_var_to_array(nvl, O_NAME, &count); - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] report[DRIVE] reportmode[namevalue]", tid); - - if (count == 1) { - (void) snprintf(buf, sizeof (buf), - " match[streq(DRIVE.'DriveName' '%s')]", - varray[0]); - (void) strlcat(cmd, buf, sizeof (cmd)); - } else if (count > 1) { - (void) strlcat(cmd, " match[or (", sizeof (cmd)); - - for (i = 0; i < count; i++) { - if (!varray[i]) { - continue; - } - (void) snprintf(buf, sizeof (buf), - "streq(DRIVE.'DriveName' '%s') ", - varray[i]); - (void) strlcat(cmd, buf, sizeof (cmd)); - } - (void) strlcat(cmd, ")]", sizeof (cmd)); - } - (void) strlcat(cmd, ";", sizeof (cmd)); - - mgmt_free_str_arr(varray, count); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "list_drives()", &response); - if (st == 0) { - st = mmp_get_nvattrs(O_NAME, B_TRUE, response, &drvattrs); - mms_free_rsp(response); - } - if (st != 0) { - goto done; - } - - while ((nvp = nvlist_next_nvpair(drvattrs, nvp)) != NULL) { - st = nvpair_value_nvlist(nvp, &drv); - if (st != 0) { - /* should never happen */ - continue; - } - st = nvlist_lookup_string(drv, O_NAME, &val); - if (st != 0) { - /* bad response from MM */ - continue; - } - - (void) memset(&conn, 0, sizeof (conn)); - (void) memset(&apps, 0, sizeof (apps)); - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] report[DM] reportmode[namevalue] " - "match[streq(DM.'DriveName' '%s')];", tid, val); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "list_dm()", - &response); - - if (st != 0) { - continue; - } - - oattrs = NULL; - i = 0; - - st = mmp_get_nvattrs("DMName", B_FALSE, response, &oattrs); - mms_free_rsp(response); - - dvp = NULL; - - while ((dvp = nvlist_next_nvpair(oattrs, dvp)) != NULL) { - st = nvpair_value_nvlist(dvp, &dva); - if (st != 0) { - continue; - } - - st = nvlist_lookup_string(dva, "DMTargetHost", &dval); - if (st == 0) { - conn[i++] = dval; - } - - if (!nvlist_exists(dva, O_TRACESZ)) { - st = nvlist_lookup_string(dva, "TraceFileSize", - &dval); - if (st == 0) { - (void) nvlist_add_string(drv, O_TRACESZ, - dval); - } - } - if (!nvlist_exists(dva, O_TRACELEVEL)) { - st = nvlist_lookup_string(dva, "TraceLevel", - &dval); - if (st == 0) { - (void) nvlist_add_string(drv, - O_TRACELEVEL, dval); - } - } - } - cmd[0] = '\0'; - first = B_TRUE; - - while (i > 0) { - if (!first) { - (void) strlcat(cmd, ",", sizeof (cmd)); - } else { - first = B_FALSE; - } - (void) strlcat(cmd, conn[--i], sizeof (cmd)); - } - (void) nvlist_add_string(drv, O_DEVCONN, cmd); - - nvlist_free(oattrs); - oattrs = NULL; - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] " - "report[DRIVEGROUPAPPLICATION.'ApplicationName'] " - "match[streq(DRIVE.'DriveName' '%s')];", tid, val); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "list drive apps()", - &response); - - if (st == 0) { - st = mmp_get_nvattrs("ApplicationName", B_FALSE, - response, &oattrs); - mms_free_rsp(response); - } - - if (st != 0) { - continue; - } - - i = 0; - while ((dvp = nvlist_next_nvpair(oattrs, dvp)) != NULL) { - dval = nvpair_name(dvp); - if (dval == NULL) { - continue; - } - - apps[i++] = dval; - } - - cmd[0] = '\0'; - first = B_TRUE; - - while (i > 0) { - if (!first) { - (void) strlcat(cmd, ",", sizeof (cmd)); - } else { - first = B_FALSE; - } - (void) strlcat(cmd, apps[--i], sizeof (cmd)); - } - (void) nvlist_add_string(drv, O_APPS, cmd); - - nvlist_free(oattrs); - - (void) nvlist_add_nvlist(*drvs, val, drv); - } - - /* filter before returning */ - mgmt_filter_results(nvl, *drvs); - - /* reset status */ - st = 0; - -done: - nvlist_free(drvattrs); - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - - return (st); -} - -int -mms_mgmt_list_libraries(void *session, nvlist_t *nvl, nvlist_t *errs, - nvlist_t **libs) -{ - int st; - void *sessp = session; - void *sess = NULL; - void *response = NULL; - char tid[64]; - char cmd[8192]; - nvlist_t *libattrs = NULL; - nvpair_t *nvp = NULL; - nvlist_t *lib; - char *val; - nvlist_t *oattrs = NULL; - nvpair_t *lvp; - nvlist_t *lva; - char *lval; - int count = 0; - int i; - char **varray = NULL; - char buf[2048]; - - if (!libs) { - return (MMS_MGMT_NOARG); - } - - if (*libs == NULL) { - st = nvlist_alloc(libs, 0, 0); - if (st != 0) { - MGMT_ADD_ERR(errs, "internal error", st); - return (st); - } - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - /* primary filter on name */ - varray = mgmt_var_to_array(nvl, O_NAME, &count); - - (void) mms_gen_taskid(tid); - - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] report[LIBRARY] reportmode[namevalue]", tid); - - if (count == 1) { - (void) snprintf(buf, sizeof (buf), - " match[streq(LIBRARY.'LibraryName' '%s')]", - varray[0]); - (void) strlcat(cmd, buf, sizeof (cmd)); - } else if (count > 1) { - (void) strlcat(cmd, " match[or (", sizeof (cmd)); - - for (i = 0; i < count; i++) { - if (!varray[i]) { - continue; - } - (void) snprintf(buf, sizeof (buf), - "streq(LIBRARY.'LibraryName' '%s') ", - varray[i]); - (void) strlcat(cmd, buf, sizeof (cmd)); - } - (void) strlcat(cmd, ")]", sizeof (cmd)); - } - (void) strlcat(cmd, ";", sizeof (cmd)); - - mgmt_free_str_arr(varray, count); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "list_libraries()", &response); - if (st == 0) { - st = mmp_get_nvattrs(O_MMSLIB, B_TRUE, response, &libattrs); - mms_free_rsp(response); - } - if (st != 0) { - goto done; - } - - while ((nvp = nvlist_next_nvpair(libattrs, nvp)) != NULL) { - st = nvpair_value_nvlist(nvp, &lib); - if (st != 0) { - /* should never happen */ - continue; - } - st = nvlist_lookup_string(lib, O_MMSLIB, &val); - if (st != 0) { - /* bad response from MM */ - continue; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] report[LM] reportmode[namevalue] " - "match[streq(LM.'LibraryName' '%s')];", tid, val); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "list_dm()", - &response); - - if (st != 0) { - continue; - } - - oattrs = NULL; - - st = mmp_get_nvattrs("LMName", B_FALSE, response, &oattrs); - mms_free_rsp(response); - - lvp = NULL; - - while ((lvp = nvlist_next_nvpair(oattrs, lvp)) != NULL) { - st = nvpair_value_nvlist(lvp, &lva); - if (st != 0) { - continue; - } - - if (!nvlist_exists(lva, O_TRACESZ)) { - st = nvlist_lookup_string(lva, "TraceFileSize", - &lval); - if (st == 0) { - (void) nvlist_add_string(lib, O_TRACESZ, - lval); - } - } - if (!nvlist_exists(lva, O_TRACELEVEL)) { - st = nvlist_lookup_string(lva, "TraceLevel", - &lval); - if (st == 0) { - (void) nvlist_add_string(lib, - O_TRACELEVEL, lval); - } - } - if (!nvlist_exists(lva, O_MSGLEVEL)) { - st = nvlist_lookup_string(lva, "MessageLevel", - &lval); - if (st == 0) { - (void) nvlist_add_string(lib, - O_MSGLEVEL, lval); - } - } - } - - nvlist_free(oattrs); - - (void) nvlist_add_nvlist(*libs, val, lib); - } - - /* filter before returning */ - mgmt_filter_results(nvl, *libs); - - /* reset status */ - st = 0; - -done: - nvlist_free(libattrs); - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - - return (st); -} - -int -mgmt_get_dgname(void *session, char *dgname, nvlist_t **dg) -{ - int st; - void *sess = NULL; - void *sessp = session; - void *response; - char tid[64]; - char cmd[8192]; - - if (!dg) { - return (MMS_MGMT_NOARG); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - *dg = NULL; - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] " - "match[streq(DRIVEGROUP.'DriveGroupName' '%s')] " - "report[DRIVEGROUP.'DriveGroupName'] " - "reportmode[namevalue]; ", tid, dgname); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "mgmt_get_dgname", - &response); - if (st == 0) { - st = mmp_get_nvattrs("DriveGroupName", B_FALSE, response, - dg); - mms_free_rsp(response); - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -int -mgmt_get_cgname(void *session, char *cgname, nvlist_t **cg) -{ - int st; - void *sess = NULL; - void *sessp = session; - void *response; - char tid[64]; - char cmd[8192]; - - if (!cg) { - return (MMS_MGMT_NOARG); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - *cg = NULL; - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] " - "match[streq(CARTRIDGEGROUP.'CartridgeGroupName' '%s')] " - "report[CARTRIDGEGROUP.'CartridgeGroupName'] " - "reportmode[namevalue]; ", tid, cgname); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "mgmt_get_cgname", - &response); - if (st == 0) { - st = mmp_get_nvattrs("CartridgeGroupName", B_FALSE, response, - cg); - mms_free_rsp(response); - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -/* - * mms_mgmt_modify_dpool() - * Add applications to existing dpool (DRIVEGROUP) by adding a - * DRIVEGROUPAPPLICATION for every app specified. - */ -int -mms_mgmt_modify_dpool(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char **varray = NULL; - int count = 0; - int i; - char cmd[8192]; - char tid[64]; - void *sess = NULL; - void *sessp = session; - void *response; - char *dpool; - nvlist_t *dgattrs = NULL; - nvlist_t *new = NULL; - - /* get list of apps, if new list != old list, update */ - - if (!mgmt_chk_auth("solaris.mms.modify")) { - return (EACCES); - } - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - st = nvlist_lookup_string(nvl, O_NAME, &dpool); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - varray = mgmt_var_to_array(nvl, O_APPS, &count); - if (varray == NULL) { - /* error or nothing to do? */ - return (0); - } - - /* get list of already-established apps */ - (void) mms_gen_taskid(tid); - - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] " - "match[streq(DRIVEGROUPAPPLICATION.'DriveGroupName' '%s')] " - "report[DRIVEGROUPAPPLICATION.'ApplicationName'];", - tid, dpool); - - if (session == NULL) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - goto done; - } - sessp = sess; - } - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "modify drivegroup", - &response); - if (st == 0) { - st = mmp_get_nvattrs("ApplicationName", B_FALSE, response, - &dgattrs); - mms_free_rsp(response); - } - if (st != 0) { - goto done; - } - - /* see if we need to add any apps */ - for (i = 0; i < count; i++) { - if (!varray[i] || (strlen(varray[i]) == 0) || - (strcasecmp(varray[i], "none") == 0) || - (strcasecmp(varray[i], "all") == 0)) { - continue; - } - - if (!nvlist_exists(dgattrs, varray[i])) { - if (!new) { - (void) nvlist_alloc(&new, NV_UNIQUE_NAME, 0); - (void) nvlist_add_string(new, O_NAME, dpool); - } - - (void) nvlist_add_string(new, O_APPS, varray[i]); - st = mms_add_object(sessp, "DRIVEGROUPAPPLICATION", - drvgrpappopts, new, errs); - if (st != 0) { - break; - } - } - } - -done: - - if (new) { - nvlist_free(new); - } - - if (dgattrs) { - nvlist_free(dgattrs); - } - - mgmt_free_str_arr(varray, count); - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -int -mms_mgmt_add_dpool(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char **varray = NULL; - int count = 0; - char *dpool = NULL; - int i; - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.create")) { - return (EACCES); - } - - st = nvlist_lookup_string(nvl, O_NAME, &dpool); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - /* save original values */ - varray = mgmt_var_to_array(nvl, O_APPS, &count); - if (count == 0) { - st = MMS_MGMT_ERR_REQUIRED; - MGMT_ADD_OPTERR(errs, O_APPS, st); - return (st); - } - - st = mms_add_object(session, "DRIVEGROUP", drvgrpopts, - nvl, errs); - if (st == EEXIST) { - MGMT_ADD_OPTERR(errs, dpool, st); - return (st); - } - if (st == 0) { - for (i = 0; i < count; i++) { - if (!varray[i] || (strlen(varray[i]) == 0) || - (strcasecmp(varray[i], "none") == 0) || - (strcasecmp(varray[i], "all") == 0)) { - continue; - } - - /* put back a single value */ - (void) nvlist_add_string(nvl, O_APPS, varray[i]); - st = mms_add_object(session, - "DRIVEGROUPAPPLICATION", drvgrpappopts, nvl, errs); - if (st != 0) { - MGMT_ADD_ERR(errs, varray[i], st); - break; - } - } - - /* put back original values */ - if (varray) { - (void) nvlist_add_string_array(nvl, O_APPS, varray, - count); - mgmt_free_str_arr(varray, count); - } - } - return (st); -} diff --git a/usr/src/lib/mms/mgmt/common/mgmt_library.h b/usr/src/lib/mms/mgmt/common/mgmt_library.h deleted file mode 100644 index 0c25cb5fca..0000000000 --- a/usr/src/lib/mms/mgmt/common/mgmt_library.h +++ /dev/null @@ -1,346 +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 _MGMT_MMS_LIBRARY_H -#define _MGMT_MMS_LIBRARY_H - - -/* - * mgmt_library.h - * - * This header contains the definitions of a library and drives that are - * controlled by the Solaris Media Management System - * - * This header includes functions such as - * 1. get library(s) - * 2. get drive(s) (by library) - * 3. add library - * 4. add drive to library - * 5. remove library - * 6. remove drive(s) from library - * 7. change library/drive state - * 8. get supported libraries and drives - To bo provided by MMS team - * - * mms_get_library(), mms_get drive(), mms_get_dm(), mms_get_lm() - * mms_add_library(), mms_add_drive() - * mms_del_library(), mms_del_drive(), - * online/offline drive, online/offline DM - */ - -#include <stdio.h> -#include <sys/nvpair.h> - -#include "mms.h" -#include "mgmt_util.h" -#include "mgmt_acsls.h" - -/* - * The MMS implementation currently supports the StorageTek ACSLS network - * attached libraries namely L180, L700 and L500, and the 9840, LTO1, LTO2, - * LTO3 and DISK (disk archiving) drives. - * - * All definitions for a library are specific to the ACSLS library, for a - * direct attached library, it is not clear as to what connection parameters - * i.e. SCSI ID, device paths etc are required. - * - * TBD: The list of supported drive and library types should be maintained - * in the MM. - */ - -/* Structure to define an ACSLS-connected library in MMS */ -typedef struct mms_acslib { - mms_list_node_t lib_link; - char name[MAXNAMELEN]; /* Type_SerialNumber */ - char serialnum[MAXSERIALNUMLEN]; - char type[32]; - char acshost[MAXHOSTNAMELEN]; - uint32_t acsport; - uint32_t flags; /* state and status */ - uint32_t acs; - uint32_t lsm; - mms_list_t drive_list; - mms_list_t lm_list; -} mms_acslib_t; - -/* - * The MMS defines a Library Manager(LM) to manage each Library object. While - * the MMS spec supports a library to be managed by multiple LMs (without any - * upper limit), multiple LMs are only required for switchover or failover - * purposes. As such, for the first release of the MMS api, the hostname of - * the LM is defaulted to the MM host. - */ - -/* Structure to define the LMs in MMS */ -typedef struct mms_lm { - mms_list_node_t lm_link; - char name[MAXNAMELEN]; - char hostname[MAXHOSTNAMELEN]; - uint32_t flags; -} mms_lm_t; - -/* Structure to define the drive in MMS */ -typedef struct mms_drive { - mms_list_node_t drive_link; - char name[MAXNAMELEN]; /* DRV_SerialNumber */ - char serialnum[MAXSERIALNUMLEN]; - char type[32]; - uint32_t flags; /* status, state */ - char libname[MAXNAMELEN]; - int32_t blocksize; - int32_t priority; - mms_list_t dm_list; - mms_list_t app_list; /* application names */ - char devpath[256]; /* drive /dev path */ - char volid[64]; /* vol name in drive, if any */ - uint32_t acs; - uint32_t lsm; - uint32_t panel; - uint32_t drive; -} mms_drive_t; - -/* Flags (status/state) for a Drive */ - -/* drive is not supported by MMS */ -#define MMS_ST_DRIVE_UNSUPPORTED 0x00000001 -/* drive is not configured in MM */ -#define MMS_ST_DRIVE_UNCONFIGURED 0x00000002 -/* use of drive is suspended although it is configured and running */ -#define MMS_ST_DRIVE_DISABLED 0x00000004 -#define MMS_ST_DRIVE_BROKEN 0x00000008 -#define MMS_ST_DRIVE_INUSE 0x00000010 -#define MMS_ST_DRIVE_READY 0x00000020 -#define MMS_ST_DRIVE_LOADED 0x00000040 -#define MMS_ST_DRIVE_LOADING 0x00000080 -#define MMS_ST_DRIVE_UNLOADING 0x00000100 -#define MMS_ST_DRIVE_UNLOADED 0x00000200 -/* LM cannot mount/unmount cartridges */ -#define MMS_ST_DRIVE_INACCESSIBLE 0x00000400 -/* cartridge in drive */ -#define MMS_ST_DRIVE_OCCUPIED 0x00000800 -/* Drive needs cleaning */ -#define MMS_ST_DRIVE_RCLEANING 0x00001000 -/* Drive needs cleaning, but may still allow mounting of cartridges */ -#define MMS_ST_DRIVE_ACLEANING 0x00002000 -/* Drive will not accept mounts until it is cleaned */ -#define MMS_ST_DRIVE_MCLEANING 0x00004000 -#define MMS_ST_DRIVE_OFFLINE 0x00008000 - -/* Structure to define the drive manager (DMs) in MMS */ -typedef struct mms_dm { - mms_list_node_t dm_link; - char name[MAXNAMELEN]; - char drivename[MAXNAMELEN]; - char hostname[MAXHOSTNAMELEN]; - /* drivepath[MAXPATHLEN] not required, MM/DM will map serial number */ -} mms_dm_t; - -/* - * The MM hostname, port number, application name, instance name, tag name and - * the application password are not taken as input parameters for the library - * related functions. Since there can be only one MM in a setup, it is better - * to store these parameters in a config file or SMF and let the calling - * function create the session first and pass the session as an input param - * - * All comunication with the MM requires an unique identifier to determine the - * associated task. This tid is provided optinally as an input param - * - */ - -/* - * The mms_get_library() function returns information about a library from - * MM configuration. - * - * PARAM - * session - IN - - * getdrives - IN - * lib_list - OUT - A list of mms_acslib_t controlled by MMS - * - * RETURN - * upon successful completion, a value of 0 is returned to indicate success and - * lib_list is filled with a list of libraries - * If the request cannot be completed, an appropriate error number is returned - * to signify the error - * - * ERROR - * internal processing errors from MM/LM/DM/API (!MMS_API_OK) - * -- media manager is not found - * -- media manager is not running - * -- unable to connect to the media manager - * MMS_RESPONSE_ECANCELLED - * MMS_RESPONSE_EUNKNOWN - * - */ -int mms_get_library(void *session, boolean_t get_drives, mms_list_t *lib_list); - - -/* - * The mms_get_lm() function returns information about the LM(s) for a - * particular library - * - * PARAM - * session - IN - - * libname - IN - library name - * lm_list - OUT - A list of mms_lm_t controlled by MMS - * - * RETURN - * upon successful completion, a value of 0 is returned to indicate success and - * lm_list is filled with a list of LM - * If the request cannot be completed, an appropriate error number is returned - * to signify the error - * - * ERROR - * - */ -int mms_get_lm(void *session, char *libname, mms_list_t *lm_list); - - -/* - * The mms_get_drives_for_lib() function returns information about the - * drives for a specific library in the MM configuration. - * - * PARAM - * session - IN - - * libname - IN - name of library - * drive_list - OUT - A list of sm_drive_t in the specified library. - * - * RETURN - * upon successful completion, a value of 0 is returned to indicate success and - * drive_list is filled with a list of drives - * If the request cannot be completed, an appropriate error number is returned - * to signify the error - * - * ERROR - * - */ -int mms_get_drives_for_lib(void *session, char *libname, - mms_list_t *drive_list); - - -/* - * The mms_get_dm() function returns information about the DM(s) for a - * particular drive. - * - * PARAM - * session - IN - - * drivename - IN - name of a drive - * dm_list - OUT - A list of sm_dm_t for the given drive - * - * RETURN - * upon successful completion, a value of 0 is returned to indicate success and - * dm_list is filled with a list of DM - * If the request cannot be completed, an appropriate error number is returned - * to signify the error - * - * ERROR - * - */ -int mms_get_dm(void *session, char *drivename, mms_list_t *dm_list); - - -/* - * The mms_add_library() function is used to add a library to the MM - * configuration. The following steps are taken: - * - * 1. A Library object is created and associated with its network IP (ACSLS) - * 2. the Library object is associated with a Library Manager - * 3. Default DriveGroups (if any) are created. - * 4. Drive objects and their respective DMs are created - * 5. Supported SLOTTYPE entries are created - * 6. Supported CARTRIDGETYPE entries are created - * 7. Default CartridgeGroups (if any) are created. - * 8. Library and drives are brought online, unless otherwise requested - * - * PARAM - * session - IN - - * lib - IN - library attributes in an nvlist - * errs - IN - Processing errors in an nvlist - * RETURN - * - * ERROR - * - * A library without drives is useless and so it is considered to be an - * error to add a library without adding some/any of its drives. - * - * IMPLEMENTATION NOTES - * 1. library name is derived from library type and serial number. - * 2. If the library to be added already exists in the MMS configuration, - * then a check is made to see if additional drives are to be added via this - * operation. This request is not treated as an error condition. - * - * QUESTIONS - * 1. How are partial failures to be handled? i.e. if there are 4 drives to be - * added to MMS configuration and only 2 of them could be added? - * - * - */ -int mms_add_library(void *session, nvlist_t *lib, nvlist_t *errs); -int mms_create_library(void *session, nvlist_t *lib, nvlist_t *errs); - - -/* - * This function is used to add drives to an existing library configuration - * - * PARAM - * - * RETURN - */ -int mms_add_drive(void *session, nvlist_t *nvl, nvlist_t *errs); - -/* - * The mms_remove_library() function is used to remove a library from the MM - * configuration. The following steps are taken: - * - * 1. The volume(s) in that library are deleted - * 2. Should the association between the CARTRIDGEGROUP and APPLICATION/INSTANCE - * be deleted? (if there are no other libraries) - * 3. If there are no more entries in the CARTRIDGEGROUP, should it be deleted? - * 4. Should the corresponding SLOTTYPE and CARTRIDGETYPE entries be deleted? - * 5. The drive(s) and their corresponding DM(s) are deleted - * 6. Should the association between the DRIVEGROUP and APPLICATION/INSTANCE - * be deleted? - * 7. If there are no more entries in the DRIVEGROUP, should it be deleted? - * 8. The LM associated with this library is deleted - * 9. The library object is deleted - * - * PARAM - * session - IN - - * libname - IN - library name - * RETURN - */ -int -mms_remove_library(void *session, nvlist_t *lib, nvlist_t *errs); - -int -mms_remove_drive(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_modify_library(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_modify_drive(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mgmt_find_local_drives(nvlist_t **drv_list); - -#endif /* _MGMT_MMS_LIBRARY_H */ diff --git a/usr/src/lib/mms/mgmt/common/mgmt_media.c b/usr/src/lib/mms/mgmt/common/mgmt_media.c deleted file mode 100644 index af05731cec..0000000000 --- a/usr/src/lib/mms/mgmt/common/mgmt_media.c +++ /dev/null @@ -1,2820 +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. - */ - -#include <libgen.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/nvpair.h> -#include <door.h> -#include <fcntl.h> - -#include "mms_mgmt.h" -#include "mgmt_acsls.h" -#include "mmp_defs.h" -#include "mgmt_media.h" -#include "mgmt_sym.h" -#include "mgmt_util.h" - -static char *_SrcFile = __FILE__; -#define HERE _SrcFile, __LINE__ - -static char *mmsmntdoor = "/var/run/mmsmnt_door"; - -static int voltype_in_use(void *session, char *voltype); -static int -mgmt_show_mmvols(void *session, char *pcl, char *library, nvlist_t **vols); -static int -mgmt_show_partition(void *session, char *pcl, char *library, nvlist_t **parts); -static int call_mmsmnt(door_arg_t *arg); - -static char *label_fname = " "; -static mms_mgmt_setopt_t cartridgegrpopts[] = { - {O_NAME, "CartridgeGroupName", NULL, B_TRUE, NULL}, - {NULL, NULL, NULL, B_FALSE, NULL} -}; -#define CGOPT_COUNT sizeof (cartridgegrpopts) / sizeof (mms_mgmt_setopt_t) - -/* - * Note that O_APPS (string array) is required for CartridgeGroupApplication. - * Add a CGA for each application specified in the array. - */ -static mms_mgmt_setopt_t cgappopts[] = { - {O_NAME, "CartridgeGroupName", NULL, B_TRUE, NULL}, - {O_APPS, "ApplicationName", NULL, B_TRUE, NULL}, - {NULL, NULL, NULL, B_FALSE, NULL} -}; -#define CGAOPT_COUNT sizeof (cgappopts) / sizeof (mms_mgmt_setopt_t) - -/* - * mms_mgmt_discover_media() - * - * Finds ACSLS media, optionally filtered by library acs & lsm. - * Those already configured for use with MMS are filtered out unless - * 'showall' is TRUE. - * - * Required opts are: - * acshost - * acsport (if not the default) - * -- or -- - * library - * If library specified, get ACS information from LIBRARY object. - */ -int -mms_mgmt_discover_media( - void *session, boolean_t showall, nvlist_t *opts, mms_list_t *vol_list, - nvlist_t *errs) -{ - int st; - mms_acslib_t *lsm = NULL; - mms_acslib_t *nlsm = NULL; - mms_acscart_t *vol = NULL; - mms_acscart_t *nvol = NULL; - mms_list_t lib_list; - char *acshost = NULL; - char *val = NULL; - char **in_libs = NULL; - int count = 0; - void *sess = NULL; - void *sessp = session; - boolean_t found; - int i; - char tid[64]; - char cmd[8192]; - void *response; - nvlist_t *volattrs = NULL; - nvlist_t *avl = NULL; - int ost; - - if (!opts || !vol_list) { - return (MMS_MGMT_NOARG); - } - - (void) memset(vol_list, 0, sizeof (mms_list_t)); - - /* - * we need either the ACSLS host or one or more libraries to - * proceed. - */ - (void) nvlist_lookup_string(opts, O_ACSHOST, &acshost); - in_libs = mgmt_var_to_array(opts, O_MMSLIB, &count); - - if (!acshost && !in_libs) { - st = ENOENT; - MGMT_ADD_OPTERR(errs, O_ACSHOST, st); - MGMT_ADD_OPTERR(errs, O_MMSLIB, st); - - return (st); - } - - if (session == NULL) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st == 0) { - sessp = sess; - } else { - return (st); - } - } - - /* get list of libs MMS knows about */ - st = mms_get_library(sessp, B_FALSE, &lib_list); - if (st != 0) { - goto done; - } - - if (!acshost) { - /* only supporting a single ACSLS server for V1 */ - lsm = mms_list_head(&lib_list); - if (lsm == NULL) { - st = ENOENT; - MGMT_ADD_OPTERR(errs, O_ACSHOST, st); - goto done; - } - acshost = lsm->acshost; - } - - if (count > 0) { - /* remove libraries not in our list */ - lsm = mms_list_head(&lib_list); - while (lsm != NULL) { - nlsm = mms_list_next(&lib_list, lsm); - found = B_FALSE; - - for (i = 0; i < count; i++) { - if (strcmp(in_libs[i], lsm->name) == 0) { - found = B_TRUE; - break; - } - } - if (!found) { - /* remove */ - mms_list_remove(&lib_list, lsm); - free(lsm); - } - lsm = nlsm; - } - } - - /* all of the volumes from the ACSLS server */ - st = get_acs_volumes(acshost, NULL, vol_list); - if (st != 0) { - goto done; - } - - /* weed out volumes for libraries we're not interested in */ - vol = mms_list_head(vol_list); - while (vol != NULL) { - nvol = mms_list_next(vol_list, vol); - found = B_FALSE; - - mms_list_foreach(&lib_list, lsm) { - if (strcmp(lsm->type, "DISK") == 0) { - continue; - } - if ((lsm->acs == vol->libacs) && - (lsm->lsm == vol->liblsm)) { - found = B_TRUE; - break; - } - } - if (!found) { - mms_list_remove(vol_list, vol); - free(vol); - } else { - if (lsm->name[0] != '\0') { - (void) strlcpy(vol->libname, lsm->name, - sizeof (vol->libname)); - } - } - vol = nvol; - } - - /* fetch the list of cartridges MMS knows about */ - (void) mms_gen_taskid(tid); - - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] " - "report[CARTRIDGE.'CartridgePCL' CARTRIDGE.'CartridgeTypeName' " - "CARTRIDGE.'LibraryName' CARTRIDGE.'CartridgeGroupName'] ", tid); - - if (count > 0) { - (void) strlcat(cmd, "match [or ", sizeof (cmd)); - for (i = 0; i < count; i++) { - if (in_libs[i] == NULL) { - continue; - } - (void) strlcat(cmd, "streq(LIBRARY.'LibraryName' ", - sizeof (cmd)); - (void) strlcat(cmd, "'", sizeof (cmd)); - (void) strlcat(cmd, in_libs[i], sizeof (cmd)); - (void) strlcat(cmd, "') ", sizeof (cmd)); - } - (void) strlcat(cmd, "]", sizeof (cmd)); - } - (void) strlcat(cmd, ";", sizeof (cmd)); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "list volumes", &response); - if (st == 0) { - st = mmp_get_nvattrs("volid", B_TRUE, response, &volattrs); - mms_free_rsp(response); - } - - if (st != 0) { - goto done; - } - - /* - * TODO: this will break horribly if barcodes are not unique for - * all libs. Fix this to be more library-aware. - */ - vol = mms_list_head(vol_list); - while (vol != NULL) { - nvol = mms_list_next(vol_list, vol); - - ost = nvlist_lookup_nvlist(volattrs, vol->label, &avl); - if (ost == 0) { - if (!showall) { - mms_list_remove(vol_list, vol); - } else { - ost = nvlist_lookup_string(avl, - O_MPOOL, &val); - if (ost == 0) { - (void) strlcpy(vol->groupname, val, - sizeof (vol->groupname)); - } - } - } - vol = nvol; - } - -done: - mgmt_free_str_arr(in_libs, count); - - if (volattrs) { - nvlist_free(volattrs); - } - - free_acslib_list(&lib_list); - - if (st != 0) { - mms_list_free_and_destroy(vol_list, free); - vol_list = NULL; - } - - return (st); -} - -int -mms_mgmt_add_mpool(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char **varray = NULL; - int count = 0; - int i; - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.create")) { - return (EACCES); - } - - st = mms_add_object(session, "CARTRIDGEGROUP", cartridgegrpopts, - nvl, errs); - - if (st == 0) { - /* save original values */ - varray = mgmt_var_to_array(nvl, O_APPS, &count); - - for (i = 0; i < count; i++) { - if (!varray[i] || (strlen(varray[i]) == 0) || - (strcasecmp(varray[i], "none") == 0) || - (strcasecmp(varray[i], "all") == 0)) { - continue; - } - - /* put back a single value */ - (void) nvlist_add_string(nvl, O_APPS, varray[i]); - st = mms_add_object(session, - "CARTRIDGEGROUPAPPLICATION", cgappopts, nvl, errs); - if (st != 0) { - break; - } - } - - /* put back original values */ - if (varray) { - (void) nvlist_add_string_array(nvl, O_APPS, varray, - count); - mgmt_free_str_arr(varray, count); - } - } - - return (st); -} - -int -mms_mgmt_modify_mpool(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char **varray = NULL; - int count = 0; - int i; - char cmd[8192]; - char tid[64]; - void *sess = NULL; - void *sessp = session; - void *response; - char *mpool; - nvlist_t *cgattrs = NULL; - nvlist_t *new = NULL; - nvpair_t *nvp; - char *val; - boolean_t found; - - /* get list of apps, if new list != old list, update */ - - if (!mgmt_chk_auth("solaris.mms.modify")) { - return (EACCES); - } - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - st = nvlist_lookup_string(nvl, O_NAME, &mpool); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - varray = mgmt_var_to_array(nvl, O_APPS, &count); - if (varray == NULL) { - /* error or nothing to do? */ - return (0); - } - - /* get list of already-established apps */ - (void) mms_gen_taskid(tid); - - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] " - "match[streq(CARTRIDGEGROUPAPPLICATION.'CartridgeGroupName' '%s')] " - "report[CARTRIDGEGROUPAPPLICATION.'ApplicationName'];", - tid, mpool); - - if (session == NULL) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - goto done; - } - sessp = sess; - } - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "modify cartridgegroup", - &response); - if (st == 0) { - st = mmp_get_nvattrs("ApplicationName", B_FALSE, response, - &cgattrs); - mms_free_rsp(response); - } - if (st != 0) { - goto done; - } - - /* see if we need to add any apps */ - for (i = 0; i < count; i++) { - if (!varray[i] || (strlen(varray[i]) == 0) || - (strcasecmp(varray[i], "none") == 0) || - (strcasecmp(varray[i], "all") == 0)) { - continue; - } - - if (!nvlist_exists(cgattrs, varray[i])) { - if (!new) { - (void) nvlist_alloc(&new, NV_UNIQUE_NAME, 0); - (void) nvlist_add_string(new, O_NAME, mpool); - } - - (void) nvlist_add_string(new, O_APPS, varray[i]); - st = mms_add_object(sessp, "CARTRIDGEGROUPAPPLICATION", - cgappopts, new, errs); - if (st != 0) { - break; - } - } - } - - /* and if we need to remove any */ - nvp = NULL; - while ((nvp = nvlist_next_nvpair(cgattrs, nvp)) != NULL) { - val = nvpair_name(nvp); - if (!val) { - /* can't happen? */ - continue; - } - - found = B_FALSE; - - for (i = 0; i < count; i++) { - if (strcmp(val, varray[i]) == 0) { - found = B_TRUE; - break; - } - } - - if (found) { - continue; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[CARTRIDGEGROUPAPPLICATION] " - "match[and " - "(streq(CARTRIDGEGROUPAPPLICATION.'CartridgeGroupName' " - "'%s') " - "streq(CARTRIDGEGROUPAPPLICATION.'ApplicationName' " - "'%s'))];", - tid, mpool, val); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "modify cartridgegroup", - &response); - if (st != 0) { - break; - } - } - -done: - - if (new) { - nvlist_free(new); - } - - if (cgattrs) { - nvlist_free(cgattrs); - } - - mgmt_free_str_arr(varray, count); - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -/* - * verify no cartridges 'allocated' - * force? remove cart anyway - * remove all carts - * remove cartridgegroupapplications - * remove cartridgegroup - */ -int -mms_mgmt_remove_mpool(void *session, char *mpool, boolean_t force, - nvlist_t *errs) -{ - int st; - nvlist_t *nvl = NULL; - void *sess = NULL; - void *sessp = session; - void *response; - char tid[64]; - char cmd[8192]; - - if (!mpool) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.delete")) { - return (EACCES); - } - - st = nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0); - if (st != 0) { - return (st); - } - - (void) nvlist_add_string(nvl, O_NAME, mpool); - (void) nvlist_add_boolean_value(nvl, O_FORCE, force); - (void) nvlist_add_string(nvl, O_VOLUMES, "*"); - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - nvlist_free(nvl); - return (st); - } - sessp = sess; - } - - st = mms_mgmt_remove_cartridges(sessp, nvl, errs); - - if (st != 0) { - goto done; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[CARTRIDGEGROUPAPPLICATION] " - "match[streq" - "(CARTRIDGEGROUPAPPLICATION.'CartridgeGroupName' '%s')];", - tid, mpool); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "remove cartridgegroup", - &response); - if (st != 0) { - goto done; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[CARTRIDGEGROUP] " - "match[streq(CARTRIDGEGROUP.'CartridgeGroupName' '%s')];", - tid, mpool); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "remove cartridgegroup", - &response); - if (st != 0) { - goto done; - } - -done: - if (nvl) { - nvlist_free(nvl); - } - - return (st); -} - -/* ARGSUSED */ -int -mms_mgmt_remove_dpool(void *session, char *dpool, boolean_t force, - nvlist_t *errs) -{ - int st; - nvlist_t *nvl = NULL; - void *sess = NULL; - void *sessp = session; - void *response; - char tid[64]; - char cmd[8192]; - - if (!dpool) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.delete")) { - return (EACCES); - } - - st = nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0); - if (st != 0) { - return (st); - } - - (void) nvlist_add_string(nvl, O_NAME, dpool); - (void) nvlist_add_boolean_value(nvl, O_FORCE, force); - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - nvlist_free(nvl); - return (st); - } - sessp = sess; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[DRIVEGROUPAPPLICATION] " - "match[streq" - "(DRIVEGROUPAPPLICATION.'DriveGroupName' '%s')];", - tid, dpool); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "remove drivegroup", - &response); - if (st != 0) { - goto done; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[DRIVEGROUP] " - "match[streq(DRIVEGROUP.'DriveGroupName' '%s')];", - tid, dpool); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "remove drivegroup", - &response); - if (st != 0) { - goto done; - } - -done: - if (nvl) { - nvlist_free(nvl); - } - - return (st); -} - -int -mms_mgmt_add_cartridges(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char *mpool; - char **volarr = NULL; - char *libname; - char *mtype = NULL; - int count; - int i; - char tid[64]; - char cmd[8192]; - void *sess = NULL; - void *sessp = session; - mms_list_t lib_list; - mms_acslib_t *lsm; - char *volstr; - mms_list_t vol_list; - mms_acscart_t *vol; - size_t len = 0; - void *response; - nvlist_t *cart = NULL; - char *volxml = "</token><token>volume</token><token>"; - int st_save = 0; - char *rwmode = "readwrite"; - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.media")) { - return (EACCES); - } - - (void) memset(&vol_list, 0, sizeof (mms_list_t)); - - st = nvlist_lookup_string(nvl, O_NAME, &mpool); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - st = nvlist_lookup_string(nvl, O_MMSLIB, &libname); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_MMSLIB, st); - return (st); - } - - st = nvlist_lookup_string(nvl, O_VOLTYPE, &mtype); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_MTYPE, st); - return (st); - } - - st = nvlist_lookup_string(nvl, "readonly", &rwmode); - if (st == 0) { - if (strcmp(rwmode, "true") == 0) { - rwmode = "readonly"; - } else if (strcmp(rwmode, "false") == 0) { - rwmode = "readwrite"; - } else { - st = MMS_MGMT_INVALID_READONLY; - MGMT_ADD_OPTERR(errs, "readonly", st); - return (st); - } - } - - volarr = mgmt_var_to_array(nvl, O_VOLUMES, &count); - if (volarr == NULL) { - st = ENOENT; - MGMT_ADD_OPTERR(errs, O_VOLUMES, st); - return (st); - } - - if (session == NULL) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - mgmt_free_str_arr(volarr, count); - return (st); - } - sessp = sess; - } - - /* get the library information */ - st = mms_get_library(sessp, B_FALSE, &lib_list); - if (st != 0) { - goto done; - } - - mms_list_foreach(&lib_list, lsm) { - if (strcmp(lsm->name, libname) == 0) { - break; - } - } - if (lsm == NULL) { - st = EINVAL; - MGMT_ADD_ERR(errs, O_MMSLIB, st); - goto done; - } - - /* get the volume info from the ACSLS server */ - for (i = 0; i < count; i++) { - len += strlen(volarr[i]) + strlen(volxml); - - } - len++; /* include trailing nul */ - volstr = malloc(len); - if (volstr == NULL) { - st = ENOMEM; - goto done; - } - volstr[0] = '\0'; - for (i = 0; i < count; i++) { - if (i > 0) { - (void) strlcat(volstr, volxml, len); - } - (void) strlcat(volstr, volarr[i], len); - } - - st = get_acs_volumes(lsm->acshost, volstr, &vol_list); - free(volstr); - - if (st != 0) { - goto done; - } - - /* requested volumes don't appear in the returned list */ - if (vol_list.list_size == 0) { - st = ENOENT; - for (i = 0; i < count; i++) { - if (volarr[i]) { - MGMT_ADD_ERR(errs, volarr[i], st); - } - } - goto done; - } - - /* list to be used when creating PARTITIONs */ - st = nvlist_alloc(&cart, NV_UNIQUE_NAME, 0); - if (st != 0) { - goto done; - } - /* pre-populate with constant values */ - (void) nvlist_add_string(cart, O_MMSLIB, libname); - - for (i = 0; i < count; i++) { - mms_list_foreach(&vol_list, vol) { - if (strcmp(vol->label, volarr[i]) == 0) { - break; - } - } - if (vol == NULL) { - /* should never happen */ - continue; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "create task['%s'] type[CARTRIDGE] " - "set[CARTRIDGE.'CartridgePCL' '%s'] " - "set[CARTRIDGE.'CartridgeTypeName' '%s'] " - "set[CARTRIDGE.'CartridgeGroupName' '%s'] " - "set[CARTRIDGE.'LibraryName' '%s']; ", - tid, vol->label, mtype, mpool, libname); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "add volume", - &response); - if (st != 0) { - MGMT_ADD_ERR(errs, vol->label, st); - st_save = MMS_MGMT_CREATE_CART_ERR; - continue; - } - /* create the PARTITION */ - (void) nvlist_add_string(cart, O_NAME, vol->label); - st = mms_mgmt_create_partition(sessp, - vol->label, -1, libname, rwmode, errs); - if (st != 0) { - MGMT_ADD_ERR(errs, vol->label, st); - st_save = MMS_MGMT_CREATE_PART_ERR; - mms_mgmt_add_vol_cleanup(sessp, vol->label, libname); - break; - } - } - -done: - if (sess) { - (void) mms_goodbye(sess, 0); - } - - free_acslib_list(&lib_list); - mms_list_free_and_destroy(&vol_list, free); - mgmt_free_str_arr(volarr, count); - - if (cart) { - nvlist_free(cart); - } - - return (st_save == 0 ? st : st_save); -} - -int -mms_mgmt_add_voltype(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - void *sessp = session; - void *sess = NULL; - void *response = NULL; - char tid[64]; - char cmd[8192]; - nvlist_t *stypes = NULL; - nvlist_t *ctypes = NULL; - nvlist_t *mnvl = NULL; - char *in_ty = NULL; - char *in_sz = NULL; - char *in_media = NULL; - char *val; - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.media")) { - return (EACCES); - } - - st = nvlist_lookup_string(nvl, O_NAME, &in_ty); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - st = nvlist_lookup_string(nvl, O_SIZE, &in_sz); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_SIZE, st); - return (st); - } - - st = nvlist_lookup_string(nvl, O_MTYPE, &in_media); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_MTYPE, st); - return (st); - } - - if (!sessp) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - /* see if we've already got this type */ - st = mms_mgmt_show_cartridge_type(sessp, in_ty, &stypes); - if (st != 0) { - goto done; - } - - /* we'll get an empty list if it isn't already defined */ - st = nvlist_lookup_nvlist(stypes, in_ty, &mnvl); - if (st == 0) { - /* make sure all attributes match */ - val = NULL; - (void) nvlist_lookup_string(mnvl, "CartridgeTypeMediaLength", - &val); - if ((!val) || (strcmp(val, in_sz) != 0)) { - st = EINVAL; - MGMT_ADD_OPTERR(errs, O_SIZE, st); - goto done; - } - - val = NULL; - (void) nvlist_lookup_string(mnvl, "CartridgeShapeName", &val); - if ((!val) || (strcmp(val, in_media) != 0)) { - st = EINVAL; - MGMT_ADD_OPTERR(errs, O_MTYPE, st); - goto done; - } - - /* all matched, nothing to do */ - goto done; - } - - nvlist_free(stypes); - stypes = NULL; - - st = mms_mgmt_list_supported_types(sessp, &stypes); - if (st != 0) { - MGMT_ADD_ERR(errs, "internal error", st); - goto done; - } - - st = nvlist_lookup_nvlist(stypes, "CARTRIDGE", &ctypes); - if (st != 0) { - MGMT_ADD_ERR(errs, "internal error", st); - goto done; - } - - /* make sure requested media type is supported */ - st = nvlist_lookup_nvlist(ctypes, in_media, &mnvl); - if (st != 0) { - if (st == ENOENT) { - st = EOPNOTSUPP; - } - MGMT_ADD_ERR(errs, in_media, st); - goto done; - } - - /* DISK type may be any size, so set in_sz = 0 */ - if (strcmp(in_media, "DISK") == 0) { - in_sz = "0"; - } - - /* create the new type */ - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "create task['%s'] type[CARTRIDGETYPE] " - "set[CARTRIDGETYPE.'CartridgeTypeName' '%s'] " - "set[CARTRIDGETYPE.'CartridgeTypeNumberSides' '1'] " - "set[CARTRIDGETYPE.'CartridgeTypeMediaType' 'data'] " - "set[CARTRIDGETYPE.'CartridgeTypeMediaLength' '%s'] " - "set[CARTRIDGETYPE.'CartridgeShapeName' '%s'];", - tid, in_ty, in_sz, in_media); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "create cartridge type", - &response); - -done: - if (sess) { - (void) mms_goodbye(sess, 0); - } - - if (stypes) { - nvlist_free(stypes); - } - - return (st); -} - -static int -voltype_in_use(void *session, char *voltype) -{ - int st; - void *sessp = session; - void *sess = NULL; - void *response = NULL; - char tid[64]; - char cmd[8192]; - nvlist_t *clist = NULL; - - if (!voltype) { - return (MMS_MGMT_NOARG); - } - - /* first, check to see if any cartridges are using this type */ - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue unique] " - "report[CARTRIDGE.'CartridgeTypeName'] " - "match[streq(CARTRIDGETYPE.'CartridgeTypeName' '%s')];", - tid, voltype); - - if (!sessp) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "check voltype", &response); - if (st == 0) { - st = mmp_get_nvattrs("CartridgeTypeName", B_FALSE, - response, &clist); - mms_free_rsp(response); - } - - if (st == 0) { - if (nvlist_exists(clist, voltype)) { - st = EBUSY; - } - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - if (clist) { - nvlist_free(clist); - } - - return (st); -} - -int -mms_mgmt_remove_voltype(void *session, char *voltype) -{ - int st; - void *sessp = session; - void *sess = NULL; - void *response = NULL; - char tid[64]; - char cmd[8192]; - - if (!voltype) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.media")) { - return (EACCES); - } - - if (!sessp) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - /* first, check to see if any cartridges are using this type */ - st = voltype_in_use(sessp, voltype); - - if (st == 0) { - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[CARTRIDGETYPE] " - "match[streq(CARTRIDGETYPE.'CartridgeTypeName' '%s')];", - tid, voltype); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "delete voltype", - &response); - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -int -mms_mgmt_modify_voltype(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - void *sessp = session; - void *sess = NULL; - void *response = NULL; - char tid[64]; - char cmd[8192]; - char buf[1024]; - char *vtype = NULL; - char *sz = NULL; - char *mtype = NULL; - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.media")) { - return (EACCES); - } - - st = nvlist_lookup_string(nvl, O_NAME, &vtype); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - if (!sessp) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - /* first, check to see if any cartridges are using this type */ - st = voltype_in_use(sessp, vtype); - if (st != 0) { - goto done; - } - - (void) nvlist_lookup_string(nvl, O_MTYPE, &mtype); - (void) nvlist_lookup_string(nvl, O_SIZE, &sz); - - if (!sz && !mtype) { - goto done; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "attribute task['%s'] type[CARTRIDGETYPE] " - "match[streq(CARTRIDGETYPE.'CartridgeTypeName' '%s')]", - tid); - - if (sz) { - (void) snprintf(buf, sizeof (buf), - " set[CARTRIDGETYPE.'CartridgeTypeMediaLength' '%s']", - sz); - (void) strlcat(cmd, buf, sizeof (cmd)); - } - - if (mtype) { - (void) snprintf(buf, sizeof (buf), - "set[CARTRIDGETYPE.'CartridgeShapeName' '%s'];", - mtype); - (void) strlcat(cmd, buf, sizeof (cmd)); - } - - (void) strlcat(cmd, ";", sizeof (cmd)); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "delete voltype", &response); - -done: - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -int -mms_mgmt_show_cartridge_type(void *session, char *voltype, nvlist_t **nvl) -{ - int st; - void *sessp = session; - void *sess = NULL; - void *response = NULL; - char tid[64]; - char cmd[8192]; - char buf[1024]; - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - /* if voltype is NULL, return a list of all found */ - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] " - "report[CARTRIDGETYPE]", tid); - - if (voltype != NULL) { - (void) snprintf(buf, sizeof (buf), - " match[streq (CARTRIDGETYPE.'CartridgeTypeName' '%s')]", - voltype); - (void) strlcat(cmd, buf, sizeof (cmd)); - } - - (void) strlcat(cmd, ";", sizeof (cmd)); - - if (!sessp) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "list cartridgetype", - &response); - if (st == 0) { - st = mmp_get_nvattrs("voltype", B_TRUE, response, nvl); - mms_free_rsp(response); - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - - -int -mms_mgmt_remove_cartridges(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char *mpool; - boolean_t force = B_FALSE; - nvlist_t *vols = NULL; - void *sess = NULL; - void *sessp = session; - void *response; - nvpair_t *nvp; - nvlist_t *vlist; - char *val; - char *vname; - boolean_t skip = B_FALSE; - char tid[64]; - char cmd[8192]; - int skipped = 0; - nvlist_t *pclnv = NULL; - char *lib = NULL; - - if (!mgmt_chk_auth("solaris.mms.media")) { - return (EACCES); - } - - st = nvlist_lookup_string(nvl, O_NAME, &mpool); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - if (!nvlist_exists(nvl, O_VOLUMES)) { - /* nothing to remove */ - return (0); - } - - (void) nvlist_lookup_string(nvl, O_MMSLIB, &lib); - - (void) nvlist_lookup_boolean_value(nvl, O_FORCE, &force); - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - /* tell the list function not to translate the var names */ - (void) nvlist_add_boolean_value(nvl, "cvt_mmp", B_FALSE); - - st = mms_mgmt_list_vols(sessp, nvl, &vols); - if (st != 0) { - goto done; - } - - /* Create a temporary nvlist to store PCL & Library */ - st = nvlist_alloc(&pclnv, NV_UNIQUE_NAME, 0); - if (st != 0) { - goto done; - } - (void) nvlist_add_string(pclnv, O_MMSLIB, lib); - - /* vols is now a list of the volumes we're supposed to remove */ - nvp = NULL; - - while ((nvp = nvlist_next_nvpair(vols, nvp)) != NULL) { - st = nvpair_value_nvlist(nvp, &vlist); - if (st != 0) { - continue; - } - st = nvlist_lookup_string(vlist, "CartridgePCL", &vname); - if (st != 0) { - continue; - } - - skip = B_FALSE; - - if (!force) { - st = nvlist_lookup_string(vlist, "CartridgeState", - &val); - if (st != 0) { - /* don't remove it if we can't tell state */ - continue; - } - if (strcmp(val, "allocated") == 0) { - /* fail */ - MGMT_ADD_ERR(errs, vname, EBUSY); - skipped++; - skip = B_TRUE; - } - } - - if (skip) { - continue; - } - - (void) nvlist_add_string(pclnv, O_NAME, vname); - - /* remove partitions and vols if necessary */ - st = mms_mgmt_remove_partition(sessp, pclnv, errs); - if (st != 0) { - MGMT_ADD_ERR(errs, vname, st); - continue; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[CARTRIDGE] " - "match[and (streq(CARTRIDGE.'CartridgeGroupName' '%s') " - "streq(CARTRIDGE.'CartridgePCL' '%s'))];", - tid, mpool, vname); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "delete cartridge", - &response); - if (st != 0) { - MGMT_ADD_ERR(errs, vname, st); - continue; - } - - /* check for disk cartridges, remove the on-disk files if yes */ - st = nvlist_lookup_string(vlist, "CartridgeTypeName", &val); - if (st == 0) { - if (strcmp(val, "DISK") == 0) { - char *mntp = NULL; - char *rpath = NULL; - - (void) nvlist_lookup_string(vlist, - "CartridgeMountPoint", &mntp); - (void) nvlist_lookup_string(vlist, - "CartridgePath", &rpath); - if (!mntp || !rpath) { - MGMT_ADD_ERR(errs, "bad cartridge path", - ENOENT); - continue; - } - (void) snprintf(cmd, sizeof (cmd), "%s/%s", - mntp, rpath); - st = mgmt_delete_dkvol(cmd, errs); - if (st != 0) { - MGMT_ADD_ERR(errs, cmd, st); - } - } - } - } - - if (pclnv) { - nvlist_free(pclnv); - } - - -done: - if (sess) { - (void) mms_goodbye(sess, 0); - } - - if (vols) { - nvlist_free(vols); - } - - if ((st == 0) && skipped) { - st = MMS_MGMT_CARTRIDGE_INUSE; - } - - return (st); -} - -/* - * list by mpool, by mpool&cartridge id or all - */ -int -mms_mgmt_list_vols(void *session, nvlist_t *nvl, nvlist_t **vol_list) -{ - int st; - char *mpool = NULL; - char **volarr = NULL; - int count; - char tid[64]; - char cmd[8192]; - void *sess = NULL; - void *sessp = session; - void *response; - boolean_t all = B_TRUE; - int i; - boolean_t cvt_mmp = B_TRUE; - char *key = "volid"; - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - (void) nvlist_lookup_string(nvl, O_NAME, &mpool); - - st = nvlist_lookup_boolean_value(nvl, "cvt_mmp", &cvt_mmp); - if (st == ENOENT) { - cvt_mmp = B_TRUE; - } else if (cvt_mmp == B_FALSE) { - key = "CartridgePCL"; - } - st = 0; - - volarr = mgmt_var_to_array(nvl, O_VOLUMES, &count); - if (volarr != NULL) { - /* special case for all volumes */ - if (strcmp(volarr[0], "*") != 0) { - all = B_FALSE; - } - } - - if (*vol_list == NULL) { - st = nvlist_alloc(vol_list, NV_UNIQUE_NAME, 0); - if (st != 0) { - goto done; - } - - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - /* - * get the cartridges from MMS. - */ - if (all) { - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] " - "report[CARTRIDGE] ", tid); - - if (!mpool) { - (void) strlcat(cmd, ";", sizeof (cmd)); - } else { - (void) strlcat(cmd, - "match[streq(CARTRIDGE.'CartridgeGroupName' '", - sizeof (cmd)); - (void) strlcat(cmd, mpool, sizeof (cmd)); - (void) strlcat(cmd, "')];", sizeof (cmd)); - } - st = mms_mgmt_send_cmd(sessp, tid, cmd, "show cartridges", - &response); - if (st == 0) { - st = mmp_get_nvattrs(key, cvt_mmp, response, - vol_list); - mms_free_rsp(response); - } - } else { - for (i = 0; i < count; i++) { - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] " - "report[CARTRIDGE] ", tid); - - if (mpool) { - (void) strlcat(cmd, "match[and (streq(", - sizeof (cmd)); - (void) strlcat(cmd, - "CARTRIDGE.'CartridgeGroupName' '", - sizeof (cmd)); - (void) strlcat(cmd, mpool, sizeof (cmd)); - (void) strlcat(cmd, "') ", sizeof (cmd)); - } - (void) strlcat(cmd, "streq(CARTRIDGE.'CartridgePCL' '", - sizeof (cmd)); - (void) strlcat(cmd, volarr[i], sizeof (cmd)); - (void) strlcat(cmd, "')", sizeof (cmd)); - if (mpool) { - (void) strlcat(cmd, ")", sizeof (cmd)); - } - (void) strlcat(cmd, "];", sizeof (cmd)); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, - "show cartridges", &response); - if (st == 0) { - st = mmp_get_nvattrs(key, cvt_mmp, - response, vol_list); - mms_free_rsp(response); - } else { - break; - } - } - } - - if (st == 0) { - mgmt_filter_results(nvl, *vol_list); - } - -done: - if (sess) { - (void) mms_goodbye(sess, 0); - } - - mgmt_free_str_arr(volarr, count); - - return (st); -} - -int -mms_mgmt_show_dpool(void *session, nvlist_t *nvl, nvlist_t **pools) -{ - int st; - char **names = NULL; - int count; - char tid[64]; - char cmd[8192]; - char buf[1024]; - void *sess = NULL; - void *sessp = session; - void *response; - int i; - char *key = O_DPOOL; - nvlist_t *nva = NULL; - nvpair_t *nvp = NULL; - char *dpname = NULL; - - if (!nvl || !pools) { - return (MMS_MGMT_NOARG); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - names = mgmt_var_to_array(nvl, O_NAME, &count); - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] " - "report[DRIVEGROUP]", - tid); - - if (count > 1) { - (void) strlcat(cmd, "match[or(", sizeof (cmd)); - } else if (count == 1) { - (void) strlcat(cmd, "match[", sizeof (cmd)); - } - for (i = 0; i < count; i++) { - (void) snprintf(buf, sizeof (buf), - " streq (DRIVEGROUP.'DriveGroupName' '%s')", - names[i]); - (void) strlcat(cmd, buf, sizeof (cmd)); - } - if (count > 1) { - (void) strlcat(cmd, ")];", sizeof (cmd)); - } else if (count == 1) { - (void) strlcat(cmd, "];", sizeof (cmd)); - } else { - (void) strlcat(cmd, ";", sizeof (cmd)); - } - - *pools = NULL; - st = mms_mgmt_send_cmd(sessp, tid, cmd, "show dpool", &response); - if (st == 0) { - st = mmp_get_nvattrs(key, B_TRUE, response, pools); - mms_free_rsp(response); - } - - if (st != 0) { - goto done; - } - - while ((nvp = nvlist_next_nvpair(*pools, nvp)) != NULL) { - st = nvpair_value_nvlist(nvp, &nva); - if (st != 0) { - continue; - } - dpname = nvpair_name(nvp); - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] " - "report[DRIVEGROUPAPPLICATION.'ApplicationName' ] " - "match[streq(DRIVEGROUP.'DriveGroupName' '%s')];", - tid, dpname); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "dpool apps", - &response); - if (st == 0) { - st = mmp_get_nvattrs_array("application", B_TRUE, - response, nva); - mms_free_rsp(response); - } - if (st != 0) { - continue; - } - - /* - * Get drives in this dpool - */ - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] " - "report[DRIVE.'DriveName' ] " - "match[streq(DRIVEGROUP.'DriveGroupName' '%s')];", - tid, dpname); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "dpool apps", - &response); - if (st == 0) { - st = mmp_get_nvattrs_array("drive", B_TRUE, - response, nva); - mms_free_rsp(response); - } - if (st != 0) { - continue; - } - } - - mgmt_filter_results(nvl, *pools); - -done: - if (sess) { - (void) mms_goodbye(sess, 0); - } - - if (names) { - mgmt_free_str_arr(names, count); - } - - return (st); -} - -int -mms_mgmt_show_mpool(void *session, nvlist_t *nvl, nvlist_t **pools) -{ - int st; - char **names = NULL; - int count; - char tid[64]; - char cmd[8192]; - char buf[1024]; - void *sess = NULL; - void *sessp = session; - void *response; - int i; - char *key = O_MPOOL; - int vcount = 0; - uint64_t poolsz = 0; - uint64_t vsz = 0; - nvlist_t *vols = NULL; - nvlist_t *nva = NULL; - nvpair_t *nvp = NULL; - nvlist_t *nvav = NULL; - nvpair_t *nvpv = NULL; - char *val; - - if (!nvl || !pools) { - return (MMS_MGMT_NOARG); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - names = mgmt_var_to_array(nvl, O_NAME, &count); - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] " - "report[CARTRIDGEGROUP]", - tid); - - if (count > 1) { - (void) strlcat(cmd, "match[or(", sizeof (cmd)); - } else if (count == 1) { - (void) strlcat(cmd, "match[", sizeof (cmd)); - } - for (i = 0; i < count; i++) { - (void) snprintf(buf, sizeof (buf), - " streq (CARTRIDGEGROUP.'CartridgeGroupName' '%s')", - names[i]); - (void) strlcat(cmd, buf, sizeof (cmd)); - } - if (count > 1) { - (void) strlcat(cmd, ")];", sizeof (cmd)); - } else if (count == 1) { - (void) strlcat(cmd, "];", sizeof (cmd)); - } else { - (void) strlcat(cmd, ";", sizeof (cmd)); - } - - *pools = NULL; - st = mms_mgmt_send_cmd(sessp, tid, cmd, "show mpool", &response); - if (st == 0) { - st = mmp_get_nvattrs(key, B_TRUE, response, pools); - mms_free_rsp(response); - } - - if (st != 0) { - goto done; - } - - while ((nvp = nvlist_next_nvpair(*pools, nvp)) != NULL) { - st = nvpair_value_nvlist(nvp, &nva); - if (st != 0) { - continue; - } - val = nvpair_name(nvp); - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] " - "report[CARTRIDGE.'CartridgePCL' " - "CARTRIDGETYPE.'CartridgeShapeName' " - "CARTRIDGETYPE.'CartridgeTypeMediaLength' " - "PARTITION.'PartitionSize'] " - "match[streq(CARTRIDGEGROUP.'CartridgeGroupName' '%s')];", - tid, val); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "mpool vols", - &response); - if (st == 0) { - st = mmp_get_nvattrs("CartridgePCL", B_FALSE, - response, &vols); - mms_free_rsp(response); - } - if (st != 0) { - continue; - } - - nvpv = NULL; - cmd[0] = '\0'; - poolsz = 0; - vcount = 0; - - while ((nvpv = nvlist_next_nvpair(vols, nvpv)) != NULL) { - st = nvpair_value_nvlist(nvpv, &nvav); - if (st != 0) { - continue; - } - vcount++; - - st = nvlist_lookup_string(nvav, "CartridgeShapeName", - &val); - if (st == 0) { - (void) snprintf(buf, sizeof (buf), "%s,", val); - if (strstr(cmd, buf) == NULL) { - (void) strlcat(cmd, buf, sizeof (cmd)); - } - } - st = nvlist_lookup_string(nvav, "PartitionSize", - &val); - if (st == 0) { - (void) do_val_mms_size(val, &vsz); - poolsz += vsz; - } else { - st = nvlist_lookup_string(nvav, - "CartridgeTypeMediaLength", &val); - if (st == 0) { - (void) do_val_mms_size(val, &vsz); - poolsz += vsz; - } - } - - } - nvlist_free(vols); - vols = NULL; - (void) snprintf(buf, sizeof (buf), "%lu", poolsz); - (void) nvlist_add_string(nva, "total size", buf); - (void) snprintf(buf, sizeof (buf), "%d", vcount); - (void) nvlist_add_string(nva, "total volumes", buf); - val = strrchr(cmd, ','); - if (val != NULL) { - *val = NULL; - } - (void) nvlist_add_string(nva, "voltype", cmd); - } - - mgmt_filter_results(nvl, *pools); - - /* TODO: list of cartridges + sum space used/free/avail */ - -done: - if (sess) { - (void) mms_goodbye(sess, 0); - } - - if (names) { - mgmt_free_str_arr(names, count); - } - - return (st); -} - -/* ARGSUSED */ -int -mms_mgmt_create_partition(void *session, char *pcl, int64_t size, char *lib, - char *rwmode, nvlist_t *errs) -{ - int st; - void *sess = NULL; - void *sessp = session; - void *response; - char tid[64]; - char cmd[8192]; - nvlist_t *carts = NULL; - - if (!mgmt_chk_auth("solaris.mms.media")) { - return (EACCES); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - if (size > 0) { - size /= (1024 * 1024); /* convert to mega bytes */ - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "create task['%s'] type[PARTITION] " - "set[PARTITION.'PartitionName' 'part1'] " - "set[PARTITION.'SideName' 'side 1'] " - "set[PARTITION.'CartridgePCL' '%s'] " - "set[PARTITION.'PartitionAvailable' '%lld'] " - "set[PARTITION.'PartitionSize' '%lld'] " - "set[PARTITION.'PartitionPercentAvailable' '%d'] " - "set[PARTITION.'PartitionRWMode' '%s'] " - "set[PARTITION.'LibraryName' '%s'];", - tid, pcl, size, size, size == -1 ? -1 : 100, rwmode, lib); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "create partition", &response); - -done: - if (sess) { - (void) mms_goodbye(sess, 0); - } - - if (carts) { - nvlist_free(carts); - } - - return (st); -} - -int -mms_mgmt_remove_partition(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - void *sess = NULL; - void *sessp = session; - void *response; - char tid[64]; - char cmd[8192]; - char *pcl = NULL; - char *lib = NULL; - nvlist_t *carts = NULL; - nvlist_t *vols = NULL; - - if (!mgmt_chk_auth("solaris.mms.media")) { - return (EACCES); - } - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - st = nvlist_lookup_string(nvl, O_NAME, &pcl); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - st = nvlist_lookup_string(nvl, O_MMSLIB, &lib); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_MMSLIB, st); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - /* check for existing volumes */ - st = mgmt_show_mmvols(sessp, pcl, lib, &vols); - if (st != 0) { - goto done; - } - - if (vols) { - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[VOLUME] " - "match[and (streq(PARTITION.'CartridgePCL' '%s') " - "streq(PARTITION.'LibraryName' '%s'))];", - tid, pcl, lib); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "delete volume", - &response); - if (st != 0) { - goto done; - } - } - - /* now the partitions */ - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[PARTITION] " - "match[and (streq (PARTITION.'LibraryName' '%s') " - "streq(PARTITION.'CartridgePCL' '%s'))];", - tid, lib, pcl); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "delete partition", - &response); - -done: - if (sess) { - (void) mms_goodbye(sess, 0); - } - - if (carts) { - nvlist_free(carts); - } - - if (vols) { - nvlist_free(vols); - } - - return (st); -} - -int -mms_mgmt_label_multi(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - int rst = 0; - void *sess = NULL; - void *sessp = session; - char *pass = NULL; - char *app = NULL; - char *inst = NULL; - char **varr = NULL; - int count = 0; - int i; - - if (!mgmt_chk_auth("solaris.mms.media")) { - return (EACCES); - } - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - varr = mgmt_var_to_array(nvl, O_NAME, &count); - if (!varr) { - st = ENOENT; - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - if (!session) { - (void) nvlist_lookup_string(nvl, O_APPS, &app); - (void) nvlist_lookup_string(nvl, "instance", &inst); - (void) nvlist_lookup_string(nvl, O_MMPASS, &pass); - - st = create_mm_clnt(app, inst, pass, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - for (i = 0; i < count; i++) { - (void) nvlist_add_string(nvl, O_NAME, varr[i]); - - st = mms_mgmt_label_vol(sessp, nvl, errs); - if (st != 0) { - /* save return status */ - if (rst == 0) { - rst = st; - } - } - } - - /* set 'name' back to the way it started */ - (void) nvlist_add_string_array(nvl, O_NAME, varr, count); - - mgmt_free_str_arr(varr, count); - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (rst); -} - -int -mms_mgmt_label_vol(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - void *sess = NULL; - void *sessp = session; - void *response; - char tid[64]; - char cmd[8192]; - char buf[1024]; - char *pcl; - char *lib; - char *app; - char *inst = NULL; - char *pass = NULL; - nvlist_t *attrs = NULL; - nvlist_t *carts = NULL; - nvpair_t *nva; - boolean_t force = B_FALSE; - boolean_t nomount = B_FALSE; - - if (!mgmt_chk_auth("solaris.mms.media")) { - return (EACCES); - } - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - st = nvlist_lookup_string(nvl, O_NAME, &pcl); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - st = nvlist_lookup_string(nvl, O_MMSLIB, &lib); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_MMSLIB, st); - return (st); - } - - st = nvlist_lookup_string(nvl, O_APPS, &app); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_APPS, st); - return (st); - } - - (void) nvlist_lookup_boolean_value(nvl, O_FORCE, &force); - - if (!session) { - (void) nvlist_lookup_string(nvl, "instance", &inst); - (void) nvlist_lookup_string(nvl, O_MMPASS, &pass); - - st = create_mm_clnt(app, inst, pass, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - /* - * Check if cartridge exists. - */ - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] report[CARTRIDGE] " - "match[and (streq(CARTRIDGE.'LibraryName' '%s') " - "streq(CARTRIDGE.'CartridgePCL' '%s'))];", - tid, lib, pcl); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "show cartridge", &response); - if (st == 0) { - st = mmp_get_nvattrs("CartridgePCL", B_FALSE, response, &carts); - mms_free_rsp(response); - } - - if (!nvlist_exists(carts, pcl)) { - MGMT_ADD_OPTERR(errs, pcl, st); - goto done; - } - - /* check if partition for cartridge exists. if no, create */ - st = mgmt_show_partition(sessp, pcl, lib, &attrs); - - if (st != 0) { - goto done; - } - - if (attrs == NULL) { - st = mms_mgmt_create_partition(sessp, pcl, -1, lib, - "readwrite", errs); - } else { - nva = nvlist_next_nvpair(attrs, NULL); - if (nva) { - if (nvlist_next_nvpair(attrs, nva)) { - /* got more than 1, not supported */ - st = MMS_MGMT_ERR_PARTITION_NOT_UNIQUE; - MGMT_ADD_ERR(errs, pcl, st); - goto done; - } - } - } - - nvlist_free(attrs); - attrs = NULL; - - /* check for existing volumes */ - st = mgmt_show_mmvols(sessp, pcl, lib, &attrs); - if (st != 0) { - goto done; - } - - if (!attrs) { - /* create a volume */ - (void) snprintf(buf, sizeof (buf), "%s_%s", lib, pcl); - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "allocate task['%s'] newvolname['%s'] " - "who['%s'] " - "match[and (streq(CARTRIDGE.'CartridgePCL' '%s') " - "streq(CARTRIDGE.'LibraryName' '%s'))];", - tid, buf, app, pcl, lib); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "create volume", - &response); - if (st != 0) { - MGMT_ADD_ERR(errs, pcl, st); - goto done; - } - } else if (!force) { - st = MMS_MGMT_CARTRIDGE_INUSE; - MGMT_ADD_ERR(errs, pcl, st); - goto done; - } - - /* filename is 17 spaces - tells MM to re-init volume */ - (void) nvlist_add_string(nvl, "filename", label_fname); - - /* - * If '-n' is not specified, them mount and label the cartridge - */ - st = nvlist_lookup_boolean_value(nvl, O_NOMOUNT, &nomount); - if (st != 0 || nomount != B_TRUE) { - /* ok, mount with appropriate options */ - st = mms_mgmt_mount_vol(sessp, nvl, errs); - - if (st == 0) { - /* label is a quick mount/unmount */ - st = mms_mgmt_unmount_vol(nvl, errs); - } - } - -done: - if (sess) { - (void) mms_goodbye(sess, 0); - } - - if (attrs) { - nvlist_free(attrs); - } - if (carts) { - nvlist_free(carts); - } - - return (st); -} - -static int -mgmt_show_partition(void *session, char *pcl, char *library, nvlist_t **parts) -{ - int st; - void *sess = NULL; - void *sessp = session; - void *response; - char tid[64]; - char cmd[8192]; - nvlist_t *plist = NULL; - nvpair_t *nvp = NULL; - - if (!pcl || !library || !parts) { - return (MMS_MGMT_NOARG); - } - - st = nvlist_alloc(&plist, NV_UNIQUE_NAME, 0); - if (st != 0) { - return (st); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - *parts = NULL; - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] report[PARTITION] reportmode[namevalue] " - "match[and (streq(PARTITION.'CartridgePCL' '%s') " - "streq(PARTITION.'LibraryName' '%s'))];", - tid, pcl, library); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "show partition", &response); - if (st == 0) { - st = mmp_get_nvattrs("PartitionName", B_FALSE, response, - &plist); - mms_free_rsp(response); - } - - if (st == 0) { - nvp = nvlist_next_nvpair(plist, NULL); - if (nvp) { - *parts = plist; - } else { - nvlist_free(plist); - } - } - - return (st); -} - -static int -mgmt_show_mmvols(void *session, char *pcl, char *library, nvlist_t **vols) -{ - int st; - void *sess = NULL; - void *sessp = session; - void *response; - char tid[64]; - char cmd[8192]; - nvlist_t *vlist = NULL; - nvpair_t *nvp = NULL; - - if (!pcl || !library || !vols) { - return (MMS_MGMT_NOARG); - } - - st = nvlist_alloc(&vlist, NV_UNIQUE_NAME, 0); - if (st != 0) { - return (st); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] report[VOLUME] reportmode[namevalue] " - "match[and (streq(PARTITION.'CartridgePCL' '%s') " - "streq(PARTITION.'LibraryName' '%s'))];", - tid, pcl, library); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "show volume", &response); - if (st == 0) { - st = mmp_get_nvattrs("VolumeName", B_FALSE, response, &vlist); - mms_free_rsp(response); - } - - if (st == 0) { - nvp = nvlist_next_nvpair(vlist, NULL); - if (!nvp) { - /* nothing there */ - nvlist_free(vlist); - *vols = NULL; - } else { - *vols = vlist; - } - } - - return (st); -} - -static int -call_mmsmnt(door_arg_t *arg) -{ - int st; - int doorfd = -1; - int count; - /* LINTED [warning: pointer cast may result in improper alignment] */ - mmsmnt_arg_t *mntarg = (mmsmnt_arg_t *)arg->rbuf; - int saverr; - timespec_t sleepfor = {5, 0}; /* 5 seconds */ - char *cmd[2]; - - if (arg == NULL) { - return (MMS_MGMT_NOARG); - } - - cmd[0] = MMSSBINDIR"/mmsmnt"; - cmd[1] = NULL; - - /* will get overwritten with correct status as appropriate */ - st = ENOTCONN; - - /* try 5 times to get connected, then give up */ - for (count = 0; count < 5; count++) { - doorfd = open(mmsmntdoor, O_RDWR); - if (doorfd == -1) { - if (errno == ENOENT) { - /* server is not running. Try to start it */ - (void) exec_mgmt_cmd(NULL, NULL, 0, 0, B_TRUE, - cmd); - mms_trace(MMS_DEBUG, - "exec_mgmt_cmd: %s", cmd[0]); - } else { - st = errno; - return (st); - } - } - - /* - * try to contact the server - if door_call successful, - * status will be set by the server - */ - st = door_call(doorfd, arg); - saverr = errno; - - if (st == 0) { - /* connected ok, return error from daemon */ - st = mntarg->st; - break; - } - - (void) close(doorfd); - doorfd = -1; - - if (saverr == EBADF) { - /* - * server was not running when we opened - * the door file - */ - (void) exec_mgmt_cmd(NULL, NULL, 0, 0, B_TRUE, cmd); - mms_trace(MMS_DEBUG, "exec_mgmt_cmd: %s", cmd[0]); - /* give the server a chance to start */ - (void) nanosleep(&sleepfor, NULL); - } else if ((saverr != EAGAIN) && (saverr != EINTR)) { - /* A non-recoverable error occurred */ - st = saverr; - mms_trace(MMS_ERR, - "Could not contact the mmsmnt process, %d", st); - return (st); - } - } - - if (doorfd != -1) { - (void) close(doorfd); - } - - return (st); -} - -int -mms_mgmt_mount_vol(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - void *sess = NULL; - void *sessp = session; - void *response = NULL; - char tid[64]; - char cmd[8192]; - char mbuf[7168]; - char buf[1024]; - char *pcl; - char *lib; - char *mfile = NULL; - char *val; - char *app = NULL; - char *vname; - nvlist_t *attrs = NULL; - nvpair_t *nvp; - nvlist_t *nva; - nvlist_t *mntattrs = NULL; - mmsmnt_arg_t arg; - door_arg_t d_arg; - int others = 0; - struct passwd *pwd = NULL; - char *usernm = NULL; - nvlist_t *cattrs = NULL; - boolean_t isdsk = B_FALSE; - char **varray = NULL; - int count = 0; - boolean_t vbool = B_FALSE; - int i; - char *inst = NULL; - char *pass = NULL; - - if (!mgmt_chk_auth("solaris.mms.io.read")) { - return (EACCES); - } - - /* this function is unique, in that it returns the session */ - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - st = nvlist_lookup_string(nvl, O_NAME, &pcl); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - st = nvlist_lookup_string(nvl, O_MMSLIB, &lib); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_MMSLIB, st); - return (st); - } - - st = nvlist_lookup_string(nvl, O_APPS, &app); - if (st != 0) { - /* if not specified, see if we can mount as admin */ - if (st == ENOENT) { - st = 0; - app = "MMS"; - (void) nvlist_add_string(nvl, O_APPS, app); - } else { - MGMT_ADD_OPTERR(errs, O_APPS, st); - return (st); - } - } - - (void) nvlist_lookup_string(nvl, "filename", &mfile); - (void) nvlist_lookup_string(nvl, "instance", &inst); - (void) nvlist_lookup_string(nvl, O_MMPASS, &pass); - - if (!sessp) { - st = create_mm_clnt(app, inst, pass, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - /* check for volumes. If one doesn't exist, fail */ - st = mgmt_show_mmvols(sessp, pcl, lib, &attrs); - if (st == 0) { - if (!attrs) { - st = MMS_MGMT_VOL_NOT_INIT; - } - } - if (st != 0) { - MGMT_ADD_ERR(errs, pcl, st); - goto done; - } - - nvp = NULL; - while ((nvp = nvlist_next_nvpair(attrs, nvp)) != NULL) { - st = nvpair_value_nvlist(nvp, &nva); - if (st != 0) { - goto done; - } - st = nvlist_lookup_string(nva, "ApplicationName", &val); - if (st != 0) { - continue; - } - - if (strcasecmp(val, app) != 0) { - continue; - } - - /* found a valid volume */ - break; - } - - if ((st != 0) || (nvp == NULL)) { - st = MMS_MGMT_NO_USABLE_VOL; - MGMT_ADD_ERR(errs, pcl, st); - goto done; - } - - st = nvlist_lookup_string(nva, "VolumeName", &vname); - if (st != 0) { - goto done; - } - - /* see what type of cartridge this is */ - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] report[CARTRIDGETYPE.'CartridgeShapeName'] " - "reportmode[namevalue] " - "match[and (streq(CARTRIDGE.'CartridgePCL' '%s') " - "streq(LIBRARY.'LibraryName' '%s'))];", - tid, pcl, lib); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "get cartridge type", - &response); - if (st == 0) { - st = mmp_get_nvattrs("CartridgeShapeName", B_FALSE, response, - &cattrs); - mms_free_rsp(response); - } - if (st == 0) { - if (nvlist_exists(cattrs, "DISK")) { - isdsk = B_TRUE; - } - } - /* reset */ - if (cattrs) { - nvlist_free(cattrs); - } - st = 0; - - st = nvlist_lookup_string(nvl, "user", &usernm); - if ((st != 0) || (usernm == NULL)) { - pwd = getpwuid(getuid()); - if (pwd != NULL) { - usernm = pwd->pw_name; - } - if (usernm == NULL) { - usernm = "root"; - } - } - - /* at last, create the mount command */ - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "mount task['%s'] user['%s'] type[VOLUME] " - "match[and (streq(LIBRARY.'LibraryName' '%s') " - "streq(CARTRIDGE.'CartridgePCL' '%s'))] " - "report[MOUNTLOGICAL] reportmode[namevalue] ", - tid, usernm, lib, pcl); - - if (mfile) { - (void) snprintf(buf, sizeof (buf), "filename['%s'] ", - mfile); - (void) strlcat(cmd, buf, sizeof (cmd)); - } - - st = nvlist_lookup_string(nvl, "blocksize", &val); - if (st == 0) { - (void) snprintf(buf, sizeof (buf), "blocksize['%s'] ", val); - (void) strlcat(cmd, buf, sizeof (cmd)); - } - - st = nvlist_lookup_boolean_value(nvl, O_NOWAIT, &vbool); - if ((st == 0) && (vbool)) { - (void) strlcat(cmd, "when[immediate] ", sizeof (cmd)); - } else { - (void) strlcat(cmd, "when[blocking] ", sizeof (cmd)); - } - st = 0; - - /* get the firstmount and accessmodes */ - mbuf[0] = '\0'; - - if (mfile && (strcmp(mfile, label_fname) == 0)) { - /* The 17-space filename indicates we're labeling */ - (void) strlcat(cmd, "accessmode['creat'] ", sizeof (cmd)); - (void) strlcat(mbuf, "firstmount[", sizeof (mbuf)); - } else { - /* all options go into accessmode otherwise */ - (void) strlcat(mbuf, "accessmode[", sizeof (mbuf)); - } - - /* get the rest of the options */ - if (isdsk) { - others++; - (void) strlcat(mbuf, "'st_bsd' ", sizeof (mbuf)); - } - - st = nvlist_lookup_string(nvl, O_MMSDRV, &val); - if (st == 0) { - others++; - (void) snprintf(buf, sizeof (buf), "'%s' ", val); - (void) strlcat(mbuf, buf, sizeof (mbuf)); - } - - st = nvlist_lookup_boolean_value(nvl, O_NOREWIND, &vbool); - if ((st == 0) && (vbool)) { - others++; - (void) strlcat(mbuf, "'norewind' ", sizeof (mbuf)); - } - - st = nvlist_lookup_string(nvl, O_DENSITY, &val); - if (st == 0) { - others++; - (void) snprintf(buf, sizeof (buf), "'%s' ", val); - (void) strlcat(mbuf, buf, sizeof (mbuf)); - } - - varray = mgmt_var_to_array(nvl, "mode", &count); - for (i = 0; i < count; i++) { - if (!varray[i]) { - continue; - } - others++; - (void) snprintf(buf, sizeof (buf), "'%s' ", varray[i]); - (void) strlcat(mbuf, buf, sizeof (mbuf)); - } - mgmt_free_str_arr(varray, count); - varray = NULL; - count = 0; - - st = nvlist_lookup_string(nvl, "readonly", &val); - if (st == 0) { - if (strcasecmp(val, "true") == 0) { - (void) snprintf(buf, sizeof (buf), "'readonly' "); - } else { - (void) snprintf(buf, sizeof (buf), "'readwrite' "); - } - others++; - (void) strlcat(mbuf, buf, sizeof (mbuf)); - } - - if (others > 0) { - (void) strlcat(mbuf, "]", sizeof (mbuf)); - (void) strlcat(cmd, mbuf, sizeof (cmd)); - } - - (void) strlcat(cmd, ";", sizeof (cmd)); - - /* - * Call the mount daemon. If successful, the handle will be - * returned. - */ - - (void) memset(&arg, 0, sizeof (mmsmnt_arg_t)); - (void) memset(&d_arg, 0, sizeof (door_arg_t)); - - arg.op = 1; - (void) strlcpy(arg.cartridge, pcl, sizeof (arg.cartridge)); - (void) strlcpy(arg.library, lib, sizeof (arg.library)); - (void) strlcpy(arg.volname, vname, sizeof (arg.volname)); - (void) strlcpy(arg.cmd, cmd, sizeof (arg.cmd)); - if (pass) { - (void) strlcpy(arg.pass, pass, sizeof (arg.pass)); - } - if (inst) { - (void) strlcpy(arg.inst, inst, sizeof (arg.inst)); - } - if (app) { - (void) strlcpy(arg.app, app, sizeof (arg.app)); - } - d_arg.data_ptr = (char *)&arg; - d_arg.data_size = sizeof (mmsmnt_arg_t); - d_arg.desc_ptr = NULL; - d_arg.desc_num = 0; - d_arg.rbuf = (char *)&arg; - d_arg.rsize = d_arg.data_size; - - st = call_mmsmnt(&d_arg); - - if (st == 0) { - (void) nvlist_add_string(nvl, "mountdev", arg.devname); - } - -done: - if (sess) { - (void) mms_goodbye(sess, 0); - } - - if (attrs) { - nvlist_free(attrs); - } - - if (mntattrs) { - nvlist_free(mntattrs); - } - - return (st); -} - -int -mms_mgmt_unmount_vol(nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char *lib = NULL; - char *pcl = NULL; - char *dev = NULL; - char *app = NULL; - char *inst = NULL; - char *pass = NULL; - void *sess = NULL; - void *resp = NULL; - char tid[64]; - char cmd[8192]; - nvlist_t *attrs = NULL; - boolean_t phys = B_FALSE; - mmsmnt_arg_t arg; - door_arg_t d_arg; - - if (!mgmt_chk_auth("solaris.mms.io.read")) { - return (EACCES); - } - - (void) memset(&arg, 0, sizeof (mmsmnt_arg_t)); - (void) memset(&d_arg, 0, sizeof (d_arg)); - - /* requires either the pseudodevice name, *or* library/volume */ - st = nvlist_lookup_string(nvl, O_NAME, &pcl); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - if (pcl[0] == '/') { - (void) strlcpy(arg.devname, pcl, sizeof (arg.devname)); - } else { - (void) strlcpy(arg.cartridge, pcl, sizeof (arg.cartridge)); - } - - st = nvlist_lookup_string(nvl, O_MMSLIB, &lib); - if ((st != 0) && (arg.cartridge[0] != '\0')) { - MGMT_ADD_OPTERR(errs, O_MMSLIB, st); - return (st); - } - - if (lib) { - (void) strlcpy(arg.library, lib, sizeof (arg.library)); - } - - /* could specify all the options, but unlikely */ - st = nvlist_lookup_string(nvl, "mountdev", &dev); - if (st == 0) { - (void) strlcpy(arg.devname, dev, sizeof (arg.devname)); - } - - (void) nvlist_lookup_string(nvl, O_APPS, &app); - if (!app) { - app = "MMS"; - } - (void) nvlist_lookup_string(nvl, "instance", &inst); - (void) nvlist_lookup_string(nvl, O_MMPASS, &pass); - - /* make sure user is permitted to unmount this volume */ - if (strcasecmp(app, "MMS") != 0) { - st = create_mm_clnt(app, inst, pass, NULL, &sess); - if (st != 0) { - return (st); - } - - (void) mms_gen_taskid(tid); - - if (pcl[0] == '/') { - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] report[MOUNTPHYSICAL] " - "reportmode[namevalue] " - "match[and " - "(streq(MOUNTPHYSICAL.'ApplicationName' '%s') " - "streq(MOUNTLOGICAL.'MountLogicalHandle' '%s'))];", - tid, app, pcl); - } else { - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] report[MOUNTPHYSICAL] " - "reportmode[namevalue] " - "match[and " - "(streq(MOUNTPHYSICAL.'ApplicationName' '%s') " - "streq(MOUNTPHYSICAL.'CartridgePCL' '%s'))];", - tid, app, pcl); - } - - st = mms_mgmt_send_cmd(sess, tid, cmd, "check mounted vol", - &resp); - if (st == 0) { - st = mmp_get_nvattrs("ApplicationName", B_FALSE, - resp, &attrs); - mms_free_rsp(resp); - } - if (st == 0) { - if (!nvlist_exists(attrs, app)) { - st = MMS_MGMT_VOL_NOT_MOUNTED; - } - nvlist_free(attrs); - } - - (void) mms_goodbye(sess, 0); - - if (st != 0) { - return (st); - } - } - - arg.op = 2; - - /* see if they want the cartridge physically unloaded */ - st = nvlist_lookup_boolean_value(nvl, "unload", &phys); - if (phys) { - (void) strlcpy(arg.cmd, "physicalunmount", sizeof (arg.cmd)); - } - - d_arg.data_ptr = (char *)&arg; - d_arg.data_size = sizeof (mmsmnt_arg_t); - d_arg.desc_ptr = NULL; - d_arg.desc_num = 0; - d_arg.rbuf = (char *)&arg; - d_arg.rsize = d_arg.data_size; - - st = call_mmsmnt(&d_arg); - - return (st); -} diff --git a/usr/src/lib/mms/mgmt/common/mgmt_media.h b/usr/src/lib/mms/mgmt/common/mgmt_media.h deleted file mode 100644 index b6e12bf3b0..0000000000 --- a/usr/src/lib/mms/mgmt/common/mgmt_media.h +++ /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 - */ -/* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -#ifndef _MMS_MGMT_MEDIA_H -#define _MMS_MGMT_MEDIA_H - - -/* - * mgmt_media.h - */ - -#include <stdio.h> - -#include "mms.h" -#include "mgmt_util.h" - -/* structure to define a cartridge in MMS */ -typedef struct { - mms_list_node_t next; - char label[MAXNAMELEN]; - time_t access; - size_t capacity; - int32_t libacs; - int32_t liblsm; - char mtype[MAXNAMELEN]; - char libname[MAXNAMELEN]; - char groupname[MAXNAMELEN]; - char appname[MAXNAMELEN]; -} mms_acscart_t; - -#endif /* _MMS_MGMT_MEDIA_H */ diff --git a/usr/src/lib/mms/mgmt/common/mgmt_mm.c b/usr/src/lib/mms/mgmt/common/mgmt_mm.c deleted file mode 100644 index fb28acb53a..0000000000 --- a/usr/src/lib/mms/mgmt/common/mgmt_mm.c +++ /dev/null @@ -1,1786 +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. - */ - - -#include <libgen.h> -#include <stdio.h> -#include <libnvpair.h> -#include <fcntl.h> -#include <sys/types.h> - -#include "mms_mgmt.h" -#include "mgmt_util.h" -#include "mms_cfg.h" -#include "net_cfg_service.h" - -static char *_SrcFile = __FILE__; -#define HERE _SrcFile, __LINE__ - -typedef struct { - char *name; - char *cfgnam; - int svc; -} mms_mgmt_cfgopt_t; - -static mms_mgmt_cfgopt_t mmscfgopts[] = { - {O_MMHOST, MMS_CFG_MGR_HOST, WCR|MM}, - {O_MMPORT, MMS_CFG_MGR_PORT, WCR|MM}, - {O_OBJTYPE, MMS_CFG_CONFIG_TYPE, 0}, - {O_SSLENABLED, MMS_CFG_SSL_ENABLED, WCR|MM}, - {O_CERTFILE, MMS_CFG_SSL_CERT_FILE, WCR|MM}, - {O_SSLPASSFILE, MMS_CFG_SSL_PASS_FILE, WCR|MM}, - {O_CRLFILE, MMS_CFG_SSL_CRL_FILE, WCR|MM}, - {O_PEERFILE, MMS_CFG_SSL_PEER_FILE, WCR|MM}, - {O_DHFILE, MMS_CFG_SSL_DH_FILE, WCR|MM}, - {"ssl_cipher", MMS_CFG_SSL_CIPHER, WCR|MM}, - {O_VERIFY, MMS_CFG_SSL_VERIFY, WCR|MM}, - {O_DBHOST, MMS_CFG_MM_DB_HOST, MM}, - {O_DBPORT, MMS_CFG_MM_DB_PORT, DB|MM}, - {O_DBDIR, MMS_CFG_DB_DATA, DB}, - {O_DBLOG, MMS_CFG_DB_LOG, DB}, - {"db-user", MMS_CFG_MM_DB_USER, MM}, - {O_DBNAME, MMS_CFG_MM_DB_NAME, DB}, - {O_TRACELEVEL, MMS_CFG_MM_TRACE, MM}, - {O_ACSLSDIR, MMS_CFG_SSI_PATH, WCR}, - {NULL, NULL, 0} -}; - -#ifdef MMS_VAR_CFG -/* MMS Client Options */ -static mms_mgmt_setopt_t mms_client_opts[] = { - {O_MMHOST, NULL, NULL, B_TRUE, NULL}, - {O_MMPORT, NULL, MMS_DEF_MMPORT, B_TRUE, val_numonly}, - {O_MMPASS, NULL, NULL, B_TRUE, val_passwd}, - {O_OBJTYPE, NULL, "client", B_TRUE, val_objtype}, - {O_SECURECOMM, NULL, "off", B_TRUE, NULL}, - {O_SSLENABLED, NULL, "false", B_TRUE, NULL}, - {O_CERTFILE, NULL, MMSSSLDIR"/mms.pem", B_FALSE, val_path}, - {O_SSLPASSFILE, NULL, MMSSSLDIR"/mms_pass", B_FALSE, val_path}, - {O_CRLFILE, NULL, MMSSSLDIR"/mms_crl.pem", B_FALSE, val_path}, - {O_PEERFILE, NULL, MMSSSLDIR"/mms_cert.pem", B_FALSE, val_path}, - {O_ACSLSDIR, NULL, NULL, B_FALSE, val_path}, - {NULL, NULL, NULL, B_FALSE, NULL} -}; -#define NUM_CLIENT_OPTS (sizeof (mms_client_opts) / sizeof (mms_mgmt_setopt_t)) -#endif /* MMS_VAR_CFG */ - -/* MMS Server Options */ -static mms_mgmt_setopt_t mms_server_opts[] = { - {O_MMHOST, NULL, NULL, B_TRUE, NULL}, - {O_MMPORT, NULL, MMS_DEF_MMPORT, B_TRUE, val_numonly}, - {O_MMPASS, NULL, NULL, B_TRUE, val_passwd}, - {O_OBJTYPE, NULL, "server", B_TRUE, val_objtype}, - {O_ACSLSDIR, NULL, NULL, B_TRUE, val_path}, - {O_SECURECOMM, NULL, "off", B_TRUE, NULL}, - {O_SSLENABLED, NULL, "false", B_TRUE, NULL}, - {O_CERTFILE, NULL, MMSSSLDIR"/mms.pem", B_FALSE, val_path}, - {O_SSLPASSFILE, NULL, MMSSSLDIR"/mms_pass", B_FALSE, val_path}, - {O_CRLFILE, NULL, MMSSSLDIR"/mms_crl.pem", B_FALSE, val_path}, - {O_PEERFILE, NULL, MMSSSLDIR"/mms_cert.pem", B_FALSE, val_path}, - {O_DHFILE, NULL, MMSSSLDIR"/mms_dh1024.pem", B_FALSE, NULL}, - {O_VERIFY, NULL, "false", B_FALSE, NULL}, - {O_LOGLEVEL, "SystemLogLevel", MMS_DEF_LOGLVL, B_FALSE, val_level}, - {O_LOGFILE, "SystemLogFile", MMSLOGDIR"/mm.log", B_FALSE, - val_path}, - {O_DBDIR, NULL, MMS_DEF_DBDIR, B_TRUE, val_path}, - {O_DBHOST, NULL, "localhost", B_TRUE, NULL}, - {O_DBPORT, NULL, MMS_DEF_DBPORT, B_TRUE, val_numonly}, - {O_DBLOG, NULL, NULL, B_FALSE, val_path}, - {O_DBNAME, NULL, "mms", B_TRUE, NULL}, - {O_NUMRESTART, "WatcherStartsLimit", "3", B_FALSE, val_numonly}, - {O_ATTENDED, "AttendanceMode", "yes", B_FALSE, val_yesno}, - {O_NUMSOCKET, "SocketFdLimit", "-1", B_FALSE, val_numonly}, - {O_DKTIMEOUT, "SystemDiskMountTimeout", "0", B_FALSE, val_numonly}, - {O_TRACELEVEL, "TraceLevel", NULL, B_FALSE, val_level}, - {O_TRACESZ, "TraceFileSize", NULL, B_FALSE, val_mms_size}, - {O_MSGLEVEL, "MessageLevel", NULL, B_FALSE, val_level}, - {NULL, NULL, NULL, B_FALSE, NULL} -}; -#define NUM_SERVER_OPTS (sizeof (mms_server_opts) / sizeof (mms_mgmt_setopt_t)) - -static mms_mgmt_setopt_t application_opts[] = { - {O_NAME, NULL, NULL, B_TRUE, NULL}, - {O_RETENTION, "Retention", NULL, B_FALSE, val_numonly}, - {O_VALIDATEEXP, "ValidateExpirationDate", NULL, B_FALSE, val_truefalse}, - {O_VALIDATEVOL, "ValidateVolumeID", NULL, B_FALSE, val_truefalse}, - {O_VALIDATEFN, "ValidateFileName", NULL, B_FALSE, val_truefalse}, - {O_OVERWRITEEXT, "WriteOverExistingData", NULL, B_FALSE, val_truefalse}, - {NULL, NULL, NULL, B_FALSE, NULL} -}; - -static int mgmt_set_pass(char *inpw); -#ifdef MMS_VAR_CFG -static int mgmt_set_ssl(nvlist_t *opts); -#endif /* MMS_VAR_CFG */ - -/* - * The create_mm_clnt() function establishes a session with - * MM. If "app" is not MMS and "inst" is not "admin", the password must - * also be provided. "tag" is an optional identifier to be used - * in the session API. - */ -int -create_mm_clnt(char *app, char *inst, char *pass, char *tag, void **session) -{ - - int version; - int st; - mms_network_cfg_t cfg; - void *ssl_data = NULL; - void *sess = NULL; - char *tagp = ""; -#ifdef MMS_OPENSSL - mms_err_t err; - char ebuf[1024]; -#endif /* MMS_OPENSSL */ - - if (!session) { - return (MMS_MGMT_NOARG); - } - - *session = NULL; - - (void) memset(&cfg, 0, sizeof (mms_network_cfg_t)); - - /* - * mms_net_cfg_service() expects to fetch information - * for MMS admin only. However, we can use this to - * fetch the non-auth information for any app. - */ - st = mms_net_cfg_service(&cfg, "admin", "MMP", "1.0"); - if (st == 2) { - /* password not available */ - if (!pass) { - st = MMS_MGMT_PASSWORD_REQUIRED; - } else { - st = 0; - } - } else if (st == 1) { - st = MMS_MGMT_MMS_NOT_INIT; - } - - if (st != 0) { - mms_trace(MMS_ERR, "Could not get MM connection info"); - return (st); - } - - if (app) { - if (strcasecmp(cfg.cli_name, app) != 0) { - free(cfg.cli_name); - cfg.cli_name = strdup(app); - if (cfg.cli_name == NULL) { - mms_trace(MMS_ERR, "Out of memory"); - mms_net_cfg_free(&cfg); - return (ENOMEM); - } - } - } - - if (inst) { - if (strcasecmp(cfg.cli_inst, inst) != 0) { - free(cfg.cli_inst); - cfg.cli_inst = strdup(app); - if (cfg.cli_inst == NULL) { - mms_trace(MMS_ERR, "Out of memory"); - mms_net_cfg_free(&cfg); - return (ENOMEM); - } - } - } - - if (pass) { - if (cfg.cli_pass) { - free(cfg.cli_pass); - } - cfg.cli_pass = strdup(pass); - if (cfg.cli_pass == NULL) { - mms_trace(MMS_ERR, "Out of memory"); - mms_net_cfg_free(&cfg); - return (ENOMEM); - } - } - - if (tag) { - tagp = tag; - } - - if ((st = mms_init(&sess, &version)) != MMS_API_OK) { - mms_trace(MMS_ERR, "Unable to create a session with MM"); - mms_net_cfg_free(&cfg); - return (st); - } - - mms_trace(MMS_DEBUG, "MM version = %d, expected version = %d", - version, MMS_API_VERSION); - -#ifdef MMS_OPENSSL - if (cfg.ssl_enabled != 0) { - st = mms_ssl_client(&cfg, &ssl_data, &err); - if (st != 0) { - mms_get_error_string(&err, ebuf, MMS_EBUF_LEN); - mms_trace(MMS_ERR, "error ssl init - %s", ebuf); - mms_net_cfg_free(&cfg); - return (st); - } - } -#endif /* MMS_OPENSSL */ - - st = mms_hello(sess, cfg.cli_host, cfg.cli_port, cfg.cli_name, - cfg.cli_inst, tagp, cfg.cli_pass, cfg.mm_pass, ssl_data); - - if (st != MMS_API_OK) { - mms_trace(MMS_ERR, - "Unable to create a session with MM, ret = %d [%s]", - st, mms_sym_code_to_str(st)); - mms_net_cfg_free(&cfg); - - return (st); - } - - *session = sess; - - mms_trace(MMS_DEBUG, "Created a connection with MM"); - mms_net_cfg_free(&cfg); - - return (0); -} - -/* - * mms_mgmt_init_host() - * - * DESCRIPTION: - * - * Sets all required MMS options, and starts required services. - * - * On an MMS client system, - * sets MM host, port and administrative password - * sets SSL options, if desired - * starts the Watcher daemon - * - * On on MMS server system, - * creates MMS database admin user - * initializes MMS database and starts database server - * sets MM options [TBD: list these with explanation] - * starts MM daemon and Watcher daemon - * - * ARGUMENTS: - * nvlist_t *opts key/value pairs for requested options - * nvlist_t **errs optional - used to return detailed errors - * about invalid/missing options, and other - * operational failures during initialization. - * If 'errs' is non-NULL, a new nvlist will be - * allocated. The caller should free this list - * with nvlist_free(). - * - * RETURN VALUES: - * - * 0 Success - * MMS_MGMT_NOARG 'opts' argument missing - * EINVAL One or more requested options is invalid - * EALREADY Host has already been initialized for MMS - * ENOMEM Out of memory - * [others TBD] - */ - -int -mms_mgmt_init_host(nvlist_t *opts, nvlist_t **errs) -{ - int st = 0; - mms_mgmt_setopt_t *optp = NULL; - int nst = 0; - char *val; - char *pass = NULL; - char *hosttype = NULL; - char cfgvar[2048]; - char buf[2048]; - int i; - nvlist_t *init_errs = NULL; - - if (!opts) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.create")) { - mms_trace(MMS_DEBUG, "mgmt_chk_auth error"); - return (EACCES); - } - -#ifdef MMS_VAR_CFG - /* make sure we've not already been initialized */ - st = mms_cfg_getvar(MMS_CFG_CONFIG_TYPE, buf); - if (st != 0) { - mms_trace(MMS_DEBUG, "mms_cfg_getvar error"); - st = mgmt_xlate_cfgerr(st); - if (st != ENOENT) { - return (st); - } - } else { - /* host already configured */ - mms_trace(MMS_DEBUG, "already config error"); - return (EALREADY); - } -#endif /* MMS_VAR_CFG */ - - if (errs) { - *errs = NULL; - st = nvlist_alloc(&init_errs, NV_UNIQUE_NAME, 0); - if (st != 0) { - return (st); - } - } - - st = nvlist_lookup_string(opts, O_OBJTYPE, &hosttype); - if (st == 0) { - if (*hosttype == 's') { - optp = mms_server_opts; -#ifdef MMS_VAR_CFG - } else if (*hosttype == 'c') { - optp = mms_client_opts; -#endif /* MMS_VAR_CFG */ - } else { - mms_trace(MMS_DEBUG, "EINVAL error"); - st = EINVAL; - } - } - - if (st != 0) { - MGMT_ADD_OPTERR(init_errs, O_OBJTYPE, st); - *errs = init_errs; - return (st); - } - - st = nvlist_lookup_string(opts, O_MMPASS, &pass); - if (st != 0) { - MGMT_ADD_OPTERR(init_errs, O_MMPASS, st); - *errs = init_errs; - return (st); - } - - st = mms_cfg_getvar(MMS_CFG_MM_DB_USER, buf); - if (st != 0) { - mms_trace(MMS_DEBUG, "mms_cfg_getvar error"); - st = mgmt_xlate_cfgerr(st); - if (st == ENOENT) { - st = mms_cfg_getvar(MMS_CFG_DB_INST - "/:properties/method_context/user", buf); - } - } - if (st != 0) { - /* major configuration error */ - mms_trace(MMS_DEBUG, "major configuration error"); - MGMT_ADD_OPTERR(init_errs, - "mmsdb method_context/user", - st); - goto done; - } - (void) nvlist_add_string(opts, "db-user", buf); - - for (i = 0; optp[i].name != NULL; i++) { -#ifndef MMS_VAR_CFG - /* We can only set opts in MMP until SMF gets sorted */ - if (optp[i].mmpopt == NULL) { - continue; - } -#endif /* MMS_VAR_CFG */ - nst = nvlist_lookup_string(opts, optp[i].name, &val); - if (nst == 0) { - if (optp[i].validate_func) { - nst = (optp[i].validate_func)(val); - } - } else if (nst == ENOENT) { - if (!(optp[i].required)) { - nst = 0; - } else if (optp[i].defval) { - nst = nvlist_add_string(opts, - optp[i].name, optp[i].defval); - } - } - - if (nst != 0) { - st = nst; - - if (errs) { - (void) nvlist_add_int32(init_errs, optp[i].name, - nst); - } else { - /* fail on first error */ - break; - } - } - } - - if (st != 0) { - goto done; - } - -#ifdef MMS_VAR_CFG - /* - * special case for DB logdir. If not specified, should be set to - * DBDIR/log - */ - if (*hosttype == 's') { - st = nvlist_lookup_string(opts, O_DBLOG, &val); - if (st == ENOENT) { - st = nvlist_lookup_string(opts, O_DBDIR, &val); - if (st == 0) { - (void) snprintf(buf, sizeof (buf), "%s/../%s", - val, "log"); - st = nvlist_add_string(opts, O_DBLOG, buf); - } - } - if (st != 0) { - MGMT_ADD_OPTERR(init_errs, O_DBDIR, st); - goto done; - } - } - - /* TODO: support ssl enabled */ - - /* have the full complement of required options - set SMF config */ - for (i = 0; mmscfgopts[i].name != NULL; i++) { - nst = nvlist_lookup_string(opts, mmscfgopts[i].name, &val); - if (nst == 0) { - mms_cfg_setvar(mmscfgopts[i].cfgnam, val); - } - } -#endif /* MMS_VAR_CFG */ - - /* Set the MMS Admin password */ - st = mgmt_set_pass(pass); - if (st != 0) { - goto done; - } - - /* If we're setting up the server, configure the DB and start MM */ - if (*hosttype == 's') { -#ifndef MMS_VAR_CFG - /* - * TEMPORARY: Fetch variables from SMF, rather than - * require them to be passed in. - */ - st = mms_cfg_getvar(MMS_CFG_DB_DATA, cfgvar); - if (st != 0) { - MGMT_ADD_OPTERR(init_errs, O_DBDIR, st); - goto done; - } else { - (void) nvlist_add_string(opts, O_DBDIR, cfgvar); - - /* fixed path for log dir */ - (void) strlcat(cfgvar, "/../log", sizeof (cfgvar)); - (void) nvlist_add_string(opts, O_DBLOG, cfgvar); - } - st = mms_cfg_getvar(MMS_CFG_MM_DB_PORT, cfgvar); - if (st == 0) { - (void) nvlist_add_string(opts, O_DBPORT, cfgvar); - } else { - MGMT_ADD_OPTERR(init_errs, O_DBPORT, st); - goto done; - } - - st = mms_cfg_getvar(MMS_CFG_MM_DB_NAME, cfgvar); - if (st == 0) { - (void) nvlist_add_string(opts, O_DBNAME, cfgvar); - } else { - MGMT_ADD_OPTERR(init_errs, O_DBNAME, st); - goto done; - } - - st = mms_cfg_getvar(MMS_CFG_MM_DB_HOST, cfgvar); - if (st == 0) { - (void) nvlist_add_string(opts, O_DBHOST, cfgvar); - } else { - MGMT_ADD_OPTERR(init_errs, O_DBHOST, st); - goto done; - } - -#endif /* !MMS_VAR_CFG */ - st = mgmt_set_db_opts(opts, init_errs); - if (st == 0) { - /* Database will be functional after this call */ - st = mgmt_db_create(1, 1, opts); - } - - if (st != 0) { - mms_trace(MMS_DEBUG, "mgmt_db_create error"); - goto done; - } - - mms_trace(MMS_DEBUG, "enable mm"); - st = mgmt_set_svc_state(MMSVC, ENABLE, NULL); - if (st != 0) - mms_trace(MMS_DEBUG, - "mgmt_set_svc_state(MMSVC, ENABLE, NULL) " - "error"); - } - - /* Watcher needs to be started for both host types */ - if (st == 0) { - mms_trace(MMS_DEBUG, "enable wcr"); - st = mgmt_set_svc_state(WCRSVC, ENABLE, NULL); - } - if (st != 0) - mms_trace(MMS_DEBUG, - "mgmt_set_svc_state(WCRSVC, ENABLE, NULL) " - "error"); - -done: - if (st != 0) { - if (errs) { - *errs = init_errs; - } - /* don't stop services if we haven't changed anything */ - if (st != EALREADY) { - (void) mms_mgmt_uninitialize(); - } - } else if (init_errs) { - nvlist_free(init_errs); - } - - return (st); -} - -/* - * mms_mgmt_get_opts() - */ -int -mms_mgmt_get_opts(char *type, nvlist_t **opts) -{ - int st; - int i; - char buf[2048]; - void *session = NULL; - void *response = NULL; - char tid[64]; - nvlist_t *sysattrs = NULL; - nvpair_t *nvp; - nvlist_t *nva; - - if ((type == NULL) || (opts == NULL)) { - return (MMS_MGMT_NOARG); - } - - /* get MM system vals */ - (void) mms_gen_taskid(tid); - (void) snprintf(buf, sizeof (buf), - "show task['%s'] report[SYSTEM] reportmode[namevalue];", tid); - - st = create_mm_clnt(NULL, NULL, NULL, NULL, &session); - if (st != 0) { - goto done; - } - - st = mms_mgmt_send_cmd(session, tid, buf, "get system attrs", - &response); - - (void) mms_goodbye(session, 0); - - if (st != 0) { - goto done; - } - st = mmp_get_nvattrs(O_NAME, B_TRUE, response, &sysattrs); - if (st != 0) { - goto done; - } - - nvp = nvlist_next_nvpair(sysattrs, NULL); - if (nvp == NULL) { - /* should never happen */ - goto done; - } - - st = nvpair_value_nvlist(nvp, &nva); - if (st != 0) { - goto done; - } - - /* add the SMF variables */ - for (i = 0; mmscfgopts[i].name != NULL; i++) { - st = mms_cfg_getvar(mmscfgopts[i].cfgnam, buf); - if (st != 0) { - /* probably unset, keep going */ - st = 0; - continue; - } - if (!nvlist_exists(nva, mmscfgopts[i].name)) { - (void) nvlist_add_string(nva, mmscfgopts[i].name, buf); - } - } - - if (st != 0) { - goto done; - } - - if (*opts == NULL) { - st = nvlist_alloc(opts, NV_UNIQUE_NAME, 0); - if (st != 0) { - goto done; - } - } - - /* don't want a proper name for this list */ - (void) nvlist_add_nvlist(*opts, "", nva); - - -done: - - if (sysattrs) { - nvlist_free(sysattrs); - } - - if (st != 0) { - nvlist_free(*opts); - *opts = NULL; - } - - return (st); -} - -/* - * Required opts that are not in inopts, and options with invalid values - * are added to the argument nvlist "errlist". - */ -int -mms_mgmt_set_opts(nvlist_t *optlist, nvlist_t *errlist) -{ - int st; - int i; - int errs = 0; - char *opt; - char *val; - mms_mgmt_setopt_t *optp = mms_server_opts; - nvpair_t *nvp; - int refresh_svcs = 0; -#ifdef MMS_VAR_CFG - int svc_to_check = 0; -#endif /* MMS_VAR_CFG */ - char mmtype[2048]; - char buf[2048]; - char cmd[8192]; - char tid[64]; - void *session = NULL; - void *response = NULL; - int count = 0; - - if (optlist == NULL) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.modify")) { - return (EACCES); - } - - /* check the type of system we're on */ - st = mms_cfg_getvar(MMS_CFG_CONFIG_TYPE, mmtype); - if (st != 0) { - return (ENOTSUP); - } - -#ifdef MMS_VAR_CFG - if (*mmtype == 'c') { - svc_to_check = WCR; - } else { - svc_to_check = MM|DB; - } -#endif /* MMS_VAR_CFG */ - - nvp = NULL; - while ((nvp = nvlist_next_nvpair(optlist, nvp)) != NULL) { - - opt = nvpair_name(nvp); - - if (strcmp(opt, O_OBJTYPE) == 0) { - /* ignore type on 'set' */ - continue; - } - - st = nvpair_value_string(nvp, &val); - if (st != 0) { - break; - } - - /* unrecognized options are ignored */ - for (i = 0; optp[i].name != NULL; i++) { - if (strcmp(opt, optp[i].name) != 0) { - continue; - } - - st = 0; - - if (optp[i].validate_func) { - st = (optp[i].validate_func)(val); - } - if (st != 0) { - errs++; - if (errlist) { - (void) nvlist_add_int32(errlist, opt, - st); - } - } - break; - } - - if ((errs) && (!errlist)) { - st = EINVAL; - break; - } - } - - if (st != 0) { - goto done; - } - -#ifdef MMS_VAR_CFG - /* set SMF config */ - for (i = 0; mmscfgopts[i].name != NULL; i++) { - if (strcmp(mmscfgopts[i].name, O_OBJTYPE) == 0) { - /* again, skip for set */ - continue; - } - st = nvlist_lookup_string(optlist, mmscfgopts[i].name, &val); - if (st == 0) { - if (!(svc_to_check & mmscfgopts[i].svc)) { - st = MMS_MGMT_ERR_SVRONLY; - MGMT_ADD_ERR(errlist, mmscfgopts[i].name, st); - continue; - } - mms_cfg_setvar(mmscfgopts[i].cfgnam, val); - refresh_svcs |= mmscfgopts[i].svc; - } - } - st = 0; - - /* set DB opts, if any were specified */ - if (refresh_svcs & DB) { - st = mgmt_set_db_opts(optlist, errlist); - - if (st != 0) { - goto done; - } - } -#endif /* MMS_VAR_CFG */ - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), "attribute task['%s'] ", tid); - - for (i = 0; mms_server_opts[i].name != NULL; i++) { - if (mms_server_opts[i].mmpopt == NULL) { - continue; - } - st = nvlist_lookup_string(optlist, mms_server_opts[i].name, - &val); - if (st != 0) { - continue; - } - if (strcmp(val, "") != 0) { - /* set */ - (void) snprintf(buf, sizeof (buf), - " set[SYSTEM.'%s' '%s']", - mms_server_opts[i].mmpopt, val); - } else { - /* unset */ - (void) snprintf(buf, sizeof (buf), - " unset[SYSTEM.'%s']", - mms_server_opts[i].mmpopt); - } - - (void) strlcat(cmd, buf, sizeof (cmd)); - count++; - } - (void) strlcat(cmd, ";", sizeof (cmd)); - - /* if no MM opts specified, nothing to set */ - if (count > 0) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &session); - if (st != 0) { - goto done; - } - - st = mms_mgmt_send_cmd(session, tid, cmd, "set system attrs", - &response); - - (void) mms_goodbye(session, 0); - - if (st != 0) { - goto done; - } - } - -#ifdef MMS_VAR_CFG - /* TODO: set SSL opts */ - st = mgmt_set_ssl(optlist); - if (st != 0) { - goto done; - } -#endif /* MMS_VAR_CFG */ - - /* refresh services */ - if (*mmtype == 's') { - if (refresh_svcs & DB) { - mms_trace(MMS_DEBUG, "refresh db"); - (void) mgmt_set_svc_state(DBSVC, REFRESH, NULL); - } - if (refresh_svcs & MM) { - mms_trace(MMS_DEBUG, "refresh mm"); - (void) mgmt_set_svc_state(MMSVC, REFRESH, NULL); - } - } - - if (refresh_svcs & WCR) { - mms_trace(MMS_DEBUG, "refresh wcr"); - (void) mgmt_set_svc_state(WCRSVC, REFRESH, NULL); - } - -done: - return (st); -} - -int -mms_mgmt_uninitialize(void) -{ - int st = 0; - char *mmsvcs[] = {WCRSVC, MMSVC, DBSVC, NULL}; - int i; - - if (!mgmt_chk_auth("solaris.mms.delete")) { - return (EACCES); - } - - /* stop all running services */ - for (i = 0; mmsvcs[i] != NULL; i++) { - mms_trace(MMS_DEBUG, "disable %s", mmsvcs[i]); - st = mgmt_set_svc_state(mmsvcs[i], DISABLE, NULL); - if (st != 0) { - break; - } - } - -#ifdef MMS_VAR_CFG - /* get rid of all the configuration information */ - if (st == 0) { - mgmt_unsetall_cfgvar(); - } -#endif /* MMS_VAR_CFG */ - - return (st); -} - -static int -mgmt_set_pass(char *inpw) -{ - int st = 0; - int fd = -1; - size_t sz; - size_t szi; - char *pf = MMSETCDIR"/passwd/hello.new"; - char *of = MMSETCDIR"/passwd/hello"; - - if (!inpw) { - return (EINVAL); - } - - fd = open64(pf, O_CREAT|O_WRONLY|O_NOFOLLOW|O_NOLINKS|O_SYNC|O_TRUNC, - 0600); - - if (fd == -1) { - return (errno); - } - - szi = strlen(inpw) + 1; - sz = write(fd, inpw, szi); - if (szi != sz) { - st = errno; - } - - (void) close(fd); - - if (st == 0) { - st = rename(pf, of); - } else { - (void) unlink(pf); - } - - return (st); -} - -#ifdef MMS_VAR_CFG -static int -mgmt_set_ssl(nvlist_t *opts) -{ - char *val = NULL; - - - if (!opts) { - return (EINVAL); - } - - nvlist_lookup_string(opts, O_SSLENABLED, &val); - if ((!val) || (strcmp(val, "false") == 0)) { - mms_cfg_setvar(MMS_CFG_SSL_ENABLED, "false"); - mms_cfg_unsetvar(MMS_CFG_SSL_CERT_FILE); - mms_cfg_unsetvar(MMS_CFG_SSL_PASS_FILE); - mms_cfg_unsetvar(MMS_CFG_SSL_CRL_FILE); - mms_cfg_unsetvar(MMS_CFG_SSL_PEER_FILE); - mms_cfg_unsetvar(MMS_CFG_SSL_DH_FILE); - mms_cfg_unsetvar(MMS_CFG_SSL_VERIFY); -#if TODO - } else { - /* TODO: Create the certs, etc. for SSL */ - /* leave existng cfg alone for now */ -#endif - } - - return (0); -} -#endif /* MMS_VAR_CFG */ - -int -mms_mgmt_add_application(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - int nst; - void *sess = NULL; - void *sessp = session; - char tid[64]; - char cmd[8192]; - char buf[1024]; - void *response; - char *name; - char *val; - char *pass; - int i; - mms_mgmt_setopt_t *optp = application_opts; - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.create")) { - return (EACCES); - } - - st = nvlist_lookup_string(nvl, O_NAME, &name); - if (st != 0) { - if (errs) { - (void) nvlist_add_int32(errs, O_NAME, st); - } - return (st); - } - - st = nvlist_lookup_string(nvl, O_MMPASS, &pass); - if (st != 0) { - if (errs) { - (void) nvlist_add_int32(errs, O_MMPASS, st); - } - return (st); - } - - (void) mms_gen_taskid(tid); - - (void) snprintf(cmd, sizeof (cmd), - "create task['%s'] type[APPLICATION]" - " set[APPLICATION.'ApplicationName' '%s']", tid, name); - - for (i = 0; optp[i].name != NULL; i++) { - if (strcmp(optp[i].name, O_NAME) == 0) { - continue; - } - nst = nvlist_lookup_string(nvl, optp[i].name, &val); - if (nst == 0) { - if (optp[i].validate_func) { - nst = (optp[i].validate_func)(val); - } - } else if (nst == ENOENT) { - if (!(optp[i].required)) { - nst = 0; - continue; - } else if (optp[i].defval) { - val = optp[i].defval; - } - } - - if (nst != 0) { - st = nst; - - if (errs) { - (void) nvlist_add_int32(errs, optp[i].name, - nst); - } else { - /* fail on first error */ - break; - } - } else { - (void) snprintf(buf, sizeof (buf), - " set[APPLICATION.'%s' '%s']", - optp[i].mmpopt, val); - (void) strlcat(cmd, buf, sizeof (cmd)); - } - } - (void) strlcat(cmd, ";", sizeof (cmd)); - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "add application", &response); - - if (st == 0) { - /* add an application instance for administrative purposes */ - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "create task['%s'] type[AI] " - "set[AI.'ApplicationName' '%s'] " - "set[AI.'AIName' 'admin'] " - "set[AI.'SessionsAllowed' 'multiple'];", - tid, name); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, - "add application instance", &response); - } - - if (st == 0) { - st = mms_mgmt_set_pass(sessp, nvl, errs); - } - - if (st != 0) { - MGMT_ADD_ERR(errs, name, st); - (void) mms_mgmt_remove_application(sessp, nvl, errs); - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -int -mms_mgmt_remove_application(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - void *sess = NULL; - void *sessp = session; - char tid[64]; - char cmd[8192]; - void *response; - char *name; - uint32_t volcnt = 0; - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.delete")) { - return (EACCES); - } - - st = nvlist_lookup_string(nvl, O_NAME, &name); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_NAME, st); - return (st); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - /* - * See if there are any volumes in use by this application - * before removing it. Fail the op so we don't lose any - * customer data. - */ - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] report[VOLUME] reportmode[number] " - "match[streq(VOLUME.'ApplicationName' '%s')];", - tid, name); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, - "find volumes for app", &response); - if (st == 0) { - st = mms_mgmt_mmp_count(response, &volcnt); - mms_free_rsp(response); - } - - if (volcnt != 0) { - st = MMS_MGMT_APP_VOLS_EXIST; - } - - if (st != 0) { - goto done; - } - - /* delete any CARTRIDGEGROUPAPPLICATIONS */ - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[CARTRIDGEGROUPAPPLICATION] " - "match[streq(CARTRIDGEGROUPAPPLICATION.'ApplicationName' '%s')];", - tid, name); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "delete mpool app", - &response); - - if (st != 0) { - goto done; - } - - /* delete any DRIVEGROUPAPPLICATIONS */ - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[DRIVEGROUPAPPLICATION] " - "match[streq(DRIVEGROUPAPPLICATION.'ApplicationName' '%s')];", - tid, name); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "delete drive app", - &response); - - if (st != 0) { - goto done; - } - - /* next, delete the application instances. */ - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[AI] " - "match[streq(AI.'ApplicationName' '%s')];", tid, name); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "delete app instance", - &response); - if (st == 0) { - - /* Finally, the application itself */ - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "delete task['%s'] type[APPLICATION]" - " match[streq(APPLICATION.'ApplicationName' '%s')];", - tid, name); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "delete application", - &response); - } - -done: - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -int -mms_mgmt_modify_application(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - void *sess = NULL; - void *sessp = session; - char tid[64]; - char cmd[8192]; - char buf[1024]; - void *response; - char *name; - char *val; - char *val2; - nvlist_t *attrs; - nvlist_t *nva; - nvpair_t *nvp; - mms_mgmt_setopt_t *optp = application_opts; - int i; - int changed = 0; - int nst; - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.modify")) { - return (EACCES); - } - - st = nvlist_lookup_string(nvl, O_NAME, &name); - if (st != 0) { - if (errs) { - (void) nvlist_add_int32(errs, O_NAME, st); - } - return (st); - } - - (void) mms_gen_taskid(tid); - - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] report[APPLICATION] reportmode[namevalue]" - " match[streq(APPLICATION.'ApplicationName' '%s')];", tid, name); - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "add application", &response); - - if (st != 0) { - goto done; - } - - st = mmp_get_nvattrs("ApplicationName", B_FALSE, response, &attrs); - if (st != 0) { - goto done; - } - - nvp = nvlist_next_nvpair(attrs, NULL); - if (nvp == NULL) { - st = EINVAL; - goto done; - } - st = nvpair_value_nvlist(nvp, &nva); - if (st != 0) { - goto done; - } - - (void) mms_gen_taskid(tid); - - (void) snprintf(cmd, sizeof (cmd), - "attribute task['%s'] " - "match[streq(APPLICATION.'ApplicationName' '%s')] ", - tid, name); - - for (i = 0; optp[i].name != NULL; i++) { - if (strcmp(optp[i].name, O_NAME) == 0) { - continue; - } - if ((nvlist_lookup_string(nvl, optp[i].name, &val)) != 0) { - continue; - } - - if (strcmp(val, "") == 0) { - (void) snprintf(buf, sizeof (buf), - " unset[APPLICATION.'%s']", optp[i].mmpopt); - (void) strlcat(cmd, buf, sizeof (cmd)); - changed++; - } else { - nst = nvlist_lookup_string(nva, optp[i].mmpopt, &val2); - if (nst == 0) { - if (strcmp(val, val2) == 0) { - continue; - } - } - (void) snprintf(buf, sizeof (buf), - " set[APPLICATION.'%s' '%s']", - optp[i].mmpopt, val); - (void) strlcat(cmd, buf, sizeof (cmd)); - changed++; - } - } - (void) strlcat(cmd, ";", sizeof (cmd)); - - if (changed == 0) { - goto done; - } - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "modify application", - &response); - -done: - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -int -mms_mgmt_set_pass(void *session, nvlist_t *nvl, nvlist_t *errs) -{ - int st; - char *passp = NULL; - char *namep = NULL; - void *sessp = session; - void *sess = NULL; - void *response = NULL; - char tid[64]; - char cmd[8192]; - - if (!nvl) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.modify")) { - return (EACCES); - } - - st = nvlist_lookup_string(nvl, O_NAME, &namep); - if (st != 0) { - if (errs) { - (void) nvlist_add_int32(errs, O_NAME, st); - } - return (st); - } - - st = nvlist_lookup_string(nvl, O_MMPASS, &passp); - if (st != 0) { - MGMT_ADD_OPTERR(errs, O_MMPASS, st); - return (st); - } - - if (strcasecmp(namep, "admin") == 0) { - namep = "MMS"; - } else if (strcasecmp(namep, "dbadmin") == 0) { - /* special case - doesn't modify MM at all */ - st = mgmt_set_db_pass(passp, errs); - return (st); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "setpassword task['%s'] password['%s'] name['%s'];", - tid, passp, namep); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, - "set password", &response); - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - if (st != 0) { - MGMT_ADD_ERR(errs, O_MMPASS, st); - } - - return (st); -} - -int -mms_mgmt_list_supported_types(void *session, nvlist_t **supported) -{ - int st; - void *sessp = session; - void *sess = NULL; - void *response = NULL; - char tid[64]; - char cmd[8192]; - nvlist_t *nvl = NULL; - - - if (!supported) { - return (MMS_MGMT_NOARG); - } - - st = nvlist_alloc(supported, NV_UNIQUE_NAME, 0); - if (st != 0) { - return (st); - } - - if (!sessp) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] report[LIBRARYLIST];", tid); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "list supported", &response); - if (st == 0) { - st = mmp_get_nvattrs("LibraryString", B_FALSE, response, &nvl); - mms_free_rsp(response); - if (st == 0) { - (void) nvlist_add_nvlist(*supported, "LIBRARY", nvl); - } - nvlist_free(nvl); - nvl = NULL; - } - if (st != 0) { - goto done; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] report[DRIVELIST];", tid); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "list supported", &response); - if (st == 0) { - st = mmp_get_nvattrs("DriveString", B_FALSE, response, &nvl); - mms_free_rsp(response); - if (st == 0) { - (void) nvlist_add_nvlist(*supported, "DRIVE", nvl); - } - nvlist_free(nvl); - nvl = NULL; - } - if (st != 0) { - goto done; - } - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] " - "report[CARTRIDGELIST];", tid); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "list supported", &response); - if (st == 0) { - st = mmp_get_nvattrs("CartridgeString", B_FALSE, response, - &nvl); - mms_free_rsp(response); - if (st == 0) { - (void) nvlist_add_nvlist(*supported, "CARTRIDGE", nvl); - } - nvlist_free(nvl); - nvl = NULL; - } - -done: - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -int -mms_mgmt_show_apps(void *session, nvlist_t *nvl, nvlist_t **apps) -{ - int st; - void *sessp = session; - void *sess = NULL; - void *response = NULL; - char tid[64]; - char cmd[8192]; - char buf[2048]; - char **names = NULL; - int count = 0; - int i; - char *key = O_NAME; - - if (!nvl || !apps) { - return (MMS_MGMT_NOARG); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - names = mgmt_var_to_array(nvl, O_NAME, &count); - - (void) mms_gen_taskid(tid); - if (count == 0) { - /* show all, filtering out the MMS Admin application */ - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] " - "match[strne(APPLICATION.'ApplicationName' 'MMS')] " - "report[APPLICATION];", - tid); - } else { - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] " - "report[APPLICATION] ", - tid); - - if (count > 1) { - (void) strlcat(cmd, "match[or", sizeof (cmd)); - } else { - (void) strlcat(cmd, "match[", sizeof (cmd)); - } - for (i = 0; i < count; i++) { - (void) snprintf(buf, sizeof (buf), - " streq (APPLICATION.'ApplicationName' '%s')", - names[i]); - (void) strlcat(cmd, buf, sizeof (cmd)); - } - (void) strlcat(cmd, "];", sizeof (cmd)); - } - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "show application", - &response); - if (st == 0) { - st = mmp_get_nvattrs(key, B_TRUE, response, apps); - mms_free_rsp(response); - } - - if (st != 0) { - goto done; - } - - mgmt_filter_results(nvl, *apps); - -done: - if (sess) { - (void) mms_goodbye(sess, 0); - } - - if (names) { - mgmt_free_str_arr(names, count); - } - - return (st); -} - -int -mms_mgmt_show_requests(void *session, nvlist_t *nvl, nvlist_t **reqs) -{ - int st; - void *sessp = session; - void *sess = NULL; - void *response = NULL; - char tid[64]; - char cmd[8192]; - char buf[2048]; - char **names = NULL; - int count = 0; - int i; - nvpair_t *nvp; - nvlist_t *nva; - char *val; - char *key = "request-id"; - char *tkey = "requestor-type"; - - if (!nvl || !reqs) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.request")) { - return (EACCES); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - names = mgmt_var_to_array(nvl, O_NAME, &count); - - (void) mms_gen_taskid(tid); - if (count == 0) { - /* show all */ - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] report[REQUEST];", - tid); - } else { - (void) snprintf(cmd, sizeof (cmd), - "show task['%s'] reportmode[namevalue] report[REQUEST] ", - tid); - - if (count > 1) { - (void) strlcat(cmd, "match[or", sizeof (cmd)); - } else { - (void) strlcat(cmd, "match[", sizeof (cmd)); - } - for (i = 0; i < count; i++) { - (void) snprintf(buf, sizeof (buf), - " streq (REQUEST.'RequestingClient' '%s')", - names[i]); - (void) strlcat(cmd, buf, sizeof (cmd)); - } - (void) strlcat(cmd, "];", sizeof (cmd)); - } - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "show oper requests", - &response); - if (st == 0) { - st = mmp_get_nvattrs(key, B_TRUE, response, - reqs); - mms_free_rsp(response); - } - - if (st != 0) { - goto done; - } - - nvp = NULL; - - while ((nvp = nvlist_next_nvpair(*reqs, nvp)) != NULL) { - st = nvpair_value_nvlist(nvp, &nva); - if (st != 0) { - continue; - } - st = nvlist_lookup_string(nva, tkey, &val); - if (st == 0) { - if (strcmp(val, "LM") == 0) { - val = "library"; - } else if (strcmp(val, "DM") == 0) { - val = "drive"; - } else if (strcmp(val, "MM") == 0) { - val = "system"; - } - (void) nvlist_add_string(nva, tkey, val); - } - } - -done: - if (sess) { - (void) mms_goodbye(sess, 0); - } - - if (names) { - mgmt_free_str_arr(names, count); - } - - return (st); -} - -int -mms_mgmt_accept_request(void *session, char *reqID, char *text) -{ - int st; - void *sessp = session; - void *sess = NULL; - void *response = NULL; - char tid[64]; - char cmd[8192]; - char *textp = text; - - if (!reqID) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.request")) { - return (EACCES); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - if (!textp) { - textp = "ok"; - } - - /* accept responsibility for this request, then respond to it */ - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "accept task['%s'] reqid['%s'];", - tid, reqID); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "accept oper request", - &response); - - if (st == 0) { - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "respond task['%s'] reqid['%s'] " - "message[id ['SUNW' 'MMS' '1000'] loctext ['EN' '%s']];", - tid, reqID, textp); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "accept oper request", - &response); - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -int -mms_mgmt_reject_request(void *session, char *reqID, char *text) -{ - int st; - void *sessp = session; - void *sess = NULL; - void *response = NULL; - char tid[64]; - char cmd[8192]; - char *textp = text; - - if (!reqID) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.request")) { - return (EACCES); - } - - if (!session) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - if (!textp) { - textp = "rejected"; - } - - /* accept responsibility for this request, then respond to it */ - - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "accept task['%s'] reqid['%s'];", - tid, reqID); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "reject oper request", - &response); - - if (st == 0) { - (void) mms_gen_taskid(tid); - (void) snprintf(cmd, sizeof (cmd), - "respond task['%s'] reqid['%s'] " - "message[id ['SUNW' 'MMS' '1000'] loctext ['EN' '%s']];", - tid, reqID, textp); - - st = mms_mgmt_send_cmd(sessp, tid, cmd, "accept oper request", - &response); - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} diff --git a/usr/src/lib/mms/mgmt/common/mgmt_mmp.c b/usr/src/lib/mms/mgmt/common/mgmt_mmp.c deleted file mode 100644 index 2d4b72ffdf..0000000000 --- a/usr/src/lib/mms/mgmt/common/mgmt_mmp.c +++ /dev/null @@ -1,1166 +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 <libgen.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/nvpair.h> - -#include "mms_mgmt.h" -#include "mgmt_acsls.h" -#include "mmp_defs.h" -#include "mgmt_sym.h" -#include "mgmt_util.h" - -static char *_SrcFile = __FILE__; -#define HERE _SrcFile, __LINE__ - -/* - * This file contains the following functionality: - * 1. parse MMP responses - * 2. error handling of MM communication - */ -static int attrs2nvlist(mms_par_node_t *attrs, boolean_t useropt, - nvlist_t **nvl); -static char *mgmt_cvt_mmp_to_user(char *in); -static char *mgmt_cvt_user_to_mmp(char *in); - -typedef struct { - char *mmp_opt; - char *public_opt; -} map_opt_names; - -/* those with NULL equivalents will not be returned to the caller */ -static map_opt_names optmap[] = { - {"CartridgeTypeName", O_VOLTYPE}, - {"CartridgeTypeNumberSides", "sides"}, - {"CartridgeTypeMediaLength", O_SIZE}, - {"CartridgeTypeMediaType", "purpose"}, - {"CartridgeStatus", "status"}, - {"CartridgeDriveOccupied", "loaded-in-drive"}, - {"MaxUseCount", "max-use-count"}, - {"CartridgeShapeName", O_MTYPE}, - {"Side1Name", NULL}, - {"CartridgeTypeSize", NULL}, - {"CartridgeID", NULL}, - {"CartridgePCL", "volid"}, - {"CartridgeState", "state"}, - {"CartridgeGroupName", O_MPOOL}, - {"DriveGroupName", O_DPOOL}, - {"CartridgeTimeCreated", "created"}, - {"CartridgeTimeMountedLast", "last-mounted"}, - {"CartridgeTimeMountedTotal", "total-mount-time"}, - {"CartridgeNumberMounts", "num-mounts"}, - {"CartridgeWriteProtected", "write-protected"}, - {"CartridgeNumberVolumes", NULL}, - {"CartridgeMediaError", "media-error"}, - {"CartridgeBytesRead", "bytes-read"}, - {"CartridgeBytesWritten", "bytes-written"}, - {"CartridgeRecovededReads", NULL}, - {"CartridgeRecovededWrites", NULL}, - {"CartridgeUnrecovededReads", NULL}, - {"CartridgeUnrecovededWrites", NULL}, - {"LibraryName", O_MMSLIB}, - {"CartridgeMountPoint", "mountpt"}, - {"CartridgePath", "path"}, - {"Administrator", NULL}, - {"AttendanceMode", O_ATTENDED}, - {"SystemLogLevel", O_LOGLEVEL}, - {"SystemAcceptLevel", NULL}, - {"SystemLogFile", O_LOGFILE}, - {"SystemMessageLimit", NULL}, - {"SystemMessageCount", NULL}, - {"SystemRequestLimit", NULL}, - {"SystemRequestCount", "num-oper-requests"}, - {"SystemSyncLimit", NULL}, - {"SystemDCALimit", NULL}, - {"SystemDCACount", NULL}, - {"ClearDriveAtLMConfig", NULL}, - {"AskClearDriveAtLMConfig", NULL}, - {"PreemptReservation", NULL}, - {"MessageLevel", O_MSGLEVEL}, - {"TraceLevel", O_TRACELEVEL}, - {"TraceFileSize", O_TRACESZ}, - {"SocketFdLimit", O_NUMSOCKET}, - {"SystemLogFileSize", "log-size"}, - {"SystemName", O_NAME}, - {"SystemInstance", NULL}, - {"UnloadDelayTime", O_UNLOADTM}, - {"DefaultBlocksize", NULL}, - {"SystemDiskMountTimeout", O_DKTIMEOUT}, - {"WatcherStartsLimit", O_NUMRESTART}, - {"DriveRecordRetention", NULL}, - {"DriveName", O_NAME}, - {"DriveName", "drive"}, - {"DriveGroupName", NULL}, - {"DrivePriority", NULL}, - {"DriveShapeName", NULL}, - {"DriveDisabled", "disabled"}, - {"DriveBroken", "broken"}, - {"DriveStateSoft", "DM state"}, - {"DriveStateHard", "state"}, - {"DriveTimeCreated", "create-time"}, - {"DriveTimeMountedLast", "last-mount"}, - {"DriveTimeMountedTotal", "total-mount-time"}, - {"DriveNumberMounts", "num-mounts"}, - {"DriveNumberMountsSinceCleaning", "mounts-since-clean"}, - {"DriveLibraryAccessible", NULL}, - {"DriveLibraryOccupied", NULL}, - {"DriveNeedsCleaning", "needs-cleaning"}, - {"MaxMounts", NULL}, - {"ExclusiveAppName", NULL}, - {"ReserveDrive", O_RESERVE}, - {"DefaultBlocksize", "blocksize"}, - {"DriveSerialNum", O_SERIALNO}, - {"DriveOnline", O_ONLINE}, - {"DriveType", O_TYPE}, - {"LibraryDisabled", "disabled"}, - {"LibraryBroken", "broken"}, - {"LibraryStateHard", "state"}, - {"LibraryStateSoft", "LM state"}, - {"LibraryOnline", O_ONLINE}, - {"LibraryType", O_TYPE}, - {"LibraryIP", O_ACSHOST}, - {"LibraryACS", O_ACSNUM}, - {"LibraryLSM", O_LSMNUM}, - {"LibrarySerialNumber", O_SERIALNO}, - {"RequestID", "request-id"}, - {"RequestingTaskID", NULL}, - {"RequestingClient", "requestor"}, - {"RequestingInstance", NULL}, - {"RequestingClientType", "requestor-type"}, - {"RequestPriority", "priority"}, - {"RequestState", O_OBJSTATE}, - {"RequestText", "description"}, - {"AcceptingSessionID", NULL}, - {"ResponseText", O_RESPTXT}, - {"RequestTimeCreated", "create-time"}, - {"RequestTimeAccepted", "accept-time"}, - {"RequestTimeResponded", "response-time"}, - {"ApplicationName", O_NAME}, - {"ApplicationName", "application"}, - {"SignatureAlgorithm", NULL}, - {"AllowRemoteMount", NULL}, - {"BypassVerify", NULL}, - {"ReadWriteMode", NULL}, - {"ValidateFileName", O_VALIDATEFN}, - {"ValidateVolumeID", O_VALIDATEVOL}, - {"ValidateExpirationDate", O_VALIDATEEXP}, - {"SwitchLabel", NULL}, - {"WriteOverExistingData", O_OVERWRITEEXT}, - {"Retention", O_RETENTION}, - {NULL, NULL} -}; - -int -mms_client_handle_rsp(void *rsp) -{ - int rc; - int class; - int code; - char *msg; - int rsptype; - - if (!rsp) { - return (MMS_MGMT_NOARG); - } - - mms_rsp_ele_t *lrsp = (mms_rsp_ele_t *)rsp; - rsptype = mms_rsp_type(rsp); - - switch (rsptype) { - case MMS_API_RSP_UNACC: - mms_trace(MMS_ERR, "Command was not accepted"); - rc = MMS_MGMT_REQ_NOT_ACCEPTED; - break; - - case MMS_API_RSP_ACC: - mms_trace(MMS_DEBUG, "Command was accepted"); - rc = 0; - break; - - case MMS_API_RSP_FINAL: - mms_trace(MMS_INFO, "Command was successful"); - rc = 0; - break; - - case MMS_API_RSP_FINAL_ERR: - mms_trace(MMS_ERR, - "Command received an error response"); - - rc = mms_handle_err_rsp(rsp, &class, &code, &msg); - if (rc != MMS_API_OK) { - mms_trace(MMS_ERR, "Error response failed"); - break; - } - - mms_trace(MMS_ERR, "Error class[%d, %s], code[%d, %s]", - class, mms_sym_code_to_str(class), - code, mms_sym_code_to_str(code)); - - if (msg) { - mms_trace(MMS_ERR, "Error message[%s]", msg); - } - - /* TODO: Translate code/class to something rational */ - if (code == MMS_EDATABASE) { - if ((strstr(lrsp->mms_rsp_str, - "duplicate key"))|| - (strstr(lrsp->mms_rsp_str, - "already exists"))) { - class = MMS_EXIST; - } else if (strstr(lrsp->mms_rsp_str, - "still referenced")) { - code = EBUSY; - } - } - - if (class == MMS_EXIST) { - rc = EEXIST; - } else { - rc = code; - } - - break; - - case MMS_API_RSP_FINAL_CANC: - mms_trace(MMS_INFO, - "Command received a cancelled response"); - rc = MMS_MGMT_RSP_CANCELLED; - break; - - default: - mms_trace(MMS_ERR, "Unknown response type: %d", - rsptype); - rc = MMS_MGMT_RSP_UNKNOWN; - break; - } - - if (lrsp->mms_rsp_str) { - mms_trace(MMS_DEBUG, "Response: %s", lrsp->mms_rsp_str); - } - - return (rc); -} - - -/* - * Parse the response to a report LIBRARY request and fill the mms_acslib_t - * structure - * - * "LibraryName" "library1" "LibraryDisabled" "false" "LibraryBroken" "false" - * "LMName" "lm1" "LibraryStateHard" "unknown" "LibraryStateSoft" "ready" - * "LibraryOnline" "true" "LibraryType" "L180" "LibraryConnection" "network" - * "LibraryIP" "nws-nsh-54-94.east" "LibraryPath" "" "LibraryACS" "0" - */ -void -mmp_parse_lib_attr(mms_par_node_t *node, mms_acslib_t *lib) -{ - mms_par_node_t *name; - mms_par_node_t *val; - mms_par_node_t *lasts = NULL; - - if (!lib) { - return; - } - - /* LibraryName */ - name = mms_pn_lookup(node, "LibraryName", MMS_PN_STRING, &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - (void) strlcpy(lib->name, mms_pn_token(val), - MAXNAMELEN); - } - } - - /* LibraryType */ - name = mms_pn_lookup(node, "LibraryType", MMS_PN_STRING, &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - (void) strlcpy(lib->type, mms_pn_token(val), 32); - } - } - - /* LibraryIP */ - name = mms_pn_lookup(node, "LibraryIP", MMS_PN_STRING, &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - (void) strlcpy(lib->acshost, - mms_pn_token(val), MAXHOSTNAMELEN); - } - } - - /* LibraryACS */ - name = mms_pn_lookup(node, "LibraryACS", MMS_PN_STRING, &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - lib->acs = atoi(mms_pn_token(val)); - } - } - - name = mms_pn_lookup(node, "LibraryLSM", MMS_PN_STRING, &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - lib->lsm = atoi(mms_pn_token(val)); - } - } - - /* LibrarySerialNumber */ - name = mms_pn_lookup(node, "LibrarySerialNumber", MMS_PN_STRING, - &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - (void) strlcpy(lib->serialnum, mms_pn_token(val), - sizeof (lib->serialnum)); - } - } -} - -/* - * parse the LIBRARY LM response which has a sequence of library objects and - * the LM(s) for each library - */ -int -mmp_parse_library_rsp(void *rsp, mms_list_t *acslib_list) -{ - - mms_acslib_t *lib; - mms_lm_t *lm; - mms_par_node_t *root; - mms_par_node_t *last = NULL, *alast = NULL; - mms_par_node_t *text, *arg; - boolean_t first = B_TRUE; - - if (!rsp || !acslib_list) { - return (-1); - } - - mms_trace(MMS_DEBUG, "Response: %s", - ((mms_rsp_ele_t *)rsp)->mms_rsp_str); - - mms_list_create(acslib_list, sizeof (mms_acslib_t), - offsetof(mms_acslib_t, lib_link)); - - root = mms_get_tree(rsp); - if (root == NULL) { - mms_trace(MMS_ERR, "parse library response failed"); - return (-1); - } - - for (text = mms_pn_lookup(root, "text", MMS_PN_CLAUSE, &last); - text != NULL; - text = mms_pn_lookup(root, "text", MMS_PN_CLAUSE, &last)) { - - - /* - * Multiple attrlist clauses in this text clause: - * First attrlist describes the library - * Subsequent attrlist describes the LM(s) for the drive - */ - - lib = (mms_acslib_t *)malloc(sizeof (mms_acslib_t)); - (void) memset(lib, 0, sizeof (mms_acslib_t)); - - mms_list_create(&lib->lm_list, sizeof (mms_lm_t), - offsetof(mms_lm_t, lm_link)); - - for (arg = mms_pn_lookup_arg(text, NULL, NULL, &alast); - arg != NULL; - arg = mms_pn_lookup_arg(text, NULL, NULL, &alast)) { - - if ((arg->pn_type & MMS_PN_CLAUSE) && - (strcmp(arg->pn_string, "attrlist") == 0)) { - - if (first) { - mmp_parse_lib_attr(arg, lib); - first = B_FALSE; - } else { - lm = (mms_lm_t *) - malloc(sizeof (mms_lm_t)); - (void) memset(lm, 0, sizeof (mms_lm_t)); - - mmp_parse_lm_attr(arg, lm); - - mms_list_insert_tail(&lib->lm_list, lm); - } - } - } - mms_list_insert_tail(acslib_list, lib); - first = B_TRUE; - alast = NULL; - } - - return (0); -} - - -/* - * parse the MMP response to a LM report and fill the values in mms_lm_t - * - * The response are position dependent. - * "LibraryName" "virt-library" "LMName" "virt-lm" "LMHost" "10.1.170.163" - * "LMTargetLibrary" "" "LMTargetPath" "" "LMTargetHost" "muddy-mn" - * "LMPassword" "" "LMMessageLevel" "error" "LMStateHard" "ready" - * "LMStateSoft" "ready" "LMDisabled" "false" "TraceLevel" "debug" - * "TraceFileSize" "10M" - */ -void -mmp_parse_lm_attr(mms_par_node_t *node, mms_lm_t *lm) -{ - mms_par_node_t *name; - mms_par_node_t *pval; - mms_par_node_t *lasts = NULL; - - if (!lm || !node) { - return; - } - - /* LMName */ - name = mms_pn_lookup(node, "LMName", MMS_PN_STRING, &lasts); - if (name != NULL) { - pval = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (pval != NULL) { - (void) strlcpy(lm->name, mms_pn_token(pval), - MAXNAMELEN); - } - } - - /* LMTargetHost */ - name = mms_pn_lookup(node, "LMTargetHost", MMS_PN_STRING, &lasts); - if (name != NULL) { - pval = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (pval != NULL) { - (void) strlcpy(lm->hostname, - mms_pn_token(pval), MAXHOSTNAMELEN); - } - } - - /* Flags - LMStateHard, LMStateSoft, LMDisabled */ -} - -int -mmp_parse_lm_rsp(void *rsp, mms_list_t *lm_list) -{ - - mms_lm_t *lm; - mms_par_node_t *root; - mms_par_node_t *last = NULL; - mms_par_node_t *text; - - mms_list_create(lm_list, sizeof (mms_lm_t), - offsetof(mms_lm_t, lm_link)); - - root = mms_get_tree(rsp); - if (root == NULL) { - mms_trace(MMS_ERR, "parse LM response failed"); - return (-1); - } - - for (text = mms_pn_lookup(root, "text", MMS_PN_CLAUSE, &last); - text != NULL; - text = mms_pn_lookup(root, "text", MMS_PN_CLAUSE, &last)) { - - lm = (mms_lm_t *)malloc(sizeof (mms_lm_t)); - (void) memset(lm, 0, sizeof (mms_lm_t)); - - mmp_parse_lm_attr(text, lm); - - mms_list_insert_tail(lm_list, lm); - } - return (0); -} - - -/* - * parse the MMP response to a DM report and fill the values in mms_dm_t - * - * "DMName" "virt-dm1" "DriveName" "virt-drive0" "DMHost" "10.1.170.163" - * "DMTargetLibrary" "" "DMTargetPath" "/devices/pseudo/dda@0:bn" - * "DMTargetHost" "muddy-mn" "DMPassword" "" "DMMessageLevel" "error" - * "DMStateHard" "ready" "DMStateSoft" "ready" "DMDisabled" "false" - * "TraceLevel" "debug" "TraceFileSize" "10M" - */ -void -mmp_parse_dm_attr(mms_par_node_t *node, mms_dm_t *dm) -{ - mms_par_node_t *name; - mms_par_node_t *pval; - mms_par_node_t *lasts = NULL; - - if (!node || !dm) { - return; - } - - /* DMName */ - name = mms_pn_lookup(node, "DMName", MMS_PN_STRING, &lasts); - if (name != NULL) { - pval = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (pval != NULL) { - (void) strlcpy(dm->name, mms_pn_token(pval), - MAXNAMELEN); - } - } - - /* DMTargetHost */ - name = mms_pn_lookup(node, "DMTargetHost", MMS_PN_STRING, &lasts); - if (name != NULL) { - pval = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (pval != NULL) { - (void) strlcpy(dm->hostname, - mms_pn_token(pval), MAXHOSTNAMELEN); - } - } - - /* Flags - DMStateHard, DMStateSoft, DMDisabled */ -} - -int -mmp_parse_dm_rsp(void *rsp, mms_list_t *dm_list) -{ - - mms_dm_t *dm; - mms_par_node_t *root; - mms_par_node_t *lasts = NULL; - mms_par_node_t *node; - - mms_list_create(dm_list, sizeof (mms_dm_t), - offsetof(mms_dm_t, dm_link)); - - root = mms_get_tree(rsp); - if (root == NULL) { - mms_trace(MMS_ERR, "parse drive response failed"); - return (-1); - } - - while (node = mms_pn_lookup(root, "text", MMS_PN_CLAUSE, &lasts)) { - if (node == NULL) { - break; - } - - dm = (mms_dm_t *)malloc(sizeof (mms_dm_t)); - (void) memset(dm, 0, sizeof (mms_dm_t)); - - mmp_parse_dm_attr(node, dm); - - mms_list_insert_tail(dm_list, dm); - } - - return (0); -} - - -/* - * Parse drive attributes from the response - * - * "DriveName" "drive1" "DriveGroupName" "LTO" "DrivePriority" "1000" - * "DMName" "" "DriveShapeName" "LTO3" "DriveDisabled" "false" - * "DriveBroken" "false" "DriveStateSoft" "ready" "DriveStateHard" "unloaded" - * "DriveTimeCreated" "2007 09 13 12 47 58 328" "DriveTimeMountedLast" - * "2007 09 20 15 33 54 037" "DriveTimeMountedTotal" "0000 00 00 00 00 00 000" - * "DriveNumberMounts" "3" "DriveNumberMountsSinceCleaning" "3" "LibraryName" - * "library1" "BayName" "panel 0" "DriveLibraryAccessible" "true" - * "DriveLibraryOccupied" "false" "CartridgePCL" "" "DriveNeedsCleaning" "false" - * "MaxMounts" "0" "ExclusiveAppName" "none" "ReserveDrive" "yes" - * "DefaultBlocksize" "262144" "DriveGeometry" "0,0,0,1" "DriveSerialNum" - * "1210013554" "DriveOnline" "true" - * - */ -void -mmp_parse_drive_attr(mms_par_node_t *node, mms_drive_t *d) -{ - mms_par_node_t *name; - mms_par_node_t *val; - mms_par_node_t *lasts = NULL; - - if (!node || !d) { - return; - } - - /* DriveName */ - name = mms_pn_lookup(node, "DriveName", MMS_PN_STRING, &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - (void) strlcpy(d->name, mms_pn_token(val), MAXNAMELEN); - } - } - - /* DriveGroupName (future) */ - - /* DrivePriority */ - name = mms_pn_lookup(node, "DrivePriority", MMS_PN_STRING, &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - d->priority = atoi(mms_pn_token(val)); - } - } - - /* Flags - DriveDisabled */ - name = mms_pn_lookup(node, "DriveDisabled", MMS_PN_STRING, &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - if (strcmp("true", mms_pn_token(val)) == 0) { - d->flags |= MMS_ST_DRIVE_DISABLED; - } - } - } - - /* Flags - DriveBroken */ - name = mms_pn_lookup(node, "DriveBroken", MMS_PN_STRING, &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - if (strcmp("true", mms_pn_token(val)) == 0) { - d->flags |= MMS_ST_DRIVE_BROKEN; - } - } - } - - /* Flags - DriveStateSoft */ - name = mms_pn_lookup(node, "DriveStateSoft", MMS_PN_STRING, &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - if (strcmp("ready", mms_pn_token(val)) == 0) { - d->flags |= MMS_ST_DRIVE_READY; - } else if (strcmp("in use", mms_pn_token(val)) == 0) { - d->flags |= MMS_ST_DRIVE_INUSE; - } - } - } - - /* Flags - DriveStateHard */ - name = mms_pn_lookup(node, "DriveStateHard", MMS_PN_STRING, &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - if (strcmp("loaded", mms_pn_token(val)) == 0) { - d->flags |= MMS_ST_DRIVE_LOADED; - } else if (strcmp("loading", mms_pn_token(val)) - == 0) { - d->flags |= MMS_ST_DRIVE_LOADING; - } else if (strcmp("unloading", mms_pn_token(val)) - == 0) { - d->flags |= MMS_ST_DRIVE_UNLOADING; - } else if (strcmp("unloaded", mms_pn_token(val)) - == 0) { - d->flags |= MMS_ST_DRIVE_UNLOADED; - } - } - } - - /* LibraryName */ - name = mms_pn_lookup(node, "LibraryName", MMS_PN_STRING, &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - (void) strlcpy(d->libname, mms_pn_token(val), - MAXNAMELEN); - } - } - - /* More Flags - DriveLibraryAccessible, DriveLibraryOccupied */ - name = mms_pn_lookup(node, "DriveLibraryAccessible", - MMS_PN_STRING, &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - if (strcmp("false", mms_pn_token(val)) == 0) { - d->flags |= MMS_ST_DRIVE_INACCESSIBLE; - } - } - } - - - name = mms_pn_lookup(node, "DriveLibraryOccupied", - MMS_PN_STRING, &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - if (strcmp("true", mms_pn_token(val)) == 0) { - d->flags |= MMS_ST_DRIVE_OCCUPIED; - } - } - } - - - /* CartridgePCL - Media in Drive */ - - /* More Flags - DriveNeedsCleaning */ - name = mms_pn_lookup(node, "DriveNeedsCleaning", - MMS_PN_STRING, &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - if (strcmp("true", mms_pn_token(val)) == 0) { - d->flags |= MMS_ST_DRIVE_RCLEANING; - } else if (strcmp("advisory", mms_pn_token(val)) - == 0) { - d->flags |= MMS_ST_DRIVE_ACLEANING; - } else if (strcmp("mandatory", mms_pn_token(val)) - == 0) { - d->flags |= MMS_ST_DRIVE_MCLEANING; - } - } - } - - - /* DefaultBlocksize */ - name = mms_pn_lookup(node, "DefaultBlocksize", - MMS_PN_STRING, &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - d->blocksize = atoi(mms_pn_token(val)); - } - } - - /* DriveSerialNum */ - name = mms_pn_lookup(node, "DriveSerialNum", MMS_PN_STRING, &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - (void) strlcpy(d->serialnum, - mms_pn_token(val), MAXSERIALNUMLEN); - } - } - - /* More Flags - DriveOnline (not in MM spec ?) */ - name = mms_pn_lookup(node, "DriveOnline", MMS_PN_STRING, &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - if (strcmp("false", mms_pn_token(val)) == 0) { - d->flags |= MMS_ST_DRIVE_OFFLINE; - } - } - } - - /* DriveType */ - lasts = NULL; - name = mms_pn_lookup(node, "DriveType", MMS_PN_STRING, &lasts); - if (name != NULL) { - val = mms_pn_lookup(name, "", MMS_PN_STRING, &lasts); - if (val != NULL) { - (void) strlcpy(d->type, mms_pn_token(val), 32); - } - } - -} - - -/* - * Parse the MMP response consisting of a sequence of drive objects and dm - * objects for that drive. Convert the response to a list of mms_drive_t - * This response is in request to a report DRIVE DM - * - * The response is made up a series of name value pairs, these name value - * entries are positional and the parsing function saves a pointer to the - * following byte, from which the next search for an attribute begins. So the - * attributes have to be parsed in a predetermined order. The response is - * given below for attribute order purposes. - * - */ -int -mmp_parse_drive_rsp(void *rsp, mms_list_t *drive_list) -{ - - mms_drive_t *drive; - mms_dm_t *dm; - mms_par_node_t *root; - mms_par_node_t *last = NULL, *alast = NULL; - mms_par_node_t *text, *arg; - boolean_t first = B_TRUE; - - if (!rsp || !drive_list) { - return (-1); - } - - mms_trace(MMS_ERR, - "Response: %s\n", ((mms_rsp_ele_t *)rsp)->mms_rsp_str); - - mms_list_create(drive_list, sizeof (mms_drive_t), - offsetof(mms_drive_t, drive_link)); - - root = mms_get_tree(rsp); - if (root == NULL) { - mms_trace(MMS_ERR, "parse drive response failed"); - return (-1); - } - - for (text = mms_pn_lookup(root, "text", MMS_PN_CLAUSE, &last); - text != NULL; - text = mms_pn_lookup(root, "text", MMS_PN_CLAUSE, &last)) { - - - /* - * Multiple attrlist clauses in this text clause: - * First attrlist describes the drive - * Subsequent attrlist describes the DM(s) for the drive - */ - - drive = (mms_drive_t *)malloc(sizeof (mms_drive_t)); - (void) memset(drive, 0, sizeof (mms_drive_t)); - mms_list_create(&drive->dm_list, sizeof (mms_dm_t), - offsetof(mms_dm_t, dm_link)); - - for (arg = mms_pn_lookup_arg(text, NULL, NULL, &alast); - arg != NULL; - arg = mms_pn_lookup_arg(text, NULL, NULL, &alast)) { - - if ((arg->pn_type & MMS_PN_CLAUSE) && - (strcmp(arg->pn_string, "attrlist") == 0)) { - - if (first) { - mmp_parse_drive_attr(arg, drive); - first = B_FALSE; - } else { - - dm = (mms_dm_t *) - malloc(sizeof (mms_dm_t)); - (void) memset(dm, 0, sizeof (mms_dm_t)); - - mmp_parse_dm_attr(arg, dm); - - mms_list_insert_tail(&drive->dm_list, - dm); - } - } - } - mms_list_insert_tail(drive_list, drive); - first = B_TRUE; - alast = NULL; - } - - return (0); -} - - -/* - * The function mmp_build() builds the command syntax using the MMP language. - * All requests to the MM, including access to media, device management - * functions, routine operational functions and MMS administration are done - * using the MMP protocol. - * - * The MMP is made up of command type, object type and its attributes. MMP - * supports a rich range of commands which fall into several different - * categories such as attribute, cancel, create, deallocate, delete, goodbye, - * locale, privilege, rename, show, accept, begin-end, cpattribute, cpscan, - * cpshow, cpreset, eject, inject, mount, move, release, respond, shutdown - * and unmount. The mmp_build() function only supports the attribute, create, - * delete and show commands at this time. - * - * The MMS defines more than 40 types of objects that make up a media - * environment. This funtion however builds the MMP for the library, lm - * drive, dm, drivegroup, drivegroupapplication, slottype, cartridge, - * cartridgegroup, and cartridgegroupapplication only. - */ - -/* - * Processes a single clause, that may have multiple attr lists - */ -int -mmp_get_nvattrs(char *key, boolean_t useropt, void *response, nvlist_t **nvl) -{ - int st = 0; - mms_par_node_t *lasts = NULL; - mms_par_node_t *root; - mms_par_node_t *alast; - mms_par_node_t *text; - mms_par_node_t *attrs; - nvlist_t *lst; - char *val; - int lcnt = 0; - char buf[1024]; - - if (!key|| !response || !nvl) { - return (MMS_MGMT_NOARG); - } - - mms_trace(MMS_DEBUG, "Response: %s", - ((mms_rsp_ele_t *)response)->mms_rsp_str); - - root = mms_get_tree(response); - if (root == NULL) { - mms_trace(MMS_ERR, "parse response failed"); - return (EINVAL); - } - - if (*nvl == NULL) { - (void) nvlist_alloc(nvl, NV_UNIQUE_NAME, 0); - } - lasts = NULL; - - while ((text = mms_pn_lookup(root, "text", MMS_PN_CLAUSE, &lasts)) - != NULL) { - if (*nvl == NULL) { - (void) nvlist_alloc(nvl, NV_UNIQUE_NAME, 0); - } - - alast = NULL; - - attrs = mms_pn_lookup_arg(text, NULL, NULL, &alast); - if (!attrs) { - break; - } - - if (strcmp(attrs->pn_string, "attrlist") != 0) { - /* - * Not attrlist - construct nvlist with args. - */ - st = attrs2nvlist(text, useropt, &lst); - } else { - while (attrs != NULL) { - st = attrs2nvlist(attrs, useropt, &lst); - if (st != 0) { - break; - } - attrs = mms_pn_lookup_arg(text, NULL, NULL, - &alast); - } - } - - if (st == 0) { - st = nvlist_lookup_string(lst, key, &val); - if (st != 0) { - (void) snprintf(buf, sizeof (buf), - "unknown_%d", ++lcnt); - val = buf; - } - st = nvlist_add_nvlist(*nvl, val, lst); - } - if (st != 0) { - break; - } - - } - - return (st); -} - -/* - * Gether attribute values into an array - */ -int -mmp_get_nvattrs_array(char *key, boolean_t useropt, - void *response, nvlist_t *nvl) -{ - int st = 0; - mms_par_node_t *lasts = NULL; - mms_par_node_t *lasta = NULL; - mms_par_node_t *root; - mms_par_node_t *text; - mms_par_node_t *attrs; - mms_par_node_t *val; - uint_t count = 0; - char **arr; - int i; - char *mmpkey = key; - - if (!key|| !response || !nvl) { - return (MMS_MGMT_NOARG); - } - - mms_trace(MMS_DEBUG, "Response: %s", - ((mms_rsp_ele_t *)response)->mms_rsp_str); - - root = mms_get_tree(response); - if (root == NULL) { - mms_trace(MMS_ERR, "parse response failed"); - return (EINVAL); - } - - lasts = NULL; - if (useropt) { - mmpkey = mgmt_cvt_user_to_mmp(key); - if (mmpkey == NULL) { - return (EINVAL); - } - } - - /* Count how many we have */ - while ((text = mms_pn_lookup_arg(root, "text", MMS_PN_CLAUSE, &lasts)) - != NULL) { - attrs = mms_pn_lookup(text, mmpkey, MMS_PN_STRING, NULL); - if (attrs != NULL) { - count++; - } - } - - arr = (char **)calloc(1, sizeof (uint_t *) * count); - if (arr == NULL) { - return (ENOMEM); - } - - lasts = NULL; - for (i = 0; i < count; i++) { - text = mms_pn_lookup_arg(root, "text", MMS_PN_CLAUSE, &lasts); - attrs = mms_pn_lookup(text, mmpkey, MMS_PN_STRING, &lasta); - val = mms_pn_lookup(attrs, NULL, MMS_PN_STRING, &lasta); - arr[i] = strdup(mms_pn_token(val)); - } - - st = nvlist_add_string_array(nvl, key, arr, count); - - return (st); -} - -/* - * If useropt = B_TRUE, convert the MMP keys to public keys - */ -static int -attrs2nvlist(mms_par_node_t *attrs, boolean_t useropt, nvlist_t **nvl) -{ - int st; - nvlist_t *lst = NULL; - mms_par_node_t *name; - mms_par_node_t *val; - mms_par_node_t *last = NULL; - char *namep; - char *valp; - - if (!attrs || !nvl) { - return (MMS_MGMT_NOARG); - } - - *nvl = NULL; - st = nvlist_alloc(&lst, NV_UNIQUE_NAME, 0); - if (st != 0) { - return (st); - } - - for (;;) { - name = mms_pn_lookup(attrs, "", MMS_PN_STRING, &last); - if (!name) { - break; - } - - namep = mms_pn_token(name); - val = mms_pn_lookup(name, "", MMS_PN_STRING, &last); - if (!val) { - continue; - } - - valp = mms_pn_token(val); - if ((valp) && (*valp != '\0')) { - if (useropt) { - namep = mgmt_cvt_mmp_to_user(namep); - } - if (namep) { - (void) nvlist_add_string(lst, namep, valp); - } - } - } - - *nvl = lst; - - return (st); -} - -static char * -mgmt_cvt_mmp_to_user(char *in) -{ - int i; - char *out = NULL; - - if (!in) { - return (NULL); - } - - for (i = 0; optmap[i].mmp_opt != NULL; i++) { - if (strcmp(optmap[i].mmp_opt, in) == 0) { - out = optmap[i].public_opt; - break; - } - } - - return (out); -} - -static char * -mgmt_cvt_user_to_mmp(char *in) -{ - int size = sizeof (optmap) / sizeof (map_opt_names); - int i; - char *out = NULL; - - if (!in) { - return (NULL); - } - - for (i = 0; i < size; i++) { - if (optmap[i].public_opt != NULL) { - if (strcmp(optmap[i].public_opt, in) == 0) { - out = optmap[i].mmp_opt; - break; - } - } - } - - return (out); -} - -int -mms_mgmt_mmp_count(void *response, uint32_t *count) -{ - mms_par_node_t *root; - mms_par_node_t *clause; - mms_par_node_t *num; - - if (!response || !count) { - return (MMS_MGMT_NOARG); - } - - *count = 0; - - mms_trace(MMS_DEBUG, "Response: %s", - ((mms_rsp_ele_t *)response)->mms_rsp_str); - - root = mms_get_tree(response); - if (root == NULL) { - mms_trace(MMS_ERR, "parse response failed"); - return (EINVAL); - } - - MMS_PN_LOOKUP(clause, root, "text", MMS_PN_CLAUSE, NULL); - MMS_PN_LOOKUP(num, clause, NULL, MMS_PN_STRING, NULL); - - *count = atoi(mms_pn_token(num)); - - return (0); - -not_found: - /* this label required for the MMS_PN_LOOKUP macro */ - - return (1); -} diff --git a/usr/src/lib/mms/mgmt/common/mgmt_mmsdb.c b/usr/src/lib/mms/mgmt/common/mgmt_mmsdb.c deleted file mode 100644 index f79716ea7d..0000000000 --- a/usr/src/lib/mms/mgmt/common/mgmt_mmsdb.c +++ /dev/null @@ -1,1571 +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. - */ - - -#include <strings.h> -#include <errno.h> -#include <unistd.h> -#include <sys/stat.h> -#include <stdlib.h> -#include <fcntl.h> -#include <sys/types.h> -#include <ctype.h> -#include <libnvpair.h> - -#include "mms_mgmt.h" -#include "mgmt_util.h" -#include "mms_cfg.h" -#include "net_cfg_service.h" - -static char *_SrcFile = __FILE__; -#define HERE _SrcFile, __LINE__ -#define MMS_MGMT_PGA ".pga" - -typedef struct { - char port[10]; - char user[256]; - char bindir[MAXPATHLEN]; - char path[MAXPATHLEN]; - char logdir[MAXPATHLEN]; - char dbname[MAXPATHLEN]; - char dbhost[MAXHOSTNAMELEN]; - uid_t dbuid; - gid_t dbgid; -} mmsdb_opts_t; - -/* If this path changes, make sure similar changes are made to mmsexplorer */ -static char db_cli_env[1024]; - -static int get_db_user(char *buf, int buflen, uid_t *uid, gid_t *gid); -static int configure_pgconf(char *port, char *logdir); -static int get_dbver_from_optfile(char *path, int *version); -static int mk_cmds_from_optfile(mmsdb_opts_t *opts, char *path, int vers, - char cmdtype, int dopd, char **cmdfile); -static int mgmt_db_sql_exec(char *cmdfile, mmsdb_opts_t *opts); -static int set_mm_system_vars_db(nvlist_t *opts, char *cmdfile); -static int mgmt_get_db_opts(mmsdb_opts_t *opts); -static int create_db_dirs(char *dbpath, uid_t uid, gid_t gid, nvlist_t *errs); -static int update_pghba(boolean_t ismd5, mmsdb_opts_t *dbopts, nvlist_t *errs); - - -/* - * Functions to manage the MMS Database - */ - -int -mgmt_set_db_opts(nvlist_t *opts, nvlist_t *errlist) -{ - int st = 0; - mmsdb_opts_t oldopts; - int doconf = 0; - uid_t uid = 0; - gid_t gid = 0; - char *val; - char *port = NULL; - char *logdir = NULL; - - if (!mgmt_chk_auth("solaris.mms.modify")) { - return (EACCES); - } - - /* - * check to see if any options have been set for the DB yet. Only - * a few are user-configurable. Changing the DB user is handled - * by the admin with SMF and chown -R. (i.e., outside of our CLI, - * at least for now) - */ - (void) memset(&oldopts, 0, sizeof (mmsdb_opts_t)); - - st = mgmt_get_db_opts(&oldopts); - if (st != 0) { - return (st); - } - - uid = oldopts.dbuid; - gid = oldopts.dbgid; - - /* TODO - should we allow change after set? Need to copy -R if so */ - st = nvlist_lookup_string(opts, O_DBDIR, &val); - if (st == 0) { - st = create_db_dirs(val, uid, gid, errlist); - if (st != 0) { - return (st); - } - } - - st = nvlist_lookup_string(opts, O_DBPORT, &port); - if (st == 0) { - /* update the conf file */ - doconf = 1; - } - - st = nvlist_lookup_string(opts, O_DBLOG, &logdir); - if (st == 0) { - /* update the conf file */ - doconf = 1; - /* create dblogdir if it doesn't exist */ - st = create_dir(logdir, 0711, NULL, uid, NULL, gid); - } - - if ((st == 0) && (doconf)) { - st = configure_pgconf(port, logdir); - } - - return (st); -} - -static int -create_db_dirs(char *dbpath, uid_t uid, gid_t gid, nvlist_t *errs) -{ - int st; - struct stat64 statbuf; - char *dbsubdirs[] = {"dump", "log", NULL}; - int i; - char buf[2048]; - - if (!dbpath) { - return (MMS_MGMT_NOARG); - } - - st = stat64(dbpath, &statbuf); - if ((st != 0) && (errno != ENOENT)) { - st = errno; - MGMT_ADD_ERR(errs, dbpath, st); - return (st); - } - - st = create_dir(dbpath, 0711, NULL, uid, NULL, gid); - if (st != 0) { - st = errno; - MGMT_ADD_ERR(errs, dbpath, st); - return (st); - } - - for (i = 0; dbsubdirs[i] != NULL; i++) { - (void) snprintf(buf, sizeof (buf), "%s/../%s", dbpath, - dbsubdirs[i]); - st = create_dir(buf, 0711, NULL, uid, NULL, gid); - if (st != 0) { - st = errno; - MGMT_ADD_ERR(errs, buf, st); - break; - } - } - - return (st); -} - -int -mgmt_db_init(void) -{ - int st; - pid_t pid; - char buf[2048]; - char dbbuf[2048]; - mmsdb_opts_t opts; - char *cmd[4]; - - if (!mgmt_chk_auth("solaris.mms.create")) { - return (EACCES); - } - - st = mgmt_get_db_opts(&opts); - if (st != 0) { - mms_trace(MMS_DEBUG, - "mgmt_get_db_opts(&opts) error"); - return (st); - } - - /* see if we've been initialized already, bail if so */ - (void) snprintf(buf, sizeof (buf), "%s/postgresql.conf", opts.path); - st = access(buf, F_OK); - if (st == 0) { - return (0); - } - - (void) snprintf(dbbuf, sizeof (dbbuf), "%s/initdb", opts.bindir); - - cmd[0] = dbbuf; - cmd[1] = "-D"; - cmd[2] = opts.path; - cmd[3] = NULL; - - pid = exec_mgmt_cmd(NULL, NULL, opts.dbuid, opts.dbgid, - B_FALSE, cmd); - mms_trace(MMS_DEBUG, "exec_mgmt_cmd: %s %s %s", cmd[0], cmd[1], cmd[2]); - - st = check_exit(pid, NULL); - if (st != 0) - mms_trace(MMS_DEBUG, - "exec_mgmt_cmd error"); - - return (st); -} - -static int -mgmt_get_db_opts(mmsdb_opts_t *opts) -{ - int st; - struct passwd pwd; - struct passwd *pwdp; - char buf[2048]; - - if (opts == NULL) { - return (MMS_MGMT_NOARG); - } - - st = mms_cfg_getvar(MMS_CFG_DB_DATA, opts->path); - if (st == 0) { - st = mms_cfg_getvar(MMS_CFG_MM_DB_USER, opts->user); - } - if (st == 0) { - st = mms_cfg_getvar(MMS_CFG_MM_DB_HOST, opts->dbhost); - } - if (st == 0) { - st = mms_cfg_getvar(MMS_CFG_MM_DB_PORT, opts->port); - } - if (st == 0) { - st = mms_cfg_getvar(MMS_CFG_MM_DB_NAME, opts->dbname); - } - if (st == 0) { - st = mms_cfg_getvar(MMS_CFG_DB_BIN, opts->bindir); - } - if (st == 0) { - (void) snprintf(opts->logdir, sizeof (opts->logdir), - "%s/../log", opts->path); - } - - if (st != 0) { - return (st); - } - - (void) getpwnam_r(opts->user, &pwd, buf, sizeof (buf), &pwdp); - if (pwdp == NULL) { - return (MMS_MGMT_DB_USER_NOTFOUND); - } - - opts->dbuid = pwdp->pw_uid; - opts->dbgid = pwdp->pw_gid; - - /* set the envvar for PGPASSFILE */ - (void) snprintf(db_cli_env, sizeof (db_cli_env), - "PGPASSFILE=%s/../%s", opts->path, MMS_MGMT_PGA); - st = putenv(db_cli_env); - - return (st); -} - -static int -get_db_user(char *buf, int buflen, uid_t *uid, gid_t *gid) -{ - int st; - struct passwd pwd; - struct passwd *pwdp; - - if ((buf == NULL) || (uid == NULL)) { - return (MMS_MGMT_NOARG); - } - - st = mms_cfg_getvar(MMS_CFG_MM_DB_USER, buf); - if (st != 0) { - return (st); - } - - (void) getpwnam_r(buf, &pwd, buf, buflen, &pwdp); - if (pwdp == NULL) { - return (MMS_MGMT_DB_USER_NOTFOUND); - } - - *uid = pwdp->pw_uid; - if (gid != NULL) { - *gid = pwdp->pw_gid; - } - - return (0); -} - -int -mgmt_db_create(int initialize, int populate, nvlist_t *optlist) -{ - int st; - pid_t pid; - mmsdb_opts_t opts; - int oldver = -1; - int ver = -1; - char buf[MAXPATHLEN]; - char *pkgfile = MMSETCDIR"/db/mms_db"; - char *cmd[7]; - char dbbuf[2048]; - - mms_trace(MMS_DEBUG, "Creating the MMS Database"); - - if (!mgmt_chk_auth("solaris.mms.modify")) { - mms_trace(MMS_DEBUG, - "mgmt_chk_auth(\"solaris.mms.modify\") error"); - return (EACCES); - } - - st = mgmt_get_db_opts(&opts); - if (st != 0) { - mms_trace(MMS_DEBUG, - "mgmt_get_db_opts(&opts) error"); - return (st); - } - - (void) snprintf(dbbuf, sizeof (dbbuf), "%s/createdb", opts.bindir); - - cmd[0] = dbbuf; - cmd[1] = "-h"; - cmd[2] = opts.dbhost; - cmd[3] = "-p"; - cmd[4] = opts.port; - cmd[5] = opts.dbname; - cmd[6] = NULL; - - if (initialize) { - st = mgmt_db_check(); - if (st == 0) { - mms_trace(MMS_DEBUG, - "EALREADY error"); - /* db is alive, already inited */ - return (EALREADY); - } - - /* check to see if files exist, even if svc is stopped */ - (void) snprintf(buf, sizeof (buf), "%s/base", opts.path); - if (access(buf, F_OK) == 0) { - mms_trace(MMS_DEBUG, - "access(buf, F_OK) error"); - return (EALREADY); - } - - st = mgmt_db_init(); - if (st != 0) - mms_trace(MMS_DEBUG, - "mgmt_db_init() error"); - if (st == 0) { - st = configure_pgconf(opts.port, opts.logdir); - } - - if (st != 0) { - mms_trace(MMS_DEBUG, - "configure_pgconf error"); - return (st); - } - - /* create the dirs we need */ - st = create_db_dirs(opts.path, opts.dbuid, opts.dbgid, NULL); - if (st != 0) { - mms_trace(MMS_DEBUG, - "create_db_dirs error"); - return (st); - } - } - - /* - * some callers may wish to populate the DB themselves, as in - * upgrade or downgrade. - */ - if (populate) { - st = get_dbver_from_optfile(pkgfile, &ver); - if (st != 0) { - mms_trace(MMS_DEBUG, - "get_dbver_from_optfile error"); - return (st); - } - - (void) snprintf(buf, sizeof (buf), "%s/../mmsdb", opts.path); - st = get_dbver_from_optfile(buf, &oldver); - if (st != 0) { - if (st != ENOENT) { - mms_trace(MMS_DEBUG, - "get_dbver_from_optfile error"); - return (st); - } - st = 0; - } - - if (ver > oldver) { - if (oldver != -1) { - /* save the old mod file */ - char newf[MAXPATHLEN]; - - (void) snprintf(newf, sizeof (newf), "%s-%d", - buf, oldver); - (void) rename(buf, newf); - } - st = cp_file(pkgfile, buf); - if (st != 0) { - return (st); - } - (void) chown(buf, opts.dbuid, opts.dbgid); - } - } - - /* make sure the DB is running */ - mms_trace(MMS_DEBUG, "enable db"); - st = mgmt_set_svc_state(DBSVC, ENABLE, NULL); - if (st != 0) { - mms_trace(MMS_DEBUG, - "mgmt_set_svc_state error"); - return (st); - } - - st = mgmt_db_ready(); - if (st != 0) { - mms_trace(MMS_ERR, - "database did not go ready"); - return (st); - } - - pid = exec_mgmt_cmd(NULL, NULL, opts.dbuid, opts.dbgid, - B_FALSE, cmd); - mms_trace(MMS_DEBUG, - "exec_mgmt_cmd: %s %s %s %s %s %s", - cmd[0], cmd[1], cmd[2], cmd[3], cmd[4], cmd[5]); - - st = check_exit(pid, NULL); - if (st != 0) { - mms_trace(MMS_DEBUG, - "exec_mgmt_cmd error: st %d", st); - } - - if ((st == 0) && (populate)) { - /* import all the sql cmds */ - char *cmdfile = NULL; - - st = mk_cmds_from_optfile(&opts, buf, ver, 'u', 1, &cmdfile); - if ((st == 0) && optlist) { - st = set_mm_system_vars_db(optlist, cmdfile); - } - if (st == 0) { - st = mgmt_db_sql_exec(cmdfile, &opts); - } - - if (cmdfile) { - (void) unlink(cmdfile); - free(cmdfile); - } - - if (st == 0) { - char *passp; - - st = nvlist_lookup_string(optlist, O_MMPASS, &passp); - if (st == 0) { - (void) snprintf(buf, sizeof (buf), - "%s_dbadmin", passp); - st = mgmt_set_db_pass(buf, NULL); - } - } - } - - return (st); -} - -int -mgmt_db_drop(void) -{ - int st; - pid_t pid; - mmsdb_opts_t opts; - char *cmd[5]; - char dbbuf[2048]; - - if (!mgmt_chk_auth("solaris.mms.modify")) { - return (EACCES); - } - - st = mgmt_get_db_opts(&opts); - if (st != 0) { - return (st); - } - - (void) snprintf(dbbuf, sizeof (dbbuf), "%s/dropdb", opts.bindir); - - cmd[0] = dbbuf; - cmd[1] = "-p"; - cmd[2] = opts.port; - cmd[3] = opts.dbname; - cmd[4] = NULL; - - pid = exec_mgmt_cmd(NULL, NULL, opts.dbuid, opts.dbgid, - B_FALSE, cmd); - mms_trace(MMS_DEBUG, "exec_mgmt_cmd: %s %s %s %s", - cmd[0], cmd[1], cmd[2], cmd[3]); - - - st = check_exit(pid, NULL); - - if (st != 0) { - /* restart the service to force users to disconnect */ - - mms_trace(MMS_DEBUG, "restart db"); - (void) mgmt_set_svc_state(DBSVC, RESTART, NULL); - - st = mgmt_db_ready(); - if (st != 0) { - mms_trace(MMS_ERR, - "database did not go ready"); - } - - if (st == 0) { - pid = exec_mgmt_cmd(NULL, NULL, opts.dbuid, opts.dbgid, - B_FALSE, cmd); - mms_trace(MMS_DEBUG, "exec_mgmt_cmd: %s %s %s %s", - cmd[0], cmd[1], cmd[2], cmd[3]); - - st = check_exit(pid, NULL); - } - } - - return (st); -} - -int -mgmt_db_ready(void) -{ - int i; - int st; - pid_t pid; - FILE *readf = NULL; - mmsdb_opts_t opts; - char *cmd[7]; - char dbbuf[2048]; - - if (!mgmt_chk_auth("solaris.mms.modify")) { - return (EACCES); - } - - st = mgmt_get_db_opts(&opts); - if (st != 0) { - return (st); - } - - mms_trace(MMS_DEBUG, "check for database ready"); - - (void) snprintf(dbbuf, sizeof (dbbuf), "%s/psql", opts.bindir); - - /* simple test to list available databases to check for db ready */ - cmd[0] = dbbuf; - cmd[1] = "-h"; - cmd[2] = opts.dbhost; - cmd[3] = "-p"; - cmd[4] = opts.port; - cmd[5] = "-l"; - cmd[6] = NULL; - - for (i = 0; i < 30; i++) { - - /* when the simple test is successful the */ - /* database is ready for socket connections */ - - pid = exec_mgmt_cmd(&readf, NULL, opts.dbuid, opts.dbgid, - B_FALSE, cmd); - mms_trace(MMS_DEBUG, "exec_mgmt_cmd: %s %s %s %s %s %s", - cmd[0], cmd[1], cmd[2], cmd[3], cmd[4], cmd[5]); - - st = check_exit(pid, NULL); - if (st == 0) { - break; - } - (void) sleep(1); - } - - (void) fclose(readf); - - return (st); -} - -int -mgmt_db_check(void) -{ - int st; - pid_t pid; - char buf[1024]; - FILE *readf = NULL; - mmsdb_opts_t opts; - char *cmd[9]; - char dbbuf[2048]; - - if (!mgmt_chk_auth("solaris.mms.modify")) { - return (EACCES); - } - - st = mgmt_get_db_opts(&opts); - if (st != 0) { - return (st); - } - - /* test to see if the mms database already exists */ - - (void) snprintf(dbbuf, sizeof (dbbuf), "%s/psql", opts.bindir); - - cmd[0] = dbbuf; - cmd[1] = "-h"; - cmd[2] = opts.dbhost; - cmd[3] = "-p"; - cmd[4] = opts.port; - cmd[5] = "-t"; - cmd[6] = "-c"; - cmd[7] = buf; - cmd[8] = NULL; - - (void) snprintf(buf, sizeof (buf), - "SELECT datname FROM pg_database where datname = '%s'", - opts.dbname); - - pid = exec_mgmt_cmd(&readf, NULL, opts.dbuid, opts.dbgid, - B_FALSE, cmd); - mms_trace(MMS_DEBUG, "exec_mgmt_cmd: %s %s %s %s %s %s %s %s", - cmd[0], cmd[1], cmd[2], cmd[3], cmd[4], - cmd[5], cmd[6], cmd[7]); - - st = check_exit(pid, NULL); - - if (st == 0) { - buf[0] = '\0'; - (void) fgets(buf, sizeof (buf), readf); - if (buf[0] == '\0') { - st = -1; - } - } - - (void) fclose(readf); - - return (st); -} - -int -mgmt_db_dump(char *dumpdir, char *dumpfile, int len) -{ - int st; - char datebuf[256]; - char filbuf[MAXPATHLEN]; - time_t now = time(NULL); - struct tm *tm = NULL; - pid_t pid; - mmsdb_opts_t opts; - char *cmd[11]; - char dbbuf[2048]; - - if (!dumpdir || !dumpfile) { - return (MMS_MGMT_NOARG); - } - - if (!mgmt_chk_auth("solaris.mms.modify")) { - return (EACCES); - } - - st = mgmt_get_db_opts(&opts); - if (st != 0) { - return (st); - } - - tm = localtime(&now); - (void) strftime(datebuf, sizeof (datebuf), - "%Y-""%m-""%dT""%H""%M""%S", tm); - - (void) snprintf(filbuf, sizeof (filbuf), "%s/mmsdb_dump_%s", dumpdir, - datebuf); - - (void) snprintf(dbbuf, sizeof (dbbuf), "%s/pg_dump", opts.bindir); - - cmd[0] = dbbuf; - cmd[1] = "-h"; - cmd[2] = opts.dbhost; - cmd[3] = "-p"; - cmd[4] = opts.port; - cmd[5] = "-F"; - cmd[6] = "p"; - cmd[7] = "-f"; - cmd[8] = filbuf; - cmd[9] = opts.dbname; - cmd[10] = NULL; - - if (dumpfile != NULL) { - (void) strlcpy(dumpfile, filbuf, len); - } - - st = create_dir(dumpdir, 0711, NULL, opts.dbuid, NULL, 0); - - if (st != 0) { - return (st); - } - - pid = exec_mgmt_cmd(NULL, NULL, opts.dbuid, opts.dbgid, - B_FALSE, cmd); - mms_trace(MMS_DEBUG, "exec_mgmt_cmd: %s %s %s %s %s %s %s %s %s %s", - cmd[0], cmd[1], cmd[2], cmd[3], cmd[4], - cmd[5], cmd[6], cmd[7], cmd[8], cmd[9]); - - st = check_exit(pid, NULL); - - return (st); -} - - -/* - * TODO: Ensure this is done on the MM server host only when client - * configs are supported. - */ -int -mgmt_db_restore(char *dumpfile) -{ - int st; - struct stat64 statbuf; - char *mmstate = NULL; - mmsdb_opts_t opts; - - if (!mgmt_chk_auth("solaris.mms.modify")) { - return (EACCES); - } - - st = mgmt_get_db_opts(&opts); - if (st != 0) { - return (st); - } - - st = stat64(dumpfile, &statbuf); - if (st != 0) { - return (MMS_MGMT_DBDUMP_MISSING); - } - if (!S_ISREG(statbuf.st_mode)) { - return (MMS_MGMT_NOT_DBFILE); - } - - /* shutdown MM */ - mms_trace(MMS_DEBUG, "disable mm"); - st = mgmt_set_svc_state(MMSVC, DISABLE, &mmstate); - if (st != 0) { - if (mmstate) { - free(mmstate); - } - return (st); - } - - st = mgmt_db_create(1, 0, NULL); - if (st != 0) { - free(mmstate); - return (st); - } - - st = mgmt_db_sql_exec(dumpfile, &opts); - - if ((st == 0) && (strcmp(mmstate, "online") == 0)) { - mms_trace(MMS_DEBUG, "enable mm"); - st = mgmt_set_svc_state(MMSVC, ENABLE, NULL); - } - - free(mmstate); - return (st); -} - -typedef struct { - char *optnam; - char *val; -} pgconf_t; - -static pgconf_t pgconf_opts[] = { - {"port", NULL}, - {"log_directory", NULL}, - {"external_pid_file", "'postgres.pid'"}, - {"log_destination", "'stderr'"}, - {"logging_collector", "on"}, - {"log_filename", "'log.%a'"}, - {"log_rotation_size", "10000"}, - {"log_truncate_on_rotation", "on"}, - {"log_line_prefix", "'%m %p '"}, - {"client_min_messages", "WARNING"}, - {"log_min_messages", "INFO"}, - {"log_disconnections", "on"}, - {"track_counts", "on"}, - {"autovacuum", "on"}, - {"autovacuum_naptime", "1200"} -}; - -static int numpgopts = sizeof (pgconf_opts) / sizeof (pgconf_t); - -static int -configure_pgconf( - char *port, - char *logdir) -{ - int st = 0; - struct stat64 statbuf; - char nambuf[256]; - char buf[MAXPATHLEN]; - char dbpath[MAXPATHLEN]; - char logpath[MAXPATHLEN]; - uid_t uid; - size_t sz; - char *bufp; - struct tm usetime; - int infd; - int outfd; - FILE *infp; - FILE *outfp; - static char datefmt[] = "%y""%m""%d""%H""%M""%S"; - time_t now; - char filbuf[2048]; - int i; - char *cptr; - int changed = 0; - int matched = 0; - - if ((port == NULL) || (logdir == NULL)) { - return (MMS_MGMT_NOARG); - } - - pgconf_opts[0].val = port; - - /* add quotes around the path */ - (void) snprintf(logpath, sizeof (logpath), "'%s'", logdir); - - pgconf_opts[1].val = logpath; - - st = get_db_user(nambuf, sizeof (nambuf), &uid, NULL); - if (st == 0) { - st = mms_cfg_getvar(MMS_CFG_DB_DATA, dbpath); - } - - if (st != 0) { - return (st); - } - - st = stat64(logdir, &statbuf); - if (st != 0) { - st = errno; - if (st == ENOENT) { - st = create_dir(logdir, 0711, NULL, uid, NULL, 0); - } - if (st != 0) { - return (st); - } - } else { - if (!S_ISDIR(statbuf.st_mode)) { - return (ENOTDIR); - } - } - - sz = strlcat(dbpath, "/postgresql.conf", sizeof (dbpath)); - if (sz > sizeof (dbpath)) { - return (ENAMETOOLONG); - } - - st = stat64(dbpath, &statbuf); - if (st != 0) { - if (errno != ENOENT) { - return (errno); - } else { - /* - * DB not initialized yet, bail without - * error as this function will be called - * later from db_create. - */ - return (0); - } - } - - /* construct the name of the new version of this file */ - now = time(NULL); - (void) localtime_r(&now, &usetime); - (void) strftime(nambuf, sizeof (nambuf), datefmt, &usetime); - (void) snprintf(buf, sizeof (buf), "%s_%s", dbpath, nambuf); - - /* open the original */ - infd = open64(dbpath, O_RDONLY); - if (infd == -1) { - st = errno; - return (st); - } - - infp = fdopen(infd, "r"); - if (infp == NULL) { - st = errno; - (void) close(infd); - return (st); - } - - /* open the target file */ - outfd = open64(buf, O_CREAT|O_RDWR, statbuf.st_mode); - if (outfd == -1) { - st = errno; - (void) close(infd); - return (st); - } - - outfp = fdopen(outfd, "w"); - if (outfp == NULL) { - st = errno; - (void) fclose(infp); - (void) close(outfd); - return (st); - } - - /* preserve, as much as possible, the existing format of the file */ - while ((bufp = fgets(filbuf, sizeof (filbuf), infp)) != NULL) { - matched = 0; - cptr = NULL; - - for (; *bufp != '\0'; bufp++) { - /* options are initially commented out */ - if (*bufp == '#') { - continue; - } - if (!isspace(*bufp)) { - break; - } - } - - if (*bufp == '\0') { - (void) fprintf(outfp, "%s", filbuf); - continue; - } - - for (i = 0; i < numpgopts; i++) { - sz = strlen(pgconf_opts[i].optnam); - if (strncmp(bufp, pgconf_opts[i].optnam, sz) != 0) { - continue; - } - bufp += sz; - while ((*bufp != '\0') && (isspace(*bufp))) { - bufp++; - sz++; - } - if (*bufp == '=') { - /* found a match - update it */ - matched++; - - /* TODO: check really needed to change */ - (void) fprintf(outfp, "%s = %s\n", - pgconf_opts[i].optnam, pgconf_opts[i].val); - cptr = strchr(bufp, '#'); - if (cptr) { - (void) fprintf(outfp, "\t\t\t\t\t%s", - cptr); - } - changed++; - break; - } else { - /* superstring or substring of another option */ - bufp -= sz; - } - } - - if (!matched) { - (void) fprintf(outfp, "%s", filbuf); - } - } - (void) fchown(outfd, statbuf.st_uid, statbuf.st_gid); - (void) fclose(outfp); - (void) fclose(infp); - - /* if we didn't change anything, we're done */ - if (!changed) { - (void) unlink(buf); - return (0); - } - - /* construct the name of the backup copy of this file */ - (void) localtime_r(&(statbuf.st_mtime), &usetime); - (void) strftime(nambuf, sizeof (nambuf), datefmt, &usetime); - - (void) snprintf(filbuf, sizeof (filbuf), "%s_%s", dbpath, nambuf); - - /* finally, swap em */ - st = rename(dbpath, filbuf); - if (st != 0) { - st = errno; - (void) unlink(buf); - } else { - st = rename(buf, dbpath); - if (st != 0) { - st = errno; - } - } - - return (st); -} - -static int -get_dbver_from_optfile(char *path, int *version) -{ - int st = 0; - FILE *fp = NULL; - char buf[1024]; - char *bufp; - int vers = -1; - int last = -1; - - if (!path || !version) { - return (ENOENT); - } - - st = access(path, R_OK); - if (st != 0) { - st = errno; - return (st); - } - - fp = fopen(path, "r"); - if (fp == NULL) { - st = errno; - return (errno); - } - - while ((bufp = fgets(buf, sizeof (buf), fp)) != NULL) { - if ((*bufp != '\0') && (!isdigit(*bufp))) { - continue; - } - - do { - bufp++; - } while (isdigit(*bufp)); - - if (*bufp != 'u') { - continue; - } - - *bufp = '\0'; - - vers = atoi(buf); - if (vers > last) { - last = vers; - } - } - (void) fclose(fp); - - *version = last; - - return (st); -} - -static int -mk_cmds_from_optfile(mmsdb_opts_t *opts, char *path, int vers, char cmdtype, - int dopd, char **cmdfile) -{ - int st = 0; - int fd = -1; - FILE *fp = NULL; - FILE *ofp = NULL; - char buf[MAXPATHLEN]; - char *bufp; - int started = 0; - char *pass; - - if (!opts || !path || !cmdfile) { - return (MMS_MGMT_NOARG); - } - - st = access(path, R_OK); - if (st != 0) { - st = errno; - return (st); - } - - fp = fopen(path, "r"); - if (fp == NULL) { - st = errno; - return (errno); - } - - /* create our cmdfile */ - (void) snprintf(buf, sizeof (buf), "%s/../mmsdbcmd-%c-%d", - opts->path, cmdtype, time(NULL)); - - fd = open(buf, O_CREAT|O_TRUNC|O_APPEND|O_WRONLY|O_NOFOLLOW|O_NOLINKS, - 0600); - if (fd == -1) { - st = errno; - goto done; - } - - /* set this so the pguser can read it */ - (void) fchown(fd, opts->dbuid, opts->dbgid); - - ofp = fdopen(fd, "a"); - if (ofp == NULL) { - st = errno; - (void) close(fd); - goto done; - } - - *cmdfile = strdup(buf); - - (void) fprintf(ofp, "BEGIN;\n"); - - while ((bufp = fgets(buf, sizeof (buf), fp)) != NULL) { - if (*bufp == '#') { - continue; - } - - if (!isdigit(*bufp)) { - if (started) { - (void) fprintf(ofp, "%s", bufp); - } - continue; - } - - while (isdigit(*bufp)) { - bufp++; - } - - if (*bufp++ == cmdtype) { - started = 1; - while (isspace(*buf)) { - bufp++; - } - (void) fprintf(ofp, "%s", bufp); - } else { - started = 0; - } - } - - if (dopd) { - (void) fclose(fp); - - /* override the junk password in the dbopts file */ - pass = mms_net_cfg_read_pass_file(MMS_NET_CFG_HELLO_FILE); - if (pass != NULL) { - (void) fprintf(ofp, - "UPDATE \"MMPASSWORD\" SET \"Password\" = '%s' " - "WHERE \"ApplicationName\" = 'MMS';\n", - pass); - free(pass); - } - } - - /* Set the version and add commit statement */ - (void) fprintf(ofp, - "UPDATE \"MM\" SET \"DBVersion\" = '%d';\nCOMMIT;\n", vers); - -done: - if (st != 0) { - if (*cmdfile) { - (void) unlink(*cmdfile); - free(cmdfile); - *cmdfile = NULL; - } - } - (void) fclose(fp); - (void) fclose(ofp); - - return (st); -} - -static int -mgmt_db_sql_exec(char *cmdfile, mmsdb_opts_t *opts) -{ - int st; - pid_t pid; - FILE *dberr; - char buf[MAXPATHLEN]; - char *cmd[10]; - char dbbuf[2048]; - - if (!cmdfile || !opts) { - return (MMS_MGMT_NOARG); - } - - (void) snprintf(dbbuf, sizeof (dbbuf), "%s/psql", opts->bindir); - - cmd[0] = dbbuf; - cmd[1] = "-a"; - cmd[2] = "-h"; - cmd[3] = opts->dbhost; - cmd[4] = "-p"; - cmd[5] = opts->port; - cmd[6] = "-f"; - cmd[7] = cmdfile; - cmd[8] = opts->dbname; - cmd[9] = NULL; - - pid = exec_mgmt_cmd(NULL, &dberr, opts->dbuid, opts->dbgid, - B_FALSE, cmd); - mms_trace(MMS_DEBUG, "exec_mgmt_cmd: %s %s %s %s %s %s %s %s %s", - cmd[0], cmd[1], cmd[2], cmd[3], cmd[4], - cmd[5], cmd[6], cmd[7], cmd[8]); - - st = check_exit(pid, NULL); - - if (st == 0) { - while (fgets(buf, sizeof (buf), dberr) != NULL) { - if ((strstr(buf, " ERROR: ") != NULL) || - (strstr(buf, "ROLLBACK") != NULL)) { - st = 1; - break; - } - } - } - (void) fclose(dberr); - - return (st); -} - -/* - * this should probably move to a header somewhere, but for - * now, leave it where it's directly mapped - */ -typedef struct { - char *mm; - char *ui; -} mgmt_dbopt_map_t; - -/* - * map of MgmtUI-specified opts to MM options. NULL indicates - * not exposed by MgmtUI - */ -static mgmt_dbopt_map_t mm_sys_opts[] = { - {"AttendanceMode", O_ATTENDED}, - {"SystemLogLevel", O_LOGLEVEL}, - {"SystemLogFile", O_LOGFILE}, - {"MessageLevel", O_MSGLEVEL}, - {"TraceLevel", O_TRACELEVEL}, - {"TraceFileSize", O_TRACESZ}, - {"SocketFdLimit", O_NUMSOCKET}, - {"SystemDiskMountTimeout", O_DKTIMEOUT}, - {"WatcherStartsLimit", O_NUMRESTART}, - {"SystemAcceptLevel", NULL}, - {"SystemMessageLimit", NULL}, - {"SystemMessageCount", NULL}, - {"SystemRequestLimit", NULL}, - {"SystemRequestCount", NULL}, - {"SystemSyncLimit", NULL}, - {"SystemDCALimit", NULL}, - {"SystemDCACount", NULL}, - {"ClearDriveAtLMConfig", NULL}, - {"AskClearDriveAtLMConfig", NULL}, - {"PreemptReservation", NULL}, - {"SystemLogFileSize", NULL}, - {"SystemName", NULL}, - {"SystemInstance", NULL}, - {"UnloadDelayTime", NULL}, - {"DefaultBlocksize", NULL}, - {"WatcherTimeLimit", NULL}, - {"DriveRecordRetention", NULL}, - {NULL, NULL} -}; - -/* add the MM options to the database before creation, if we know them */ -static int -set_mm_system_vars_db(nvlist_t *opts, char *cmdfile) -{ - int st; - char *val = NULL; - int i; - int fd = -1; - FILE *ofp = NULL; - struct stat sb; - int changed = 0; - - if (!opts) { - return (0); - } - - if (!cmdfile) { - return (MMS_MGMT_NOARG); - } - - fd = open(cmdfile, O_RDWR|O_NOFOLLOW|O_NOLINKS); - if (fd == -1) { - return (errno); - } - st = fstat(fd, &sb); - if (st != 0) { - st = errno; - (void) close(fd); - return (st); - } - - ofp = fdopen(fd, "a"); - if (ofp == NULL) { - st = errno; - (void) close(fd); - return (st); - } - - for (i = 0; mm_sys_opts[i].mm != NULL; i++) { - if (mm_sys_opts[i].ui == NULL) { - continue; - } - st = nvlist_lookup_string(opts, mm_sys_opts[i].ui, &val); - if ((st == 0) && val) { - if (!changed) { - (void) fprintf(ofp, "BEGIN;\n"); - } - (void) fprintf(ofp, - "UPDATE \"SYSTEM\" SET \"%s\" = '%s';\n", - mm_sys_opts[i].mm, val); - - changed++; - } - } - - if (changed) { - (void) fprintf(ofp, "COMMIT;\n"); - } - - (void) fclose(ofp); - - return (0); -} - -int -mgmt_set_db_pass(char *dbpass, nvlist_t *errs) -{ - int st; - mmsdb_opts_t opts; - char buf[2048]; - boolean_t ismd5 = B_FALSE; - int fd = -1; - int wr = 0; - char file[MAXPATHLEN]; - - /* no provided password means use 'trust' */ - if (dbpass) { - ismd5 = B_TRUE; - } - - st = mgmt_get_db_opts(&opts); - if (st != 0) { - return (st); - } - - /* tell Postgres to use the new password */ - (void) snprintf(file, sizeof (file), "%s/../tsql", opts.path); - fd = open64(file, O_CREAT|O_TRUNC|O_WRONLY, 0600); - if (fd == -1) { - st = errno; - MGMT_ADD_ERR(errs, file, st); - return (st); - } - - (void) fchown(fd, opts.dbuid, opts.dbgid); - - (void) snprintf(buf, sizeof (buf), - "alter user postgres with password '%s' valid until 'infinity';", - dbpass); - wr = write_buf(fd, buf, strlen(buf)); - (void) close(fd); - - if (wr == -1) { - MGMT_ADD_ERR(errs, file, EIO); - (void) unlink(file); - return (EIO); - } - - st = mgmt_db_sql_exec(file, &opts); - if (st != 0) { - MGMT_ADD_ERR(errs, "postgres failure", st); - (void) unlink(file); - return (st); - } - - (void) unlink(file); - - /* next, set up the conf file */ - st = update_pghba(ismd5, &opts, errs); - if (st != 0) { - return (st); - } - - /* write the PGPASSFILE */ - (void) snprintf(file, sizeof (file), "%s/../%s", - opts.path, MMS_MGMT_PGA); - fd = open64(file, O_CREAT|O_TRUNC|O_WRONLY, 0600); - if (fd == -1) { - st = errno; - MGMT_ADD_ERR(errs, file, st); - return (st); - } - (void) fchown(fd, opts.dbuid, opts.dbgid); - - (void) snprintf(buf, sizeof (buf), "*:*:*:*:%s", dbpass); - wr = write_buf(fd, buf, strlen(buf)); - (void) close(fd); - - if (wr == -1) { - MGMT_ADD_ERR(errs, file, EIO); - (void) unlink(file); - return (EIO); - } - - st = mms_net_cfg_write_pass_file(MMS_NET_CFG_DB_FILE, dbpass); - if (st != 0) { - return (st); - } - - /* restart the db */ - mms_trace(MMS_DEBUG, "restart db"); - st = mgmt_set_svc_state(DBSVC, RESTART, NULL); - - if (st == 0) { - st = mgmt_db_ready(); - if (st != 0) { - mms_trace(MMS_ERR, - "database did not go ready"); - } - } - - return (st); -} - -static int -update_pghba(boolean_t ismd5, mmsdb_opts_t *dbopts, nvlist_t *errs) -{ - int st; - char buf[2048]; - char *bufp; - int infd = -1; - int outfd = -1; - FILE *infp = NULL; - FILE *outfp = NULL; - struct stat64 statbuf; - char confpath[2048]; - char newconfpath[2048]; - time_t now; - struct tm usetime; - static char datefmt[] = "%y""%m""%d""%H""%M""%S"; - boolean_t changed = B_FALSE; - char timebuf[256]; - - if (!dbopts) { - return (MMS_MGMT_NOARG); - } - - (void) snprintf(confpath, sizeof (confpath), "%s/pg_hba.conf", - dbopts->path); - - st = stat64(confpath, &statbuf); - if (st != 0) { - st = errno; - MGMT_ADD_ERR(errs, confpath, st); - return (st); - } - - /* construct the name of the new version of this file */ - now = time(NULL); - (void) localtime_r(&now, &usetime); - (void) strftime(timebuf, sizeof (timebuf), datefmt, &usetime); - (void) snprintf(newconfpath, sizeof (newconfpath), "%s_%s", confpath, - timebuf); - - /* open the original */ - infd = open64(confpath, O_RDONLY); - if (infd == -1) { - st = errno; - MGMT_ADD_ERR(errs, confpath, st); - return (st); - } - - infp = fdopen(infd, "r"); - if (infp == NULL) { - st = errno; - MGMT_ADD_ERR(errs, confpath, st); - (void) close(infd); - return (st); - } - - /* open the target file */ - outfd = open64(newconfpath, O_CREAT|O_RDWR, 0600); - if (outfd == -1) { - st = errno; - (void) close(infd); - MGMT_ADD_ERR(errs, newconfpath, st); - return (st); - } - - outfp = fdopen(outfd, "w"); - if (outfp == NULL) { - st = errno; - (void) fclose(infp); - (void) close(outfd); - MGMT_ADD_ERR(errs, newconfpath, st); - return (st); - } - - /* preserve, as much as possible, the existing format of the file */ - while ((bufp = fgets(buf, sizeof (buf), infp)) != NULL) { - while (isspace(*bufp)) { - bufp++; - } - - if ((*bufp == '\0') || (*bufp == '#')) { - (void) fprintf(outfp, "%s", buf); - continue; - } - - /* look for 'trust' or 'md5' */ - if (ismd5) { - /* changing to password-protected */ - bufp = strstr(buf, "trust"); - if (bufp) { - (void) strlcpy(bufp, "md5\n", 7); - changed = B_TRUE; - } - } else { - /* removing password protection */ - bufp = strstr(buf, "md5"); - if (bufp) { - (void) strlcpy(bufp, "trust\n", 7); - changed = B_TRUE; - } - } - - (void) fprintf(outfp, "%s", buf); - } - - (void) fchown(outfd, dbopts->dbuid, dbopts->dbgid); - (void) fclose(outfp); - (void) fclose(infp); - - /* if we didn't change anything, we're done */ - if (!changed) { - (void) unlink(newconfpath); - return (0); - } - - /* construct the name of the backup copy of this file */ - (void) localtime_r(&(statbuf.st_mtime), &usetime); - (void) strftime(timebuf, sizeof (timebuf), datefmt, &usetime); - - (void) snprintf(buf, sizeof (buf), "%s_%s", confpath, timebuf); - - /* finally, swap em */ - st = rename(confpath, buf); - if (st != 0) { - st = errno; - (void) unlink(buf); - MGMT_ADD_ERR(errs, confpath, st); - } else { - st = rename(newconfpath, confpath); - if (st != 0) { - st = errno; - MGMT_ADD_ERR(errs, newconfpath, st); - } - } - - return (st); -} diff --git a/usr/src/lib/mms/mgmt/common/mgmt_probe.c b/usr/src/lib/mms/mgmt/common/mgmt_probe.c deleted file mode 100644 index c6add400d4..0000000000 --- a/usr/src/lib/mms/mgmt/common/mgmt_probe.c +++ /dev/null @@ -1,238 +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 <errno.h> -#include <stdio.h> -#include <strings.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/param.h> -#include <sys/scsi/impl/uscsi.h> -#include <sys/scsi/generic/sense.h> -#include <sys/scsi/generic/status.h> -#include <dirent.h> -#include <sys/mtio.h> -#include <ctype.h> -#include <fcntl.h> -#include <libnvpair.h> - -#include "mms_mgmt.h" -#include "mgmt_sym.h" - -#define TPDIR "/dev/rmt" - -int -mgmt_find_local_drives(nvlist_t **drv_list) -{ - int st = 0; - int i; - struct uscsi_cmd us; - uchar_t cdb[] = {0x12, 0x01, 0x80, 0x00, 64, 0x00}; - /* cdb to read serial number */ - uchar_t cdbinq[] = { 0x12, 0x00, 0x00, 0x00, 64, 0 }; - /* cdb to read inquiry data */ - int fd = -1; - char senbuf[64]; - char buf[68]; /* 64 + 4 */ - char ser[65]; /* 64 + nul */ - DIR *dir; - dirent_t *ent; - ssize_t len; - char *name; - char path[MAXPATHLEN]; - struct mtdrivetype dt; - struct mtdrivetype_request dtreq = { sizeof (dt), &dt }; - char vid[9]; - char pid[17]; - char *bufp; - nvlist_t *drv = NULL; - char *unavail = "device unavailable"; - - if (!drv_list) { - return (MMS_MGMT_NOARG); - } - - if ((dir = opendir(TPDIR)) == NULL) { - st = errno; - return (st); - } - - st = nvlist_alloc(drv_list, NV_UNIQUE_NAME, 0); - if (st != 0) { - return (st); - } - - while (ent = readdir(dir)) { - if (fd != -1) { - (void) close(fd); - fd = -1; - } - - if (drv != NULL) { - (void) nvlist_add_nvlist(*drv_list, path, drv); - drv = NULL; - } - - /* - * Use the device with only norewind - */ - len = strlen(ent->d_name); - name = ent->d_name; - if (name[len - 1] != 'n' || !isdigit(name[len - 2])) { - continue; - } - - (void) snprintf(path, sizeof (path), "%s/%s", TPDIR, name); - - /* list all drives, accessible or not */ - st = nvlist_alloc(&drv, NV_UNIQUE_NAME, 0); - if (st != 0) { - break; - } - (void) nvlist_add_string(drv, O_DEVPATH, path); - - fd = open(path, O_NDELAY | O_RDWR); - if (fd < 0) { - if (errno == EBUSY) { - (void) nvlist_add_string(drv, O_TYPE, - "device busy"); - } else { - (void) nvlist_add_string(drv, O_TYPE, unavail); - } - continue; - } - - /* - * Read the serial number - */ - (void) memset(&us, 0, sizeof (us)); - us.uscsi_flags |= (USCSI_RQENABLE | USCSI_READ); - us.uscsi_cdb = (char *)cdb; - us.uscsi_cdblen = sizeof (cdb); - us.uscsi_bufaddr = buf; - us.uscsi_buflen = sizeof (buf); - us.uscsi_rqlen = sizeof (senbuf); - us.uscsi_rqbuf = senbuf; - - (void) memset(us.uscsi_rqbuf, 0, us.uscsi_rqlen); - - if (ioctl(fd, USCSICMD, &us)) { - if (errno != EIO) { - (void) nvlist_add_string(drv, O_TYPE, unavail); - continue; - } - } - - if ((us.uscsi_status != STATUS_GOOD) || - (us.uscsi_resid == us.uscsi_buflen)) { - /* No data transfered */ - (void) nvlist_add_string(drv, O_TYPE, unavail); - continue; - } - - (void) memset(ser, 0, sizeof (ser)); - len = buf[3]; - bufp = &(buf[4]); - - for (i = 0; (i < (sizeof (ser) - 1)) && (i < len); - i++, bufp++) { - if ((*bufp == '\0') || (*bufp == ' ')) { - break; - } - - ser[i] = *bufp; - } - - /* - * Read vid and pid using inquiry. The MTIOCGETDRIVETYPE - * ioctl does not give you the full 16 bytes of product id. - */ - (void) memset(&us, 0, sizeof (us)); - us.uscsi_flags |= (USCSI_RQENABLE | USCSI_READ); - us.uscsi_cdb = (char *)cdbinq; - us.uscsi_cdblen = sizeof (cdbinq); - us.uscsi_bufaddr = buf; - us.uscsi_buflen = sizeof (buf); - us.uscsi_rqlen = sizeof (senbuf); - us.uscsi_rqbuf = senbuf; - - (void) memset(us.uscsi_rqbuf, 0, us.uscsi_rqlen); - - if (ioctl(fd, USCSICMD, &us)) { - (void) nvlist_add_string(drv, O_TYPE, unavail); - continue; - } - - if ((us.uscsi_status != STATUS_GOOD) || - (us.uscsi_resid == us.uscsi_buflen)) { - /* No data transfered */ - (void) nvlist_add_string(drv, O_TYPE, unavail); - continue; - } - - (void) memset(vid, 0, sizeof (vid)); - bufp = &(buf[8]); - - for (i = 0; i < (sizeof (vid) - 1); i++, bufp++) { - if ((*bufp == '\0') || (*bufp == ' ')) { - break; - } - - vid[i] = *bufp; - } - - (void) memset(pid, 0, sizeof (pid)); - bufp = &(buf[16]); - - for (i = 0; i < (sizeof (pid) - 1); i++, bufp++) { - if ((*bufp == '\0') || (*bufp == ' ')) { - break; - } - - pid[i] = *bufp; - } - - /* - * Get the drive type - */ - if (ioctl(fd, MTIOCGETDRIVETYPE, &dtreq) == 0) { - (void) nvlist_add_string(drv, O_SERIALNO, ser); - (void) nvlist_add_string(drv, O_TYPE, pid); - (void) nvlist_add_string(drv, "vendorid", vid); - (void) nvlist_add_string(drv, "fullname", dt.name); - } - - (void) close(fd); - fd = -1; - } - (void) closedir(dir); - - /* make sure the last drive made it to the list */ - if (drv != NULL) { - (void) nvlist_add_nvlist(*drv_list, path, drv); - } - - return (st); -} diff --git a/usr/src/lib/mms/mgmt/common/mgmt_sym.h b/usr/src/lib/mms/mgmt/common/mgmt_sym.h deleted file mode 100644 index ef110ff14b..0000000000 --- a/usr/src/lib/mms/mgmt/common/mgmt_sym.h +++ /dev/null @@ -1,80 +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 __MGMT_SYM_H__ -#define __MGMT_SYM_H__ - -#define MMS_MGMT_ERR_OFFSET 2000 -#define MMS_MGMT_NOARG 2001 -#define MMS_MGMT_ERR_EXEC_SSI 2002 -#define MMS_MGMT_ERR_ACSLS_COMM 2003 -#define MMS_MGMT_ERR_ACSLS_RSP 2004 -#define MMS_MGMT_ERR_ACSLS_PARSE 2005 -#define MMS_MGMT_ERR_REQUIRED 2006 -#define MMS_MGMT_NO_MMHOST 2007 -#define MMS_MGMT_CARTRIDGE_INUSE 2008 -#define MMS_MGMT_DBDUMP_MISSING 2009 -#define MMS_MGMT_RSP_UNKNOWN 2010 -#define MMS_MGMT_RSP_CANCELLED 2011 -#define MMS_MGMT_REQ_NOT_ACCEPTED 2012 -#define MMS_MGMT_ERR_GROUP 2013 -#define MMS_MGMT_ERR_USER 2014 -#define MMS_MGMT_ERR_SVRONLY 2015 -#define MMS_MGMT_ERR_CART_NOT_UNIQUE 2016 -#define MMS_MGMT_ERR_PARTITION_NOT_UNIQUE 2017 -#define MMS_MGMT_VOL_NOT_INIT 2018 -#define MMS_MGMT_NO_USABLE_VOL 2019 -#define MMS_MGMT_ACSLS_NOT_FOUND 2020 -#define MMS_MGMT_MMS_NOT_INIT 2021 -#define MMS_MGMT_REMOTE_NOT_SUPP 2022 -#define MMS_MGMT_PASSWORD_REQUIRED 2023 -#define MMS_MGMT_VOL_NOT_MOUNTED 2024 -#define MMS_MGMT_NOT_AUTHORIZED 2025 -#define MMS_MGMT_PASSWD_MISMATCH 2026 -#define MMS_MGMT_GETPASS_FAILED 2027 -#define MMS_MGMT_PASSTOOSHORT 2028 -#define MMS_MGMT_MMP_PARSE_ERR 2029 -#define MMS_MGMT_APP_VOLS_EXIST 2030 -#define MMS_MGMT_NOT_DBFILE 2031 -#define MMS_MGMT_DB_USER_NOTFOUND 2032 -#define MMS_MGMT_INVALID_PATH 2033 -#define MMS_MGMT_INV_HOSTPATH 2034 -#define MMS_MGMT_LIB_EXISTS 2035 -#define MMS_MGMT_LIB_NOT_EXIST 2036 -#define MMS_MGMT_NO_HWTYPE 2037 -#define MMS_MGMT_NO_VOLTYPE 2038 -#define MMS_MGMT_DFLTPATH_ERR 2039 -#define MMS_MGMT_DG_NOT_EXIST 2040 -#define MMS_MGMT_CG_NOT_EXIST 2041 -#define MMS_MGMT_SHOW_CT_ERR 2042 -#define MMS_MGMT_CT_NOT_EXIST 2043 -#define MMS_MGMT_SN_ERR 2044 -#define MMS_MGMT_REQ_ARG 2045 -#define MMS_MGMT_CREATE_PART_ERR 2046 -#define MMS_MGMT_CREATE_CART_ERR 2047 -#define MMS_MGMT_INVALID_READONLY 2048 - -#define MMS_MGMT_LAST_ERR_CODE 2200 /* Must be last */ - -#endif /* __MGMT_SYM_H__ */ diff --git a/usr/src/lib/mms/mgmt/common/mgmt_util.c b/usr/src/lib/mms/mgmt/common/mgmt_util.c deleted file mode 100644 index 02dd8c209f..0000000000 --- a/usr/src/lib/mms/mgmt/common/mgmt_util.c +++ /dev/null @@ -1,1914 +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. - */ - -static char *_SrcFile = __FILE__; /* Using __FILE__ makes duplicate strings */ - -/* - * various utility functions - */ - -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <sys/param.h> -#include <sys/wait.h> -#include <unistd.h> -#include <string.h> -#include <stdarg.h> -#include <time.h> -#include <sys/mnttab.h> -#include <libgen.h> -#include <pwd.h> -#include <grp.h> -#include <ctype.h> -#include <fcntl.h> -#include <unistd.h> -#include <procfs.h> -#include <dirent.h> -#include <auth_attr.h> -#include <secdb.h> - -#include "mgmt_util.h" -#include "mmp_defs.h" -#include "mms_cfg.h" - -/* forward declarations */ -static int file_chown(char *file, struct stat64 *statbuf, char *user, - char *group); -static int file_chown_id(char *file, struct stat64 *statbuf, uid_t uid, - gid_t gid); -static void -filter_on_var(char *varname, char **varray, int count, nvlist_t *nvl); - -/* error messages */ -static mms_sym_t mms_mgmt_errs[] = { - "Internal error; missing argument", - MMS_MGMT_NOARG, - "Could not exec ACSLS ssi daemon", - MMS_MGMT_ERR_EXEC_SSI, - "Could not communicate with ACSLS server", - MMS_MGMT_ERR_ACSLS_COMM, - "Received invalid response from ACSLS server", - MMS_MGMT_ERR_ACSLS_RSP, - "Could not parse response from ACSLS server", - MMS_MGMT_ERR_ACSLS_PARSE, - "Missing required option", - MMS_MGMT_ERR_REQUIRED, - "Could not determine MM host", - MMS_MGMT_NO_MMHOST, - "Volume in use", - MMS_MGMT_CARTRIDGE_INUSE, - "Could not access database backup", - MMS_MGMT_DBDUMP_MISSING, - "Unknown response type", - MMS_MGMT_RSP_UNKNOWN, - "Request cancelled", - MMS_MGMT_RSP_CANCELLED, - "Request not accepted", - MMS_MGMT_REQ_NOT_ACCEPTED, - "Could not determine group", - MMS_MGMT_ERR_GROUP, - "Could not determine user", - MMS_MGMT_ERR_USER, - "Option applies to MM server host only", - MMS_MGMT_ERR_SVRONLY, - "Volume not unique", - MMS_MGMT_ERR_CART_NOT_UNIQUE, - "Partition not unique", - MMS_MGMT_ERR_PARTITION_NOT_UNIQUE, - "Volume not labeled", - MMS_MGMT_VOL_NOT_INIT, - "No usable volume found", - MMS_MGMT_NO_USABLE_VOL, - "Could not find ACSLS client libraries", - MMS_MGMT_ACSLS_NOT_FOUND, - "MMS is not initialized or not running", - MMS_MGMT_MMS_NOT_INIT, - "Drives on remote systems cannot be configured at this time", - MMS_MGMT_REMOTE_NOT_SUPP, - "Operation requires a password", - MMS_MGMT_PASSWORD_REQUIRED, - "Volume not mounted", - MMS_MGMT_VOL_NOT_MOUNTED, - "Not authorized. Use the correct application/password combination.", - MMS_MGMT_NOT_AUTHORIZED, - "Password validation failed", - MMS_MGMT_PASSWD_MISMATCH, - "Failed to get the password", - MMS_MGMT_GETPASS_FAILED, - "Password must be 8 characters or longer.", - MMS_MGMT_PASSTOOSHORT, - "Internal error: MMP parsing failed", - MMS_MGMT_MMP_PARSE_ERR, - "Application is still using one or more volumes.", - MMS_MGMT_APP_VOLS_EXIST, - "Not a valid MMS database backup file", - MMS_MGMT_NOT_DBFILE, - "Database Administrator user account not found", - MMS_MGMT_DB_USER_NOTFOUND, - "Default DISK lib path invalid", - MMS_MGMT_INVALID_PATH, - "Invalid hostpath format. Must be hostname@path", - MMS_MGMT_INV_HOSTPATH, - "Library already exists", - MMS_MGMT_LIB_EXISTS, - "Library does not exist", - MMS_MGMT_LIB_NOT_EXIST, - "Must specify hardware type", - MMS_MGMT_NO_HWTYPE, - "Must specify volume type", - MMS_MGMT_NO_VOLTYPE, - "Cannot get library DefaultPath", - MMS_MGMT_DFLTPATH_ERR, - "dpool does not exist. Create it first.", - MMS_MGMT_DG_NOT_EXIST, - "mpool does not exist. Create it first.", - MMS_MGMT_CG_NOT_EXIST, - "voltype does not exist. Create it first.", - MMS_MGMT_SHOW_CT_ERR, - "show voltype error", - MMS_MGMT_CT_NOT_EXIST, - "voltype does not exist. Create it first", - MMS_MGMT_SN_ERR, - "missing required arguement", - MMS_MGMT_REQ_ARG, - "create PARTITION error", - MMS_MGMT_CREATE_PART_ERR, - "create CARTRIDGE error", - MMS_MGMT_CREATE_CART_ERR, - "invalid readonly value", - MMS_MGMT_INVALID_READONLY, -}; - -/* - * mms_gen_taskid() - * - * Parameters: - * - tid unique task identifier. - * - * This function returns a task identifier (TID). All responses to an MMP - * command will include the TID of the initiating command. The TID will be - * unique in the context of a session so that the client can determine which - * responses go with which command. - */ -int -mms_gen_taskid(char *tid) -{ - if (!tid) { - return (MMS_MGMT_NOARG); - } - - (void) sprintf(tid, "%d-%ld", (int)getpid(), time(NULL)); - - return (0); -} - -/* - * create the directory dir. This function will not fail if the directory - * already exists. - */ -int -create_dir(char *dir, mode_t perms, char *user, uid_t uid, char *group, - gid_t gid) -{ - - struct stat64 dir_stat; - int st = 0; - - if (!dir) { - return (MMS_MGMT_NOARG); - } - - if (perms == 0) { - /* make the dir rwx by owner, and rx by other and group */ - perms = 0 | S_IRWXU | S_IROTH | S_IXOTH | S_IRGRP | S_IXGRP; - } - - mms_trace(MMS_INFO, "creating directory %s", dir); - errno = 0; - if (stat64(dir, &dir_stat) == 0) { - if (!S_ISDIR(dir_stat.st_mode)) { - - /* TBD: set errno and errmsg */ - return (ENOTDIR); - } - } else if (errno == ENOENT) { - errno = 0; - st = mkdirp(dir, perms); - if (st != 0) { - return (errno); - } - (void) stat64(dir, &dir_stat); - } - - if (uid == 0) { - st = file_chown(dir, &dir_stat, user, group); - } else { - st = file_chown_id(dir, &dir_stat, uid, gid); - } - - return (st); -} - -static int -file_chown(char *file, struct stat64 *statbuf, char *user, char *group) -{ - struct passwd pwd; - struct passwd *pwdp; - struct group gr; - struct group *grp; - char buf[1024]; - uid_t uid = 0; - gid_t gid = 0; - int st; - - if ((file == NULL) || (statbuf == NULL)) { - return (MMS_MGMT_NOARG); - } - - if (user == NULL) { - /* nothing to do */ - return (0); - } - - (void) getpwnam_r(user, &pwd, buf, sizeof (buf), &pwdp); - if (pwdp == NULL) { - return (MMS_MGMT_ERR_USER); - } - uid = pwdp->pw_uid; - gid = pwdp->pw_gid; /* default to user's default group */ - - if (group != NULL) { - (void) getgrnam_r(group, &gr, buf, sizeof (buf), &grp); - if (grp == NULL) { - return (MMS_MGMT_ERR_GROUP); - } - gid = grp->gr_gid; - } - - st = file_chown_id(file, statbuf, uid, gid); - - return (st); -} - -static int -file_chown_id(char *file, struct stat64 *statbuf, uid_t uid, gid_t gid) -{ - int st; - - if ((file == NULL) || (statbuf == NULL)) { - return (MMS_MGMT_NOARG); - } - - if ((uid == 0) && (gid == 0)) { - /* nothing to do */ - return (0); - } - - if ((statbuf->st_uid == uid) && (statbuf->st_gid == gid)) { - /* nothing to do */ - return (0); - } - - st = chown(file, uid, gid); - - return (st); -} - -int cp_file( - const char *old, - const char *new) -{ - int oldfd = -1; - int newfd = -1; - struct stat oldstatbuf; - struct stat newstatbuf; - int res; - int saverr = 0; - struct timeval oldtimes[2]; - char buf[8192]; - int wlen; - ssize_t oldlen; - - mms_trace(MMS_DEBUG, "copying file %s to %s", old, new); - - /* make sure old exists */ - res = stat(old, &oldstatbuf); - if (res != 0) { - return (errno); - } - - /* if the target exists, remove it */ - res = stat(new, &newstatbuf); - if (res == 0) { - mms_trace(MMS_DEBUG, "cp_file: removing %s", new); - (void) unlink(new); - } - - /* save the access & mod times so they can be reset */ - oldtimes[0].tv_sec = oldstatbuf.st_atim.tv_sec; - oldtimes[0].tv_usec = oldstatbuf.st_atim.tv_nsec / 1000; - oldtimes[1].tv_sec = oldstatbuf.st_mtim.tv_sec; - oldtimes[1].tv_usec = oldstatbuf.st_mtim.tv_nsec / 1000; - - oldfd = open(old, O_RDONLY, oldstatbuf.st_mode); - if (oldfd == -1) { - res = errno; - mms_trace(MMS_ERR, "Error opening %s, %d", old, res); - return (res); - } - newfd = open(new, O_WRONLY|O_CREAT|O_EXCL, oldstatbuf.st_mode); - if (newfd == -1) { - res = errno; - (void) close(oldfd); - mms_trace(MMS_ERR, "Error opening %s, %d", new, res); - return (res); - } - - /* finally, copy the file */ - res = 0; - oldlen = oldstatbuf.st_size; - - while (oldlen > 0) { - if (oldlen < 8192) { - wlen = oldlen; - } else { - wlen = 8192; - } - - res = readbuf(oldfd, buf, wlen); - if (res == -1) { - saverr = errno; - mms_trace(MMS_ERR, "Error reading file %s, %d", - old, saverr); - break; - } - - res = write_buf(newfd, buf, wlen); - if (res == -1) { - saverr = errno; - mms_trace(MMS_ERR, "Error writing file %s, %d", - new, saverr); - break; - } - - oldlen -= wlen; - } - - (void) close(newfd); - (void) close(oldfd); - - /* set acccess & modify times to match original file */ - if (saverr == 0) { - (void) utimes(new, oldtimes); - (void) utimes(old, oldtimes); - res = 0; - } else { - res = saverr; - } - - return (res); -} - -/* helper function to use read() correctly */ -int -readbuf(int fd, void* buffer, int len) -{ - int numread = 0; - int ret; - char *bufp; - - if ((buffer == NULL) || (len < 1) || (fd == -1)) { - return (-1); - } - - bufp = buffer; - - while (numread < len) { - ret = read(fd, bufp, (len - numread)); - - if (ret == 0) { - /* reached EOF */ - break; - } else if (ret == -1) { - if (errno == EAGAIN) { - continue; - } - numread = -1; - break; - } - - numread += ret; - bufp += ret; - } - - return (numread); -} - -/* helper function to use write() correctly */ -int -write_buf(int fd, void* buffer, int len) -{ - int written = 0; - int ret; - char *bufp; - - if ((buffer == NULL) || (fd == -1)) { - return (-1); - } - - bufp = buffer; - - while (written < len) { - ret = write(fd, bufp, (len - written)); - - if (ret == -1) { - if (errno == EAGAIN) { - continue; - } - written = -1; - break; - } - - written += ret; - bufp += written; - } - - return (written); -} - -/* - * mk_wc_path() - * - * Function to generate a path name for working copies of - * files and creates the file. - */ -int -mk_wc_path( - char *original, /* IN - path to original file */ - char *tmppath, /* IN/OUT - buffer to hold new file path */ - size_t buflen) /* IN - length of buffer */ -{ - char *copypath; - char template[MAXPATHLEN+1]; - char buf[MAXPATHLEN+1]; - char *fname; - int ret; - struct stat64 statbuf; - - if (!original || !tmppath) { - return (MMS_MGMT_NOARG); - } - - /* make sure target directory exists */ - ret = create_dir(default_tmpfile_dir, 0, NULL, geteuid(), - NULL, getegid()); - if (ret != 0) { - return (ret); - } - - ret = stat64(original, &statbuf); - - /* - * not an error if the original doesn't exist. In this - * case, dummy up a mode to be used for the later mknod. - */ - if (ret != 0) { - statbuf.st_mode = S_IFREG; - statbuf.st_mode |= S_IRWXU|S_IRGRP|S_IROTH; - } - - /* create the template name */ - (void) strlcpy(buf, original, MAXPATHLEN+1); - fname = basename(buf); - (void) snprintf(template, MAXPATHLEN+1, "%s/%s_XXXXXX", - default_tmpfile_dir, fname); - - copypath = mktemp(template); - - if (copypath == NULL) { - return (-1); - } else { - (void) strlcpy(tmppath, copypath, buflen); - } - - /* make sure an old version isn't hanging around */ - (void) unlink(tmppath); - - /* create the target file */ - ret = mknod(tmppath, statbuf.st_mode, 0); - - return (ret); -} - -/* - * make_working_copy() - * - * Copies a file to the default temporary location and returns - * the pathname of the copy. - * - */ -int -make_working_copy(char *path, char *wc_path, int pathlen) -{ - int ret; - - if (!path || !wc_path) { - return (-1); - } - - ret = mk_wc_path(path, wc_path, pathlen); - if (ret != 0) { - return (ret); - } - - ret = cp_file(path, wc_path); - - return (ret); -} - - -typedef struct proclist proclist_t; -struct proclist { - mms_list_node_t next_proc; - psinfo_t *proc; -}; - -/* - * The find_process() function reads through /proc and finds all processes with - * the specified executable name. - * - * PARAM - * exename - INPUT - name of executable - * procs - OUTPUT - list of psinfo_t structs - * - * ERRORS - */ -int -find_process(char *exename, mms_list_t *procs) -{ - DIR *dirp; - dirent64_t *dent; - dirent64_t *dentp; - char pname[MAXPATHLEN]; - char *ptr; - int procfd; /* filedescriptor for /proc/nnnnn/psinfo */ - psinfo_t info; /* process information from /proc */ - int ret = 0; - int len = sizeof (info); - - if (!exename || !procs) { - return (MMS_MGMT_NOARG); - } - - mms_trace(MMS_INFO, "finding all %s processes", exename); - - if ((dirp = opendir(PROCDIR)) == NULL) { - ret = errno; - mms_trace(MMS_ERR, "Could not open %s, %d", PROCDIR, ret); - return (ret); - } - - mms_list_create(procs, sizeof (proclist_t), - offsetof(proclist_t, next_proc)); - - /* allocate the dirent structure */ - dent = malloc(MAXPATHLEN + sizeof (dirent64_t)); - if (dent == NULL) { - (void) closedir(dirp); - mms_list_destroy(procs); - return (ENOMEM); - } - - /* find each active process --- */ - while ((ret = readdir64_r(dirp, dent, &dentp)) == 0) { - - if (dentp == NULL) { - break; - } - - /* skip . and .. */ - if (dentp->d_name[0] == '.') { - continue; - } - - (void) snprintf(pname, MAXPATHLEN, "%s/%s/%s", PROCDIR, - dentp->d_name, "psinfo"); - - procfd = open64(pname, O_RDONLY); - if (procfd == -1) { - /* process may have ended while we were processing */ - continue; - } - - /* - * Get the info structure for the process and close quickly. - */ - ret = readbuf(procfd, &info, len); - - (void) close(procfd); - - if (ret == -1) { - break; - } - - if (info.pr_lwp.pr_state == 0) /* can't happen? */ - continue; - - /* ensure cmd buffers properly terminated */ - info.pr_psargs[PRARGSZ-1] = '\0'; - info.pr_fname[PRFNSZ-1] = '\0'; - - /* is it the proc we're looking for? */ - if (strncmp(info.pr_psargs, exename, strlen(exename)) != 0) { - continue; - } - - ptr = malloc(len); - if (ptr == NULL) { - ret = ENOMEM; - break; - } - (void) memcpy(ptr, &info, len); - mms_list_insert_tail(procs, ptr); - } - - (void) closedir(dirp); - free(dent); - return (ret); -} - -/* - * exec_mgmt_cmd() - * - * Helper functino to exec an external program, optionally returning - * messages written to stdout/stderr and exec()ing as a different UID. - * - * The 'cmd' array must have the executable as the first entry, and *must* - * have a NULL as the last entry. - */ -int -exec_mgmt_cmd( - FILE **outstr, - FILE **errstr, - uid_t euid, - gid_t egid, - boolean_t daemon, - char *cmd[]) -{ - int fdo[2] = {-1, -1}; /* pipe for reading stdout */ - int fde[2] = {-1, -1}; /* pipe for reading stderr */ - pid_t pid; - - /* The path to the executable must be fully-qualified */ - if ((cmd == NULL) || (cmd[0] == NULL) || (cmd[0][0] != '/')) { - mms_trace(MMS_DEBUG, - "validate error"); - return (-1); - } - - if (outstr != NULL) { - if (pipe(fdo) < 0) { - mms_trace(MMS_DEBUG, - "pipe(fdo) error"); - return (-1); - } - } - - if (errstr != NULL) { - if (pipe(fde) < 0) { - mms_trace(MMS_DEBUG, - "pipe(fde) error"); - (void) close(fdo[0]); - (void) close(fdo[1]); - return (-1); - } - } - - if ((pid = fork()) < 0) { - mms_trace(MMS_DEBUG, - "fork() error"); - (void) close(fdo[0]); - (void) close(fdo[1]); - (void) close(fde[0]); - (void) close(fde[1]); - return (-1); - } - - if (pid == 0) { /* child */ - /* redirect stdout and stderr */ - int ret; - - if (!outstr) { - fdo[1] = open("/dev/null", O_WRONLY); - } - - if (!errstr) { - fde[1] = open("/dev/null", O_WRONLY); - } - - if ((fde[1] == -1) || (fdo[1] == -1)) { - mms_trace(MMS_DEBUG, - "(fde[1] == -1) || (fdo[1] == -1) error"); - exit(9); - } - - (void) dup2(fdo[1], STDOUT_FILENO); - (void) dup2(fde[1], STDERR_FILENO); - - (void) close(fdo[0]); - (void) close(fde[0]); - - (void) close(STDIN_FILENO); - - (void) closefrom(3); - - /* set UID if requested */ - if (euid != 0) { - (void) setuid(euid); - } - - if (egid != 0) { - (void) setgid(egid); - } - - if (daemon) { - (void) setsid(); /* become session leader */ - pid = fork(); - if (pid < 0) { - exit(1); - } else if (pid > 0) { - /* parent */ - exit(0); - } - } - - ret = execv(cmd[0], cmd); - - if (0 != ret) { - mms_trace(MMS_DEBUG, - "execv(cmd[0], cmd) error"); - return (ret); - } - } - - /* parent */ - if (outstr) { - (void) close(fdo[1]); - *outstr = fdopen(fdo[0], "r"); - } - - if (errstr) { - (void) close(fde[1]); - *errstr = fdopen(fde[0], "r"); - } - - return (pid); -} - -/* configuration functions */ -void -mgmt_unsetall_cfgvar(void) -{ - (void) mms_cfg_unsetvar(MMS_CFG_CONFIG_TYPE); - (void) mms_cfg_unsetvar(MMS_CFG_MGR_HOST); - (void) mms_cfg_unsetvar(MMS_CFG_MGR_PORT); - (void) mms_cfg_unsetvar(MMS_CFG_SSL_ENABLED); - (void) mms_cfg_unsetvar(MMS_CFG_SSL_CERT_FILE); - (void) mms_cfg_unsetvar(MMS_CFG_SSL_PASS_FILE); - (void) mms_cfg_unsetvar(MMS_CFG_SSL_DH_FILE); - (void) mms_cfg_unsetvar(MMS_CFG_SSL_CRL_FILE); - (void) mms_cfg_unsetvar(MMS_CFG_SSL_PEER_FILE); - (void) mms_cfg_unsetvar(MMS_CFG_SSL_CIPHER); - (void) mms_cfg_unsetvar(MMS_CFG_SSL_VERIFY); - (void) mms_cfg_unsetvar(MMS_CFG_DB_DATA); - (void) mms_cfg_unsetvar(MMS_CFG_DB_LOG); - (void) mms_cfg_unsetvar(MMS_CFG_MM_DB_HOST); - (void) mms_cfg_unsetvar(MMS_CFG_MM_DB_PORT); - (void) mms_cfg_unsetvar(MMS_CFG_MM_DB_NAME); - (void) mms_cfg_unsetvar(MMS_CFG_MM_DB_USER); - (void) mms_cfg_unsetvar(MMS_CFG_SSI_PATH); -} - -int -mgmt_set_svc_state( - char *fmri, - mms_svcstate_t targetState, - char **original) -{ - char *startState = NULL; - char *endState = NULL; - int st = 0; - const char *cmpState; - int i; - - if (fmri == NULL) { - mms_trace(MMS_ERR, "fmri is null"); - return (MMS_MGMT_NOARG); - } - - startState = smf_get_state(fmri); - if (startState == NULL) { - st = scf_error(); - mms_trace(MMS_ERR, "get state %s - %s", fmri, scf_strerror(st)); - /* - * Not an error if request to disable or degrade a - * non-existent svc - */ - if ((targetState == DISABLE) || (targetState == DEGRADE)) { - if (st == SCF_ERROR_NOT_FOUND) { - st = 0; - } - } - return (st); - } - - if (original != NULL) { - *original = startState; - } - - switch (targetState) { - case ENABLE: - cmpState = SCF_STATE_STRING_ONLINE; - if (strcmp(startState, cmpState) != 0) { - st = smf_enable_instance(fmri, 0); - } - break; - case DISABLE: - cmpState = SCF_STATE_STRING_DISABLED; - /* - * can't go directly from maintenance to disabled, - * though I can't see why. - */ - if (strcmp(startState, SCF_STATE_STRING_MAINT) == 0) { - mms_trace(MMS_DEBUG, - "restore before disable %s", - fmri); - st = mgmt_set_svc_state(fmri, RESTORE, NULL); - if (st != 0) { - mms_trace(MMS_ERR, - "failed to restore %s", - fmri); - } - st = smf_disable_instance(fmri, 0); - } - if (strcmp(startState, cmpState) != 0) { - st = smf_disable_instance(fmri, 0); - } - break; - case REFRESH: - /* refresh shouldn't change the current state */ - cmpState = startState; - st = smf_refresh_instance(fmri); - break; - case RESTART: - cmpState = SCF_STATE_STRING_ONLINE; - st = smf_restart_instance(fmri); - break; - case MAINTAIN: - cmpState = SCF_STATE_STRING_MAINT; - st = smf_maintain_instance(fmri, SMF_IMMEDIATE); - break; - case DEGRADE: - /* only available if 'online' */ - if (strcmp(startState, SCF_STATE_STRING_ONLINE) == 0) { - cmpState = SCF_STATE_STRING_DEGRADED; - st = smf_degrade_instance(fmri, 0); - } else { - cmpState = startState; - } - break; - case RESTORE: - /* - * if disabled, returns to online. If maintenance, - * returns to disabled. - */ - if (strcmp(startState, SCF_STATE_STRING_DISABLED) - == 0) { - cmpState = SCF_STATE_STRING_ONLINE; - } else if (strcmp(startState, SCF_STATE_STRING_MAINT) - == 0) { - cmpState = SCF_STATE_STRING_DISABLED; - } else { - /* invalid operation */ - st = EINVAL; - break; - } - st = smf_restore_instance(fmri); - break; - default: - st = -1; - mms_trace(MMS_ERR, "%s unknown action %d", - fmri, targetState); - break; - } - - if (st == 0) { - /* - * Changing state sometimes takes a while and - * the scf service state functions do not wait. - * Check to see if the action was successul. - */ - st = 1; - for (i = 0; i < 10; i++) { - endState = smf_get_state(fmri); - if (endState == NULL) { - st = scf_error(); - mms_trace(MMS_ERR, - "wait for state change %s - %s", - fmri, scf_strerror(st)); - break; - } else if (strcmp(endState, cmpState) == 0) { - st = 0; - break; - } - free(endState); - endState = NULL; - (void) sleep(1); - } - } else if (st != -1) { - st = scf_error(); - mms_trace(MMS_ERR, "state change %s - %s", - fmri, scf_strerror(st)); - } - - if ((startState != NULL) && (original == NULL)) { - free(startState); - } - if (endState != NULL) { - free(endState); - } - - return (st); -} - -int -check_exit(pid_t pid, int *signo) -{ - pid_t wpid; - int pst; - int st = EINVAL; - - if (pid == (pid_t)-1) { - return (st); - } - - wpid = waitpid(pid, &pst, 0); - - if (wpid != pid) { - st = errno; - } else { - if (WIFEXITED(pst)) { - st = WEXITSTATUS(pst); - } else if (WIFSIGNALED(pst)) { - st = EINTR; - if (signo) { - *signo = WTERMSIG(pst); - } - } else if (WCOREDUMP(pst)) { - st = EINTR; - if (signo) { - *signo = SIGSEGV; - } - } - } - return (st); -} - -/* Helper function for MMS lists */ -void -mms_list_free_and_destroy(mms_list_t *list, void (*free_func)(void *)) -{ - mms_list_node_t *node; - - if (!list || !free_func || (list->list_size == 0)) { - return; - } - - while (! mms_list_empty(list)) { - node = mms_list_head(list); - - mms_list_remove(list, node); - free_func(node); - } - - mms_list_destroy(list); -} - -/* helper functions to validate option values */ -int -val_numonly(char *val) -{ - int st = 0; - char *bufp; - - if (!val) { - return (MMS_MGMT_NOARG); - } - - for (bufp = val; *bufp != '\0'; bufp++) { - if (*bufp == '-') { - /* negative number */ - continue; - } - if (!isdigit(*bufp)) { - st = EINVAL; - break; - } - } - - return (st); -} - -int -val_passwd(char *val) -{ - if (!val) { - return (MMS_MGMT_NOARG); - } else if (strlen(val) < 8) { - return (EINVAL); - } else { - return (0); - } -} - -int -val_objtype(char *val) -{ - if (!val) { - return (MMS_MGMT_NOARG); - } - - if ((strcmp(val, "client") == 0) || - (strcmp(val, "server") == 0) || - (strcmp(val, "library") == 0) || - (strcmp(val, "drive") == 0) || - (strcmp(val, "dpool") == 0) || - (strcmp(val, "mpool") == 0) || - (strcmp(val, "app") == 0) || - (strcmp(val, "alarm") == 0) || - (strcmp(val, "vol") == 0) || - (strcmp(val, "voltype") == 0)) { - return (0); - } else { - return (EINVAL); - } -} - -int -val_path(char *val) -{ - if (!val) { - return (MMS_MGMT_NOARG); - } - - if (*val != '/') { - return (EINVAL); - } - - return (0); -} - -int -val_level(char *val) -{ - if (!val) { - return (MMS_MGMT_NOARG); - } - - if ((strcmp(val, "emergency") == 0) || - (strcmp(val, "alert") == 0) || - (strcmp(val, "critical") == 0) || - (strcmp(val, "error") == 0) || - (strcmp(val, "warning") == 0) || - (strcmp(val, "notice") == 0) || - (strcmp(val, "information") == 0) || - (strcmp(val, "debug") == 0)) { - return (0); - } else { - return (EINVAL); - } -} - -int -val_yesno(char *val) -{ - if (!val) { - return (MMS_MGMT_NOARG); - } - - if (*val == 'y' || *val == 'Y' || *val == 'n' || *val == 'N') { - return (0); - } else { - return (EINVAL); - } -} - -int -val_truefalse(char *val) -{ - if (!val) { - return (MMS_MGMT_NOARG); - } - - if ((strcmp(val, "true") == 0) || (strcmp(val, "false") == 0)) { - return (0); - } else { - return (EINVAL); - } -} - -int -val_mms_size(char *val) -{ - return (do_val_mms_size(val, NULL)); -} - -int -do_val_mms_size(char *val, uint64_t *bytes) -{ - uint64_t sz = 0; - char *unit = NULL; - uint64_t mult = 1; - - if (!val) { - return (MMS_MGMT_NOARG); - } - - sz = strtoll(val, &unit, 10); - if ((sz == LONG_MAX) || (sz == LONG_MIN)) { - return (EINVAL); - } - - if (unit) { - switch (*unit) { - case 'b': - case 'B': - mult = 1; - break; - case 'k': - case 'K': - mult = KILO; - break; - case 'm': - case 'M': - mult = MEGA; - break; - case 'g': - case 'G': - mult = GIGA; - break; - case 't': - case 'T': - mult = TERA; - break; - case 'p': - case 'P': - mult = PETA; - break; - default: - return (EINVAL); - break; - } - } - - if (bytes) { - *bytes = sz * mult; - } - - return (0); -} - -int -val_density(char *val) -{ - if (!val) { - return (MMS_MGMT_NOARG); - } - - if ((strcmp(val, "den_9840C") == 0) || - (strcmp(val, "den_9840") == 0) || - (strcmp(val, "den_LTO4") == 0) || - (strcmp(val, "den_LTO3") == 0) || - (strcmp(val, "den_LTO2") == 0) || - (strcmp(val, "den_LTO1") == 0)) { - return (0); - } - - return (EINVAL); -} - -int -mms_mgmt_get_pwd(char *pwfile, char *key, char *phrase[2], nvlist_t *nvl, - nvlist_t *errs) -{ - int st = 0; - char *mpwp; - char *chkpw; - char buf[512]; - int fd; - size_t sz; - - if (!key || !nvl) { - return (MMS_MGMT_NOARG); - } - - if (pwfile != NULL) { - fd = open(pwfile, O_RDONLY); - if (fd == -1) { - st = errno; - if (errs) { - (void) nvlist_add_int32(errs, pwfile, st); - } - return (st); - } - - sz = readbuf(fd, buf, sizeof (buf)); - (void) close(fd); - - buf[sz] = '\0'; - - while ((sz > 1) && (isspace(buf[sz - 1]))) { - buf[sz -1] = '\0'; - sz--; - } - - mpwp = buf; - if (strlen(mpwp) < 8) { - return (MMS_MGMT_PASSTOOSHORT); - } - } else { - if ((!phrase) || (!phrase[0])) { - return (MMS_MGMT_NOARG); - } - - mpwp = getpassphrase(phrase[0]); - if (mpwp == NULL) { - return (MMS_MGMT_GETPASS_FAILED); - } else if (strlen(mpwp) < 8) { - return (MMS_MGMT_PASSTOOSHORT); - } - - /* getpassphrase overwrites previous result, so save first */ - (void) strlcpy(buf, mpwp, sizeof (buf)); - mpwp = buf; - - /* verify entered password if required */ - if (phrase[1]) { - chkpw = getpassphrase(phrase[1]); - if ((chkpw == NULL) || (strcmp(mpwp, chkpw) != 0)) { - return (MMS_MGMT_PASSWD_MISMATCH); - } - } - } - - st = nvlist_add_string(nvl, key, mpwp); - return (0); -} - -/* - * Helper function to generate the MMP 'create' clause for the specified - * object. - */ -int -create_mmp_clause(char *objtype, mms_mgmt_setopt_t *opts, nvlist_t *inopts, - nvlist_t *errs, char *cmd, size_t cmdlen) -{ - int st = 0; - int ost = 0; - char tid[64]; - char buf[1024]; - char *val; - int i; - - if (!objtype || !opts || !buf || !inopts) { - return (MMS_MGMT_NOARG); - } - - (void) mms_gen_taskid(tid); - - (void) snprintf(cmd, cmdlen, "create task['%s'] type[%s]", tid, - objtype); - - for (i = 0; opts[i].name != NULL; i++) { - if (opts[i].mmpopt == NULL) { - continue; - } - ost = nvlist_lookup_string(inopts, opts[i].name, &val); - if (ost == ENOENT) { - if (opts[i].required) { - if (opts[i].defval) { - val = opts[i].defval; - ost = 0; - } - } else { - ost = 0; - continue; - } - } - if (ost != 0) { - MGMT_ADD_OPTERR(errs, opts[i].name, ost); - if (st == 0) { - st = ost; - } - continue; - } - (void) snprintf(buf, sizeof (buf), " set[%s.'%s' '%s']", - objtype, opts[i].mmpopt, val); - (void) strlcat(cmd, buf, cmdlen); - } - - (void) strlcat(cmd, ";\n", cmdlen); - - return (st); -} - -int -mms_add_object(void *session, char *objtype, mms_mgmt_setopt_t *objopts, - nvlist_t *nvl, nvlist_t *errs) -{ - void *response = NULL; - int st; - char tid[64]; - char cmd[8192]; - void *sess = NULL; - void *sessp = session; - - if (!objtype || !objopts || !nvl) { - return (MMS_MGMT_NOARG); - } - - if (session == NULL) { - st = create_mm_clnt(NULL, NULL, NULL, NULL, &sess); - if (st != 0) { - return (st); - } - sessp = sess; - } - - st = create_mmp_clause(objtype, objopts, nvl, errs, cmd, sizeof (cmd)); - if (st == 0) { - st = mms_mgmt_send_cmd(sessp, tid, cmd, "mms_add_object()", - &response); - - mms_free_rsp(response); - } - - if (sess) { - (void) mms_goodbye(sess, 0); - } - - return (st); -} - -int -mms_mgmt_send_cmd(void *sess, char *tid, char *cmd, char *pfx, void **response) -{ - int st = 0; - - if (!sess || !tid || !cmd || !pfx || !response) { - return (MMS_MGMT_NOARG); - } - - mms_trace(MMS_DEBUG, "%s request command: %s", pfx, cmd); - - if ((st = mms_send_cmd(sess, cmd, response)) != 0) { - st = MMS_MGMT_MMP_PARSE_ERR; - mms_trace(MMS_ERR, "%s send command failed with %d", pfx, - st); - } else { - mms_trace(MMS_DEBUG, "Response[%s]: %s", - tid, ((mms_rsp_ele_t *)(*response))->mms_rsp_str); - - if ((st = mms_client_handle_rsp(*response)) != MMS_API_OK) { - mms_trace(MMS_ERR, "%s response failed", pfx); - } - } - - return (st); -} - -int -mgmt_find_changed_attrs(char *objtype, mms_mgmt_setopt_t *opts, - nvlist_t *nvl, char **carray, int *count, nvlist_t *errs) -{ - int st = 0; - int ost = 0; - int i; - - if (!objtype || !opts || !nvl || !carray || !count) { - return (MMS_MGMT_NOARG); - } - - *count = 0; - - for (i = 0; opts[i].name != NULL; i++) { - if (strcmp(opts[i].name, "name") == 0) { - continue; - } - ost = nvlist_lookup_string(nvl, opts[i].name, &carray[i]); - if (ost == 0) { - if (opts[i].validate_func) { - ost = (opts[i].validate_func)(carray[i]); - if (ost != 0) { - if (st == 0) { - st = ost; - } - MGMT_ADD_OPTERR(errs, opts[i].name, - ost); - carray[i] = NULL; - continue; - } - } - (*count)++; - } - } - - return (st); -} - -void -cmp_mmp_opts(mms_mgmt_setopt_t *opts, char **carray, nvlist_t *nva, int *count) -{ - int i; - int ost; - char *val; - - if (!opts || !carray || !nva || !count) { - return; - } - - for (i = 0; opts[i].name != NULL; i++) { - if (carray[i] == NULL) { - continue; - } - ost = nvlist_lookup_string(nva, opts[i].mmpopt, &val); - if (ost != 0) { - continue; - } - if (strcmp(val, carray[i]) == 0) { - /* value identical */ - carray[i] = NULL; - (*count)--; - } - } -} - -void -mk_set_clause(char *objtype, mms_mgmt_setopt_t *opts, char **carray, - char *buf, int buflen) -{ - int i; - char phrase[1024]; - - if (!objtype || !opts || !carray || !buf) { - return; - } - - for (i = 0; opts[i].name != NULL; i++) { - if (carray[i] == NULL) { - continue; - } - (void) snprintf(phrase, sizeof (phrase), - " set[%s.'%s' '%s']", - objtype, opts[i].mmpopt, carray[i]); - (void) strlcat(buf, phrase, buflen); - } -} - -char ** -mgmt_var_to_array(nvlist_t *nvl, char *optname, int *count) -{ - int st; - data_type_t nvt; - nvpair_t *nvp = NULL; - char **arr = NULL; - char *val = NULL; - char **aval = NULL; - int i; - - if (!nvl || !optname || !count) { - return (NULL); - } - - *count = 0; - - st = nvlist_lookup_nvpair(nvl, optname, &nvp); - if (nvp == NULL) { - return (NULL); - } - - nvt = nvpair_type(nvp); - - if (nvt == DATA_TYPE_STRING) { - st = nvpair_value_string(nvp, &val); - if (st == 0) { - *count = 1; - arr = malloc(sizeof (char *)); - if (arr != NULL) { - arr[0] = strdup(val); - } - } - } else if (nvt == DATA_TYPE_STRING_ARRAY) { - st = nvpair_value_string_array(nvp, &aval, (uint_t *)count); - if ((st == 0) && (*count > 0)) { - arr = malloc(sizeof (char *) * *count); - if (arr != NULL) { - for (i = 0; i < *count; i++) { - arr[i] = strdup(aval[i]); - } - } - } - } - - return (arr); -} - -void -mgmt_free_str_arr(char **inarr, int count) -{ - int i; - - if (!inarr) { - return; - } - - for (i = 0; i < count; i++) { - if (inarr[i]) { - free(inarr[i]); - } - } - - free(inarr); -} - -int -mgmt_opt_to_var(char *in_str, boolean_t allow_empty, nvlist_t *nvl) -{ - int st; - char *bufp; - char *wstr; - - if (!in_str || !nvl) { - return (MMS_MGMT_NOARG); - } - - wstr = strdup(in_str); - if (!wstr) { - return (ENOMEM); - } - - bufp = strchr(wstr, '='); - if (!bufp) { - return (MMS_MGMT_NOARG); - } - *bufp++ = '\0'; - - st = mgmt_set_str_or_arr(bufp, wstr, nvl); - if (st != 0) { - if (st == ENOENT) { - if (allow_empty) { - /* common for 'list' options */ - st = 0; - (void) nvlist_add_string(nvl, wstr, ""); - } - } - } - - free(wstr); - - return (st); -} - -int -mgmt_set_str_or_arr(char *inargs, char *key, nvlist_t *nvl) -{ - int st; - char *bufp; - int count; - char **tmparr; - - if (!inargs || !key || !nvl) { - return (MMS_MGMT_NOARG); - } - - bufp = inargs; - count = 1; - - for (;;) { - bufp = strchr(bufp, ','); - if (bufp == NULL) { - break; - } - bufp++; - count++; - } - - if (count == 1) { - st = nvlist_add_string(nvl, key, inargs); - } else { - tmparr = calloc(count, sizeof (char *)); - if (tmparr == NULL) { - return (ENOMEM); - } - bufp = inargs; - /* set delimiter to comma */ - (void) bufsplit(",", 0, NULL); - - (void) bufsplit(bufp, count, tmparr); - st = nvlist_add_string_array(nvl, key, tmparr, count); - free(tmparr); - } - - return (st); -} - -int -mgmt_xlate_cfgerr(scf_error_t in_err) -{ - int st; - - switch (in_err) { - case SCF_ERROR_NOT_SET: - case SCF_ERROR_NOT_FOUND: - case SCF_ERROR_DELETED: - st = ENOENT; - break; - case SCF_ERROR_NO_MEMORY: - st = ENOMEM; - break; - case SCF_ERROR_TYPE_MISMATCH: - st = EINVAL; - break; - default: - st = in_err; - break; - } - - return (st); -} - -int -mgmt_compare_hosts(char *host1, char *host2) -{ - int st; - struct addrinfo *res1 = NULL; - struct addrinfo *res2 = NULL; - struct addrinfo *p1 = NULL; - struct addrinfo *p2 = NULL; - boolean_t match = B_FALSE; - int a; - - if (!host1 || !host2) { - return (MMS_MGMT_NOARG); - } - - st = getaddrinfo(host1, NULL, NULL, &res1); - if (st != 0) { - return (st); - } - - st = getaddrinfo(host2, NULL, NULL, &res2); - if (st != 0) { - freeaddrinfo(res1); - return (st); - } - - for (p1 = res1; p1 != NULL; p1 = p1->ai_next) { - for (p2 = res2; p2 != NULL; p2 = p2->ai_next) { - a = memcmp(p1->ai_addr, p2->ai_addr, - sizeof (struct sockaddr)); - if (a == 0) { - match = B_TRUE; - break; - } - if (memcmp(p1->ai_addr, p2->ai_addr, - sizeof (struct sockaddr)) == 0) { - match = B_TRUE; - break; - } - } - } - - if (res1) { - freeaddrinfo(res1); - } - if (res2) { - freeaddrinfo(res2); - } - - if (match) { - return (0); - } - - return (1); -} - -const char * -mms_mgmt_get_errstr(int errcode) -{ - int i; - int max_err = sizeof (mms_mgmt_errs) / sizeof (mms_sym_t); - static char msg[1024]; - - /* standard errors */ - if (errcode < 256) { - return (strerror(errcode)); - } - - /* SCF errors */ - if ((errcode >= 1000) && (errcode < 1020)) { - return (scf_strerror(errcode)); - } - - if ((errcode > MMS_MGMT_ERR_OFFSET) && - (errcode < MMS_MGMT_LAST_ERR_CODE)) { - for (i = 0; i < max_err; i++) { - if (mms_mgmt_errs[i].sym_code == errcode) { - return (mms_mgmt_errs[i].sym_token); - } - } - (void) snprintf(msg, sizeof (msg), "Unknown err code %d", - errcode); - return (msg); - } - - if (errcode >= MMS_ERR_BIAS) { - return (mms_sym_code_to_str(errcode)); - } - - return (NULL); -} - -int -mgmt_chk_auth(char *authname) -{ - int st; - struct passwd pwd; - struct passwd *pwdp; - char buf[1024]; - - if (!authname) { - return (1); - } - - st = getpwuid_r(getuid(), &pwd, buf, sizeof (buf), &pwdp); - - if (st != 0) { - /* fail if we can't determine the username */ - return (0); - } - - st = chkauthattr(authname, pwdp->pw_name); - - return (st); -} - -void -mgmt_filter_results(nvlist_t *filter, nvlist_t *nvl) -{ - int st; - int count; - char **varray; - nvpair_t *nvp; - char *key; - data_type_t nvt; - boolean_t do_filter = B_FALSE; - - if (!filter || !nvl) { - /* not a failure if nothing to do */ - return; - } - - st = nvlist_lookup_boolean_value(filter, "filter", &do_filter); - if ((st != 0) || !do_filter) { - return; - } - - nvp = NULL; - while ((nvp = nvlist_next_nvpair(filter, nvp)) != NULL) { - key = nvpair_name(nvp); - - if ((strcmp(key, "printopts") == 0) || - (strcmp(key, "name") == 0) || - (strcmp(key, "objtype") == 0)) { - continue; - } - - nvt = nvpair_type(nvp); - if ((nvt != DATA_TYPE_STRING_ARRAY) && - (nvt != DATA_TYPE_STRING)) { - continue; - } - - varray = mgmt_var_to_array(filter, key, &count); - filter_on_var(key, varray, count, nvl); - mgmt_free_str_arr(varray, count); - } -} - -static void -filter_on_var(char *varname, char **varray, int count, nvlist_t *nvl) -{ - int st; - uint_t vcount; - char **arr; - nvpair_t *nvp = NULL; - nvlist_t *attrs; - char *val; - data_type_t nvt; - int i; - int j; - nvpair_t *fnvp; - char *attrname; - nvpair_t *lastnvp = NULL; - boolean_t keep; - - if (!varname || (count == 0) || !nvl) { - return; - } - - - while ((nvp = nvlist_next_nvpair(nvl, nvp)) != NULL) { - st = nvpair_value_nvlist(nvp, &attrs); - if (st != 0) { - continue; - } - - attrname = nvpair_name(nvp); - - st = nvlist_lookup_nvpair(attrs, varname, &fnvp); - if (st != 0) { - /* no match, remove it */ - (void) nvlist_remove_all(nvl, attrname); - nvp = lastnvp; - continue; - } - - keep = B_FALSE; - - nvt = nvpair_type(fnvp); - - val = NULL; - if (nvt == DATA_TYPE_STRING) { - (void) nvpair_value_string(fnvp, &val); - if (val) { - for (i = 0; i < count; i++) { - if (strcmp(val, varray[i]) == 0) { - /* a keeper */ - keep = B_TRUE; - break; - } - } - } - } else if (nvt == DATA_TYPE_STRING_ARRAY) { - st = nvpair_value_string_array(fnvp, &arr, &vcount); - if (st == 0) { - for (j = 0; j < vcount; j++) { - for (i = 0; i < count; i++) { - if (strcmp(val, varray[i]) - == 0) { - /* a keeper */ - keep = B_TRUE; - break; - } - } - if (keep) { - break; - } - } - } - } - - if (keep) { - lastnvp = nvp; - } else { - (void) nvlist_remove_all(nvl, attrname); - nvp = lastnvp; - } - } -} diff --git a/usr/src/lib/mms/mgmt/common/mgmt_util.h b/usr/src/lib/mms/mgmt/common/mgmt_util.h deleted file mode 100644 index ccb35918c1..0000000000 --- a/usr/src/lib/mms/mgmt/common/mgmt_util.h +++ /dev/null @@ -1,257 +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 _MGMT_UTIL_H -#define _MGMT_UTIL_H - - -#include <sys/types.h> -#include <stdio.h> -#include <limits.h> -#include <libnvpair.h> -#include <libscf.h> -#include <sys/statvfs.h> - -#include "mms.h" -#include "mgmt_sym.h" - -/* Generic parsing constant */ -#define WHITESPACE " \11\12\15" - -/* define commonly used string lengths */ -#define MAXSERIALNUMLEN MAXNAMELEN - -/* define commonly-used paths */ -#define PROCDIR "/proc" -#define TAPEDEVDIR "/dev/rmt" - -#define TMP_DIR "/tmp" -#define default_tmpfile_dir TMP_DIR /* TBD: change this location */ - -/* define commonly used sizes */ -#define KILO (uint64_t)(1024LL) -#define MEGA (uint64_t)(1024LL * 1024) -#define GIGA (uint64_t)(1024LL * 1024 * 1024) -#define TERA (uint64_t)(1024LL * 1024 * 1024 * 1024) -#define PETA (uint64_t)(1024LL * 1024 * 1024 * 1024 * 1024) -#define EXA (uint64_t)(1024LL * 1024 * 1024 * 1024 * 1024 * 1024) - - -/* SMF service states */ -typedef enum { - ENABLE, - DISABLE, - REFRESH, - RESTART, - MAINTAIN, - DEGRADE, - RESTORE -} mms_svcstate_t; - -/* data structures for setting options */ - -typedef struct { - char *name; - char *mmpopt; - char *defval; - boolean_t required; - int (*validate_func)(char *val); -} mms_mgmt_setopt_t; - -#define MGMT_ADD_ERR(errs, opt, in_err) { \ - if (errs) { \ - (void) nvlist_add_int32(errs, opt, in_err); \ - } \ -} - -#define MGMT_ADD_OPTERR(errs, opt, in_err) { \ - if (in_err == ENOENT) { \ - in_err = MMS_MGMT_ERR_REQUIRED; \ - } \ - MGMT_ADD_ERR(errs, opt, in_err) \ -} - -/* function prototypes */ - -int -exec_mgmt_cmd( - FILE **outstr, - FILE **errstr, - uid_t euid, - gid_t egid, - boolean_t daemon, - char *cmd[]); - -int -check_exit(pid_t pid, int *signo); - -/* - * mms_gen_taskid() - * - * Parameters: - * - tid unique task identifier - * - * This function returns a task identifier (TID). All responses to an MMP - * command will include the TID of the initiating command. The TID will be - * unique in the context of a session so that the client can determine which - * responses go with which command. tid must be a buffer of at least 128 bytes. - */ -int mms_gen_taskid(char *tid); - -/* - * create_mm_clnt() - */ -int -create_mm_clnt(char *app, char *inst, char *pass, char *tag, void **session); - -int -mgmt_set_svc_state( - char *fmri, - mms_svcstate_t targetState, - char **original); - -int -create_dir(char *dir, mode_t perms, char *user, uid_t uid, char *group, - gid_t gid); - -int cp_file( - const char *old, - const char *new); - -/* helper function to use read() correctly */ -int -readbuf(int fd, void* buffer, int len); - -/* - * mk_wc_path() - * - * Function to generate a path name for working copies of - * files and creates the file. - */ -int -mk_wc_path( - char *original, /* IN - path to original file */ - char *tmppath, /* IN/OUT - buffer to hold new file path */ - size_t buflen); /* IN - length of buffer */ - - -/* - * make_working_copy() - * - * Copies a file to the default temporary location and returns - * the pathname of the copy. - * - */ -int -make_working_copy(char *path, char *wc_path, int pathlen); - -int -find_process(char *exename, mms_list_t *procs); - -void -mgmt_unsetall_cfgvar(void); - -int -mgmt_xlate_cfgerr(scf_error_t in_err); - -/* helper function for MMS lists */ -void -mms_list_free_and_destroy(mms_list_t *, void (*)(void *)); - -/* helper validation functions */ -int val_numonly(char *val); -int val_passwd(char *val); -int val_objtype(char *val); -int val_path(char *val); -int val_level(char *val); -int val_yesno(char *val); -int val_truefalse(char *val); -int val_mms_size(char *val); -int do_val_mms_size(char *val, uint64_t *bytes); -int val_density(char *val); - - -/* MMP helper functions */ -int -mms_mgmt_send_cmd(void *sess, char *tid, char *cmd, char *pfx, void **response); - -int -mmp_get_nvattrs(char *key, boolean_t useropt, void *response, nvlist_t **nvl); - -int -mmp_get_nvattrs_array(char *key, boolean_t useropt, - void *response, nvlist_t *nvl); - -int -mms_mgmt_mmp_count(void *response, uint32_t *count); - -int -create_mmp_clause(char *objtype, mms_mgmt_setopt_t *opts, nvlist_t *inopts, - nvlist_t *errs, char *cmd, size_t cmdlen); -int -mms_add_object(void *session, char *objtype, mms_mgmt_setopt_t *objopts, - nvlist_t *nvl, nvlist_t *errs); - -int -mgmt_find_changed_attrs(char *objtype, mms_mgmt_setopt_t *opts, nvlist_t *nvl, - char **carray, int *count, nvlist_t *errs); - -void -mk_set_clause(char *objtype, mms_mgmt_setopt_t *opts, char **carray, - char *buf, int buflen); - -void -cmp_mmp_opts(mms_mgmt_setopt_t *opts, char **carray, nvlist_t *nva, int *count); - -char ** -mgmt_var_to_array(nvlist_t *nvl, char *optname, int *count); - -void -mgmt_free_str_arr(char **inarr, int count); - -int -mgmt_opt_to_var(char *in_str, boolean_t allow_empty, nvlist_t *nvl); - -int -mgmt_set_str_or_arr(char *inargs, char *key, nvlist_t *nvl); - -int write_buf(int fd, void* buffer, int len); - -int -mgmt_compare_hosts(char *host1, char *host2); - -const char * -mms_mgmt_get_errstr(int errcode); - -int -mgmt_chk_auth(char *authname); - -int -mms_mgmt_get_pwd(char *pwfile, char *key, char *phrase[2], nvlist_t *nvl, - nvlist_t *errs); - -void -mgmt_filter_results(nvlist_t *filter, nvlist_t *nvl); - -#endif /* _MGMT_UTIL_H */ diff --git a/usr/src/lib/mms/mgmt/common/mmp_defs.h b/usr/src/lib/mms/mgmt/common/mmp_defs.h deleted file mode 100644 index 61e481a6de..0000000000 --- a/usr/src/lib/mms/mgmt/common/mmp_defs.h +++ /dev/null @@ -1,78 +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 _MMP_DEFS_H -#define _MMP_DEFS_H - - -/* - * mmp_def.h - private header file - * This header contains the definitions used in the MMP protocol. The MMS - * client will communicate with the MM using the MMP - */ - -#include <stdio.h> -#include <sys/nvpair.h> - -#include "mms.h" -#include "mgmt_util.h" -#include "mgmt_library.h" -#include "mgmt_media.h" - -/* - * All requests to the MM, including access to media, device management - * functions, routine operational functions and MMS administration are done - * using the MMP protocol. - * - * The MMP is made up of command type, object type and its attributes. MMP - * supports a rich range of commands which fall into several different - * categories such as attribute, cancel, create, deallocate, delete, goodbye, - * locale, privilege, rename, show, accept, begin-end, cpattribute, cpscan, - * cpshow, cpreset, eject, inject, mount, move, release, respond, shutdown - * and unmount. The build_mmp() function only supports the attribute, create, - * delete and show commands at this time. - * - * The MMS defines more than 40 types of objects that make up a media - * environment. However this management library is only interested in the - * following objects:- - * drive, dm, drivegroup, drivegroupapplication, slottype, cartridge, - * cartridgegroup, and cartridgegroupapplication - */ - -int mms_client_handle_rsp(void *rsp); - -void mmp_parse_lib_attr(mms_par_node_t *node, mms_acslib_t *lib); -void mmp_parse_lm_attr(mms_par_node_t *node, mms_lm_t *lm); -void mmp_parse_drive_attr(mms_par_node_t *node, mms_drive_t *drive); -void mmp_parse_dm_attr(mms_par_node_t *node, mms_dm_t *dm); - -int mmp_parse_library_rsp(void *rsp, mms_list_t *list); -int mmp_parse_lm_rsp(void *rsp, mms_list_t *list); -int mmp_parse_drive_rsp(void *rsp, mms_list_t *list); -int mmp_parse_dm_rsp(void *rsp, mms_list_t *list); - -int mmp_parse_app_rsp(void *rsp, mms_list_t *list); -int mmp_parse_rsp(void *resp, mms_list_t *list); - -#endif /* _MMP_DEFS_H */ diff --git a/usr/src/lib/mms/mgmt/common/mms_mgmt.h b/usr/src/lib/mms/mgmt/common/mms_mgmt.h deleted file mode 100644 index c1f43c5eb4..0000000000 --- a/usr/src/lib/mms/mgmt/common/mms_mgmt.h +++ /dev/null @@ -1,391 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -#ifndef _MMS_MGMT_H_ -#define _MMS_MGMT_H_ - - -#include <sys/types.h> -#include <sys/param.h> -#include <netdb.h> -#include <pwd.h> -#include <libnvpair.h> - -#include "mms_list.h" /* temporary, change over to nvlists */ - -/* MMS Options and Default Values */ - -/* All MMS configurable options for all objects */ - -#define O_MMHOST "mmhost" -#define O_MMPORT "port" -#define O_MMPASS "password" -#define O_OBJTYPE "objtype" -#define O_SECURECOMM "secure-comm" -#define O_SSLENABLED "sslenabled" -#define O_SSLPASSFILE "sslpassfile" -#define O_CERTFILE "certfile" -#define O_CRLFILE "crlfile" -#define O_PEERFILE "peerfile" -#define O_WELCOME "welcomefile" -#define O_DHFILE "dhfile" -#define O_VERIFY "verify" -#define O_LOGLEVEL "log-level" -#define O_LOGFILE "log-file" -#define O_DBDIR "db-dir" -#define O_DBPORT "db-port" -#define O_DBLOG "db-log" -#define O_DBNAME "dbname" -#define O_DBHOST "dbhost" -#define O_NUMRESTART "num-restarts" -#define O_ATTENDED "attended" -#define O_NUMSOCKET "num-socket" -#define O_DKTIMEOUT "disk-timeout" -#define O_SERIALNO "serialno" -#define O_ACSHOST "acsls" -#define O_ACSPORT "acsport" -#define O_OBJSTATE "state" -#define O_MSGLEVEL "msg-level" -#define O_TRACELEVEL "trace-level" -#define O_TRACESZ "trace-file-size" -#define O_MMSLIB "library" -#define O_DEVCONN "connection" -#define O_LIBCONN "libconntype" -#define O_APPS "apps" -#define O_UNLOADTM "unload-time" -#define O_RESERVE "reserve" -#define O_RETENTION "retain" -#define O_VALIDATEEXP "validate-expiration" -#define O_VALIDATEVOL "validate-volid" -#define O_VALIDATEFN "validate-filename" -#define O_OVERWRITEEXT "overwrite-existing" -#define O_RESPTXT "responsetxt" -#define O_FORCE "force" -#define O_MPOOL "mpool" -#define O_DPOOL "dpool" -#define O_HOST "host" -#define O_UNCFG "uncfg" -#define O_NAME "name" -#define O_ACSNUM "acs" -#define O_LSMNUM "lsm" -#define O_LMNAME "lmname" -#define O_DMNAME "dmname" -#define O_MMSDRV "drive" -#define O_TYPE "hwtype" -#define O_ONLINE "online" -#define O_DISABLED "disabled" -#define O_VOLUMES "volumes" -#define O_DEVPATH "devpath" -#define O_SIZE "size" -#define O_MTYPE "mediatype" -#define O_VOLTYPE "voltype" -#define O_ACSLSDIR "acslsdir" -#define O_DENSITY "density" -#define O_NOWAIT "nowait" -#define O_NOREWIND "norewind" -#define O_NOMOUNT O_NOREWIND /* used in mmsadm label */ -#define O_DFLTPATH "dkpath" -/* helpers for MMS services */ -#define MM 0x00000001 -#define WCR 0x00000002 -#define DB 0x00000004 - -#if 0 -#define MMSVC "svc:/application/management/mms:mm" -#define WCRSVC "svc:/application/management/mms:wcr" -#define DBSVC "svc:/application/management/mms:db" -#endif -#define MMSVC MMS_CFG_MM_INST -#define WCRSVC MMS_CFG_WCR_INST -#define DBSVC MMS_CFG_DB_INST - -/* defaults */ -#define MMSSBINDIR "/usr/bin" -#define MMSVARDIR "/var/mms" -#define MMSETCDIR "/etc/mms" -#define MMSSSLDIR "/var/mms/ssl/pub" -#define MMSLOGDIR MMSVARDIR"/logs" -#define MMS_DEF_DBDIR MMSVARDIR"/db" -#define MMS_DEF_MMPORT "7151" -#define MMS_DEF_DBPORT "7656" -#define MMS_DEF_LOGLVL "error" - -/* - * mms_mgmt_init_host() - * - * DESCRIPTION: - * Sets all required MMS options, and starts required services. - * - * On an MMS client system, - * sets MM host, port and administrative password - * sets SSL options, if desired - * starts the Watcher daemon - * - * On on MMS server system, - * creates MMS database admin user - * initializes MMS database and starts database server - * sets MM options [TBD: list these with explanation] - * starts MM daemon and Watcher daemon - * - * ARGUMENTS: - * nvlist_t *opts key/value pairs for requested options - * nvlist_t **errs optional - used to return detailed errors - * about invalid/missing options, and other - * operational failures during initialization. - * If 'errs' is non-NULL, a new nvlist will be - * allocated. The caller should free this list - * with nvlist_free(). - * - * RETURN VALUES: - * - * 0 Success - * MMS_MGMT_NOARG 'opts' argument missing - * EINVAL One or more requested options is invalid - * EALREADY Host has already been initialized for MMS - * ENOMEM Out of memory - * [others TBD] - */ - -int -mms_mgmt_init_host(nvlist_t *opts, nvlist_t **errs); - -/* - * Required opts that are not in inopts, and options with invalid values - * are added to the argument nvlist "errlist". - */ -int mms_mgmt_set_opts(nvlist_t *optlist, nvlist_t *errlist); - -/* - * mms_mgmt_get_opts(char* type, nvlist_t **opts) - */ -int -mms_mgmt_get_opts(char *type, nvlist_t **opts); - - -int mms_mgmt_uninitialize(void); - -/* MMS Database Functions */ -int -mgmt_set_db_opts(nvlist_t *opts, nvlist_t *errlist); - -int -mgmt_db_init(void); - -int -mgmt_db_create(int initialize, int populate, nvlist_t *optlist); - -int -mgmt_db_drop(void); - -int -mgmt_db_ready(void); - -int -mgmt_db_check(void); - -int -mgmt_db_dump(char *dumpdir, char *dumpfile, int len); - -int -mgmt_db_restore(char *dumpfile); - -/* Library and Drive functions */ -/* - * mms_mgmt_discover_libraries() - * - * Finds ACSLS libraries, and optionally associated drives. - * Those already configured for use with MMS are filtered out unless - * 'showall' is TRUE. - */ -int -mms_mgmt_discover_libraries( - char *acshost, boolean_t getdrives, mms_list_t *liblist); - -void free_drive_list(void *arg); -void free_acslib_list(void *arg); - -/* Online/Offline functions */ -int -mms_mgmt_set_state(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_mgmt_add_application(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_mgmt_remove_application(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_mgmt_modify_application(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_mgmt_discover_media( - void *session, boolean_t showall, nvlist_t *opts, mms_list_t *vol_list, - nvlist_t *errs); - -int -mms_mgmt_add_mpool(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_mgmt_add_dpool(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_mgmt_modify_mpool(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_mgmt_modify_dpool(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_mgmt_remove_mpool(void *session, char *mpool, boolean_t force, - nvlist_t *errs); - -int -mms_mgmt_remove_dpool(void *session, char *dpool, boolean_t force, - nvlist_t *errs); - -int -mms_mgmt_add_cartridges(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_mgmt_remove_cartridges(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_mgmt_set_pass(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_mgmt_list_vols(void *session, nvlist_t *nvl, nvlist_t **vol_list); - -int -mms_mgmt_list_drives(void *session, nvlist_t *nvl, nvlist_t *errs, - nvlist_t **drvs); - -int -mms_mgmt_list_supported_types(void *session, nvlist_t **supported); - -int -mms_mgmt_show_cartridge_type(void *session, char *voltype, nvlist_t **nvl); - -int -mms_mgmt_add_voltype(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_mgmt_create_voltype(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_mgmt_remove_voltype(void *session, char *voltype); - -int -mms_mgmt_modify_voltype(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_mgmt_list_libraries(void *session, nvlist_t *nvl, nvlist_t *errs, - nvlist_t **libs); - -int -mms_mgmt_show_requests(void *session, nvlist_t *nvl, nvlist_t **reqs); - -int -mms_mgmt_accept_request(void *session, char *reqID, char *text); - -int -mms_mgmt_reject_request(void *session, char *reqID, char *text); - -int -mms_mgmt_create_dklib(void *session, nvlist_t *lib, nvlist_t *errs); - -int -mms_mgmt_add_dkvol(void *session, nvlist_t *nvl, nvlist_t *errs); - -void -mms_mgmt_add_vol_cleanup(void *session, char *pcl, char *lib); - -int -mms_mgmt_create_dkdrive(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_mgmt_show_apps(void *session, nvlist_t *nvl, nvlist_t **apps); - -int -mms_mgmt_show_mpool(void *session, nvlist_t *nvl, nvlist_t **pools); - -int -mms_mgmt_show_dpool(void *session, nvlist_t *nvl, nvlist_t **pools); - -int -mms_mgmt_set_vol_mode(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mgmt_delete_dkvol(char *volpath, nvlist_t *errs); - -int -mms_mgmt_create_partition(void *session, char *pcl, int64_t size, char *lib, - char *rwmode, nvlist_t *errs); - -int -mms_mgmt_remove_partition(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_mgmt_label_multi(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_mgmt_label_vol(void *session, nvlist_t *nvl, nvlist_t *errs); - - -/* mount processing door info */ -#define MMS_MGMT_MOUNT 1 -#define MMS_MGMT_UNMOUNT 2 - -typedef struct { - int op; - int st; - char cartridge[1024]; - char library[1024]; - char volname[1024]; - char devname[1024]; - char app[1024]; - char inst[1024]; - char pass[1024]; - char cmd[8192]; -} mmsmnt_arg_t; - -int -mms_mgmt_mount_vol(void *session, nvlist_t *nvl, nvlist_t *errs); - -int -mms_mgmt_unmount_vol(nvlist_t *nvl, nvlist_t *errs); - -int -mgmt_set_db_pass(char *dbpass, nvlist_t *errs); - -int -mgmt_get_drvgrp(void *session, char *grpname, nvlist_t **drvgrp); - -int -mgmt_get_dgname(void *session, char *dgname, nvlist_t **dg); - -int -mgmt_get_cgname(void *session, char *dgname, nvlist_t **cg); - - - -#endif /* _MMS_MGMT_H_ */ diff --git a/usr/src/lib/mms/mgmt/i386/Makefile b/usr/src/lib/mms/mgmt/i386/Makefile deleted file mode 100644 index d77b753d64..0000000000 --- a/usr/src/lib/mms/mgmt/i386/Makefile +++ /dev/null @@ -1,26 +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. -# -# -include ../Makefile.com diff --git a/usr/src/lib/mms/mgmt/sparc/Makefile b/usr/src/lib/mms/mgmt/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/mgmt/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/mms/Makefile b/usr/src/lib/mms/mms/Makefile deleted file mode 100644 index 5027e8e194..0000000000 --- a/usr/src/lib/mms/mms/Makefile +++ /dev/null @@ -1,89 +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. -# -# - -include ../../Makefile.lib - -HDRS = mms.h \ - mms_api_msg.h \ - mms_err.h \ - mms_network.h \ - mms_strapp.h \ - mms_trace.h \ - mms_api.h \ - mms_cat.h \ - mms_dmd.h \ - mms_list.h \ - mms_parser.h \ - mms_sym.h - - -HDRDIR = $(SRC)/common/mms/mms -SUBDIRS = $(MACH) - -POFILE = mms.po -MSGFILES = common/mms_cat.i -CLEANFILES += $(MSGFILES) - -ROOTLIBDIR = $(ROOT)/usr/lib -ROOTHDRDIR= $(ROOT)/usr/include/mms -ROOTDIRS = $(ROOTLIBDIR) $(ROOTHDRDIR) - -# C preprocessor flags used to build message catalog: -# - Include message header file directories. -# - Don't redefine gettext for message catalog generation. -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -DMMS_CAT - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber lint: $(SUBDIRS) - -install: $(ROOTDIRS) $(SUBDIRS) - -install_h: $(ROOTHDRDIR) $(ROOTHDRS) - -check: $(CHECKHDR) - -$(ROOTDIRS): - $(INS.dir) - -$(POFILE): $(MSGFILES) - $(BUILDPO.msgfiles) - -_msg: $(MSGDOMAINPOFILE) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: - -include $(SRC)/Makefile.msg.targ -include ../../Makefile.targ diff --git a/usr/src/lib/mms/mms/Makefile.com b/usr/src/lib/mms/mms/Makefile.com deleted file mode 100644 index 2378b1938f..0000000000 --- a/usr/src/lib/mms/mms/Makefile.com +++ /dev/null @@ -1,121 +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. -# -# - -LIBRARY = libmms.a -VERS = .1 - -NOLINTSRC = cfg_yacc.c mmsp_yacc.c cfg_lex.c mmsp_lex.c cfg_parse.c - -LIBSRCS = mms_list.c mmsp_common.c connect.c mms_mgmt.c msg_sub.c \ - host_ident.c mms_par_util.c net_cfg.c mms_api.c mms_rw.c \ - net_cfg_service.c mms_cat.c mms_scsi.c strapp.c mms_cfg.c \ - mms_sock.c trace.c mms_client.c mms_ssl.c mms_cores.c \ - mms_sym.c - -OBJECTS = cfg_yacc.o mmsp_yacc.o cfg_lex.o mmsp_lex.o cfg_parse.o \ - mms_list.o mmsp_common.o connect.o mms_mgmt.o msg_sub.o \ - host_ident.o mms_par_util.o net_cfg.o mms_api.o mms_rw.o \ - net_cfg_service.o mms_cat.o mms_scsi.o strapp.o mms_cfg.o \ - mms_sock.o trace.o mms_client.o mms_ssl.o mms_cores.o \ - mms_sym.o - -include $(SRC)/lib/Makefile.lib - -YACC = bison -YACCFLAGS += -vd - -SRCS = $(LIBSRCS:%.c=../common/%.c) -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -LDLIBS += -lc -lsocket -lnsl -lscf -LDLIBS += -lssl -lcrypto - -CFLAGS += $(CTF_FLAGS) $(CCVERBOSE) -CFLAGS += $(C_BIGPICFLAGS) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms - -C99MODE= $(C99_ENABLE) - -LOGMMS = $(ROOT)/var/log/mms - -FILES += $(LOGMMS)/mms_logadm.conf - -.KEEP_STATE: - -all: $(SRCDIR)/cfg_yacc.c $(SRCDIR)/mmsp_yacc.c .WAIT \ - $(SRCDIR)/cfg_lex.c $(SRCDIR)/mmsp_lex.c .WAIT \ - $(LIBS) $(LIBLINKS) - -install: $(FILES) - -lint: $(LINTLIB) lintcheck - -CLEANFILES += \ - $(SRCDIR)/cfg_yacc.c \ - $(SRCDIR)/cfg_yacc.h \ - $(SRCDIR)/mmsp_yacc.c \ - $(SRCDIR)/mmsp_yacc.h \ - $(SRCDIR)/cfg_lex.c \ - $(SRCDIR)/mmsp_lex.c - -$(LOGMMS): - $(INS.dir) - -$(LOGMMS)/%: $(LOGMMS) ../common/% - $(INS.file) - -$(SRCDIR)/cfg_yacc.c: $(SRCDIR)/cfg_yacc.y - $(YACC) $(YACCFLAGS) $(SRCDIR)/cfg_yacc.y -o $(SRCDIR)/cfg_yacc.c - rm -f $(SRCDIR)/cfg_yacc.output - -$(SRCDIR)/mmsp_yacc.c: $(SRCDIR)/mmsp_yacc.y - $(YACC) $(YACCFLAGS) $(SRCDIR)/mmsp_yacc.y -o $(SRCDIR)/mmsp_yacc.c - rm -f $(SRCDIR)/mmsp_yacc.output - -$(SRCDIR)/cfg_lex.c: $(SRCDIR)/cfg_lex.l - $(FLEX) -t $(SRCDIR)/cfg_lex.l > $(SRCDIR)/cfg_lex.c - -$(SRCDIR)/mmsp_lex.c: $(SRCDIR)/mmsp_lex.l - $(FLEX) -t $(SRCDIR)/mmsp_lex.l > $(SRCDIR)/mmsp_lex.c - -$(LIBLINKS): FRC - $(RM) $@; $(SYMLINK) $(DYNLIB) $@ - -$(ROOTLIBDIR): - $(INS.dir) - -$(ROOTLIBDIR64): - $(INS.dir) - -FRC: - -include $(SRC)/lib/Makefile.targ - -install: all $(ROOTLIBDIR) $(ROOTLIBS) $(ROOTLINKS) diff --git a/usr/src/lib/mms/mms/common/cfg_lex.l b/usr/src/lib/mms/mms/common/cfg_lex.l deleted file mode 100644 index de9d239456..0000000000 --- a/usr/src/lib/mms/mms/common/cfg_lex.l +++ /dev/null @@ -1,203 +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. - */ - - -/* - * A scanner for SAM Media Manager Protocol - */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <cfg_yacc.h> - -#undef YYSTYPE -#define YYSTYPE mms_stype_t - -#include <mms_list.h> -#include <mms_parser.h> -#include <mms_par_impl.h> - - -/* - * Redine yylex to accept a pointer to the work area - */ -#undef YY_DECL -#define YY_DECL int yylex(YYSTYPE *lvalp, void *wka) - -#define SAVE_TOKEN(src) { \ - int index = (mms_pwka->par_wka_token_index++) % 2; \ - int len; \ - if ((len = strlen(src)) > MMS_PAR_MAX_TOKEN) { \ - len = MMS_PAR_MAX_TOKEN; \ - } \ - strlcpy(mms_pwka->par_wka_token[index], src, \ - MMS_PAR_MAX_TOKEN); \ - lvalp->str = mms_pwka->par_wka_token[index]; \ - } - - - -%} - -%option noyywrap debug prefix = "mms_cfg_" -%x prolog comment - -DIGIT [+-]*[0-9]+ -DECNUM (\"[\+-]*[0-9]+\")|('[\+-]*[0-9]+') -WORD [a-zA-Z][a-zA-Z0-9_]* -STRING (\"[^"]*\")|(\'[^']*\') -BADSTRING (\"[^"]*)|(\'[^']*) - - -%% - -\<\!-- { - BEGIN(comment); - } -<comment>--\> { - BEGIN(INITIAL); - } -<comment>\n { - mms_pwka->par_wka_line++; - mms_pwka->par_wka_col = 1; - } -<comment>. { - mms_pwka->par_wka_col++; - } -\<\? { - BEGIN(prolog); - } -<prolog>\?> { - BEGIN(INITIAL); - } -<prolog>\n { - mms_pwka->par_wka_line++; - mms_pwka->par_wka_col = 1; - } -<prolog>. { - mms_pwka->par_wka_col++; - } - -"\<\/" { - mms_pwka->par_wka_col += yyleng; - return (LT_SLASH); - } -"/>" { - mms_pwka->par_wka_col += yyleng; - return (SLASH_GT); - } -\<\?[^?]*\?> { - ; - } -{DECNUM} { - yytext[yyleng - 1] = '\0'; - if (yyleng - 2 > MMS_PAR_MAX_TOKEN) { - mms_par_error(mms_pwka, "token size exceeded " - "MMS_PAR_MAX_TOKEN"); - return (ERR_TOKEN_TOO_BIG); - } - SAVE_TOKEN(yytext + 1); - mms_pwka->par_wka_col += yyleng; - return (NUMERIC); - } - -{WORD} { - mms_sym_t *syment = NULL; - if (yyleng > MMS_PAR_MAX_TOKEN) { - mms_par_error(mms_pwka, "token size exceeded " - "MMS_PAR_MAX_TOKEN"); - return (ERR_TOKEN_TOO_BIG); - } - SAVE_TOKEN(yytext); - mms_pwka->par_wka_col += yyleng; - if (strcmp(yytext, "mms_cfg") == 0) { - return (MMS_CFG); - } else if (strcmp(yytext, "lm_cfg") == 0) { - return (LM_CFG); - } else if (strcmp(yytext, "dm_cfg") == 0) { - return (DM_CFG); - } else { - return (KEYWORD); - } - } - -{STRING} { - mms_sym_t *syment = NULL; - char *text; - /* Remove the enclosing quotes */ - yytext[yyleng - 1] = '\0'; - text = mms_par_xml_escape_to_char(yytext + 1); - if (text == NULL) { - mms_par_error(mms_pwka, "Out of memory"); - return (NO_MEM); - } - if (strlen(text) > MMS_PAR_MAX_TOKEN) { - mms_par_error(mms_pwka, "token size exceeded " - "MMS_PAR_MAX_TOKEN"); - return (ERR_TOKEN_TOO_BIG); - } - SAVE_TOKEN(text); - free(text); - mms_pwka->par_wka_col += yyleng; - return (STRING); - } -{BADSTRING} { - mms_par_error(mms_pwka, "No ending quote"); - return (NO_ENDING_QUOTE); - } -\xfe { - mms_par_error(mms_pwka, "Input function returned " - "too many characters"); - return (INCORRECT_INPUT_SIZE); - } -" "|\t { - mms_pwka->par_wka_col++; /* discard white spaces */ - } -\n { - mms_pwka->par_wka_line++; - mms_pwka->par_wka_col = 1; - } -. { - mms_pwka->par_wka_col++; - SAVE_TOKEN(yytext); - return (yytext[0]); - } - - -%% - -static YY_BUFFER_STATE buffer; - -void -mms_cfg_scan_string(char *str) -{ - buffer = yy_scan_string(str); -} - -void -mms_cfg_delete_buffer() -{ - yy_delete_buffer(buffer); -} diff --git a/usr/src/lib/mms/mms/common/cfg_parse.c b/usr/src/lib/mms/mms/common/cfg_parse.c deleted file mode 100644 index b226d870f1..0000000000 --- a/usr/src/lib/mms/mms/common/cfg_parse.c +++ /dev/null @@ -1,106 +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 <thread.h> -#include <synch.h> -#include <stdio.h> -#include <stdarg.h> -#include <stdlib.h> -#include <string.h> -#include <sys/int_types.h> -#include <mms_list.h> -#include <mms_sym.h> -#include <mms_parser.h> -#include <mms_par_impl.h> -#include <cfg_yacc.h> - -#define yyparse mms_cfg_parse -int yyparse(mms_pw_t *); - -int mms_cfg_debug; -extern int mms_cfg__flex_debug; - -/* - * Parse the config files - */ -extern mms_sym_t *mms_config_symtab; -extern int mms_num_config_syms; -static mutex_t mms_config_mutex = DEFAULTMUTEX; -static int mms_config_symtab_initialized = 0; - -/* - * - * config_parse_buf() - * - * Parameters: - * cfg_node Ptr to the generated parse tree of XML cfg string - * msg_list List needed by parser routine if errors encountered - * buf XML cmd string that needs to be parsed. - * - * This function is a generic version of mms_config_parse. - * It is designed so that - * a user does not have to create a input routine. The only requirement is - * that the XML string they need parsed be a character string. - * - * Return Values: - * 0 If config parsed without errors. - * 1 If config parsed with errors. - * -1 If unable to allocate enough memory for parse tree. - * - */ - -int -mms_config_parse(mms_par_node_t **cfg_node, mms_list_t *msg_list, char *buf) -{ - mms_pw_t *wka; - int rc = 0; - - mms_cfg__flex_debug = 0; - mms_cfg_debug = 0; - wka = mms_par_init_wka(cfg_node, msg_list, - mms_config_symtab, mms_num_config_syms, - &mms_config_symtab_initialized); - strlcpy(wka->par_wka_parser, "mms_config_parse", - sizeof (wka->par_wka_parser)); - if (wka == NULL) { - return (-1); - } - wka->par_wka_symtab = NULL; - wka->par_wka_num_syms = 0; - wka->par_wka_lock = &mms_config_mutex; - mutex_lock(wka->par_wka_lock); - mms_cfg_scan_string(buf); - if (yyparse(wka) || wka->par_wka_err_count) { - rc = 1; - } - mms_cfg_delete_buffer(); - mms_pn_fini(*cfg_node); - mutex_unlock(wka->par_wka_lock); - free(wka->par_wka_token[0]); - free(wka->par_wka_token[1]); - free(wka); - return (rc); -} diff --git a/usr/src/lib/mms/mms/common/cfg_yacc.y b/usr/src/lib/mms/mms/common/cfg_yacc.y deleted file mode 100644 index c78293cae3..0000000000 --- a/usr/src/lib/mms/mms/common/cfg_yacc.y +++ /dev/null @@ -1,222 +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 <thread.h> -#include <synch.h> -#include <stdio.h> -#include <stdarg.h> -#include <stdlib.h> -#include <string.h> -#include <sys/int_types.h> -#include <mms_list.h> -#include <mms_parser.h> -#include <mms_par_impl.h> - -#define YYPARSE_PARAM wka -#define YYLEX_PARAM wka -#define YYERROR_VERBOSE 1 - -#undef YYSTYPE -#define YYSTYPE mms_stype_t - -int yylex(YYSTYPE *lvalp, void *wka); - -#define mms_cfg_error(msg) { \ - mms_par_error(mms_pwka, msg); \ - if (mms_pwka->par_wka_err_count >= MMS_PE_MAX) { \ - mms_par_error(mms_pwka, "Too many errors"); \ - YYABORT; \ - } \ - } - -mms_sym_t mms_cfg_tab[] = { - "mms_cfg", MMS_CFG, -}; -mms_sym_t *mms_config_symtab = mms_cfg_tab; -int mms_num_config_syms = sizeof (mms_cfg_tab) / sizeof (mms_sym_t); - - - -%} - -%name-prefix = "mms_cfg_" -%defines -%pure_parser - -%token TOKEN_MIN - -%token MMS_CFG LM_CFG DM_CFG KEYWORD STRING NUMERIC LT_SLASH SLASH_GT -%token ERR_TOKEN_TOO_BIG NO_ENDING_QUOTE NO_MEM INCORRECT_INPUT_SIZE -%token NULL_STRING - -%token TOKEN_MAX - - -%% - -/* - * MMS cfg file - */ - -mms_cfg - : L config_name R section_content_list LS config_name_spec R - { - mms_list_move_tail(&$2.nodep->pn_arglist, $4.listp); - if (strcmp(mms_pn_token($2.nodep), $6.str)) { - char msg[200]; - sprintf(msg, "Unexpected tag \"%s\", " - "expecting \"%s\"", $6.str, - mms_pn_token($2.nodep)); - yyerror(msg); - YYERROR; - } - $$.nodep = $2.nodep; - } - ; - -section : L section_name R section_content_list LS KEYWORD R - { - mms_list_move_tail(&$2.nodep->pn_arglist, $4.listp); - if (strcmp(mms_pn_token($2.nodep), $6.str)) { - char msg[200]; - sprintf(msg, "Unexpected tag \"%s\", " - "expecting \"%s\"", $6.str, - mms_pn_token($2.nodep)); - yyerror(msg); - YYERROR; - } - $$.nodep = $2.nodep; - } - ; - -section_content_list - : section_content - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_list_insert_tail($$.listp, $1.nodep); - } - | section_content_list section_content - { - mms_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -section_content - : section - | L option_name attr_list SR - { - mms_list_move_tail(&$2.nodep->pn_arglist, $3.listp); - $$.nodep = $2.nodep; - } - ; - - -attr_list - : attr - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_list_insert_tail($$.listp, $1.nodep); - } - | attr_list attr - { - mms_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -attr : cfg_keyword '=' value - { - mms_list_insert_tail(&$1.nodep->pn_arglist, $3.nodep); - $$.nodep = $1.nodep; - } - ; - -value : string - | number - ; - -option_name - : KEYWORD - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_OPTION); - } - ; - -config_name - : config_name_spec - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_CONFIG); - } - ; - -config_name_spec - : MMS_CFG | LM_CFG | DM_CFG - ; - -section_name - : KEYWORD - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_SECTION); - } - ; - -cfg_keyword - : KEYWORD - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -string : STRING - { - if (strlen($1.str) == 0) { - yyerror("Null string"); - } - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_STRING); - } - ; - -number : NUMERIC - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, - MMS_PN_NUMERIC | MMS_PN_STRING); - } - ; - -L : '<' - ; - -R : '>' - ; - -LS : LT_SLASH - ; - -SR : SLASH_GT - ; - -%% diff --git a/usr/src/lib/mms/mms/common/connect.c b/usr/src/lib/mms/mms/common/connect.c deleted file mode 100644 index de491a1c19..0000000000 --- a/usr/src/lib/mms/mms/common/connect.c +++ /dev/null @@ -1,460 +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. - */ - - -#include <stdio.h> -#include <stdlib.h> -#include <pthread.h> -#include <string.h> -#include <errno.h> -#include <unistd.h> -#include <syslog.h> -#include "mms_list.h" -#include "mms_parser.h" -#include "mms_network.h" -#include <mms_sym.h> -#include <mms_trace.h> -#include <mms_strapp.h> -#include "mms_sock.h" - - -#include <fcntl.h> -#include <sys/types.h> -#include <sys/stat.h> - - - -#define MMS_OK 0 -#define MMS_ERROR -1 -#define MMS_WELCOME 6 -#define MMS_UNWELCOME 7 - -static char *_SrcFile = __FILE__; - -/* - * - * mms_intrp() - * - * Parameters: - * rsp The response to the welcome command (XML format) that - * was sent from the MM to the client. - * err_code The error code if MMS_ERROR was returned. - * - * Globals: - * None - * - * This function will determine the type of response that was received in - * response to the client's "hello" command. - * - * Return Values: - * MMS_WELCOME If the response was a welcome - * MMS_UNWELCOME If the response was a unwelcome - * MMS_ERROR If an error was encountered while processing response - * or if the respone was a error response. - * - */ - -int -mms_intrp(char *rsp, char **pass, char **cert, char **auth, int *err_code) -{ - mms_par_node_t *cmd; - mms_par_node_t *node; - mms_par_node_t *clause; - mms_par_node_t *value; - mms_par_node_t *index; - mms_list_t err_list; - mms_par_err_t *err; - int ret_val; - - *pass = NULL; - *cert = NULL; - *auth = NULL; - - if (mms_mmp_parse(&cmd, &err_list, rsp)) { - mms_list_foreach(&err_list, err) { - mms_trace(MMS_ERR, - "mms_mmconnect mms_mmp_parse, line %d, " - "col %d, near token %s, err code %d, %s\n", - err->pe_line, - err->pe_col, - err->pe_token, - err->pe_code, - err->pe_msg); - } - mms_pe_destroy(&err_list); - mms_pn_destroy(cmd); - *err_code = MMS_E_SYNTAX_ERR; - return (MMS_ERROR); - } - - mms_pe_destroy(&err_list); - - if (mms_pn_lookup(cmd, "welcome", MMS_PN_CMD, 0) != NULL) { - if (clause = mms_pn_lookup_arg(cmd, "password", - MMS_PN_CLAUSE, NULL)) { - if (value = mms_pn_lookup_arg(clause, NULL, - MMS_PN_STRING, NULL)) { - *pass = strdup(value->pn_string); - } - } - if (clause = mms_pn_lookup_arg(cmd, "certificate", - MMS_PN_CLAUSE, NULL)) { - index = NULL; - if (value = mms_pn_lookup_arg(clause, NULL, - MMS_PN_STRING, &index)) { - *cert = strdup(value->pn_string); - } - - if (value = mms_pn_lookup_arg(clause, NULL, - MMS_PN_STRING, &index)) { - *auth = strdup(value->pn_string); - } - } - ret_val = MMS_WELCOME; - } else if (mms_pn_lookup(cmd, "unwelcome", MMS_PN_CMD, 0) != NULL) { - ret_val = MMS_UNWELCOME; - if ((node = mms_pn_lookup(cmd, NULL, MMS_PN_STRING, 0)) - == NULL) { - *err_code = MMS_E_INVALID_RESPONSE; - } else { - *err_code = mms_sym_str_to_code(mms_pn_token(node)); - } - } else { - *err_code = MMS_E_INVALID_RESPONSE; - ret_val = MMS_ERROR; - } - - mms_pn_destroy(cmd); - return (ret_val); -} - -#define MMS_HELLO_CMD_STRING "hello client [\"%s\"] instance [\"%s\"] \ -language [%s] version [\"%s\"] password [\"%s\"]; " -#define MMS_HELLO_CMD_TAG_STRING "hello client [\"%s\"] instance [\"%s\"] \ -language [%s] version [\"%s\"] password [\"%s\"] tag [\"%s\"]; " -#define MMS_HELLO_CMD_CERT_STRING "hello client [\"%s\"] instance [\"%s\"] \ -language [%s] version [\"%s\"] certificate [\"\n%s\n\" \"%s\"]; " -#define MMS_HELLO_CMD_CERT_TAG_STRING "hello client [\"%s\"] instance [\"%s\"] \ -language [%s] version [\"%s\"] certificate [\"\n%s\n\" \"%s\"] tag [\"%s\"]; " - -/* - * - * mms_mmconnect() - * - * Parameters: - * net Structure containing network information for - * connecting to the MM. This structure contains all - * necessary information needed to compose a "hello" - * command from a client module to the MM. - * conn Structure which will contain the socket connection - * information. - * err_code error code if MMS_ERROR is returned. - * error code is either MMS error code. - * tag Tag to be used for the connection. - * - * Globals: - * None. - * - * This is a general purpose routine that can be used by a client that - * need to connect to MM. All client specific information is contained in - * the mms_network_cfg structure. This routine generates a "hello" command and - * send it to the MM. It waits for a response from the MM and determines - * if a welcome or unwelcome response was sent by MM. - * - * Return Values: - * fd If a welcome response was received from MM, then - * this routine returns the file descriptor that the - * client will use to communicate with MM. - * MMS_ERROR If an error occurred while processing or if an - * unwelcome response was receieved from MM. - * - */ - -int -mms_mmconnect(mms_network_cfg_t *net, - void *ssl_data, - mms_t *conn, - int *err_code, - char *tag) -{ - int n; - int len; - char ebuf[MMS_EBUF_LEN]; - char cmd_str[4096]; - char *rsp = NULL; - char *cert = NULL; - char *auth = NULL; - char *pass = NULL; - int rc; - - - *err_code = 0; - - /* - * Connect to media manager, if ssl data is not null - * then establish a SSLv3 connection. - */ - mms_trace(MMS_DEVP, "host %s port %s", net->cli_host, net->cli_port); - if (mms_connect(net->cli_host, net->cli_port, ssl_data, conn)) { - mms_get_error_string(&conn->mms_err, ebuf, MMS_EBUF_LEN); - mms_trace(MMS_ERR, "mms_mmconnect: failed to connect to MMS, " - "%s\n", ebuf); - *err_code = MMS_E_CONNECT_ERR; - return (MMS_ERROR); - } - - /* - * Create hello command. - */ -#ifdef MMS_OPENSSL - if (mms_ssl_has_cert_clause(ssl_data, conn)) { - /* - * Create auth-clause hello command using - * its private key for the signature. - */ - if (mms_ssl_build_cert_clause(ssl_data, conn, - net->cli_pass, &cert, &auth)) { - mms_trace(MMS_ERR, - "mms_mmconnect: hello certificate-clause"); - *err_code = MMS_E_SSL_CERT_CLAUSE; - return (MMS_ERROR); - } - if (tag == NULL) { - (void) snprintf(cmd_str, sizeof (cmd_str), - MMS_HELLO_CMD_CERT_STRING, - net->cli_name, net->cli_inst, - net->cli_lang, net->cli_vers, - cert, auth); - } else { - (void) snprintf(cmd_str, sizeof (cmd_str), - MMS_HELLO_CMD_CERT_TAG_STRING, - net->cli_name, net->cli_inst, - net->cli_lang, net->cli_vers, - cert, auth, tag); - } - free(cert); - free(auth); - cert = NULL; - auth = NULL; - mms_trace(MMS_DEBUG, cmd_str); - - } else { -#endif /* MMS_OPENSSL */ - - /* - * Use password, client does not have - * private key for signature. - */ - if (tag == NULL) { - (void) snprintf(cmd_str, sizeof (cmd_str), - MMS_HELLO_CMD_STRING, - net->cli_name, net->cli_inst, - net->cli_lang, net->cli_vers, - net->cli_pass); - mms_trace(MMS_DEBUG, MMS_HELLO_CMD_STRING, - net->cli_name, net->cli_inst, - net->cli_lang, net->cli_vers, - ""); - } else { - (void) snprintf(cmd_str, sizeof (cmd_str), - MMS_HELLO_CMD_TAG_STRING, - net->cli_name, net->cli_inst, - net->cli_lang, net->cli_vers, - net->cli_pass, tag); - mms_trace(MMS_DEBUG, MMS_HELLO_CMD_TAG_STRING, - net->cli_name, net->cli_inst, - net->cli_lang, net->cli_vers, - "", tag); - } - -#ifdef MMS_OPENSSL - } -#endif /* MMS_OPENSSL */ - - len = strlen(cmd_str); - if ((n = mms_writer(conn, cmd_str)) != len) { - mms_get_error_string(&conn->mms_err, ebuf, MMS_EBUF_LEN); - mms_trace(MMS_ERR, - "mms_mmconnect: Failed to write hello cmd, %d, " - "%s\n", n, ebuf); - mms_close(conn); - *err_code = MMS_E_NET_IO_ERR; - return (MMS_ERROR); - } - - rsp = NULL; - if ((n = mms_reader(conn, &rsp)) <= 0) { - mms_get_error_string(&conn->mms_err, ebuf, MMS_EBUF_LEN); - mms_trace(MMS_ERR, - "mms_mmconnect: Failed to read response to hello " - "cmd, %d, %s\n", n, ebuf); - mms_close(conn); - *err_code = MMS_E_NET_IO_ERR; - return (MMS_ERROR); - } - - switch (mms_intrp(rsp, &pass, &cert, &auth, err_code)) { - - case MMS_WELCOME: - /* - * Verifing welcome auth-clause is optional. - */ - rc = MMS_OK; - if (pass != NULL) { - - if (net->mm_pass != NULL) { - - if (strcmp(net->mm_pass, pass) != 0) { - - mms_trace(MMS_ERR, - "mms_mmconnect: welcome " - "password mismatch"); - - *err_code = MMS_E_WELCOME_PASSWORD; - rc = MMS_ERROR; - - } else { - mms_trace(MMS_DEVP, - "mms_mmconnect: welcome " - "password matched"); - } - } - -#ifdef MMS_OPENSSL - } else if (cert != NULL && auth != NULL) { - - char *tmp_pass = NULL; - - if (mms_ssl_verify_cert_clause(ssl_data, conn, - cert, auth, &tmp_pass)) { - - mms_trace(MMS_ERR, - "mms_mmconnect: welcome certificate-clause " - "invalid"); - - *err_code = MMS_E_SSL_VERIFY; - rc = MMS_ERROR; - - } else if (net->mm_pass != NULL) { - - if (strcmp(net->mm_pass, tmp_pass) != 0) { - - mms_trace(MMS_ERR, - "mms_mmconnect: welcome " - "certificate-clause " - "password mismatch"); - - *err_code = MMS_E_WELCOME_PASSWORD; - rc = MMS_ERROR; - - } else { - mms_trace(MMS_DEVP, - "mms_mmconnect: welcome " - "certificate-clause ok"); - } - - free(tmp_pass); - } - -#endif /* MMS_OPENSSL */ - - } else if (net->mm_pass != NULL) { - - mms_trace(MMS_ERR, - "mms_mmconnect: welcome missing auth-clause"); - - *err_code = MMS_E_NO_WELCOME_PASSWORD; - rc = MMS_ERROR; - - } - free(pass); - free(cert); - free(auth); - if (rc == MMS_OK) { - free(rsp); - return (MMS_OK); - } - break; - case MMS_UNWELCOME: - mms_trace(MMS_NOTICE, - "mms_mmconnect: unwelcome resp - %s", rsp); - break; - case MMS_ERROR: - break; - default: - break; - } - - free(rsp); - mms_close(conn); - return (MMS_ERROR); -} - -/* - * - * mms_mmdisconnect() - * - * Parameters: - * conn Structure containing network information for - * connecting to the MM. This structure contains all - * necessary information needed to compose a "goodbye" - * command from a client module to the MM. - * - * Globals: - * None. - * - * This is a general purpose routine that can be used by a client that - * is disconnecting from the MM. This routine generates a "goodbye" command and - * send it to the MM. It does not wait for a response from the MM. - * - * Return Values: - * MMS_OK If the goodbye command was sent successfully. - * MMS_ERROR If an error occurred while processing - * - */ - -int -mms_mmdisconnect(mms_t *conn) -{ - - int n; - int len; - char ebuf[MMS_EBUF_LEN]; - char cmd_str[1024]; - - (void) snprintf(cmd_str, sizeof (cmd_str), - "goodbye task[\"goodbye%d\"];", conn->mms_fd); - - len = strlen(cmd_str); - if ((n = mms_writer(conn, cmd_str)) != len) { - mms_get_error_string(&conn->mms_err, ebuf, MMS_EBUF_LEN); - mms_trace(MMS_ERR, "Failed to write goodbye cmd - %d, %s \n", - n, ebuf); - mms_close(conn); - return (MMS_ERROR); - } - - mms_close(conn); - return (MMS_OK); -} diff --git a/usr/src/lib/mms/mms/common/host_ident.c b/usr/src/lib/mms/mms/common/host_ident.c deleted file mode 100644 index eb4be9ecb0..0000000000 --- a/usr/src/lib/mms/mms/common/host_ident.c +++ /dev/null @@ -1,219 +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. - */ - - -/* - * Covert host name or ip mms_address to internal mm ident. - * - * IPv6 and IPv4 lookup code is from: - * http://aggregate.eng/ws/onnv_nightly/source - * /usr/src/cmd/auditconfig/auditconfig.c - */ -#include <string.h> -#include <sys/types.h> -#include <string.h> -#include <stdlib.h> -#include <netdb.h> -#include <nss_dbdefs.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <unistd.h> -#include <ctype.h> -#include <strings.h> -#include "mms_network.h" -#include "host_ident.h" - - -typedef enum mms_address_type mms_a_type_t; -enum mms_address_type { - MMS_ADDRESS_IPv4, - MMS_ADDRESS_IPv6 -}; - -typedef struct mms_address mms_address_t; -struct mms_address { - mms_a_type_t a_type; - uint_t a_addr[4]; -}; - -static void mms_get_address(char *host_str, mms_address_t *addressp); -static void mms_get_strings(char *host, char *ip, mms_address_t *addressp); -static void mms_get_localhost(char *host_str); - - -char * -mms_host_ident(char *host_str, char *host, char *ip) -{ - mms_address_t mms_address; - - (void) memset(&mms_address, 0, sizeof (mms_address_t)); - if (host_str == NULL || host == NULL || ip == NULL) - return (NULL); - host[0] = '\0'; - ip[0] = '\0'; - - mms_get_localhost(host_str); - mms_get_address(host_str, &mms_address); - mms_get_strings(host, ip, &mms_address); - - if (strcmp(host, "unknown") == 0 || - strcmp(ip, "::") == 0) { - return (NULL); - } - - /* currently mm uses ip addresses internally */ - return (ip); -} - -static void -mms_get_address(char *host_str, mms_address_t *addressp) -{ - struct hostent *phe; - int err; - uint32_t ibuf; - uint32_t ibuf6[4]; - - addressp->a_type = 0; - bzero(addressp->a_addr, 16); - - /* try ip mms_address first */ - if (inet_pton(AF_INET, host_str, &ibuf)) { - addressp->a_addr[0] = ibuf; - addressp->a_type = MMS_ADDRESS_IPv4; - return; - } else if (inet_pton(AF_INET6, host_str, ibuf6)) { - addressp->a_addr[0] = ibuf6[0]; - addressp->a_addr[1] = ibuf6[1]; - addressp->a_addr[2] = ibuf6[2]; - addressp->a_addr[3] = ibuf6[3]; - addressp->a_type = MMS_ADDRESS_IPv6; - return; - } - - /* try by name */ - phe = getipnodebyname((const void *)host_str, AF_INET, 0, &err); - if (phe == 0) { - phe = getipnodebyname((const void *)host_str, AF_INET6, - 0, &err); - } - - if (phe != NULL) { - if (phe->h_addrtype == AF_INET6) { - /* mms_address is IPv6 (128 bits) */ - (void) memcpy(&addressp->a_addr[0], - phe->h_addr_list[0], 16); - addressp->a_type = MMS_ADDRESS_IPv6; - } else { - /* mms_address is IPv4 (32 bits) */ - (void) memcpy(&addressp->a_addr[0], - phe->h_addr_list[0], 4); - addressp->a_type = MMS_ADDRESS_IPv4; - } - freehostent(phe); - } -} - -static void -mms_get_strings(char *host, char *ip, mms_address_t *addressp) -{ - struct hostent *phe = NULL; - char *hostname = NULL; - struct in_addr ia; - uint32_t *addr = NULL; - int err; - char buf[256]; - char *bufp = NULL; - - struct hostent result; - char *buffer; - - /* IPV6 or IPV4 mms_address */ - if (addressp->a_type == MMS_ADDRESS_IPv4) { - buffer = (char *)malloc(NSS_BUFLEN_HOSTS); - if (buffer != NULL && - (phe = gethostbyaddr_r((char *)&addressp->a_addr[0], - sizeof (addressp->a_addr[0]), AF_INET, - &result, buffer, NSS_BUFLEN_HOSTS, &err)) - != (struct hostent *)NULL) - hostname = phe->h_name; - else - hostname = "unknown"; - - ia.s_addr = addressp->a_addr[0]; - - (void) strcpy(host, hostname); - (void) strcpy(ip, inet_ntoa(ia)); - if (buffer) { - free(buffer); - } - } else { - addr = &addressp->a_addr[0]; - phe = getipnodebyaddr((const void *)addr, 16, - AF_INET6, &err); - - bzero(buf, sizeof (buf)); - - (void) inet_ntop(AF_INET6, (void *)addr, buf, sizeof (buf)); - if (phe == (struct hostent *)0) { - bufp = "unknown"; - } else { - bufp = phe->h_name; - } - - (void) strcpy(host, bufp); - (void) strcpy(ip, buf); - if (phe) { - freehostent(phe); - } - } -} - -static void -mms_get_localhost(char *host_str) -{ - char ip[MMS_IP_IDENT_LEN+1]; - - if (strcmp(host_str, "localhost") == 0 || - strcmp(host_str, "127.0.0.1") == 0 || - strcmp(host_str, "::1") == 0) { - (void) mms_host_info(host_str, ip); - } -} - -/* localhost info */ -char * -mms_host_info(char *host, char *ip) -{ - char host_str[MMS_HOST_IDENT_LEN+1]; - mms_address_t mms_address; - - (void) memset(&mms_address, 0, sizeof (mms_address_t)); - (void) gethostname(host_str, sizeof (host_str)); - mms_get_address(host_str, &mms_address); - mms_get_strings(host, ip, &mms_address); - - return (ip); -} diff --git a/usr/src/lib/mms/mms/common/host_ident.h b/usr/src/lib/mms/mms/common/host_ident.h deleted file mode 100644 index 841e46750f..0000000000 --- a/usr/src/lib/mms/mms/common/host_ident.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 _HOST_IDENT_H -#define _HOST_IDENT_H - - -#include <netdb.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define MMS_HOST_IDENT_LEN MAXHOSTNAMELEN -#define MMS_IP_IDENT_LEN 255 - -/* covert host name or ip mms_address to internal mm usage */ -char *mms_host_ident(char *host_str, char *host, char *ip); - -/* localhost info */ -char *mms_host_info(char *host, char *ip); - -#ifdef __cplusplus -} -#endif - - -#endif /* _HOST_IDENT_H */ diff --git a/usr/src/lib/mms/mms/common/mapfile-vers b/usr/src/lib/mms/mms/common/mapfile-vers deleted file mode 100644 index b9f31858e6..0000000000 --- a/usr/src/lib/mms/mms/common/mapfile-vers +++ /dev/null @@ -1,158 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNW_1.1 { - mms_agoodbye; - mms_ainit; - mms_free_rsp; - mms_get_attribute; - mms_goodbye; - mms_handle_err_rsp; - mms_hello; - mms_init; - mms_read_event; - mms_read_response; - mms_send_acmd; - mms_send_cmd; - - local: - *; -}; - -SUNWprivate_1.1 { - global: - mms_host_ident; - mms_host_info; - mms_pn_lookup; - mms_sym_code_to_str; - - mms_accept; - mms_be_wakeup; - mms_bld_msgcl; - mms_buf_msgcl; - mms_cat_open; - mms_cfg_alloc_getvar; - mms_cfg_getvar; - mms_cfg_setvar; - mms_cfg_unsetvar; - mms_close; - mms_config_parse; - mms_connect; - mms_dmpd_parse; - mms_dmpm_parse; - mms_format_sense; - mms_get_cat_msg; - mms_get_error_string; - mms_get_locstr; - mms_list_create; - mms_list_create_like; - mms_list_destroy; - mms_list_head; - mms_list_insert_after; - mms_list_insert_after_node; - mms_list_insert_before; - mms_list_insert_before_node; - mms_list_insert_head; - mms_list_insert_tail; - mms_list_move; - mms_list_move_tail; - mms_list_next; - mms_list_prev; - mms_list_remove; - mms_list_tail; - mms_listen; - mms_lmpl_parse; - mms_lmpm_parse; - mms_man_cores; - mms_mmconnect; - mms_mmp_parse; - mms_msg_get_severity; - mms_msg_sub; - mms_net_cfg_free; - mms_net_cfg_read; - mms_net_cfg_read_pass_file; - mms_net_cfg_service; - mms_net_cfg_write_pass_file; - mms_obfpassword; - mms_pe_destroy; - mms_pn_build_cmd_text; - mms_pn_destroy; - mms_pn_lookup_arg; - mms_reader; - mms_scsi_cmd; - mms_scsi_sensekey; - mms_scsi_status; - mms_set_core; - mms_ssl_build_cert_clause; - mms_ssl_check_conn_cert; - mms_ssl_client; - mms_ssl_finish; - mms_ssl_has_cert_clause; - mms_ssl_has_crl; - mms_ssl_reload_crl_file; - mms_ssl_server; - mms_ssl_server_set_verify_peer; - mms_ssl_verify_cert_clause; - mms_strapp; - mms_strnapp; - mms_strnew; - mms_strpar_escape_sequence; - mms_strpar_undo_escape_sequence; - mms_trace; - mms_trace_close; - mms_trace_dump; - mms_trace_filter; - mms_trace_flush; - mms_trace_get_fd; - mms_trace_get_severity; - mms_trace_open; - mms_trace_set_fsize; - mms_trace_sev2str; - mms_trace_str2sev; - mms_trace_str_filter; - mms_trace_str_to_fsize; - mms_trace_va; - mms_vstrapp; - mms_writer; - - local: - - *; -}; diff --git a/usr/src/lib/mms/mms/common/mgmt_mms.h b/usr/src/lib/mms/mms/common/mgmt_mms.h deleted file mode 100644 index d3a5e4a2ea..0000000000 --- a/usr/src/lib/mms/mms/common/mgmt_mms.h +++ /dev/null @@ -1,75 +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 __MMS_MGMT_H -#define __MMS_MGMT_H - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum mms_cmd_name mms_cmd_name_t; -enum mms_cmd_name { - MMS_CMD_OTHER = 0, - MMS_CMD_BEGIN = 1, - MMS_CMD_END = 2 -}; - -void mms_acc_insert(mms_session_t *, mms_rsp_ele_t *); -void mms_acc_wakeup(mms_session_t *); -void mms_be_wait(mms_session_t *, boolean_t); -void mms_be_wakeup(mms_session_t *); -void mms_cmd_create(mms_session_t *, char *, char *, int, - void (*callbk)(void *arg, void *arg1), void *); -void mms_cmd_free(mms_cmd_ele_t *); -void mms_cmd_flush(mms_session_t *, char *); -void mms_cmd_insert(mms_session_t *, mms_cmd_ele_t *); -void mms_ev_insert(mms_session_t *, mms_rsp_ele_t *); -void mms_rsp_insert(mms_session_t *, mms_rsp_ele_t *); -void mms_rsp_wakeup(mms_session_t *); -void mms_start_notify(mms_session_t *); -void mms_thread_exit(mms_session_t *); -void mms_thread_start(mms_session_t *); - -char *mms_cmd_get_task(mms_par_node_t *); - -int mms_cmd_extract(char *, char **, mms_cmd_name_t *); -int mms_obtain_accept(mms_session_t *, char *, mms_rsp_ele_t **); -int mms_obtain_final(mms_session_t *, char *, mms_rsp_ele_t **); -int mms_send(mms_session_t *, char *, mms_cmd_name_t, char *, - mms_rsp_ele_t **); -int mms_sync_reader(mms_session_t *, int, char *, mms_rsp_ele_t **); - -mms_cmd_name_t mms_be_extract(mms_session_t *, char *); -mms_cmd_ele_t *mms_cmd_remove(mms_session_t *, char *); -mms_rsp_ele_t *mms_rsp_create(char *, mms_par_node_t *, int, char *); -mms_rsp_ele_t *mms_rsp_find(mms_session_t *, char *); - -#ifdef __cplusplus -} -#endif - - -#endif /* __MMS_MGMT_H */ diff --git a/usr/src/lib/mms/mms/common/mms_api.c b/usr/src/lib/mms/mms/common/mms_api.c deleted file mode 100644 index 7749b40d31..0000000000 --- a/usr/src/lib/mms/mms/common/mms_api.c +++ /dev/null @@ -1,1337 +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 <mms.h> -#include <mgmt_mms.h> - -#define MMS_API_MSG_CMD "message task [\"3999\"] who [operator] \ -severity [error] %s; " - -#if mms_lint -extern int mms_select_large_fdset(int, fd_set *_RESTRICT_KYWD, - fd_set *_RESTRICT_KYWD, fd_set *_RESTRICT_KYWD, - struct timeval *_RESTRICT_KYWD); -#define select mms_select_large_fdset -#endif - -static char *_SrcFile = __FILE__; - -/* - * mms_serr() - * - * Parameters: - * - severity The severity of the system error encountered - * - file The name of the file in which the error occurred - * - line The line number in the file where the error occurred - * - fmt The format of the message to be mms_printed. - * - ... The variable number of arguments for the message. - * - * This function is used within the MMS API to handle system errors that - * are not recoverable from. The function outputs the critial message to - * the mms_trace file and then aborts. This function is used to handle - * system errors such as thread function errors. - * - * Return Values: - * None - * - */ -void -mms_serr(mms_trace_sev_t severity, char *file, int line, const char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - mms_trace_va(severity, file, line, fmt, args); - va_end(args); - - mms_trace_flush(); - mms_trace_close(); - abort(); -} - -#define MMS_API_ERR_FMT "response task [\"%s\"] error [%s %s] %s;" -#define MMS_API_MSG_PAD 30 - -/* - * mms_gen_err_rsp() - * - * Parameters: - * - tid The task id of the command to receive error response - * - code The code to use in the error response - * - err_msg The error message to use in the error response - * - * This function is used within the MMS API to generate an error response. - * This is only used in the mms_api_reader to send a generated error - * response to async commands waiting for a response. This is done - * when the API has an internal processing error that it cannot recover - * from - * - * Return Values: - * The generated error response if it could create it or NULL - * - */ -mms_rsp_ele_t * -mms_gen_err_rsp(char *tid, int code, char *err_msg) -{ - mms_list_t err_list; - mms_par_err_t *err; - mms_par_node_t *cmd; - mms_rsp_ele_t *rsp; - char *err_rsp; - char *s_internal; - char *s_code; - int len = MMS_API_MSG_PAD; - - if ((rsp = (mms_rsp_ele_t *)malloc(sizeof (mms_rsp_ele_t))) == NULL) { - mms_serr(MMS_CRIT, "mms_gen_err_rsp: Malloc of space for new " - "error response failed with errno - %s", strerror(errno)); - } - - rsp->mms_rsp_tid = strdup(tid); - rsp->mms_rsp_type = MMS_API_RSP_FINAL_ERR; - rsp->mms_rsp_cmd = NULL; - - s_internal = mms_sym_code_to_str(MMS_INTERNAL); - s_code = mms_sym_code_to_str(code); - len += strlen(MMS_API_ERR_FMT) + strlen(tid) + strlen(s_internal) + - strlen(s_code); - if (err_msg) - len += strlen(err_msg); - - err_rsp = malloc(len); - if (!err_rsp) { - mms_serr(MMS_CRIT, "mms_gen_err_rsp: Malloc of space for " - "error message failed with errno - %s", strerror(errno)); - } - - (void) snprintf(err_rsp, len, - MMS_API_ERR_FMT, tid, s_internal, s_code, - err_msg ? err_msg : "API Error"); - rsp->mms_rsp_str = err_rsp; - - if (mms_mmp_parse(&cmd, &err_list, err_rsp)) { - /* Should never occur unless error response format */ - /* has a syntax error or the parser cannot obtain */ - /* memory for the parse tree */ - mms_trace(MMS_ERR, "mms_gen_err_rsp: parse error detected " - "during generation of error response:\n%s", err_rsp); - mms_list_foreach(&err_list, err) { - mms_trace(MMS_ERR, "mms_gen_err_rsp: " - "mms_mmp_parse, line %d, col %d, " - "near token \"%s\", err code %d, %s", - err->pe_line, err->pe_col, - err->pe_token, err->pe_code, - err->pe_msg); - } - mms_pe_destroy(&err_list); - rsp->mms_rsp_cmd = NULL; - return (rsp); - } - mms_pe_destroy(&err_list); - rsp->mms_rsp_cmd = cmd; - return (rsp); -} - -/* - * mms_log_error - * - * Output an error message to a log file. - */ -static void -mms_log_error(mms_session_t *sp, char *message) -{ - mms_par_err_t *err; - mms_par_node_t *msg; - mms_list_t err_list; - char *lmsg; - char *err_msg; - int len = MMS_API_MSG_PAD; - - if (sp->clog == NULL) - return; - - if (message == NULL) - return; - - len += strlen(MMS_API_MSG_CMD) + strlen(message); - err_msg = malloc(len); - if (!err_msg) { - free(message); - return; - } - - if (snprintf(err_msg, len, MMS_API_MSG_CMD, message) == -1) { - mms_trace(MMS_ERR, "mms_log_error: Unable to create API error " - "message:\n%s", message); - free(err_msg); - free(message); - } - - if (mms_mmp_parse(&msg, &err_list, err_msg)) { - - /* - * Should never occur unless message format has a syntax - * error or the parser cannot obtain memory for the parse - * tree. - */ - mms_trace(MMS_ERR, "mms_log_error: parse error detected " - "during generation of message:\n%s", message); - mms_list_foreach(&err_list, err) { - mms_trace(MMS_ERR, - "mms_log_error: mms_mmp_parse, line %d, " - "col %d, near token \"%s\", err code %d, %s", - err->pe_line, err->pe_col, - err->pe_token, err->pe_code, - err->pe_msg); - } - mms_pe_destroy(&err_list); - mms_trace(MMS_DEBUG, "mms_log_error: Outputing default " - "message to clients log"); - sp->clog(sp->cprefix, message); - free(err_msg); - free(message); - return; - } - mms_pe_destroy(&err_list); - if ((lmsg = mms_get_msg(msg)) != NULL) { - sp->clog(sp->cprefix, lmsg); - } else { - mms_trace(MMS_DEBUG, "mms_log_error: Outputing default " - "message to client's log"); - sp->clog(sp->cprefix, message); - } - mms_pn_destroy(msg); - free(err_msg); - free(message); -} - -/* - * mms_send_errmsg() - * - * Parameters: - * - session Connection to MMS to use. - * - message The mms api error message to log to client - * - * This function will log a error that is internal to MMS into the - * clients log file if it is enabled. The message is in the mms catalog - * and thus will be internationalized. If any type of error is encountered, - * the message itself will be outputed to the log file. - * - * Return Values: - * - None - * - */ -void -mms_send_errmsg(mms_session_t *sp, int msgid, ...) -{ - va_list args; - char *message; - - if (sp->clog == NULL) - return; - - /* - * Calculate the message length. - */ - va_start(args, msgid); - message = mms_get_msgcl(msgid, args); - va_end(args); - - if (!message) - return; - - mms_trace(MMS_DEBUG, "mms_send_errmsg: Send message to " - "client's log file:\n%s", message); - - mms_log_error(sp, message); -} - - -/* - * mms_rsp_extract - * - * Extract the command, command type, and tag from the response. - * - * Return: - * 0 Successful - * > 0 API Error - * < 0 Response specific error - */ -int -mms_rsp_extract(mms_session_t *sp, char *input, mms_par_node_t **cmdp, - int *resp_type, char **tid, char **msg) -{ - mms_list_t err_list; - mms_par_err_t *err; - mms_par_node_t *cmd; - mms_par_node_t *cnode; - mms_par_node_t *clause; - mms_par_node_t *value; - - *tid = NULL; - - if (mms_mmp_parse(cmdp, &err_list, input)) { - mms_trace(MMS_ERR, "mms_rsp_extract: parse error " - "detected on MMS input:\n%s", input); - err = mms_list_head(&err_list); - if (err) { - mms_trace(MMS_ERR, - "mms_rsp_extract: mms_mmp_parse, line " - "%d, col %d, near token \"%s\", err code %d, %s", - err->pe_line, err->pe_col, - err->pe_token, err->pe_code, - err->pe_msg); - } - *msg = mms_get_msgcl(MMS_API_3017_MSG, "errmsg", - (err == NULL) ? "parse error" : err->pe_msg); - mms_pe_destroy(&err_list); - return (MMS_E_INVALID_RESPONSE); - } - - mms_pe_destroy(&err_list); - cmd = *cmdp; - - cnode = mms_pn_lookup(cmd, NULL, MMS_PN_CMD, NULL); - if (cnode == NULL) { - mms_trace(MMS_CRIT, "mms_rsp_extract: No command " - "node found in what should be a valid " - "response or event from MMS:\n%s", input); - mms_pn_destroy(cmd); - *msg = mms_get_msgcl(MMS_API_3014_MSG, "part", "command node", - NULL); - return (MMS_E_INVALID_RESPONSE); - } - - /* - * Validate the response. - */ - if ((strcmp("response", mms_pn_token(cnode)) != 0) && - (strcmp("event", mms_pn_token(cnode)) != 0)) { - mms_trace(MMS_ERR, "mms_rsp_extract: Received a non " - "response or event input from MMS:\n%s", input); - mms_pn_destroy(cmd); - return (-1); - } - - /* - * Process an event. - */ - if (strcmp("event", mms_pn_token(cnode)) == 0) { - - mms_trace(MMS_DEBUG, "mms_rsp_extract: Received an " - "event from MMS:\n%s", input); - - clause = mms_pn_lookup(cmd, "tag", MMS_PN_CLAUSE, NULL); - if (clause == NULL) { - mms_trace(MMS_ERR, "mms_rsp_extract: No tag " - "clause found in event:\n%s", input); - *msg = mms_get_msgcl(MMS_API_3013_MSG, NULL); - mms_pn_destroy(cmd); - return (-1); - } - - value = mms_pn_lookup(clause, NULL, MMS_PN_STRING, NULL); - if (value == NULL) { - mms_trace(MMS_ERR, "mms_rsp_extract: No tag " - "string found in event:\n%s", input); - *msg = mms_get_msgcl(MMS_API_3013_MSG, NULL); - mms_pn_destroy(cmd); - return (-1); - } - - *resp_type = MMS_API_RSP_EVENT; - *tid = strdup(mms_pn_token(value)); - - /* - * Process an unacceptable response. - */ - } else if (mms_pn_lookup(cmd, "unacceptable", MMS_PN_KEYWORD, - NULL) != NULL) { - - mms_trace(MMS_DEBUG, "mms_rsp_extract: Received an " - "unaccept response from MMS"); - *tid = strdup(sp->mms_acc_tid); - *resp_type = MMS_API_RSP_UNACC; - - /* - * Process all other response types. - */ - } else { - - mms_trace(MMS_DEVP, "mms_rsp_extract: Received a response " - "from MMS:\n%s", input); - - clause = mms_pn_lookup(cmd, "task", MMS_PN_CLAUSE, NULL); - if (clause == NULL) { - mms_trace(MMS_ERR, "mms_rsp_extract: No task " - "clause found in response:\n%s", input); - mms_pn_destroy(cmd); - *msg = mms_get_msgcl(MMS_API_3014_MSG, "part", - "task id clause", NULL); - return (MMS_MISSING_TASKID); - } - value = mms_pn_lookup(clause, NULL, MMS_PN_STRING, NULL); - if (value == NULL) { - mms_trace(MMS_ERR, "mms_rsp_extract: No task" - "string found in response:\n%s", input); - mms_pn_destroy(cmd); - *msg = mms_get_msgcl(MMS_API_3014_MSG, "part", - "task id string", NULL); - return (MMS_MISSING_TASKID); - } - - *tid = strdup(mms_pn_token(value)); - - /* - * Determine the response type. - */ - if (mms_pn_lookup(cmd, "accepted", MMS_PN_KEYWORD, NULL) - != NULL) { - mms_trace(MMS_DEBUG, "mms_rsp_extract: Received an " - "accept response"); - *resp_type = MMS_API_RSP_ACC; - - } else if (mms_pn_lookup(cmd, "success", - MMS_PN_KEYWORD, NULL) != NULL) { - mms_trace(MMS_DEBUG, "mms_rsp_extract: Received a " - "success response"); - *resp_type = MMS_API_RSP_FINAL; - - } else if (mms_pn_lookup(cmd, "intermediate", - MMS_PN_KEYWORD, NULL) != NULL) { - mms_trace(MMS_DEBUG, "mms_rsp_extract: Received an " - "intermediate response"); - *resp_type = MMS_API_RSP_FINAL_INTR; - - } else if (mms_pn_lookup(cmd, "error", - MMS_PN_CLAUSE, NULL) != NULL) { - mms_trace(MMS_DEBUG, "mms_rsp_extract: Received an " - "error response"); - *resp_type = MMS_API_RSP_FINAL_ERR; - - } else if (mms_pn_lookup(cmd, "cancelled", - MMS_PN_KEYWORD, NULL) != NULL) { - mms_trace(MMS_DEBUG, "mms_rsp_extract: Received a " - "cancelled response"); - *resp_type = MMS_API_RSP_FINAL_CANC; - - } else { - mms_trace(MMS_CRIT, "mms_rsp_extract: Recevied an " - "unknown type of response:\n%s", input); - *msg = mms_get_msgcl(MMS_API_3006_MSG, "taskid", *tid, - NULL); - mms_pn_destroy(cmd); - return (MMS_INVALID_RSP); - } - } - - return (0); -} - - -/* - * mms_rsp_read - * - * Wait for and read a response from the MM. - * - * Return: - * 0 Successful - * > 0 API Error - * < 0 Response specific error - */ -int -mms_rsp_read(mms_session_t *sp, mms_rsp_ele_t **rsp, char **msg) -{ - fd_set fdset; - struct timeval tv; - struct timeval *tvp; - mms_par_node_t *cmd; /* ptr to parsed input string */ - char *input = NULL; /* ptr to input string from MM */ - char *tid = NULL; - int resp_type = 0; - int rc; - - *rsp = NULL; - *msg = NULL; - - /* LINTED warning: constant in conditional context */ - while (1) { - if (sp->mms_api_state == MMS_API_SHUTDOWN) { - mms_trace(MMS_OPER, "mms_rsp_read: MMS " - "API session is being terminated"); - *msg = mms_get_msgcl(MMS_API_3018_MSG, NULL); - return (MMS_API_SHUTDOWN); - } - - if (sp->mms_api_state == MMS_API_FAILURE) { - mms_trace(MMS_ERR, "mms_rsp_read: MMS API is in a state" - " of error, returning error response for command"); - *msg = mms_get_msgcl(MMS_API_3001_MSG, NULL); - return (sp->mms_api_errcode); - } - - FD_ZERO(&fdset); - FD_SET(sp->mms_conn.mms_fd, &fdset); - - tv.tv_sec = 10; - tv.tv_usec = 0; - tvp = &tv; - - rc = select(sp->mms_conn.mms_fd + 1, &fdset, NULL, NULL, tvp); - if (rc < 0) { - if (errno == EINTR) - continue; - else if (errno == EBADF) { - if (sp->mms_api_state == MMS_API_SHUTDOWN) - continue; - mms_trace(MMS_ERR, "mms_rsp_read: " - "Socket to MMS is not open"); - *msg = mms_get_msgcl(MMS_API_3010_MSG, NULL); - return (MMS_E_NET_IO_ERR); - } else { - mms_trace(MMS_ERR, "mms_rsp_read: select " - "failed with errno - %s", strerror(errno)); - *msg = mms_get_msgcl(MMS_API_3011_MSG, "errno", - strerror(errno), NULL); - return (MMS_SELECT_ERROR); - } - } else if (rc == 0) { /* select timeout hit */ - continue; - } else { /* something to read on socket */ - break; - } - } - - /* - * Obtain next response from mm. - */ - if ((rc = mms_reader(&sp->mms_conn, &input)) <= 0) { - if (rc == 0) { - mms_trace(MMS_ERR, "mms_rsp_read: MMS " - "disconnected from client"); - } else { - mms_trace(MMS_ERR, "mms_rsp_read: Failed " - "to read new response, rc - %d", rc); - } - *msg = mms_get_msgcl((rc == 0) ? MMS_API_3012_MSG : - MMS_API_3013_MSG, NULL); - return (MMS_E_NET_IO_ERR); - } - - /* - * Extract the command, type and tag from the data. - */ - rc = mms_rsp_extract(sp, input, &cmd, &resp_type, &tid, msg); - if (rc) { - free(input); - return (rc); - } - - /* - * Create the response structure. - */ - *rsp = mms_rsp_create(input, cmd, resp_type, tid); - - return (0); -} - - -/* - * mms_obtain_accept - * - * Wait for and then process an accept response. - */ -int -mms_obtain_accept(mms_session_t *sp, char *tid, mms_rsp_ele_t **ret_rsp) -{ - mms_rsp_ele_t *rsp; - int rc = MMS_API_OK; - int c; - - mms_trace(MMS_DEBUG, "mms_obtain_accept: Thread looking for accept " - "response, tid - %s", tid); - - if ((c = pthread_mutex_lock(&sp->mms_acc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_obtain_accept: Lock of MMS " - "accept mutex failed with errno - %s", strerror(c)); - } - - *ret_rsp = NULL; - - /* LINTED warning: constant in conditional context */ - while (1) { - - if (sp->mms_api_state == MMS_API_SHUTDOWN) { - mms_trace(MMS_OPER, "mms_obtain_accept: MMS API " - "session is being terminated"); - mms_send_errmsg(sp, MMS_API_3018_MSG, NULL); - rc = MMS_API_SHUTDOWN; - break; - } - - /* - * Check to see if MMS API has encountered an - * internal processing error. - */ - if (sp->mms_api_state == MMS_API_FAILURE) { - mms_trace(MMS_ERR, "mms_obtain_accept: MMS API is in " - "a state of error, returning an error response " - "for command with task id %s", tid); - mms_send_errmsg(sp, MMS_API_3001_MSG, NULL); - rc = sp->mms_api_errcode; - break; - } - - /* - * Process an accept/unaccept if it was received. - */ - if ((rsp = sp->mms_acc_rsp) != NULL) { - - sp->mms_acc_rsp = NULL; - sp->mms_acc_tid = mms_empty_string; - - if (rsp->mms_rsp_type == MMS_API_RSP_ACC && - strcmp(tid, rsp->mms_rsp_tid) != 0) { - - mms_trace(MMS_ERR, "mms_obtain_accept: Task " - "id of accept response, %s, and task id of " - "last command sent to MMS, %s, do not " - "match", rsp->mms_rsp_tid, tid); - - sp->mms_api_errcode = MMS_WRONG_TASKID; - sp->mms_api_state = MMS_API_FAILURE; - mms_send_errmsg(sp, MMS_API_3008_MSG, - "expected", tid, - "received", rsp->mms_rsp_tid, NULL); - mms_free_rsp(rsp); - rc = MMS_WRONG_TASKID; - } - break; - } - - /* - * Wait for the accept response, becoming the socket - * reader if no thread is currently reading from socket. - */ - if (! pthread_mutex_trylock(&sp->mms_reading)) { - - if ((c = pthread_mutex_unlock(&sp->mms_acc_mutex)) - != 0) { - mms_serr(MMS_CRIT, "mms_obtain_accept: " - "Unlock of MMS accept mutex failed " - "with errno - %s", strerror(c)); - } - - rc = mms_sync_reader(sp, MMS_API_RSP_ACC, tid, &rsp); - - if ((c = pthread_mutex_lock(&sp->mms_acc_mutex)) - != 0) { - mms_serr(MMS_CRIT, "mms_obtain_accept: Lock of" - " MMS accept mutex failed with errno - %s", - strerror(c)); - } - - if (rc != MMS_API_OK) - break; - - } else { - if ((c = pthread_cond_wait(&sp->mms_acc_cv, - &sp->mms_acc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_obtain_accept: " - "Unable to wait on accept condition" - " variable, errno - %s", strerror(c)); - } - } - - mms_trace(MMS_DEBUG, "mms_obtain_accept: Thread woken up " - "by broadcast from reader thread to look for a accept " - "response, tid - %s", tid); - } - - if ((c = pthread_mutex_unlock(&sp->mms_acc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_obtain_accept: Unlock of MMS " - "accept mutex failed with errno - %s", strerror(c)); - } - - *ret_rsp = rsp; - - return (rc); -} - - -/* - * mms_obtain_event() - * - * This function obtains an event that has been sent by the MM. - * - * Return Values: - * MMS_API_OK If an event was obtained from MMS. - * ! MMS_API_OK If an error occurred during processing. - * - */ -int -mms_obtain_event(mms_session_t *sp, mms_rsp_ele_t **event) -{ - mms_rsp_ele_t *rsp; - int err; - int rc; - - mms_trace(MMS_DEBUG, "mms_obtain_event: Obtain the next sync event"); - - *event = NULL; - if (sp == NULL) { - mms_trace(MMS_ERR, - "mms_obtain_event: Session pointer is set to " - "NULL, unable to obtain any events at this time"); - mms_send_errmsg(sp, MMS_API_3000_MSG, NULL); - return (MMS_WRONG_API_MODE); - } - - if ((rc = pthread_mutex_lock(&sp->mms_ev_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_obtain_event: Lock of MMS event list " - "mutex failed with errno - %s", strerror(rc)); - } - /* LINTED constant in conditional context */ - while (1) { - if (sp->mms_api_state == MMS_API_SHUTDOWN) { - mms_trace(MMS_OPER, "mms_obtain_event: MMS API " - "session is being terminated"); - rc = MMS_API_SHUTDOWN; - break; - } - if (sp->mms_api_state == MMS_API_FAILURE) { - mms_trace(MMS_ERR, "mms_obtain_event: MMS API is in a " - "state of error, unable to obtain any events " - "at this time"); - rc = sp->mms_api_errcode; - break; - } - - /* - * Check for a queued event. - */ - if ((rsp = mms_list_head(&sp->mms_ev_list)) != NULL) { - - mms_trace(MMS_DEBUG, - "mms_obtain_event: Found event with %s" - " tag waiting to be processed", rsp->mms_rsp_tid); - - mms_list_remove(&sp->mms_ev_list, rsp); - - rc = MMS_API_OK; - *event = rsp; - break; - } - - /* - * Did not find a event for thread. - */ - mms_trace(MMS_DEBUG, - "mms_obtain_event: No event waiting, check if " - "any thread is reading from socket to MM"); - - /* - * If no thread reading from MM, become reader thread. - */ - if (! pthread_mutex_trylock(&sp->mms_reading)) { - - if ((rc = pthread_mutex_unlock(&sp->mms_ev_mutex)) - != 0) { - mms_serr(MMS_CRIT, "mms_obtain_event: Unlock " - "of MMS event list mutex failed with errno" - " - %s", strerror(rc)); - } - - rc = mms_sync_reader(sp, MMS_API_RSP_EVENT, "", - &rsp); - - *event = rsp; - return (rc); - - } else { - mms_trace(MMS_DEBUG, "mms_obtain_event: Reader thread " - "already exists, going into wait"); - - if ((rc = pthread_cond_wait(&sp->mms_ev_cv, - &sp->mms_ev_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_obtain_event: Wait on " - "MMS event condition variable failed with " - "errno - %s", strerror(rc)); - } - } - mms_trace(MMS_DEBUG, "mms_obtain_event: Thread woke up " - "by broadcast from reader thread"); - } - - if ((err = pthread_mutex_unlock(&sp->mms_ev_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_obtain_event: Unlock of MMS event " - "list mutex failed with errno - %s", strerror(err)); - } - - return (rc); -} - - -/* - * mms_obtain_final - * - * Wait for and then process a final response. - */ -int -mms_obtain_final(mms_session_t *sp, char *tid, mms_rsp_ele_t **final_rsp) -{ - mms_rsp_ele_t *rsp; - int rc; - int c; - - mms_trace(MMS_DEBUG, "mms_obtain_final: Thread looking for final " - "response, tid - %s", tid); - - if ((c = pthread_mutex_lock(&sp->mms_rsp_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_obtain_final: Lock of MMS " - "response mutex failed with errno - %s", strerror(c)); - } - - *final_rsp = NULL; - - /* LINTED warning: constant in conditional context */ - while (1) { - - if (sp->mms_api_state == MMS_API_SHUTDOWN) { - mms_trace(MMS_OPER, "mms_obtain_final: MMS API " - "session is being terminated"); - mms_send_errmsg(sp, MMS_API_3018_MSG, NULL); - rc = MMS_API_SHUTDOWN; - break; - } - - /* - * Check to see if MMS API has encountered an - * internal processing error. - */ - if (sp->mms_api_state == MMS_API_FAILURE) { - mms_trace(MMS_ERR, "mms_obtain_final: MMS API is in " - "a state of error, returning an error response " - "for command with task id %s", tid); - mms_send_errmsg(sp, MMS_API_3001_MSG, NULL); - rc = sp->mms_api_errcode; - break; - } - - /* - * Go through response list to see if a final - * response for the specified command exists. - */ - if ((rsp = mms_rsp_find(sp, tid)) != NULL) { - *final_rsp = rsp; - rc = MMS_API_OK; - break; - } - - /* - * Wait for the final response, becoming the socket - * reader if no thread is currently reading from socket. - */ - if (! pthread_mutex_trylock(&sp->mms_reading)) { - - if ((c = pthread_mutex_unlock(&sp->mms_rsp_mutex)) - != 0) { - mms_serr(MMS_CRIT, "mms_obtain_final: " - "Unlock of MMS wait response mutex failed " - "with errno - %s", strerror(c)); - } - - rc = mms_sync_reader(sp, MMS_API_RSP_FINAL, tid, - final_rsp); - - if ((c = pthread_mutex_lock(&sp->mms_rsp_mutex)) - != 0) { - mms_serr(MMS_CRIT, "mms_obtain_final: " - "Lock of MMS wait response mutex failed " - "with errno - %s", strerror(c)); - } - break; - - } else { - if ((c = pthread_cond_wait(&sp->mms_rsp_cv, - &sp->mms_rsp_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_obtain_final: " - "Unable to wait on accept condition" - " variable, errno - %s", strerror(c)); - } - } - - mms_trace(MMS_DEBUG, "mms_obtain_final: Thread woken up " - "by broadcast from reader thread to look for a final " - "response, tid - %s", tid); - } - - if ((c = pthread_mutex_unlock(&sp->mms_rsp_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_obtain_final: Unlock of MMS " - "response mutex failed with errno - %s", strerror(c)); - } - - return (rc); -} - - -/* - * mms_send - * - * Send a command and wait for an accept. - */ -int -mms_send(mms_session_t *sp, char *tid, mms_cmd_name_t cmdtype, char *cmd, - mms_rsp_ele_t **rsp) -{ - mms_rsp_ele_t *rsp_accept; - int cmdlen; - int rc; - int c; - - /* - * A response is returned on synchronous requests. - */ - if (rsp) - *rsp = NULL; - - /* - * Only one begin-end command sequence may be pending at a time, - * If this is a 'begin' command or a command sent synchronously, - * wait for any pending command sequences to complete before - * allowing this command to be sent. - */ - if (cmdtype == MMS_CMD_BEGIN || rsp != NULL) { - mms_be_wait(sp, cmdtype == MMS_CMD_BEGIN); - } - - /* - * Stop other clients from sending commands until this - * client receives an accept or unaccept to this command. - */ - if ((c = pthread_mutex_lock(&sp->mms_cacc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_send: Lock on MMS command " - "accept mutex failed with errno - %s", strerror(c)); - } - - sp->mms_acc_tid = tid; - sp->mms_acc_rsp = NULL; - cmdlen = strlen(cmd); - - if ((c = pthread_mutex_lock(&sp->mms_conn_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_send: Lock of MMS connection " - "mutex failed with errno - %s", strerror(c)); - } - - /* - * Write the command to the socket. - */ - rc = mms_writer(&sp->mms_conn, cmd); - - if ((c = pthread_mutex_unlock(&sp->mms_conn_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_send: Unlock of MMS " - "connection mutex failed with errno - %s", strerror(c)); - } - - if (rc != cmdlen) { - mms_trace(MMS_CRIT, "mms_send: mms_writer failed, " - "rc - %d, command being sent:\n%s", rc, cmd); - if ((c = pthread_mutex_unlock(&sp->mms_cacc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_send: Unlock of MMS " - "command accept mutex failed with errno - %s", - strerror(c)); - } - if (cmdtype == MMS_CMD_END || cmdtype == MMS_CMD_BEGIN) - mms_be_wakeup(sp); - mms_send_errmsg(sp, MMS_API_3005_MSG, "taskid", tid, NULL); - sp->mms_api_errcode = MMS_E_NET_IO_ERR; - sp->mms_api_state = MMS_API_FAILURE; - return (MMS_E_NET_IO_ERR); - } - - /* - * Wait for an accept response. - */ - rc = mms_obtain_accept(sp, tid, &rsp_accept); - - if (rc == MMS_API_OK) { - if (rsp && rsp_accept->mms_rsp_type == MMS_API_RSP_UNACC) { - *rsp = (void *)rsp_accept; - } else { - mms_free_rsp(rsp_accept); - } - } - - if ((c = pthread_mutex_unlock(&sp->mms_cacc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_send: Unlock of MMS command " - "accept mutex failed with errno - %s", strerror(c)); - } - - if (cmdtype == MMS_CMD_END || - ((rc != MMS_API_OK) && (cmdtype == MMS_CMD_BEGIN))) { - mms_be_wakeup(sp); - } - - return (rc); -} - - -/* - * mms_sync_reader - * - * Wait for and then process data written to the socket. - */ -int -mms_sync_reader(mms_session_t *sp, int wait_type, char *tid, - mms_rsp_ele_t **final_rsp) -{ - mms_rsp_ele_t *rsp; - char *msg; - int rc; - int c; - - *final_rsp = NULL; - - mms_trace(MMS_DEBUG, "mms_sync_reader: Thread becoming reader, tid %s", - tid); - - /* LINTED warning: constant in conditional context */ - while (1) { - - /* - * Wait for data to be written to the socket. - */ - rc = mms_rsp_read(sp, &rsp, &msg); - if (rc > 0) { - break; - } else if (rc < 0) { - continue; - } - - /* - * Process an event response. Add the event to the - * event list is there is an registration for the event. - */ - if (rsp->mms_rsp_type == MMS_API_RSP_EVENT) { - - /* - * If waiting for events, return this event. - * Otherwise, queue the response and signal - * the waiting thread. - */ - if (wait_type == MMS_API_RSP_EVENT) { - break; - } else { - mms_ev_insert(sp, rsp); - } - - /* - * An accept/unaccept response was received. - */ - } else if (rsp->mms_rsp_type == MMS_API_RSP_UNACC || - rsp->mms_rsp_type == MMS_API_RSP_ACC) { - - mms_acc_insert(sp, rsp); - - if (wait_type == MMS_API_RSP_ACC) - break; - - /* - * Process a final response. - */ - } else if (rsp->mms_rsp_type >= MMS_API_RSP_FINAL || - rsp->mms_rsp_type <= MMS_API_RSP_FINAL_CANC) { - - if ((wait_type == MMS_API_RSP_FINAL) && - strcmp(rsp->mms_rsp_tid, tid) == 0) { - mms_trace(MMS_DEBUG, "mms_sync_reader: Found a " - "final response for itself, tid %s", tid); - break; - } - - mms_rsp_insert(sp, rsp); - } - } - - if (rc == MMS_API_OK) { - *final_rsp = rsp; - - } else { - mms_log_error(sp, msg); - sp->mms_api_errcode = rc; - if (rc == MMS_API_SHUTDOWN) - sp->mms_api_state = MMS_API_SHUTDOWN; - else - sp->mms_api_state = MMS_API_FAILURE; - } - - /* - * Unlock and wakeup up threads waiting for a response to be - * read. This will allow another thread to become the reader. - */ - if ((c = pthread_mutex_lock(&sp->mms_acc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_sync_reader: Lock MMS accept " - "mutex failed with errno - %s", strerror(c)); - } - if ((c = pthread_mutex_lock(&sp->mms_rsp_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_sync_reader: Lock MMS response " - "mutex failed with errno - %s", strerror(c)); - } - if ((c = pthread_mutex_lock(&sp->mms_ev_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_sync_reader: Lock MMS event " - "mutex failed with errno - %s", strerror(c)); - } - - /* - * Release the reader lock. - */ - if ((c = pthread_mutex_unlock(&sp->mms_reading)) != 0) { - mms_serr(MMS_CRIT, "mms_sync_reader: Unlock of MMS reading " - "mutex failed with errno - %s", strerror(c)); - } - - /* - * Wake-up threads waiting on read. Another thread must - * become the reader if waiting for a response. - */ - if ((c = pthread_cond_broadcast(&sp->mms_ev_cv)) != 0) { - mms_serr(MMS_CRIT, "mms_sync_reader: Broadcast on MMS event " - "response condition variable failed with errno - %s", - strerror(c)); - } - if ((c = pthread_cond_broadcast(&sp->mms_rsp_cv)) != 0) { - mms_serr(MMS_CRIT, "mms_sync_reader: Broadcast on MMS " - "response condition variable failed with errno - %s", - strerror(c)); - } - if ((c = pthread_cond_broadcast(&sp->mms_acc_cv)) != 0) { - mms_serr(MMS_CRIT, "mms_sync_reader: Broadcast on MMS " - "accept condition variable failed with errno - %s", - strerror(c)); - } - - if ((c = pthread_mutex_unlock(&sp->mms_ev_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_sync_reader: Unlock of MMS event " - "mutex failed with errno - %s", strerror(c)); - } - if ((c = pthread_mutex_unlock(&sp->mms_rsp_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_sync_reader: Unlock of MMS response " - "mutex failed with errno - %s", strerror(c)); - } - if ((c = pthread_mutex_unlock(&sp->mms_acc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_sync_reader: Unlock of MMS accept " - "mutex failed with errno - %s", strerror(c)); - } - return (rc); -} - - -/* - * mms_api_reader() - * - * Parameters: - * - arg The structure used to access the session to MMS - * - * The mms_async_init() starts this function as a standalone thread. - * This thread reads input on behalf of a client connect to the MMS - * through an async connection. It will currently handle accept/unaccept - * and final command responses as well as unsolictied events that the client - * has registered for. - * - * Return Values: - * None - * - */ -void * -mms_api_reader(void *arg) -{ - mms_session_t *sp; - mms_rsp_ele_t *new_rsp; - mms_rsp_ele_t *unacc_rsp; - mms_cmd_ele_t *cmd; - char *msg; - char *tid; - int rc; - - mms_trace(MMS_OPER, "mms_api_reader: MMS api reader thread started"); - - sp = (mms_session_t *)arg; - - /* - * Lock the reading thread. The API reader thread should - * always hold this lock. - */ - if (pthread_mutex_trylock(&sp->mms_reading)) { - mms_trace(MMS_ERR, "mms_api_reader: Unable to obtain lock of " - "MMS reading mutex, reader thread exiting"); - sp->mms_api_errcode = MMS_ASYNC_API_FAILURE; - sp->mms_api_state = MMS_API_FAILURE; - /* log msg, set state, any wakeup */ - return ((void *)NULL); - } - - /* - * Reader thread ready for requests. - */ - mms_start_notify(sp); - - /* - * Update the thread count. - */ - mms_thread_start(sp); - - /* - * Wait for input from the MMS socket and process the response. - */ - - /* LINTED warning: constant in conditional context */ - while (1) { - - /* - * Wait for a response from the MM. - */ - rc = mms_rsp_read(sp, &new_rsp, &msg); - if (rc > 0) { - break; - } else if (rc < 0) { - continue; - } - - /* - * Process an event response. - */ - if (new_rsp->mms_rsp_type == MMS_API_RSP_EVENT) { - - if (sp->mms_ev_callbk != NULL) { - mms_trace(MMS_DEBUG, "mms_api_reader: return " - "event with tag %s", new_rsp->mms_rsp_tid); - sp->mms_ev_callbk(sp->mms_ev_callbk_param, - new_rsp); - - } else { - mms_ev_insert(sp, new_rsp); - } - - /* - * Process an accept response. - */ - } else if (new_rsp->mms_rsp_type == MMS_API_RSP_ACC) { - - mms_acc_insert(sp, new_rsp); - - /* - * Process an unaccept response. - */ - } else if (new_rsp->mms_rsp_type == MMS_API_RSP_UNACC) { - - cmd = mms_cmd_remove(sp, new_rsp->mms_rsp_tid); - if (cmd == NULL) { - msg = mms_get_msgcl(MMS_API_3015_MSG, - "list", "command list", - "taskid", new_rsp->mms_rsp_tid, NULL); - rc = MMS_API_ERR; - break; - } - - if (cmd->mms_cmd_type == MMS_API_ASYNC) { - unacc_rsp = new_rsp; - tid = strdup(new_rsp->mms_rsp_tid); - new_rsp = mms_rsp_create(NULL, NULL, - MMS_API_RSP_UNACC, tid); - cmd->mms_cmd_callbk(cmd->mms_cmd_callbk_param, - unacc_rsp); - } - - mms_cmd_free(cmd); - mms_acc_insert(sp, new_rsp); - - /* - * Process a final response. - */ - } else if (new_rsp->mms_rsp_type >= MMS_API_RSP_FINAL || - new_rsp->mms_rsp_type <= MMS_API_RSP_FINAL_CANC) { - - /* - * Find the command in the command list. - */ - cmd = mms_cmd_remove(sp, new_rsp->mms_rsp_tid); - if (cmd == NULL) { - msg = mms_get_msgcl(MMS_API_3015_MSG, - "list", "command list", - "taskid", new_rsp->mms_rsp_tid, NULL); - mms_free_rsp(new_rsp); - break; - } - - mms_trace(MMS_DEBUG, - "mms_api_reader: Final response is for" - " %s command with task id %s", cmd->mms_cmd_type == - MMS_API_ASYNC ? "asynchronous" : "synchronous", - new_rsp->mms_rsp_tid); - - if (cmd->mms_cmd_type == MMS_API_ASYNC) { - cmd->mms_cmd_callbk(cmd->mms_cmd_callbk_param, - new_rsp); - } else { - mms_rsp_insert(sp, new_rsp); - } - - mms_cmd_free(cmd); - - /* - * An invalid response was received. - */ - } else { - msg = mms_get_msgcl(MMS_API_3006_MSG, "taskid", - new_rsp->mms_rsp_tid, NULL); - mms_free_rsp(new_rsp); - break; - } - - } - - /* - * An unrecoverable error occurred. Terminate processing - * and wakeup any threads waiting for responses. - */ - sp->mms_api_errcode = rc; - - if (sp->mms_api_state != MMS_API_SHUTDOWN) { - sp->mms_api_state = MMS_API_FAILURE; - mms_cmd_flush(sp, msg); - mms_rsp_wakeup(sp); - mms_acc_wakeup(sp); - } - - if (sp->mms_async_error != NULL) - sp->mms_async_error(sp->mms_async_error_param); - - if (msg) - free(msg); - - mms_thread_exit(sp); - - return (0); -} diff --git a/usr/src/lib/mms/mms/common/mms_cat.c b/usr/src/lib/mms/mms/common/mms_cat.c deleted file mode 100644 index efdbb64cd6..0000000000 --- a/usr/src/lib/mms/mms/common/mms_cat.c +++ /dev/null @@ -1,372 +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 <libintl.h> -#include <locale.h> -#include <sys/varargs.h> -#include <string.h> -#include <stdlib.h> -#include <stdio.h> -#include <ctype.h> -#include "mms_parser.h" -#include "mms_strapp.h" -#include "mms_trace.h" -#include "mms_sym.h" -#include "msg_sub.h" -#include "mms_cat.h" - -static char *_SrcFile = __FILE__; - -/* - * Message Catalog - */ - - -/* - * Gettext is not redefined here so the C preprocessor output from - * this file can be used for mms message catalog generation. The - * MMS_CAT define is a C preprocessor flag. - */ -#ifndef MMS_CAT -#define gettext(s) s -#endif - -/* - * Get the messsageids and message format strings when the message - * header files are included below. - */ -#define MM_MSG(n, s) s, n, -#define MMS_API_MSG(n, s) s, n, -#define WCR_MSG(n, s) s, n, -#define DM_MSG(n, s) s, n, -#define LM_MSG(n, s) s, n, - -/* - * Message array used to lookup a message format string by messageid. - */ -static mms_sym_t _mms_msg_cat[] = { -/* - * Message header files - */ -#include <mms_mm_msg.h> -#include <mms_api_msg.h> -#include <mms_wcr_msg.h> -#include <mms_dm_msg.h> -#include <mms_lm_msg.h> - NULL, 0 -}; - -/* - * Gettext is once again used to localize the message format string. - */ -#ifndef MMS_CAT -#undef gettext -#endif - -static mms_sym_t *mms_msg_cat = _mms_msg_cat; -static int mms_msg_cat_num = sizeof (_mms_msg_cat) / sizeof (mms_sym_t); - -void -mms_cat_open(void) -{ - /* - * Locale is "C" so the API, WCR, DM and LM use the - * English (EN) language. MM will reset locale based - * on client application preference. - */ - (void) setlocale(LC_MESSAGES, "C"); - - /* - * Set the message catalog file name. - */ - (void) textdomain(TEXT_DOMAIN); - - /* - * Sort the message format strings. - */ - mms_sort_sym_code(mms_msg_cat, mms_msg_cat_num); -} - -char * -mms_get_cat_msg(int msgid) -{ - mms_sym_t *mms_sym; - char *fmt; - - mms_sym = mms_lookup_sym_code(msgid, mms_msg_cat, mms_msg_cat_num); - if (mms_sym != NULL && mms_sym->sym_token != NULL) { - fmt = gettext(mms_sym->sym_token); - } else { - fmt = NULL; - } - - return (fmt); -} - -char * -mms_get_msg(mms_par_node_t *message) -{ - int msgid; - - char *p; - char *fmt; - char *text = NULL; - char *man; - char *model; - char err_msg[128]; - - mms_par_node_t *clause; - mms_par_node_t *arg; - mms_par_node_t *name; - mms_par_node_t *value; - mms_par_node_t *loc; - - /* - * Parse and localize command's message-clause - */ - - MMS_PN_LOOKUP(arg, message, "id", MMS_PN_CLAUSE, NULL); - loc = NULL; - MMS_PN_LOOKUP(value, arg, NULL, MMS_PN_STRING, &loc); - man = value->pn_string; - - MMS_PN_LOOKUP(value, arg, NULL, MMS_PN_STRING, &loc); - model = value->pn_string; - - MMS_PN_LOOKUP(value, arg, NULL, MMS_PN_STRING, &loc); - msgid = atoi(value->pn_string); - - - /* lookup localized message */ - fmt = mms_get_cat_msg(msgid); - if (fmt == NULL || fmt[0] == '\0') { - /* No message found in catalog, obtain loctext */ - /* if one exists and output it */ - goto get_loctext; - } - - /* Make copy so args can be substituted */ - text = strdup(fmt); - - /* Get any arguments for message */ - if (arg = mms_pn_lookup(message, "arguments", MMS_PN_CLAUSE, - NULL)) { - /* Substitute each argument with value in message */ - mms_list_pair_foreach(&arg->pn_arglist, name, value) { - - if (name == NULL || value == NULL) - goto get_loctext; - - if ((p = mms_msg_sub(text, name->pn_string, - value->pn_string)) == NULL) { - mms_trace(MMS_ERR, "mms_get_msg: message " - "argument substitution failed"); - free(text); - goto get_loctext; - } - free(text); - text = p; - } - } - - mms_trace(MMS_DEBUG, - "mms_get_msg: %s %s %d - %s", man, model, msgid, text); - return (text); - -not_found: - mms_trace(MMS_ERR, "mms_get_msg: Missing components to message clause"); - return (NULL); - -get_loctext: - clause = mms_pn_lookup(message, "loctext", MMS_PN_CLAUSE, NULL); - if (clause != NULL) { - loc = NULL; - value = mms_pn_lookup(clause, NULL, MMS_PN_STRING, &loc); - value = mms_pn_lookup(clause, NULL, MMS_PN_STRING, &loc); - if (value != NULL) { - if ((text = value->pn_string) != NULL) { - mms_trace(MMS_OPER, "mms_get_msg: loctext " - "message is:\n%s", text); - return (text); - } - } - } - mms_trace(MMS_OPER, "mms_get_msg: No message found in catalog and " - "no loctext found in message"); - (void) snprintf(err_msg, sizeof (err_msg), - "Unknown Message: Manufacturer: %s, Model: %s, " - "Messageid: %d", man, model, msgid); - text = strdup(err_msg); - return (text); -} - -static char * -mms_get_locale(char *locale, int len) -{ - char *lang; - int i; - - locale[0] = '\0'; - lang = setlocale(LC_MESSAGES, NULL); - if (lang == NULL || lang[0] == 'C') { - (void) snprintf(locale, len, "EN"); - } else { - for (i = 0; i < len - 1 && islower(lang[i]); i++) { - locale[i] = (char)toupper(lang[i]); - locale[i+1] = '\0'; - } - } - return (locale); -} - -char * -mms_get_msgcl(int msgid, ...) -{ - char *msg; - va_list args; - - va_start(args, msgid); - msg = mms_bld_msgcl(msgid, args); - va_end(args); - return (msg); -} - -char * -mms_buf_msgcl(char *buf, int len, int msgid, ...) -{ - char *msg; - va_list args; - - if (buf != NULL && len > 0) { - va_start(args, msgid); - msg = mms_bld_msgcl(msgid, args); - va_end(args); - - buf[0] = '\0'; - if (msg != NULL) { - (void) snprintf(buf, len, "%s", msg); - free(msg); - } - } - return (buf); -} - -char * -mms_bld_msgcl(int msgid, va_list args) -{ - char *msgcl = NULL; - char *msgfmt; - char *arg_key; - char *arg_text; - char *loctext = NULL; - char *argcl = NULL; - char *arglist = NULL; - va_list argscp; - char lang[20]; - - /* - * Get language - */ - (void) mms_get_locale(lang, sizeof (lang)); - - /* - * Get message format string - */ - msgfmt = mms_get_cat_msg(msgid); - if (msgfmt == NULL || msgfmt[0] == '\0') { - /* Undefined message */ - mms_trace(MMS_ERR, "Undefined message id '%d'", msgid); - return (msgcl); - } - - /* - * Create argument list - */ - va_copy(argscp, args); - while ((arg_key = va_arg(argscp, char *)) != NULL) { - if ((arg_text = va_arg(argscp, char *)) == NULL) { - break; - } - arglist = mms_strapp(arglist, "'%s' '%s' ", arg_key, arg_text); - } - va_end(argscp); - - if (arglist) { - argcl = mms_strnew("arguments [ %s ] ", arglist); - free(arglist); - } else { - argcl = strdup(""); - } - - /* - * Localize message - */ - if ((loctext = mms_get_locstr(msgid, args)) == NULL) { - loctext = strdup("\0"); - } - - /* - * Build message clause - */ - msgcl = mms_strapp(msgcl, "message [ id [ 'SUNW' 'MMS' '%d' ] %s " - "loctext [ '%s' '%s' ]] ", msgid, argcl, lang, loctext); - free(argcl); - free(loctext); - return (msgcl); -} - -char * -mms_get_locstr(int msgid, va_list args) -{ - char *s1; - char *s2; - char *arg_key; - char *arg_text; - char *msgfmt; - - /* - * Get localized message format string. - */ - msgfmt = mms_get_cat_msg(msgid); - if (msgfmt == NULL || msgfmt[0] == '\0') { - /* Undefined message */ - mms_trace(MMS_ERR, "Undefined message id '%d'", msgid); - return (NULL); - } - - /* - * Substitute message arguments into message format string - * to create a localized message string. - */ - s1 = strdup(msgfmt); - while ((arg_key = va_arg(args, char *)) != NULL) { - if ((arg_text = va_arg(args, char *)) == NULL) { - break; - } - s2 = mms_msg_sub(s1, arg_key, arg_text); - free(s1); - s1 = s2; - } - return (s1); -} diff --git a/usr/src/lib/mms/mms/common/mms_cfg.c b/usr/src/lib/mms/mms/common/mms_cfg.c deleted file mode 100644 index 3b304abcbb..0000000000 --- a/usr/src/lib/mms/mms/common/mms_cfg.c +++ /dev/null @@ -1,478 +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 <stdlib.h> -#include <strings.h> -#include <stdio.h> -#include <syslog.h> -#include <malloc.h> -#include <errno.h> -#include <sys/param.h> -#include <pthread.h> -#include "mms_cfg.h" - -static struct { - char *mms_cfg_fmri; - scf_type_t mms_cfg_type; -} mms_cfg_list [] = { - MMS_CFG_CONFIG_TYPE, SCF_TYPE_ASTRING, - MMS_CFG_MGR_HOST, SCF_TYPE_USTRING, - MMS_CFG_MGR_PORT, SCF_TYPE_INTEGER, - MMS_CFG_SSL_ENABLED, SCF_TYPE_BOOLEAN, - MMS_CFG_SSL_CERT_FILE, SCF_TYPE_ASTRING, - MMS_CFG_SSL_PASS_FILE, SCF_TYPE_ASTRING, - MMS_CFG_SSL_DH_FILE, SCF_TYPE_ASTRING, - MMS_CFG_SSL_CRL_FILE, SCF_TYPE_ASTRING, - MMS_CFG_SSL_PEER_FILE, SCF_TYPE_ASTRING, - MMS_CFG_SSL_CIPHER, SCF_TYPE_ASTRING, - MMS_CFG_SSL_VERIFY, SCF_TYPE_BOOLEAN, - MMS_CFG_DB_DATA, SCF_TYPE_ASTRING, - MMS_CFG_DB_LOG, SCF_TYPE_ASTRING, - MMS_CFG_MM_DB_HOST, SCF_TYPE_ASTRING, - MMS_CFG_MM_DB_PORT, SCF_TYPE_INTEGER, - MMS_CFG_MM_DB_USER, SCF_TYPE_ASTRING, - MMS_CFG_MM_DB_NAME, SCF_TYPE_ASTRING, - MMS_CFG_MM_TRACE, SCF_TYPE_ASTRING, - MMS_CFG_SSI_PATH, SCF_TYPE_ASTRING, - MMS_CFG_LIBAPI_PATH, SCF_TYPE_ASTRING, - MMS_CFG_DB_RETRY, SCF_TYPE_INTEGER, - MMS_CFG_DB_TIMEOUT, SCF_TYPE_INTEGER, - NULL, NULL, -}; - -static pthread_mutex_t mms_cfg_mutex = PTHREAD_MUTEX_INITIALIZER; -static scf_handle_t *mms_cfg_handle = NULL; -static scf_scope_t *mms_cfg_scope = NULL; -static scf_service_t *mms_cfg_svc = NULL; -static scf_instance_t *mms_cfg_inst = NULL; -static scf_propertygroup_t *mms_cfg_pg = NULL; -static scf_property_t *mms_cfg_prop = NULL; - -static int mms_cfg_bind(void); -static int mms_cfg_open(const char *fmri); -static void mms_cfg_close(void); -static int mms_cfg_set_prop(const char *name, const char *value, - scf_type_t type); -static int mms_cfg_delete_prop(const char *name); -static int mms_cfg_tx_error(scf_transaction_t *tx, - scf_transaction_entry_t *e1, scf_value_t *v1); -static void mms_cfg_tx_fini(scf_transaction_t *tx, - scf_transaction_entry_t *e1, scf_value_t *v1); - -scf_type_t -mms_cfg_get_type(const char *fmri) -{ - int i; - - for (i = 0; mms_cfg_list[i].mms_cfg_fmri != NULL; i++) { - if (strcmp(mms_cfg_list[i].mms_cfg_fmri, fmri) == 0) { - /* built-in property */ - return (mms_cfg_list[i].mms_cfg_type); - } - } - /* not built-in property */ - return (SCF_TYPE_INVALID); -} - -static int -mms_cfg_bind(void) -{ - int rc = 0; - - if (!(mms_cfg_handle = scf_handle_create(SCF_VERSION)) || - !(mms_cfg_scope = scf_scope_create(mms_cfg_handle)) || - !(mms_cfg_svc = scf_service_create(mms_cfg_handle)) || - !(mms_cfg_inst = scf_instance_create(mms_cfg_handle)) || - !(mms_cfg_pg = scf_pg_create(mms_cfg_handle)) || - !(mms_cfg_prop = scf_property_create(mms_cfg_handle)) || - scf_handle_bind(mms_cfg_handle) == -1) { - rc = scf_error(); - mms_cfg_close(); - } - return (rc); -} - -static int -mms_cfg_open(const char *fmri) -{ - int rc; - - if (rc = mms_cfg_bind()) { - return (rc); - } - if (scf_handle_decode_fmri(mms_cfg_handle, fmri, - mms_cfg_scope, mms_cfg_svc, mms_cfg_inst, mms_cfg_pg, - mms_cfg_prop, 0) == -1) { - rc = scf_error(); - mms_cfg_close(); - } - return (rc); -} - -static void -mms_cfg_close(void) -{ - if (mms_cfg_handle) - scf_handle_destroy(mms_cfg_handle); - if (mms_cfg_scope) - scf_scope_destroy(mms_cfg_scope); - if (mms_cfg_svc) - scf_service_destroy(mms_cfg_svc); - if (mms_cfg_inst) - scf_instance_destroy(mms_cfg_inst); - if (mms_cfg_pg) - scf_pg_destroy(mms_cfg_pg); - if (mms_cfg_prop) - scf_property_destroy(mms_cfg_prop); - - mms_cfg_handle = NULL; - mms_cfg_scope = NULL; - mms_cfg_svc = NULL; - mms_cfg_inst = NULL; - mms_cfg_pg = NULL; - mms_cfg_prop = NULL; -} - -char * -mms_cfg_alloc_getvar(const char *fmri, int *err) -{ - char *value = malloc(MMS_CFG_MAX_VALUE); - char *str = NULL; - int rc; - - if (rc = mms_cfg_getvar(fmri, value)) { - if (err) - *err = rc; - free(value); - return (NULL); - } - if (strlen(value) > 0) { - if ((str = strdup(value)) == NULL) { - rc = SCF_ERROR_NO_MEMORY; - } - } - if (err) - *err = rc; - free(value); - return (str); -} - -int -mms_cfg_getvar(const char *fmri, char *value) -{ - int rc; - scf_value_t *svalue; - - (void) pthread_mutex_lock(&mms_cfg_mutex); - if (rc = mms_cfg_open(fmri)) { - (void) pthread_mutex_unlock(&mms_cfg_mutex); - return (rc); - } - - if (!(svalue = scf_value_create(mms_cfg_handle)) || - scf_property_get_value(mms_cfg_prop, svalue) == -1 || - scf_value_get_as_string(svalue, value, MMS_CFG_MAX_VALUE) == -1) { - rc = scf_error(); - } - - if (svalue) - scf_value_destroy(svalue); - - mms_cfg_close(); - (void) pthread_mutex_unlock(&mms_cfg_mutex); - return (rc); -} - -static int -mms_cfg_set_prop(const char *name, const char *value, scf_type_t type) -{ - scf_transaction_t *tx; - scf_transaction_entry_t *e1; - scf_value_t *v1; - - tx = scf_transaction_create(mms_cfg_handle); - e1 = scf_entry_create(mms_cfg_handle); - v1 = scf_value_create(mms_cfg_handle); - - if (scf_pg_update(mms_cfg_pg) == -1) { - return (mms_cfg_tx_error(tx, e1, v1)); - } - if (scf_transaction_start(tx, mms_cfg_pg) == -1) { - return (mms_cfg_tx_error(tx, e1, v1)); - } - if (scf_transaction_property_new(tx, e1, name, type) == -1) { - if (scf_error() != SCF_ERROR_EXISTS) { - return (mms_cfg_tx_error(tx, e1, v1)); - } - if (scf_transaction_property_change(tx, e1, name, type) == -1) { - return (mms_cfg_tx_error(tx, e1, v1)); - } - } - if (scf_value_set_from_string(v1, type, value) == -1) { - return (mms_cfg_tx_error(tx, e1, v1)); - } - if (scf_entry_add_value(e1, v1) == -1) { - return (mms_cfg_tx_error(tx, e1, v1)); - } - if (scf_transaction_commit(tx) == -1) { - return (mms_cfg_tx_error(tx, e1, v1)); - } - mms_cfg_tx_fini(tx, e1, v1); - return (0); -} - -static void -mms_cfg_get_pg_name(const char *fmri, char *name) -{ - char *buf = malloc(MMS_CFG_MAX_NAME); - char *end; - char *begin; - - (void) strlcpy(buf, fmri, MMS_CFG_MAX_NAME); - if (end = strrchr(buf, '/')) { - *end = 0; - if (begin = strrchr(buf, '/')) { - (void) strlcpy(name, begin + 1, MMS_CFG_MAX_NAME); - free(buf); - return; - } - } - (void) strlcpy(name, fmri, MMS_CFG_MAX_NAME); - free(buf); -} - -static void -mms_cfg_get_prop_name(const char *fmri, char *name) -{ - char *begin; - - if (begin = strrchr(fmri, '/')) { - (void) strlcpy(name, begin + 1, MMS_CFG_MAX_NAME); - return; - } - (void) strlcpy(name, fmri, MMS_CFG_MAX_NAME); -} - -static char * -mms_cfg_get_inst(const char *fmri) -{ - if (strncmp(fmri, MMS_CFG_MM_INST, strlen(MMS_CFG_MM_INST)) == 0) { - return (MMS_CFG_MM_INST); - } - - if (strncmp(fmri, MMS_CFG_DB_INST, strlen(MMS_CFG_DB_INST)) == 0) { - return (MMS_CFG_DB_INST); - } - - if (strncmp(fmri, MMS_CFG_WCR_INST, strlen(MMS_CFG_WCR_INST)) == 0) { - return (MMS_CFG_WCR_INST); - } - - return ((char *)fmri); -} - -static int -mms_cfg_newvar(const char *fmri, const char *value, scf_type_t type) -{ - int rc; - char *pg_name = malloc(MMS_CFG_MAX_NAME); - char *prop_name = malloc(MMS_CFG_MAX_NAME); - - if (rc = mms_cfg_bind()) { - free(pg_name); - free(prop_name); - return (rc); - } - - mms_cfg_get_pg_name(fmri, pg_name); - mms_cfg_get_prop_name(fmri, prop_name); - - if (fmri[strlen(MMS_CFG_SVC)] == '/') { - /* service property group */ - if (scf_handle_get_scope(mms_cfg_handle, SCF_SCOPE_LOCAL, - mms_cfg_scope) == -1) { - free(pg_name); - free(prop_name); - return (scf_error()); - } - if (scf_scope_get_service(mms_cfg_scope, MMS_CFG_MMS_SVC, - mms_cfg_svc) == -1) { - free(pg_name); - free(prop_name); - return (scf_error()); - } - if (scf_service_get_pg(mms_cfg_svc, pg_name, - mms_cfg_pg) == -1) { - if ((rc = scf_error()) != SCF_ERROR_NOT_FOUND) { - free(pg_name); - free(prop_name); - return (rc); - } - if (scf_service_add_pg(mms_cfg_svc, pg_name, - SCF_GROUP_APPLICATION, 0, mms_cfg_pg) == -1) { - free(pg_name); - free(prop_name); - return (scf_error()); - } - } - } else { - /* service instance property group */ - if (scf_handle_decode_fmri(mms_cfg_handle, - mms_cfg_get_inst(fmri), mms_cfg_scope, mms_cfg_svc, - mms_cfg_inst, mms_cfg_pg, NULL, 0) == -1) { - free(pg_name); - free(prop_name); - return (scf_error()); - } - if (scf_instance_get_pg(mms_cfg_inst, pg_name, - mms_cfg_pg) == -1) { - if ((rc = scf_error()) != SCF_ERROR_NOT_FOUND) { - free(pg_name); - free(prop_name); - return (rc); - } - if (scf_instance_add_pg(mms_cfg_inst, pg_name, - SCF_GROUP_APPLICATION, 0, mms_cfg_pg) == -1) { - free(pg_name); - free(prop_name); - return (scf_error()); - } - } - } - rc = mms_cfg_set_prop(prop_name, value, type); - free(pg_name); - free(prop_name); - return (rc); -} - -int -mms_cfg_setvar(const char *fmri, const char *value) -{ - int rc; - scf_type_t type; - - if ((type = mms_cfg_get_type(fmri)) == SCF_TYPE_INVALID) { - /* not built-in, try explicit setvar type func */ - return (SCF_TYPE_INVALID); - } - rc = mms_cfg_setvar_type(fmri, value, type); - return (rc); -} - -int -mms_cfg_setvar_type(const char *fmri, const char *value, scf_type_t type) -{ - int rc; - char *name = malloc(MMS_CFG_MAX_NAME); - - (void) pthread_mutex_lock(&mms_cfg_mutex); - if (rc = mms_cfg_open(fmri)) { - if (rc != SCF_ERROR_NOT_FOUND) { - (void) pthread_mutex_unlock(&mms_cfg_mutex); - free(name); - return (rc); - } - rc = mms_cfg_newvar(fmri, value, type); - } else { - if (scf_property_get_name(mms_cfg_prop, name, - MMS_CFG_MAX_NAME) == -1) { - rc = scf_error(); - } else { - rc = mms_cfg_set_prop(name, value, type); - } - } - mms_cfg_close(); - (void) pthread_mutex_unlock(&mms_cfg_mutex); - free(name); - return (rc); -} - -static int -mms_cfg_delete_prop(const char *name) -{ - scf_transaction_t *tx; - scf_transaction_entry_t *e1; - - tx = scf_transaction_create(mms_cfg_handle); - e1 = scf_entry_create(mms_cfg_handle); - - if (scf_pg_update(mms_cfg_pg) == -1) { - return (mms_cfg_tx_error(tx, e1, NULL)); - } - if (scf_transaction_start(tx, mms_cfg_pg) == -1) { - return (mms_cfg_tx_error(tx, e1, NULL)); - } - if (scf_transaction_property_delete(tx, e1, name) == -1) { - return (mms_cfg_tx_error(tx, e1, NULL)); - } - if (scf_transaction_commit(tx) == -1) { - return (mms_cfg_tx_error(tx, e1, NULL)); - } - mms_cfg_tx_fini(tx, e1, NULL); - return (0); -} - -int -mms_cfg_unsetvar(const char *fmri) -{ - int rc; - char *name = malloc(MMS_CFG_MAX_NAME); - - (void) pthread_mutex_lock(&mms_cfg_mutex); - if (rc = mms_cfg_open(fmri)) { - (void) pthread_mutex_unlock(&mms_cfg_mutex); - free(name); - return (rc); - } - if (scf_property_get_name(mms_cfg_prop, name, MMS_CFG_MAX_NAME) == -1) { - rc = scf_error(); - } else { - rc = mms_cfg_delete_prop(name); - } - mms_cfg_close(); - (void) pthread_mutex_unlock(&mms_cfg_mutex); - free(name); - return (rc); -} - -static int -mms_cfg_tx_error(scf_transaction_t *tx, scf_transaction_entry_t *e1, - scf_value_t *v1) -{ - mms_cfg_tx_fini(tx, e1, v1); - return (scf_error()); -} - -static void -mms_cfg_tx_fini(scf_transaction_t *tx, scf_transaction_entry_t *e1, - scf_value_t *v1) -{ - scf_transaction_reset(tx); - scf_transaction_destroy(tx); - if (e1) - scf_entry_destroy(e1); - if (v1) - scf_value_destroy(v1); -} diff --git a/usr/src/lib/mms/mms/common/mms_cfg.h b/usr/src/lib/mms/mms/common/mms_cfg.h deleted file mode 100644 index a3df0da15f..0000000000 --- a/usr/src/lib/mms/mms/common/mms_cfg.h +++ /dev/null @@ -1,83 +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 _MMS_CFG_H -#define _MMS_CFG_H - - -#include <libscf.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define MMS_CFG_MAX_NAME scf_limit(SCF_LIMIT_MAX_NAME_LENGTH) -#define MMS_CFG_MAX_VALUE scf_limit(SCF_LIMIT_MAX_VALUE_LENGTH) - -#define MMS_CFG_MMS_SVC "application/management/mms" -#define MMS_CFG_SVC "svc:/" MMS_CFG_MMS_SVC -#define MMS_CFG_MM_INST MMS_CFG_SVC ":mm" -#define MMS_CFG_DB_INST MMS_CFG_SVC ":db" -#define MMS_CFG_WCR_INST MMS_CFG_SVC ":wcr" - -#define MMS_CFG_CONFIG_TYPE MMS_CFG_SVC "/:properties/config/type" -#define MMS_CFG_MGR_HOST MMS_CFG_SVC "/:properties/manager/host" -#define MMS_CFG_MGR_PORT MMS_CFG_SVC "/:properties/manager/port" -#define MMS_CFG_SSL_ENABLED MMS_CFG_SVC "/:properties/ssl/enabled" -#define MMS_CFG_SSL_CERT_FILE MMS_CFG_SVC "/:properties/ssl/cert_file" -#define MMS_CFG_SSL_PASS_FILE MMS_CFG_SVC "/:properties/ssl/pass_file" -#define MMS_CFG_SSL_DH_FILE MMS_CFG_SVC "/:properties/ssl/dh_file" -#define MMS_CFG_SSL_CRL_FILE MMS_CFG_SVC "/:properties/ssl/crl_file" -#define MMS_CFG_SSL_PEER_FILE MMS_CFG_SVC "/:properties/ssl/peer_file" -#define MMS_CFG_SSL_CIPHER MMS_CFG_SVC "/:properties/ssl/cipher" -#define MMS_CFG_SSL_VERIFY MMS_CFG_SVC "/:properties/ssl/verify" -#define MMS_CFG_DB_DATA MMS_CFG_DB_INST "/:properties/postgresql/data" -#define MMS_CFG_DB_LOG MMS_CFG_DB_INST "/:properties/postgresql/log" -#define MMS_CFG_DB_BIN MMS_CFG_DB_INST "/:properties/postgresql/bin" -#define MMS_CFG_MM_DB_HOST MMS_CFG_MM_INST "/:properties/db/host" -#define MMS_CFG_MM_DB_PORT MMS_CFG_MM_INST "/:properties/db/port" -#define MMS_CFG_MM_DB_USER MMS_CFG_MM_INST "/:properties/db/user" -#define MMS_CFG_MM_DB_NAME MMS_CFG_MM_INST "/:properties/db/name" -#define MMS_CFG_MM_TRACE MMS_CFG_MM_INST "/:properties/option/trace" -#define MMS_CFG_SSI_PATH MMS_CFG_SVC ":wcr/:properties/option/ssi_path" -#define MMS_CFG_LIBAPI_PATH MMS_CFG_SVC \ - ":wcr/:properties/option/libapi_path" -#define MMS_CFG_DB_RETRY MMS_CFG_SVC \ - ":mm/:properties/option/db_reconnect_max_retry" -#define MMS_CFG_DB_TIMEOUT MMS_CFG_SVC \ - ":mm/:properties/option/db_reconnect_timeout" - -char *mms_cfg_alloc_getvar(const char *fmri, int *err); -int mms_cfg_getvar(const char *fmri, char *value); -int mms_cfg_setvar(const char *fmri, const char *value); -int mms_cfg_unsetvar(const char *fmri); -scf_type_t mms_cfg_get_type(const char *fmri); -int mms_cfg_setvar_type(const char *fmri, const char *value, scf_type_t type); - - -#ifdef __cplusplus -} -#endif - -#endif /* _MMS_CFG_H */ diff --git a/usr/src/lib/mms/mms/common/mms_client.c b/usr/src/lib/mms/mms/common/mms_client.c deleted file mode 100644 index a71ff15c5d..0000000000 --- a/usr/src/lib/mms/mms/common/mms_client.c +++ /dev/null @@ -1,1521 +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 <mms.h> -#include <mgmt_mms.h> - -static char *_SrcFile = __FILE__; - /* Only first call to mms_init or mms_ainit */ - /* will create a mms_trace file if called for */ - -char mms_empty_string[] = "empty"; -char *mms_empty_message = "No loctext message found\n"; - -char *mms_api[] = { - "Unconfigured", - "Asynchronous", - "Synchronous", - NULL}; - -char *mms_state[] = { - "Unconfigured", - "Configured", - "Failure", - "Shutdown", - NULL}; - -/* - * mms_free_rsp() - * - * Parameters: - * - rsp Pointer to a response returned from one of - * routines that return a command response or - * the response sent to a callback routine. - * - * This function is used by a client to free unneeded responses to commands. - * list elements. - * - * Return Values: - * None - * - */ -void -mms_free_rsp(void *rsp) -{ - mms_rsp_ele_t *ele = (mms_rsp_ele_t *)rsp; - - if (ele != NULL) { - if (ele->mms_rsp_tid != NULL) - free(ele->mms_rsp_tid); - if (ele->mms_rsp_str != NULL) - free(ele->mms_rsp_str); - if (ele->mms_rsp_cmd != NULL) - mms_pn_destroy(ele->mms_rsp_cmd); - free(ele); - ele = NULL; - mms_trace(MMS_DEBUG, "mms_free_rsp: Completed free of response " - "list element memory"); - } else { - mms_trace(MMS_DEBUG, "mms_free_rsp: response list element is " - "NULL, no memory to free"); - } -} - -/* - * mms_handle_err_rsp() - * - * Parameters: - * - response The error response to process - * - class The class contained in the response - * - code The code contained in the response - * - msg The internationalized version of the error message - * This message needs to be freed by the client once - * it is done with it. - * - * This function takes an error response and processes on behalf of the - * the client. - * - * Return Values: - * - MMS_API_NOT_ERR_RSP if response is not an error response - * - MMS_API_ERROR if unable to obtain error class and code - * - MMS_API_OK if processing completed correctly - * - */ -int -mms_handle_err_rsp(void *response, int *class, int *code, char **msg) -{ - mms_rsp_ele_t *rsp = (mms_rsp_ele_t *)response; - - mms_par_node_t *clause; - mms_par_node_t *token; - mms_par_node_t *loc = NULL; - - *msg = NULL; - - if (rsp->mms_rsp_type != MMS_API_RSP_FINAL_ERR) { - mms_trace(MMS_ERR, "mms_handle_err_rsp: Response is " - " not a error response:\n%s", rsp->mms_rsp_str); - return (MMS_API_NOT_ERR_RSP); - } - - MMS_PN_LOOKUP(clause, rsp->mms_rsp_cmd, "error", MMS_PN_CLAUSE, - NULL); - MMS_PN_LOOKUP(token, clause, NULL, MMS_PN_KEYWORD, &loc); - *class = mms_sym_str_to_code(mms_pn_token(token)); - MMS_PN_LOOKUP(token, clause, NULL, MMS_PN_KEYWORD, &loc); - *code = mms_sym_str_to_code(mms_pn_token(token)); - - if ((clause = mms_pn_lookup(rsp->mms_rsp_cmd, "message", - MMS_PN_CLAUSE, NULL)) != NULL) { - if ((*msg = mms_get_msg(clause)) == NULL) - *msg = strdup(rsp->mms_rsp_str); - } - - return (MMS_API_OK); - -not_found: - mms_trace(MMS_ERR, "mms_handle_err_rsp: Missing class or code in " - "error response:\n%s", rsp->mms_rsp_str); - return (MMS_API_ERROR); -} - -/* - * mms_hello() - * - * Parameters: - * - session Session structure to to use to connect to MMS. - * - host The hostname of where MM is running. - * - port The port where MM is running. - * - app Name of client's application name to use in - * HELLO command. - * - ai Name of client's application instance to use in - * HELLO command. - * - tag This is an optional parameter that a client can - * specify that will tag the session with this value. - * If no tag is to be used, use NULL. - * - cli_pass Client's password to use in HELLO command. - * - mm_pass Optional, expected password in MMS_WELCOME response, - * set to null for no password validation. - * - ssl_data SSL connection data is required for secure MM, - * set to null for no SSL connection. - * - * This function fills in the network structure with the client's - * specific information to use in the HELLO command that is to - * be sent to MMS. - * If the connection is an async connection, it will start the writer and - * reader threads after the connection is established. - * - * Return Values: - * MMS_API_OK If connection was made successfully. - * ! MMS_API_OK The code relevant to the internal processing error - * that was encountered. If the client has registered - * a logging routine for the API, a message will be - * sent to that routine. - * - */ -int -mms_hello(void *session, char *host, char *port, char *app, char *ai, char *tag, - char *cli_pass, char *mm_pass, void *ssl_data) -{ - mms_network_cfg_t net; - int rc; - - (void) memset(&net, 0, sizeof (mms_network_cfg_t)); - net.cli_host = host; - net.cli_port = port; - net.cli_name = app; - net.cli_inst = ai; - net.cli_vers = MMS_MMP_VERSION; - net.cli_lang = MMS_MMP_LANG; - net.cli_pass = cli_pass; - net.mm_pass = mm_pass; - - rc = mms_hello_net(session, &net, tag, ssl_data); - return (rc); -} - -/* - * mms_hello_net() - * - * Parameters: - * - session Session structure to to use to connect to MMS. - * - net MMS network configuration where the MMS MM is located. - * - tag This is an optional parameter that a client can - * specify that will tag the session with this value. - * If no tag is to be used, use NULL. - * - ssl_data SSL connection data is required for secure MM, - * set to null for no SSL connection. - * - * This function uses the network structure with the client's - * specific information to use in the HELLO command that is to - * be sent to MMS. - * If the connection is an async connection, it will start the writer and - * reader threads after the connection is established. - * - * Return Values: - * MMS_API_OK If connection was made successfully. - * ! MMS_API_OK The code relevant to the internal processing error - * that was encountered. If the client has registered - * a logging routine for the API, a message will be - * sent to that routine. - * - */ -int -mms_hello_net(void *session, mms_network_cfg_t *net, char *tag, void *ssl_data) -{ - mms_session_t *sp = (mms_session_t *)session; - pthread_t id; - int rc; - int err; - - - if (mms_mmconnect(net, ssl_data, &sp->mms_conn, &err, tag) != 0) { - mms_trace(MMS_ERR, "mms_hello: Error returned from " - "mms_mmconnect() - %d, %s", err, mms_sym_code_to_str(err)); - mms_send_errmsg(sp, MMS_API_3051_MSG, "error", - mms_sym_code_to_str(err), NULL); - return (err); - } - - if (sp->mms_api_mode == MMS_API_ASYNC) { - - /* Start reader thread */ - if ((rc = pthread_create(&id, &sp->mms_reader_attr, - mms_api_reader, (void *)sp)) != 0) { - mms_serr(MMS_CRIT, "mms_hello: Start of MMS reader " - "thread failed with errno - %s", strerror(rc)); - } - - /* Wait until reader thread gets starts */ - if ((rc = pthread_mutex_lock(&sp->mms_acc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_hello: Lock of MMS reader " - "start mutex failed with errno - %s", strerror(rc)); - } - - while (sp->mms_api_rstarted == MMS_API_NO) { - if ((rc = pthread_cond_wait(&sp->mms_acc_cv, - &sp->mms_acc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_hello: Unable to wait " - "on reader start condition variable, errno " - "- %s", strerror(rc)); - } - } - - if ((rc = pthread_mutex_unlock(&sp->mms_acc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_hello: Unlock of MMS reader " - "start mutex failed with errno - %s", strerror(rc)); - } - } - - mms_trace(MMS_OPER, "mms_hello: Client connected to MMS"); - return (MMS_API_OK); -} - -/* - * mms_sess_create - * - * Allocate and initialize a session structure. - */ -mms_session_t * -mms_sess_create() -{ - mms_session_t *sp; - int rc; - - if ((sp = (mms_session_t *)malloc(sizeof (mms_session_t))) == NULL) { - mms_trace(MMS_CRIT, - "mms_sess_create: Malloc of memory for a new " - "client session failed with errno - %s", strerror(errno)); - return (NULL); - } - - (void) memset(sp, 0, sizeof (mms_session_t)); - - /* - * Create lists for the command responses, registered events, - * and events received. - */ - mms_list_create(&sp->mms_rsp_list, sizeof (mms_rsp_ele_t), - offsetof(mms_rsp_ele_t, mms_rsp_next)); - mms_list_create(&sp->mms_ev_list, sizeof (mms_rsp_ele_t), - offsetof(mms_rsp_ele_t, mms_rsp_next)); - mms_list_create(&sp->mms_cmd_list, sizeof (mms_cmd_ele_t), - offsetof(mms_cmd_ele_t, mms_cmd_next)); - - /* - * Initialize a mutex used to track the number of outstanding - * client threads with pending MM requests. - */ - if ((rc = pthread_mutex_init(&sp->mms_cnt_mutex, NULL)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_create: Create of MMS count " - "mutex failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_cond_init(&sp->mms_cnt_cv, NULL)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_create: Init of MMS count " - "condition variable failed with errno - %s", strerror(rc)); - } - - /* - * Initialize a mutex to allow only one command to be - * sent to MMS until a accept response is received. - */ - if ((rc = pthread_mutex_init(&sp->mms_cacc_mutex, NULL)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_create: Create of MMS command " - "accept mutex failed with errno - %s", strerror(rc)); - } - - /* - * Create mutex and condition variable to coordinate handling of - * accept/unaccept responses between a reader thread and a thread - * waiting on accept response. - */ - if ((rc = pthread_mutex_init(&sp->mms_acc_mutex, NULL)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_create: Create of MMS accept " - "mutex failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_cond_init(&sp->mms_acc_cv, NULL)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_create: Init of MMS accept " - "condition variable failed with errno - %s", strerror(rc)); - } - - /* - * Initialize a mutex used to manage the pending commands. - */ - if ((rc = pthread_mutex_init(&sp->mms_cmd_mutex, NULL)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_create: Create of MMS command " - "list mutex init failed with errno - %s", strerror(rc)); - } - - /* - * Create mutex and condition variable to coordinate handling of - * final responses between a reader thread and a thread waiting on - * final response. - */ - if ((rc = pthread_mutex_init(&sp->mms_rsp_mutex, NULL)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_create: Create of MMS response " - "list mutex failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_cond_init(&sp->mms_rsp_cv, NULL)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_create: Init of MMS response " - "list condition variable failed with errno - %s", - strerror(rc)); - } - - /* - * Initialize a mutex and condition variable which will be used to - * prevent more than one begin-end sequence being sent to the MM. - */ - if ((rc = pthread_mutex_init(&sp->mms_be_mutex, NULL)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_create: Create of MMS begin-end " - "mutex failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_cond_init(&sp->mms_be_cv, NULL)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_create: Init of MMS begin-end " - "condition variable failed with errno - %s", strerror(rc)); - } - - /* - * Create mutex to allow only one thread to write to the - * socket at a time. - */ - if ((rc = pthread_mutex_init(&sp->mms_conn_mutex, NULL)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_create: Init of MMS connection " - "mutex failed with errno - %s", strerror(rc)); - } - - /* - * Create mutex to allow only one thread to become the socket reader. - */ - if ((rc = pthread_mutex_init(&sp->mms_reading, NULL)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_create: Init of MMS reading " - "mutex failed with errno - %s", strerror(rc)); - } - - /* - * Initialize an event manager mutex and condition variable. - */ - if ((rc = pthread_mutex_init(&sp->mms_ev_mutex, NULL)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_create: Init of MMS event list " - "mutex failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_cond_init(&sp->mms_ev_cv, NULL)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_create: Init of MMS event list " - "condition variable failed with errno - %s", strerror(rc)); - } - - if ((rc = pthread_attr_init(&sp->mms_reader_attr)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_create: Init of MMS reader's " - "attribute failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_attr_setdetachstate(&sp->mms_reader_attr, - PTHREAD_CREATE_DETACHED)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_create: Create of MMS reader " - "detach state failed with errno - %s", strerror(rc)); - } - - sp->clog = NULL; - sp->cprefix = NULL; - sp->mms_thrd_cnt = 0; - sp->mms_be_pending = B_FALSE; - - return (sp); -} - - -/* - * mms_sess_free - * - * Free all resources used to manage a session. - */ -void -mms_sess_free(mms_session_t *sp) -{ - int rc; - - if ((rc = pthread_cond_destroy(&sp->mms_cnt_cv)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_free: Destroy of MMS count " - "condition variable failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_mutex_destroy(&sp->mms_cnt_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_free: Destroy of MMS count " - "mutex failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_mutex_destroy(&sp->mms_cmd_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_free: Destroy of MMS command " - "mutex failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_cond_destroy(&sp->mms_acc_cv)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_free: Destroy of MMS accept " - "condition variable failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_mutex_destroy(&sp->mms_acc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_free: Destroy of MMS accept " - "mutex failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_mutex_destroy(&sp->mms_cacc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_free: Destroy of MMS command " - "accept mutex failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_cond_destroy(&sp->mms_rsp_cv)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_free: Destroy of MMS response " - "condition variable failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_mutex_destroy(&sp->mms_rsp_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_free: Destroy of MMS response " - "mutex failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_cond_destroy(&sp->mms_be_cv)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_free: Destroy of MMS begin-end " - "condition variable failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_mutex_destroy(&sp->mms_be_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_free: Destroy of MMS begin-end " - "mutex failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_cond_destroy(&sp->mms_ev_cv)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_free: Destroy of MMS event " - "condition variable failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_mutex_destroy(&sp->mms_ev_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_free: Destroy of MMS event " - "mutex failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_mutex_destroy(&sp->mms_conn_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_free: Destroy of MMS connection" - " mutex failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_mutex_destroy(&sp->mms_reading)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_free: Destroy of MMS reading " - "mutex failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_attr_destroy(&sp->mms_reader_attr)) != 0) { - mms_serr(MMS_CRIT, "mms_sess_free: Destroy of MMS reader " - "attribute failed with errno - %s", strerror(rc)); - } - - mms_list_destroy(&sp->mms_ev_list); - mms_list_destroy(&sp->mms_cmd_list); - mms_list_destroy(&sp->mms_rsp_list); - - (void) memset(sp, 0, sizeof (mms_session_t)); - free(sp); -} - - -/* - * mms_mm_shutdown - * - * Send a shutdown request to the MM. - */ -void -mms_mm_shutdown(mms_session_t *sp, int force) -{ - void *rsp; - char cmd_str[128]; - int rc; - - if (force) { - mms_trace(MMS_OPER, "mms_mm_shutdown: force shutdown, current " - "count - %d", sp->mms_thrd_cnt); - return; - } - - (void) snprintf(cmd_str, sizeof (cmd_str), - "goodbye task[\"api_goodbye\"];"); - mms_trace(MMS_OPER, "mms_mm_shutdown: Send goodbye to MM: %s", cmd_str); - - if ((rc = mms_send_cmd(sp, cmd_str, &rsp)) != MMS_API_OK) { - mms_trace(MMS_ERR, "mms_mm_shutdown: Sending goodbye to MM " - "failed with a %s error", mms_sym_code_to_str(rc)); - mms_send_errmsg(sp, MMS_API_3052_MSG, NULL); - return; - } - - switch (mms_rsp_type(rsp)) { - case MMS_API_RSP_UNACC: - mms_trace(MMS_ERR, "mms_mm_shutdown: Received an unacceptable " - "response to goodbye command"); - break; - - case MMS_API_RSP_FINAL: - mms_trace(MMS_OPER, "mms_mm_shutdown: Received a success " - "response to goodbye command"); - break; - - case MMS_API_RSP_FINAL_ERR: - mms_trace(MMS_ERR, "mms_mm_shutdown: Received an error " - "response to goodbye command"); - break; - - case MMS_API_RSP_FINAL_CANC: - mms_trace(MMS_ERR, "mms_mm_shutdown: Received a cancel " - "response to goodbye command"); - break; - default: - mms_trace(MMS_ERR, "mms_mm_shutdown: Received an unknown " - "response to goodbye command"); - break; - } - - mms_free_rsp(rsp); -} - - -/* - * mms_shutdown - * - * Shutdown all activity for a session. - */ -void -mms_shutdown(mms_session_t *sp, int force) -{ - timespec_t tv; - timespec_t *tvp; - mms_rsp_ele_t *rsp_ele; - mms_cmd_ele_t *cmd_ele; - int rc; - - /* - * Send a shutdown command to the MM. - */ - mms_mm_shutdown(sp, force); - - /* - * Set state of API session to shutdown. - */ - sp->mms_api_state = MMS_API_SHUTDOWN; - - /* - * Close socket to MM. - */ - mms_close(&sp->mms_conn); - - mms_trace(MMS_OPER, "mms_shutdown: Set shutdown flag and wait for all " - "outstanding api threads to shutdown, current count - %d", - sp->mms_thrd_cnt); - - /* - * Broadcast to wake any client threads in a condition wait. - */ - if ((rc = pthread_mutex_lock(&sp->mms_acc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_shutdown: Lock of MMS accept mutex " - "failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_cond_broadcast(&sp->mms_acc_cv)) != 0) { - mms_serr(MMS_CRIT, "mms_shutdown: Broadcast on accept " - "condition variable failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_mutex_unlock(&sp->mms_acc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_shutdown: Unlock of MMS accept mutex " - "failed with errno - %s", strerror(rc)); - } - - if ((rc = pthread_cond_broadcast(&sp->mms_rsp_cv)) != 0) { - mms_serr(MMS_CRIT, "mms_shutdown: Broadcast on response list " - "condition variable failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_mutex_unlock(&sp->mms_rsp_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_shutdown: Unlock of MMS response list" - " mutex failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_cond_broadcast(&sp->mms_ev_cv)) != 0) { - mms_serr(MMS_CRIT, "mms_shutdown: Broadcast on event list " - "condition variable failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_mutex_unlock(&sp->mms_ev_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_shutdown: Unlock of MMS event list " - "mutex failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_cond_broadcast(&sp->mms_be_cv)) != 0) { - mms_serr(MMS_CRIT, "mms_shutdown: Broadcast on send list " - "condition variable failed with errno - %s", strerror(rc)); - } - if ((rc = pthread_mutex_unlock(&sp->mms_be_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_shutdown: Unlock of MMS send list " - "mutex failed with errno - %s", strerror(rc)); - } - - /* - * Check to see if any client threads are still outstanding. - */ - if ((rc = pthread_mutex_lock(&sp->mms_cnt_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_shutdown: Lock of MMS thread " - "count mutex failed with errno - %s", strerror(rc)); - } - - if (sp->mms_thrd_cnt != 0) { - - tv.tv_sec = time(NULL) + 15; - tv.tv_nsec = 0; - tvp = &tv; - if ((rc = pthread_cond_timedwait(&sp->mms_cnt_cv, - &sp->mms_cnt_mutex, tvp)) != 0) { - if (rc == ETIMEDOUT) - mms_trace(MMS_ERR, "mms_shutdown: 15 seconds " - "wait period expired waiting for all " - "client threads to exit, forcing shutdown"); - else - mms_serr(MMS_CRIT, "mms_shutdown: Unable to " - "wait on thread condition variable, " - "errno - %s", strerror(rc)); - } else { - mms_trace(MMS_OPER, - "mms_shutdown: all outstanding client " - "threads have exited, connection to MM closed"); - } - } else { - mms_trace(MMS_OPER, - "mms_shutdown: There are no outstanding client " - "threads currently running, connection to MM closed"); - } - - if ((rc = pthread_mutex_unlock(&sp->mms_cnt_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_shutdown: Unlock of MMS thread " - "count mutex failed with errno - %s", strerror(rc)); - } - - /* - * Clean the event lists. - */ - if ((rc = pthread_mutex_lock(&sp->mms_ev_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_shutdown: Lock of MMS event list " - "mutex failed with errno - %s", strerror(rc)); - } - while (! mms_list_empty(&sp->mms_ev_list)) { - rsp_ele = mms_list_head(&sp->mms_ev_list); - mms_list_remove(&sp->mms_ev_list, rsp_ele); - mms_free_rsp(rsp_ele); - } - if ((rc = pthread_mutex_unlock(&sp->mms_ev_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_shutdown: Unlock of MMS event list " - "mutex failed with errno - %s", strerror(rc)); - } - - /* - * Clean the response list. - */ - if ((rc = pthread_mutex_lock(&sp->mms_rsp_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_shutdown: Lock of MMS response list " - "mutex failed with errno - %s", strerror(rc)); - } - while (! mms_list_empty(&sp->mms_rsp_list)) { - rsp_ele = mms_list_head(&sp->mms_rsp_list); - - mms_list_remove(&sp->mms_rsp_list, rsp_ele); - mms_free_rsp(rsp_ele); - } - if ((rc = pthread_mutex_unlock(&sp->mms_rsp_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_shutdown: Unlock of MMS response " - "list mutex failed with errno - %s", strerror(rc)); - } - - /* - * Clean the command list. - */ - if ((rc = pthread_mutex_lock(&sp->mms_cmd_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_shutdown: Lock of MMS command list " - "mutex failed with errno - %s", strerror(rc)); - } - while (! mms_list_empty(&sp->mms_cmd_list)) { - cmd_ele = mms_list_head(&sp->mms_cmd_list); - - mms_list_remove(&sp->mms_cmd_list, cmd_ele); - mms_cmd_free(cmd_ele); - } - if ((rc = pthread_mutex_unlock(&sp->mms_cmd_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_shutdown: Unlock of MMS command list" - " mutex failed with errno - %s", strerror(rc)); - } -} - - -/* - * mms_init() - * - * Parameters: - * - session If init is successful, returns the pointer to the new - * session structure that the client uses to - * communicate with MMS. If an error occurs it is set - * to NULL; - * - version Set to the version that the API was built with. - * The client will use this to determine if it is - * compatible with the MMS API. - * - * This function initializes the mutexs, condition variables, lists, - * necessary for a client to communicate with MMS in a sync mode. - * - * Return Values: - * MMS_API_OK If a new sessions was successfully created. - * ! MMS_API_OK The code relevant to the internal processing error - * that was encountered. If the client has registered - * a logging routine for the API, a message will be - * sent to that routine. - * - */ -int -mms_init(void **session, int *version) -{ - mms_session_t *sp; - - if (session == NULL || version == NULL) { - mms_trace(MMS_DEBUG, "mms_init: Null pointer specified for %s", - session == NULL ? "session" : "version"); - return (MMS_INVALID_REQ); - } - - if ((sp = mms_sess_create()) == NULL) { - *session = NULL; - return (MMS_MALLOC_ERROR); - } - - sp->mms_api_state = MMS_API_CONFIG; - sp->mms_api_mode = MMS_API_SYNC; - - mms_trace(MMS_OPER, "mms_init: Init of client's sync api connection " - "to MMS complete"); - - *version = MMS_API_VERSION; - *session = sp; - - return (MMS_API_OK); -} - - -/* - * mms_ainit() - * - * Parameters: - * - session If init is successful, returns a pointer to the new - * session structure that the client uses to - * communicate with MMS. If an error occurs it is set - * to NULL; - * - version Set to the version the API was built with. - * The client will use this to determine if it is - * compatible with the MMS API. - * - err_callbk The routine that is to be called when the reader - * detects an internal processing error and is ready to - * exit. This function is called to notify the client - * that a internal processing error has occurred and - * the api is no longer is a stable state. This routine - * is also called when reader exits because the api - * has been terminated by the client. - * - ev_callbk The routine that is to be called when an event is - * received. - * - * This function initializes the mutexs, condition variables, lists, - * necessary for a client to communicate with MMS in a async mode. - * - * Return Values: - * MMS_API_OK If a new sessions was successfully created - * ! MMS_API_OK The code relevant to the internal processing error - * that was encountered. If the client has registered - * a logging routine for the API, a message will be - * sent to that routine. - * - */ -int -mms_ainit(void **session, int *version, mms_callbk_t *err_callbk, - mms_rsp_callbk_t *ev_callbk) -{ - mms_session_t *sp; - - if (session == NULL || version == NULL) { - mms_trace(MMS_DEBUG, "mms_init: Null pointer specified for %s", - session == NULL ? "session" : "version"); - return (MMS_INVALID_REQ); - } - - if ((sp = mms_sess_create()) == NULL) { - *session = NULL; - return (MMS_MALLOC_ERROR); - } - - sp->mms_api_rstarted = MMS_API_NO; - sp->mms_api_mode = MMS_API_ASYNC; - sp->mms_api_state = MMS_API_CONFIG; - - /* - * Set callback function to process events. - */ - if (ev_callbk) { - sp->mms_ev_callbk = ev_callbk->mms_func; - sp->mms_ev_callbk_param = ev_callbk->mms_param; - } else { - sp->mms_ev_callbk = NULL; - sp->mms_ev_callbk_param = NULL; - } - - /* - * Set callback function in case reader thread needs to - * shutdown due to internal processing. - */ - if (err_callbk) { - sp->mms_async_error = err_callbk->mms_func; - sp->mms_async_error_param = err_callbk->mms_param; - } else { - sp->mms_async_error = NULL; - sp->mms_async_error_param = NULL; - } - - mms_trace(MMS_OPER, "mms_ainit: Init of client's async api " - "connection to MMS complete"); - - *version = MMS_API_VERSION; - *session = sp; - - return (MMS_API_OK); -} - -/* - * mms_goodbye() - * - * Parameters: - * - session The session that is to be closed - * - force 0 - indicates graceful shutdown - * 1 - indicates an immediate shutdown - * - * This function closes a synchronouse session that a client has open with MMS. - * - * Return Values: - * MMS_API_OK If session was closed successfully - * ! MMS_API_OK The code relevant to the internal processing error - * that was encountered. If the client has registered - * a logging routine for the API, a message will be - * sent to that routine. - * - */ -int -mms_goodbye(void *session, int force) -{ - mms_session_t *sp = (mms_session_t *)session; - - mms_trace(MMS_DEBUG, "mms_goodbye: Closing session with MMS"); - - if (sp == NULL) { - mms_trace(MMS_ERR, "mms_goodbye: Client session pointer is " - "NULL, unable to close session"); - mms_send_errmsg(sp, MMS_API_3000_MSG, NULL); - return (MMS_INVALID_REQ); - } - - if (sp->mms_api_mode != MMS_API_SYNC) { - mms_trace(MMS_ERR, "mms_goodbye: Trying to use sync close " - "on a session which is not an sync session"); - mms_send_errmsg(sp, MMS_API_3019_MSG, NULL); - return (MMS_WRONG_API_MODE); - } - - /* - * Shutdown the session. - */ - mms_shutdown(sp, force); - - /* - * Free all resources used to manage the session. - */ - mms_sess_free(sp); - - return (MMS_API_OK); -} - -/* - * mms_agoodbye() - * - * Parameters: - * - session The session that is to be closed - * - force 0 - indicates graceful shutdown - * 1 - indicates an immediate shutdown - * - * This function closes a asynchronous session that a client has open with mms - * - * Return Values: - * MMS_API_OK If session was closed successfully. - * ! MMS_API_OK An error code indicating the error encountered. - * - */ -int -mms_agoodbye(void *session, int force) -{ - mms_session_t *sp = (mms_session_t *)session; - - mms_trace(MMS_DEBUG, "mms_agoodbye: Closing session with MMS"); - - if (sp == NULL) { - mms_trace(MMS_ERR, "mms_agoodbye: Client session pointer is " - "NULL, unable to close session"); - mms_send_errmsg(sp, MMS_API_3000_MSG, NULL); - return (MMS_INVALID_REQ); - } - - if (sp->mms_api_mode != MMS_API_ASYNC) { - mms_trace(MMS_ERR, "mms_agoodbye: Trying to use async close " - "on a session which is not an async session"); - mms_send_errmsg(sp, MMS_API_3019_MSG, NULL); - return (MMS_WRONG_API_MODE); - } - - /* - * Shutdown the session. - */ - mms_shutdown(sp, force); - - /* - * Free all resources used to manage the session. - */ - mms_sess_free(sp); - - return (MMS_API_OK); -} - -/* - * mms_send_cmd() - * - * Parameters: - * - session The structure used to access the socket to MMS. - * - cmd The MMP cmd to be sent to MMS. - * - rsp The response from MMS to the cmd. This is actually a - * mms_rsp_ele_t structure. When the client is - * done with the response, they need to call - * mms_free_rsp() to free up the strucutes memory. - * - * This function sends MMP commands to MMS and waits for a response to them. - * It returns in rsp a MMS response structure. The client will then use - * other MMS API commands to obtain the information from the response, thus - * the client does not need to know the actual format of the response - * actually pull the response apart in order to determine what it needs from - * structure. If a processing error has occurred within the MMS API, this - * routine will return a error response and return a value indicating what - * processing error occurred. - * - * Return Values: - * MMS_API_OK If it received a vaild response from MMS - * ! MMS_API_OK The code relevant to the internal processing error - * that was encountered. If the client has registered - * a logging routine for the API, a message will be - * sent to that routine. - * - */ -int -mms_send_cmd(void *session, char *cmd, void **rsp) -{ - mms_session_t *sp = (mms_session_t *)session; - mms_rsp_ele_t *new_rsp; - mms_cmd_name_t cmdtype; - char *tid; - int rc; - - if (cmd == NULL) { - mms_trace(MMS_DEBUG, "mms_send_cmd: Null pointer specified" - " for the command"); - return (MMS_INVALID_REQ); - } - - mms_trace(MMS_OPER, "mms_send_cmd: Command to be sent to MMS:\n%s", - cmd); - - if (rsp == NULL) { - mms_trace(MMS_DEBUG, "mms_send_cmd: Null pointer specified " - "for the response"); - return (MMS_INVALID_REQ); - } - - *rsp = NULL; - - if (sp == NULL) { - mms_trace(MMS_ERR, "mms_send_cmd: Session pointer is set " - "to NULL, unable to send new command:\n%s", cmd); - return (MMS_INVALID_REQ); - } - - if (sp->mms_api_state == MMS_API_FAILURE) { - mms_trace(MMS_ERR, "mms_send_cmd: MMS API is in a state of " - "error, unable to send new command:\n%s", cmd); - mms_send_errmsg(sp, MMS_API_3001_MSG, NULL); - return (sp->mms_api_errcode); - } - - /* - * Extract the command type and task id from the command. - */ - rc = mms_cmd_extract(cmd, &tid, &cmdtype); - if (rc != MMS_API_OK) { - return (rc); - } - - /* - * The begin-end command sequence cannot be issued synchronously. - */ - if (cmdtype == MMS_CMD_BEGIN || cmdtype == MMS_CMD_END) { - free(tid); - return (MMS_INVALID_REQ); - } - - /* - * Create and queue a command element to manage the command. - */ - if (sp->mms_api_mode == MMS_API_ASYNC) { - mms_cmd_create(sp, tid, cmd, MMS_API_SYNC, NULL, NULL); - } - - mms_thread_start(sp); - - /* - * Send the command and wait for the accept. - */ - rc = mms_send(sp, tid, cmdtype, cmd, &new_rsp); - - /* - * Return an error if the command could not be sent or - * was not accepted. - */ - if (rc != MMS_API_OK) { - if (sp->mms_api_mode == MMS_API_ASYNC) - (void) mms_cmd_remove(sp, tid); - free(tid); - mms_thread_exit(sp); - return (rc); - } - if (new_rsp != NULL) { - *rsp = (void *)new_rsp; - mms_thread_exit(sp); - free(tid); - return (rc); - } - - /* - * Wait for the final response. - */ - rc = mms_obtain_final(sp, tid, &new_rsp); - - mms_thread_exit(sp); - free(tid); - - if (rc != MMS_API_OK) { - if (rc != MMS_API_SHUTDOWN) - mms_trace(MMS_ERR, "mms_send_cmd: obtaining a MMS " - "response failed %d, %s for command:\n%s", rc, - mms_sym_code_to_str(rc), cmd); - return (rc); - } - - *rsp = (void *)new_rsp; - return (MMS_API_OK); -} - - -/* - * mms_read_response() - * - * Parameters: - * - session The structure used to communicate with MMS. - * - tid The task id for the command that client is waiting - * for additional responses for. - * - rsp Will contain the next response for the command with - * taskid. - * - * This function obtains secondary responses to commands that have been sent - * to MMS. The function should only be called if the mms_send_cmd() - * function received a "intermediate" response or a prior call to this - * function received a "intermediate" response. - * - * Return Values: - * MMS_API_OK If a response from MMS was received without any - * internal processing errors. - * ! MMS_API_OK The code relevant to the internal processing error - * that was encountered. If the client has registered - * a logging routine for the API, a message will be - * sent to that routine. - * - */ -int -mms_read_response(void *session, char *tid, void **rsp) -{ - mms_rsp_ele_t *new_rsp; - mms_session_t *sp = (mms_session_t *)session; - int rc; - - if (tid == NULL || rsp == NULL) { - mms_trace(MMS_DEBUG, "mms_read_response: Null pointer " - "specified for %s", tid == NULL ? "task id" : - "response"); - return (MMS_INVALID_REQ); - } - - *rsp = NULL; - - if (sp == NULL) { - mms_trace(MMS_ERR, "mms_read_response: Session pointer is " - "set to NULL, unable to obtain a response for command " - "with taskid %s", tid); - mms_send_errmsg(sp, MMS_API_3000_MSG, NULL); - return (MMS_INVALID_REQ); - } - if (sp->mms_api_state == MMS_API_FAILURE) { - mms_trace(MMS_ERR, "mms_read_response: MMS API is in a " - "state of error, unable to obtain a response for command " - "with taskid %s", tid); - mms_send_errmsg(sp, MMS_API_3001_MSG, NULL); - return (sp->mms_api_errcode); - } - - mms_thread_start(sp); - - rc = mms_obtain_final(sp, tid, &new_rsp); - - mms_thread_exit(sp); - - if (rc != MMS_API_OK) { - if (rc != MMS_API_SHUTDOWN) { - mms_trace(MMS_ERR, "mms_read_response: Obtaining a " - "response for command with taskid %s from MMS " - "failed, rc - %d, %s.", tid, rc, - mms_sym_code_to_str(rc)); - } - return (rc); - } - - *rsp = (void *)new_rsp; - return (MMS_API_OK); -} - -/* - * mms_send_acmd() - * - * Parameters: - * - sp The structure used to access the socket to MMS. - * - tid The task id of the MMP command to be sent to MMS. - * - cmd The MMP cmd to be sent to MMS. - * - callbk The routine that is to be called when the reader - * receives a final response for the command. - * - callbk_param A user specified parameter to send to the callbk - * function when the final response is received. - * - * This function sends MMP commands to MMS and does not wait for any type - * of response from MMS before returning to the caller of this function. - * It just adds the command to the outstanding command list and the send - * command list and returns. - * - * Return Values: - * MMS_API_OK If function completed correctly. - * ! MMS_API_OK The code relevant to the internal processing error - * that was encountered. If the client has registered - * a logging routine for the API, a message will be - * sent to that routine. - * - */ -int -mms_send_acmd(void *session, char *cmd, void (*callbk)(void *arg, void *arg1), - void *callbk_param) -{ - mms_session_t *sp = (mms_session_t *)session; - char *tid; - mms_cmd_name_t cmdtype; - int rc; - - if (cmd == NULL) { - mms_trace(MMS_DEBUG, "mms_send_acmd: Null pointer " - "specified for command"); - return (MMS_INVALID_REQ); - } - - mms_trace(MMS_OPER, "mms_send_acmd: Command to be sent to MMS:\n%s", - cmd); - - if (sp == NULL) { - mms_trace(MMS_ERR, "mms_send_acmd: Session pointer is set " - "to NULL, unable to send new comand:\n%s", cmd); - return (MMS_INVALID_REQ); - } - - if (callbk == NULL) { - mms_trace(MMS_DEBUG, "mms_send_acmd: Null pointer specified " - "for callback function"); - return (MMS_INVALID_REQ); - } - - if (sp->mms_api_state == MMS_API_FAILURE) { - mms_trace(MMS_ERR, "mms_send_acmd: MMS API is in a state " - "of error, unable to send new command:\n%s", cmd); - mms_send_errmsg(sp, MMS_API_3001_MSG, NULL); - return (sp->mms_api_errcode); - } - - /* - * MM connection must have been initialized in asynchronous mode. - */ - if (sp->mms_api_mode != MMS_API_ASYNC) { - mms_trace(MMS_ERR, "mms_send_acmd: Trying to use the MMS " - "API connection in ASYNC mode, though it is configured for " - "%s mode", mms_api[sp->mms_api_mode]); - mms_send_errmsg(sp, MMS_API_3019_MSG, NULL); - return (MMS_WRONG_API_MODE); - } - - /* - * Extract the command type and task id from the command. - */ - rc = mms_cmd_extract(cmd, &tid, &cmdtype); - if (rc != MMS_API_OK) { - return (rc); - } - - /* - * Create and add the command to the command list for this - * session. - */ - mms_cmd_create(sp, tid, cmd, MMS_API_ASYNC, callbk, callbk_param); - - mms_thread_start(sp); - - /* - * Send the command and wait for an accept. - */ - rc = mms_send(sp, tid, cmdtype, cmd, NULL); - - mms_thread_exit(sp); - - /* - * Return an error if the command could not be sent or - * was not accepted. - */ - if (rc != MMS_API_OK) { - (void) mms_cmd_remove(sp, tid); - free(tid); - return (rc); - } - - mms_trace(MMS_DEBUG, "mms_send_acmd: Command with taskid " - "%s accepted", tid); - free(tid); - - return (MMS_API_OK); -} - -/* - * mms_read_event() - * - * Parameters: - * - session Connection to MMS to use. - * - event The generic response structure used to store the - * event to be processed by the client. - * - * This function obtains events from MMS. When MMS has an event to send - * to a client, it sends it over the session socket. This routine pulls the - * event off the socket and then returns it to the client. A client needs to - * call mms_free_rsp() to free the memory associated with the event structure - * that is returned. - * - * Return Values: - * MMS_API_OK If it was able to obtain a event successfully. - * ! MMS_API_OK The code relevant to the internal processing error - * that was encountered. - * - */ -int -mms_read_event(void *session, void **event) -{ - int rc; - - mms_rsp_ele_t *new_ev; - mms_session_t *sp = (mms_session_t *)session; - - if (sp == NULL || event == NULL) { - mms_trace(MMS_DEBUG, "mms_read_event: Null pointer specified" - " for %s", sp == NULL ? "session" : "event"); - return (MMS_INVALID_REQ); - } - - mms_thread_start(sp); - - /* - * Wait for an event. - */ - rc = mms_obtain_event(sp, &new_ev); - - mms_thread_exit(sp); - - if (rc != MMS_API_OK) { - if (rc != MMS_API_SHUTDOWN) { - mms_trace(MMS_ERR, - "mms_read_event: obtaining new event " - "failed, error code - %d, %s", rc, - mms_sym_code_to_str(rc)); - } - *event = (void *)NULL; - return (rc); - } - - *event = new_ev; - return (MMS_API_OK); -} - -/* - * mms_get_attr_aux() - * - * Parameters: - * - top The top of the list being searched - * - start The starting point to search from in the list - * - str The string to search for - * - type The type of attribute to search for - * receives a final response for the command. - * - self Indicates if start should be searched. - * - * This function calls itself recursivily looking for str in the list - * top starting at the start location. - * - * Return Values: - * Returns a pointer to the node in the list that matches str and type - * or it returns NULL if the list is exhausted without finding str. - * - */ -static mms_par_node_t * -mms_get_attr_aux(mms_par_node_t *top, - mms_par_node_t *start, char *str, int type, - int self) -{ - mms_par_node_t *tmp; - mms_par_node_t *node; - mms_par_node_t *result; - mms_list_t *list; - - if (top == NULL || start == NULL) { - return (NULL); - } - - /* Start from the start node */ - if (self == 1) { - if (type & mms_pn_type(start)) { - if (strcmp(str, mms_pn_token(start)) == 0) { - /* found a matching node */ - return (start); - } - } - /* Already did self check, don't do it again */ - self = 0; - } - - list = &top->pn_arglist; - if (top == start) { - start = mms_list_head(list); - /* Have a new start node, do self check on this one */ - self = 1; - } - for (node = start; node != NULL; node = mms_list_next(list, node)) { - result = mms_get_attr_aux(node, node, str, type, self); - if (result != NULL) { - /* found a matching node */ - return (result); - } - /* skip value of name value pair */ - tmp = mms_list_next(list, node); - if (tmp != NULL && (type & mms_pn_type(tmp))) { - node = tmp; - } - /* Do self check from now on */ - self = 1; - } - - /* Can't find a matching node. */ - return (NULL); -} - -/* - * mms_get_attribute() - * - * Parameters: - * - rsp The response that is to be processed - * - name The name of the attribute to scan the response for. - * - prev Maintains the location of how far the scan has been - * done between calls. The client sets this to NULL - * on the initial call to this routine and then the - * routine updates it to keep track of where it is in - * the response. - * - * This function takes a response that has a report in namevalue form - * and looks through it for the name attribute. It returns the value - * associated with the name when it finds one. - * - * Return Values: - * value of name If a name attribute was found it returns the value - * associated with the attribute. - * NULL If no name attribute was found. - * - */ -char * -mms_get_attribute(void *rsp, char *name, void **prev) -{ - int self = 1; - - mms_rsp_ele_t *lrsp = (mms_rsp_ele_t *)rsp; - - mms_par_node_t *root = lrsp->mms_rsp_cmd; - mms_par_node_t *clause_top; - mms_par_node_t *start; - mms_par_node_t *node = NULL; - mms_par_node_t *value = NULL; - - if (name == NULL) { - mms_trace(MMS_ERR, "mms_get_attribute: Name is set to NULL"); - return (NULL); - } - - if (prev == NULL || *prev == NULL) { - if ((clause_top = mms_pn_lookup(root, "text", - MMS_PN_CLAUSE, NULL)) == NULL) { - mms_trace(MMS_DEBUG, "mms_get_attribute: No text found " - "found in response %s", lrsp->mms_rsp_str); - return (NULL); - } - start = clause_top; - } else { - start = (mms_par_node_t *)(*prev); - - clause_top = start->pn_list; - self = 0; - } - - node = mms_get_attr_aux(clause_top, start, name, - MMS_PN_STRING, self); - - while (clause_top != NULL && node == NULL) { - - if (strcmp(mms_pn_token(clause_top), "text") == 0) { - if ((clause_top = mms_pn_lookup(root, "text", - MMS_PN_CLAUSE, &clause_top)) == NULL) { - mms_trace(MMS_DEBUG, - "mms_get_attribute: No more " - "text clause found"); - continue; - } - start = clause_top; - } else { - start = clause_top; - clause_top = clause_top->pn_list; - node = mms_list_next(&clause_top->pn_arglist, start); - if (node == NULL) - continue; - start = node; - } - - self = 1; - node = mms_get_attr_aux(clause_top, start, name, - MMS_PN_STRING, self); - if (node != NULL) - break; - } - - if (prev != NULL && node != NULL) { - value = mms_list_next(&node->pn_list->pn_arglist, node); - if (value != NULL) { - mms_trace(MMS_DEBUG, - "mms_get_attribute: Next value for " - "%s attribute - %s", name, mms_pn_token(value)); - *prev = value; - return (mms_pn_token(value)); - } - } - - return (NULL); -} diff --git a/usr/src/lib/mms/mms/common/mms_cores.c b/usr/src/lib/mms/mms/common/mms_cores.c deleted file mode 100644 index e0bc223c2f..0000000000 --- a/usr/src/lib/mms/mms/common/mms_cores.c +++ /dev/null @@ -1,170 +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 <string.h> -#include <limits.h> -#include <unistd.h> -#include <sys/corectl.h> -#include "mms_cores.h" -#include <mms_strapp.h> -#include <stdlib.h> -#include <sys/stat.h> -#include <dirent.h> -#include <syslog.h> - -int -mms_set_core(char *dir, char *proc) -{ - int val; - char *pattern; - char cpath[PATH_MAX]; - int len; - - if (proc == NULL) { /* filename and pid */ - pattern = mms_strapp(NULL, "core.%s.%s", "%f", "%p"); - } else { /* filename, process name and pid */ - pattern = mms_strapp(NULL, "core.%s.%s.%s", "%f", proc, "%p"); - } - - if (dir == NULL) { - (void) strcpy(cpath, MMS_CORES_DIR); - } else { - (void) strcpy(cpath, dir); - } - - len = strlen(cpath); - (void) snprintf(&cpath[len], PATH_MAX - len, "/%s", pattern); - - /* - * Allow per process core file with executable file name and pid - * file name extension. - */ - if ((val = core_get_options()) == -1) { - free(pattern); - return (-1); - } - if (core_set_options(val | CC_PROCESS_PATH | CC_PROCESS_SETID) == -1) { - free(pattern); - return (-1); - } - if (core_set_process_path(cpath, strlen(cpath) + 1, getpid())) { - free(pattern); - return (-1); - } - free(pattern); - return (0); -} - -int -corecmp(const void *c1, const void *c2) -{ - corestat_t *t1 = (corestat_t *)c1; - corestat_t *t2 = (corestat_t *)c2; - return ((int)t1->time - (int)t2->time); -} - -/* - * Function name mms_man_cores - * - * - * Parameters: - * - dir : pointer to cores directory - * - proc : the core file name - * - * Description: Rotates the core file if necessary. - * - * - * Return code: 0 on success - * -1 on failure - * - */ -int -mms_man_cores(char *dir, char *proc) -{ - DIR *dp; - struct dirent *dirp; - struct stat stp; - int corecount = 0; - int coreamt = MMS_CORE_AMT; - int coretot = 20; - size_t bufsize = sizeof (corestat_t) * coretot; - corestat_t *buf2 = (corestat_t *)malloc(bufsize); - corestat_t *tmpbuf; - int i; - - if ((dp = opendir(dir)) == NULL) { - syslog(LOG_ERR, "mms_man_cores: opendir failed"); - return (-1); - } else { - while ((dirp = readdir(dp)) != NULL) { - if (strcmp(dirp->d_name, ".") == 0 || - strcmp(dirp->d_name, "..") == 0) - continue; - else { - if (corecount > coretot) { - bufsize = bufsize * 2; - coretot = coretot *2; - tmpbuf = (corestat_t *) - realloc(buf2, bufsize); - if (tmpbuf != NULL) - buf2 = tmpbuf; - else { - syslog(LOG_ERR, - "mms_man_cores: reallocr"); - } - } - if (strncmp(dirp->d_name, proc, - strlen(proc)) == 0) { - buf2[corecount].name = mms_strapp(NULL, - "%s/%s", dir, dirp->d_name); - if (stat(buf2[corecount].name, - &stp) != 0) { - syslog(LOG_ERR, - "mms_man_cores: opendir"); - } else { - buf2[corecount].time = - stp.st_mtime; - corecount++; - } - } - } - } - /* Remove old core files if needed */ - if (corecount > coreamt) { - qsort(buf2, corecount, sizeof (corestat_t), corecmp); - /* Remove the oldest core files */ - for (i = 0; i < (corecount - coreamt); i++) { - (void) remove(buf2[i].name); - } - } - } - - /* Free up all the core names */ - for (i = 0; i < corecount; i++) - free(buf2[i].name); - free(buf2); - return (0); -} diff --git a/usr/src/lib/mms/mms/common/mms_cores.h b/usr/src/lib/mms/mms/common/mms_cores.h deleted file mode 100644 index 7b19df832d..0000000000 --- a/usr/src/lib/mms/mms/common/mms_cores.h +++ /dev/null @@ -1,53 +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 _MMS_CORES_H -#define _MMS_CORES_H - - -#ifdef __cplusplus -extern "C" { -#endif - -#define MMS_CORES_DIR "/var/mms/cores" -#define MMS_CORE_AMT 10 - -extern int mms_set_core(char *dir, char *proc); -extern int mms_man_cores(char *dir, char *proc); - -typedef struct corestat { - char *name; - int time; -} corestat_t; - -/* - * mms_trace location define - */ -#define MMS_HERE _SrcFile, __LINE__ - -#ifdef __cplusplus -} -#endif - -#endif /* _MMS_CORES_H */ diff --git a/usr/src/lib/mms/mms/common/mms_list.c b/usr/src/lib/mms/mms/common/mms_list.c deleted file mode 100644 index b735e377ea..0000000000 --- a/usr/src/lib/mms/mms/common/mms_list.c +++ /dev/null @@ -1,204 +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 <mms_list.h> - -/* - * Initialize a list like another one. - */ -void -mms_list_create_like(mms_list_t *targ, mms_list_t *src) -{ - mms_list_create(targ, src->list_size, src->list_offset); -} - -/* - * Move a list to an uninitialized list and make the original list empty. - */ -void -mms_list_move(mms_list_t *targ, mms_list_t *src) -{ - mms_list_create_like(targ, src); - mms_list_move_tail(targ, src); -} - -void -mms_list_insert_after_node(mms_list_t *list, - mms_list_node_t *node, void *object) -{ - mms_list_node_t *lnew = mms_list_d2l(list, object); - assert(MMS_LIST_NOT_MOVED(list)); - lnew->list_prev = node; - lnew->list_next = node->list_next; - node->list_next->list_prev = lnew; - node->list_next = lnew; -} - -void -mms_list_insert_before_node(mms_list_t *list, - mms_list_node_t *node, void *object) -{ - mms_list_node_t *lnew = mms_list_d2l(list, object); - assert(MMS_LIST_NOT_MOVED(list)); - lnew->list_next = node; - lnew->list_prev = node->list_prev; - node->list_prev->list_next = lnew; - node->list_prev = lnew; -} - - -void -mms_list_create(mms_list_t *list, size_t size, size_t offset) -{ - assert(list); - assert(size > 0); - assert(size >= offset + sizeof (mms_list_node_t)); - - list->list_size = size; - list->list_offset = offset; - list->list_head.list_next = list->list_head.list_prev = - &list->list_head; -} - -void -mms_list_destroy(mms_list_t *list) -{ - mms_list_node_t *node = &list->list_head; - - assert(list); - assert(list->list_head.list_next == node); - assert(list->list_head.list_prev == node); - - assert(MMS_LIST_NOT_MOVED(list)); - node->list_next = node->list_prev = NULL; -} - -void -mms_list_insert_after(mms_list_t *list, void *object, void *nobject) -{ - mms_list_node_t *lold = mms_list_d2l(list, object); - mms_list_insert_after_node(list, lold, nobject); -} - -void -mms_list_insert_before(mms_list_t *list, void *object, void *nobject) -{ - mms_list_node_t *lold = mms_list_d2l(list, object); - mms_list_insert_before_node(list, lold, nobject); -} - -void -mms_list_insert_head(mms_list_t *list, void *object) -{ - mms_list_node_t *lold = &list->list_head; - mms_list_insert_after_node(list, lold, object); -} - -void -mms_list_insert_tail(mms_list_t *list, void *object) -{ - mms_list_node_t *lold = &list->list_head; - mms_list_insert_before_node(list, lold, object); -} - -void -mms_list_remove(mms_list_t *list, void *object) -{ - mms_list_node_t *lold = mms_list_d2l(list, object); - - assert(!mms_list_empty(list)); - assert(MMS_LIST_NOT_MOVED(list)); - lold->list_prev->list_next = lold->list_next; - lold->list_next->list_prev = lold->list_prev; - lold->list_next = lold->list_prev = NULL; -} - -void * -mms_list_head(mms_list_t *list) -{ - assert(MMS_LIST_NOT_MOVED(list)); - if (mms_list_empty(list)) - return (NULL); - return (mms_list_object(list, list->list_head.list_next)); -} - -void * -mms_list_tail(mms_list_t *list) -{ - assert(MMS_LIST_NOT_MOVED(list)); - if (mms_list_empty(list)) - return (NULL); - return (mms_list_object(list, list->list_head.list_prev)); -} - -void * -mms_list_next(mms_list_t *list, void *object) -{ - mms_list_node_t *node = mms_list_d2l(list, object); - - assert(MMS_LIST_NOT_MOVED(list)); - if (node->list_next != &list->list_head) - return (mms_list_object(list, node->list_next)); - - return (NULL); -} - -void * -mms_list_prev(mms_list_t *list, void *object) -{ - mms_list_node_t *node = mms_list_d2l(list, object); - - assert(MMS_LIST_NOT_MOVED(list)); - if (node->list_prev != &list->list_head) - return (mms_list_object(list, node->list_prev)); - - return (NULL); -} - -/* - * Insert src list after dst list. Empty src list thereafter. - */ -void -mms_list_move_tail(mms_list_t *dst, mms_list_t *src) -{ - mms_list_node_t *dstnode = &dst->list_head; - mms_list_node_t *srcnode = &src->list_head; - - assert(dst->list_size == src->list_size); - assert(dst->list_offset == src->list_offset); - - assert(MMS_LIST_NOT_MOVED(src)); - assert(MMS_LIST_NOT_MOVED(dst)); - if (mms_list_empty(src)) - return; - - dstnode->list_prev->list_next = srcnode->list_next; - srcnode->list_next->list_prev = dstnode->list_prev; - dstnode->list_prev = srcnode->list_prev; - srcnode->list_prev->list_next = dstnode; - - /* empty src list */ - srcnode->list_next = srcnode->list_prev = srcnode; -} diff --git a/usr/src/lib/mms/mms/common/mms_logadm.conf b/usr/src/lib/mms/mms/common/mms_logadm.conf deleted file mode 100644 index 58385a89b3..0000000000 --- a/usr/src/lib/mms/mms/common/mms_logadm.conf +++ /dev/null @@ -1,28 +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. -# - - -# -# logadm.conf for mms -# diff --git a/usr/src/lib/mms/mms/common/mms_mgmt.c b/usr/src/lib/mms/mms/common/mms_mgmt.c deleted file mode 100644 index 58a6121eeb..0000000000 --- a/usr/src/lib/mms/mms/common/mms_mgmt.c +++ /dev/null @@ -1,642 +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. - */ - - -/* - * mms_mgmt.c - * - * Define functions used to manage API lists. - */ - -#include <mms.h> -#include <mgmt_mms.h> - -static char *_SrcFile = __FILE__; - -/* - * mms_acc_insert - * - * Add a response to the accept pointer. - */ -void -mms_acc_insert(mms_session_t *sp, mms_rsp_ele_t *rsp) -{ - int rc; - - if ((rc = pthread_mutex_lock(&sp->mms_acc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_acc_insert: Lock of MMS accept mutex " - "failed with errno - %s", strerror(rc)); - } - - sp->mms_acc_rsp = rsp; - - /* - * Wake up any thread waiting on an accept/unaccept response. - */ - if ((rc = pthread_cond_broadcast(&sp->mms_acc_cv)) != 0) { - mms_serr(MMS_CRIT, "mms_acc_insert: Broadcast on accept " - "condition variable failed with errno - %s", strerror(rc)); - } - - if ((rc = pthread_mutex_unlock(&sp->mms_acc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_acc_insert: Unlock of MMS accept " - "mutex failed with errno - %s", strerror(rc)); - } -} - - -/* - * mms_acc_wakeup - * - * Wake-up threads waiting for the an accept response. - */ -void -mms_acc_wakeup(mms_session_t *sp) -{ - int rc; - - if ((rc = pthread_mutex_lock(&sp->mms_acc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_reperr: Lock of MMS accept mutex " - "failed with errno - %s", strerror(rc)); - } - - /* - * Wake up any thread waiting on an accept/unaccept response. - */ - if ((rc = pthread_cond_broadcast(&sp->mms_acc_cv)) != 0) { - mms_serr(MMS_CRIT, "mms_reperr: Broadcast on accept " - "condition variable failed with errno - %s", strerror(rc)); - } - - if ((rc = pthread_mutex_unlock(&sp->mms_acc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_reperr: Unlock of MMS accept mutex " - "failed with errno - %s", strerror(rc)); - } -} - - -/* - * mms_be_wait - * - * Wait for a pending begin-end sequence to complete. - */ -void -mms_be_wait(mms_session_t *sp, boolean_t be_start) -{ - int rc; - - if ((rc = pthread_mutex_lock(&sp->mms_be_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_be_wait: Lock of MMS begin-end " - "mutex failed with error - %s", strerror(rc)); - } - - while (sp->mms_be_pending) { - if ((rc = pthread_cond_wait(&sp->mms_be_cv, - &sp->mms_be_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_be_wait: Unable to wait " - "on begin-end condition variable, error " - "- %s", strerror(rc)); - } - } - - if (be_start) - sp->mms_be_pending = B_TRUE; - - if ((rc = pthread_mutex_unlock(&sp->mms_be_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_be_wait: Unlock of MMS begin-end " - "mutex failed with error - %s", strerror(rc)); - } -} - - -/* - * mms_be_wakeup - * - * Wake-up threads waiting for a begin-end sequence to complete. - */ -void -mms_be_wakeup(mms_session_t *sp) -{ - int rc; - - if ((rc = pthread_mutex_lock(&sp->mms_be_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_be_wakeup: Lock of MMS begin-end " - "mutex failed with error - %s", strerror(rc)); - } - - sp->mms_be_pending = B_FALSE; - - if ((rc = pthread_cond_broadcast(&sp->mms_be_cv)) != 0) { - mms_serr(MMS_CRIT, "mms_be_wakeup: Broadcast on begin-end " - "condition variable failed with errno - %s", strerror(rc)); - } - - if ((rc = pthread_mutex_unlock(&sp->mms_be_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_be_wakeup: Unlock of MMS begin-end " - "mutex failed with error - %s", strerror(rc)); - } - - mms_trace(MMS_DEBUG, "mms_be_wakeup: Wakeup pending begin-end " - "sequences"); -} - - -/* - * mms_cmd_create - * - * Create an element to manage asynchronous requests. - */ -void -mms_cmd_create(mms_session_t *sp, char *tid, char *mms_cmd, int cmd_type, - void (*callbk)(void *arg, void *arg1), void *callbk_param) -{ - mms_cmd_ele_t *cmd; - - cmd = (mms_cmd_ele_t *)malloc(sizeof (mms_cmd_ele_t)); - if (cmd == NULL) { - mms_serr(MMS_CRIT, "mms_cmd_create: Unable to allocate memory " - "for a command list element (errno = %s)", strerror(errno)); - } - - cmd->mms_cmd_type = cmd_type; - cmd->mms_cmd_tid = strdup(tid); - cmd->mms_cmd_cmd = strdup(mms_cmd); - cmd->mms_cmd_callbk = callbk; - cmd->mms_cmd_callbk_param = callbk_param; - - mms_cmd_insert(sp, cmd); -} - - -/* - * mms_cmd_extract - * - * Parse a command, extracting the command type and task id. - */ -int -mms_cmd_extract(char *cmd, char **tid, mms_cmd_name_t *cmdtype) -{ - mms_par_node_t *root; - mms_list_t err_list; - int rc; - - *cmdtype = MMS_CMD_OTHER; - - rc = mms_mmp_parse(&root, &err_list, cmd); - if (rc) { - mms_pe_destroy(&err_list); - return (rc); - } - - mms_pe_destroy(&err_list); - - *tid = mms_cmd_get_task(root); - if (*tid == NULL) { - return (MMS_INVALID_REQ); - } - - if (strcmp(mms_pn_token(root), "begin") == 0) { - *cmdtype = MMS_CMD_BEGIN; - - } else if (strcmp(mms_pn_token(root), "end") == 0) { - *cmdtype = MMS_CMD_END; - } - - mms_pn_destroy(root); - return (MMS_API_OK); -} - - -/* - * mms_cmd_flush - * - * Flush all entries from the command queue. - */ -void -mms_cmd_flush(mms_session_t *sp, char *msg) -{ - mms_rsp_ele_t *err_rsp; - mms_cmd_ele_t *cmd; - int rc; - - if ((rc = pthread_mutex_lock(&sp->mms_cmd_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_reperr: Lock of MMS command list " - "mutex failed with errno - %s", strerror(rc)); - } - - /* - * Send error final response for all outstanding commands. - */ - while (! mms_list_empty(&sp->mms_cmd_list)) { - - cmd = mms_list_head(&sp->mms_cmd_list); - mms_list_remove(&sp->mms_cmd_list, cmd); - - /* - * If the command was sent asynchronously, then execute the - * callback function, sending a generated error response. - * For commands sent over a synchronous connection, - * mms_obtain_response will return the error response. - */ - if (msg && cmd->mms_cmd_type == MMS_API_ASYNC) { - err_rsp = mms_gen_err_rsp(cmd->mms_cmd_tid, - sp->mms_api_errcode, msg); - if (err_rsp) { - cmd->mms_cmd_callbk( - cmd->mms_cmd_callbk_param, err_rsp); - } - } - mms_cmd_free(cmd); - } - if ((rc = pthread_mutex_unlock(&sp->mms_cmd_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_reperr: Unlock of MMS command list" - " mutex failed with errno - %s", strerror(rc)); - } -} - - -/* - * mms_cmd_free - * - * This function frees memory associated with a command list element. - */ -void -mms_cmd_free(mms_cmd_ele_t *cmd) -{ - if (cmd == NULL) - return; - - free(cmd->mms_cmd_tid); - free(cmd->mms_cmd_cmd); - free(cmd); - - mms_trace(MMS_DEBUG, "mms_cmd_free: Completed free of command " - "list element memory"); -} - - -/* - * mms_cmd_get_task - * - * Extract the task id from the command. - */ -char * -mms_cmd_get_task(mms_par_node_t *root) -{ - mms_par_node_t *node; - mms_par_node_t *tasknode; - char *task; - - node = mms_pn_lookup(root, "task", MMS_PN_CLAUSE, NULL); - if (node == NULL) { - mms_trace(MMS_DEBUG, - "mms_cmd_get_task: Couldn't find a task clause"); - return (NULL); - } - - tasknode = mms_pn_lookup(node, NULL, MMS_PN_STRING, NULL); - if (tasknode == NULL) { - mms_trace(MMS_DEBUG, - "mms_cmd_get_task: Couldn't find the task string"); - return (NULL); - } - if (mms_pn_token(tasknode) == NULL) { - mms_trace(MMS_DEBUG, - "mms_cmd_get_task: Task string is null"); - return (NULL); - } - - task = strdup(mms_pn_token(tasknode)); - return (task); -} - - -/* - * mms_cmd_insert - * - * Add an element to the command list. - */ -void -mms_cmd_insert(mms_session_t *sp, mms_cmd_ele_t *cmd) -{ - int rc; - - if ((rc = pthread_mutex_lock(&sp->mms_cmd_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_cmd_insert: Lock of MMS command list " - "mutex failed with errno - %s", strerror(rc)); - } - - /* - * Add cmd element to outstanding command list so that reader - * thread knows what to do with the response, either add to - * response list or do a callback. - */ - mms_list_insert_tail(&sp->mms_cmd_list, cmd); - - if ((rc = pthread_mutex_unlock(&sp->mms_cmd_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_cmd_insert: Unlock of MMS command " - "list mutex failed with errno - %s", strerror(rc)); - } -} - - -/* - * mms_cmd_remove - * - * Return the command list element for task 'tid'. - */ -mms_cmd_ele_t * -mms_cmd_remove(mms_session_t *sp, char *tid) -{ - mms_cmd_ele_t *cmd_ele; - mms_cmd_ele_t *next; - int rc; - - /* - * Obtain the command structure that is associated with the - * taskid of the last command sent to MMS. - */ - if ((rc = pthread_mutex_lock(&sp->mms_cmd_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_cmd_remove: Lock of command " - "mutex failed with errno - %s", strerror(rc)); - } - - mms_list_foreach_safe(&sp->mms_cmd_list, cmd_ele, next) { - if ((strcmp(cmd_ele->mms_cmd_tid, tid)) == 0) { - mms_trace(MMS_DEBUG, - "mms_cmd_remove: Entry in command list" - " found for final response for taskid %s", tid); - mms_list_remove(&sp->mms_cmd_list, cmd_ele); - break; - } - } - - if (cmd_ele == NULL) { - mms_trace(MMS_ERR, - "mms_cmd_remove, Did not find final response " - "entry in command list for command with taskid %s", tid); - } - - if ((rc = pthread_mutex_unlock(&sp->mms_cmd_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_cmd_remove: Unlock of command" - "list mutex failed with errno - %s", strerror(rc)); - } - - return (cmd_ele); -} - - -/* - * mms_ev_insert - * - * Insert response in the event list and wakeup any threads reading - * events. - */ -void -mms_ev_insert(mms_session_t *sp, mms_rsp_ele_t *rsp) -{ - int rc; - - if ((rc = pthread_mutex_lock(&sp->mms_ev_mutex)) != 0) { - mms_send_errmsg(sp, MMS_API_3002_MSG, "name", "mms_ev_mutex", - "errno", strerror(rc), NULL); - mms_serr(MMS_CRIT, "mms_ev_insert: Lock of MMS event" - "mutex failed with errno - %s\n", strerror(rc)); - } - - mms_list_insert_tail(&sp->mms_ev_list, rsp); - - if ((rc = pthread_cond_broadcast(&sp->mms_ev_cv)) != 0) { - mms_send_errmsg(sp, MMS_API_3003_MSG, "name", "mms_ev_cv", - "errno", strerror(rc), NULL); - mms_serr(MMS_CRIT, "mms_ev_insert: Broadcast on " - "event list condition variable failed with errno -" - " %s", strerror(rc)); - } - - if ((rc = pthread_mutex_unlock(&sp->mms_ev_mutex)) != 0) { - mms_send_errmsg(sp, MMS_API_3003_MSG, "name", "mms_ev_mutex", - "errno", strerror(rc), NULL); - mms_serr(MMS_CRIT, "mms_ev_insert: Unlock of MMS event " - "list mutex failed with errno - %s", strerror(rc)); - } -} - - -/* - * mms_rsp_create - * - * Create an MMS response. - */ -mms_rsp_ele_t * -mms_rsp_create(char *input, mms_par_node_t *cmd, int resp_type, char *tid) -{ - mms_rsp_ele_t *rsp; - - rsp = (mms_rsp_ele_t *)malloc(sizeof (mms_rsp_ele_t)); - if (rsp == NULL) { - mms_serr(MMS_CRIT, "mms_rsp_create: Malloc of space for new " - "response list element failed with errno - %s", - strerror(errno)); - } - - rsp->mms_rsp_str = input; - rsp->mms_rsp_cmd = cmd; - rsp->mms_rsp_type = resp_type; - rsp->mms_rsp_tid = tid; - - return (rsp); -} - - -/* - * mms_rsp_find - * - * Find the response, with the specified id, in the response list. - */ -mms_rsp_ele_t * -mms_rsp_find(mms_session_t *sp, char *tid) -{ - mms_rsp_ele_t *ele; - mms_rsp_ele_t *next; - - mms_list_foreach_safe(&sp->mms_rsp_list, ele, next) { - if ((strcmp(ele->mms_rsp_tid, tid)) == 0) { - mms_trace(MMS_DEBUG, "mms_rsp_find: Found final " - "response for command with taskid %s", tid); - mms_list_remove(&sp->mms_rsp_list, ele); - break; - } - } - - return (ele); -} - - -/* - * mms_rsp_insert - * - * Add a response to the response list. - */ -void -mms_rsp_insert(mms_session_t *sp, mms_rsp_ele_t *rsp) -{ - int rc; - - if ((rc = pthread_mutex_lock(&sp->mms_rsp_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_rsp_insert: Unlock of MMS " - "response list mutex failed with errno - %s", strerror(rc)); - } - - mms_list_insert_tail(&sp->mms_rsp_list, rsp); - - if ((rc = pthread_cond_broadcast(&sp->mms_rsp_cv)) != 0) { - mms_serr(MMS_CRIT, "mms_rsp_insert: Broadcast on " - "response list condition variable failed with errno - %s", - strerror(rc)); - } - - if ((rc = pthread_mutex_unlock(&sp->mms_rsp_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_rsp_insert: Unlock of MMS " - "response list mutex failed with errno - %s", strerror(rc)); - } -} - - -/* - * mms_rsp_wakeup - * - * Wakeup threads waiting for a final response. - */ -void -mms_rsp_wakeup(mms_session_t *sp) -{ - int rc; - - if ((rc = pthread_mutex_lock(&sp->mms_rsp_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_rsp_wakeup: Lock of MMS response list" - " mutex failed with errno - %s", strerror(rc)); - } - - if ((rc = pthread_cond_broadcast(&sp->mms_rsp_cv)) != 0) { - mms_serr(MMS_CRIT, "mms_rsp_wakeup: Broadcast on response list" - " condition variable failed with errno - %s", strerror(rc)); - } - - if ((rc = pthread_mutex_unlock(&sp->mms_rsp_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_rsp_wakeup: Unlock of MMS response" - " list mutex failed with errno - %s", strerror(rc)); - } -} - - -/* - * mms_start_notify - * - * Notify anyone waiting for the asynchronous interface to start - * processing requests. - */ -void -mms_start_notify(mms_session_t *sp) -{ - int rc; - - if ((rc = pthread_mutex_lock(&sp->mms_acc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_start_notify: Lock of MMS reader " - " start mutex failed with errno - %s", strerror(rc)); - } - - sp->mms_api_rstarted = MMS_API_YES; - - if ((rc = pthread_cond_broadcast(&sp->mms_acc_cv)) != 0) { - mms_serr(MMS_CRIT, "mms_start_notify: Broadcast on MMS " - "reader start condition variable failed with errno - %s", - strerror(rc)); - } - - if ((rc = pthread_mutex_unlock(&sp->mms_acc_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_start_notify: Unlock of MMS reader " - "start mutex failed with errno - %s", strerror(rc)); - } -} - - -/* - * mms_thread_exit - * - * Decrement the thread count. - */ -void -mms_thread_exit(mms_session_t *sp) -{ - int rc; - - if ((rc = pthread_mutex_lock(&sp->mms_cnt_mutex)) != 0) { - sp->mms_thrd_cnt--; - mms_serr(MMS_CRIT, "mms_thread_exit: Lock of MMS thread " - "count mutex failed with errno - %s", strerror(rc)); - } - - if (--sp->mms_thrd_cnt == 0 && - sp->mms_api_state == MMS_API_SHUTDOWN) { - mms_trace(MMS_DEBUG, - "mms_thread_exit: Last client thread to exit, " - "send broadcast to wake up goodbye"); - if ((rc = pthread_cond_broadcast(&sp->mms_cnt_cv)) != 0) { - mms_serr(MMS_CRIT, "mms_thread_exit: Broadcast on " - "thrd cnt variable failed with errno - %s", - strerror(rc)); - } - } - - if ((rc = pthread_mutex_unlock(&sp->mms_cnt_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_thread_exit: Unlock of MMS thread " - "count mutex failed with errno - %s", strerror(rc)); - } -} - - -/* - * mms_thread_start - * - * Start MMS API processing for a thread. - */ -void -mms_thread_start(mms_session_t *sp) -{ - int rc; - - if ((rc = pthread_mutex_lock(&sp->mms_cnt_mutex)) != 0) { - mms_serr(MMS_CRIT, "mms_thread_start: Lock of MMS thread " - "count mutex failed with errno - %s", strerror(rc)); - } - - sp->mms_thrd_cnt++; - - if ((rc = pthread_mutex_unlock(&sp->mms_cnt_mutex)) != 0) { - sp->mms_thrd_cnt--; - mms_serr(MMS_CRIT, "mms_thread_start: Unlock of MMS thread " - "count mutex failed with errno - %s", strerror(rc)); - } -} diff --git a/usr/src/lib/mms/mms/common/mms_par_impl.h b/usr/src/lib/mms/mms/common/mms_par_impl.h deleted file mode 100644 index 7a32fec8ae..0000000000 --- a/usr/src/lib/mms/mms/common/mms_par_impl.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - - -#ifndef __MMS_PAR_IMPL_H -#define __MMS_PAR_IMPL_H - - -#ifdef __cplusplus -extern "C" { -#endif - -#include <thread.h> -#include <synch.h> -#include <mms_sym.h> -#include <mms_parser.h> - -typedef union { - char *str; - mms_par_node_t *nodep; - mms_list_t *listp; -} mms_stype_t; - -#define MMS_PAR_MAX_CMDSIZE (1024*8) -#define MMS_PW_MAX_LEVEL 20 -#define MMS_PAR_REC_ERR_MAX 5 -#define MMS_PE_MAX (MMS_PAR_REC_ERR_MAX * 3) -#define MMS_PAR_MAX_TOKEN 2000 - -#define MMS_PAR_ALLOC_NODE(s, val, type) { \ - (s) = mms_par_alloc_node(type, val); \ - if ((s) == NULL) { \ - mms_pwka->par_wka_error = MMS_PE_NOMEM; \ - YYERROR; \ - } \ - mms_pwka->par_wka_cur_node = (s); \ - if (mms_par_cmd_node == NULL) { \ - mms_par_cmd_node = (s); \ - } else { \ - mms_list_insert_tail(&mms_par_cmd_node->pn_memlist, \ - (s)); \ - } \ - } - -#define MMS_PAR_ALLOC_LIST(s) { \ - mms_par_node_t *node; \ - node = mms_par_alloc_node(MMS_PN_LIST, "mem_list"); \ - if (node == NULL) { \ - mms_pwka->par_wka_error = MMS_PE_NOMEM; \ - YYERROR; \ - } \ - mms_list_insert_tail(&mms_par_cmd_node->pn_memlist, node); \ - (s) = &node->pn_arglist; \ - } - -#define MMS_PAR_FLAG_BYTE(x) ((x - TOKEN_MIN) / 8) -#define MMS_PAR_FLAG_SHIFT(x) ((x - TOKEN_MIN) % 8) -#define MMS_PAR_FLAG(x) (1 << MMS_PAR_FLAG_SHIFT(x)) -#define MMS_PAR_SET_FLAG(x) \ - (mms_pwka->par_wka_token_flags[MMS_PAR_FLAG_BYTE(x)] |= \ - MMS_PAR_FLAG(x)) -#define MMS_PAR_UNSET_FLAG(x) \ - (mms_pwka->par_wka_token_flags[MMS_PAR_FLAG_BYTE(x)] &= \ - ~MMS_PAR_FLAG(x)) -#define MMS_PAR_CHK_FLAG(x) \ - ((mms_pwka->par_wka_token_flags[MMS_PAR_FLAG_BYTE(x)] & \ - MMS_PAR_FLAG(x)) != 0 ? 1 : 0) -#define MMS_PAR_CHK_DUP(x) { \ - if (MMS_PAR_CHK_FLAG(x)) { \ - yyerror("Only one " #x " is allowed"); \ - } else { \ - MMS_PAR_SET_FLAG(x); \ - } \ - } - -typedef struct mms_pw { - uint32_t par_wka_flags; - int par_wka_scanner_offset; - struct mms_par_node **par_wka_cmd_node; - struct mms_par_node *par_wka_cur_node; - int par_wka_line; - int par_wka_col; - int par_wka_err_count; - int par_wka_err_type; - int par_wka_err_col; - uchar_t *par_wka_token_flags; - mms_list_t *par_wka_err_list; - int par_wka_rec_err; - int par_wka_error; /* Set this before */ - /* calling yyerror */ - mms_sym_t *par_wka_symtab; - int par_wka_num_syms; - mms_sym_t *par_wka_symtab_depend; - int par_wka_num_syms_depend; - mutex_t *par_wka_lock; - int par_wka_token_index; - char *par_wka_token[2]; - char par_wka_parser[40]; -} mms_pw_t; - -#define MMS_PW_NOTREE 0x01 -#define MMS_PW_KEYWORD 0x02 /* want keyword name */ -#define MMS_PW_DEPEND 0x04 /* Look in depend tbl first */ -#define MMS_PW_ATTR 0x08 -#define MMS_PW_EOF 0x10 -#define MMS_PW_ERROR 0x20 -#define MMS_PW_ERROR_CODE 0x40 /* Looking for error code */ - -#define mms_pwka ((mms_pw_t *)wka) -#define mms_par_cmd_node (*(mms_pwka->par_wka_cmd_node)) - -void mms_pe_free(mms_par_err_t *err); -void mms_par_error(mms_pw_t *wka, char *msg); - -mms_par_node_t *mms_par_alloc_node(enum mms_pn_type type, char *str); -mms_sym_t *mms_par_lookup_sym(char *mms_sym, mms_pw_t *wka); - -mms_pw_t * -mms_par_init_wka(mms_par_node_t **cmd_node, - mms_list_t *msg_list, - mms_sym_t *depend_symtab, int num_depend_syms, - int *depend_symtab_initialized); - -void mms_par_list_insert_tail(mms_list_t *list, void *node); -char *mms_par_char_to_xml_escape(char *src); -char *mms_par_xml_escape_to_char(char *src); - -#undef MMS_YY_INPUT - -#ifdef __cplusplus -} -#endif - -#endif /* __MMS_PAR_IMPL_H */ diff --git a/usr/src/lib/mms/mms/common/mms_par_util.c b/usr/src/lib/mms/mms/common/mms_par_util.c deleted file mode 100644 index 143675f5f3..0000000000 --- a/usr/src/lib/mms/mms/common/mms_par_util.c +++ /dev/null @@ -1,982 +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 <stdlib.h> -#include <string.h> -#include <synch.h> -#include <mms_list.h> -#include <mms_sym.h> -#include <mms_parser.h> -#include <mms_par_impl.h> -#include <mms_sym.h> -#include <msg_sub.h> -#include <mms_trace.h> - -static int mms_pn_token_start_xml(mms_par_node_t *node, - char *line, int level, int len); -static int mms_pn_token_end_xml(mms_par_node_t *node, - char *line, int level, int len); -static int mms_pn_token_end_text(mms_par_node_t *node, char *line, int len); -static int mms_pn_token_start_text(mms_par_node_t *node, char *line, int len); -static mms_par_node_t *mms_pn_lookup_aux(mms_par_node_t *top, - mms_par_node_t *start, char *str, int type, int self); -static int mms_pn_cmd_len_xml_aux(mms_par_node_t *top, int level); - -static int mms_pn_build_cmd_xml_aux(mms_par_node_t *top, char *line, - int level, int len); -static void mms_pn_fini_aux(mms_par_node_t *root); - -int mms_symtab_initialized = 0; -extern mutex_t mms_par_mutex; -extern mms_pw_t *mms_pw; - -#define MMS_FUZZ 5 - -/* - * Translate chars &, <. >, " and ' to xml mms_escape sequence - */ -typedef struct mms_escape_seq { - char *es_char; - char *es_seq; - int es_len; -} mms_escape_seq_t; - -#define MMS_SEMICOLON "\073" /* Have to do this to suppress cstyle */ - /* from complaining */ -static mms_escape_seq_t mms_esseq[] = { - "\"", """ MMS_SEMICOLON, 6, - "'", "&apos" MMS_SEMICOLON, 6, - ">", ">" MMS_SEMICOLON, 4, - "<", "<" MMS_SEMICOLON, 4, - "&", "&" MMS_SEMICOLON, 5, -}; -static int mms_num_esseq = sizeof (mms_esseq) / sizeof (mms_escape_seq_t); - -static void -mms_par_indent(char *line, int level) -{ - int i; - for (i = 0; i < level; i++) { - line[i] = ' '; - } -} - -void -mms_par_list_insert_tail(mms_list_t *list, void *node) -{ - if (node != NULL) { - mms_list_insert_tail(list, node); - } -} - -void -mms_pe_destroy(mms_list_t *err_list) -{ - mms_par_err_t *err, *tmp; - - mms_list_foreach_safe(err_list, err, tmp) { - mms_list_remove(err_list, err); - mms_pe_free(err); - } -} - -void -mms_pe_free(mms_par_err_t *err) -{ - if (err->pe_msg) - free(err->pe_msg); - if (err->pe_token) - free(err->pe_token); - free(err); -} - -mms_par_node_t * -mms_par_alloc_node(enum mms_pn_type type, char *str) -{ - mms_par_node_t *node; - - node = (mms_par_node_t *)malloc(sizeof (mms_par_node_t)); - if (node == NULL) { - return (NULL); - } - (void) memset(node, 0, sizeof (mms_par_node_t)); - node->pn_type = type; - mms_list_create(&node->pn_arglist, sizeof (mms_par_node_t), - offsetof(mms_par_node_t, pn_next)); - mms_list_create(&node->pn_attrlist, sizeof (mms_par_node_t), - offsetof(mms_par_node_t, pn_attrlist)); - mms_list_create(&node->pn_memlist, sizeof (mms_par_node_t), - offsetof(mms_par_node_t, pn_memnext)); - node->pn_string = strdup(str); - if (mms_pn_token(node) == NULL) { - free(node); - return (NULL); - } - return (node); -} - -void -mms_pn_destroy(mms_par_node_t *node) -{ - mms_par_node_t *obj; - mms_par_node_t *tmp; - - if (node == NULL) - return; - - mms_list_foreach_safe(&node->pn_memlist, obj, tmp) { - mms_list_remove(&node->pn_memlist, obj); - if (obj->pn_string) { - free(obj->pn_string); - obj->pn_string = NULL; - } - free(obj); - } - if (node->pn_string) { - free(node->pn_string); - node->pn_string = NULL; - } - free(node); -} - -/* - * mms_pn_len_xml - return the length needed to convert this node to text - */ -int -mms_pn_len_xml(mms_par_node_t *node, int level) -{ - int len = 0; - int i, j; - char *str; - - len = strlen(mms_pn_token(node)); - switch (mms_pn_type(node)) { - case MMS_PN_CMD: - len = 2 * len + 7 + level; - break; - case MMS_PN_OPS: - len = 2 * len + 7 + level; - break; - case MMS_PN_CLAUSE: - len = 2 * len + 7 + level; - break; - case MMS_PN_RANGE: - len = 2 * len + 7 + level; - break; - case MMS_PN_OBJ: - len = len + 19 + level; - break; - case MMS_PN_ATTR: - len = len + 8; - break; - case MMS_PN_STRING: - len = len * 5 + 16 + level; - break; - case MMS_PN_NUMERIC | MMS_PN_STRING: - len = len + 16 + level; - break; - case MMS_PN_NULLSTR | MMS_PN_STRING: - len = len + 8 + level; - break; - case MMS_PN_KEYWORD: - len = len + 4 + level; - break; - default: - len += 1; - break; - } - - str = mms_pn_token(node); - for (i = 0; i < strlen(str); i++) { - for (j = 0; j < mms_num_esseq; j++) { - if (str[i] == mms_esseq[j].es_char[0]) { - len += 10; - } - } - } - return (len + MMS_FUZZ); -} - -/* - * mms_pn_cmd_len_xml - return the length needed to convert this node - * and the list of nodes attached to this node. - */ -int -mms_pn_cmd_len_xml(mms_par_node_t *top) -{ - return (mms_pn_cmd_len_xml_aux(top, 0)); -} - -static int -mms_pn_cmd_len_xml_aux(mms_par_node_t *top, int level) -{ - mms_par_node_t *node; - int len; - - len = mms_pn_len_xml(top, level); - mms_list_foreach(&top->pn_arglist, node) { - len += mms_pn_cmd_len_xml_aux(node, level + 1); - } - return (len); -} - -/* - * par_node_to_text_start - convert the beginning part of this node - */ -static int -mms_pn_token_start_xml(mms_par_node_t *node, char *line, int level, int len) -{ - char *start = line + level; - char *text; - - switch (mms_pn_type(node)) { - case MMS_PN_CMD: - mms_par_indent(line, level); - (void) snprintf(start, len - level, - "<%s>\n", mms_pn_token(node)); - break; - case MMS_PN_OPS: - mms_par_indent(line, level); - (void) snprintf(start, len - level, - "<%s>\n", mms_pn_token(node)); - break; - case MMS_PN_CLAUSE: - mms_par_indent(line, level); - (void) snprintf(start, len - level, - "<%s>\n", mms_pn_token(node)); - break; - case MMS_PN_RANGE: - mms_par_indent(line, level); - (void) snprintf(start, len - level, - "<%s>\n", mms_pn_token(node)); - break; - case MMS_PN_OBJ: - mms_par_indent(line, level); - (void) snprintf(start, len - level, - "<object name=\"%s\"", mms_pn_token(node)); - break; - case MMS_PN_ATTR: - (void) snprintf(line, len - level, - " attr=\"%s\"", mms_pn_token(node)); - break; - case MMS_PN_STRING: - mms_par_indent(line, level); - text = mms_par_char_to_xml_escape(mms_pn_token(node)); - if (text == NULL) { - text = "\n****** OUT OF MEMORY ******\n\n"; - } - (void) snprintf(start, len - level, - "<arg value=\"%s\"/>\n", text); - break; - case MMS_PN_KEYWORD: - case MMS_PN_NULLSTR | MMS_PN_STRING: - mms_par_indent(line, level); - (void) snprintf(start, len - level, - "<%s/>\n", mms_pn_token(node)); - break; - case MMS_PN_NUMERIC | MMS_PN_STRING: - mms_par_indent(line, level); - (void) snprintf(start, len - level, - "<arg value=\"%s\"/>\n", mms_pn_token(node)); - break; - default: - (void) snprintf(line, len - level, "%s", " "); - break; - } - return (strlen(line)); -} - -/* - * par_node_to_text_end - terminate the converted text. - */ -static int -mms_pn_token_end_xml(mms_par_node_t *node, char *line, int level, int len) -{ - char *start = line + level; - - switch (mms_pn_type(node)) { - case MMS_PN_CMD: - mms_par_indent(line, level); - (void) snprintf(start, len - level, - "</%s>\n", mms_pn_token(node)); - break; - case MMS_PN_OPS: - mms_par_indent(line, level); - (void) snprintf(start, len - level, - "</%s>\n", mms_pn_token(node)); - break; - case MMS_PN_CLAUSE: - mms_par_indent(line, level); - (void) snprintf(start, len - level, - "</%s>\n", mms_pn_token(node)); - break; - case MMS_PN_RANGE: - mms_par_indent(line, level); - (void) snprintf(start, len - level, - "</%s>\n", mms_pn_token(node)); - break; - case MMS_PN_OBJ: - (void) snprintf(line, len - level, "%s", "/>\n"); - break; - case MMS_PN_ATTR: - break; - case MMS_PN_STRING: - break; - case MMS_PN_KEYWORD: - break; - case MMS_PN_NUMERIC | MMS_PN_STRING: - break; - } - return (strlen(line)); -} - -/* - * mms_pn_build_cmd_xml - convert a node structure to a line of text - */ -char * -mms_pn_build_cmd_xml(mms_par_node_t *top) -{ - int len; - int off; - char *prolog = "<?xml version=\"1.0\"?>\n"; - char *buf; - - len = mms_pn_cmd_len_xml(top) + strlen(prolog) + 100; - - buf = malloc(len); - if (buf == NULL) { - return (NULL); - } - off = snprintf(buf, len, "%s", prolog); - - (void) mms_pn_build_cmd_xml_aux(top, buf + off, 0, len); - return (buf); -} - -static int -mms_pn_build_cmd_xml_aux(mms_par_node_t *top, char *line, int level, int size) -{ - mms_par_node_t *node; - int len = 0; - - if (top == NULL) - return (0); - - line[0] = '\0'; - - len += mms_pn_token_start_xml(top, line, level, size); - - mms_list_foreach(&top->pn_arglist, node) { - len += mms_pn_build_cmd_xml_aux(node, line + len, level + 1, - size); - } - len += mms_pn_token_end_xml(top, line + len, level, size); - return (len); -} - - -char * -mms_pn_build_cmd_text(mms_par_node_t *top) -{ - int len = 0; - char *line; - - len = mms_pn_cmd_len_text(top); - line = (char *)malloc(len + 200); - if (line == NULL) { - return (NULL); - } - line[0] = '\0'; - - (void) mms_pn_build_cmd_text_aux(top, line, len); - return (line); -} - -int -mms_pn_build_cmd_text_aux(mms_par_node_t *top, char *line, int size) -{ - int len; - mms_par_node_t *node; - - len = mms_pn_token_start_text(top, line, size); - - mms_list_foreach(&top->pn_arglist, node) { - if (mms_pn_type(node) == MMS_PN_RANGE && - strcmp(mms_pn_token(node), "..") == 0) { - mms_par_node_t *tmp; - - tmp = mms_list_head(&node->pn_arglist); - len += mms_pn_token_start_text(tmp, line + len, size); - if (line[len - 1] == ' ') { - len--; - } - len += mms_pn_token_start_text(node, line + len, size); - tmp = mms_list_next(&node->pn_arglist, tmp); - len += mms_pn_token_start_text(tmp, line + len, size); - } else { - len += mms_pn_build_cmd_text_aux(node, line + len, - size); - } - } - len += mms_pn_token_end_text(top, line + len, size); - return (len); -} - -int -mms_pn_cmd_len_text(mms_par_node_t *top) -{ - mms_par_node_t *node; - int len; - - len = mms_pn_len_text(top); - mms_list_foreach(&top->pn_arglist, node) { - len += mms_pn_cmd_len_text(node); - } - return (len); -} - -int -mms_pn_len_text(mms_par_node_t *node) -{ - int len = 0; - - len = strlen(mms_pn_token(node)); - switch (mms_pn_type(node)) { - case MMS_PN_CMD: - len += 2; - break; - case MMS_PN_OPS: - len += 3; - break; - case MMS_PN_CLAUSE: - len += 3; - break; - case MMS_PN_OBJ: - len += 1; - break; - case MMS_PN_ATTR: - len += 4; - break; - case MMS_PN_STRING: - len += 3; - break; - case MMS_PN_NUMERIC | MMS_PN_STRING: - len += 3; - break; - case MMS_PN_NULLSTR | MMS_PN_STRING: - len += 3; - break; - case MMS_PN_KEYWORD: - len += 3; - break; - default: - len += 1; - break; - } - return (len + MMS_FUZZ); -} - -static int -mms_pn_token_end_text(mms_par_node_t *node, char *line, int len) -{ - switch (mms_pn_type(node)) { - case MMS_PN_CMD: - (void) snprintf(line, len, "%c", ';'); - break; - case MMS_PN_OPS: - if (line[-1] == ' ') - (void) snprintf(line - 1, len, "%c ", ')'); - else - (void) snprintf(line, len, "%c ", ')'); - break; - case MMS_PN_CLAUSE: - if (line[-1] == ' ') - (void) snprintf(line - 1, len, "%c ", ']'); - else - (void) snprintf(line, len, "%c ", ']'); - break; - case MMS_PN_OBJ: - break; - case MMS_PN_ATTR: - break; - case MMS_PN_STRING: - break; - case MMS_PN_KEYWORD: - break; - case MMS_PN_NUMERIC | MMS_PN_STRING: - break; - case MMS_PN_RANGE: - break; - } - return (strlen(line)); -} - -static int -mms_pn_token_start_text(mms_par_node_t *node, char *line, int len) -{ - - switch (mms_pn_type(node)) { - case MMS_PN_CMD: - (void) snprintf(line, len, "%s ", mms_pn_token(node)); - break; - case MMS_PN_OPS: - (void) snprintf(line, len, "%s(", mms_pn_token(node)); - break; - case MMS_PN_CLAUSE: - (void) snprintf(line, len, "%s[", mms_pn_token(node)); - break; - case MMS_PN_OBJ: - (void) snprintf(line, len, "%s ", mms_pn_token(node)); - break; - case MMS_PN_ATTR: - /* Back up over blank following object name */ - (void) snprintf(line - 1, len, ".'%s' ", mms_pn_token(node)); - break; - case MMS_PN_STRING: - (void) snprintf(line, len, "'%s' ", mms_pn_token(node)); - break; - case MMS_PN_KEYWORD: - (void) snprintf(line, len, "%s ", mms_pn_token(node)); - break; - case MMS_PN_NUMERIC | MMS_PN_STRING: - (void) snprintf(line, len, "'%s' ", mms_pn_token(node)); - break; - case MMS_PN_NULLSTR | MMS_PN_STRING: - (void) snprintf(line, len, "%s", mms_pn_token(node)); - break; - case MMS_PN_RANGE: - (void) snprintf(line, len, "%s", mms_pn_token(node)); - break; - default: - (void) snprintf(line, len, " "); - break; - } - return (strlen(line)); -} - -mms_par_node_t * -mms_pn_lookup_arg(mms_par_node_t *top, char *str, - int type, mms_par_node_t **prev) -{ - mms_par_node_t *start; - - if (prev == NULL || *prev == NULL) { - /* first time */ - start = mms_list_head(&top->pn_arglist); - } else { - start = mms_list_next(&top->pn_arglist, *prev); - } - - for (; start != NULL; - start = mms_list_next(&top->pn_arglist, start)) { - if ((str == NULL || str[0] == '\0' || - strcmp(mms_pn_token(start), str) == 0) && - ((type == 0 || (start->pn_type & type)))) { - /* Found a matching start */ - if (prev != NULL) { - *prev = start; - } - return (start); - } - } - - /* - * No matching node - */ - return (NULL); -} - -mms_par_node_t * -mms_pn_lookup(mms_par_node_t *top, char *str, int type, mms_par_node_t **prev) -{ - mms_par_node_t *root = top; - mms_par_node_t *node = NULL; - mms_par_node_t *start = top; - int self = 1; - - if (top == NULL) { /* no tree to lookup */ - return (NULL); - } - - if (prev != NULL && (*prev) != NULL) { - start = *prev; - self = 0; - root = start->pn_list; - if (root == NULL) { - root = start; - } - } - - node = mms_pn_lookup_aux(root, start, str, type, self); - - while (root != top && node == NULL) { - /* - * Go up 1 level and get the next node to start - */ - start = root; - root = root->pn_list; - node = NULL; - if (start->pn_flags & MMS_PN_ATTR_LIST) { - node = mms_list_next(&root->pn_attrlist, start); - if (node == NULL) { - node = mms_list_head(&root->pn_arglist); - } - } else { - node = mms_list_next(&root->pn_arglist, start); - } - - if (node == NULL) { - /* - * No more node at this level - */ - start = root; - continue; - } - - start = node; - self = 1; - node = mms_pn_lookup_aux(root, start, str, type, self); - if (node != NULL) { - /* - * Found a matching node - */ - break; - } - } - - if (prev != NULL && node != NULL) { - *prev = node; - } - return (node); -} - -static mms_par_node_t * -mms_pn_lookup_aux(mms_par_node_t *top, mms_par_node_t *start, - char *str, int type, - int self) -{ - mms_par_node_t *node; - mms_par_node_t *result; - mms_list_t *list; - - if (top == NULL || start == NULL) { - return (NULL); - } - - /* - * Start from the start node - */ - if (self == 1) { - /* - * Do self check - */ - if (type == 0 || (type & mms_pn_type(start))) { - if (str == NULL || str[0] == '\0' || - strcmp(str, mms_pn_token(start)) == 0) { - /* found a matching node */ - return (start); - } - } - /* - * Already did self check, don't do it again - */ - self = 0; - } - - /* - * Check each of the attributes of this node. - */ - list = &top->pn_attrlist; - if (top == start) { - start = mms_list_head(list); - /* - * Have a new start node, do self check on this one - */ - self = 1; - } - if (start != NULL && (start->pn_flags & MMS_PN_ATTR_LIST)) { - for (node = start; - node != NULL; - node = mms_list_next(list, node)) { - result = mms_pn_lookup_aux(node, node, str, type, - self); - if (result != NULL) { - /* found a matching node */ - return (result); - } - /* - * Do self check from now on - */ - self = 1; - } - start = NULL; - } - /* - * Start search of arglist - */ - list = &top->pn_arglist; - if (start == NULL) { - start = mms_list_head(list); - /* - * Have a new start node, do self check on this one - */ - self = 1; - } - for (node = start; node != NULL; node = mms_list_next(list, node)) { - result = mms_pn_lookup_aux(node, node, str, type, self); - if (result != NULL) { - /* found a matching node */ - return (result); - } - /* - * Do self check from now on - */ - self = 1; - } - - /* - * Can't find a matching node. - */ - return (NULL); -} - -mms_sym_t * -mms_par_lookup_sym(char *mms_sym, mms_pw_t *wka) -{ - mms_sym_t *syment; - - if (wka->par_wka_flags & MMS_PW_DEPEND) { - wka->par_wka_flags &= ~MMS_PW_DEPEND; - /* - * Look in parser dependent table first - */ - syment = mms_lookup_sym_token(mms_sym, - wka->par_wka_symtab_depend, - wka->par_wka_num_syms_depend); - if (syment != NULL) { - return (syment); - } - syment = mms_lookup_sym_token(mms_sym, wka->par_wka_symtab, - wka->par_wka_num_syms); - if (syment != NULL) { - return (syment); - } - } else { - syment = mms_lookup_sym_token(mms_sym, wka->par_wka_symtab, - wka->par_wka_num_syms); - if (syment != NULL) { - return (syment); - } - syment = mms_lookup_sym_token(mms_sym, - wka->par_wka_symtab_depend, - wka->par_wka_num_syms_depend); - if (syment != NULL) { - return (syment); - } - } - return (NULL); -} - -char * -mms_par_char_to_xml_escape(char *src) -{ - int out_incr; - int out_len; - int out_off; - char *out; - int in_len; - int in_off; - char *in; - int esc_len; - int i; - - in = src; - in_len = strlen(in); - in_off = 0; - - out_len = strlen(in) * 2; /* get more space */ - out_off = 0; - out = malloc(out_len + 1); - if (out == NULL) { /* can't get out buffer */ - return (NULL); - } - for (in_off = 0, out_off = 0; - in_off < in_len; - in_off++, out_off += out_incr) { - out_incr = 1; - for (i = 0; i < mms_num_esseq; i++) { - if (in[in_off] == mms_esseq[i].es_char[0]) { - esc_len = mms_esseq[i].es_len; - break; - } - } - - if (i == mms_num_esseq) { - /* No need to mms_escape */ - out[out_off] = in[in_off]; - } else { - /* mms_escape this char */ - while ((out_len - out_off) < - (in_len - in_off - 1 + esc_len)) { - /* - * If output buf cannot hold the remaining - * input and the escapeext length, then - * get more space - */ - char *new; - char new_len = out_len * 2; - - new = realloc(out, new_len); - if (new == NULL) { - free(out); - return (NULL); - } - free(out); - out = new; - out_len = new_len; - } - (void) strcpy(out + out_off, mms_esseq[i].es_seq); - out_incr = esc_len; - } - } - out[out_off] = '\0'; - return (out); -} - -char * -mms_par_xml_escape_to_char(char *src) -{ - int out_len; - int out_off; - char *out; - int in_incr; - int in_len; - int in_off; - char *in; - int esc_len; - int i; - - in = src; - in_len = strlen(in); - in_off = 0; - - out_len = strlen(in) * 2; /* get more space */ - out_off = 0; - out = malloc(out_len + 1); - if (out == NULL) { /* can't get out buffer */ - return (NULL); - } - for (in_off = 0, out_off = 0; - in_off < in_len; - in_off += in_incr, out_off++) { - in_incr = 1; - for (i = 0; i < mms_num_esseq; i++) { - esc_len = mms_esseq[i].es_len; - if (strncmp(in + in_off, mms_esseq[i].es_seq, esc_len) - == 0) { - break; - } - } - - if (i == mms_num_esseq) { - /* No need to mms_escape */ - out[out_off] = in[in_off]; - } else { - /* found an mms_escape sequence */ - out[out_off] = mms_esseq[i].es_char[0]; - in_incr = esc_len; - } - } - out[out_off] = '\0'; - return (out); -} - -void -mms_par_error(mms_pw_t *wka, char *msg) -{ - mms_par_err_t *err; - char msgtext[500]; - - /* - * Do this only once. - */ - wka->par_wka_err_count++; - err = (mms_par_err_t *)malloc(sizeof (mms_par_err_t)); - if (err == NULL) { - if (wka->par_wka_error == 0) { - wka->par_wka_error = MMS_PE_NOMEM; - return; - } - } - (void) memset(err, 0, sizeof (mms_par_err_t)); - err->pe_line = wka->par_wka_line; - err->pe_col = wka->par_wka_col; - err->pe_token = strdup(wka->par_wka_token - [(wka->par_wka_token_index - 1) % 2]); - (void) snprintf(msgtext, sizeof (msgtext), - "%s: %s", wka->par_wka_parser, msg); - err->pe_msg = strdup(msgtext); - mms_par_list_insert_tail(wka->par_wka_err_list, err); - if (wka->par_wka_error == 0) { - wka->par_wka_error = MMS_PE_SYNTAX; - } - err->pe_code = wka->par_wka_error; -} - -void -mms_pn_fini(mms_par_node_t *root) -{ - if (root != NULL) { - root->pn_list = NULL; - mms_pn_fini_aux(root); - } -} - -void -mms_pn_fini_aux(mms_par_node_t *list) -{ - mms_par_node_t *node; - - /* - * Check each of the attributes of this node. - */ - mms_list_foreach(&list->pn_attrlist, node) { - node->pn_list = list; - node->pn_flags |= MMS_PN_ATTR_LIST; - mms_pn_fini_aux(node); - } - - /* - * Check each of the arguements of this node. - */ - mms_list_foreach(&list->pn_arglist, node) { - node->pn_list = list; - node->pn_flags |= MMS_PN_ARG_LIST; - mms_pn_fini_aux(node); - } -} diff --git a/usr/src/lib/mms/mms/common/mms_rw.c b/usr/src/lib/mms/mms/common/mms_rw.c deleted file mode 100644 index fabf18bda0..0000000000 --- a/usr/src/lib/mms/mms/common/mms_rw.c +++ /dev/null @@ -1,260 +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. - */ - - -/* - * MMS socket or named-pipe string writer and string reader. - * - * O_NDELAY and O_NONBLOCK are assumed to be not set for a blocking - * read and write. Currently, both flags are clear as the default. - */ -#include <sys/types.h> -#include <sys/filio.h> -#include <pthread.h> -#include <stropts.h> -#include <sys/conf.h> -#include <stdio.h> -#include <stdlib.h> -#include <errno.h> -#include <string.h> -#include <unistd.h> -#include <sys/time.h> -#include <mms_dmd.h> -#include "mms_network.h" -#include "mms_sym.h" -#include "mms_sock.h" - -static pthread_mutex_t mms_read_mutex = PTHREAD_MUTEX_INITIALIZER; -static pthread_mutex_t mms_write_mutex = PTHREAD_MUTEX_INITIALIZER; - -/* - * mms_writer() - * - * Parameters: - * fd File descriptor that packet is to be written to - * buf Contains the text that is to be written. Buf must be '\0' - * terminated. - * - * This routine will write out a mms command from one process to another - * using the fd as the descriptor to write to. It replaces newline - * characters in the input buffer with blanks and appends "\r\n" to the end - * of the input buffer. The newline character is used as the delimiter of a - * command. O_NDELAY and O_ NONBLOCK are assumed to be clear, thus it will - * block if it cannot write. This routine should be protected by a mutex if - * more than one thread or process can write to fd at one time. The reason - * for this is that if the routine is interrupted while it is writing, it - * will try to complete the write when control is returned to this routine. - * Though the odds of this are slim, it should still be done. - * - * Return Values: - * -1 No data was written and write failed. Check errno - * for cause of failure. - * < len of buf If the write was able to write part of the data - * but write returned a -1 on suplmental call to write. - * Thus one needs to look at errno to determine the - * cause of the failure. This will also corrupt the - * socket. Recovery should be to close the socket and - * reconnect if a application to MM. If no data was - * written in then a len of 0 will be returned. - * len of buf If write was successful. This routine also writes the - * '\0' byte but does not add this to the length returned. - * - */ - -int -mms_writer(mms_t *conn, char *buf) -{ - struct iovec iov[3]; - struct iovec *iov_start; - int nleft; - int i; - int rc; - int nwritten; - int niov; - char *terminator = "\n"; - int termlen = strlen(terminator); - int buflen; - char hdr[MMS_SOCK_HDR_SIZE + 1]; - - buflen = strlen(buf); - (void) snprintf(hdr, sizeof (hdr), "%8.8s%7.7d\n", MMS_MSG_MAGIC, - buflen + termlen); - - iov[0].iov_base = hdr; - iov[0].iov_len = MMS_SOCK_HDR_SIZE; - - iov[1].iov_base = buf; - iov[1].iov_len = buflen; - - iov[2].iov_base = terminator; - iov[2].iov_len = termlen; - - nwritten = 0; - nleft = 0; - for (i = 0; i < 3; i++) { - /* Calculate the number of bytes to write */ - nleft += iov[i].iov_len; - } - iov_start = iov; - niov = 3; - (void) pthread_mutex_lock(&mms_write_mutex); - while (nleft > 0) { - /* - * if socket or fifo full, write blocks until room - * is made - */ - if ((rc = mms_write(conn, iov_start, niov)) < 0) { - if (mms_write_has_error(conn) == 0) - continue; - /* see if any data has been written */ - if (nwritten) { - rc = nwritten; - } - (void) pthread_mutex_unlock(&mms_write_mutex); - return (rc); - } - /* some or all data written */ - nleft -= rc; - nwritten += rc; - - if (nleft > 0) { /* not all written */ - /* Have to figure out where to restart */ - for (i = 0; i < niov; i++) { - if (rc < iov[i].iov_len) { - break; - } - rc -= iov[i].iov_len; - } - iov[i].iov_base += rc; - iov[i].iov_len -= rc; - iov_start += i; - niov -= i; - continue; - } - } - - (void) pthread_mutex_unlock(&mms_write_mutex); - /* buffer written */ - return (buflen); -} - -/* - * mms_reader() - * - * Return a complete MMS command in a read buffer, including the newline - * character that delimits one command from the next. - * - * Parameters: - * fd File descriptor that routine is to read from - * buf Ptr to the text that was read in. Actual return value - * of the message that was received. If an error occurs - * this will be set to NULL. - * - * This routine allocates a read buffer and copy bytes from the receive - * buffer for the file descriptor until a newline character is encountered - * and copied. Then the read buffer is terminated with '\0'. If an interrupt - * occurs while reading, the routine will start another read. This routine - * will read until the necessary amount of data is obtained or it errors out - * for some some reason. O_NDELAY and O_NONBLOCK are assumed to be clear, - * thus it will block if it cannot read. This routine should be protected by - * a mutex if more than one thread or process can read from the fd at one - * time. The reason for this is that if the routine is interrupted while it - * is reading, it will try to complete the read when control is returned to - * this routine. Though the odds of this are slim, it should still be - * done. - * - * Return Values: - * -1 No data was read and read failed. Check errno - * for cause of failure. If errno was an EINTR the - * routine will attempt to read again. All other reasons - * for a -1 return value from read will return a -1. User - * will need to check the errno to determine reason. - * 0 If EOF was read, the read will return a 0. This - * routine will return a 0 in this case otherwise the - * internal loops turn into infinite loops. - * len of buf The length of the message that was read. Even though - * this routine reads the header and a trailing '\0' - * character this value does not include them. - * - */ - -int -mms_reader(mms_t *conn, char **cmdbuf) -{ - int rc; - int bufsize; - char *buf; - char hdr[MMS_SOCK_HDR_SIZE + 1]; - - *cmdbuf = NULL; - (void) pthread_mutex_lock(&mms_read_mutex); - - /* - * Read header to get message size - */ - while ((rc = mms_read(conn, hdr, MMS_SOCK_HDR_SIZE)) < 0) { - if (mms_read_has_error(conn) == 0) { - continue; - } - (void) pthread_mutex_unlock(&mms_read_mutex); - return (-1); - } - if (rc == 0) { - /* Hit EOF */ - (void) pthread_mutex_unlock(&mms_read_mutex); - return (rc); - } - hdr[MMS_SOCK_HDR_SIZE] = '\0'; - - /* - * Check message magic - */ - if (strncmp(hdr, MMS_MSG_MAGIC, MMS_MSG_MAGIC_LEN) != 0) { - /* Incorrect input */ - mms_error(&conn->mms_err, MMS_ERR_READ); - (void) pthread_mutex_unlock(&mms_read_mutex); - return (-1); - } - - (void) sscanf(hdr + MMS_MSG_MAGIC_LEN, "%d", &bufsize); - - buf = malloc(bufsize + 1); - if (buf == NULL) { - mms_error(&conn->mms_err, MMS_ERR_NOMEM); - (void) pthread_mutex_unlock(&mms_read_mutex); - return (-1); - } - while ((rc = mms_read(conn, buf, bufsize)) < 0) { - if (mms_read_has_error(conn) == 0) { - continue; - } - free(buf); - (void) pthread_mutex_unlock(&mms_read_mutex); - return (-1); - } - *cmdbuf = buf; /* return buffer ptr */ - buf[rc] = '\0'; /* terminate what is read */ - (void) pthread_mutex_unlock(&mms_read_mutex); - return (rc); -} diff --git a/usr/src/lib/mms/mms/common/mms_scsi.c b/usr/src/lib/mms/mms/common/mms_scsi.c deleted file mode 100644 index ee42fec638..0000000000 --- a/usr/src/lib/mms/mms/common/mms_scsi.c +++ /dev/null @@ -1,237 +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 <stdlib.h> -#include <sys/scsi/generic/sense.h> -#include <sys/scsi/generic/status.h> -#include <sys/scsi/generic/commands.h> -#include <mms_sym.h> -#include <mms_scsi.h> -#include <mms_strapp.h> - -static mms_sym_t mms_scsi_cmd_tab[] = { - "TEST_UNIT_READY", SCMD_TEST_UNIT_READY, /* 0x00 */ - "REZERO/REWIND", SCMD_REWIND | SCMD_REZERO_UNIT, /* 0x01 */ - "REQUEST_SENSE", SCMD_REQUEST_SENSE, /* 0x03 */ - "FORMAT", SCMD_FORMAT, /* 0x04 */ - "READ_BLOCK_LIMITS", SCMD_READ_BLKLIM, /* 0x05 */ - "REASSIGN", SCMD_REASSIGN_BLOCK, /* 0x07 */ - "READ", SCMD_READ | SCMD_RECEIVE, /* 0x08 */ - "WRITE", SCMD_PRINT | SCMD_SEND | SCMD_WRITE, /* 0x0A */ - "SEEK", SCMD_SEEK | SCMD_SLEW_PRINT | SCMD_TRK_SEL, - /* 0x0B */ - "READ_REVERSE", SCMD_READ_REVERSE, /* 0x0F */ - "WRITE_FILE_MARK", SCMD_WRITE_FILE_MARK | SCMD_FLUSH_PRINT_BUF, - /* 0x10 */ - "SPACE", SCMD_SPACE, /* 0x11 */ - "INQUIRY", SCMD_INQUIRY, /* 0x12 */ - "VERIFY", SCMD_VERIFY_G0, /* 0x13 */ - "RECOVER_BUFFER_DATA", SCMD_RECOVER_BUF, /* 0x14 */ - "MODE_SELECT", SCMD_MODE_SELECT, /* 0x15 */ - "RESERVE", SCMD_RESERVE, /* 0x16 */ - "RELEASE", SCMD_RELEASE, /* 0x17 */ - "COPY", SCMD_COPY, /* 0x18 */ - "ERASE_TAPE", SCMD_ERASE, /* 0x19 */ - "MODE_SENSE", SCMD_MODE_SENSE, /* 0x1A */ - "LOAD/START/STOP", SCMD_LOAD | SCMD_START_STOP | SCMD_STOP_PRINT, - /* 0x1B */ - "GET_DIAGNOSTIC_RESULTS", SCMD_GDIAG, /* 0x1C */ - "SEND_DIAGNOSTIC_COMMAND", SCMD_SDIAG, /* 0x1D */ - "DOOR_LOCK", SCMD_DOORLOCK, /* 0x1E */ - "READ_FORMAT_CAPACITY", SCMD_READ_FORMAT_CAP, /* 0x23 */ - "READ_CAPACITY", SCMD_READ_CAPACITY, /* 0x25 */ - "READ(10)", SCMD_READ_G1, /* 0x28 */ - "WRITE(10)", SCMD_WRITE_G1, /* 0x2A */ - "SEEK(10)", SCMD_SEEK_G1 | SCMD_LOCATE, /* 0x2B */ - "WRITE_VERIFY", SCMD_WRITE_VERIFY, /* 0x2E */ - "VERIFY(10)", SCMD_VERIFY, /* 0x2F */ - "SEARCH_DATA_HIGH", SCMD_SEARCH_HIGH, /* 0x30 */ - "SEARCH_DATA_EQUAL", SCMD_SEARCH_EQUAL, /* 0x31 */ - "SEARCH_DATA_LOW", SCMD_SEARCH_LOW, /* 0x32 */ - "SET_LIMITS", SCMD_SET_LIMITS, /* 0x33 */ - "READ_POSITION", SCMD_READ_POSITION, /* 0x34 */ - "SYNCHRONIZE_CACHE", SCMD_SYNCHRONIZE_CACHE, /* 0x35 */ - "READ_DEFECT_DATA", SCMD_READ_DEFECT_LIST, /* 0x37 */ - "COMPARE", SCMD_COMPARE, /* 0x39 */ - "COPY_VERIFY", SCMD_COPY_VERIFY, /* 0x3A */ - "WRITE_BUFFER", SCMD_WRITE_BUFFER, /* 0x3B */ - "READ_BUFFER", SCMD_READ_BUFFER, /* 0x3C */ - "READ_LONG", SCMD_READ_LONG, /* 0x3E */ - "WRITE_LONG", SCMD_WRITE_LONG, /* 0x3F */ - "REPORT_DENSITIES/READ_HEADER", SCMD_REPORT_DENSITIES, /* 0x44 */ - "LOG_SELECT", SCMD_LOG_SELECT_G1, /* 0x4C */ - "LOG_SENSE", SCMD_LOG_SENSE_G1, /* 0x4D */ - "MODE_SELECT(10)", SCMD_MODE_SELECT_G1, /* 0x55 */ - "RESERVE(10)", SCMD_RESERVE_G1, /* 0x56 */ - "RELEASE(10)", SCMD_RELEASE_G1, /* 0x57 */ - "MODE_SENSE(10)", SCMD_MODE_SENSE_G1, /* 0x5A */ - "PERSISTENT_RESERVE_IN", SCMD_PERSISTENT_RESERVE_IN, /* 0x5E */ - "PERSISTENT_RESERVE_OUT", SCMD_PERSISTENT_RESERVE_OUT, /* 0x5F */ - "EXTENDED_COPY", SCMD_EXTENDED_COPY, /* 0x83 */ - "READ(16)", SCMD_READ_G4, /* 0x88 */ - "WRITE(16)", SCMD_WRITE_G4, /* 0x8A */ - "READ_ATTRIBUTE", SCMD_READ_ATTRIBUTE, /* 0x8C */ - "WRITE_ATTRIBUTE", SCMD_WRITE_ATTRIBUTE, /* 0x8D */ - "VERIFY(16)", SCMD_VERIFY_G4, /* 0x8F */ - "LOCATE(16)", SCMD_LOCATE_G4, /* 0x92 */ - "SERVICE_ACTION_IN(16)", SCMD_SVC_ACTION_IN_G4, /* 0x9E */ - "SERVICE_ACTION_OUT(16)", SCMD_SVC_ACTION_OUT_G4, /* 0x9F */ - "REPORT_LUNS", SCMD_REPORT_LUNS, /* 0xA0 */ - "READ(12)", SCMD_READ_G5, /* 0xA8 */ - "WRITE(12)", SCMD_WRITE_G5, /* 0xAA */ - "GET_PERFORMANCE", SCMD_GET_PERFORMANCE, /* 0xAC */ - "VERIFY(12)", SCMD_VERIFY_G5, /* 0xAF */ - - NULL, -1, -}; - -static mms_sym_t mms_scsi_status_tab[] = { - "GOOD", STATUS_GOOD, - "CHECK", STATUS_CHECK, - "CONDITION MET", STATUS_MET, - "BUSY", STATUS_BUSY, - "INTERMEDIATE", STATUS_INTERMEDIATE, - "INTERMEDIATE MET", STATUS_INTERMEDIATE_MET, - "RESERVATION CONFLICT", STATUS_RESERVATION_CONFLICT, - "TERMINATED", STATUS_TERMINATED, - NULL, -1, -}; - - -static mms_sym_t mms_scsi_senkey_tab[] = { - "NO SENSE", KEY_NO_SENSE, - "RECOVERABLE ERROR", KEY_RECOVERABLE_ERROR, - "NOT READY", KEY_NOT_READY, - "MEDIUM ERROR", KEY_MEDIUM_ERROR, - "HARDWARE ERROR", KEY_HARDWARE_ERROR, - "ILLEGAL REQUEST", KEY_ILLEGAL_REQUEST, - "UNIT ATTENTION", KEY_UNIT_ATTENTION, - "WRITE PROTECT", KEY_WRITE_PROTECT, - "DATA PROTECT", KEY_DATA_PROTECT, - "BLANK CHECK", KEY_BLANK_CHECK, - "VENDOR UNIQUE", KEY_VENDOR_UNIQUE, - "COPY ABORTED", KEY_COPY_ABORTED, - "ABORTED COMMAND", KEY_ABORTED_COMMAND, - "EQUAL", KEY_EQUAL, - "VOLUME OVERFLOW", KEY_VOLUME_OVERFLOW, - "MISCOMPARE", KEY_MISCOMPARE, - "RESERVED", KEY_RESERVED, - /* - * The following are SUN keys - */ - "SUN FATAL", SUN_KEY_FATAL, - "SUN TIMEOUT", SUN_KEY_TIMEOUT, - "SUN EOF", SUN_KEY_EOF, - "SUN EOT", SUN_KEY_EOT, - "SUN LENGTH ERROR", SUN_KEY_LENGTH, - "SUN BOT", SUN_KEY_BOT, - "SUN WRONG MEDIA", SUN_KEY_WRONGMEDIA, - - NULL, -1, -}; - -static char * -mms_scsi_lookup(mms_sym_t *tab, int code) -{ - mms_sym_t *mms_sym; - static char hexcode[10]; - - for (mms_sym = tab; mms_sym->sym_token != NULL; mms_sym++) { - if (mms_sym->sym_code == code) { - return (mms_sym->sym_token); - } - } - (void) snprintf(hexcode, sizeof (hexcode), "0x%2.2x", code); - return (hexcode); -} - -char * -mms_scsi_cmd(int cmd) -{ - return (mms_scsi_lookup(mms_scsi_cmd_tab, cmd)); -} - -char * -mms_scsi_status(int stat) -{ - return (mms_scsi_lookup(mms_scsi_status_tab, stat)); -} - -char * -mms_scsi_sensekey(int senkey) -{ - return (mms_scsi_lookup(mms_scsi_senkey_tab, senkey)); -} - -char * -mms_scsi_asc(int asc) -{ - static char buf[10]; - - (void) snprintf(buf, sizeof (buf), "0x%2.2x", asc); - return (buf); -} - -char * -mms_scsi_ascq(int ascq) -{ - static char buf[10]; - - (void) snprintf(buf, sizeof (buf), "0x%2.2x", ascq); - return (buf); -} - -char * -mms_format_sense(struct scsi_extended_sense *sen) -{ - char *buf; - mms_skey_specific_t *sks; - - sks = (mms_skey_specific_t *)sen->es_skey_specific; - - buf = mms_strapp(NULL, - "valid=%x, resp code=%2.2x, seg num=%2.2x, " - "filemark=%x, eom=%x, ili=%x, sen key=%x, " - "info=%8.8x, add len=%2.2x, cmd info=%8.8x, " - "asc=%2.2x, ascq=%2.2x, fruc=%2.2x, " - "SKSV=%x, C/D=%x, BPV=%x, bit ptr=%x, field ptr=%4.4x", - - sen->es_valid, (sen->es_class << 4) | sen->es_code, - sen->es_segnum, - sen->es_filmk, sen->es_eom, sen->es_ili, sen->es_key, - (sen->es_info_1 << 24) | (sen->es_info_2 << 16) | - (sen->es_info_3 << 8) | sen->es_info_4, - sen->es_add_len, - (sen->es_cmd_info[0] << 24) | (sen->es_cmd_info[1] << 16) | - (sen->es_cmd_info[2] << 8) | sen->es_cmd_info[3], - sen->es_add_code, sen->es_qual_code, sen->es_fru_code, - sks->mms_sksv, sks->mms_cd, sks->mms_bpv, - sks->mms_bitptr, - (sks->mms_fp[0] << 8) | sks->mms_fp[1]); - - return (buf); -} diff --git a/usr/src/lib/mms/mms/common/mms_scsi.h b/usr/src/lib/mms/mms/common/mms_scsi.h deleted file mode 100644 index 9193d9f634..0000000000 --- a/usr/src/lib/mms/mms/common/mms_scsi.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 __MMS_SCSI_H -#define __MMS_SCSI_H - - -#include <sys/list.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#define MMS_MAX_CDB_LEN 32 /* max cdb length (bytes) */ -#define MMS_SENSEKEY(sen) ((sen)[2] & 0x0f) -#define MMS_ASC(sen) ((sen)[12]) -#define MMS_ASCQ(sen) ((sen)[13]) - -typedef struct mms_skey_specific { -#if defined(_BIT_FIELDS_HTOL) - uchar_t mms_sksv : 1, /* SKV */ - mms_cd : 1, /* cmd / data */ - mms_reserved : 2, - mms_bpv : 1, - mms_bitptr : 3; /* bit pointer */ -#elif defined(_BIT_FIELDS_LTOH) - uchar_t mms_bitptr : 3, /* bit pointer */ - mms_bpv : 1, - mms_reserved : 2, - mms_cd : 1, /* cmd / data */ - mms_sksv : 1; /* SKV */ -#else -#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined -#endif - uchar_t mms_fp[2]; /* field pointer */ -} mms_skey_specific_t; - -char *mms_scsi_cmd(int cmd); -char *mms_scsi_status(int stat); -char *mms_scsi_sensekey(int senkey); -char *mms_scsi_asc(int asc); -char *mms_scsi_ascq(int ascq); -char *mms_format_sense(struct scsi_extended_sense *sen); - - - -#ifdef __cplusplus -} -#endif - -#endif /* __MMS_SCSI_H */ diff --git a/usr/src/lib/mms/mms/common/mms_sock.c b/usr/src/lib/mms/mms/common/mms_sock.c deleted file mode 100644 index 8e8357b5d0..0000000000 --- a/usr/src/lib/mms/mms/common/mms_sock.c +++ /dev/null @@ -1,386 +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/socket.h> -#include <pthread.h> -#include <netdb.h> -#include <unistd.h> -#include <string.h> -#include <stdlib.h> -#include <sys/time.h> -#include <time.h> -#include <libgen.h> -#include <errno.h> -#include <fcntl.h> -#include <signal.h> -#include "mms_network.h" -#include "mms_sym.h" -#include "mms_sock.h" -#include <mms_trace.h> - -static void mms_gai_error(mms_err_t *err, int id, int n); - - -/* Protocol-independent IPv4/IPv6 client connection. */ -int -mms_connect(char *host, char *service, void *ssl_data, mms_t *conn) -{ - int sockfd; - int n; - struct addrinfo hints; - struct addrinfo *res = NULL; - struct addrinfo *ressave; - char host_str[MAXHOSTNAMELEN]; - char *host_p = host; - - (void) memset(conn, 0, sizeof (mms_t)); - conn->mms_fd = -1; - - (void) memset(&hints, 0, sizeof (struct addrinfo)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - - if (strcmp(host_p, "localhost") == 0) { - /* getaddrinfo can't handle localhost so look up hostname */ - if (gethostname(host_str, sizeof (host_str)) != 0) { - mms_sys_error(&conn->mms_err, MMS_ERR_GETHOSTNAME); - return (1); - } - host_p = host_str; - } - - if ((n = getaddrinfo(host_p, service, &hints, &res)) != 0) { - mms_gai_error(&conn->mms_err, MMS_ERR_GETADDRINFO, n); - return (1); - } - if (res == NULL) { - mms_error(&conn->mms_err, MMS_ERR_RES_NULL); - return (1); - } - ressave = res; - - do { - sockfd = socket(res->ai_family, res->ai_socktype, - res->ai_protocol); - - if (sockfd < 0) { - continue; /* ignore this one */ - } - - if (connect(sockfd, res->ai_addr, res->ai_addrlen) == 0) { - break; /* success */ - } - - (void) close(sockfd); /* ignore this one */ - } while ((res = res->ai_next) != NULL); - - freeaddrinfo(ressave); - - if (res == NULL) { - mms_error(&conn->mms_err, MMS_ERR_SERVICE_NOT_FOUND); - return (1); - } - - conn->mms_fd = sockfd; - -#ifdef MMS_OPENSSL - if (ssl_data && mms_ssl_connect(ssl_data, conn)) { - return (1); - } -#endif /* MMS_OPENSSL */ - - return (0); -} - -/* Server accepts client connection. */ -int -mms_accept(int serv_fd, void *ssl_data, mms_t *conn) -{ - int sockfd = -1; - struct sockaddr sa; - socklen_t salen; - - (void) memset(conn, 0, sizeof (mms_t)); - conn->mms_fd = -1; - - salen = sizeof (struct sockaddr); - while ((sockfd = accept(serv_fd, &sa, &salen)) < 0) { - if (errno == EINTR || errno == ECONNABORTED) { - continue; - } - mms_sys_error(&conn->mms_err, MMS_ERR_ACCEPT_FAILED); - return (1); - } - - conn->mms_fd = sockfd; - -#ifdef MMS_OPENSSL - if (ssl_data && mms_ssl_accept(ssl_data, conn)) { - return (1); - } -#endif /* MMS_OPENSSL */ - - return (0); -} - -/* Protocol-independent IPv4/IPv6 server listener. */ -int -mms_listen(char *host, char *service, int *serv_fd, mms_err_t *err) -{ - int listenfd; - int n; - const int on = 1; - struct addrinfo hints; - struct addrinfo *res = NULL; - struct addrinfo *ressave; - char host_str[MAXHOSTNAMELEN]; - char *host_p = host; - - *serv_fd = -1; - - (void) memset(&hints, 0, sizeof (struct addrinfo)); - hints.ai_flags = AI_PASSIVE; - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - - if (strcmp(host_p, "localhost") == 0) { - if (gethostname(host_str, sizeof (host_str)) != 0) { - mms_sys_error(err, MMS_ERR_GETHOSTNAME); - return (1); - } - host_p = host_str; - } - - if ((n = getaddrinfo(host_p, service, &hints, &res)) != 0) { - mms_gai_error(err, MMS_ERR_GETADDRINFO, n); - return (1); - } - if (res == NULL) { - mms_error(err, MMS_ERR_RES_NULL); - return (1); - } - ressave = res; - - do { - listenfd = socket(res->ai_family, res->ai_socktype, - res->ai_protocol); - - if (listenfd < 0) - continue; /* error, try next one */ - - if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, - sizeof (on)) < 0) { - (void) close(listenfd); - continue; - } - - if (bind(listenfd, res->ai_addr, res->ai_addrlen) == 0) { - break; /* success */ - } - - (void) close(listenfd); /* bind error, try next one */ - } while ((res = res->ai_next) != NULL); - - freeaddrinfo(ressave); - - if (listen(listenfd, MMS_BACKLOG) == -1) { - mms_sys_error(err, MMS_ERR_LISTEN); - return (1); - } - - *serv_fd = listenfd; - return (0); -} - -/* Read from socket. */ -int -mms_read(mms_t *conn, char *buf, int len) -{ - int rc; - - if (conn->mms_ssl) { -#ifdef MMS_OPENSSL - rc = mms_ssl_read(conn, buf, len); -#endif /* MMS_OPENSSL */ - } else { - rc = read(conn->mms_fd, buf, len); - } - return (rc); -} - -/* Should the read continue or be stopped? */ -int -mms_read_has_error(mms_t *conn) -{ - if (conn->mms_ssl) { -#ifdef MMS_OPENSSL - return (mms_ssl_read_has_error(conn)); -#endif /* MMS_OPENSSL */ - } else { - if (errno == EINTR) { - return (0); /* continue */ - } - mms_sys_error(&conn->mms_err, MMS_ERR_READ); - } - return (1); /* stop reading */ -} - -/* Write to the socket */ -int -mms_write(mms_t *conn, struct iovec *iov, int iovcnt) -{ - int rc; - - if (conn->mms_ssl) { -#ifdef MMS_OPENSSL - rc = mms_ssl_write(conn, iov, iovcnt); -#endif /* MMS_OPENSSL */ - } else { - rc = writev(conn->mms_fd, iov, iovcnt); - } - return (rc); -} - -/* Should the write continue or be stopped. */ -int -mms_write_has_error(mms_t *conn) -{ - if (conn->mms_ssl) { -#ifdef MMS_OPENSSL - return (mms_ssl_write_has_error(conn)); -#endif /* MMS_OPENSSL */ - } else { - if (errno == EINTR) { - return (0); /* continue */ - } - mms_sys_error(&conn->mms_err, MMS_ERR_WRITE); - } - return (1); /* stop writing */ -} - -/* Close the socket. */ -void -mms_close(mms_t *conn) -{ - mms_err_t err; - - if (conn == NULL) { - return; - } - - err = conn->mms_err; /* save any error info */ - - if (conn->mms_ssl) { -#ifdef MMS_OPENSSL - mms_ssl_close(conn); -#endif /* MMS_OPENSSL */ - } else if (conn->mms_fd >= 0) { - (void) close(conn->mms_fd); - } - - (void) memset(conn, 0, sizeof (mms_t)); - conn->mms_fd = -1; - conn->mms_err = err; -} - -void -mms_error(mms_err_t *err, int id) -{ - err->mms_id = id; - err->mms_type = 0; - err->mms_num = 0; -} - -static void -mms_gai_error(mms_err_t *err, int id, int n) -{ - err->mms_id = id; - err->mms_type = MMS_ERR_GAI; - err->mms_num = n; -} - -void -mms_sys_error(mms_err_t *err, int id) -{ - err->mms_id = id; - err->mms_type = MMS_ERR_SYS; - err->mms_num = errno; -} - -/* Get error string */ -void -mms_get_error_string(mms_err_t *err, char *ebuf, int ebuflen) -{ - int id; - - if (err == NULL || ebuf == NULL || ebuflen < 1) { - return; - } - - if ((id = err->mms_id) == 0) - id = MMS_ERR_NONE; - - /* turn error number into a string */ - switch (err->mms_type) { - case MMS_ERR_SYS: - if (err->mms_num) { - (void) snprintf(ebuf, ebuflen, "%s (%lu) %s", - mms_sym_code_to_str(id), - err->mms_num, - strerror(err->mms_num)); - } else { - (void) snprintf(ebuf, ebuflen, "%s", - mms_sym_code_to_str(id)); - } - break; - case MMS_ERR_GAI: - if (err->mms_num) { - (void) snprintf(ebuf, ebuflen, "%s (%lu) %s", - mms_sym_code_to_str(id), - err->mms_num, - gai_strerror(err->mms_num)); - } else { - (void) snprintf(ebuf, ebuflen, "%s", - mms_sym_code_to_str(id)); - } - break; -#ifdef MMS_OPENSSL - case MMS_ERR_SSL: - mms_ssl_get_error_string(err, ebuf, ebuflen); - break; -#endif /* MMS_OPENSSL */ - default: - if (err->mms_num) { - (void) snprintf(ebuf, ebuflen, "%s (%lu)", - mms_sym_code_to_str(id), - err->mms_num); - } else { - (void) snprintf(ebuf, ebuflen, "%s", - mms_sym_code_to_str(id)); - } - break; - } -} diff --git a/usr/src/lib/mms/mms/common/mms_sock.h b/usr/src/lib/mms/mms/common/mms_sock.h deleted file mode 100644 index 064069c42c..0000000000 --- a/usr/src/lib/mms/mms/common/mms_sock.h +++ /dev/null @@ -1,71 +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 _MMS_SOCK_H -#define _MMS_SOCK_H - - -#ifdef __cplusplus -extern "C" { -#endif - -int mms_listen(char *host, char *service, int *serv_fd, mms_err_t *err); -int mms_accept(int serv_fd, void *ssl_data, mms_t *cli_conn); -int mms_read(mms_t *conn, char *buf, int len); -int mms_write(mms_t *conn, struct iovec *iov, int num); -void mms_error(mms_err_t *err, int id); -int mms_read_has_error(mms_t *conn); -int mms_write_has_error(mms_t *conn); -void mms_error(mms_err_t *err, int id); -void mms_sys_error(mms_err_t *err, int id); - -#ifdef MMS_OPENSSL -int mms_ssl_server(mms_network_cfg_t *net, char *dh_file, - int verify_peer, void **ssl_data, mms_err_t *err); -char *mms_ssl_get_cipher(void *ssl_data, mms_err_t *err); -int mms_ssl_has_cert_clause(void *ssl_data, mms_t *conn); -int mms_ssl_build_cert_clause(void *ssl_data, mms_t *conn, - char *password, char **cert, char **auth); -int mms_ssl_verify_cert_clause(void *ssl_data, mms_t *conn, - char *cert, char *auth, char **password); -void mms_ssl_server_set_verify_peer(void *ssl_data, int verify_peer); -int mms_ssl_reload_crl_file(void *ssl_data, char *crl_file, - mms_err_t *err); -int mms_ssl_has_crl(void *ssl_data); -int mms_ssl_check_conn_cert(void *ssl_data, mms_t *conn); -int mms_ssl_connect(void *ssl_data, mms_t *conn); -int mms_ssl_accept(void *ssl_data, mms_t *conn); -int mms_ssl_read(mms_t *conn, char *buf, int len); -int mms_ssl_read_has_error(mms_t *conn); -int mms_ssl_write(mms_t *conn, struct iovec *iov, int iovcnt); -int mms_ssl_write_has_error(mms_t *conn); -void mms_ssl_close(mms_t *conn); -void mms_ssl_get_error_string(mms_err_t *err, char *ebuf, int ebuflen); -#endif /* MMS_OPENSSL */ - -#ifdef __cplusplus -} -#endif - -#endif /* _MMS_SOCK_H */ diff --git a/usr/src/lib/mms/mms/common/mms_ssl.c b/usr/src/lib/mms/mms/common/mms_ssl.c deleted file mode 100644 index 11e53f8cf1..0000000000 --- a/usr/src/lib/mms/mms/common/mms_ssl.c +++ /dev/null @@ -1,1894 +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. - */ - - -#ifdef MMS_OPENSSL -#define MMS_OPENSSL_THREAD_DEFINES -#include <openssl/opensslconf.h> -#include <openssl/bio.h> -#include <openssl/err.h> -#include <openssl/rand.h> -#include <openssl/ssl.h> -#include <unistd.h> -#include <pthread.h> -#include "mms_network.h" -#include "mms_sym.h" -#include "mms_sock.h" -#include <mms_trace.h> - -static char *_SrcFile = __FILE__; - -#define UNWELCOME_SSL "unwelcome \"SSAI_E_SSL\";" -#define UNWELCOME_ACCESS_SSL "unwelcome \"SSAI_E_ACCESS_DENIED\" " \ - "\"SSAI_E_SSL\";" -#define MMS_SSL_CIPHER "EDH-RSA-DES-CBC3-SHA" - -typedef struct mms_ssl_data mms_ssl_t; -struct mms_ssl_data { - char *mms_cipher; - int mms_verify; - X509 **mms_chain; - int mms_nchain; - X509 *mms_peer; - RSA *mms_key; - SSL_CTX *mms_ctx; - DH *mms_dh; - X509_CRL *mms_crl; - X509_STORE *mms_store; -}; - -typedef struct mms_ssl_conn mms_sc_t; -struct mms_ssl_conn { - SSL *mms_sc_ssl; - X509 *mms_sc_cert; -}; - -static pthread_mutex_t *mms_ssl_mutex = NULL; - -static int mms_ssl_init(mms_err_t *err); -static int mms_ssl_client_ctx(void *ssl_data, mms_err_t *err); -static int mms_ssl_server_ctx(void *ssl_data, int verify_peer, mms_err_t *err); -static int mms_ssl_set_cipher(void *ssl_data, char *cipher, mms_err_t *err); -static int mms_ssl_set_peer_file(void *ssl_data, char *peer_cert_file, - mms_err_t *err); -static int mms_ssl_data_use_files(void **ssl_data, char *cert_file, char *pass, - char *pass_file, char *dh_file, char *crl_file, mms_err_t *err); -static void mms_ssl_data_free(void *ssl_data); -static void mms_ssl_error(mms_err_t *err, int id); -static void mms_ssl_set_error(mms_err_t *err, int id, ulong_t num); -static int mms_ssl_check_cert(mms_ssl_t *data, X509 *x509_cert, - mms_err_t *err); -static int mms_ssl_use_crl_file(mms_ssl_t *data, char *crl_file, - mms_err_t *err); -static int mms_ssl_compare_cert(X509 *acert, X509 *bcert); - -int -mms_ssl_client(mms_network_cfg_t *net, void **ssl_data, mms_err_t *err) -{ - if (net->ssl_enabled) { - if (mms_ssl_init(err)) { - return (1); - } - if (mms_ssl_data_use_files(ssl_data, - net->ssl_cert_file, - net->ssl_pass, - net->ssl_pass_file, - NULL, - net->ssl_crl_file, - err)) { - mms_ssl_finish(NULL); - return (1); - } - if (mms_ssl_set_peer_file(*ssl_data, net->ssl_peer_file, err) || - mms_ssl_set_cipher(*ssl_data, net->ssl_cipher, err) || - mms_ssl_client_ctx(*ssl_data, err)) { - mms_ssl_finish(*ssl_data); - return (1); - } - } - return (0); -} - -int -mms_ssl_server(mms_network_cfg_t *net, char *dh_file, int verify_peer, - void **ssl_data, mms_err_t *err) -{ - if (net->ssl_enabled) { - if (mms_ssl_init(err)) { - return (1); - } - if (mms_ssl_data_use_files(ssl_data, - net->ssl_cert_file, - net->ssl_pass, - net->ssl_pass_file, - dh_file, - net->ssl_crl_file, - err)) { - mms_ssl_finish(NULL); - return (1); - } - if (mms_ssl_set_cipher(*ssl_data, net->ssl_cipher, err) || - mms_ssl_server_ctx(*ssl_data, verify_peer, err)) { - mms_ssl_finish(*ssl_data); - return (1); - } - } - return (0); -} - -static int -mms_ssl_set_cipher(void *ssl_data, char *cipher, mms_err_t *err) -{ - mms_ssl_t *data = (mms_ssl_t *)ssl_data; - - if (data == NULL) { - mms_trace(MMS_ERR, "no ssl"); - mms_error(err, MMS_ERR_NO_SSL); - return (1); - } - if (data->mms_cipher) { - free(data->mms_cipher); - data->mms_cipher = NULL; - } - if (cipher == NULL) { - return (0); - } - if ((data->mms_cipher = strdup(cipher)) == NULL) { - mms_sys_error(err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "cipher dup"); - return (1); - } - return (0); -} - -char * -mms_ssl_get_cipher(void *ssl_data, mms_err_t *err) -{ - mms_ssl_t *data = (mms_ssl_t *)ssl_data; - char *cipher = NULL; - - if (data == NULL) { - mms_trace(MMS_ERR, "no ssl"); - mms_error(err, MMS_ERR_NO_SSL); - } else { - if (data->mms_cipher) { - cipher = strdup(data->mms_cipher); - } else { - cipher = strdup(MMS_SSL_CIPHER); - } - if (cipher == NULL) { - mms_sys_error(err, MMS_ERR_NOMEM); - } - } - return (cipher); -} - -static void -mms_ssl_lock(int mode, int n, const char *file, int line) -{ - if (mode & CRYPTO_LOCK) { - if (pthread_mutex_lock(&mms_ssl_mutex[n]) != 0) { - mms_trace(MMS_ERR, "openssl lock %s:%d", - file, line); - } - } else { - if (pthread_mutex_unlock(&mms_ssl_mutex[n]) != 0) { - mms_trace(MMS_ERR, "openssl unlock %s:%d", - file, line); - } - } -} - -static ulong_t -mms_ssl_id(void) -{ - return ((ulong_t)pthread_self()); -} - -static int -mms_ssl_lock_setup(mms_err_t *err) -{ - int i; - -#if defined(OPENSSL_THREADS) - mms_trace(MMS_DEVP, "openssl lock setup - %d", - CRYPTO_num_locks()); - if ((mms_ssl_mutex = (pthread_mutex_t *)calloc(CRYPTO_num_locks(), - sizeof (pthread_mutex_t))) == NULL) { - mms_sys_error(err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "openssl lock setup %s", - strerror(errno)); - return (1); - } - for (i = 0; i < CRYPTO_num_locks(); i++) { - if (pthread_mutex_init(&mms_ssl_mutex[i], NULL)) { - mms_sys_error(err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "openssl lock setup mutex init"); - for (i -= 1; i >= 0; i--) { - (void) pthread_mutex_destroy(&mms_ssl_mutex[i]); - } - free(mms_ssl_mutex); - mms_ssl_mutex = NULL; - return (1); - } - } - CRYPTO_set_id_callback(mms_ssl_id); - CRYPTO_set_locking_callback(mms_ssl_lock); -#endif - return (0); -} - -static void -mms_ssl_lock_cleanup(void) -{ - int i; - -#if defined(OPENSSL_THREADS) - if (mms_ssl_mutex) { - mms_trace(MMS_DEVP, "openssl lock cleanup - %d", - CRYPTO_num_locks()); - CRYPTO_set_id_callback(NULL); - CRYPTO_set_locking_callback(NULL); - for (i = 0; i < CRYPTO_num_locks(); i++) { - (void) pthread_mutex_destroy(&mms_ssl_mutex[i]); - } - free(mms_ssl_mutex); - mms_ssl_mutex = NULL; - } -#endif -} - -int -mms_ssl_init(mms_err_t *err) -{ - /* openssl needs locks for multithreaded applications */ - if (mms_ssl_lock_setup(err)) { - return (1); - } - (void) SSL_library_init(); - OpenSSL_add_all_algorithms(); - SSL_load_error_strings(); - OpenSSL_add_all_ciphers(); - OpenSSL_add_all_digests(); - (void) RAND_load_file("/dev/random", 1024); - return (0); -} - -void -mms_ssl_finish(void *ssl_data) -{ - if (ssl_data) { - mms_ssl_data_free(ssl_data); - } - mms_ssl_lock_cleanup(); -} - -int -mms_ssl_connect(void *ssl_data, mms_t *conn) -{ - mms_ssl_t *data = (mms_ssl_t *)ssl_data; - mms_sc_t *sc; - int rc; - - /* - * Client connects to SSL server. - */ - conn->mms_ssl = (void *)calloc(1, sizeof (mms_sc_t)); - if (conn->mms_ssl == NULL) { - mms_sys_error(&conn->mms_err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "connect ssl alloc"); - goto error; - } - sc = (mms_sc_t *)conn->mms_ssl; - if (data->mms_ctx == NULL) { - mms_error(&conn->mms_err, MMS_ERR_SSL_CTX); - mms_trace(MMS_ERR, "no ssl context"); - goto error; - } - if ((sc->mms_sc_ssl = SSL_new(data->mms_ctx)) == NULL) { - mms_error(&conn->mms_err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "ssl new"); - goto error; - } - if (SSL_set_fd(sc->mms_sc_ssl, conn->mms_fd) != 1) { - mms_error(&conn->mms_err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "ssl set fd"); - goto error; - } - if ((rc = SSL_connect(sc->mms_sc_ssl)) != 1) { - mms_ssl_set_error(&conn->mms_err, - MMS_ERR_SSL_CONNECT, - SSL_get_error(sc->mms_sc_ssl, rc)); - mms_trace(MMS_ERR, "ssl connect"); - goto error; - } - sc->mms_sc_cert = SSL_get_peer_certificate(sc->mms_sc_ssl); - if (sc->mms_sc_cert == NULL) { - mms_error(&conn->mms_err, MMS_ERR_SSL_VERIFY); - mms_trace(MMS_ERR, - "unauthenticated ssl connection, " - "no server certificate"); - goto error; - } - if (mms_ssl_check_cert(data, sc->mms_sc_cert, &conn->mms_err)) { - mms_error(&conn->mms_err, MMS_ERR_SSL_VERIFY); - mms_trace(MMS_ERR, "invalid server certificate"); - goto error; - } - /* verify connection cert matches expected peer cert */ - if (data->mms_peer && - mms_ssl_compare_cert(data->mms_peer, sc->mms_sc_cert)) { - mms_error(&conn->mms_err, MMS_ERR_SSL_VERIFY); - goto error; - } - mms_trace(MMS_DEBUG, "client ssl connection"); - return (0); - -error: - mms_ssl_close(conn); - return (1); -} - -int -mms_ssl_accept(void *ssl_data, mms_t *conn) -{ - mms_ssl_t *data = (mms_ssl_t *)ssl_data; - mms_sc_t *sc; - int rc; - mms_t myconn; - - /* - * Server accepts client SSL connection. - */ - conn->mms_ssl = (void *)calloc(1, sizeof (mms_sc_t)); - if (conn->mms_ssl == NULL) { - mms_sys_error(&conn->mms_err, MMS_ERR_NOMEM); - goto error; - } - sc = (mms_sc_t *)conn->mms_ssl; - if (data->mms_ctx == NULL) { - mms_error(&conn->mms_err, MMS_ERR_SSL_CTX); - mms_trace(MMS_ERR, "server no ssl context"); - goto error; - } - if ((sc->mms_sc_ssl = SSL_new(data->mms_ctx)) == NULL) { - mms_error(&conn->mms_err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "server ssl new"); - goto error; - } - if (SSL_set_fd(sc->mms_sc_ssl, conn->mms_fd) != 1) { - mms_error(&conn->mms_err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "server ssl set fd"); - goto error; - } - SSL_set_accept_state(sc->mms_sc_ssl); - if ((rc = SSL_accept(sc->mms_sc_ssl)) != 1) { - mms_ssl_set_error(&conn->mms_err, - MMS_ERR_ACCEPT_FAILED, - SSL_get_error(sc->mms_sc_ssl, rc)); - mms_trace(MMS_ERR, "server ssl accept"); - goto error_no_ssl; - } - sc->mms_sc_cert = SSL_get_peer_certificate(sc->mms_sc_ssl); - if (sc->mms_sc_cert == NULL) { - if (data->mms_verify) { - mms_error(&conn->mms_err, MMS_ERR_SSL_VERIFY); - mms_trace(MMS_ERR, "client certificate is required"); - goto error_ssl; - } - mms_trace(MMS_DEVP, - "unauthenticated ssl connection, " - "no client certificate"); - } else if (mms_ssl_check_cert(data, sc->mms_sc_cert, - &conn->mms_err)) { - mms_trace(MMS_ERR, "invalid client certificate"); - goto error_ssl; - } - mms_trace(MMS_DEBUG, "server accepted ssl connection"); - return (0); - -error_no_ssl: - /* - * Assume problem is non-ssl client. - * Attempt to send unwelcome ssl to client. - */ - mms_trace(MMS_DEVP, "send fd %d -> %s", conn->mms_fd, UNWELCOME_SSL); - (void) memset(&myconn, 0, sizeof (mms_t)); - myconn.mms_fd = conn->mms_fd; - (void) mms_writer(&myconn, UNWELCOME_SSL); - mms_ssl_close(conn); - return (1); - -error_ssl: - /* - * Problem is client ssl validation. - * Attempt to send unwelcome access deined ssl to client. - */ - mms_trace(MMS_DEVP, "send fd %d -> %s", conn->mms_fd, - UNWELCOME_ACCESS_SSL); - (void) mms_writer(conn, UNWELCOME_ACCESS_SSL); - mms_ssl_close(conn); - return (1); - -error: - /* - * Don't know if connection is ssl or non-ssl. - */ - mms_trace(MMS_DEVP, "close fd %d", conn->mms_fd); - mms_ssl_close(conn); - return (1); -} - -int -mms_ssl_read(mms_t *conn, char *buf, int len) -{ - mms_sc_t *sc = (mms_sc_t *)conn->mms_ssl; - int rc; - int n; - - /* data is decrypted by ssl read */ - - (void) memset(&conn->mms_err, 0, sizeof (mms_err_t)); - for (n = 0; n < len; n += rc) { - rc = SSL_read(sc->mms_sc_ssl, buf + n, len - n); - if (rc <= 0) { - mms_ssl_set_error(&conn->mms_err, - MMS_ERR_READ, - SSL_get_error(sc->mms_sc_ssl, rc)); - mms_trace(MMS_ERR, "ssl read"); - return (-1); - } - } - return (n); -} - -int -mms_ssl_read_has_error(mms_t *conn) -{ - if (conn->mms_err.mms_id == 0) { - return (0); /* continue reading */ - } - return (1); /* stop reading */ -} - -int -mms_ssl_write(mms_t *conn, struct iovec *iov, int iovcnt) -{ - mms_sc_t *sc = (mms_sc_t *)conn->mms_ssl; - int rc; - int i; - int n; - int total = 0; - - /* data is encrypted by ssl write */ - - (void) memset(&conn->mms_err, 0, sizeof (mms_err_t)); - for (i = 0; i < iovcnt; i++) { - for (n = 0; n < iov[i].iov_len; n += rc) { - rc = SSL_write(sc->mms_sc_ssl, - iov[i].iov_base + n, - iov[i].iov_len - n); - if (rc <= 0) { - mms_ssl_set_error(&conn->mms_err, - MMS_ERR_WRITE, - SSL_get_error(sc->mms_sc_ssl, rc)); - mms_trace(MMS_ERR, "ssl write"); - return (-1); - } - } - total += n; - } - return (total); -} - -int -mms_ssl_write_has_error(mms_t *conn) -{ - if (conn->mms_err.mms_id == 0) { - return (0); /* continue writing */ - } - return (1); /* stop writing */ -} - -void -mms_ssl_close(mms_t *conn) -{ - mms_sc_t *sc = (mms_sc_t *)conn->mms_ssl; - - /* - * Close SSL connection. - */ - if (sc == NULL) { - return; - } - - if (sc->mms_sc_ssl) { - if (SSL_get_shutdown(sc->mms_sc_ssl) & SSL_RECEIVED_SHUTDOWN) { - (void) SSL_shutdown(sc->mms_sc_ssl); - } else { - (void) SSL_clear(sc->mms_sc_ssl); - } - SSL_free(sc->mms_sc_ssl); - (void) close(conn->mms_fd); - conn->mms_fd = -1; - } - - if (sc->mms_sc_cert) { - X509_free(sc->mms_sc_cert); - } - - free(sc); - conn->mms_ssl = NULL; -} - -static void -mms_ssl_error(mms_err_t *err, int id) -{ - err->mms_type = MMS_ERR_SSL; - err->mms_id = id; - err->mms_num = ERR_get_error(); -} - -static void -mms_ssl_set_error(mms_err_t *err, int id, ulong_t num) -{ - err->mms_type = MMS_ERR_SSL; - err->mms_id = id; - err->mms_num = num; -} - -/* Get error string */ -void -mms_ssl_get_error_string(mms_err_t *err, char *ebuf, int ebuflen) -{ - int id; - char buf[MMS_EBUF_LEN]; - - if (err != NULL && ebuf != NULL && ebuflen > 0) { - - if ((id = err->mms_id) == 0) - id = MMS_ERR_NONE; - - if (err->mms_num == 0) { - /* no ssl error */ - (void) snprintf(ebuf, ebuflen, "%s", - mms_sym_code_to_str(id)); - } else { - /* ssl error string */ - ERR_error_string_n(err->mms_num, buf, sizeof (buf)); - (void) snprintf(ebuf, ebuflen, "%s (%lu) %s", - mms_sym_code_to_str(id), - err->mms_num, - buf); - } - } -} - -/* ARGSUSED0 */ -static int -mms_ssl_pass_file_cb(char *buf, int size, int rwflag, void *u) -{ - FILE *fp; - char *file = (char *)u; - char *ptr; - - /* - * Read private key password pharse from file. - */ - if (file == NULL) { - mms_trace(MMS_ERR, "null pass file"); - return (0); - } - if ((fp = fopen(file, "r")) == NULL) { - mms_trace(MMS_ERR, "pass file open %s %s", - file, strerror(errno)); - return (0); - } - ptr = fgets(buf, size, fp); - (void) fclose(fp); - if (ptr == NULL || ptr != buf) { - mms_trace(MMS_WARN, "pass file empty %s", file); - return (0); - } - if (ptr = strrchr(buf, '\n')) { - *ptr = '\0'; - } - return (strlen(buf)); -} - -static int -mms_ssl_store_cb(int ok, X509_STORE_CTX *store) -{ - X509 *cert; - int depth; - int err; - char issuer[256]; - char subject[256]; - - if (!ok) { - cert = X509_STORE_CTX_get_current_cert(store); - depth = X509_STORE_CTX_get_error_depth(store); - err = X509_STORE_CTX_get_error(store); - - (void) X509_NAME_oneline(X509_get_issuer_name(cert), - issuer, sizeof (issuer)); - (void) X509_NAME_oneline(X509_get_subject_name(cert), - subject, sizeof (subject)); - - mms_trace(MMS_ERR, - "Certificate Store Error:\n" - "\tdepth %d\n" - "\tissuer %s\n" - "\tsubject %s\n" - "\terror %s\n", - depth, - issuer, - subject, - X509_verify_cert_error_string(err)); - } - return (ok); -} - -static int -mms_ssl_check_cert(mms_ssl_t *data, X509 *cert, mms_err_t *err) -{ - X509_STORE_CTX *store_ctx; - int rc; - - /* - * Verify certificate. - */ - if (data->mms_store == NULL || - cert == NULL) { - return (0); - } - if ((store_ctx = X509_STORE_CTX_new()) == NULL) { - mms_ssl_error(err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "x509 store new"); - return (1); - } - -#if (OPENSSL_VERSION_NUMBER > 0x00907000L) - if (X509_STORE_CTX_init(store_ctx, data->mms_store, - cert, NULL) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_STORE); - X509_STORE_CTX_free(store_ctx); - mms_trace(MMS_ERR, "x509 store init"); - return (1); - } -#else - X509_STORE_CTX_init(store_ctx, data->mms_store, cert, NULL); -#endif - - if (!(rc = X509_verify_cert(store_ctx))) { - mms_ssl_error(err, MMS_ERR_SSL_VERIFY); - mms_trace(MMS_WARN, "x509 invalid cert"); - } - X509_STORE_CTX_cleanup(store_ctx); - X509_STORE_CTX_free(store_ctx); - - return (!rc); -} - -int -mms_ssl_reload_crl_file(void *ssl_data, char *crl_file, mms_err_t *err) -{ - mms_ssl_t *data = (mms_ssl_t *)ssl_data; - int rc; - - if (data == NULL) { - return (0); - } - - /* - * Release previous CRL. - */ - if (data->mms_crl) { - X509_CRL_free(data->mms_crl); - data->mms_crl = NULL; - } - if (data->mms_store) { - X509_STORE_free(data->mms_store); - data->mms_store = NULL; - } - - /* - * Get updated CRL. - */ - if (rc = mms_ssl_use_crl_file(data, crl_file, err)) { - if (crl_file) { - mms_trace(MMS_ERR, "reload crl file %s", crl_file); - } else { - mms_trace(MMS_ERR, "reload crl file"); - } - } - return (rc); -} - -int -mms_ssl_has_crl(void *ssl_data) -{ - mms_ssl_t *data = (mms_ssl_t *)ssl_data; - - if (data == NULL || data->mms_store == NULL) { - return (0); /* no crl */ - } - return (1); /* has valid crl */ -} - -int -mms_ssl_check_conn_cert(void *ssl_data, mms_t *conn) -{ - mms_ssl_t *data = (mms_ssl_t *)ssl_data; - mms_sc_t *sc = (mms_sc_t *)conn->mms_ssl; - int rc; - - /* - * Check conn certs against updated CRL. - */ - if (data == NULL || data->mms_store == NULL || - sc == NULL || sc->mms_sc_cert == NULL) { - return (0); - } - if (rc = mms_ssl_check_cert(data, sc->mms_sc_cert, &conn->mms_err)) { - mms_trace(MMS_DEVP, "check conn cert"); - } - return (rc); -} - -static int -mms_ssl_use_crl_file(mms_ssl_t *data, char *crl_file, mms_err_t *err) -{ - FILE *fp; - int i; - - if (crl_file && data->mms_nchain) { - mms_trace(MMS_DEBUG, "handle crl file %s", crl_file); - if ((fp = fopen(crl_file, "r")) == NULL) { - mms_sys_error(err, MMS_ERR_SSL_FILE); - mms_trace(MMS_ERR, "open crl %s %s", - crl_file, strerror(errno)); - return (1); - } - data->mms_crl = PEM_read_X509_CRL(fp, NULL, NULL, NULL); - (void) fclose(fp); - if (data->mms_crl == NULL) { - mms_ssl_error(err, MMS_ERR_SSL_FILE); - mms_trace(MMS_ERR, "read crl %s", crl_file); - return (1); - } - - if ((data->mms_store = X509_STORE_new()) == NULL) { - mms_ssl_error(err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "new crl store"); - return (1); - } - X509_STORE_set_verify_cb_func(data->mms_store, - mms_ssl_store_cb); - if (X509_STORE_add_cert(data->mms_store, - data->mms_chain[data->mms_nchain-1]) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_CERT); - mms_trace(MMS_ERR, "add cacert %s %d", - crl_file, data->mms_nchain-1); - return (1); - } - if (X509_STORE_add_crl(data->mms_store, data->mms_crl) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_FILE); - mms_trace(MMS_ERR, "add crl %s", crl_file); - return (1); - } -#if (OPENSSL_VERSION_NUMBER > 0x00907000L) - (void) X509_STORE_set_flags(data->mms_store, - X509_V_FLAG_CRL_CHECK|X509_V_FLAG_CRL_CHECK_ALL); -#endif - - for (i = 0; i < data->mms_nchain; i++) { - if (mms_ssl_check_cert(data, - data->mms_chain[i], err)) { - mms_trace(MMS_ERR, "check cert %s at %d", - crl_file, i); - return (1); - } - } - } - return (0); -} - -/* - * Source SSL data from files. - * - * To source SSL data not from files, write a function to load the - * ssl data from your SSL source. The other ssl calls remain the same. - * - * Two-way authentication, server and client both have the following - * PEM-encoded certificate file structure: - * 1. RSA certificate - * 2. Private key - * 3. CA RSA Certificate Chain - * - * One-way authentication, the server has a RSA certificate, private key, - * and CA RSA certificate chain. The client only has the server's - * CA RSA certificate chain in the following PEM-encoded certificate - * file structure: - * 1. Optional for client - * 2. Certificate Chain - * - * The RSA certificate private key password pharse: - * 1. Optional - * 2. password argument - * 3. password file argument - * - * The CRL file is optional. - */ -static int -mms_ssl_data_use_files(void **ssl_data, - char *cert_file, - char *pass, - char *pass_file, - char *dh_file, - char *crl_file, - mms_err_t *err) -{ - mms_ssl_t *data; - FILE *fp = NULL; - X509 *cert = NULL; - X509 **chain; - long off; - ulong_t rc; - - /* - * Load PEM-encoded files into SSL structures. - */ - if ((data = (mms_ssl_t *)calloc(1, sizeof (mms_ssl_t))) == NULL) { - mms_sys_error(err, MMS_ERR_NOMEM); - return (NULL); - } - - /* - * User Certificate or CA Certificate - */ - if (cert_file == NULL) { - /* - * User wants unauthenticated connection. - */ - *ssl_data = data; - mms_trace(MMS_DEVP, "no cert file"); - return (0); - } - mms_trace(MMS_DEVP, "handle cert file %s", cert_file); - if ((fp = fopen(cert_file, "r")) == NULL) { - mms_sys_error(err, MMS_ERR_SSL_FILE); - mms_trace(MMS_ERR, "cert file open %s %s", - cert_file, strerror(errno)); - goto error; - } - if ((cert = PEM_read_X509(fp, NULL, NULL, NULL)) == NULL) { - mms_ssl_error(err, MMS_ERR_SSL_FILE); - mms_trace(MMS_ERR, "read 1st cert %s", cert_file); - goto error; - } - if ((data->mms_chain = (X509 **)malloc(sizeof (X509 *))) == NULL) { - mms_sys_error(err, MMS_ERR_NOMEM); - goto error; - } - data->mms_chain[data->mms_nchain++] = cert; - cert = NULL; - mms_trace(MMS_DEVP, "read cert"); - - /* - * Private Key Password Pharse - */ - if ((off = ftell(fp)) == -1) { - mms_sys_error(err, MMS_ERR_SSL_FILE); - mms_trace(MMS_ERR, "cert file tell %s %s", - cert_file, strerror(errno)); - goto error; - } - if (pass) { - mms_trace(MMS_DEVP, "password"); - data->mms_key = PEM_read_RSAPrivateKey(fp, NULL, NULL, pass); - } else if (pass_file) { - mms_trace(MMS_DEVP, "password file %s", pass_file); - data->mms_key = PEM_read_RSAPrivateKey(fp, NULL, - mms_ssl_pass_file_cb, pass_file); - } else { - mms_trace(MMS_DEVP, "no password"); - data->mms_key = PEM_read_RSAPrivateKey(fp, NULL, - mms_ssl_pass_file_cb, NULL); - } - if (data->mms_key == NULL) { - if (rc = ERR_get_error()) { - switch (ERR_GET_REASON(rc)) { - case PEM_R_NO_START_LINE: - mms_trace(MMS_DEVP, "no private key"); - break; - default: - mms_ssl_set_error(err, MMS_ERR_SSL_FILE, rc); - mms_trace(MMS_ERR, - "read private key %s %d %d", - cert_file, rc, ERR_GET_REASON(rc)); - goto error; - } - } - /* one-way authentication */ - if (fseek(fp, off, SEEK_SET) == -1) { - mms_sys_error(err, MMS_ERR_SSL_FILE); - mms_trace(MMS_ERR, "cert file seek %s %s", - cert_file, strerror(errno)); - goto error; - } - } else { - mms_trace(MMS_DEBUG, "read private key"); - } - - /* - * Certificate Chain Hierarchy - */ - while (cert = PEM_read_X509(fp, NULL, NULL, NULL)) { - if ((chain = (X509 **)realloc(data->mms_chain, - sizeof (X509 *) * (data->mms_nchain + 1))) == NULL) { - mms_sys_error(err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "pem alloc"); - goto error; - } - data->mms_chain = chain; - data->mms_chain[data->mms_nchain++] = cert; - cert = NULL; - mms_trace(MMS_DEVP, "added to cert chain, count %d", - data->mms_nchain); - } - if (rc = ERR_get_error()) { - switch (ERR_GET_REASON(rc)) { - case PEM_R_NO_START_LINE: - break; - default: - mms_ssl_set_error(err, MMS_ERR_SSL_FILE, rc); - mms_trace(MMS_ERR, - "read cert chain %s %d %d\n", - cert_file, rc, ERR_GET_REASON(rc)); - goto error; - } - } - (void) fclose(fp); - fp = NULL; - - /* - * Optional Certificate Revocation List - */ - if (mms_ssl_use_crl_file(data, crl_file, err)) { - mms_trace(MMS_DEVP, "crl file failed"); - goto error; - } - - /* - * Diffie-Hellman required for server, client does not use. - */ - if (dh_file) { - int code; - - mms_trace(MMS_DEBUG, "handle server dh file %s", dh_file); - if ((fp = fopen(dh_file, "r")) == NULL) { - mms_sys_error(err, MMS_ERR_SSL_FILE); - mms_trace(MMS_ERR, "open dh %s %s", - dh_file, strerror(errno)); - goto error; - } - data->mms_dh = PEM_read_DHparams(fp, NULL, NULL, NULL); - if (data->mms_dh == NULL) { - mms_ssl_error(err, MMS_ERR_SSL_FILE); - mms_trace(MMS_ERR, "read dh %s", dh_file); - goto error; - } - (void) fclose(fp); - fp = NULL; - if (DH_check(data->mms_dh, &code) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_WARN, "%s dh parameters are bad 0x%x", - dh_file, code); - goto error; - } - } - - *ssl_data = data; - return (0); - -error: - if (cert) - X509_free(cert); - mms_ssl_data_free(data); - (void) fclose(fp); - return (1); -} - -static int -mms_ssl_set_peer_file(void *ssl_data, char *peer_cert_file, mms_err_t *err) -{ - mms_ssl_t *data = (mms_ssl_t *)ssl_data; - FILE *fp; - - /* - * Optional, clients only, load the mm peer certificate. - * This certificate is compared to the ssl connection peer - * certificate obtained from the ssl connection and will - * prevent the client from sending the password to a mm - * imposter. - */ - if (ssl_data == NULL) { - mms_trace(MMS_ERR, "no ssl data"); - mms_error(err, MMS_ERR_NO_SSL); - return (0); - } - if (data->mms_peer) { - X509_free(data->mms_peer); - data->mms_peer = NULL; - } - if (peer_cert_file == NULL) { - return (0); - } - if ((fp = fopen(peer_cert_file, "r")) == NULL) { - mms_sys_error(err, MMS_ERR_SSL_CERT); - mms_trace(MMS_ERR, "unable to open %s", peer_cert_file); - return (1); - } - data->mms_peer = PEM_read_X509(fp, NULL, NULL, NULL); - (void) fclose(fp); - if (data->mms_peer == NULL) { - mms_ssl_error(err, MMS_ERR_SSL_CERT); - mms_trace(MMS_ERR, "read %s", peer_cert_file); - return (1); - } - if (mms_ssl_check_cert(data, data->mms_peer, err)) { - X509_free(data->mms_peer); - data->mms_peer = NULL; - return (1); - } - return (0); -} - -static void -mms_ssl_data_free(void *ssl_data) -{ - mms_ssl_t *data = (mms_ssl_t *)ssl_data; - int i; - - /* - * Free SSL connection context data. - */ - if (data) { - if (data->mms_chain) { - for (i = 0; i < data->mms_nchain; i++) { - X509_free(data->mms_chain[i]); - } - free(data->mms_chain); - } - if (data->mms_peer) - X509_free(data->mms_peer); - if (data->mms_key) - RSA_free(data->mms_key); - if (data->mms_ctx) - SSL_CTX_free(data->mms_ctx); - if (data->mms_dh) - DH_free(data->mms_dh); - if (data->mms_store) - X509_STORE_free(data->mms_store); - free(data); - } -} - -static int -mms_ssl_verify_cb(int ok, X509_STORE_CTX *store) -{ - X509 *cert; - int depth; - int err; - char issuer[256]; - char subject[256]; - - if (!ok) { - cert = X509_STORE_CTX_get_current_cert(store); - depth = X509_STORE_CTX_get_error_depth(store); - err = X509_STORE_CTX_get_error(store); - - (void) X509_NAME_oneline(X509_get_issuer_name(cert), - issuer, sizeof (issuer)); - (void) X509_NAME_oneline(X509_get_subject_name(cert), - subject, sizeof (subject)); - - if (err == X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN) { - mms_trace(MMS_DEVP, "self signed cert in chain"); - ok = 1; - } else { - mms_trace(MMS_ERR, - "Certificate Verify Error:\n" - "\tdepth %d\n" - "\tissuer %s\n" - "\tsubject %s\n" - "\terror %s\n", - depth, - issuer, - subject, - X509_verify_cert_error_string(err)); - } - } - return (ok); -} - -void -mms_ssl_server_set_verify_peer(void *ssl_data, int verify_peer) -{ - mms_ssl_t *data = (mms_ssl_t *)ssl_data; - - if (data) { - data->mms_verify = verify_peer; - } -} - -static int -mms_ssl_server_ctx(void *ssl_data, int verify_peer, mms_err_t *err) -{ - mms_ssl_t *data = (mms_ssl_t *)ssl_data; - char *cipher_name = MMS_SSL_CIPHER; - int i; - - /* - * Create server SSL connection context. - */ - if (data->mms_nchain < 2 || - data->mms_key == NULL || - data->mms_dh == NULL) { - mms_trace(MMS_ERR, "server context requires chain, key and dh"); - return (1); - } - if ((data->mms_ctx = SSL_CTX_new(SSLv23_server_method())) == NULL) { - mms_ssl_error(err, MMS_ERR_NOMEM); - return (1); - } - if (SSL_CTX_use_certificate(data->mms_ctx, - data->mms_chain[0]) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_CERT); - mms_trace(MMS_ERR, "server context 1st cert"); - return (1); - } - for (i = 1; i < data->mms_nchain; i++) { - if (SSL_CTX_add_extra_chain_cert(data->mms_ctx, - data->mms_chain[i]) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_CERT); - mms_trace(MMS_ERR, "server context cert %d", i); - return (1); - } - } - if (SSL_CTX_use_RSAPrivateKey(data->mms_ctx, - data->mms_key) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_KEY); - mms_trace(MMS_ERR, "server private key"); - return (1); - } - SSL_CTX_set_verify_depth(data->mms_ctx, data->mms_nchain); - data->mms_verify = verify_peer; - if (data->mms_verify == 0) { - mms_trace(MMS_DEVP, "client certificate not required"); - } else { - mms_trace(MMS_DEVP, "client certificate required"); - } - SSL_CTX_set_verify(data->mms_ctx, SSL_VERIFY_PEER, - mms_ssl_verify_cb); - if (SSL_CTX_set_tmp_dh(data->mms_ctx, data->mms_dh) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_DH); - mms_trace(MMS_ERR, "server context dh"); - return (1); - } - (void) SSL_CTX_set_options(data->mms_ctx, - SSL_OP_ALL|SSL_OP_NO_SSLv2| - SSL_MODE_AUTO_RETRY|SSL_OP_SINGLE_DH_USE); - if (data->mms_cipher) - cipher_name = data->mms_cipher; - if (SSL_CTX_set_cipher_list(data->mms_ctx, cipher_name) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_CIPHER); - mms_trace(MMS_ERR, "server context cipher %s", cipher_name); - return (1); - } - return (0); -} - -static int -mms_ssl_client_ctx(void *ssl_data, mms_err_t *err) -{ - mms_ssl_t *data = (mms_ssl_t *)ssl_data; - char *cipher_name = MMS_SSL_CIPHER; - int i; - - /* - * Create client SSL connection context. - */ - if ((data->mms_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL) { - mms_ssl_error(err, MMS_ERR_NOMEM); - return (1); - } - if (data->mms_nchain) { - if (SSL_CTX_use_certificate(data->mms_ctx, - data->mms_chain[0]) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_CERT); - mms_trace(MMS_ERR, "client context 1st cert"); - return (1); - } - } - for (i = 1; i < data->mms_nchain; i++) { - if (SSL_CTX_add_extra_chain_cert(data->mms_ctx, - data->mms_chain[i]) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_CERT); - mms_trace(MMS_ERR, "client context cert %d", i); - return (1); - } - } - if (data->mms_key) { - if (SSL_CTX_use_RSAPrivateKey(data->mms_ctx, - data->mms_key) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_KEY); - mms_trace(MMS_ERR, "client context private key"); - return (1); - } - } - if (data->mms_nchain) { - SSL_CTX_set_verify_depth(data->mms_ctx, data->mms_nchain); - SSL_CTX_set_verify(data->mms_ctx, SSL_VERIFY_PEER, - mms_ssl_verify_cb); - } - (void) SSL_CTX_set_options(data->mms_ctx, - SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_MODE_AUTO_RETRY); - if (data->mms_cipher) - cipher_name = data->mms_cipher; - if (SSL_CTX_set_cipher_list(data->mms_ctx, cipher_name) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_CIPHER); - mms_trace(MMS_ERR, "client context cipher %s", cipher_name); - return (1); - } - return (0); -} - -static char * -mms_ssl_x509_to_pem(X509 *cert, mms_err_t *err) -{ - BIO *bio = NULL; - char *buf = NULL; - int len; - int i; - int n; - - /* - * Convert x509 certificate structure to text certficate. - */ - if (cert == NULL) { - mms_error(err, MMS_ERR_SSL_NOCERT); - mms_trace(MMS_ERR, "x509 to pem null cert"); - goto error; - } - if ((bio = BIO_new(BIO_s_mem())) == NULL) { - mms_ssl_error(err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "x509 to pem s mem"); - goto error; - } - if (PEM_write_bio_X509(bio, cert) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "x509 to pem write"); - goto error; - } - len = 4096; - if ((buf = malloc(len)) == NULL) { - mms_sys_error(err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "x509 to pem buf"); - goto error; - } - if ((n = BIO_read(bio, buf, len)) <= 0) { - mms_ssl_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "x509 to pem read"); - goto error; - } - buf[n] = '\0'; - /* remove trailing newlines */ - for (i = strlen(buf) - 1; i >= 0; i--) { - if (buf[i] == '-') - break; - buf[i] = '\0'; - } - (void) BIO_free(bio); - return (buf); - -error: - if (bio) - (void) BIO_free(bio); - if (buf) - free(buf); - return (NULL); -} - -static X509 * -mms_ssl_pem_to_x509(char *cert, mms_err_t *err) -{ - BIO *bio = NULL; - X509 *cert_x509; - int len; - int n; - - /* - * Convert text certificate to x509 certificate structure. - */ - if (cert == NULL) { - mms_error(err, MMS_ERR_SSL_NOCERT); - mms_trace(MMS_ERR, "pem to x509 null cert"); - goto error; - } - if ((bio = BIO_new(BIO_s_mem())) == NULL) { - mms_ssl_error(err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "pem to x509 s mem"); - goto error; - } - len = strlen(cert); - n = BIO_write(bio, cert, len); - if (n <= 0 || n != len) { - mms_ssl_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "pem to x509 write"); - goto error; - } - if ((cert_x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL)) == NULL) { - mms_ssl_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "pem to x509 read"); - goto error; - } - (void) BIO_free(bio); - return (cert_x509); - -error: - if (bio) - (void) BIO_free(bio); - return (NULL); -} - -static int -mms_ssl_compare_cert(X509 *acert, X509 *bcert) -{ - char *atext = NULL; - char *btext = NULL; - mms_err_t err; - int rc = 1; - - if ((atext = mms_ssl_x509_to_pem(acert, &err)) == NULL) - goto out; - if ((btext = mms_ssl_x509_to_pem(bcert, &err)) == NULL) - goto out; - if (strlen(atext) != strlen(btext)) - goto out; - if (rc = memcmp(atext, btext, strlen(atext))) { - mms_trace(MMS_DEVP, "cert compare failed"); - } -out: - free(atext); - free(btext); - return (rc); -} - -static char * -mms_ssl_encode(uchar_t *buf, int len, mms_err_t *err) -{ - uchar_t *out = NULL; - int outl; - EVP_ENCODE_CTX encode_ctx; - int tmplen; - - /* base64 encode */ - - if (buf) { - outl = ((len + 2 / 3) * 4) + 1; - if ((out = (uchar_t *)malloc(outl)) == NULL) { - mms_sys_error(err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "encode"); - } else { - EVP_EncodeInit(&encode_ctx); - EVP_EncodeUpdate(&encode_ctx, out, &outl, buf, len); - EVP_EncodeFinal(&encode_ctx, out + outl, &tmplen); - outl += tmplen; - out[outl - 1] = 0; - } - } - return ((char *)out); -} - -static uchar_t * -mms_ssl_decode(char *buf, int *len, mms_err_t *err) -{ - uchar_t *out = NULL; - int outl; - EVP_ENCODE_CTX encode_ctx; - int tmplen; - - /* base64 decode */ - - if (buf) { - outl = (((strlen(buf) + 3) / 4) * 3); - if ((out = (uchar_t *)malloc(outl)) == NULL) { - mms_sys_error(err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "decode"); - } else { - EVP_DecodeInit(&encode_ctx); - if (EVP_DecodeUpdate(&encode_ctx, out, len, - (uchar_t *)buf, strlen(buf)) == -1) { - mms_sys_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "decode update"); - goto failed; - } - if (EVP_DecodeFinal(&encode_ctx, out + *len, - &tmplen) == -1) { - mms_sys_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "decode final"); - goto failed; - } - *len += tmplen; - } - } - return (out); - -failed: - free(out); - return (NULL); -} - -static int -mms_ssl_encrypt(EVP_PKEY *pubkey, char *passwd, char *data[], mms_err_t *err) -{ - EVP_CIPHER_CTX cipher_ctx; - EVP_PKEY *pub_key[1] = {pubkey}; - uchar_t *ek[1] = {NULL}; - int eklen; - uchar_t *iv = NULL; - int ivlen; - uchar_t *encbuf = NULL; - int enclen; - int tmplen; - int i; - int rc = 1; - - /* public key encrypt */ - - EVP_CIPHER_CTX_init(&cipher_ctx); - - eklen = EVP_PKEY_size(pubkey); - if ((ek[0] = (uchar_t *)malloc(eklen)) == NULL) { - mms_sys_error(err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "encrypt init"); - goto out; - } - ivlen = EVP_CIPHER_iv_length(EVP_des_cbc()); - if ((iv = (uchar_t *)malloc(ivlen)) == NULL) { - mms_sys_error(err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "encrypt init"); - goto out; - } - - (void) RAND_pseudo_bytes(ek[0], eklen); - (void) RAND_pseudo_bytes(iv, ivlen); - - if (EVP_SealInit(&cipher_ctx, EVP_des_cbc(), - ek, &eklen, iv, pub_key, 1) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "encrypt init"); - goto out; - } - enclen = strlen(passwd) + EVP_CIPHER_CTX_block_size(&cipher_ctx); - if ((encbuf = (uchar_t *)malloc(enclen)) == NULL) { - mms_sys_error(err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "encrypt buf"); - goto out; - } - if (EVP_SealUpdate(&cipher_ctx, encbuf, &enclen, - (uchar_t *)passwd, strlen(passwd)) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "encrypt update"); - goto out; - } - if (EVP_SealFinal(&cipher_ctx, encbuf + enclen, &tmplen) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "encrypt final"); - goto out; - } - enclen += tmplen; - if ((data[0] = mms_ssl_encode(ek[0], eklen, err)) == NULL) { - mms_trace(MMS_DEVP, "encrypt encode ek"); - goto out; - } - if ((data[1] = mms_ssl_encode(iv, ivlen, err)) == NULL) { - mms_trace(MMS_DEVP, "encrypt encode iv"); - goto out; - } - if ((data[2] = mms_ssl_encode(encbuf, enclen, err)) == NULL) { - mms_trace(MMS_DEVP, "encrypt encode buf"); - goto out; - } - rc = 0; - -out: - if (rc) { - for (i = 0; i < 4; i++) { - free(data[i]); - } - } - free(ek[0]); - free(iv); - free(encbuf); - (void) EVP_CIPHER_CTX_cleanup(&cipher_ctx); - return (rc); -} - -static char * -mms_ssl_decrypt(EVP_PKEY *pkey, char *data[], mms_err_t *err) -{ - EVP_CIPHER_CTX cipher_ctx; - int len; - char *password = NULL; - uchar_t *ek = NULL; - int eklen; - uchar_t *iv = NULL; - int ivlen; - uchar_t *encbuf = NULL; - int enclen; - int tmplen; - int rc = 1; - - /* private key decrypt */ - - (void) EVP_CIPHER_CTX_init(&cipher_ctx); - - if ((ek = mms_ssl_decode(data[0], &eklen, err)) == NULL) { - mms_trace(MMS_DEVP, "decrypt decode ek"); - goto out; - } - if ((iv = mms_ssl_decode(data[1], &ivlen, err)) == NULL) { - mms_trace(MMS_DEVP, "decrypt decode iv"); - goto out; - } - if ((encbuf = mms_ssl_decode(data[2], &enclen, err)) == NULL) { - mms_trace(MMS_DEVP, "decrypt decode buf"); - goto out; - } - if ((password = (char *)malloc(enclen)) == NULL) { - mms_sys_error(err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "decrypt get memory"); - goto out; - } - if (EVP_OpenInit(&cipher_ctx, EVP_des_cbc(), - ek, eklen, iv, pkey) == 0) { - mms_ssl_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "decrypt init"); - goto out; - } - if (EVP_OpenUpdate(&cipher_ctx, (uchar_t *)password, &len, - encbuf, enclen) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "decrypt update"); - goto out; - } - if (EVP_OpenFinal(&cipher_ctx, (uchar_t *)password + len, - &tmplen) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "decrypt final"); - goto out; - } - len += tmplen; - password[len] = 0; - rc = 0; - -out: - if (rc) { - free(password); - password = NULL; - } - free(ek); - free(iv); - free(encbuf); - (void) EVP_CIPHER_CTX_cleanup(&cipher_ctx); - return (password); -} - -static int -mms_ssl_sign(EVP_PKEY *pkey, char *data[], mms_err_t *err) -{ - EVP_MD_CTX md_ctx; - uchar_t *signbuf = NULL; - int signlen; - int i; - int rc = 1; - - /* private key sign */ - - (void) EVP_MD_CTX_init(&md_ctx); - - signlen = EVP_PKEY_size(pkey); - if ((signbuf = (uchar_t *)malloc(signlen)) == NULL) { - mms_sys_error(err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "sign get buf memory"); - goto out; - } - if (EVP_SignInit_ex(&md_ctx, EVP_sha1(), NULL) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "sign init"); - goto out; - } - for (i = 0; i < 3; i++) { - if (EVP_SignUpdate(&md_ctx, data[i], strlen(data[i])) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "sign update %d", i); - goto out; - } - } - if (EVP_SignFinal(&md_ctx, signbuf, (uint_t *)&signlen, pkey) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "sign final"); - goto out; - } - if ((data[3] = mms_ssl_encode(signbuf, signlen, err)) == NULL) { - mms_trace(MMS_DEVP, "sign encode"); - goto out; - } - rc = 0; - -out: - (void) EVP_MD_CTX_cleanup(&md_ctx); - free(signbuf); - return (rc); -} - -static int -mms_ssl_verify_sign(EVP_PKEY *pubkey, char *data[], mms_err_t *err) -{ - EVP_MD_CTX md_ctx; - uchar_t *signbuf = NULL; - int signlen; - int i; - int rc = 1; - - /* public key verify sign */ - - (void) EVP_MD_CTX_init(&md_ctx); - - if ((signbuf = mms_ssl_decode(data[3], &signlen, err)) == NULL) { - mms_trace(MMS_DEVP, "verify sign decode"); - goto out; - } - if (EVP_VerifyInit_ex(&md_ctx, EVP_sha1(), NULL) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "verify sign init"); - goto out; - } - for (i = 0; i < 3; i++) { - if (EVP_VerifyUpdate(&md_ctx, data[i], strlen(data[i])) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "verify sign update %d", i); - goto out; - } - } - if (EVP_VerifyFinal(&md_ctx, signbuf, signlen, pubkey) != 1) { - mms_ssl_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "verify sign final"); - goto out; - } - rc = 0; - -out: - (void) EVP_MD_CTX_cleanup(&md_ctx); - free(signbuf); - return (rc); -} - -int -mms_ssl_has_cert_clause(void *ssl_data, mms_t *conn) -{ - mms_ssl_t *data = (mms_ssl_t *)ssl_data; - mms_sc_t *sc = (mms_sc_t *)conn->mms_ssl; - - if (data != NULL && sc != NULL) { - /* - * my certificate, my private key and - * other guy's certificate - */ - if (data->mms_nchain > 0 && - data->mms_key != NULL && - (data->mms_peer != NULL || sc->mms_sc_cert != NULL)) { - return (1); /* use hello/welcome certificate-clause */ - } - } - return (0); /* don't use hello/welcome certificate-clause */ -} - -int -mms_ssl_build_cert_clause(void *ssl_data, - mms_t *conn, - char *password, - char **cert, - char **auth) -{ - mms_ssl_t *data = (mms_ssl_t *)ssl_data; - mms_sc_t *sc = (mms_sc_t *)conn->mms_ssl; - mms_err_t *err = &conn->mms_err; - EVP_PKEY *pkey = NULL; - EVP_PKEY *pubkey = NULL; - char *mydata[4] = {0, 0, 0, 0}; - int i; - int len; - int rc = 1; - X509 *peer_cert; - - /* create certificate clause */ - - *cert = NULL; - *auth = NULL; - - mms_trace(MMS_DEVP, "build certificate clause"); - - /* my private key */ - if ((pkey = EVP_PKEY_new()) == NULL) { - mms_ssl_error(err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "new evp key"); - goto out; - } - if (EVP_PKEY_set1_RSA(pkey, data->mms_key) == 0) { - mms_ssl_error(err, MMS_ERR_SSL_KEY); - mms_trace(MMS_ERR, "set evp rsa key"); - goto out; - } - /* my certificate */ - if ((*cert = mms_ssl_x509_to_pem(data->mms_chain[0], err)) == NULL) { - mms_trace(MMS_DEVP, "my certificate"); - goto out; - } - /* get other guy's public key */ - if ((peer_cert = data->mms_peer) == NULL) { - peer_cert = sc->mms_sc_cert; - } - if ((pubkey = X509_get_pubkey(peer_cert)) == NULL) { - mms_ssl_error(err, MMS_ERR_SSL_KEY); - mms_trace(MMS_ERR, "other guy's public key"); - goto out; - } - /* encrypt password using other guy's public key */ - if (mms_ssl_encrypt(pubkey, password, mydata, err)) { - mms_trace(MMS_DEVP, "encryption failed"); - goto out; - } - /* sign password using my private key */ - if (mms_ssl_sign(pkey, mydata, err)) { - mms_trace(MMS_DEVP, "signing failed"); - goto out; - } - /* build authenticaton message */ - len = 0; - for (i = 0; i < 4; i++) { - len += (strlen(mydata[i]) + 1); - } - if ((*auth = (char *)malloc(len)) == NULL) { - mms_sys_error(err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "get auth memory"); - goto out; - } - (void) snprintf(*auth, len, "%s %s %s %s", - mydata[0], mydata[1], mydata[2], mydata[3]); - rc = 0; - -out: - if (rc) { - free(*cert); - free(*auth); - } - for (i = 0; i < 4; i++) { - free(mydata[i]); - } - if (pkey) - EVP_PKEY_free(pkey); - return (rc); -} - -int -mms_ssl_verify_cert_clause(void *ssl_data, - mms_t *conn, - char *cert_pem, - char *auth, - char **password) -{ - mms_ssl_t *data = (mms_ssl_t *)ssl_data; - X509 *cert = NULL; - mms_err_t *err = &conn->mms_err; - EVP_PKEY *pkey = NULL; - EVP_PKEY *pubkey = NULL; - char *mydata[4] = {0, 0, 0, 0}; - int i; - int rc = 1; - - /* verify certificate clause */ - - *password = NULL; - - mms_trace(MMS_DEVP, "verify certificate clause"); - - /* my private key */ - if ((pkey = EVP_PKEY_new()) == NULL) { - mms_ssl_error(err, MMS_ERR_SSL_KEY); - mms_trace(MMS_ERR, "new evp key"); - goto out; - } - if (EVP_PKEY_set1_RSA(pkey, data->mms_key) == 0) { - mms_ssl_error(err, MMS_ERR_SSL_KEY); - mms_trace(MMS_ERR, "set evp rsa key"); - goto out; - } - /* get certificate from other guy's certificate text */ - if ((cert = mms_ssl_pem_to_x509(cert_pem, err)) == NULL) { - mms_trace(MMS_ERR, "other guy's cert failed"); - goto out; - } - /* check other guy's cert */ - if (mms_ssl_check_cert(data, cert, err)) { - mms_trace(MMS_ERR, "other guy's cert invalid"); - goto out; - } - /* get other guy's public key */ - if ((pubkey = X509_get_pubkey(cert)) == NULL) { - mms_ssl_error(err, MMS_ERR_SSL_KEY); - mms_trace(MMS_ERR, "other guy's public key"); - goto out; - } - /* parse authentication message */ - if ((mydata[0] = strdup(auth)) == NULL) { - mms_sys_error(err, MMS_ERR_NOMEM); - mms_trace(MMS_ERR, "auth message dup"); - goto out; - } - for (i = 1; i < 4; i++) { - if ((mydata[i] = strchr(mydata[i - 1], ' ')) == NULL) { - mms_error(err, MMS_ERR_SSL_OP); - mms_trace(MMS_ERR, "parse auth message"); - goto out; - } - mydata[i][0] = 0; - mydata[i]++; - } - /* verify other guy's signature */ - if (mms_ssl_verify_sign(pubkey, mydata, err)) { - mms_trace(MMS_ERR, "other guy's signature invalid"); - goto out; - } - /* decrypt password using my private key */ - if ((*password = mms_ssl_decrypt(pkey, mydata, err)) == NULL) { - mms_trace(MMS_ERR, "decryption failed"); - goto out; - } - rc = 0; - -out: - if (cert) - X509_free(cert); - if (pkey) - EVP_PKEY_free(pkey); - if (mydata[0]) - free(mydata[0]); - return (rc); -} - -#endif /* MMS_OPENSSL */ diff --git a/usr/src/lib/mms/mms/common/mms_sym.c b/usr/src/lib/mms/mms/common/mms_sym.c deleted file mode 100644 index 98ad2eadd1..0000000000 --- a/usr/src/lib/mms/mms/common/mms_sym.c +++ /dev/null @@ -1,583 +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 <stdlib.h> -#include <string.h> -#include <syslog.h> -#include <thread.h> -#include <synch.h> -#include <mms_sym.h> - - -static mms_sym_t mms_err_symtab[] = { - - "UNKNOWN_CODE", MMS_UNKNOWN_CODE, - - /* - * Error class - */ - "state", MMS_STATE, - "compat", MMS_COMPAT, - "config", MMS_CONFIG, - "exist", MMS_EXIST, - "explicit", MMS_EXPLICIT, - "internal", MMS_INTERNAL, - "invalid", MMS_INVALID, - "permpriv", MMS_PERMPRIV, - "retry", MMS_RETRY, - "subop", MMS_SUBOP, - "language", MMS_LANGUAGE, - "DM_C_INVALID", MMS_DM_C_INVALID, - "DM_C_COMMAND", MMS_DM_C_COMMAND, - "LM_C_INVALID", MMS_LM_C_INVALID, - "LM_C_COMMAND", MMS_LM_C_COMMAND, - "MM_C_INVALID", MMS_MM_C_INVALID, - "MM_C_MANAGEMENT", MMS_MM_C_MANAGEMENT, - - /* - * Error codes - */ - - "E_NET_IO_ERR", MMS_E_NET_IO_ERR, - "E_SYNTAX_ERR", MMS_E_SYNTAX_ERR, - "E_INVALID_RESPONSE", MMS_E_INVALID_RESPONSE, - "E_UNKNOWN_ERR_STRING", MMS_E_UNKNOWN_ERR_STRING, - "E_OUTOFMEMORY", MMS_E_OUTOFMEMORY, - "E_CONNECT_ERR", MMS_E_CONNECT_ERR, - "E_SSL_CERT_CLAUSE", MMS_E_SSL_CERT_CLAUSE, - "E_WELCOME_PASSWORD", MMS_E_WELCOME_PASSWORD, - "E_NO_WELCOME_PASSWORD", MMS_E_NO_WELCOME_PASSWORD, - "E_SSL_VERIFY", MMS_E_SSL_VERIFY, - - /* - * The following are error codes added by MMS for client API - */ - - "MALLOC_ERROR", MMS_MALLOC_ERROR, - "SELECT_ERROR", MMS_SELECT_ERROR, - "UNACCEPTABLE_RSP", MMS_UNACCEPTABLE_RSP, - "INVALID_RSP", MMS_INVALID_RSP, - "INVALID_RSP_CODE", MMS_INVALID_RSP_CODE, - "MISSING_TASKID", MMS_MISSING_TASKID, - "WRONG_TASKID", MMS_WRONG_TASKID, - - "TRACE_FAILURE", MMS_TRACE_FAILURE, - "WRONG_API_MODE", MMS_WRONG_API_MODE, - "ASYNC_API_FAILURE", MMS_ASYNC_API_FAILURE, - "API_ERR", MMS_API_ERR, - "API_NOT_ERR_RSP", MMS_API_NOT_ERR_RSP, - "CFG_FILE_ERR", MMS_CFG_FILE_ERR, - "DUPLICATE_REG", MMS_DUPLICATE_REG, - "EV_REG_FAILED", MMS_EV_REG_FAILED, - "EV_UNREG_FAILED", MMS_EV_UNREG_FAILED, - "API_SHUTDOWN", MMS_API_SHUTDOWN, - "INVALID_REQ", MMS_INVALID_REQ, - - /* - * The following are error codes defined in the MMS spec. - */ - "DM_E_AGAIN", MMS_DM_E_AGAIN, - "DM_E_BADHANDLE", MMS_DM_E_BADHANDLE, - "DM_E_BADVAL", MMS_DM_E_BADVAL, - "DM_E_CMDARGS", MMS_DM_E_CMDARGS, - "DM_E_DEVADMINCLT", MMS_DM_E_DEVADMINCLT, - "DM_E_DEVCMD", MMS_DM_E_DEVCMD, - "DM_E_DEVCMDABORT", MMS_DM_E_DEVCMDABORT, - "DM_E_DEVCMDILLEGAL", MMS_DM_E_DEVCMDILLEGAL, - "DM_E_DEVCMDTEMEOUT", MMS_DM_E_DEVCMDTEMEOUT, - "DM_E_DEVCOMMERR", MMS_DM_E_DEVCOMMERR, - "DM_E_DEVDET", MMS_DM_E_DEVDET, - "DM_E_DEVEMPTY", MMS_DM_E_DEVEMPTY, - "DM_E_DEVFULL", MMS_DM_E_DEVFULL, - "DM_E_DEVNORESPONSE", MMS_DM_E_DEVNORESPONSE, - "DM_E_DEVOPERATOR", MMS_DM_E_DEVOPERATOR, - "DM_E_DEVOVERFLOW", MMS_DM_E_DEVOVERFLOW, - "DM_E_DEVPERM", MMS_DM_E_DEVPERM, - "DM_E_DEVPREV", MMS_DM_E_DEVPREV, - "DM_E_DEVRESET", MMS_DM_E_DEVRESET, - "DM_E_DEVSYNCHERR", MMS_DM_E_DEVSYNCHERR, - "DM_E_DRIVE", MMS_DM_E_DRIVE, - "DM_E_HANDLEBUSY", MMS_DM_E_HANDLEBUSY, - "DM_E_HANDLEINUSE", MMS_DM_E_HANDLEINUSE, - "DM_E_INTERNAL", MMS_DM_E_INTERNAL, - "DM_E_LIBRARY", MMS_DM_E_LIBRARY, - "DM_E_MODE", MMS_DM_E_MODE, - "DM_E_NOCANC", MMS_DM_E_NOCANC, - "DM_E_NOCART", MMS_DM_E_NOCART, - "DM_E_NOELT", MMS_DM_E_NOELT, - "DM_E_NOEXISTHANDLE", MMS_DM_E_NOEXISTHANDLE, - "DM_E_NOID", MMS_DM_E_NOID, - "DM_E_NOTASK", MMS_DM_E_NOTASK, - "DM_E_READY", MMS_DM_E_READY, - "DM_E_UNKNOWN", MMS_DM_E_UNKNOWN, - "EACCHANDLESTILLINUSE", MMS_EACCHANDLESTILLINUSE, - "EAPPACCESSTOCART", MMS_EAPPACCESSTOCART, - "EAPPCARTNOACC", MMS_EAPPCARTNOACC, - "EAPPDMDIFFHOSTS", MMS_EAPPDMDIFFHOSTS, - "EAPPDRVNOACC", MMS_EAPPDRVNOACC, - "EAPPHASNOVOLS", MMS_EAPPHASNOVOLS, - "EAPPLIBNOACCESS", MMS_EAPPLIBNOACCESS, - "EAPPMOUNTNOTIUSSUED", MMS_EAPPMOUNTNOTIUSSUED, - "EAPPSESS", MMS_EAPPSESS, - "EAPPTASKNOTISSUED", MMS_EAPPTASKNOTISSUED, - "EAUTOCREATEFAILED", MMS_EAUTOCREATEFAILED, - "ECANCELLED", MMS_ECANCELLED, - "ECANCELNUMRANGEDISALLOWED", MMS_ECANCELNUMRANGEDISALLOWED, - "ECANTCANCEL", MMS_ECANTCANCEL, - "ECARTDRVNOTCOMPATIBLE", MMS_ECARTDRVNOTCOMPATIBLE, - "ECARTDRVSLOTMISMATCH", MMS_ECARTDRVSLOTMISMATCH, - "ECARTINSLOT", MMS_ECARTINSLOT, - "ECARTINUSE", MMS_ECARTINUSE, - "ECARTMOUNTNOTINVOLVED", MMS_ECARTMOUNTNOTINVOLVED, - "ECARTNOACC", MMS_ECARTNOACC, - "ECARTNOCGA", MMS_ECARTNOCGA, - "ECARTNOFREEPARTS", MMS_ECARTNOFREEPARTS, - "ECARTNOTINSLOT", MMS_ECARTNOTINSLOT, - "ECARTNOTLOCATED", MMS_ECARTNOTLOCATED, - "ECARTNOTOWNEDBYAP", MMS_ECARTNOTOWNEDBYAP, - "ECARTNOTOWNEDBYAPP", MMS_ECARTNOTOWNEDBYAPP, - "ECLAUSEMISSING", MMS_ECLAUSEMISSING, - "ECLAUSEMUTEX", MMS_ECLAUSEMUTEX, - "ECLAUSENEEDSARG", MMS_ECLAUSENEEDSARG, - "ECLAUSENOPRIVILEGE", MMS_ECLAUSENOPRIVILEGE, - "ECOMMANDBEINGSUBMITTED", MMS_ECOMMANDBEINGSUBMITTED, - "ECOMMANDFAILED", MMS_ECOMMANDFAILED, - "ECOMMANDNOPRIVILEGE", MMS_ECOMMANDNOPRIVILEGE, - "ECONNDELETE", MMS_ECONNDELETE, - "EDMCONFIG", MMS_EDMCONFIG, - "EDMNOTCONNECTED", MMS_EDMNOTCONNECTED, - "EDMNOTREADY", MMS_EDMNOTREADY, - "EDMPATTACH", MMS_EDMPATTACH, - "EDMPDETACH", MMS_EDMPDETACH, - "EDMPLOAD", MMS_EDMPLOAD, - "EDMPUNLOAD", MMS_EDMPUNLOAD, - "EDMRECOVERING", MMS_EDMRECOVERING, - "EDMSTATE", MMS_EDMSTATE, - "EDMSTILLBOOTING", MMS_EDMSTILLBOOTING, - "EDRIVEEMPTY", MMS_EDRIVEEMPTY, - "EDRIVESET", MMS_EDRIVESET, - "EDRVBROKEN", MMS_EDRVBROKEN, - "EDRVCARTNOTREADABLE", MMS_EDRVCARTNOTREADABLE, - "EDRVDISABLEDPERM", MMS_EDRVDISABLEDPERM, - "EDRVDISABLEDTEMP", MMS_EDRVDISABLEDTEMP, - "EDRVEJECTING", MMS_EDRVEJECTING, - "EDRVINUSE", MMS_EDRVINUSE, - "EDRVLOADED", MMS_EDRVLOADED, - "EDRVMOUNTNOTINVOLVED", MMS_EDRVMOUNTNOTINVOLVED, - "EDRVNODMCONFIGURED", MMS_EDRVNODMCONFIGURED, - "EDRVNOTINBAY", MMS_EDRVNOTINBAY, - "EDRVNOTLOADED", MMS_EDRVNOTLOADED, - "EDRVSESSNOUSE", MMS_EDRVSESSNOUSE, - "EDRVTASKNOTREQUIRED", MMS_EDRVTASKNOTREQUIRED, - "EDRVUNKNOWN", MMS_EDRVUNKNOWN, - "EHANDLEINUSE", MMS_EHANDLEINUSE, - "EHANDLENOTDESTROY", MMS_EHANDLENOTDESTROY, - "EINVALCLAUSEARG", MMS_EINVALCLAUSEARG, - "ELANGNOTSUPPORTED", MMS_ELANGNOTSUPPORTED, - "ELIBBROKEN", MMS_ELIBBROKEN, - "ELIBCARTNOCONTAINMENT", MMS_ELIBCARTNOCONTAINMENT, - "ELIBDISABLEDPERM", MMS_ELIBDISABLEDPERM, - "ELIBDISABLEDTEMP", MMS_ELIBDISABLEDTEMP, - "ELIBDRVNOCONTAINMENT", MMS_ELIBDRVNOCONTAINMENT, - "ELIBINUSE", MMS_ELIBINUSE, - "ELIBNOLMCONFIGURED", MMS_ELIBNOLMCONFIGURED, - "ELMADD", MMS_ELMADD, - "ELMCARTBAYNOTACCESS", MMS_ELMCARTBAYNOTACCESS, - "ELMCONFIG", MMS_ELMCONFIG, - "ELMDMCOMMUNICATION", MMS_ELMDMCOMMUNICATION, - "ELMDRVBAYNOTACCESS", MMS_ELMDRVBAYNOTACCESS, - "ELMDRVNOTACCESS", MMS_ELMDRVNOTACCESS, - "ELMNOTCONNECTED", MMS_ELMNOTCONNECTED, - "ELMNOTREADY", MMS_ELMNOTREADY, - "ELMPMOUNT", MMS_ELMPMOUNT, - "ELMPORTNOTREADY", MMS_ELMPORTNOTREADY, - "ELMPUNMOUNT", MMS_ELMPUNMOUNT, - "ELMSLOTNOTACCESS", MMS_ELMSLOTNOTACCESS, - "ELMSTATE", MMS_ELMSTATE, - "ELMSTILLBOOTING", MMS_ELMSTILLBOOTING, - "EMLOGCREATE", MMS_EMLOGCREATE, - "EMLOGDELETE", MMS_EMLOGDELETE, - "EMNTCARTPRES", MMS_EMNTCARTPRES, - "EMOUNTLIBNOTINVOLVED", MMS_EMOUNTLIBNOTINVOLVED, - "EMPCREATE", MMS_EMPCREATE, - "EMPHYSDEL", MMS_EMPHYSDEL, - "ENEWVOLEXISTS", MMS_ENEWVOLEXISTS, - "ENEWVOLNAMECOUNT", MMS_ENEWVOLNAMECOUNT, - "ENOALLOCATABLEPARTS", MMS_ENOALLOCATABLEPARTS, - "ENOCANCELLABLETASKS", MMS_ENOCANCELLABLETASKS, - "ENOCARTRIDGE", MMS_ENOCARTRIDGE, - "ENOINSTANCE", MMS_ENOINSTANCE, - "ENOMATCH", MMS_ENOMATCH, - "ENOMEMORY", MMS_ENOMEMORY, - "ENOPRIVCHANGE", MMS_ENOPRIVCHANGE, - "ENOSESSION", MMS_ENOSESSION, - "ENOSLOT", MMS_ENOSLOT, - "ENOSOLUTIONS", MMS_ENOSOLUTIONS, - "ENOSUCHCART", MMS_ENOSUCHCART, - "ENOSUCHLANG", MMS_ENOSUCHLANG, - "ENOSUCHPRIV", MMS_ENOSUCHPRIV, - "ENOSUCHREQ", MMS_ENOSUCHREQ, - "ENOSUCHSIDE", MMS_ENOSUCHSIDE, - "ENOSUCHSORT", MMS_ENOSUCHSORT, - "ENOSUCHVOLUME", MMS_ENOSUCHVOLUME, - "EOBJATTRMODDISALLOWED", MMS_EOBJATTRMODDISALLOWED, - "EOBJATTRTOOMANY", MMS_EOBJATTRTOOMANY, - "EOBJATTRVALNOTENUM", MMS_EOBJATTRVALNOTENUM, - "EOBJATTRVALNOTNUM", MMS_EOBJATTRVALNOTNUM, - "EOBJATTRVALNULLSTRING", MMS_EOBJATTRVALNULLSTRING, - "EOBJCREATEDISALLOWED", MMS_EOBJCREATEDISALLOWED, - "EOBJCREATEINVALREPORT", MMS_EOBJCREATEINVALREPORT, - "EOBJCREATESYSATTRREQUIRED", MMS_EOBJCREATESYSATTRREQUIRED, - "EOBJDELDISALLOWED", MMS_EOBJDELDISALLOWED, - "EOBJDELNUMRANGEDISALLOWED", MMS_EOBJDELNUMRANGEDISALLOWED, - "EOBJDEPENDNOEXIST", MMS_EOBJDEPENDNOEXIST, - "EOBJKEYCHANGE", MMS_EOBJKEYCHANGE, - "EOBJKEYNOTUNIQUE", MMS_EOBJKEYNOTUNIQUE, - "EOBJNOTVISIBLE", MMS_EOBJNOTVISIBLE, - "EOBJREFERENCES", MMS_EOBJREFERENCES, - "EOBJSYSATTRCREATEDISALLOWED", MMS_EOBJSYSATTRCREATEDISALLOWED, - "EOBJSYSATTRMODDISALLOWED", MMS_EOBJSYSATTRMODDISALLOWED, - "EOBJSYSATTRMODNOPRIV", MMS_EOBJSYSATTRMODNOPRIV, - "EOBJUSRATTRCREATEDISALLOWED", MMS_EOBJUSRATTRCREATEDISALLOWED, - "EOBJUSRATTRCREATENOPRIV", MMS_EOBJUSRATTRCREATENOPRIV, - "EPARTNOTALLOCABLE", MMS_EPARTNOTALLOCABLE, - "EPRIVCHANGEDISALLOWED", MMS_EPRIVCHANGEDISALLOWED, - "ERENAMEDVOLEXISTS", MMS_ERENAMEDVOLEXISTS, - "EREPLACEFAILED", MMS_EREPLACEFAILED, - "EREQACCEPTEDBYDIFFSESS", MMS_EREQACCEPTEDBYDIFFSESS, - "EREQSTATECHANGEFAILED", MMS_EREQSTATECHANGEFAILED, - "EREQUESTALREADYACCEPTED", MMS_EREQUESTALREADYACCEPTED, - "EREQUESTALREADYSATISFIED", MMS_EREQUESTALREADYSATISFIED, - "EREQUESTNOTACCEPTED", MMS_EREQUESTNOTACCEPTED, - "ESESSCARTNOTUSED", MMS_ESESSCARTNOTUSED, - "ESESSLIBNOTUSED", MMS_ESESSLIBNOTUSED, - "ESESSMNTNOTISSUED", MMS_ESESSMNTNOTISSUED, - "ESESSTASKNOISSUED", MMS_ESESSTASKNOISSUED, - "ESHUTDOWNFAILED", MMS_ESHUTDOWNFAILED, - "ESLOTNOTOCCUPIED", MMS_ESLOTNOTOCCUPIED, - "ESLOTOCCUPIED", MMS_ESLOTOCCUPIED, - "ESORTNOTSUPPORTED", MMS_ESORTNOTSUPPORTED, - "ESYSATTRUNSETDISALLOWED", MMS_ESYSATTRUNSETDISALLOWED, - "ESYSTEM", MMS_ESYSTEM, - "ETABLELIMIT", MMS_ETABLELIMIT, - "ETASKCARTNOUSE", MMS_ETASKCARTNOUSE, - "ETASKLIBNOUSE", MMS_ETASKLIBNOUSE, - "ETASKMNTNOUSE", MMS_ETASKMNTNOUSE, - "ETMPUNAVAIL", MMS_ETMPUNAVAIL, - "ETMPINUSE", MMS_ETMPINUSE, - "ETOOMANY", MMS_ETOOMANY, - "ETOOMANYCLAUSES", MMS_ETOOMANYCLAUSES, - "ETRANSACTIONFAILED", MMS_ETRANSACTIONFAILED, - "EUNKNOWNERROR", MMS_EUNKNOWNERROR, - "EVOLEXISTS", MMS_EVOLEXISTS, - "EVOLINUSE", MMS_EVOLINUSE, - "EVOLNAMEREWRITE", MMS_EVOLNAMEREWRITE, - "EVOLNOTOWNEDBYAPP", MMS_EVOLNOTOWNEDBYAPP, - "EWOULDDEADLOCK", MMS_EWOULDDEADLOCK, - "LM_E_ACCESS", MMS_LM_E_ACCESS, - "LM_E_AGAIN", MMS_LM_E_AGAIN, - "LM_E_BADVAL", MMS_LM_E_BADVAL, - "LM_E_CMDARGS", MMS_LM_E_CMDARGS, - "LM_E_DESTFULL", MMS_LM_E_DESTFULL, - "LM_E_DEVADMINCLT", MMS_LM_E_DEVADMINCLT, - "LM_E_DEVCMD", MMS_LM_E_DEVCMD, - "LM_E_DEVCMDABORT", MMS_LM_E_DEVCMDABORT, - "LM_E_DEVCMDILLEGAL", MMS_LM_E_DEVCMDILLEGAL, - "LM_E_DEVCMDTEMEOUT", MMS_LM_E_DEVCMDTEMEOUT, - "LM_E_DEVCOMMERR", MMS_LM_E_DEVCOMMERR, - "LM_E_DEVEJ", MMS_LM_E_DEVEJ, - "LM_E_DEVINJ", MMS_LM_E_DEVINJ, - "LM_E_DEVNORESPONSE", MMS_LM_E_DEVNORESPONSE, - "LM_E_DEVOPERATOR", MMS_LM_E_DEVOPERATOR, - "LM_E_DEVOVERFLOW", MMS_LM_E_DEVOVERFLOW, - "LM_E_DEVPREM", MMS_LM_E_DEVPREM, - "LM_E_DEVPREV", MMS_LM_E_DEVPREV, - "LM_E_DEVRESET", MMS_LM_E_DEVRESET, - "LM_E_DEVSYNCHERR", MMS_LM_E_DEVSYNCHERR, - "LM_E_DIRECTION", MMS_LM_E_DIRECTION, - "LM_E_INTERNAL", MMS_LM_E_INTERNAL, - "LM_E_LIBRARY", MMS_LM_E_LIBRARY, - "LM_E_MOVE", MMS_LM_E_MOVE, - "LM_E_NOCANC", MMS_LM_E_NOCANC, - "LM_E_NODRIVE", MMS_LM_E_NODRIVE, - "LM_E_NOELT", MMS_LM_E_NOELT, - "LM_E_NOPCL", MMS_LM_E_NOPCL, - "LM_E_NOSLOT", MMS_LM_E_NOSLOT, - "LM_E_NOTASK", MMS_LM_E_NOTASK, - "LM_E_PCL", MMS_LM_E_PCL, - "LM_E_PORT", MMS_LM_E_PORT, - "LM_E_PORTDIR", MMS_LM_E_PORTDIR, - "LM_E_READY", MMS_LM_E_READY, - "LM_E_SCREMPTY", MMS_LM_E_SCREMPTY, - "LM_E_SHAPE", MMS_LM_E_SHAPE, - "LM_E_SLOTGROUP", MMS_LM_E_SLOTGROUP, - "LM_E_UNKNOWN", MMS_LM_E_UNKNOWN, - "MM_E_AGAIN", MMS_MM_E_AGAIN, - "MM_E_BADVAL", MMS_MM_E_BADVAL, - "MM_E_CMDARGS", MMS_MM_E_CMDARGS, - "MM_E_DEVCMD", MMS_MM_E_DEVCMD, - "MM_E_DEVCMDABORT", MMS_MM_E_DEVCMDABORT, - "MM_E_DEVCMDILLEGAL", MMS_MM_E_DEVCMDILLEGAL, - "MM_E_DEVCMDTEMEOUT", MMS_MM_E_DEVCMDTEMEOUT, - "MM_E_DEVOVERFLOW", MMS_MM_E_DEVOVERFLOW, - "MM_E_DEVPREM", MMS_MM_E_DEVPREM, - "MM_E_DEVPREV", MMS_MM_E_DEVPREV, - "MM_E_INTERNAL", MMS_MM_E_INTERNAL, - "MM_E_NOELT", MMS_MM_E_NOELT, - "SSAI_E_PROTOCOL_ERROR", MMS_SSAI_E_PROTOCOL_ERROR, - "SSAI_E_ACCESS_DENIED", MMS_SSAI_E_ACCESS_DENIED, - "SSAI_E_DUPLICATE_SESSION", MMS_SSAI_E_DUPLICATE_SESSION, - "SSAI_E_UNKNOWN_LANGUAGE", MMS_SSAI_E_UNKNOWN_LANGUAGE, - "SSAI_E_UNSUPPORTED_LANGUAGE", MMS_SSAI_E_UNSUPPORTED_LANGUAGE, - "SSAI_E_SSL", MMS_SSAI_E_SSL, - "LM_E_SUBCMDFAILED", MMS_LM_E_SUBCMDFAILED, - "LM_E_CONFIG", MMS_LM_E_CONFIG, - - /* - * Additional DM errors - */ - "DM_E_ENABLED", MMS_DM_E_ENABLED, - "DM_E_VIDMISMATCH", MMS_DM_E_VIDMISMATCH, - "DM_E_COMMAND", MMS_DM_E_COMMAND, - "DM_E_UNSUPPORTED", MMS_DM_E_UNSUPPORTED, - "DM_E_IO", MMS_DM_E_IO, - "DM_E_COMMUNICATION", MMS_DM_E_COMMUNICATION, - "DM_E_MAKEHANDLE", MMS_DM_E_MAKEHANDLE, - "DM_E_USER", MMS_DM_E_USER, - "DM_E_LOAD", MMS_DM_E_LOAD, - "DM_E_OPERATOR_ABORT", MMS_DM_E_OPERATOR_ABORT, - "DM_E_VOLUME_ID", MMS_DM_E_VOLUME_ID, - "DM_E_DRIVE_SER_NUM", MMS_DM_E_DRIVE_SER_NUM, - "DM_E_DENSITY", MMS_DM_E_DENSITY, - - /* - * Additional MM errors - */ - "ENOSUCHPCL", MMS_ENOSUCHPCL, - "ELIBRARYNOEXIST", MMS_ELIBRARYNOEXIST, - "ELMNOEXIST", MMS_ELMNOEXIST, - "ELIBALREADYONLINE", MMS_ELIBALREADYONLINE, - "ELIBALREADYOFFLINE", MMS_ELIBALREADYOFFLINE, - "EDRIVENOEXIST", MMS_EDRIVENOEXIST, - "EDRIVEALREADYONLINE", MMS_EDRIVEALREADYONLINE, - "EDRIVEALREADYOFFLINE", MMS_EDRIVEALREADYOFFLINE, - "EDRIVEONLINE", MMS_EDRIVEONLINE, - "EDRIVEOFFLINE", MMS_EDRIVEOFFLINE, - "ELIBRARYONLINE", MMS_ELIBRARYONLINE, - "ELIBRARYOFFLINE", MMS_ELIBRARYOFFLINE, - "EDRVUNLOADING", MMS_EDRVUNLOADING, - "EDMNOMOUNTPOINT", MMS_EDMNOMOUNTPOINT, - /* - * Label errors - */ - "E_LABEL_NOT_PROCESSED", MMS_E_LABEL_NOT_PROCESSED, - "E_LABEL_MOUNT_SEND", MMS_E_LABEL_MOUNT_SEND, - "E_LABEL_MOUNT_RSP", MMS_E_LABEL_MOUNT_RSP, - "E_LABEL_HANDLE_NULL", MMS_E_LABEL_HANDLE_NULL, - "E_LABEL_HANDLE_OPEN", MMS_E_LABEL_HANDLE_OPEN, - "E_LABEL_UNMOUNT_SEND", MMS_E_LABEL_UNMOUNT_SEND, - "E_LABEL_UNMOUNT_RSP", MMS_E_LABEL_UNMOUNT_RSP, - "E_LABEL_NO_CARTRIDGES", MMS_E_LABEL_NO_CARTRIDGES, - "E_LABEL_NO_LIBRARY", MMS_E_LABEL_NO_LIBRARY, - "E_LABEL_COMMANDS", MMS_E_LABEL_COMMANDS, - - /* - * Sun MM System vendor-defined error codes. - */ - "EDATABASE", MMS_EDATABASE, - "ENOTFOUND", MMS_ENOTFOUND, - "ESYNTAX", MMS_ESYNTAX, - "EPRIVNOTMMSADMIN", MMS_EPRIVNOTSMMSADMIN, - "MM_E_NOTASK", MMS_MM_E_NOTASK, - "MM_E_TOOMANYTASKS", MMS_MM_E_TOOMANYTASKS, - "ENOSUCHPCL", MMS_ENOSUCHPCL, - "ENOTENOUGHPARTITIONS", MMS_ENOTENOUGHPARTITIONS, - "EPARTITIONSTATECHANGE", MMS_EPARTITIONSTATECHANGE, - "ECARTRIDGESTATECHANGE", MMS_ECARTRIDGESTATECHANGE, - "ESYSTEMCONFIGCHANGE", MMS_ESYSTEMCONFIGCHANGE, - "ENOTCONNECTED", MMS_ENOTCONNECTED, - "ECOMMUNICATION", MMS_ECOMMUNICATION, - - /* - * Socket and SSL error codes. - */ - "MMS_ERR_NONE", MMS_ERR_NONE, - "MMS_ERR_GETADDRINFO", MMS_ERR_GETADDRINFO, - "MMS_ERR_SERVICE_NOT_FOUND", MMS_ERR_SERVICE_NOT_FOUND, - "MMS_ERR_ACCEPT_FAILED", MMS_ERR_ACCEPT_FAILED, - "MMS_ERR_LISTEN", MMS_ERR_LISTEN, - "MMS_ERR_READ", MMS_ERR_READ, - "MMS_ERR_WRITE", MMS_ERR_WRITE, - "MMS_ERR_RES_NULL", MMS_ERR_RES_NULL, - "MMS_ERR_GETHOSTNAME", MMS_ERR_GETHOSTNAME, - "MMS_ERR_NOMEM", MMS_ERR_NOMEM, - "MMS_ERR_SSL_CONNECT", MMS_ERR_SSL_CONNECT, - "MMS_ERR_SSL_FILE", MMS_ERR_SSL_FILE, - "MMS_ERR_SSL_CTX", MMS_ERR_SSL_CTX, - "MMS_ERR_SSL_CERT", MMS_ERR_SSL_CERT, - "MMS_ERR_SSL_NOCERT", MMS_ERR_SSL_NOCERT, - "MMS_ERR_SSL_KEY", MMS_ERR_SSL_KEY, - "MMS_ERR_SSL_DH", MMS_ERR_SSL_DH, - "MMS_ERR_SSL_CIPHER", MMS_ERR_SSL_CIPHER, - "MMS_ERR_SSL_OP", MMS_ERR_SSL_OP, - "MMS_ERR_SSL_STORE", MMS_ERR_SSL_STORE, - "MMS_ERR_SSL_VERIFY", MMS_ERR_SSL_VERIFY, - "MMS_ERR_NO_SSL", MMS_ERR_NO_SSL, - - -}; -static int mms_num_err_syms = sizeof (mms_err_symtab) / sizeof (mms_sym_t); -static int mms_symtab_initialized = 0; -static mutex_t mms_symtab_mutex = DEFAULTMUTEX; - - - - - -#define MMS_STR_EQ(a, b) (strcmp(a, b) == 0) -#define MMS_STR_GT(a, b) (strcmp(a, b) > 0) -#define MMS_STR_LT(a, b) (strcmp(a, b) < 0) -#define MMS_STR_GE(a, b) (strcmp(a, b) >= 0) -#define MMS_STR_LE(a, b) (strcmp(a, b) <= 0) - -void -mms_sym_init_symtab() -{ - (void) mutex_lock(&mms_symtab_mutex); - if (mms_symtab_initialized == 0) { - mms_sort_sym_token(mms_err_symtab, mms_num_err_syms); - mms_symtab_initialized = 1; - } - (void) mutex_unlock(&mms_symtab_mutex); -} - -int -mms_sym_str_to_code(char *errstr) -{ - mms_sym_t *mms_sym; - - if (mms_symtab_initialized == 0) { - mms_sym_init_symtab(); - } - - if ((mms_sym = mms_lookup_sym_token(errstr, mms_err_symtab, - mms_num_err_syms)) == NULL) { - return (MMS_E_UNKNOWN_ERR_STRING); - } else { - return (mms_sym->sym_code); - } -} - -char * -mms_sym_code_to_str(int code) -{ - int i; - mms_sym_t *mms_sym; - int index = 0; - - if (mms_symtab_initialized == 0) { - mms_sym_init_symtab(); - } - - for (i = 0; i < mms_num_err_syms; i++) { - mms_sym = mms_err_symtab + i; - if (mms_sym->sym_code == code) { - return (mms_sym->sym_token); - } - if (mms_sym->sym_code == MMS_UNKNOWN_CODE) { - index = i; - } - } - - return (mms_err_symtab[index].sym_token); -} - -/* - * Sort symbol table - */ - -int -mms_sym_compare(const void *arga, const void *argb) -{ - /* - * Compare functions for sort - */ - mms_sym_t *a = (mms_sym_t *)arga; - mms_sym_t *b = (mms_sym_t *)argb; - - return (strcmp(a->sym_token, b->sym_token)); -} - -void -mms_sort_sym_token(mms_sym_t *tab, int num) -{ - qsort(tab, num, sizeof (mms_sym_t), mms_sym_compare); -} - -int -mms_code_compare(const void *arga, const void *argb) -{ - /* - * Compare functions for sort - */ - mms_sym_t *a = (mms_sym_t *)arga; - mms_sym_t *b = (mms_sym_t *)argb; - - return (a->sym_code - b->sym_code); -} - -void -mms_sort_sym_code(mms_sym_t *tab, int num) -{ - qsort(tab, num, sizeof (mms_sym_t), mms_code_compare); -} - -/* - * Use binary search to lookup symbol - */ - -mms_sym_t * -mms_lookup_sym_token(char *mms_sym, mms_sym_t *tab, int num) -{ - mms_sym_t key = { mms_sym }; - - return (bsearch(&key, tab, num, sizeof (mms_sym_t), mms_sym_compare)); -} - -mms_sym_t * -mms_lookup_sym_code(int code, mms_sym_t *tab, int num) -{ - int i; - - for (i = 0; i < num; i++) { - if (tab[i].sym_code == code) { - return (tab + i); - } - } - - return (NULL); -} diff --git a/usr/src/lib/mms/mms/common/mmsp_common.c b/usr/src/lib/mms/mms/common/mmsp_common.c deleted file mode 100644 index 06b99a7441..0000000000 --- a/usr/src/lib/mms/mms/common/mmsp_common.c +++ /dev/null @@ -1,353 +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. - */ - - -#include <thread.h> -#include <synch.h> -#include <stdio.h> -#include <stdarg.h> -#include <stdlib.h> -#include <string.h> -#include <sys/int_types.h> -#include <mmsp_yacc.h> -#include <mms_list.h> -#include <mms_sym.h> -#include <mms_parser.h> -#include <mms_par_impl.h> -#include <mmsp_yacc.h> -#include <mms_sym.h> - - - - -#define yyparse mms_mmsp_parse -int yyparse(mms_pw_t *); - -int mms_mmsp_debug; -extern int mms_mmsp__flex_debug; -extern uchar_t *mms_token_flags; - -/* - * The symbol table will be sorted in ascending order when the parser - * is initialized. There is no need to add new symbols in any particular order. - */ - -extern mms_sym_t *mms_symtab; -extern int mms_num_syms; -static int mms_symtab_initialized = 0; -static mutex_t mms_symtab_mutex = DEFAULTMUTEX; -static mutex_t mmsp_mutex = DEFAULTMUTEX; - -mms_pw_t * -mms_par_init_wka(mms_par_node_t **cmd_node, - mms_list_t *msg_list, - mms_sym_t *depend_symtab, int num_depend_syms, - int *depend_symtab_initialized) -{ - mms_pw_t *wka; - - mms_list_create(msg_list, sizeof (mms_par_err_t), - offsetof(mms_par_err_t, pe_next)); - *cmd_node = NULL; - wka = (mms_pw_t *)malloc(sizeof (mms_pw_t)); - if (wka == NULL) { - /* Can't get mem for wka */ - return (NULL); - } - (void) memset(wka, 0, sizeof (mms_pw_t)); - wka->par_wka_token[0] = malloc(MMS_PAR_MAX_TOKEN + 1); - if (wka->par_wka_token[0] == NULL) { - free(wka); - return (NULL); - } - wka->par_wka_token[1] = malloc(MMS_PAR_MAX_TOKEN + 1); - if (wka->par_wka_token[1] == NULL) { - free(wka->par_wka_token[0]); - free(wka); - return (NULL); - } - wka->par_wka_token_index = 1; - - wka->par_wka_token_flags = mms_token_flags; - - wka->par_wka_line = 1; - wka->par_wka_col = 1; - wka->par_wka_err_list = msg_list; - wka->par_wka_cmd_node = cmd_node; - - wka->par_wka_symtab = mms_symtab; - wka->par_wka_num_syms = mms_num_syms; - wka->par_wka_symtab_depend = depend_symtab; - wka->par_wka_num_syms_depend = num_depend_syms; - *cmd_node = NULL; - (void) mutex_lock(&mms_symtab_mutex); - if (!mms_symtab_initialized) { - mms_sort_sym_token(wka->par_wka_symtab, wka->par_wka_num_syms); - mms_symtab_initialized = 1; - } - if (!(*depend_symtab_initialized)) { - mms_sort_sym_token(wka->par_wka_symtab_depend, - wka->par_wka_num_syms_depend); - *depend_symtab_initialized = 1; - } - (void) mutex_unlock(&mms_symtab_mutex); - return (wka); -} - -/* - * The following is the symbols for all the MMP commands. - */ -extern mms_sym_t *mms_mmp_symtab; -extern int mms_num_mmsp_syms; -static int mms_mmp_symtab_initialized = 0; - -/* - * - * mmp_parse_buf(), dmpm_parse_buf(), dmpd_parse_buf(), lmpm_parse_buf() - * lmpl_parse_buf() - * - * Parameters: - * cmd_node Ptr to the generated parse tree of XML cmd string - * msg_list List needed by parser routine if errors encountered - * buf XML cmd string that needs to be parsed. - * - * These functions are less specific version of the functions less the _buf - * These routines use the generic mms_par_input routine as the input routine - * used by the parser, thus if a user has a character string, they can - * use these routines instead of having to generate their own input routine - * and data structure that retains an index into the cmd string as the - * parser parses the cmd. - * - * Return Value: - * 0 If cmd parsed without errors. - * 1 If cmd parsed with errors. - * -1 If unable to allocate enough memory for parse tree. - * - */ - -int -mms_mmp_parse(mms_par_node_t **cmd_node, mms_list_t *msg_list, char *buf) -{ - - mms_pw_t *wka; - int rc = 0; - - (void) memset(msg_list, 0, sizeof (mms_list_t)); - mms_mmsp__flex_debug = 0; - mms_mmsp_debug = 0; - wka = mms_par_init_wka(cmd_node, msg_list, - mms_mmp_symtab, mms_num_mmsp_syms, - &mms_mmp_symtab_initialized); - (void) strlcpy(wka->par_wka_parser, "mms_mmp_parse", - sizeof (wka->par_wka_parser)); - if (wka == NULL) { - return (-1); - } - wka->par_wka_flags |= MMS_PW_DEPEND; /* Look in depend tab 1st */ - wka->par_wka_lock = &mmsp_mutex; - (void) mutex_lock(wka->par_wka_lock); - mms_mmsp_allow_quote(0); /* no quote in string */ - mms_mmsp_scan_string(buf); - /* LINTED assignment */ - if ((rc = yyparse(wka)) || wka->par_wka_err_count) { - rc = 1; - } - mms_mmsp_delete_buffer(); - if (*cmd_node != NULL) { - mms_pn_fini(*cmd_node); - } - (void) mutex_unlock(wka->par_wka_lock); - free(wka->par_wka_token[0]); - free(wka->par_wka_token[1]); - free(wka); - - return (rc); -} - -/* - * These are the DMPM commands - */ -extern mms_sym_t *mms_dmpm_symtab; -extern int mms_num_dmpm_syms; -static int mms_dmpm_symtab_initialized = 0; - -int -mms_dmpm_parse(mms_par_node_t **cmd_node, mms_list_t *msg_list, char *buf) -{ - mms_pw_t *wka; - int rc = 0; - - (void) memset(msg_list, 0, sizeof (mms_list_t)); - - mms_mmsp__flex_debug = 0; - mms_mmsp_debug = 0; - wka = mms_par_init_wka(cmd_node, msg_list, - mms_dmpm_symtab, mms_num_dmpm_syms, - &mms_dmpm_symtab_initialized); - (void) strlcpy(wka->par_wka_parser, "mms_dmpm_parse", - sizeof (wka->par_wka_parser)); - if (wka == NULL) { - return (-1); - } - wka->par_wka_flags |= MMS_PW_DEPEND; /* Look in depend tab 1st */ - wka->par_wka_lock = &mmsp_mutex; - (void) mutex_lock(wka->par_wka_lock); - mms_mmsp_allow_quote(0); /* no quote in string */ - mms_mmsp_scan_string(buf); - if (yyparse(wka) || wka->par_wka_err_count) { - rc = 1; - } - mms_mmsp_delete_buffer(); - mms_pn_fini(*cmd_node); - (void) mutex_unlock(wka->par_wka_lock); - free(wka->par_wka_token[0]); - free(wka->par_wka_token[1]); - free(wka); - return (rc); -} - -/* - * These are the DMPD commands - */ -extern mms_sym_t *mms_dmpd_symtab; - -extern int mms_num_dmpd_syms; -static int mms_dmpd_symtab_initialized = 0; - -int -mms_dmpd_parse(mms_par_node_t **cmd_node, mms_list_t *msg_list, char *buf) -{ - mms_pw_t *wka; - int rc = 0; - - (void) memset(msg_list, 0, sizeof (mms_list_t)); - - mms_mmsp__flex_debug = 0; - mms_mmsp_debug = 0; - wka = mms_par_init_wka(cmd_node, msg_list, - mms_dmpd_symtab, mms_num_dmpd_syms, - &mms_dmpd_symtab_initialized); - (void) strlcpy(wka->par_wka_parser, "mms_dmpd_parse", - sizeof (wka->par_wka_parser)); - if (wka == NULL) { - return (-1); - } - wka->par_wka_flags |= MMS_PW_DEPEND; /* Look in depend tab 1st */ - wka->par_wka_lock = &mmsp_mutex; - (void) mutex_lock(wka->par_wka_lock); - mms_mmsp_allow_quote(0); /* no quote in string */ - mms_mmsp_scan_string(buf); - if (yyparse(wka) || wka->par_wka_err_count) { - rc = 1; - } - mms_mmsp_delete_buffer(); - mms_pn_fini(*cmd_node); - (void) mutex_unlock(wka->par_wka_lock); - free(wka->par_wka_token[0]); - free(wka->par_wka_token[1]); - free(wka); - return (rc); -} - -/* - * These are the LMPM commands - */ -extern mms_sym_t *mms_lmpm_symtab; -extern int mms_num_lmpm_syms; -static int mms_lmpm_symtab_initialized = 0; - -int -mms_lmpm_parse(mms_par_node_t **cmd_node, mms_list_t *msg_list, char *buf) -{ - mms_pw_t *wka; - int rc = 0; - - (void) memset(msg_list, 0, sizeof (mms_list_t)); - mms_mmsp__flex_debug = 0; - mms_mmsp_debug = 0; - wka = mms_par_init_wka(cmd_node, msg_list, - mms_lmpm_symtab, mms_num_lmpm_syms, - &mms_lmpm_symtab_initialized); - (void) strlcpy(wka->par_wka_parser, "mms_lmpm_parse", - sizeof (wka->par_wka_parser)); - if (wka == NULL) { - return (-1); - } - wka->par_wka_flags |= MMS_PW_DEPEND; /* Look in depend tab 1st */ - wka->par_wka_lock = &mmsp_mutex; - (void) mutex_lock(wka->par_wka_lock); - mms_mmsp_allow_quote(0); /* no quote in string */ - mms_mmsp_scan_string(buf); - if (yyparse(wka) || wka->par_wka_err_count) { - rc = 1; - } - mms_mmsp_delete_buffer(); - mms_pn_fini(*cmd_node); - (void) mutex_unlock(wka->par_wka_lock); - free(wka->par_wka_token[0]); - free(wka->par_wka_token[1]); - free(wka); - return (rc); -} - -/* - * These are the LMPD commands - */ -extern mms_sym_t *mms_lmpl_symtab; -extern int mms_num_lmpl_syms; -static int mms_lmpl_symtab_initialized = 0; - -int -mms_lmpl_parse(mms_par_node_t **cmd_node, mms_list_t *msg_list, char *buf) -{ - mms_pw_t *wka; - int rc = 0; - - (void) memset(msg_list, 0, sizeof (mms_list_t)); - mms_mmsp__flex_debug = 0; - mms_mmsp_debug = 0; - wka = mms_par_init_wka(cmd_node, msg_list, - mms_lmpl_symtab, mms_num_lmpl_syms, - &mms_lmpl_symtab_initialized); - (void) strlcpy(wka->par_wka_parser, "mms_lmpl_parse", - sizeof (wka->par_wka_parser)); - if (wka == NULL) { - return (-1); - } - wka->par_wka_flags |= MMS_PW_DEPEND; /* Look in depend tab 1st */ - wka->par_wka_lock = &mmsp_mutex; - (void) mutex_lock(wka->par_wka_lock); - mms_mmsp_allow_quote(0); /* no quote in string */ - mms_mmsp_scan_string(buf); - if (yyparse(wka) || wka->par_wka_err_count) { - rc = 1; - } - mms_mmsp_delete_buffer(); - mms_pn_fini(*cmd_node); - (void) mutex_unlock(wka->par_wka_lock); - free(wka->par_wka_token[0]); - free(wka->par_wka_token[1]); - free(wka); - return (rc); -} diff --git a/usr/src/lib/mms/mms/common/mmsp_lex.l b/usr/src/lib/mms/mms/common/mmsp_lex.l deleted file mode 100644 index 4e9e7f1504..0000000000 --- a/usr/src/lib/mms/mms/common/mmsp_lex.l +++ /dev/null @@ -1,251 +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. - */ - - -/* - * A scanner for SAM Media Manager Protocol - */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <mmsp_yacc.h> - -#undef YYSTYPE -#define YYSTYPE mms_stype_t - -#include <mms_list.h> -#include <mms_sym.h> -#include <mms_parser.h> -#include <mms_par_impl.h> - -/* - * Redefine yylex to accept a pointer to the work area - */ -#undef YY_DECL -#define YY_DECL int yylex(YYSTYPE *lvalp, void *wka) - -#define SAVE_TOKEN(src) { \ - int index = (mms_pwka->par_wka_token_index++) % 2; \ - int len; \ - if ((len = strlen(src)) > MMS_PAR_MAX_TOKEN) { \ - len = MMS_PAR_MAX_TOKEN; \ - } \ - strncpy(mms_pwka->par_wka_token[index], src, len); \ - mms_pwka->par_wka_token[index][len] = '\0'; \ - lvalp->str = mms_pwka->par_wka_token[index]; \ - } -%} - -%option noyywrap -%option debug prefix = "mms_mmsp_" -%s allow_quote no_quote - -DIGIT ([+-]*[0-9]+) -DECNUM (([\+-]*[0-9]+)|([\+-]*[0-9]+)) -DECNUM_STR ((\"[\+-]*[0-9]+\")|('[\+-]*[0-9]+')) -WORD ([a-zA-Z][a-zA-Z0-9_]*) -STRING ((\"[^"]*\")|(\'[^']*\')) -BAD_STRING ((\"[^"]*)|(\'[^']*)) -NO_QUOTE_IN_STRING ((\"[^"']*\")|(\'[^"']*\')) -NO_QUOTE_BAD_STRING ((\"[^"']*\')|(\'[^'"]*\")) -RANGE (\.\.) -MMP_COMMENT (#[^\n]*) - - -%% - -{RANGE} { - SAVE_TOKEN(yytext); - mms_pwka->par_wka_col += yyleng; - return (RANGE); - } - -{DECNUM_STR} { - yytext[yyleng - 1] = '\0'; - if (yyleng - 2 > MMS_PAR_MAX_TOKEN) { - mms_par_error(mms_pwka, "token size exceeded " - "MMS_PAR_MAX_TOKEN"); - return (ERR_TOKEN_TOO_BIG); - } - SAVE_TOKEN(yytext + 1); - mms_pwka->par_wka_col += yyleng; - mms_pwka->par_wka_flags &= ~MMS_PW_KEYWORD; - return (NUMERIC_STR); - } - -{DECNUM} { - if (yyleng > MMS_PAR_MAX_TOKEN) { - mms_par_error(mms_pwka, "token size exceeded " - "MMS_PAR_MAX_TOKEN"); - return (ERR_TOKEN_TOO_BIG); - } - SAVE_TOKEN(yytext); - mms_pwka->par_wka_col += yyleng; - mms_pwka->par_wka_flags &= ~MMS_PW_KEYWORD; - return (NUMERIC); - } - -{WORD} { - mms_sym_t *syment = NULL; - if (yyleng > MMS_PAR_MAX_TOKEN) { - mms_par_error(mms_pwka, "token size exceeded " - "MMS_PAR_MAX_TOKEN"); - return (ERR_TOKEN_TOO_BIG); - } - SAVE_TOKEN(yytext); - mms_pwka->par_wka_col += yyleng; - mms_pwka->par_wka_flags &= ~MMS_PW_KEYWORD; - if (mms_pwka->par_wka_flags & MMS_PW_ERROR_CODE) { - /* Error code may be any word */ - mms_pwka->par_wka_flags &= ~MMS_PW_ERROR_CODE; - return (ERROR_CODE); - } - syment = mms_par_lookup_sym(yytext, mms_pwka); - if (syment == NULL) { - return (UNKNOWN_KEYWORD); - } - return (syment->sym_code); - } - -<no_quote>{NO_QUOTE_BAD_STRING} { - SAVE_TOKEN(yytext + 1); - mms_par_error(mms_pwka, - "single or double quote not allowed in string"); - mms_pwka->par_wka_flags &= ~MMS_PW_KEYWORD; - return (QUOTE_IN_STRING); - } - -<no_quote>{NO_QUOTE_IN_STRING} { - mms_sym_t *syment = NULL; - - /* Remove the enclosing quotes */ - yytext[yyleng - 1] = '\0'; - if (strlen(yytext + 1) > MMS_PAR_MAX_TOKEN) { - mms_par_error(mms_pwka, "token size exceeded " - "MMS_PAR_MAX_TOKEN"); - return (ERR_TOKEN_TOO_BIG); - } - SAVE_TOKEN(yytext + 1); - mms_pwka->par_wka_col += yyleng; - if (mms_pwka->par_wka_flags & MMS_PW_ERROR_CODE) { - /* Error code may be any string */ - mms_pwka->par_wka_flags &= ~MMS_PW_ERROR_CODE; - return (ERROR_CODE); - } - if (mms_pwka->par_wka_flags & MMS_PW_KEYWORD) { - /* Looking for a keyword or an objectname */ - mms_pwka->par_wka_flags &= ~MMS_PW_KEYWORD; - syment = mms_par_lookup_sym(lvalp->str, - mms_pwka); - if (syment != NULL) { - return (syment->sym_code); - } - } - return (STRING); - } - -<allow_quote>{STRING} { - mms_sym_t *syment = NULL; - - /* Remove the enclosing quotes */ - yytext[yyleng - 1] = '\0'; - if (strlen(yytext + 1) > MMS_PAR_MAX_TOKEN) { - mms_par_error(mms_pwka, "token size exceeded " - "MMS_PAR_MAX_TOKEN"); - return (ERR_TOKEN_TOO_BIG); - } - SAVE_TOKEN(yytext + 1); - mms_pwka->par_wka_col += yyleng; - if (mms_pwka->par_wka_flags & MMS_PW_ERROR_CODE) { - /* Error code may be any string */ - mms_pwka->par_wka_flags &= ~MMS_PW_ERROR_CODE; - return (ERROR_CODE); - } - if (mms_pwka->par_wka_flags & MMS_PW_KEYWORD) { - /* Looking for a keyword or an objectname */ - mms_pwka->par_wka_flags &= ~MMS_PW_KEYWORD; - syment = mms_par_lookup_sym(lvalp->str, - mms_pwka); - if (syment != NULL) { - return (syment->sym_code); - } - } - return (STRING); - } - -<allow_quote>{BAD_STRING} { - mms_par_error(mms_pwka, "No ending quote"); - mms_pwka->par_wka_flags &= ~MMS_PW_KEYWORD; - return (NO_ENDING_QUOTE); - } - -\xfe { - mms_par_error(mms_pwka, "Input function returned " - "too many characters"); - return (INCORRECT_INPUT_SIZE); - } - -" "|\t|\r { - /* discard white spaces */ - mms_pwka->par_wka_col++; - } - -\n { - mms_pwka->par_wka_line++; - mms_pwka->par_wka_col = 1; - } - -. { - mms_pwka->par_wka_col++; - SAVE_TOKEN(yytext); - return (yytext[0]); - } - - -%% - -static YY_BUFFER_STATE mmsp_buffer; - -void -mms_mmsp_scan_string(char *str) -{ - mmsp_buffer = yy_scan_string(str); -} - -void -mms_mmsp_delete_buffer() -{ - yy_delete_buffer(mmsp_buffer); -} - -void -mms_mmsp_allow_quote(int flag) -{ - if (flag) { - BEGIN(allow_quote); - } else { - BEGIN(no_quote); - } -} diff --git a/usr/src/lib/mms/mms/common/mmsp_yacc.y b/usr/src/lib/mms/mms/common/mmsp_yacc.y deleted file mode 100644 index a588e8e4b6..0000000000 --- a/usr/src/lib/mms/mms/common/mmsp_yacc.y +++ /dev/null @@ -1,8216 +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. - */ - - -/* - * A parser for MMS protocols - * This parser is called by "mms_parse()". - * - * - * NAME - * - * Parser for MMP. - * - * SYNOPSIS - * - * libpar.a - library of parser functions. - * - * #include <mms_list.h> - * #include <mms_parser.h> - * - * int mms_mmp_parse(mms_par_node_t **cmd_node, - * void (*input_func)(char *buf, int *result, int max, - * void *callback_parm), - * mms_list_t *err_list, - * void *callback_parm); - * - * void mms_pn_destroy(mms_par_node_t *cmd_node); - * - * void mms_pe_destroy(mms_list_t *err_list); - * - * - * DESCRIPTION - * - * mms_mmp_parse parses an MMP command in XML form and constructs a parse tree. - * - * - * mms_par_node_t **cmd_node - * cmd_node specify the mms_address of a pointer to the root of the - * parse tree. mms_mmp_parse will put the mms_address of the root node - * in pointer. - * - * After processing the parse tree, mms_pn_destroy() must be called - * to delete resources allocated where the command was parsed. - * - * void (*input_func)(char *buf, int *result, int max, void *callback_parm) - * specifies a function that the parser will call when it needs more - * input. input_func() should put additional data into buf. The number - * of bytes should not be more than the value in max. The number of - * bytes is returned in *result. callback_parm is the callback_parm passed - * to mms_mmp_parse. - * If there is no more data, *result should be set to 0. - * - * mms_list_t *err_list - * specifies the mms_address of a mms_list_t - * which holds a list of mms_par_err_t. - * The parser will add mms_par_err_t to the list when it discovers errors. - * The definition of mms_par_err_t is: - * - * typedef struct mms_par_err { - * mms_list_node_t pe_next; - * int pe_code; - * int pe_line; - * int pe_col; - * char *pe_token; - * char *pe_msg; - * } mms_par_err_t; - * - * pe_code has the following values: - * - * MMS_PE_NOMEM 1 - no memory - * MMS_PE_SYNTAX 2 - Syntax error - * MMS_PE_MAX_LEVEL 3 - max level reached - * MMS_PE_INVAL_CALLBACK 4 - bad return value - * MMS_PE_USERABORT 5 - User abort - * - * - * pe_line, pe_col and pe_token indicate the location - * and the token near where the error occured. - * - * mms_pe_msg is the error message. If the error was MMS_PE_NOMEM, - * mms_pe_msg may be NULL because the parser was unable to obtain - * memory to store the message. - * - * It is up to the caller to print and examine the mms_par_err_t. - * - * After the parse tree is processed, mms_pe_destroy() must be - * called to remove the resource allocated for errors. - * - * void *callback_parm - * specifies the arguement that should be passed to the callback function. - * If no callback arguement is needed or if no callback processing - * is required, specify NULL. - * - * Return value - * mms_mmp_parse returns 0 is ther is no error, returns 1 if the parser - * entered an error, the error code is in mms_par_err_t and returns -1 - * if mms_mmp_parse was unable to allocate memory for a work area. - * - * Parse Tree - * The parser discards the prolog of the XML file. The root of the - * parse tree is the root element of the XML file. Arguements to a - * command, clause and operations are stored in the arglist of the node. - * - */ - -#include <thread.h> -#include <synch.h> -#include <stdio.h> -#include <stdarg.h> -#include <stdlib.h> -#include <strings.h> -#include <sys/int_types.h> -#include <mms_sym.h> -#include "mms_list.h" -#include "mms_parser.h" -#include "mms_par_impl.h" - -#define YYPARSE_PARAM wka -#define YYLEX_PARAM wka -#define YYERROR_VERBOSE 1 - -#undef YYSTYPE -#define YYSTYPE mms_stype_t - -int yylex(YYSTYPE * lvalp, void *wka); - -#define mms_mmsp_error(msg) { \ - mms_pwka->par_wka_flags |= MMS_PW_ERROR; \ - mms_par_error(mms_pwka, msg); \ - if (mms_pwka->par_wka_err_count >= MMS_PE_MAX) { \ - mms_par_error(mms_pwka, "Too many errors"); \ - YYABORT; \ - } \ - } - -char *mms_mmp_validate_object(mms_par_node_t *recv); - -/* - * The symbol table will be sorted in ascending order when the parser - * is initialized. There is no need to add new symbols in any particular order. - */ - -mms_sym_t mms_sym_tab[] = { - "setpassword", SETPASSWORD, - "oldpassword", OLDPASSWORD, - "name", NAME, - "identity", IDENTITY, - "online", ONLINE, - "offline", OFFLINE, - "event", EVENT, - "newdrive", NEWDRIVE, - "newcartridge", NEWCARTRIDGE, - "request", REQUEST, - "cartridge", CARTRIDGE, - "volume", VOLUME, - "application", APPLICATION, - "global", GLOBAL, - "user", USER, - "direct", DIRECT, - "data", DATA, - "volumeid", VOLUMEID, - "filename", FILENAME, - "blocksize", BLOCKSIZE, - "retention", RETENTION, - "msgfile", MSGFILE, - "filesequence", FILESEQUENCE, - "bay", BAY, - "where", WHERE, - "CLEAN", CLEAN, - "signature", SIGNATURE, - "physicalunmount", PHYSICALUNMOUNT, - "unmount", UNMOUNT, - "from", FROM, - "to", TO, - "priority", PRIORITY, - "disconnected", DISCONNECTED, - "present", PRESENT, - "broken", BROKEN, - "response", RESPONSE, - "hello", HELLO, - "tag", TAG, - "alert", ALERT, - "warning", WARNING, - "who", WHO, - "operator", OPERATOR, - "notice", NOTICE, - "severity", SEVERITY, - "debug", DEBUG, - "log", LOG, - "emergency", EMERGENCY, - "critical", CRITICAL, - "information", INFORMATION, - "developer", DEVELOPER, - "get", GET, - "none", NONE, - "ansilabel", ANSILABEL, - "stale", STALE, - "drivehandle", DRIVEHANDLE, - "drive", DRIVE_CL, - "whichtask", WHICHTASK, - "partition", PARTITION, - "modename", MODENAME, - "caplist", CAPLIST, - "scope", SCOPE, - "bitformat", BITFORMAT, - "group", GROUP, - "cap", CAP, - "shapepriority", SHAPEPRIORITY, - "densitypriority", DENSITYPRIORITY, - "enable", ENABLE, - "disable", DISABLE, - "reserve", RESERVE, - "release", RELEASE, - "force", FORCE, - "restart", RESTART, - "nonewapps", NONEWAPPS, - "nonewmounts", NONEWMOUNTS, - "abortqueue", ABORTQUEUE, - "level", LEVEL, - "standard", STANDARD, - "administrator", ADMINISTRATOR, - "system", SYSTEM_PRIV, - "sort", SORT, - "slotgroup", SLOTGROUP, - "slot", SLOT, - "abort", ABORT, - "cartid", CARTID, - "cart", CART, - "all", ALL, - "fromslot", FROMSLOT, - "toslot", TOSLOT, - "partial", PARTIAL, - "full", FULL, - "AI", AI, - "APPLICATION", APPLICATION, - "BAY", BAY, - "CARTRIDGE", CARTRIDGE, - "CARTRIDGEGROUP", CARTRIDGEGROUP, - "CARTRIDGEGROUPAPPLICATION", CARTRIDGEGROUPAPPLICATION, - "CARTRIDGETYPE", CARTRIDGETYPE, - "CONNECTION", CONNECTION, - "LIBRARYACCESS", LIBRARYACCESS, - "DM", DM, - "DMBITFORMAT", DMBITFORMAT, - "DMBITFORMATTOKEN", DMBITFORMATTOKEN, - "DMCAPABILITY", DMCAPABILITY, - "DMCAPABILITYDEFAULTTOKEN", DMCAPABILITYDEFAULTTOKEN, - "DMCAPABILITYGROUP", DMCAPABILITYGROUP, - "DMCAPABILITYGROUPTOKEN", DMCAPABILITYGROUPTOKEN, - "DMCAPABILITYTOKEN", DMCAPABILITYTOKEN, - "DMP", DMP, - "DRIVE", DRIVE, - "DRIVECARTRIDGEACCESS", DRIVECARTRIDGEACCESS, - "DRIVECARTRIDGEERROR", DRIVECARTRIDGEERROR, - "DRIVEGROUP", DRIVEGROUP, - "DRIVEGROUPAPPLICATION", DRIVEGROUPAPPLICATION, - "FIRST", FIRST, - "LAST", LAST, - "LIBRARY", LIBRARY, - "LM", LM, - "LMP", LMP, - "MESSAGE", MESSAGE, - "MMP", MMP, - "MOUNTLOGICAL", MOUNTLOGICAL, - "MOUNTPHYSICAL", MOUNTPHYSICAL, - "NOTIFY", NOTIFY, - "PARTITION", PARTITION, - "REQUEST", REQUEST, - "SESSION", SESSION, - "SIDE", SIDE, - "SLOT", SLOT_OBJ, - "SLOTCONFIG", SLOTCONFIG, - "SLOTGROUP", SLOTGROUP, - "SLOTTYPE", SLOTTYPE, - "STALEHANDLE", STALEHANDLE, - "SYSTEM", SYSTEM, - "TASK", TASK, - "TASKCARTRIDGE", TASKCARTRIDGE, - "TASKDRIVE", TASKDRIVE, - "TASKLIBRARY", TASKLIBRARY, - "VOLUME", VOLUME, - "message", MESSAGE, - "accessmode", ACCESSMODE, - "and", AND, - "arg", ARG, - "attr", ATTR, - "bigendian", BIGENDIAN, - "block", BLOCK, - "blocking", BLOCKING, - "certificate", CERTIFICATE, - "client", CLIENT, - "false", FALSE, - "firstmount", FIRSTMOUNT, - "immediate", IMMEDIATE, - "instance", INSTANCE, - "isattr", ISATTR, - "isset", ISSET, - "notset", NOTSET, - "language", LANGUAGE, - "littleendian", LITTLEENDIAN, - "match", MATCH, - "name", NAME, - "namevalue", NAMEVALUE, - "newvolname", NEWVOLNAME, - "noattr", NOATTR, - "not", NOT, - "hosteq", HOSTEQ, - "hostne", HOSTNE, - "timeeq", TIMEEQ, - "timene", TIMENE, - "timelt", TIMELT, - "timele", TIMELE, - "timegt", TIMEGT, - "timege", TIMEGE, - "number", NUMBER, - "numeq", NUMEQ, - "numge", NUMGE, - "numgt", NUMGT, - "numhilo", NUMHILO, - "numle", NUMLE, - "numlohi", NUMLOHI, - "numlt", NUMLT, - "numne", NUMNE, - "object", OBJECT, - "action", ACTION, - "or", OR, - "order", ORDER, - "password", PASSWORD, - "range", RANGE, - "regex", REGEX, - "report", REPORT, - "reportmode", REPORTMODE, - "set", SET, - "streq", STREQ, - "strge", STRGE, - "strgt", STRGT, - "strhilo", STRHILO, - "strle", STRLE, - "strlohi", STRLOHI, - "strlt", STRLT, - "strne", STRNE, - "task", TASK, - "true", TRUE, - "type", TYPE, - "unique", UNIQUE, - "unset", UNSET, - "value", VALUE, - "version", VERSION, - "volname", VOLNAME, - "when", WHEN, - "servername", SERVERNAME, - "id", ID, - "cancelled", CANCELLED, - "canceled", CANCELED, - "success", SUCCESS, - "intermediate", INTERMEDIATE, - "loctext", LOCTEXT, - "text", TEXT, - "unacceptable", UNACCEPTABLE, - "arguments", ARGUMENTS, - "error", ERROR, - "accepted", ACCEPTED, - "attrlist", ATTRLIST, - "reqid", REQID, - "cpset", CPSET, - "cpunset", CPUNSET, - "cpreport", CPREPORT, - "cpreportmode", CPREPORTMODE, - "cptype", CPTYPE, - "receive", RECEIVE, - "volumeadd", VOLUMEADD, - "volumedelete", VOLUMEDELETE, - "dmup", DMUP, - "dmdown", DMDOWN, - "driveonline", DRIVEONLINE, - "driveoffline", DRIVEOFFLINE, - "lmup", LMUP, - "lmdown", LMDOWN, - "volumeinject", VOLUMEINJECT, - "volumeeject", VOLUMEEJECT, - "status", STATUS, - "librarycreate", LIBRARYCREATE, - "librarydelete", LIBRARYDELETE, - "drivedelete", DRIVEDELETE, - "LIBRARYLIST", LIBRARYLIST, - "DRIVELIST", DRIVELIST, - "CARTRIDGELIST", CARTRIDGELIST, - -#if 0 - /* - * These are Error codes - */ - "DM_E_ENABLED", ERROR_CODE, - "DM_E_COMMAND", ERROR_CODE, - "EOUTOFMEMORY", ERROR_CODE, - "DM_E_VIDMISMATCH", ERROR_CODE, - "DM_E_AGAIN", ERROR_CODE, - "DM_E_BADHANDLE", ERROR_CODE, - "DM_E_BADVAL", ERROR_CODE, - "DM_E_CMDARGS", ERROR_CODE, - "DM_E_DEVADMINCLT", ERROR_CODE, - "DM_E_DEVCMD", ERROR_CODE, - "DM_E_DEVCMDABORT", ERROR_CODE, - "DM_E_DEVCMDILLEGAL", ERROR_CODE, - "DM_E_DEVCMDTEMEOUT", ERROR_CODE, - "DM_E_DEVCOMMERR", ERROR_CODE, - "DM_E_DEVDET", ERROR_CODE, - "DM_E_DEVEMPTY", ERROR_CODE, - "DM_E_DEVFULL", ERROR_CODE, - "DM_E_DEVNORESPONSE", ERROR_CODE, - "DM_E_DEVOPERATOR", ERROR_CODE, - "DM_E_DEVOVERFLOW", ERROR_CODE, - "DM_E_DEVPERM", ERROR_CODE, - "DM_E_DEVPREV", ERROR_CODE, - "DM_E_DEVRESET", ERROR_CODE, - "DM_E_DEVSYNCHERR", ERROR_CODE, - "DM_E_DRIVE", ERROR_CODE, - "DM_E_HANDLEBUSY", ERROR_CODE, - "DM_E_HANDLEINUSE", ERROR_CODE, - "DM_E_INTERNAL", ERROR_CODE, - "DM_E_LIBRARY", ERROR_CODE, - "DM_E_MODE", ERROR_CODE, - "DM_E_NOCANC", ERROR_CODE, - "DM_E_NOCART", ERROR_CODE, - "DM_E_NOELT", ERROR_CODE, - "DM_E_NOEXISTHANDLE", ERROR_CODE, - "DM_E_NOID", ERROR_CODE, - "DM_E_NOTASK", ERROR_CODE, - "DM_E_READY", ERROR_CODE, - "DM_E_UNKNOWN", ERROR_CODE, - "EACCHANDLESTILLINUSE", ERROR_CODE, - "EAPPACCESSTOCART", ERROR_CODE, - "EAPPCARTNOACC", ERROR_CODE, - "EAPPDMDIFFHOSTS", ERROR_CODE, - "EAPPDRVNOACC", ERROR_CODE, - "EAPPHASNOVOLS", ERROR_CODE, - "EAPPLIBNOACCESS", ERROR_CODE, - "EAPPMOUNTNOTIUSSUED", ERROR_CODE, - "EAPPSESS", ERROR_CODE, - "EAPPTASKNOTISSUED", ERROR_CODE, - "EAUTOCREATEFAILED", ERROR_CODE, - "ECANCELLED", ERROR_CODE, - "ECANCELNUMRANGEDISALLOWED", ERROR_CODE, - "ECANTCANCEL", ERROR_CODE, - "ECARTDRVNOTCOMPATIBLE", ERROR_CODE, - "ECARTDRVSLOTMISMATCH", ERROR_CODE, - "ECARTINSLOT", ERROR_CODE, - "ECARTINUSE", ERROR_CODE, - "ECARTMOUNTNOTINVOLVED", ERROR_CODE, - "ECARTNOACC", ERROR_CODE, - "ECARTNOCGA", ERROR_CODE, - "ECARTNOFREEPARTS", ERROR_CODE, - "ECARTNOTINSLOT", ERROR_CODE, - "ECARTNOTLOCATED", ERROR_CODE, - "ECARTNOTOWNEDBYAP", ERROR_CODE, - "ECARTNOTOWNEDBYAPP", ERROR_CODE, - "ECLAUSEMISSING", ERROR_CODE, - "ECLAUSEMUTEX", ERROR_CODE, - "ECLAUSENEEDSARG", ERROR_CODE, - "ECLAUSENOPRIVILEGE", ERROR_CODE, - "ECOMMANDBEINGSUBMITTED", ERROR_CODE, - "ECOMMANDFAILED", ERROR_CODE, - "ECOMMANDNOPRIVILEGE", ERROR_CODE, - "ECONNDELETE", ERROR_CODE, - "EDMCONFIG", ERROR_CODE, - "EDMNOTCONNECTED", ERROR_CODE, - "EDMNOTREADY", ERROR_CODE, - "EDMPATTACH", ERROR_CODE, - "EDMPDETACH", ERROR_CODE, - "EDMPLOAD", ERROR_CODE, - "EDMPUNLOAD", ERROR_CODE, - "EDMRECOVERING", ERROR_CODE, - "EDMSTATE", ERROR_CODE, - "EDMSTILLBOOTING", ERROR_CODE, - "EDRIVEEMPTY", ERROR_CODE, - "EDRIVESET", ERROR_CODE, - "EDRVBROKEN", ERROR_CODE, - "EDRVCARTNOTREADABLE", ERROR_CODE, - "EDRVDISABLEDPERM", ERROR_CODE, - "EDRVDISABLEDTEMP", ERROR_CODE, - "EDRVEJECTING", ERROR_CODE, - "EDRVINUSE", ERROR_CODE, - "EDRVLOADED", ERROR_CODE, - "EDRVMOUNTNOTINVOLVED", ERROR_CODE, - "EDRVNODMCONFIGURED", ERROR_CODE, - "EDRVNOTINBAY", ERROR_CODE, - "EDRVNOTLOADED", ERROR_CODE, - "EDRVSESSNOUSE", ERROR_CODE, - "EDRVTASKNOTREQUIRED", ERROR_CODE, - "EDRVUNKNOWN", ERROR_CODE, - "EHANDLEINUSE", ERROR_CODE, - "EHANDLENOTDESTROY", ERROR_CODE, - "EINVALCLAUSEARG", ERROR_CODE, - "ELANGNOTSUPPORTED", ERROR_CODE, - "ELIBBROKEN", ERROR_CODE, - "ELIBCARTNOCONTAINMENT", ERROR_CODE, - "ELIBDISABLEDPERM", ERROR_CODE, - "ELIBDISABLEDTEMP", ERROR_CODE, - "ELIBDRVNOCONTAINMENT", ERROR_CODE, - "ELIBINUSE", ERROR_CODE, - "ELIBNOLMCONFIGURED", ERROR_CODE, - "ELMADD", ERROR_CODE, - "ELMCARTBAYNOTACCESS", ERROR_CODE, - "ELMCONFIG", ERROR_CODE, - "ELMDMCOMMUNICATION", ERROR_CODE, - "ELMDRVBAYNOTACCESS", ERROR_CODE, - "ELMDRVNOTACCESS", ERROR_CODE, - "ELMNOTCONNECTED", ERROR_CODE, - "ELMNOTREADY", ERROR_CODE, - "ELMPMOUNT", ERROR_CODE, - "ELMPORTNOTREADY", ERROR_CODE, - "ELMPUNMOUNT", ERROR_CODE, - "ELMSLOTNOTACCESS", ERROR_CODE, - "ELMSTATE", ERROR_CODE, - "ELMSTILLBOOTING", ERROR_CODE, - "EMLOGCREATE", ERROR_CODE, - "EMLOGDELETE", ERROR_CODE, - "EMNTCARTPRES", ERROR_CODE, - "EMOUNTLIBNOTINVOLVED", ERROR_CODE, - "EMPCREATE", ERROR_CODE, - "EMPHYSDEL", ERROR_CODE, - "ENEWVOLEXISTS", ERROR_CODE, - "ENEWVOLNAMECOUNT", ERROR_CODE, - "ENOALLOCATABLEPARTS", ERROR_CODE, - "ENOCANCELLABLETASKS", ERROR_CODE, - "ENOCARTRIDGE", ERROR_CODE, - "ENOINSTANCE", ERROR_CODE, - "ENOMATCH", ERROR_CODE, - "ENOMEMORY", ERROR_CODE, - "ENOPRIVCHANGE", ERROR_CODE, - "ENOSESSION", ERROR_CODE, - "ENOSLOT", ERROR_CODE, - "ENOSOLUTIONS", ERROR_CODE, - "ENOSUCHCART", ERROR_CODE, - "ENOSUCHLANG", ERROR_CODE, - "ENOSUCHPRIV", ERROR_CODE, - "ENOSUCHREQ", ERROR_CODE, - "ENOSUCHSIDE", ERROR_CODE, - "ENOSUCHSORT", ERROR_CODE, - "ENOSUCHVOLUME", ERROR_CODE, - "EOBJATTRMODDISALLOWED", ERROR_CODE, - "EOBJATTRTOOMANY", ERROR_CODE, - "EOBJATTRVALNOTENUM", ERROR_CODE, - "EOBJATTRVALNOTNUM", ERROR_CODE, - "EOBJATTRVALNULLSTRING", ERROR_CODE, - "EOBJCREATEDISALLOWED", ERROR_CODE, - "EOBJCREATEINVALREPORT", ERROR_CODE, - "EOBJCREATESYSATTRREQUIRED", ERROR_CODE, - "EOBJDELDISALLOWED", ERROR_CODE, - "EOBJDELNUMRANGEDISALLOWED", ERROR_CODE, - "EOBJDEPENDNOEXIST", ERROR_CODE, - "EOBJKEYCHANGE", ERROR_CODE, - "EOBJKEYNOTUNIQUE", ERROR_CODE, - "EOBJNOTVISIBLE", ERROR_CODE, - "EOBJREFERENCES", ERROR_CODE, - "EOBJSYSATTRCREATEDISALLOWED", ERROR_CODE, - "EOBJSYSATTRMODDISALLOWED", ERROR_CODE, - "EOBJSYSATTRMODNOPRIV", ERROR_CODE, - "EOBJUSRATTRCREATEDISALLOWED", ERROR_CODE, - "EOBJUSRATTRCREATENOPRIV", ERROR_CODE, - "EPARTNOTALLOCABLE", ERROR_CODE, - "EPRIVCHANGEDISALLOWED", ERROR_CODE, - "ERENAMEDVOLEXISTS", ERROR_CODE, - "EREPLACEFAILED", ERROR_CODE, - "EREQACCEPTEDBYDIFFSESS", ERROR_CODE, - "EREQSTATECHANGEFAILED", ERROR_CODE, - "EREQUESTALREADYACCEPTED", ERROR_CODE, - "EREQUESTALREADYSATISFIED", ERROR_CODE, - "EREQUESTNOTACCEPTED", ERROR_CODE, - "ESESSCARTNOTUSED", ERROR_CODE, - "ESESSLIBNOTUSED", ERROR_CODE, - "ESESSMNTNOTISSUED", ERROR_CODE, - "ESESSTASKNOISSUED", ERROR_CODE, - "ESHUTDOWNFAILED", ERROR_CODE, - "ESLOTNOTOCCUPIED", ERROR_CODE, - "ESLOTOCCUPIED", ERROR_CODE, - "ESORTNOTSUPPORTED", ERROR_CODE, - "ESYSATTRUNSETDISALLOWED", ERROR_CODE, - "ESYSTEM", ERROR_CODE, - "ETABLELIMIT", ERROR_CODE, - "ETASKCARTNOUSE", ERROR_CODE, - "ETASKLIBNOUSE", ERROR_CODE, - "ETASKMNTNOUSE", ERROR_CODE, - "ETMPUNAVAIL", ERROR_CODE, - "ETMPINUSE", ERROR_CODE, - "ETOOMANY", ERROR_CODE, - "ETOOMANYCLAUSES", ERROR_CODE, - "ETRANSACTIONFAILED", ERROR_CODE, - "EUNKNOWNERROR", ERROR_CODE, - "EVOLEXISTS", ERROR_CODE, - "EVOLINUSE", ERROR_CODE, - "EVOLNAMEREWRITE", ERROR_CODE, - "EVOLNOTOWNEDBYAPP", ERROR_CODE, - "EWOULDDEADLOCK", ERROR_CODE, - "LM_E_ACCESS", ERROR_CODE, - "LM_E_AGAIN", ERROR_CODE, - "LM_E_BADVAL", ERROR_CODE, - "LM_E_CMDARGS", ERROR_CODE, - "LM_E_DESTFULL", ERROR_CODE, - "LM_E_DEVADMINCLT", ERROR_CODE, - "LM_E_DEVCMD", ERROR_CODE, - "LM_E_DEVCMDABORT", ERROR_CODE, - "LM_E_DEVCMDILLEGAL", ERROR_CODE, - "LM_E_DEVCMDTEMEOUT", ERROR_CODE, - "LM_E_DEVCOMMERR", ERROR_CODE, - "LM_E_DEVEJ", ERROR_CODE, - "LM_E_DEVINJ", ERROR_CODE, - "LM_E_DEVNORESPONSE", ERROR_CODE, - "LM_E_DEVOPERATOR", ERROR_CODE, - "LM_E_DEVOVERFLOW", ERROR_CODE, - "LM_E_DEVPREM", ERROR_CODE, - "LM_E_DEVPREV", ERROR_CODE, - "LM_E_DEVRESET", ERROR_CODE, - "LM_E_DEVSYNCHERR", ERROR_CODE, - "LM_E_DIRECTION", ERROR_CODE, - "LM_E_INTERNAL", ERROR_CODE, - "LM_E_LIBRARY", ERROR_CODE, - "LM_E_MOVE", ERROR_CODE, - "LM_E_NOCANC", ERROR_CODE, - "LM_E_NODRIVE", ERROR_CODE, - "LM_E_NOELT", ERROR_CODE, - "LM_E_NOPCL", ERROR_CODE, - "LM_E_NOSLOT", ERROR_CODE, - "LM_E_NOTASK", ERROR_CODE, - "LM_E_PCL", ERROR_CODE, - "LM_E_PORT", ERROR_CODE, - "LM_E_PORTDIR", ERROR_CODE, - "LM_E_READY", ERROR_CODE, - "LM_E_SCREMPTY", ERROR_CODE, - "LM_E_SHAPE", ERROR_CODE, - "LM_E_SLOTGROUP", ERROR_CODE, - "LM_E_UNKNOWN", ERROR_CODE, - "LM_E_SUBCMDFAILED", ERROR_CODE, - "LM_E_CONFIG", ERROR_CODE, - "MM_E_AGAIN", ERROR_CODE, - "MM_E_BADVAL", ERROR_CODE, - "MM_E_CMDARGS", ERROR_CODE, - "MM_E_DEVCMD", ERROR_CODE, - "MM_E_DEVCMDABORT", ERROR_CODE, - "MM_E_DEVCMDILLEGAL", ERROR_CODE, - "MM_E_DEVCMDTEMEOUT", ERROR_CODE, - "MM_E_DEVOVERFLOW", ERROR_CODE, - "MM_E_DEVPREM", ERROR_CODE, - "MM_E_DEVPREV", ERROR_CODE, - "MM_E_INTERNAL", ERROR_CODE, - "MM_E_NOELT", ERROR_CODE, - - - - - - - /* - * Sun MM System vendor-defined error codes. - */ - "EDATABASE", ERROR_CODE, - "ENOTFOUND", ERROR_CODE, - "ESYNTAX", ERROR_CODE, - "EPRIVNOTMMSADMIN", ERROR_CODE, - "MM_E_NOTASK", ERROR_CODE, - "MM_E_TOOMANYTASKS", ERROR_CODE, - "ENOSUCHPCL", ERROR_CODE, - "ENOTENOUGHPARTITIONS", ERROR_CODE, - "EPARTITIONSTATECHANGE", ERROR_CODE, - "ECARTRIDGESTATECHANGE", ERROR_CODE, - "ESYSTEMCONFIGCHANGE", ERROR_CODE, - "ENOTCONNECTED", ERROR_CODE, - "ECOMMUNICATION", ERROR_CODE, - - /* New error codes for library/drive online */ - "ELIBRARYNOEXIST", ERROR_CODE, - "ELMNOEXIST", ERROR_CODE, - "ELIBALREADYONLINE", ERROR_CODE, - "ELIBALREADYOFFLINE", ERROR_CODE, - "EDRIVENOEXIST", ERROR_CODE, - "EDRIVEALREADYONLINE", ERROR_CODE, - "EDRIVEALREADYOFFLINE", ERROR_CODE, - "EDRIVEONLINE", ERROR_CODE, - "EDRIVEOFFLINE", ERROR_CODE, - "ELIBRARYONLINE", ERROR_CODE, - "ELIBRARYOFFLINE", ERROR_CODE, - "ELIBRARYDEPENDS", ERROR_CODE, -#endif - /* - * These are error classes - */ - "compat", COMPAT, - "config", CONFIG, - "exist", EXIST, - "explicit", EXPLICIT, - "internal", INTERNAL, - "invalid", INVALID, - "permpriv", PERMPRIV, - "retry", RETRY, - "subop", SUBOP, - "state", STATE, - "LM_C_INVALID", LM_C_INVALID, - "LM_C_COMMAND", LM_C_COMMAND, - "DM_C_INVALID", DM_C_INVALID, - "DM_C_COMMAND", DM_C_COMMAND, - "MM_C_INVALID", MM_C_INVALID, - "MM_C_MANAGEMENT", MM_C_MANAGEMENT, -}; -mms_sym_t *mms_symtab = mms_sym_tab; -int mms_num_syms = sizeof (mms_sym_tab) / sizeof (mms_sym_t); - -/* - * The following is the symbols for all the MMP commands. - */ -mms_sym_t mms_mmp_sym_tab[] = { - "request", MMP_REQUEST, - "message", MMP_MESSAGE, - "library", LIBRARY, - "drive", DRIVE, - "notify", NOTIFY_CMD, - "respond", RESPOND, - "accept", ACCEPT, - "allocate", ALLOCATE, - "attribute", ATTRIBUTE, - "show", SHOW, - "begin", BEGIN_CMD, - "cancel", CANCEL, - "add", ADD, - "change", CHANGE, - "cpattribute", CPATTRIBUTE, - "cpreset", CPRESET, - "cpstart", CPSTART, - "cpexit", CPEXIT, - "cpscan", CPSCAN, - "cpshow", CPSHOW, - "create", CREATE, - "deallocate", DEALLOCATE, - "delete", DELETE, - "eject", EJECT, - "end", END, - "goodbye", GOODBYE, - "inject", INJECT, - "locale", LOCALE, - "mount", MMP_MOUNT, - "move", MOVE, - "privilege", PRIVILEGE, - "release", RELEASE, - "rename", RENAME, - "shutdown", SHUTDOWN, - "unwelcome", MMS_UNWELCOME, - "welcome", MMS_WELCOME, -}; -mms_sym_t *mms_mmp_symtab = mms_mmp_sym_tab; -int mms_num_mmsp_syms = sizeof (mms_mmp_sym_tab) / sizeof (mms_sym_t); - -/* - * These are the DMPM commands - */ -static mms_sym_t mms_dmpm_sym_tab[] = { - "unload", UNLOAD, - "reset", XMPM_RESET, - "private", XMPM_PRIVATE, - "load", LOAD, - "exit", EXIT, - "identify", IDENTIFY, - "detach", DETACH, - "cancel", XMPX_CANCEL, - "activate", ACTIVATE, - "attach", ATTACH, - "event", EVENT, -}; -mms_sym_t *mms_dmpm_symtab = mms_dmpm_sym_tab; -int mms_num_dmpm_syms = sizeof (mms_dmpm_sym_tab) / sizeof (mms_sym_t); - -/* - * These are the DMPD commands - */ -mms_sym_t mms_dmpd_sym_tab[] = { - "notify", NOTIFY_CMD, - "config", DMPD_CONFIG, - "message", XMPD_MESSAGE, - "private", DMPD_PRIVATE, - "ready", XMPD_READY, - "request", DMPD_REQUEST, - "cancel", XMPX_CANCEL, - "shutdown", SHUTDOWN, - "attribute", ATTRIBUTE, - "create", CREATE, - "show", SHOW, -}; -mms_sym_t *mms_dmpd_symtab = mms_dmpd_sym_tab; -int mms_num_dmpd_syms = sizeof (mms_dmpd_sym_tab) / sizeof (mms_sym_t); - -/* - * These are the LMPM commands - */ -mms_sym_t mms_lmpm_sym_tab[] = { - "activate", LMPM_ACTIVATE, - "barrier", BARRIER, - "eject", LMPM_EJECT, - "exit", LMPM_EXIT, - "inject", LMPM_INJECT, - "mount", LMPM_MOUNT, - "move", LMPM_MOVE, - "private", XMPM_PRIVATE, - "reset", XMPM_RESET, - "scan", LMPM_SCAN, - "unmount", LMPM_UNMOUNT, - "cancel", XMPX_CANCEL, - "event", EVENT, -}; -mms_sym_t *mms_lmpm_symtab = mms_lmpm_sym_tab; -int mms_num_lmpm_syms = sizeof (mms_lmpm_sym_tab) / sizeof (mms_sym_t); - -/* - * These are the LMPD commands - */ -mms_sym_t mms_lmpl_sym_tab[] = { - "notify", NOTIFY_CMD, - "cancel", XMPX_CANCEL, - "config", LMPD_CONFIG, - "freeslots", FREESLOTS, - "delslots", DELSLOTS, - "in", IN, - "out", OUT, - "both", BOTH, - "perf", PERF, - "message", XMPD_MESSAGE, - "private", LMPD_PRIVATE, - "ready", XMPD_READY, - "request", LMPD_REQUEST, - "shutdown", SHUTDOWN, - "attribute", ATTRIBUTE, - "show", SHOW, -}; -mms_sym_t *mms_lmpl_symtab = mms_lmpl_sym_tab; -int mms_num_lmpl_syms = sizeof (mms_lmpl_sym_tab) / sizeof (mms_sym_t); - -uchar_t mms_tokflags[(TOKEN_MAX - TOKEN_MIN ) / 8 + 1]; -uchar_t *mms_token_flags = mms_tokflags; - -%} - -%name-prefix = "mms_mmsp_" -%defines -%pure_parser - -%token TOKEN_MIN - -%token STRING NUMERIC SLASH_GT LT_SLASH ERR_TOKEN_TOO_BIG NO_ENDING_QUOTE -%token NUMERIC_STR -%token MMS_EOF INCORRECT_INPUT_SIZE NO_MEM -%token MMP_MOUNT DMPM_MOUNT UNKNOWN_KEYWORD - -%token ERROR_CLASS ERROR_CODE -%token AI APPLICATION BAY CARTRIDGE CARTRIDGEGROUP CARTRIDGEGROUPAPPLICATION -%token CARTRIDGETYPE CONNECTION DM DMBITFORMAT DMBITFORMATTOKEN DMCAPABILITY -%token DMCAPABILITYDEFAULTTOKEN DMCAPABILITYGROUP DMCAPABILITYGROUPTOKEN -%token DMCAPABILITYTOKEN DMP DRIVE DRIVECARTRIDGEACCESS DRIVEGROUP -%token DRIVEGROUPAPPLICATION FIRST LAST LIBRARY LM LMP MESSAGE MMP -%token MOUNTLOGICAL MOUNTPHYSICAL PARTITION REQUEST SESSION SIDE -%token SLOT_OBJ SLOTCONFIG SLOTGROUP SLOTTYPE STALEHANDLE SYSTEM -%token TASK TASKCARTRIDGE TASKDRIVE TASKLIBRARY VOLUME ACCESSMODE -%token ALLOCATE AND ARG ATTR ATTRIBUTE BEGIN_CMD -%token BIGENDIAN BLOCK BLOCKING CERTIFICATE CLIENT -%token CREATE DELETE FALSE FIRSTMOUNT HELLO TAG IMMEDIATE -%token INSTANCE ISATTR LANGUAGE LITTLEENDIAN MATCH -%token NAMEVALUE NEWVOLNAME NOATTR -%token HOSTEQ HOSTNE TIMEEQ TIMENE TIMELT TIMELE TIMEGT TIMEGE -%token NOREWIND NOT NUMBER NUMEQ NUMGE NUMGT -%token NUMHILO NUMLE NUMLOHI NUMLT NUMNE OBJECT -%token OR ORDER PASSWORD RANGE READONLY READWRITE -%token REGEX RENAME REPORT REPORTMODE REWIND SET -%token SHOW STREQ STRGE STRGT STRHILO STRLE -%token STRLOHI STRLT STRNE TRUE TYPE -%token UNIQUE UNSET VALUE VERSION VOLNAME WHEN -%token MMS_WELCOME SERVERNAME MMS_UNWELCOME XMPX_CANCEL -%token ID CANCELLED CANCELED SUCCESS INTERMEDIATE LOCTEXT RESPONSE -%token TEXT UNACCEPTABLE ACTION ADD CHANGE -%token ARGUMENTS ERROR ACCEPTED ATTRLIST ACCEPT REQID CANCEL RESPOND -%token CPSET CPUNSET CPATTRIBUTE CPREPORT CPREPORTMODE CPTYPE -%token CPRESET CPEXIT CPSTART PARTIAL FULL XMPM_PRIVATE -%token ALL FROMSLOT TOSLOT CPSCAN CPSHOW DEALLOCATE EJECT CARTID CART -%token ABORT END INJECT GOODBYE SORT LOCALE MOVE PRIVILEGE STANDARD -%token ADMINISTRATOR LEVEL SYSTEM_PRIV RELEASE RESERVE USER -%token SHUTDOWN FORCE RESTART NONEWAPPS NONEWMOUNTS ABORTQUEUE -%token ACTIVATE ENABLE DISABLE UNMOUNT NOTIFY QUOTE_IN_STRING -%token DMPD_CONFIG SCOPE BITFORMAT GROUP CAP CAPLIST ATTACH MODENAME -%token WHICHTASK DETACH STALE DRIVEHANDLE EXIT -%token IDENTIFY NONE ANSILABEL LOAD GET PRIVATE RESET UNLOAD -%token ALERT WARNING WHO OPERATOR NOTICE SEVERITY DEBUG LOG EMERGENCY -%token CRITICAL INFORMATION DEVELOPER READY XMPD_MESSAGE DMPD_PRIVATE -%token XMPD_READY DISCONNECTED BROKEN PRIORITY DMPD_REQUEST -%token LMPM_ACTIVATE BARRIER LMPM_EJECT SLOT LMPM_EXIT STATE EVENT -%token LMPM_INJECT DRIVE_CL LMPM_MOVE TO FROM LMPM_MOUNT XMPM_RESET -%token LMPM_SCAN SIGNATURE PHYSICALUNMOUNT CLEAN LMPM_UNMOUNT LMPD_REQUEST -%token FREESLOTS DELSLOTS IN OUT BOTH PERF LMPD_CONFIG LMPD_PRIVATE WHERE -%token CAPABILITY FILENAME FILESEQUENCE BLOCKSIZE VOLUMEID UID GID -%token NEWDRIVE NEWCARTRIDGE NOTIFY_CMD RECEIVE GLOBAL -%token PRESENT ONLINE OFFLINE SHAPEPRIORITY DENSITYPRIORITY -%token ISSET NOTSET IDENTITY MMP_REQUEST MMP_MESSAGE NAME -%token VOLUMEADD VOLUMEDELETE RETENTION MSGFILE SETPASSWORD OLDPASSWORD -%token DMUP DMDOWN DRIVEONLINE DRIVEOFFLINE DRIVECARTRIDGEERROR -%token LMUP LMDOWN VOLUMEINJECT VOLUMEEJECT STATUS LIBRARYCREATE LIBRARYDELETE -%token DRIVEDELETE DIRECT DATA LIBRARYLIST DRIVELIST CARTRIDGELIST -%token LIBRARYACCESS - -%token LM_C_INVALID LM_C_COMMAND MM_C_INVALID MM_C_MANAGEMENT -%token DM_C_INVALID DM_C_COMMAND - -%token COMPAT -%token CONFIG -%token EXIST -%token EXPLICIT -%token INTERNAL -%token INVALID -%token PERMPRIV -%token RETRY -%token SUBOP - -%token HAVE_STR_ARG HAVE_SUB_CLAUSE TO_MATCH - - - - -%token TOKEN_MAX - - -%% - -command : { - memset(mms_tokflags, 0, sizeof (mms_tokflags)); - } - cmd - { - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -cmd /* MMP commands */ - : accept_cmd - | allocate_cmd - | attribute_cmd - | begin_cmd - | cancel_cmd - | cpattribute_cmd - | cpreset_cmd - | cpexit_cmd - | cpstart_cmd - | cpscan_cmd - | cpshow_cmd - | create_cmd - | deallocate_cmd - | delete_cmd - | drive_cmd - | eject_cmd - | end_cmd - | event_cmd - | goodbye_cmd - | hello_cmd - | identity_cmd - | inject_cmd - | internal_cmd - | library_cmd - | locale_cmd - | mmp_message_cmd - | mmp_mount_cmd - | mmp_request_cmd - | move_cmd - | notify_cmd - | privilege_cmd - | release_cmd - | rename_cmd - | respond_cmd - | response_cmd - | setpassword_cmd - | show_cmd - | shutdown_cmd - | unmount_cmd - | unwelcome_cmd - | welcome_cmd - | direct_cmd - /* - * XMP/M commands - * Commands common to both DMP/M and LMP/M - */ - | xmpm_private_cmd - | xmpm_reset_cmd - /* - * XMP/D commands - * Commands common to both DMP/D and LMP/D - */ - | xmpd_message_cmd - | xmpd_ready_cmd - /* - * XMP/X commands - * Commands common to dmpm, dmpd, lmpm and lmpd - */ - | xmpx_cancel_cmd - /* - * DMP/M commands - */ - | dmpm_activate_cmd - | dmpm_attach_cmd - | dmpm_detach_cmd - | dmpm_exit_cmd - | dmpm_identify_cmd - | dmpm_load_cmd - | dmpm_unload_cmd - /* - * DMP/D commands - */ - | dmpd_config_cmd - | dmpd_private_cmd - | dmpd_request_cmd - /* - * LMP/M commands - */ - | lmpm_activate_cmd - | lmpm_barrier_cmd - | lmpm_eject_cmd - | lmpm_exit_cmd - | lmpm_inject_cmd - | lmpm_mount_cmd - | lmpm_move_cmd - | lmpm_scan_cmd - | lmpm_unmount_cmd - /* - * LMP/D commands - */ - | lmpl_config_cmd - | lmpl_private_cmd - | lmpl_request_cmd - - ; - -setpassword_cmd - : SETPASSWORD - { - MMS_PAR_ALLOC_NODE($$.nodep, "setpassword", MMS_PN_CMD); - } - setpassword_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(PASSWORD) == 0) { - yyerror("a password clause is required"); - } - if (MMS_PAR_CHK_FLAG(OLDPASSWORD) && - MMS_PAR_CHK_FLAG(NAME)) { - yyerror("oldpassword and name clauses are " - "incompatible"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -setpassword_arg_list - : setpassword_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | setpassword_arg_list setpassword_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -setpassword_arg - : task_clause - | passwd_clause - | oldpassword_clause - | name_clause - ; - -oldpassword_clause - : OLDPASSWORD - { - MMS_PAR_CHK_DUP(OLDPASSWORD); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "oldpassword", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -passwd_clause - : PASSWORD - { - MMS_PAR_CHK_DUP(PASSWORD); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "password", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -name_clause - : NAME - { - MMS_PAR_CHK_DUP(NAME); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "name", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -identity_cmd - : IDENTITY - { - MMS_PAR_ALLOC_NODE($$.nodep, "identity", MMS_PN_CMD); - } - task_clause ';' - { - $$.nodep = $2.nodep; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -direct_cmd - : DIRECT - { - MMS_PAR_ALLOC_NODE($$.nodep, "direct", MMS_PN_CMD); - } - direct_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(TO) == 0) { - yyerror("a to clause is required"); - } - if (MMS_PAR_CHK_FLAG(DATA) == 0) { - yyerror("a data clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -direct_arg_list - : direct_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | direct_arg_list direct_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -direct_arg - : task_clause - | direct_to_clause - | direct_data_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -direct_to_clause - : TO - { - MMS_PAR_CHK_DUP(TO); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "to", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -direct_data_clause - : DATA - { - MMS_PAR_CHK_DUP(DATA); - } - '[' str_arg_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "data", MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $4.listp); - } - ; - -drive_cmd - : DRIVE - { - MMS_PAR_ALLOC_NODE($$.nodep, "drive", MMS_PN_CMD); - } - drive_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(ONLINE) + - MMS_PAR_CHK_FLAG(OFFLINE) == 0) { - yyerror("One of online or offline clauses " - "is required"); - } - } - ; - -drive_arg_list - : drive_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | drive_arg_list drive_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -drive_arg - : task_clause - | online_clause - | offline_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -online_clause - : ONLINE - { - MMS_PAR_CHK_DUP(ONLINE); - if (MMS_PAR_CHK_FLAG(OFFLINE)) { - yyerror("online and offline clauses are " - "imcompatible"); - } - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "online", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -offline_clause - : OFFLINE - { - MMS_PAR_CHK_DUP(OFFLINE); - if (MMS_PAR_CHK_FLAG(ONLINE)) { - yyerror("online and offline clauses are " - "imcompatible"); - } - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "offline", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -library_cmd - : LIBRARY - { - MMS_PAR_ALLOC_NODE($$.nodep, "library", MMS_PN_CMD); - } - library_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(ONLINE) + - MMS_PAR_CHK_FLAG(OFFLINE) == 0) { - yyerror("one of online or offline clauses " - "is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -library_arg_list - : library_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | library_arg_list library_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -library_arg - : task_clause - | lib_online_clause - | lib_offline_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -lib_online_clause - : ONLINE - { - MMS_PAR_CHK_DUP(ONLINE); - if (MMS_PAR_CHK_FLAG(OFFLINE)) { - yyerror("online and offline clauses are " - "imcompatible"); - } - } - '[' str_arg opt_str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "online", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - } - ; - -lib_offline_clause - : OFFLINE - { - MMS_PAR_CHK_DUP(OFFLINE); - if (MMS_PAR_CHK_FLAG(ONLINE)) { - yyerror("online and offline clauses are " - "imcompatible"); - } - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "offline", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -notify_cmd - : NOTIFY_CMD - { - MMS_PAR_ALLOC_NODE($$.nodep, "notify", MMS_PN_CMD); - } - notify_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(HAVE_STR_ARG) && - MMS_PAR_CHK_FLAG(HAVE_SUB_CLAUSE)) { - yyerror("cannot have old style and new style " - "receive or cancel clauses"); - } - if (MMS_PAR_CHK_FLAG(RECEIVE) == 0 && - MMS_PAR_CHK_FLAG(CANCEL) == 0) { - yyerror("a receive or a cancel clause " - "is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -notify_arg_list - : notify_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | notify_arg_list notify_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -notify_arg - : task_clause - | receive_clause - | cancel_clause - | notify_scope_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -notify_scope_clause - : SCOPE - { - MMS_PAR_CHK_DUP(SCOPE); - } - '[' notify_scope_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "scope", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -notify_scope_arg - : global_or_app - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -global_or_app - : GLOBAL - { - MMS_PAR_CHK_DUP(GLOBAL); - } - | APPLICATION - { - MMS_PAR_CHK_DUP(APPLICATION); - } - | STRING - { - if (strcmp($1.str, "global") == 0) { - MMS_PAR_CHK_DUP(GLOBAL); - } else if (strcmp($1.str, "application") == 0) { - MMS_PAR_CHK_DUP(APPLICATION); - } else { - yyerror("unexpected STRING, expecting " - "global or application"); - YYERROR; - } - $$.str = $1.str; - } - ; - -receive_clause - : RECEIVE - { - MMS_PAR_UNSET_FLAG(OBJECT); - MMS_PAR_UNSET_FLAG(TAG); - MMS_PAR_UNSET_FLAG(ACTION); - MMS_PAR_UNSET_FLAG(MATCH); - MMS_PAR_UNSET_FLAG(TO_MATCH); - MMS_PAR_UNSET_FLAG(TO); - MMS_PAR_UNSET_FLAG(FROM); - MMS_PAR_UNSET_FLAG(ADD); - MMS_PAR_UNSET_FLAG(DELETE); - MMS_PAR_UNSET_FLAG(CHANGE); - MMS_PAR_UNSET_FLAG(DATA); - MMS_PAR_SET_FLAG(RECEIVE); - } - '[' receive_arg_list ']' - { - mms_par_node_t *node; - char *msg; - - MMS_PAR_ALLOC_NODE($$.nodep, "receive", MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, $4.listp); - - if (MMS_PAR_CHK_FLAG(HAVE_SUB_CLAUSE) != 0) { - if (MMS_PAR_CHK_FLAG(OBJECT) == 0) { - yyerror("an object clause is required " - "in a receive clause"); - } - if (MMS_PAR_CHK_FLAG(ADD) != 0 || - MMS_PAR_CHK_FLAG(DELETE) != 0) { - /* "add" or "delete" action */ - if (MMS_PAR_CHK_FLAG(TO) != 0) { - yyerror("to clause not " - "allowed with action 'add' " - "or 'delete'"); - } - } - /* - * If 'change' verify that only one object - * is referenced in the match clause and it - * matches the object specified in the - * onject clause. - */ - if (msg = mms_mmp_validate_object($$.nodep)) { - yyerror(msg); - } - } - - } - ; - -receive_arg_list - : str_arg_list - { - MMS_PAR_SET_FLAG(HAVE_STR_ARG); - $$.listp = $1.listp; - } - | receive_subclause_list - { - MMS_PAR_SET_FLAG(HAVE_SUB_CLAUSE); - $$.listp = $1.listp; - } - ; - -receive_subclause_list - : receive_subclause - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | receive_subclause_list receive_subclause - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -receive_subclause - : recv_object_clause - | recv_tag_clause - | action_clause - | match_clause - | recv_to_clause - | recv_data_clause - ; - -recv_data_clause - : direct_data_clause - ; - -recv_to_clause - : TO - { - MMS_PAR_CHK_DUP(TO); - MMS_PAR_UNSET_FLAG(MATCH); - } - '[' match_clause ']' - { - MMS_PAR_SET_FLAG(TO_MATCH); - MMS_PAR_ALLOC_NODE($$.nodep, "to", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -recv_object_clause - : OBJECT - { - MMS_PAR_CHK_DUP(OBJECT); - } - '[' object_spec opt_attr_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "object", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - if ($5.listp != NULL) { - mms_list_move_tail(&$$.nodep->pn_arglist, - $5.listp); - } - } - ; - -opt_attr_list - : opt_str_arg_list - ; - - -recv_tag_clause - : TAG - { - MMS_PAR_CHK_DUP(TAG); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "tag", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -action_clause - : ACTION - { - MMS_PAR_CHK_DUP(ACTION); - } - '[' action ']' - { - mms_par_node_t *node; - - if (strcmp($4.str, "add") == 0) { - MMS_PAR_SET_FLAG(ADD); - } else if (strcmp($4.str, "delete") == 0) { - MMS_PAR_SET_FLAG(DELETE); - } else if (strcmp($4.str, "change") == 0) { - MMS_PAR_SET_FLAG(CHANGE); - } - MMS_PAR_ALLOC_NODE($$.nodep, "action", MMS_PN_CLAUSE); - MMS_PAR_ALLOC_NODE(node, $4.str, MMS_PN_KEYWORD); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, node); - } - ; - -action : ADD - | DELETE - | CHANGE - | STRING - { - if (strcmp($1.str, "add") && - strcmp($1.str, "delete") && - strcmp($1.str, "change")) { - yyerror("unexpected STRING, " - "expecting add, delete, chage or all"); - YYERROR; - } - $$.str = $1.str; - } - ; - -cancel_clause - : CANCEL '[' cancel_arg_list ']' - { - MMS_PAR_SET_FLAG(CANCEL); - MMS_PAR_ALLOC_NODE($$.nodep, "cancel", MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, $3.listp); - } - ; - -cancel_arg_list - : str_arg_list - { - MMS_PAR_SET_FLAG(HAVE_STR_ARG); - $$.listp = $1.listp; - } - | cancel_subclause - { - MMS_PAR_SET_FLAG(HAVE_SUB_CLAUSE); - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - ; - -cancel_subclause - : tag_clause - | cancel_object_clause - ; - -cancel_object_clause - : event_object_clause - ; - -event_cmd - : EVENT - { - MMS_PAR_ALLOC_NODE($$.nodep, "event", MMS_PN_CMD); - } - event_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - } - ; - -event_arg_list - : event_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | event_arg_list event_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -event_arg - : event_config - | event_newdrive - | event_newcartridge - | event_message - | event_request - | event_volumeadd - | event_volumedelete - | event_dmup - | event_dmdown - | event_driveonline - | event_driveoffline - | event_lmup - | event_lmdown - | event_volumeinject - | event_volumeeject - | event_status - | event_librarycreate - | event_librarydelete - | event_drivedelete - | event_cartridge - | event_volume - | event_direct - | event_object_clause - | recv_tag_clause - | event_data_clause - | error { yyclearin; $$.nodep = NULL; } - ; - - -event_driveoffline - : DRIVEOFFLINE '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "driveoffline", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -event_driveonline - : DRIVEONLINE '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "driveonline", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -event_lmup - : LMUP '[' str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "lmup", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -event_lmdown - : LMDOWN '[' str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "lmdown", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -event_dmup - : DMUP '[' str_arg str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "dmup", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - } - ; - -event_dmdown - : DMDOWN '[' str_arg str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "dmdown", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - } - ; - - -event_volumeinject - : VOLUMEINJECT '[' str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "volumeinject", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -event_volumeeject - : VOLUMEEJECT '[' str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "volumeeject", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - - ; - -event_data_clause - : direct_data_clause - ; - -event_object_clause - : OBJECT - { - MMS_PAR_CHK_DUP(OBJECT); - } - '[' object_spec ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "object", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -event_status - : STATUS '[' str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "status", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -event_librarycreate - : LIBRARYCREATE '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "librarycreate", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -event_librarydelete - : LIBRARYDELETE '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "librarydelete", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -event_drivedelete - : DRIVEDELETE '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "drivedelete", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - - - - -event_volumeadd - : VOLUMEADD '[' str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "volumeadd", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -event_volumedelete - : VOLUMEDELETE '[' str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "volumedelete", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -event_config - : CONFIG '[' str_arg str_arg str_arg opt_str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "config", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $6.nodep); - } - ; - -event_newdrive - : NEWDRIVE '[' str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "newdrive", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -event_newcartridge - : NEWCARTRIDGE '[' str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "newcartridge", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -event_message - : MESSAGE '[' str_arg str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "message", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - } - ; - -event_request - : REQUEST '[' str_arg str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "request", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - } - ; - -event_cartridge - : CARTRIDGE '[' str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "cartridge", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -event_volume - : VOLUME '[' str_arg str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "volume", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - } - ; - -event_direct - : DIRECT - { - MMS_PAR_CHK_DUP(DIRECT); - } - '[' str_arg_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "direct", MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $4.listp); - } - ; - -mmp_request_cmd - : MMP_REQUEST - { - MMS_PAR_ALLOC_NODE($$.nodep, "request", MMS_PN_CMD); - } - mmp_request_arg_list ';' - { - int count; - - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(TYPE) == 0) { - yyerror("a type clause is required"); - } - if (MMS_PAR_CHK_FLAG(PRIORITY) == 0) { - yyerror("a priority clause is required"); - } - if (MMS_PAR_CHK_FLAG(MESSAGE) == 0) { - yyerror("a message clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -mmp_request_arg_list - : mmp_request_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | mmp_request_arg_list mmp_request_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -mmp_request_arg - : task_clause - | mmp_type_clause - | mmp_priority_clause - | message_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -mmp_type_clause - : TYPE - { - MMS_PAR_CHK_DUP(TYPE); - } - '[' object_spec ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "type", MMS_PN_CLAUSE); - if (strcmp(mms_pn_token($4.nodep), "AI")) { - yyerror("unexpected objectname. " - "AI required"); - YYERROR; - } - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -mmp_priority_clause - : PRIORITY - { - MMS_PAR_CHK_DUP(PRIORITY); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "priority", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -mmp_message_cmd - : MMP_MESSAGE - { - MMS_PAR_ALLOC_NODE($$.nodep, "message", MMS_PN_CMD); - } - mmp_message_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(WHO) == 0) { - yyerror("a who clause is required"); - } - if (MMS_PAR_CHK_FLAG(SEVERITY) == 0) { - yyerror("a severity clause is required"); - } - if (MMS_PAR_CHK_FLAG(MESSAGE) == 0) { - yyerror("a message clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -mmp_message_arg_list - : mmp_message_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | mmp_message_arg_list mmp_message_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -mmp_message_arg - : task_clause - | who_clause - | severity_clause - | message_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -lmpl_request_cmd - : LMPD_REQUEST - { - MMS_PAR_ALLOC_NODE($$.nodep, "request", MMS_PN_CMD); - } - lmpl_request_arg_list ';' - { - int count; - - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(TYPE) == 0) { - yyerror("a type clause is required"); - } - if (MMS_PAR_CHK_FLAG(PRIORITY) == 0) { - yyerror("a priority clause is required"); - } - if (MMS_PAR_CHK_FLAG(MESSAGE) == 0) { - yyerror("a message clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -lmpl_request_arg_list - : lmpl_request_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | lmpl_request_arg_list lmpl_request_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -lmpl_request_arg - : task_clause - | lmpl_type_clause - | lmpl_priority_clause - | message_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -lmpl_type_clause - : TYPE - { - MMS_PAR_CHK_DUP(TYPE); - } - '[' lm_spec ']' - { - mms_par_node_t *node; - - MMS_PAR_ALLOC_NODE($$.nodep, "type", MMS_PN_CLAUSE); - MMS_PAR_ALLOC_NODE($$.nodep, $4.str, MMS_PN_OBJ); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - node); - } - ; - -lm_spec : LM - | STRING - { - if (strcmp($1.str, "LM")) { - yyerror("unexpected type. LM expected"); - YYERROR; - } - $$.str = $1.str; - } - ; - -lmpl_priority_clause - : PRIORITY - { - MMS_PAR_CHK_DUP(PRIORITY); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "priority", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - - - - -lmpl_private_cmd - : LMPD_PRIVATE - { - MMS_PAR_ALLOC_NODE($$.nodep, "private", MMS_PN_CMD); - } - lmpl_private_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(SET) + MMS_PAR_CHK_FLAG(UNSET) + - MMS_PAR_CHK_FLAG(GET) == 0) { - yyerror("a set, unset or get clause is " - "required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -lmpl_private_arg_list - : lmpl_private_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | lmpl_private_arg_list lmpl_private_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -lmpl_private_arg - : task_clause - | lmpl_set_clause - | lmpl_unset_clause - | lmpl_get_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -lmpl_set_clause - : SET '[' lmpl_set_arglist ']' - { - MMS_PAR_SET_FLAG(SET); - MMS_PAR_ALLOC_NODE($$.nodep, "set", MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - } - ; - -lmpl_set_arglist - : lmpl_object_id str_arg str_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - mms_par_list_insert_tail($$.listp, $2.nodep); - mms_par_list_insert_tail($$.listp, $3.nodep); - } - | lmpl_set_arglist lmpl_object_id str_arg str_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - mms_par_list_insert_tail($1.listp, $3.nodep); - mms_par_list_insert_tail($1.listp, $4.nodep); - $$.listp = $1.listp; - } - ; - -lmpl_object_id - : object_spec - { - char msg[100]; - if (strcmp(mms_pn_token($1.nodep), "LM") && - strcmp(mms_pn_token($1.nodep), "LIBRARY")) { - sprintf(msg, - "Unexpected object \"%s\", only " - "\"LM\" or \"LIBRARY\" object is " - "allowed", mms_pn_token($1.nodep)); - yyerror(msg); - YYERROR; - } - } - ; - -lmpl_unset_clause - : UNSET '[' lmpl_unset_arglist ']' - { - MMS_PAR_SET_FLAG(UNSET); - MMS_PAR_ALLOC_NODE($$.nodep, "unset", MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - } - ; - -lmpl_unset_arglist - : lmpl_object_id str_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - mms_par_list_insert_tail($$.listp, $2.nodep); - } - | lmpl_unset_arglist lmpl_object_id str_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - mms_par_list_insert_tail($1.listp, $3.nodep); - $$.listp = $1.listp; - } - ; - -lmpl_get_clause - : GET '[' lmpl_get_arglist ']' - { - MMS_PAR_SET_FLAG(GET); - MMS_PAR_ALLOC_NODE($$.nodep, "get", MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - } - ; - -lmpl_get_arglist - : lmpl_object_id str_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - mms_par_list_insert_tail($$.listp, $2.nodep); - } - | lmpl_get_arglist lmpl_object_id str_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - mms_par_list_insert_tail($1.listp, $3.nodep); - $$.listp = $1.listp; - } - ; - - - - -lmpl_config_cmd - : LMPD_CONFIG - { - MMS_PAR_ALLOC_NODE($$.nodep, "config", MMS_PN_CMD); - } - lmpl_config_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -lmpl_config_arg_list - : lmpl_config_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | lmpl_config_arg_list lmpl_config_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -lmpl_config_arg - : task_clause - | lmpl_slot_clause - | scope_clause - | bay_clause - | lmpl_drive_clause - | freeslots_clause - | delslots_clause - | lmpl_slotgroup_clause - | perf_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -perf_clause - : PERF '[' num_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "perf", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -lmpl_slotgroup_clause - : SLOTGROUP '[' str_arg str_arg direction_spec str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "slotgroup", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $6.nodep); - } - ; - -direction_spec - : direction - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -direction - : IN | OUT | BOTH | NONE - | STRING - { - if (strcmp($1.str, "in") && - strcmp($1.str, "out") && - strcmp($1.str, "both") && - strcmp($1.str, "none")) { - yyerror("unexpected STRING, " - "expecting in, out, both or none"); - YYERROR; - } - $$.str = $1.str; - } - ; - -lmpl_drive_clause - : DRIVE_CL '[' str_arg str_arg str_arg str_arg - true_or_false_spec true_or_false_spec ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "drive", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $6.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $7.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $8.nodep); - } - ; - -freeslots_clause - : FREESLOTS '[' str_arg str_arg num_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "freeslots", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - } - ; - -delslots_clause - : DELSLOTS '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "delslots", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -bay_clause - : BAY '[' str_arg true_or_false_spec ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "bay", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - - - -lmpl_slot_clause - : SLOT '[' str_arg str_arg str_arg str_arg str_arg true_or_false_spec - true_or_false_spec ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "slot", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $6.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $7.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $8.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $9.nodep); - } - ; - -lmpm_unmount_cmd - : LMPM_UNMOUNT - { - MMS_PAR_ALLOC_NODE($$.nodep, "unmount", MMS_PN_CMD); - } - lmpm_unmount_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(ALL) == 0 && - MMS_PAR_CHK_FLAG(FROMSLOT) == 0) { - yyerror("either all or fromslot clause is " - "required"); - } - if (MMS_PAR_CHK_FLAG(ALL) && - MMS_PAR_CHK_FLAG(FROMSLOT)) { - yyerror("all and fromslot clauses are " - "incompatible"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -lmpm_unmount_arg_list - : lmpm_unmount_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | lmpm_unmount_arg_list lmpm_unmount_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -lmpm_unmount_arg - : task_clause - | drive_clause - | lmpm_fromslot_clause - | lmpm_toslot_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -lmpm_fromslot_clause - : FROMSLOT - { - MMS_PAR_CHK_DUP(FROMSLOT); - } - '[' str_arg str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "fromslot", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $6.nodep); - } - ; - -lmpm_toslot_clause - : TOSLOT - { - MMS_PAR_CHK_DUP(TOSLOT); - } - '[' str_arg str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "toslot", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $6.nodep); - } - ; - -lmpm_scan_cmd - : LMPM_SCAN - { - MMS_PAR_ALLOC_NODE($$.nodep, "scan", MMS_PN_CMD); - } - lmpm_scan_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(ALL)) { - if (MMS_PAR_CHK_FLAG(FROMSLOT) || - MMS_PAR_CHK_FLAG(TOSLOT) || - MMS_PAR_CHK_FLAG(SLOT) || - MMS_PAR_CHK_FLAG(DRIVE)) { - yyerror("all is incompatible with " - "fromslot, toslot, " - "drive and slot"); - } - } - if (MMS_PAR_CHK_FLAG(SLOT)) { - if (MMS_PAR_CHK_FLAG(FROMSLOT) || - MMS_PAR_CHK_FLAG(TOSLOT) || - MMS_PAR_CHK_FLAG(ALL) || - MMS_PAR_CHK_FLAG(DRIVE)) { - yyerror("slot is incompatible with " - "fromslot, toslot, " - "drive and all"); - } - } - if (MMS_PAR_CHK_FLAG(DRIVE)) { - if (MMS_PAR_CHK_FLAG(FROMSLOT) || - MMS_PAR_CHK_FLAG(TOSLOT) || - MMS_PAR_CHK_FLAG(ALL) || - MMS_PAR_CHK_FLAG(SLOT)) { - yyerror - ("drive is incompatible with " - "fromslot, toslot, " - "all and slot"); - } - } - if (MMS_PAR_CHK_FLAG(FROMSLOT)) { - if (MMS_PAR_CHK_FLAG(DRIVE) || - MMS_PAR_CHK_FLAG(ALL) || - MMS_PAR_CHK_FLAG(SLOT)) { - yyerror - ("fromslot is incompatible with " - "all, drive and slot"); - } - } - if (MMS_PAR_CHK_FLAG(TOSLOT)) { - if (MMS_PAR_CHK_FLAG(DRIVE) || - MMS_PAR_CHK_FLAG(ALL) || - MMS_PAR_CHK_FLAG(SLOT)) { - yyerror - ("toslot is incompatible with " - "all, drive and slot"); - } - } - if (MMS_PAR_CHK_FLAG(FROMSLOT) + - MMS_PAR_CHK_FLAG(TOSLOT) == - 1) { - yyerror("fromslot and toslot must be " - "specified together"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -lmpm_scan_arg_list - : lmpm_scan_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | lmpm_scan_arg_list lmpm_scan_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -lmpm_scan_arg - : task_clause - | all_spec - | from_spec - | to_spec - | scan_slot_clause - | drive_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -scan_slot_clause - : SLOT '[' str_arg ']' - { - MMS_PAR_SET_FLAG(SLOT); - MMS_PAR_ALLOC_NODE($$.nodep, "slot", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -lmpm_move_cmd - : LMPM_MOVE - { - MMS_PAR_ALLOC_NODE($$.nodep, "move", MMS_PN_CMD); - } - lmpm_move_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(FROM) == 0) { - yyerror("a from clause is required"); - } - if (MMS_PAR_CHK_FLAG(TO) == 0) { - yyerror("a to clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -lmpm_move_arg_list - : lmpm_move_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | lmpm_move_arg_list lmpm_move_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -lmpm_move_arg - : task_clause - | from_clause - | to_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -from_clause - : FROM - { - MMS_PAR_CHK_DUP(FROM); - } - '[' str_arg str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "from", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $6.nodep); - } - ; - -to_clause - : TO - { - MMS_PAR_CHK_DUP(TO); - } - '[' str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "to", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - } - ; - -lmpm_mount_cmd - : LMPM_MOUNT - { - MMS_PAR_ALLOC_NODE($$.nodep, "mount", MMS_PN_CMD); - } - lmpm_mount_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(DRIVE) == 0) { - yyerror("a drive clause is required"); - } - if (MMS_PAR_CHK_FLAG(SLOT) == 0) { - yyerror("a slot clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -lmpm_mount_arg_list - : lmpm_mount_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | lmpm_mount_arg_list lmpm_mount_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -lmpm_mount_arg - : task_clause - | drive_clause - | mount_slot_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -drive_clause - : DRIVE_CL '[' str_arg ']' - { - MMS_PAR_SET_FLAG(DRIVE); - MMS_PAR_ALLOC_NODE($$.nodep, "drive", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -mount_slot_clause - : SLOT '[' str_arg str_arg str_arg ']' - { - MMS_PAR_SET_FLAG(SLOT); - MMS_PAR_ALLOC_NODE($$.nodep, "slot", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - } - ; - -lmpm_inject_cmd - : LMPM_INJECT - { - MMS_PAR_ALLOC_NODE($$.nodep, "inject", MMS_PN_CMD); - } - lmpm_inject_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(SLOTGROUP) == 0) { - yyerror("a slotgroup clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -lmpm_inject_arg_list - : lmpm_inject_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | lmpm_inject_arg_list lmpm_inject_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -lmpm_inject_arg - : task_clause - | slotgroup_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -lmpm_exit_cmd - : LMPM_EXIT - { - MMS_PAR_ALLOC_NODE($$.nodep, "exit", MMS_PN_CMD); - } - task_clause ';' - { - $$.nodep = $2.nodep; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -lmpm_eject_cmd - : LMPM_EJECT - { - MMS_PAR_ALLOC_NODE($$.nodep, "eject", MMS_PN_CMD); - } - lmpm_eject_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(SLOTGROUP) == 0) { - yyerror("a slotgroup clause is required"); - } - if (MMS_PAR_CHK_FLAG(SLOT) == 0) { - yyerror("a slot clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -lmpm_eject_arg_list - : lmpm_eject_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | lmpm_eject_arg_list lmpm_eject_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -lmpm_eject_arg - : task_clause - | slotgroup_clause - | slot_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -slot_clause - : SLOT '[' str_arg str_arg ']' - { - MMS_PAR_SET_FLAG(SLOT); - MMS_PAR_ALLOC_NODE($$.nodep, "slot", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -lmpm_barrier_cmd - : BARRIER - { - MMS_PAR_ALLOC_NODE($$.nodep, "barrier", MMS_PN_CMD); - } - task_clause ';' - { - $$.nodep = $2.nodep; - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -lmpm_activate_cmd - : LMPM_ACTIVATE - { - MMS_PAR_ALLOC_NODE($$.nodep, "activate", MMS_PN_CMD); - } - activate_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(ENABLE) == 0 && - MMS_PAR_CHK_FLAG(DISABLE) - == 0) { - yyerror("one of enable and disable is " - "required"); - } - if (MMS_PAR_CHK_FLAG(ENABLE) == 1 && - MMS_PAR_CHK_FLAG(DISABLE) - == 1) { - yyerror - ("enable and disable are incompatible"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -dmpd_request_cmd - : DMPD_REQUEST - { - MMS_PAR_ALLOC_NODE($$.nodep, "request", MMS_PN_CMD); - } - dmpd_request_arg_list ';' - { - int count; - - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(TYPE) == 0) { - yyerror("a type clause is required"); - } - if (MMS_PAR_CHK_FLAG(PRIORITY) == 0) { - yyerror("a priority clause is required"); - } - if (MMS_PAR_CHK_FLAG(MESSAGE) == 0) { - yyerror("a message clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -dmpd_request_arg_list - : dmpd_request_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | dmpd_request_arg_list dmpd_request_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -dmpd_request_arg - : task_clause - | dmpd_type_clause - | dmpd_priority_clause - | message_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -dmpd_type_clause - : TYPE - { - MMS_PAR_CHK_DUP(TYPE); - } - '[' dm_spec ']' - { - mms_par_node_t *node; - - MMS_PAR_ALLOC_NODE($$.nodep, "type", MMS_PN_CLAUSE); - MMS_PAR_ALLOC_NODE(node, $4.str, MMS_PN_OBJ); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - node); - } - ; - -dm_spec : DM - | STRING - { - if (strcmp($1.str, "DM")) { - yyerror("unexpected type. DM expected"); - YYERROR; - } - $$.str = $1.str; - } - ; - -dmpd_priority_clause - : PRIORITY - { - MMS_PAR_CHK_DUP(PRIORITY); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "priority", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -xmpd_ready_cmd - : XMPD_READY - { - MMS_PAR_ALLOC_NODE($$.nodep, "ready", MMS_PN_CMD); - } - xmpd_ready_arg_list ';' - { - int count; - - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - YYERROR; - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -xmpd_ready_arg_list - : xmpd_ready_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | xmpd_ready_arg_list xmpd_ready_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -xmpd_ready_arg - : task_clause - | ready_state_spec - | message_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -ready_state_spec - : ready_state - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -ready_state - : NOT - { - MMS_PAR_CHK_DUP(NOT); - } - | BROKEN - { - MMS_PAR_CHK_DUP(BROKEN); - } - | DISCONNECTED - { - MMS_PAR_CHK_DUP(DISCONNECTED); - } - | PRESENT - { - MMS_PAR_CHK_DUP(PRESENT); - } - | STRING - { - if (strcmp($1.str, "not") && - strcmp($1.str, "present") && - strcmp($1.str, "broken") && - strcmp($1.str, "disconnected")) { - yyerror("unexpected STRING, " - "expecting not, present, broken or " - "disconnected"); - YYERROR; - } - $$.str = $1.str; - } - ; - -dmpd_private_cmd - : DMPD_PRIVATE - { - MMS_PAR_ALLOC_NODE($$.nodep, "private", MMS_PN_CMD); - } - dmpd_private_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(SET) + MMS_PAR_CHK_FLAG(UNSET) + - MMS_PAR_CHK_FLAG(GET) == 0) { - yyerror("a set, unset or get clause is " - "required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -dmpd_private_arg_list - : dmpd_private_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | dmpd_private_arg_list dmpd_private_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -dmpd_private_arg - : task_clause - | dmpd_set_clause - | dmpd_unset_clause - | dmpd_get_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -dmpd_set_clause - : SET '[' dmpd_set_arglist ']' - { - MMS_PAR_SET_FLAG(SET); - MMS_PAR_ALLOC_NODE($$.nodep, "set", MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - } - ; - -dmpd_set_arglist - : dmpd_object_id str_arg str_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - mms_par_list_insert_tail($$.listp, $2.nodep); - mms_par_list_insert_tail($$.listp, $3.nodep); - } - | dmpd_set_arglist dmpd_object_id str_arg str_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - mms_par_list_insert_tail($1.listp, $3.nodep); - mms_par_list_insert_tail($1.listp, $4.nodep); - $$.listp = $1.listp; - } - ; - -dmpd_object_id - : object_spec - { - char msg[100]; - if (strcmp(mms_pn_token($1.nodep), "DM") && - strcmp(mms_pn_token($1.nodep), "DRIVE")) { - sprintf(msg, - "Unexpected object \"%s\", only " - "\"DM\" or \"DRIVE\" object is " - "allowed", mms_pn_token($1.nodep)); - yyerror(msg); - YYERROR; - } - } - ; - -dmpd_unset_clause - : UNSET '[' dmpd_unset_arglist ']' - { - MMS_PAR_SET_FLAG(UNSET); - MMS_PAR_ALLOC_NODE($$.nodep, "unset", MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - } - ; - -dmpd_unset_arglist - : dmpd_object_id str_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - mms_par_list_insert_tail($$.listp, $2.nodep); - } - | dmpd_unset_arglist dmpd_object_id str_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - mms_par_list_insert_tail($1.listp, $3.nodep); - $$.listp = $1.listp; - } - ; - -dmpd_get_clause - : GET '[' dmpd_get_arglist ']' - { - MMS_PAR_SET_FLAG(GET); - MMS_PAR_ALLOC_NODE($$.nodep, "get", MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - } - ; - -dmpd_get_arglist - : dmpd_object_id str_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - mms_par_list_insert_tail($$.listp, $2.nodep); - } - | dmpd_get_arglist dmpd_object_id str_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - mms_par_list_insert_tail($1.listp, $3.nodep); - $$.listp = $1.listp; - } - ; - -xmpd_message_cmd - : XMPD_MESSAGE - { - MMS_PAR_ALLOC_NODE($$.nodep, "message", MMS_PN_CMD); - } - xmpd_message_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(WHO) == 0) { - yyerror("a who clause is required"); - } - if (MMS_PAR_CHK_FLAG(SEVERITY) == 0) { - yyerror("a severity clause is required"); - } - if (MMS_PAR_CHK_FLAG(MESSAGE) == 0) { - yyerror("a message clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -xmpd_message_arg_list - : xmpd_message_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | xmpd_message_arg_list xmpd_message_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -xmpd_message_arg - : task_clause - | who_clause - | severity_clause - | message_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -who_clause - : WHO - { - MMS_PAR_CHK_DUP(WHO); - } - '[' receiver ']' - { - mms_par_node_t *node; - - MMS_PAR_ALLOC_NODE($$.nodep, "who", MMS_PN_CLAUSE); - MMS_PAR_ALLOC_NODE(node, $4.str, MMS_PN_KEYWORD); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - node); - } - ; - -receiver: OPERATOR | ADMINISTRATOR | LOG - | STRING - { - if (strcmp($1.str, "operator") && - strcmp($1.str, "administrator") && - strcmp($1.str, "log")) { - yyerror("unexpected STRING, expecting " - "operator, administrator or log"); - YYERROR; - } - $$.str = $1.str; - } - ; - -severity_clause - : SEVERITY - { - MMS_PAR_CHK_DUP(SEVERITY); - } - '[' severity ']' - { - mms_par_node_t *node; - - MMS_PAR_ALLOC_NODE($$.nodep, "severity", - MMS_PN_CLAUSE); - MMS_PAR_ALLOC_NODE(node, $4.str, MMS_PN_KEYWORD); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - node); - } - ; - -severity: EMERGENCY | ALERT | CRITICAL | ERROR | WARNING | NOTICE - | INFORMATION | DEBUG | DEVELOPER - | STRING - { - if (strcmp($1.str, "emergency") && - strcmp($1.str, "alert") && - strcmp($1.str, "critical") && - strcmp($1.str, "error") && - strcmp($1.str, "warning") && - strcmp($1.str, "notice") && - strcmp($1.str, "information") && - strcmp($1.str, "debug") && - strcmp($1.str, "developer")) { - yyerror("unexpected STRING, expecting " - "emergency, alert, critical, " - "error, warning, notice, " - "information, debug or developer"); - YYERROR; - } - $$.str = $1.str; - } - ; - -dmpm_unload_cmd - : UNLOAD - { - MMS_PAR_ALLOC_NODE($$.nodep, "unload", MMS_PN_CMD); - } - task_clause ';' - { - $$.nodep = $2.nodep; - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -xmpm_reset_cmd - : XMPM_RESET - { - MMS_PAR_ALLOC_NODE($$.nodep, "reset", MMS_PN_CMD); - } - xmpm_reset_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(FULL) == 0 && - MMS_PAR_CHK_FLAG(PARTIAL) == 0) { - yyerror("full or partial is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -xmpm_reset_arg_list - : xmpm_reset_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | xmpm_reset_arg_list xmpm_reset_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -xmpm_reset_arg - : task_clause - | scope_arg - | error { yyclearin; $$.nodep = NULL; } - ; - -xmpm_private_cmd - : XMPM_PRIVATE - { - MMS_PAR_ALLOC_NODE($$.nodep, "private", MMS_PN_CMD); - } - dmpm_private_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(SET) + MMS_PAR_CHK_FLAG(UNSET) + - MMS_PAR_CHK_FLAG(GET) == 0) { - yyerror("a set, unset or get clause is " - "required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -dmpm_private_arg_list - : dmpm_private_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | dmpm_private_arg_list dmpm_private_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -dmpm_private_arg - : task_clause - | dmpm_set_clause - | dmpm_unset_clause - | dmpm_get_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -dmpm_set_clause - : SET '[' dmpm_set_arglist ']' - { - MMS_PAR_SET_FLAG(SET); - MMS_PAR_ALLOC_NODE($$.nodep, "set", MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - } - ; - -dmpm_set_arglist - : str_arg str_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - mms_par_list_insert_tail($$.listp, $2.nodep); - } - | dmpm_set_arglist str_arg str_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - mms_par_list_insert_tail($1.listp, $3.nodep); - $$.listp = $1.listp; - } - ; - -dmpm_unset_clause - : UNSET '[' dmpm_unset_arglist ']' - { - MMS_PAR_SET_FLAG(UNSET); - MMS_PAR_ALLOC_NODE($$.nodep, "unset", MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - } - ; - -dmpm_unset_arglist - : str_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | dmpm_unset_arglist str_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -dmpm_get_clause - : GET '[' dmpm_get_arglist ']' - { - MMS_PAR_SET_FLAG(GET); - MMS_PAR_ALLOC_NODE($$.nodep, "get", MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - } - ; - -dmpm_get_arglist - : str_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | dmpm_get_arglist str_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -dmpm_load_cmd - : LOAD - { - MMS_PAR_ALLOC_NODE($$.nodep, "load", MMS_PN_CMD); - } - task_clause ';' - { - $$.nodep = $2.nodep; - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - - -dmpm_identify_cmd - : IDENTIFY - { - MMS_PAR_ALLOC_NODE($$.nodep, "identify", MMS_PN_CMD); - } - identify_dmpm_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(TYPE) == 0) { - yyerror("a type clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -identify_dmpm_arg_list - : identify_dmpm_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | identify_dmpm_arg_list identify_dmpm_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -identify_dmpm_arg - : task_clause - | identify_type_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -identify_type_clause - : TYPE - { - MMS_PAR_CHK_DUP(TYPE); - } - '[' partition_signature_type_spec ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "type", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -partition_signature_type_spec - : partition_signature_type - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -partition_signature_type - : NONE - | ANSILABEL - | STRING - { - if (strcmp($1.str, "none") && - strcmp($1.str, "ansilabel")) { - yyerror("unexpected STRING, expecting " - "none or ansilabel"); - } - $$.str = $1.str; - } - ; - -dmpm_exit_cmd - : EXIT - { - MMS_PAR_ALLOC_NODE($$.nodep, "exit", MMS_PN_CMD); - } - task_clause ';' - { - $$.nodep = $2.nodep; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -dmpm_detach_cmd - : DETACH - { - MMS_PAR_ALLOC_NODE($$.nodep, "detach", MMS_PN_CMD); - } - detach_dmpm_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(STALE) == 0) { - yyerror("a stale clause is required"); - } - if (MMS_PAR_CHK_FLAG(DRIVEHANDLE) == 0) { - yyerror("a drivehandle clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -detach_dmpm_arg_list - : detach_dmpm_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | detach_dmpm_arg_list detach_dmpm_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -detach_dmpm_arg - : task_clause - | drivehandle_clause - | stale_clause - | error { yyclearin; $$.nodep = NULL; } - ; - - -drivehandle_clause - : DRIVEHANDLE - { - MMS_PAR_CHK_DUP(DRIVEHANDLE); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "drivehandle", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -stale_clause - : STALE - { - MMS_PAR_CHK_DUP(STALE); - } - '[' stale_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "stale", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -stale_arg - : true_or_false_spec - ; - -internal_cmd - : INTERNAL - { - MMS_PAR_ALLOC_NODE($$.nodep, "internal", MMS_PN_CMD); - } - str_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - } - ; - -xmpx_cancel_cmd - : XMPX_CANCEL - { - MMS_PAR_ALLOC_NODE($$.nodep, "cancel", MMS_PN_CMD); - } - xmpx_cancel_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(WHICHTASK) == 0) { - yyerror("a whichtask clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -xmpx_cancel_arg_list - : xmpx_cancel_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | xmpx_cancel_arg_list xmpx_cancel_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -xmpx_cancel_arg - : task_clause - | whichtask_clause - ; - -whichtask_clause - : WHICHTASK - { - MMS_PAR_CHK_DUP(WHICHTASK); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "whichtask", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -dmpm_attach_cmd - : ATTACH - { - MMS_PAR_ALLOC_NODE($$.nodep, "attach", MMS_PN_CMD); - } - attach_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(MODENAME) == 0) { - yyerror("a scope clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -attach_arg_list - : attach_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | attach_arg_list attach_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -attach_arg - : task_clause - | modename_clause - | partition_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -modename_clause - : MODENAME - { - MMS_PAR_CHK_DUP(MODENAME); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "modename", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -partition_clause - : PARTITION - { - MMS_PAR_CHK_DUP(PARTITION); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "partition", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -dmpd_config_cmd - : DMPD_CONFIG - { - MMS_PAR_ALLOC_NODE($$.nodep, "config", MMS_PN_CMD); - } - config_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(SCOPE) == 0) { - yyerror("a scope clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -config_arg_list - : config_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | config_arg_list config_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -config_arg - : task_clause - | scope_clause - | group_clause - | bit_clause - | cap_clause - | shape_pri_clause - | den_pri_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -shape_pri_clause - : SHAPEPRIORITY - { - MMS_PAR_CHK_DUP(SHAPEPRIORITY); - } - '[' str_arg_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "shapepriority", - MMS_PN_CLAUSE); - mms_list_move(&$$.nodep->pn_arglist, $4.listp); - } - ; - -den_pri_clause - : DENSITYPRIORITY - { - MMS_PAR_CHK_DUP(DENSITYPRIORITY); - } - '[' str_arg_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "densitypriority", - MMS_PN_CLAUSE); - mms_list_move(&$$.nodep->pn_arglist, $4.listp); - } - ; - -scope_clause - : SCOPE - { - MMS_PAR_CHK_DUP(SCOPE); - } - '[' scope_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "scope", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -scope_arg - : full_or_partial - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -full_or_partial - : FULL - { - MMS_PAR_CHK_DUP(FULL); - } - | PARTIAL - { - MMS_PAR_CHK_DUP(PARTIAL); - } - | STRING - { - if (strcmp($1.str, "full") == 0) { - MMS_PAR_CHK_DUP(FULL); - } else if (strcmp($1.str, "partial") == 0) { - MMS_PAR_CHK_DUP(PARTIAL); - } else { - yyerror("unexpected STRING, expecting " - "full or partial"); - YYERROR; - } - $$.str = $1.str; - } - ; - -group_clause - : GROUP '[' str_arg_list ']' - { - MMS_PAR_SET_FLAG(GROUP); - MMS_PAR_ALLOC_NODE($$.nodep, "group", MMS_PN_CLAUSE); - mms_list_move(&$$.nodep->pn_arglist, $3.listp); - } - ; - -str_arg_list - : str_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | str_arg_list str_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -bit_clause - : BITFORMAT '[' str_arg str_arg opt_str_arg_list ']' - { - MMS_PAR_SET_FLAG(BITFORMAT); - MMS_PAR_ALLOC_NODE($$.nodep, "bitformat", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - if ($5.listp != NULL) { - mms_list_move_tail(&$$.nodep->pn_arglist, - $5.listp); - } - } - ; - -cap_clause - : CAP '[' - { - MMS_PAR_UNSET_FLAG(CAPLIST); - } - str_arg cap_arg_list ']' - { - MMS_PAR_SET_FLAG(CAP); - MMS_PAR_ALLOC_NODE($$.nodep, "cap", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_list_move_tail(&$$.nodep->pn_arglist, - $5.listp); - } - ; - -cap_arg_list - : cap_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | cap_arg_list cap_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -cap_arg : cap_attr_clause - | caplist_clause - ; - -cap_attr_clause - : ATTR '[' str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "attr", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -caplist_clause - : CAPLIST - { - MMS_PAR_CHK_DUP(CAPLIST); - } - '[' cap_token_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "caplist", - MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $4.listp); - } - ; - -cap_token_list - : str_arg_list - ; - -dmpm_activate_cmd - : ACTIVATE - { - MMS_PAR_ALLOC_NODE($$.nodep, "activate", MMS_PN_CMD); - } - activate_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(ENABLE) == 0 && - MMS_PAR_CHK_FLAG(DISABLE) == 0 && - MMS_PAR_CHK_FLAG(RESERVE) == 0 && - MMS_PAR_CHK_FLAG(RELEASE) == 0) { - yyerror("one of enable, disable, " - "reserve or release is " "required"); - } - if (MMS_PAR_CHK_FLAG(ENABLE) + - MMS_PAR_CHK_FLAG(DISABLE) + - MMS_PAR_CHK_FLAG(RESERVE) + - MMS_PAR_CHK_FLAG(RELEASE) > - 1) { - yyerror("enable, disable, " - "reserve and release are incompatible"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -activate_arg_list - : activate_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | activate_arg_list activate_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -activate_arg - : task_clause - | activate_type_spec - | error { yyclearin; $$.nodep = NULL; } - ; - -activate_type_spec - : activate_type - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -activate_type - : ENABLE - { - MMS_PAR_CHK_DUP(ENABLE); - } - | DISABLE - { - MMS_PAR_CHK_DUP(DISABLE); - } - | RELEASE - { - MMS_PAR_CHK_DUP(RELEASE); - } - | RESERVE - { - MMS_PAR_CHK_DUP(RESERVE); - } - ; - -shutdown_cmd - : SHUTDOWN - { - MMS_PAR_ALLOC_NODE($$.nodep, "shutdown", MMS_PN_CMD); - } - shutdown_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(TYPE) == 0) { - yyerror("a type clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -shutdown_arg_list - : shutdown_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | shutdown_arg_list shutdown_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -shutdown_arg - : task_clause - | shutdown_type_clause - | restart_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -shutdown_type_clause - : TYPE '[' - { - MMS_PAR_UNSET_FLAG(RESTART); - MMS_PAR_CHK_DUP(TYPE); - } - shutdown_type_arg_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "type", MMS_PN_CLAUSE); - if (MMS_PAR_CHK_FLAG(NONEWAPPS) + - MMS_PAR_CHK_FLAG(NONEWMOUNTS) - + MMS_PAR_CHK_FLAG(ABORTQUEUE) + - MMS_PAR_CHK_FLAG(FORCE) > 1) { - yyerror - ("nonewapps, nonewmounts, abortqueue " - "and force are imcompatible"); - YYERROR; - } - MMS_PAR_UNSET_FLAG(RESTART); - mms_list_move_tail(&$$.nodep->pn_arglist, - $4.listp); - } - ; - -shutdown_type_arg_list - : shutdown_type_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | shutdown_type_arg_list shutdown_type_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -shutdown_type_arg - : shutdown_type - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -shutdown_type - : NONEWAPPS - { - MMS_PAR_CHK_DUP(NONEWAPPS); - } - | NONEWMOUNTS - { - MMS_PAR_CHK_DUP(NONEWMOUNTS); - } - | ABORTQUEUE - - { - MMS_PAR_CHK_DUP(ABORTQUEUE); - } - | FORCE - { - MMS_PAR_CHK_DUP(FORCE); - } - | RESTART - { - MMS_PAR_CHK_DUP(RESTART); - } - | STRING - { - if (strcmp($1.str, "nonewapps") == 0) { - MMS_PAR_CHK_DUP(NONEWAPPS); - } else if (strcmp($1.str, "nonewmounts") == 0) { - MMS_PAR_CHK_DUP(NONEWMOUNTS); - } else if (strcmp($1.str, "abortqueue") == 0) { - MMS_PAR_CHK_DUP(ABORTQUEUE); - } else if (strcmp($1.str, "force") == 0) { - MMS_PAR_CHK_DUP(FORCE); - } else if (strcmp($1.str, "restart") == 0) { - MMS_PAR_CHK_DUP(RESTART); - } else { - yyerror("unexpected STRING, expecting " - "nonewapps, nonewmounts, abortqueue " - "force or restart"); - YYERROR; - } - $$.str = $1.str; - } - ; - -restart_clause - : restart - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -restart : RESTART - { - MMS_PAR_CHK_DUP(RESTART); - } - | STRING - { - if (strcmp($1.str, "restart")) { - yyerror("unexpected STRING, expecting " - "restart"); - YYERROR; - } - $$.str = $1.str; - } - ; - -release_cmd - : RELEASE - { - MMS_PAR_ALLOC_NODE($$.nodep, "release", MMS_PN_CMD); - } - release_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(MATCH) && - MMS_PAR_CHK_FLAG(REQID)) { - yyerror("match and reqid clauses are " - "incompatible"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -release_arg_list - : release_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | release_arg_list release_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -release_arg - : task_clause - | reqid_clause - | match_clause - | order_clause - | number_clause - | report_group - | error { yyclearin; $$.nodep = NULL; } - ; - -privilege_cmd - : PRIVILEGE - { - MMS_PAR_ALLOC_NODE($$.nodep, "privilege", MMS_PN_CMD); - } - privilege_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(LEVEL) == 0) { - yyerror("a level clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -privilege_arg_list - : privilege_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | privilege_arg_list privilege_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -privilege_arg - : task_clause - | level_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -level_clause - : LEVEL - { - MMS_PAR_CHK_DUP(LEVEL); - } - '[' level_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "level", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -level_arg - : level - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -level : STANDARD - | ADMINISTRATOR - | SYSTEM_PRIV - | STRING - { - if (strcmp($1.str, "standard") && - strcmp($1.str, "administrator") && - strcmp($1.str, "system")) { - yyerror("unexpected STRING, expecting " - "standard or administrator or " - "system_priv"); - YYERROR; - } - $$.str = $1.str; - } - ; - - -move_cmd - : MOVE - { - MMS_PAR_ALLOC_NODE($$.nodep, "move", MMS_PN_CMD); - } - move_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(TOSLOT) == 0) { - yyerror("a toslot clause is required"); - } - if (MMS_PAR_CHK_FLAG(CART) && - MMS_PAR_CHK_FLAG(CARTID)) { - yyerror("cart and cartid clauses are " - "incompatible"); - } - if ((MMS_PAR_CHK_FLAG(CART) + - MMS_PAR_CHK_FLAG(CARTID)) && - (MMS_PAR_CHK_FLAG(MATCH) + MMS_PAR_CHK_FLAG(ORDER) + - MMS_PAR_CHK_FLAG(NUMBER))) { - yyerror("cart and cartid clauses are " - "incompatible with match, order and " - "number clauses"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -move_arg_list - : move_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | move_arg_list move_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -move_arg - : task_clause - | to_slot_clause - | move_cart_id_clause - | match_clause - | order_clause - | number_clause - | report_group - | error { yyclearin; $$.nodep = NULL; } - ; - -to_slot_clause - : TOSLOT - { - MMS_PAR_CHK_DUP(TOSLOT); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "toslot", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -move_cart_id_clause - : move_id_clause - | move_cart_clause - ; - -move_id_clause - : CARTID - { - MMS_PAR_CHK_DUP(CARTID); - } - '[' str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "cartid", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - } - ; - -move_cart_clause - : CART - { - MMS_PAR_CHK_DUP(CART); - } - '[' str_arg str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "cart", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $6.nodep); - } - ; - - - -locale_cmd - : LOCALE - { - MMS_PAR_ALLOC_NODE($$.nodep, "locale", MMS_PN_CMD); - } - locale_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -locale_arg_list - : locale_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | locale_arg_list locale_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -locale_arg - : task_clause - | locale_language_clause - | sortorder_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -locale_language_clause - : LANGUAGE - { - MMS_PAR_CHK_DUP(LANGUAGE); - } - '[' language_name opt_language_flavor_name ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "language", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - } - ; - -language_name - : str_arg - ; - -opt_language_flavor_name - : /* Empty */ { $$.nodep = NULL; } - | str_arg - ; - -sortorder_clause - : SORT - { - MMS_PAR_CHK_DUP(SORT); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "sort", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -inject_cmd - : INJECT - { - MMS_PAR_ALLOC_NODE($$.nodep, "inject", MMS_PN_CMD); - } - inject_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(REPORTMODE) && - MMS_PAR_CHK_FLAG(REPORT) == 0) { - yyerror - ("a report clause is required with a " - "reportmode clause"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -inject_arg_list - : inject_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | inject_arg_list inject_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -inject_arg - : task_clause - | slotgroup_clause - | match_clause - | order_clause - | number_clause - | report_group - | error { yyclearin; $$.nodep = NULL; } - ; - -goodbye_cmd - : GOODBYE - { - MMS_PAR_ALLOC_NODE($$.nodep, "goodbye", MMS_PN_CMD); - } - task_clause ';' - { - $$.nodep = $2.nodep; - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -end_cmd : END - { - MMS_PAR_ALLOC_NODE($$.nodep, "end", MMS_PN_CMD); - } - end_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -end_arg_list - : end_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | end_arg_list end_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -end_arg : task_clause - | abort_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -abort_clause - : abort - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -abort : ABORT - { - MMS_PAR_CHK_DUP(ABORT); - } - | STRING - { - if (strcmp($1.str, "abort")) { - yyerror("unexpected STRING, expecting " - "abort"); - YYERROR; - } - $$.str = $1.str; - } - ; - -eject_cmd - : EJECT - { - MMS_PAR_ALLOC_NODE($$.nodep, "eject", MMS_PN_CMD); - } - eject_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(REPORTMODE) && - MMS_PAR_CHK_FLAG(REPORT) == 0) { - yyerror - ("a report clause is required with a " - "REPORTMODE clause"); - } - if (MMS_PAR_CHK_FLAG(MATCH) + - (MMS_PAR_CHK_FLAG(CARTID) || - MMS_PAR_CHK_FLAG(CART)) > 1) { - yyerror("match is incompatible with cartid " - "and cart"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -eject_arg_list - : eject_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | eject_arg_list eject_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -eject_arg - : task_clause - | slotgroup_clause - | match_clause - | cartridge_clause - | order_clause - | number_clause - | report_group - | error { yyclearin; $$.nodep = NULL; } - ; - -cartridge_clause - : cartid_clause - | cart_spec - ; - -cartid_clause - : CARTID '[' cartid_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "cartid", MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - } - ; - -cartid_list - : str_arg_list - ; - -cart_spec - : CART '[' str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "cart", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -slotgroup_clause - : SLOTGROUP - { - MMS_PAR_CHK_DUP(SLOTGROUP); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "slotgroup", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -deallocate_cmd - : DEALLOCATE - { - MMS_PAR_ALLOC_NODE($$.nodep, "deallocate", - MMS_PN_CMD); - } - deallocate_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(REPORTMODE) && - MMS_PAR_CHK_FLAG(REPORT) == 0) { - yyerror - ("a report clause is required with a " - "reportmode clause"); - } - if (MMS_PAR_CHK_FLAG(CPREPORTMODE) && - MMS_PAR_CHK_FLAG(CPREPORT) == 0) { - yyerror - ("a cpreport clause is required with a " - "cpreportmode clause"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -deallocate_arg_list - : deallocate_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | deallocate_arg_list deallocate_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -deallocate_arg - : task_clause - | volname_clause - | match_clause - | order_clause - | number_clause - | report_group - | error { yyclearin; $$.nodep = NULL; } - ; - -cpshow_cmd - : CPSHOW - { - MMS_PAR_ALLOC_NODE($$.nodep, "cpshow", MMS_PN_CMD); - } - cpshow_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(CPTYPE) == 0) { - yyerror("a cptype clause is required"); - } - if (MMS_PAR_CHK_FLAG(REPORTMODE) && - MMS_PAR_CHK_FLAG(REPORT) == 0) { - yyerror - ("a report clause is required with a " - "reportmode clause"); - } - if (MMS_PAR_CHK_FLAG(CPREPORTMODE) && - MMS_PAR_CHK_FLAG(CPREPORT) == 0) { - yyerror - ("a cpreport clause is required with a " - "cpreportmode clause"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -cpshow_arg_list - : cpshow_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | cpshow_arg_list cpshow_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -cpshow_arg - : task_clause - | cptype_clause - | match_clause - | order_clause - | number_clause - | report_group - | cpreport_group - | error { yyclearin; $$.nodep = NULL; } - ; - -cpscan_cmd - : CPSCAN - { - MMS_PAR_ALLOC_NODE($$.nodep, "cpscan", MMS_PN_CMD); - } - cpscan_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(ALL)) { - if (MMS_PAR_CHK_FLAG(FROMSLOT) || - MMS_PAR_CHK_FLAG(TOSLOT) || - MMS_PAR_CHK_FLAG(SLOT) || - MMS_PAR_CHK_FLAG(DRIVE)) { - yyerror("all is incompatible with " - "fromslot, toslot, " - "drive and slot"); - } - } - if (MMS_PAR_CHK_FLAG(SLOT)) { - if (MMS_PAR_CHK_FLAG(FROMSLOT) || - MMS_PAR_CHK_FLAG(TOSLOT) || - MMS_PAR_CHK_FLAG(ALL) || - MMS_PAR_CHK_FLAG(DRIVE)) { - yyerror("slot is incompatible with " - "fromslot, toslot, " - "drive and all"); - } - } - if (MMS_PAR_CHK_FLAG(DRIVE)) { - if (MMS_PAR_CHK_FLAG(FROMSLOT) || - MMS_PAR_CHK_FLAG(TOSLOT) || - MMS_PAR_CHK_FLAG(ALL) || - MMS_PAR_CHK_FLAG(SLOT)) { - yyerror - ("drive is incompatible with " - "fromslot, toslot, " - "all and slot"); - } - } - if (MMS_PAR_CHK_FLAG(FROMSLOT)) { - if (MMS_PAR_CHK_FLAG(DRIVE) || - MMS_PAR_CHK_FLAG(ALL) || - MMS_PAR_CHK_FLAG(SLOT)) { - yyerror - ("fromslot is incompatible with " - "all, drive and slot"); - } - } - if (MMS_PAR_CHK_FLAG(TOSLOT)) { - if (MMS_PAR_CHK_FLAG(DRIVE) || - MMS_PAR_CHK_FLAG(ALL) || - MMS_PAR_CHK_FLAG(SLOT)) { - yyerror - ("toslot is incompatible with " - "all, drive and slot"); - } - } - if (MMS_PAR_CHK_FLAG(FROMSLOT) + - MMS_PAR_CHK_FLAG(TOSLOT) == - 1) { - yyerror("fromslot and toslot must be " - "specified together"); - } - if (MMS_PAR_CHK_FLAG(REPORTMODE) && - MMS_PAR_CHK_FLAG(REPORT) == 0) { - yyerror - ("a report clause is required with a " - "reportmode clause"); - } - if (MMS_PAR_CHK_FLAG(CPREPORTMODE) && - MMS_PAR_CHK_FLAG(CPREPORT) == 0) { - yyerror - ("a cpreport clause is required with a " - "cpreportmode clause"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -cpscan_arg_list - : cpscan_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | cpscan_arg_list cpscan_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -cpscan_arg - : task_clause - | all_spec - | from_spec - | to_spec - | match_clause - | order_clause - | number_clause - | report_group - | scan_slot_clause - | drive_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -all_spec - : all - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -all : ALL - { - MMS_PAR_CHK_DUP(ALL); - if (MMS_PAR_CHK_FLAG(FROMSLOT) || - MMS_PAR_CHK_FLAG(TOSLOT)) { - yyerror("all is incompatible with " - "fromslot and toslot"); - YYERROR; - } - } - | STRING - { - if (strcmp($1.str, "all") == 0) { - MMS_PAR_CHK_DUP(ALL); - if (MMS_PAR_CHK_FLAG(FROMSLOT) || - MMS_PAR_CHK_FLAG(TOSLOT)) { - yyerror("all is incompatible with " - "fromslot and toslot"); - YYERROR; - } - } else { - yyerror("unexpected STRING, expecting " - "full or partial"); - YYERROR; - } - $$.str = $1.str; - } - ; - -from_spec - : FROMSLOT - { - MMS_PAR_CHK_DUP(FROMSLOT); - if (MMS_PAR_CHK_FLAG(ALL)) { - yyerror("all is incompatible with " - "fromslot and toslot"); - YYERROR; - } - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "fromslot", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -to_spec : TOSLOT - { - MMS_PAR_CHK_DUP(TOSLOT); - if (MMS_PAR_CHK_FLAG(ALL)) { - yyerror("all is incompatible with " - "fromslot and toslot"); - YYERROR; - } - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "toslot", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -cpreset_cmd - : CPRESET - { - MMS_PAR_ALLOC_NODE($$.nodep, "cpreset", MMS_PN_CMD); - } - cpreset_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(CPTYPE) == 0) { - yyerror("a cptype clause is required"); - } - if (MMS_PAR_CHK_FLAG(REPORTMODE) && - MMS_PAR_CHK_FLAG(REPORT) == 0) { - yyerror - ("a report clause is required with a " - "reportmode clause"); - } - if (MMS_PAR_CHK_FLAG(CPREPORTMODE) && - MMS_PAR_CHK_FLAG(CPREPORT) == 0) { - yyerror - ("a cpreport clause is required with a " - "cpreportmode clause"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -cpreset_arg_list - : cpreset_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | cpreset_arg_list cpreset_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -cpreset_arg - : task_clause - | cptype_clause - | scope_arg - | match_clause - | order_clause - | number_clause - | report_group - | cpreport_group - | error { yyclearin; $$.nodep = NULL; } - ; - -cpstart_cmd - : CPSTART - { - MMS_PAR_ALLOC_NODE($$.nodep, "cpstart", MMS_PN_CMD); - } - cpstart_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(CPTYPE) == 0) { - yyerror("a cptype clause is required"); - } - if (MMS_PAR_CHK_FLAG(REPORTMODE) && - MMS_PAR_CHK_FLAG(REPORT) == 0) { - yyerror - ("a report clause is required with a " - "reportmode clause"); - } - if (MMS_PAR_CHK_FLAG(CPREPORTMODE) && - MMS_PAR_CHK_FLAG(CPREPORT) == 0) { - yyerror - ("a cpreport clause is required with a " - "cpreportmode clause"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -cpstart_arg_list - : cpstart_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | cpstart_arg_list cpstart_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -cpstart_arg - : task_clause - | cptype_clause - | match_clause - | order_clause - | number_clause - | report_group - | cpreport_group - | error { yyclearin; $$.nodep = NULL; } - ; - -cpexit_cmd - : CPEXIT - { - MMS_PAR_ALLOC_NODE($$.nodep, "cpexit", MMS_PN_CMD); - } - cpexit_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(CPTYPE) == 0) { - yyerror("a cptype clause is required"); - } - if (MMS_PAR_CHK_FLAG(REPORTMODE) && - MMS_PAR_CHK_FLAG(REPORT) == 0) { - yyerror - ("a report clause is required with a " - "reportmode clause"); - } - if (MMS_PAR_CHK_FLAG(CPREPORTMODE) && - MMS_PAR_CHK_FLAG(CPREPORT) == 0) { - yyerror - ("a cpreport clause is required with a " - "cpreportmode clause"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -cpexit_arg_list - : cpexit_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | cpexit_arg_list cpexit_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -cpexit_arg - : task_clause - | cptype_clause - | match_clause - | order_clause - | number_clause - | report_group - | cpreport_group - | error { yyclearin; $$.nodep = NULL; } - ; - -cpattribute_cmd - : CPATTRIBUTE - { - MMS_PAR_ALLOC_NODE($$.nodep, "cpattribute", - MMS_PN_CMD); - } - cpattribute_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(CPTYPE) == 0) { - yyerror("a cptype clause is required"); - } - if (MMS_PAR_CHK_FLAG(CPSET) == 0 && - MMS_PAR_CHK_FLAG(CPUNSET) - == 0) { - yyerror("a cpset or cpunset clause is " - "required"); - } - if (MMS_PAR_CHK_FLAG(REPORTMODE) && - MMS_PAR_CHK_FLAG(REPORT) == 0) { - yyerror - ("a report clause is required with a " - "reportmode clause"); - } - if (MMS_PAR_CHK_FLAG(CPREPORTMODE) && - MMS_PAR_CHK_FLAG(CPREPORT) == 0) { - yyerror - ("a cpreport clause is required with a " - "cpreportmode clause"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -cpattribute_arg_list - : cpattribute_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | cpattribute_arg_list cpattribute_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -cpattribute_arg - : task_clause - | cptype_clause - | cpset_clause - | cpunset_clause - | match_clause - | order_clause - | number_clause - | report_group - | cpreport_group - | error { yyclearin; $$.nodep = NULL; } - ; - -cptype_clause - : CPTYPE - { - MMS_PAR_CHK_DUP(CPTYPE); - } - '[' cptype_spec ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "cptype", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -cptype_spec - : cptype - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -cptype : LM - | DM - | STRING - { - if (strcmp($1.str, "LM") && strcmp($1.str, "DM")) { - yyerror("unexpected STRING, expecting " - "LM or DM"); - YYERROR; - } - $$.str = $1.str; - } - ; - -cpset_clause - : CPSET '[' cpattrname cpattrvalue ']' - { - MMS_PAR_SET_FLAG(CPSET); - MMS_PAR_ALLOC_NODE($$.nodep, "cpset", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -cpunset_clause - : CPUNSET '[' cpattrname ']' - { - MMS_PAR_SET_FLAG(CPUNSET); - MMS_PAR_ALLOC_NODE($$.nodep, "cpunset", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -cpreport_group - : cpreport_clause - | cpreportmode_clause - ; - -cpreport_clause - : CPREPORT - { - MMS_PAR_CHK_DUP(CPREPORT); - } - '[' cpattrname_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "cpreport", - MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $4.listp); - } - ; - -cpattrname_list - : cpattrname - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | cpattrname_list cpattrname - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -cpreportmode_clause - : CPREPORTMODE - { - MMS_PAR_CHK_DUP(CPREPORTMODE); - } - '[' reportmode_arg_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "cpreportmode", - MMS_PN_CLAUSE); - if ((MMS_PAR_CHK_FLAG(NAME) + - MMS_PAR_CHK_FLAG(NAMEVALUE) + - MMS_PAR_CHK_FLAG(UNIQUE)) > 2) { - yyerror("only two of name, " - "namevalue and unique are allowed"); - YYERROR; - } - MMS_PAR_UNSET_FLAG(NAME); - MMS_PAR_UNSET_FLAG(NAMEVALUE); - MMS_PAR_UNSET_FLAG(UNIQUE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $4.listp); - } - ; - -cpattrname - : str_arg - ; - -cpattrvalue - : str_arg - ; - -cancel_cmd - : CANCEL - { - MMS_PAR_ALLOC_NODE($$.nodep, "cancel", MMS_PN_CMD); - } - cancel_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(REPORTMODE) && - MMS_PAR_CHK_FLAG(REPORT) == 0) { - yyerror - ("a report clause is required with a " - "reportmode clause"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -cancel_arg_list - : cancel_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | cancel_arg_list cancel_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -cancel_arg - : task_clause - | match_clause - | order_clause - | report_group - | error { yyclearin; $$.nodep = NULL; } - ; - -accept_cmd - : ACCEPT - { - MMS_PAR_ALLOC_NODE($$.nodep, "accept", MMS_PN_CMD); - } - accept_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(MATCH) && - MMS_PAR_CHK_FLAG(REQID)) { - yyerror("match and reqid are incompatible"); - } - if (MMS_PAR_CHK_FLAG(REPORTMODE) && - MMS_PAR_CHK_FLAG(REPORT) == 0) { - yyerror - ("a report clause is required with a " - "reportmode clause"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -accept_arg_list - : accept_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | accept_arg_list accept_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -accept_arg - : task_clause - | match_clause - | reqid_clause - | order_clause - | number_clause - | report_group - | error { yyclearin; $$.nodep = NULL; } - ; - -reqid_clause - : REQID - { - MMS_PAR_CHK_DUP(REQID); - } - '[' reqid_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "reqid", MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $4.listp); - } - ; - -reqid_list - : str_arg_list - ; - -respond_cmd - : RESPOND - { - MMS_PAR_ALLOC_NODE($$.nodep, "respond", MMS_PN_CMD); - } - respond_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(REQID) == 0) { - yyerror("a reqid clause is required"); - } - if (MMS_PAR_CHK_FLAG(MESSAGE) == 0) { - yyerror("a message clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -respond_arg_list - : respond_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | respond_arg_list respond_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -respond_arg - : task_clause - | message_clause - | respond_reqid_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -respond_reqid_clause - : REQID - { - MMS_PAR_CHK_DUP(REQID); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "reqid", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -response_cmd - : RESPONSE - { - mms_mmsp_allow_quote(1); - MMS_PAR_ALLOC_NODE($$.nodep, "response", MMS_PN_CMD); - } - response_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(UNACCEPTABLE) == 0 && - MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(UNACCEPTABLE)) { - if (MMS_PAR_CHK_FLAG(TEXT)) { - yyerror - ("unacceptable is incompatible " - "with text and task"); - } - } else if (MMS_PAR_CHK_FLAG(ACCEPTED)) { - if (MMS_PAR_CHK_FLAG(MESSAGE) || - MMS_PAR_CHK_FLAG(TEXT)) { - yyerror("accepted is incompatible " - "with message and task"); - } - } else if (MMS_PAR_CHK_FLAG(SUCCESS)) { - ; - } else if (MMS_PAR_CHK_FLAG(INTERMEDIATE)) { - ; - } else if (MMS_PAR_CHK_FLAG(CANCELLED)) { - if (MMS_PAR_CHK_FLAG(TEXT)) { - yyerror("cancelled is incompatible " - "with text"); - } - } else if (MMS_PAR_CHK_FLAG(ERROR)) { - if (MMS_PAR_CHK_FLAG(TEXT)) { - yyerror("error is incompatible " - "with text"); - } - } else { - yyerror("one of unacceptable, accepted, " - "success, intermediate, " - "cancelled or error is " "required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -response_arg_list - : response_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | response_arg_list response_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -response_arg - : UNACCEPTABLE - { - MMS_PAR_CHK_DUP(UNACCEPTABLE); - if (MMS_PAR_CHK_FLAG(ACCEPTED) || - MMS_PAR_CHK_FLAG(SUCCESS) || - MMS_PAR_CHK_FLAG(INTERMEDIATE) || - MMS_PAR_CHK_FLAG(CANCELLED) || - MMS_PAR_CHK_FLAG(ERROR)) { - yyerror("unacceptable is incompatible with " - "accepted, intermediate," - "success, cancelled and error"); - YYERROR; - } - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - | ACCEPTED - { - MMS_PAR_CHK_DUP(ACCEPTED); - if (MMS_PAR_CHK_FLAG(UNACCEPTABLE) || - MMS_PAR_CHK_FLAG(SUCCESS) || - MMS_PAR_CHK_FLAG(INTERMEDIATE) || - MMS_PAR_CHK_FLAG(CANCELLED) || - MMS_PAR_CHK_FLAG(ERROR)) { - yyerror("accepted is incompatible with " - "unacceptable, intermediate," - "success, cancelled and error"); - YYERROR; - } - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - | SUCCESS - { - MMS_PAR_CHK_DUP(SUCCESS); - if (MMS_PAR_CHK_FLAG(UNACCEPTABLE) || - MMS_PAR_CHK_FLAG(ACCEPTED) || - MMS_PAR_CHK_FLAG(INTERMEDIATE) || - MMS_PAR_CHK_FLAG(CANCELLED) || - MMS_PAR_CHK_FLAG(ERROR)) { - yyerror("success is incompatible with " - "unacceptable, intermediate," - "accepted, cancelled and error"); - YYERROR; - } - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - | INTERMEDIATE - { - MMS_PAR_CHK_DUP(INTERMEDIATE); - if (MMS_PAR_CHK_FLAG(UNACCEPTABLE) || - MMS_PAR_CHK_FLAG(ACCEPTED) || - MMS_PAR_CHK_FLAG(SUCCESS) || - MMS_PAR_CHK_FLAG(CANCELLED) || - MMS_PAR_CHK_FLAG(ERROR)) { - yyerror("intermediate is incompatible with " - "unacceptable, success, " - "accepted, cancelled and error"); - YYERROR; - } - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - - | cancelled - { - MMS_PAR_CHK_DUP(CANCELLED); - if (MMS_PAR_CHK_FLAG(UNACCEPTABLE) || - MMS_PAR_CHK_FLAG(INTERMEDIATE) || - MMS_PAR_CHK_FLAG(ACCEPTED) || - MMS_PAR_CHK_FLAG(SUCCESS) || - MMS_PAR_CHK_FLAG(ERROR)) { - yyerror("cancelled is incompatible with " - "unacceptable, intermediate," - "accepted, cancelled and error"); - YYERROR; - } - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - | STRING - { - if (strcmp($1.str, "unacceptable") == 0) { - MMS_PAR_CHK_DUP(UNACCEPTABLE); - if (MMS_PAR_CHK_FLAG(ACCEPTED) || - MMS_PAR_CHK_FLAG(SUCCESS) || - MMS_PAR_CHK_FLAG(INTERMEDIATE) || - MMS_PAR_CHK_FLAG(CANCELLED) || - MMS_PAR_CHK_FLAG(ERROR)) { - yyerror - ("unacceptable is incompatible " - "with " - "accepted, intermediate," - "success, cancelled and error"); - YYERROR; - } - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, - MMS_PN_KEYWORD); - } else if (strcmp($1.str, "accepted") == 0) { - MMS_PAR_CHK_DUP(ACCEPTED); - if (MMS_PAR_CHK_FLAG(UNACCEPTABLE) || - MMS_PAR_CHK_FLAG(SUCCESS) || - MMS_PAR_CHK_FLAG(INTERMEDIATE) || - MMS_PAR_CHK_FLAG(CANCELLED) || - MMS_PAR_CHK_FLAG(ERROR)) { - yyerror - ("accepted is incompatible with " - "unacceptable, intermediate," - "success, cancelled and error"); - YYERROR; - } - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, - MMS_PN_KEYWORD); - } else if (strcmp($1.str, "success") == 0) { - MMS_PAR_CHK_DUP(SUCCESS); - if (MMS_PAR_CHK_FLAG(UNACCEPTABLE) || - MMS_PAR_CHK_FLAG(INTERMEDIATE) || - MMS_PAR_CHK_FLAG(ACCEPTED) || - MMS_PAR_CHK_FLAG(CANCELLED) || - MMS_PAR_CHK_FLAG(ERROR)) { - yyerror - ("success is incompatible with " - "unacceptable, intermediate," - "accepted, cancelled and " - "error"); - YYERROR; - } - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, - MMS_PN_KEYWORD); - } else if (strcmp($1.str, "intermediate") == 0) { - MMS_PAR_CHK_DUP(INTERMEDIATE); - if (MMS_PAR_CHK_FLAG(UNACCEPTABLE) || - MMS_PAR_CHK_FLAG(SUCCESS) || - MMS_PAR_CHK_FLAG(ACCEPTED) || - MMS_PAR_CHK_FLAG(CANCELLED) || - MMS_PAR_CHK_FLAG(ERROR)) { - yyerror - ("intermediate is incompatible " - "with unacceptable, success," - "accepted, cancelled and " - "error"); - YYERROR; - } - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, - MMS_PN_KEYWORD); - } else if (strcmp($1.str, "cancelled") == 0) { - MMS_PAR_CHK_DUP(CANCELLED); - if (MMS_PAR_CHK_FLAG(UNACCEPTABLE) || - MMS_PAR_CHK_FLAG(ACCEPTED) || - MMS_PAR_CHK_FLAG(INTERMEDIATE) || - MMS_PAR_CHK_FLAG(SUCCESS) || - MMS_PAR_CHK_FLAG(ERROR)) { - yyerror("cancelled is incompatible " - "with " - "unacceptable, intermediate," - "accepted, cancelled and " - "error"); - YYERROR; - } - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, - MMS_PN_KEYWORD); - } else { - yyerror("unexpected STRING, expecting " - "unacceptable, accepted, success, " - "intermediate, " - "cancelled, error, text, task or " - "message"); - YYERROR; - } - } - | ERROR '[' err_class_spec - { - /* Looking for an error code */ - mms_pwka->par_wka_flags |= MMS_PW_ERROR_CODE; - } - err_code_spec ']' - { - MMS_PAR_CHK_DUP(ERROR); - if (MMS_PAR_CHK_FLAG(UNACCEPTABLE) || - MMS_PAR_CHK_FLAG(ACCEPTED) || - MMS_PAR_CHK_FLAG(INTERMEDIATE) || - MMS_PAR_CHK_FLAG(SUCCESS) || - MMS_PAR_CHK_FLAG(CANCELLED)) { - yyerror("error is incompatible with " - "unacceptable, intermediate, " - "accepted, success and cancelled"); - YYERROR; - } - MMS_PAR_ALLOC_NODE($$.nodep, "error", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - } - | TEXT '[' text_arg_list ']' - { - MMS_PAR_SET_FLAG(TEXT); - MMS_PAR_ALLOC_NODE($$.nodep, "text", MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - } - | task_clause - | message_clause - | error - { - yyclearin; - $$.nodep = NULL; - } - ; - -cancelled - : CANCELLED - | CANCELED - { - $$.str = "cancelled"; - } - ; - -text_arg_list - : text_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | text_arg_list text_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -text_arg: str_arg - | ATTRLIST '[' str_arg_list ']' - { - MMS_PAR_SET_FLAG(ATTRLIST); - MMS_PAR_ALLOC_NODE($$.nodep, "attrlist", - MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - } - ; - -err_class_spec - : error_class - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -error_class - : COMPAT | CONFIG | EXIST | EXPLICIT | INTERNAL | INVALID | PERMPRIV - | RETRY | SUBOP | LANGUAGE | STATE | MM_C_MANAGEMENT | MM_C_INVALID - | LM_C_INVALID | LM_C_COMMAND | DM_C_INVALID | DM_C_COMMAND - | STRING - { - if (strcmp($1.str, "compat") && - strcmp($1.str, "config") && - strcmp($1.str, "exist") && - strcmp($1.str, "explicit") && - strcmp($1.str, "internal") && - strcmp($1.str, "invalid") && - strcmp($1.str, "permpriv") && - strcmp($1.str, "retry") && - strcmp($1.str, "subop") && - strcmp($1.str, "language") && - strcmp($1.str, "state") && - strcmp($1.str, "MM_C_MANAGEMENT") && - strcmp($1.str, "MM_C_INVALID") && - strcmp($1.str, "DM_C_INVALID") && - strcmp($1.str, "DM_C_COMMAND") && - strcmp($1.str, "LM_C_INVALID") && - strcmp($1.str, "LM_C_COMMAND")) { - yyerror("unexpected STRING, expecting " - "compat, config, exist, explicit, " - "internal, invalid, permpriv, " - "retry, subop, language, state, " - "MM_C_MANAGEMENT, MM_C_INVALID, " - "DM_C_INVALID, " - "DM_C_COMMAND, LM_C_INVALID, " - "or LM_C_COMMAND"); - YYERROR; - } - $$.str = $1.str; - } - ; - -err_code_spec - : err_code - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - - -err_code: ERROR_CODE - | STRING - ; - -message_clause - : MESSAGE - { - MMS_PAR_CHK_DUP(MESSAGE); - } - '[' message_arg_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "message", - MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $4.listp); - } - ; - -message_arg_list - : message_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | message_arg_list message_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -message_arg - : id_clause - | arg_clause - | locale_text_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -id_clause - : ID - { - MMS_PAR_CHK_DUP(ID); - } - '[' manufacturer model messageid ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "id", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $6.nodep); - } - ; - -manufacturer - : str_arg - ; - -model : str_arg - ; - -messageid - : str_arg - ; - -arg_clause - : ARGUMENTS - { - MMS_PAR_CHK_DUP(ARGUMENTS); - } - '[' arg_pair_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "arguments", - MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $4.listp); - } - ; - -arg_pair_list - : str_arg str_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - mms_par_list_insert_tail($$.listp, $2.nodep); - } - | arg_pair_list str_arg str_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - mms_par_list_insert_tail($1.listp, $3.nodep); - $$.listp = $1.listp; - } - ; - -locale_text_clause - : LOCTEXT - { - MMS_PAR_CHK_DUP(LOCTEXT); - } - '[' language localized_string ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "loctext", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - } - ; - -localized_string - : str_arg - ; - -language: str_arg - ; - -unmount_cmd - : UNMOUNT - { - MMS_PAR_ALLOC_NODE($$.nodep, "unmount", MMS_PN_CMD); - } - unmount_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(TYPE) == 0) { - yyerror("a type clause is required"); - } - if (MMS_PAR_CHK_FLAG(MATCH) == 0 && - MMS_PAR_CHK_FLAG(VOLNAME) == 0) { - yyerror("a match or volname clause " - "is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -unmount_arg_list - : unmount_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | unmount_arg_list unmount_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -unmount_arg - : task_clause - | mount_type_clause - | volname_clause - | match_clause - | signature_clause - | order_clause - | number_clause - | report_clause - | reportmode_clause - | physicalunmount_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -signature_clause - : SIGNATURE - { - MMS_PAR_CHK_DUP(SIGNATURE); - } - '[' signature_spec_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "signature", - MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $4.listp); - } - ; - -signature_spec_list - : clean_spec - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | partition_signature_type str_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - mms_par_list_insert_tail($$.listp, $2.nodep); - } - ; - -clean_spec - : clean - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -clean : CLEAN - { - MMS_PAR_CHK_DUP(CLEAN); - } - | STRING - { - if (strcmp($1.str, "clean")) { - yyerror("unexpected STRING, expecting " - "clean"); - YYERROR; - } - $$.str = $1.str; - } - ; - -physicalunmount_clause - : physicalunmount - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -physicalunmount - : PHYSICALUNMOUNT - { - MMS_PAR_CHK_DUP(PHYSICALUNMOUNT); - } - | STRING - { - if (strcmp($1.str, "physicalunmount")) { - yyerror("unexpected STRING, expecting " - "physicalunmount"); - YYERROR; - } - $$.str = $1.str} - - ; - -unwelcome_cmd - : MMS_UNWELCOME - { - MMS_PAR_ALLOC_NODE($$.nodep, "unwelcome", MMS_PN_CMD); - } - unwelcome_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -unwelcome_arg_list - : unwelcome_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | unwelcome_arg_list unwelcome_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -unwelcome_arg - : str_arg - { - char *err_list[] = { - "SSAI_E_PROTOCOL_ERROR", - "SSAI_E_ACCESS_DENIED", - "SSAI_E_DUPLICATE_SESSION", - "SSAI_E_UNKNOWN_LANGUAGE", - "SSAI_E_UNSUPPORTED_LANGUAGE", - "SSAI_E_SSL" - }; - int num_errs = sizeof (err_list) / sizeof (char *); - int i; - - $$.nodep = $1.nodep; - for (i = 0; i < num_errs; i++) { - if (strcmp(mms_pn_token($$.nodep), - err_list[i]) == 0) { - break; - } - } - if (i == num_errs) { - /* Invalid error */ - char msg[200]; - sprintf(msg, "Invalid error %s", - mms_pn_token($$.nodep)); - yyerror(msg); - YYERROR; - } - } - ; - -welcome_cmd - : MMS_WELCOME - { - MMS_PAR_ALLOC_NODE($$.nodep, "welcome", MMS_PN_CMD); - } - welcome_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(VERSION) == 0) { - yyerror("a version clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -welcome_arg_list - : welcome_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | welcome_arg_list welcome_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -welcome_arg - : version_clause - | servername_clause - | auth_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -servername_clause - : SERVERNAME - { - MMS_PAR_CHK_DUP(SERVERNAME); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "servername", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -mmp_mount_cmd - : MMP_MOUNT - { - MMS_PAR_ALLOC_NODE($$.nodep, "mount", MMS_PN_CMD); - } - mmp_mount_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(REPORTMODE) && - MMS_PAR_CHK_FLAG(REPORT) == 0) { - yyerror - ("a report clause is required with a " - "reportmode clause"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -mmp_mount_arg_list - : mmp_mount_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | mmp_mount_arg_list mmp_mount_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -mmp_mount_arg - : task_clause - | mount_type_clause - | volname_clause - | firstmount_clause - | accessmode_clause - | match_clause - | order_clause - | number_clause - | report_group - | when_clause - | where_clause - | retention_clause - | filename_clause - | blocksize_clause - | filesequence_clause - | volumeid_clause - | user_clause - | msgfile_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -msgfile_clause - : MSGFILE '[' str_arg ']' - { - MMS_PAR_CHK_DUP(MSGFILE); - MMS_PAR_ALLOC_NODE($$.nodep, "msgfile", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -retention_clause - : RETENTION '[' num_arg ']' - { - MMS_PAR_CHK_DUP(RETENTION); - MMS_PAR_ALLOC_NODE($$.nodep, "retention", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -user_clause - : USER '[' str_arg ']' - { - MMS_PAR_CHK_DUP(USER); - MMS_PAR_ALLOC_NODE($$.nodep, "user", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -volumeid_clause - : VOLUMEID - { - MMS_PAR_CHK_DUP(VOLUMEID); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "volumeid", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - if (strlen(mms_pn_token($4.nodep)) > 6) { - yyerror - ("Volume ID greater than 6 characters"); - } - } - ; - -filename_clause - : FILENAME - { - MMS_PAR_CHK_DUP(FILENAME); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "filename", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - if (strlen(mms_pn_token($4.nodep)) > 17) { - yyerror - ("Filename greater than 17 characters"); - } - } - ; - -blocksize_clause - : BLOCKSIZE - { - MMS_PAR_CHK_DUP(BLOCKSIZE); - } - '[' num_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "blocksize", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -filesequence_clause - : FILESEQUENCE - { - MMS_PAR_CHK_DUP(FILESEQUENCE); - } - '[' num_arg ']' - { - int fseq; - MMS_PAR_ALLOC_NODE($$.nodep, "filesequence", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - fseq = 0; - sscanf(mms_pn_token($4.nodep), "%d", &fseq); - if (fseq == 0 || (fseq > 1)) { - char msg[100]; - sprintf("Unsupported filesequence: %s", - mms_pn_token($4.nodep)); - yyerror(msg); - } - } - ; - -where_clause - : WHERE - { - MMS_PAR_CHK_DUP(WHERE); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "where", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -mount_type_clause - : TYPE - { - MMS_PAR_CHK_DUP(TYPE); - } - '[' mount_type_arg_spec ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "type", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -mount_type_arg_spec - : mount_type_arg - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -mount_type_arg - : SIDE | PARTITION | VOLUME - | STRING - { - if (strcmp($1.str, "side") && - strcmp($1.str, "partition") && - strcmp($1.str, "volume")) { - yyerror("unexpected STRING, expecting " - "side, partition or volume"); - YYERROR; - } - $$.str = $1.str; - } - ; - -firstmount_clause - : FIRSTMOUNT '[' cap_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "firstmount", - MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - } - ; - -accessmode_clause - : ACCESSMODE '[' cap_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "accessmode", - MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - } - ; - -cap_list - : str_arg_list - ; - -rename_cmd - : RENAME - { - MMS_PAR_ALLOC_NODE($$.nodep, "rename", MMS_PN_CMD); - } - rename_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(NEWVOLNAME) == 0) { - yyerror("a newvolname clause is required"); - } - if (MMS_PAR_CHK_FLAG(MATCH) && - MMS_PAR_CHK_FLAG(VOLNAME)) { - yyerror("match and volname clauses are " - "incompatible"); - } - if (MMS_PAR_CHK_FLAG(REPORTMODE) && - MMS_PAR_CHK_FLAG(REPORT) - == 0) { - yyerror - ("a report clause is required with a " - "reportmode clause"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -rename_arg_list - : rename_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | rename_arg_list rename_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -rename_arg - : task_clause - | newvolname_clause - | volname_clause - | match_clause - | order_clause - | number_clause - | report_group - | error { yyclearin; $$.nodep = NULL; } - ; - - -attribute_cmd - : ATTRIBUTE - { - MMS_PAR_ALLOC_NODE($$.nodep, "attribute", MMS_PN_CMD); - } - attribute_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if ((MMS_PAR_CHK_FLAG(SET) + - MMS_PAR_CHK_FLAG(UNSET)) == 0) { - yyerror("one of set and unset clauses is " - "required"); - } - if (MMS_PAR_CHK_FLAG(MATCH) && - MMS_PAR_CHK_FLAG(VOLNAME)) { - yyerror("only one of match and volname is " - "allowed"); - } - if (MMS_PAR_CHK_FLAG(REPORTMODE) && - MMS_PAR_CHK_FLAG(REPORT) - == 0) { - yyerror - ("a report clause is required with a " - "reportmode clause"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -attribute_arg_list - : attribute_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | attribute_arg_list attribute_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -attribute_arg - : task_clause - | set_clause - | unset_clause - | match_clause - | order_clause - | number_clause - | report_group - | error { yyclearin; $$.nodep = NULL; } - ; - -unset_clause - : UNSET '[' unset_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "unset", MMS_PN_CLAUSE); - MMS_PAR_SET_FLAG(UNSET); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -unset_arg - : object_attribute_spec - ; - -allocate_cmd - : ALLOCATE - { - MMS_PAR_ALLOC_NODE($$.nodep, "allocate", MMS_PN_CMD); - } - allocate_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(NEWVOLNAME) == 0) { - yyerror("a newvolname clause is required"); - } - if (MMS_PAR_CHK_FLAG(REPORTMODE) && - MMS_PAR_CHK_FLAG(REPORT) == 0) { - yyerror - ("a report clause is required with a " - "reportmode clause"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -allocate_arg_list - : allocate_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | allocate_arg_list allocate_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -allocate_arg - : task_clause - | newvolname_clause - | allocate_who_clause - | match_clause - | order_clause - | number_clause - | report_group - | error { yyclearin; $$.nodep = NULL; } - ; - -allocate_who_clause - : WHO - { - MMS_PAR_CHK_DUP(WHO); - } - '[' str_arg opt_str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "who", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - } - ; - -newvolname_clause - : NEWVOLNAME - { - MMS_PAR_CHK_DUP(NEWVOLNAME); - } - '[' newvolname_arg_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "newvolname", - MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $4.listp); - } - ; - -newvolname_arg_list - : newvolname_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | newvolname_arg_list newvolname_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -newvolname_arg - : str_arg - ; - -delete_cmd - : DELETE - { - MMS_PAR_ALLOC_NODE($$.nodep, "delete", MMS_PN_CMD); - } - delete_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(TYPE) == 0) { - yyerror("a type clause is required"); - } - if (MMS_PAR_CHK_FLAG(REPORTMODE) && - MMS_PAR_CHK_FLAG(REPORT) == 0) { - yyerror - ("a report clause is required with a " - "reportmode clause"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -delete_arg_list - : delete_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | delete_arg_list delete_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -delete_arg - : task_clause - | object_type_clause - | match_clause - | volname_clause - | order_clause - | number_clause - | report_group - | error { yyclearin; $$.nodep = NULL; } - ; - -create_cmd - : CREATE - { - MMS_PAR_ALLOC_NODE($$.nodep, "create", MMS_PN_CMD); - } - create_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(TYPE) == 0) { - yyerror("a type clause is required"); - } - if (MMS_PAR_CHK_FLAG(SET) == 0) { - yyerror("a set clause is required"); - } - if (MMS_PAR_CHK_FLAG(REPORTMODE) && - MMS_PAR_CHK_FLAG(REPORT) == 0) { - yyerror - ("a report clause is required with a " - "reportmode clause"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -create_arg_list - : create_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | create_arg_list create_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -create_arg - : task_clause - | object_type_clause - | set_clause - | report_group - | error { yyclearin; $$.nodep = NULL; } - ; - -object_type_clause - : TYPE - { - MMS_PAR_CHK_DUP(TYPE); - } - '[' object_spec ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "type", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -set_clause - : SET '[' object_attribute_spec set_arg ']' - { - MMS_PAR_SET_FLAG(SET); - MMS_PAR_ALLOC_NODE($$.nodep, "set", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -set_arg : str_arg - ; - -show_cmd: SHOW - { - MMS_PAR_ALLOC_NODE($$.nodep, "show", MMS_PN_CMD); - } - show_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (MMS_PAR_CHK_FLAG(REPORTMODE) && - MMS_PAR_CHK_FLAG(REPORT) == 0) { - yyerror - ("a report clause is required with a " - "reportmode clause"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -show_arg_list - : show_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | show_arg_list show_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -show_arg - : task_clause - | match_clause - | volname_clause - | order_clause - | number_clause - | report_group - | error { yyclearin; $$.nodep = NULL; } - ; - -match_clause - : MATCH - { - MMS_PAR_CHK_DUP(MATCH); - if (MMS_PAR_CHK_FLAG(VOLNAME) == 1) { - yyerror("a volname clause is incompatible " - "with the match clause"); - YYERROR; - } - } - '[' base_match ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "match", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -volname_clause - : VOLNAME - { - MMS_PAR_CHK_DUP(VOLNAME); - if (MMS_PAR_CHK_FLAG(MATCH) == 1) { - yyerror("a volname clause is incompatible " - "with the match clause"); - YYERROR; - } - } - '[' volname_arg_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "volname", - MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $4.listp); - } - ; - -order_clause - : ORDER - { - MMS_PAR_CHK_DUP(ORDER); - } - '[' order_one ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "order", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -number_clause - : NUMBER - { - MMS_PAR_CHK_DUP(NUMBER); - } - '[' number_spec ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "number", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -number_spec - : number_arg opt_range_spec - { - if ($2.nodep == NULL) { - /* Not a range spec */ - $$.nodep = $1.nodep; - } else { - $$.nodep = $2.nodep; - mms_list_insert_head(&$$.nodep-> - pn_arglist, $1.nodep); - } - } - ; - -opt_range_spec - : /* nothing */ - { - $$.nodep = NULL; - } - | RANGE - { - if (MMS_PAR_CHK_FLAG(LAST)) { - /* Last canot be start of range */ - yyerror - ("range cannot be started with LAST"); - YYERROR; - } - mms_pwka->par_wka_flags |= MMS_PW_KEYWORD; - } - number_arg - { - if (strcmp(mms_pn_token($3.nodep), "FIRST") == 0) { - yyerror("range cannot be terminated " - "with FIRST"); - YYERROR; - } - MMS_PAR_ALLOC_NODE($$.nodep, "..", MMS_PN_RANGE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -number_arg - : NUMERIC - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, - MMS_PN_NUMERIC | MMS_PN_STRING); - } - | NUMERIC_STR - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, - MMS_PN_NUMERIC | MMS_PN_STRING); - } - | FIRST - { - MMS_PAR_CHK_DUP(FIRST); - MMS_PAR_ALLOC_NODE($$.nodep, "FIRST", MMS_PN_KEYWORD); - } - | LAST - { - MMS_PAR_CHK_DUP(LAST); - MMS_PAR_ALLOC_NODE($$.nodep, "LAST", MMS_PN_KEYWORD); - } - | STRING - { - if (strcmp($1.str, "FIRST") == 0) { - MMS_PAR_CHK_DUP(FIRST); - } else if (strcmp($1.str, "LAST") == 0) { - MMS_PAR_CHK_DUP(LAST); - } else { - yyerror("unexpected STRING, expecting " - "first, last or NUMBER"); - YYERROR; - } - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -report_group - : report_clause - | reportmode_clause - ; - -report_clause - : REPORT - { - MMS_PAR_CHK_DUP(REPORT); - } - '[' report_arg_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "report", MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $4.listp); - } - ; - -report_arg_list - : report_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | report_arg_list report_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -report_arg - : object_attribute_spec - | object_spec - ; - -reportmode_clause - : REPORTMODE - { - MMS_PAR_CHK_DUP(REPORTMODE); - } - '[' reportmode_arg_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "reportmode", - MMS_PN_CLAUSE); - if ((MMS_PAR_CHK_FLAG(NAME) + - MMS_PAR_CHK_FLAG(NAMEVALUE) + - MMS_PAR_CHK_FLAG(UNIQUE)) > 2) { - yyerror("only two of name, " - "namevalue and unique are allowed"); - YYERROR; - } - MMS_PAR_UNSET_FLAG(NAME); - MMS_PAR_UNSET_FLAG(NAMEVALUE); - MMS_PAR_UNSET_FLAG(UNIQUE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $4.listp); - } - ; - -reportmode_arg_list - : reportmode_arg_spec - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | reportmode_arg_list reportmode_arg_spec - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -reportmode_arg_spec - : reportmode_arg - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -reportmode_arg - : NAME - { - MMS_PAR_CHK_DUP(NAME); - } - | NAMEVALUE - { - MMS_PAR_CHK_DUP(NAMEVALUE); - } - | UNIQUE - { - MMS_PAR_CHK_DUP(UNIQUE); - } - | VALUE - { - MMS_PAR_CHK_DUP(VALUE); - } - | NUMBER - { - MMS_PAR_CHK_DUP(NUMBER); - } - | STRING - { - if (strcmp($1.str, "name") && - strcmp($1.str, "namevalue") && - strcmp($1.str, "unique") && - strcmp($1.str, "number") && - strcmp($1.str, "value")) { - yyerror("unexpected STRING, expecting " - "name, namevalue, unique or value"); - YYERROR; - } - $$.str = $1.str; - } - ; - -order_one - : STRLOHI '(' object_attribute_spec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "strlohi", MMS_PN_OPS); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - | STRHILO '(' object_attribute_spec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "strhilo", MMS_PN_OPS); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - | NUMLOHI '(' object_attribute_spec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "numlohi", MMS_PN_OPS); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - | NUMHILO '(' object_attribute_spec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "numhilo", MMS_PN_OPS); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -object_attribute_spec - : object_spec '.' attr_name_spec - { - $3.nodep->pn_type = MMS_PN_ATTR; - mms_par_list_insert_tail(&$1.nodep->pn_arglist, - $3.nodep); - $$.nodep = $1.nodep; - } - ; - -attr_name_spec - : str_arg - ; - -object_spec - : objectname_token - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_OBJ); - } - ; - -base_match - : unaryattrop - | unarynegop - | unarysetop - | topmatch - ; - -unaryattrop - : ISATTR '(' object_attribute_spec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "isattr", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_UNARYOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - | NOATTR '(' object_attribute_spec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "noattr", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_UNARYOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -unarynegop - : NOT '(' matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "not", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_UNARYOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -unarysetop - : ISSET '(' object_attribute_spec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "isset", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_UNARYOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - | NOTSET '(' object_attribute_spec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "notset", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_UNARYOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -topmatch: binaryop - | multiop - ; - -binaryop: REGEX '(' matchspec matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "regex", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - (MMS_PN_MULTIOPS | MMS_PN_REGEX); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | STREQ '(' streq_spec streq_spec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "streq", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | STRNE '(' streq_spec streq_spec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "strne", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | STRLT '(' matchspec matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "strlt", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | STRLE '(' matchspec matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "strle", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | STRGT '(' matchspec matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "strgt", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | STRGE '(' matchspec matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "strge", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | HOSTEQ '(' matchspec matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "hosteq", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | HOSTNE '(' matchspec matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "hostne", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | TIMEEQ '(' matchspec matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "timeeq", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | TIMENE '(' matchspec matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "timene", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | TIMELT '(' matchspec matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "timelt", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | TIMELE '(' matchspec matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "timele", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | TIMEGT '(' matchspec matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "timegt", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | TIMEGE '(' matchspec matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "timege", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | NUMEQ '(' matchspec matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "numeq", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | NUMNE '(' matchspec matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "numne", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | NUMLT '(' matchspec matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "numlt", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | NUMLE '(' matchspec matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "numle", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | NUMGT '(' matchspec matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "numgt", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - | NUMGE '(' matchspec matchspec ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "numge", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -multiop : AND '(' matchspec_list ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "and", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - } - | OR '(' matchspec_list ')' - { - MMS_PAR_ALLOC_NODE($$.nodep, "or", MMS_PN_OPS); - mms_pwka->par_wka_cur_node->pn_flags |= - MMS_PN_MULTIOPS; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - } - ; - -matchspec_list - : matchspec - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | matchspec_list matchspec - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -streq_spec - : matchspec - ; - -matchspec - : topmatch - | unaryattrop - | unarysetop - | unarynegop - | object_attribute_spec - | str_arg - ; - -volname_arg_list - : str_arg_list - ; - -begin_cmd - : BEGIN_CMD - { - MMS_PAR_ALLOC_NODE($$.nodep, "begin", MMS_PN_CMD); - } - begin_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (MMS_PAR_CHK_FLAG(TASK) == 0) { - yyerror("a task clause is required"); - } - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -begin_arg_list - : begin_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | begin_arg_list begin_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -begin_arg - : task_clause - | when_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -task_clause - : TASK - { - MMS_PAR_CHK_DUP(TASK); - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "task", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -when_clause - : WHEN - { - MMS_PAR_CHK_DUP(WHEN); - } - '[' when_arg_spec ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "when", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -when_arg_spec - : when_arg - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -when_arg: IMMEDIATE - { - MMS_PAR_CHK_DUP(IMMEDIATE); - if (MMS_PAR_CHK_FLAG(BLOCKING) == 1) { - yyerror("blocking and immediate are " - "incompatible"); - YYERROR; - } - } - | BLOCKING - { - MMS_PAR_CHK_DUP(BLOCKING); - if (MMS_PAR_CHK_FLAG(IMMEDIATE) == 1) { - yyerror("blocking and immediate are " - "incompatible"); - YYERROR; - } - } - | STRING - { - if (strcmp($1.str, "immediate") == 0) { - MMS_PAR_CHK_DUP(IMMEDIATE); - if (MMS_PAR_CHK_FLAG(BLOCKING) == 1) { - yyerror - ("blocking and immediate are " - "incompatible"); - YYERROR; - } - } else if (strcmp($1.str, "blocking") == 0) { - MMS_PAR_CHK_DUP(BLOCKING); - if (MMS_PAR_CHK_FLAG(IMMEDIATE) == 1) { - yyerror - ("blocking and immediate are " - "incompatible"); - YYERROR; - } - } else { - yyerror("unexpected STRING, expecting " - "immediate or blocking"); - YYERROR; - } - $$.str = $1.str; - } - ; - -hello_cmd - : HELLO - { - MMS_PAR_ALLOC_NODE($$.nodep, "hello", MMS_PN_CMD); - } - hello_arg_list ';' - { - $$.nodep = $2.nodep; - mms_list_move_tail(&$$.nodep->pn_arglist, - $3.listp); - if (mms_pwka->par_wka_flags & MMS_PW_ERROR) { - YYERROR; - } - } - ; - -hello_arg_list - : hello_arg - { - MMS_PAR_ALLOC_LIST($$.listp); - mms_par_list_insert_tail($$.listp, $1.nodep); - } - | hello_arg_list hello_arg - { - mms_par_list_insert_tail($1.listp, $2.nodep); - $$.listp = $1.listp; - } - ; - -hello_arg - : client_clause - | instance_clause - | language_clause - | version_clause - | auth_clause - | tag_clause - | error { yyclearin; $$.nodep = NULL; } - ; - -client_clause - : CLIENT '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "client", MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - ; - -instance_clause - : INSTANCE '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "instance", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - - ; - -language_clause - : LANGUAGE '[' lang_arg_spec ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "language", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $3.nodep); - } - - ; - -lang_arg_spec - : lang_arg - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -lang_arg: MMP - | DMP - | LMP - | STRING - { - if (strcmp($1.str, "MMP") && - strcmp($1.str, "DMP") && - strcmp($1.str, "LMP")) { - yyerror("unexpected STRING, expecting " - "MMP, DMP or LMP"); - YYERROR; - } - $$.str = $1.str; - } - ; - -version_clause - : VERSION - { - MMS_PAR_CHK_DUP(VERSION); - } - '[' version_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "version", - MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $4.listp); - } - ; - -version_list - : str_arg_list - ; - -auth_clause - : password_clause - | certificate_clause - ; - -tag_clause - : TAG - { - MMS_PAR_CHK_DUP(TAG); - } - '[' tag_list ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "tag", MMS_PN_CLAUSE); - mms_list_move_tail(&$$.nodep->pn_arglist, - $4.listp); - } - ; - -tag_list - : str_arg_list - ; - - -password_clause - : PASSWORD - { - MMS_PAR_CHK_DUP(PASSWORD); - if (MMS_PAR_CHK_FLAG(CERTIFICATE)) { - yyerror("certificate and password " - "clauses are incompatible"); - YYERROR; - } - } - '[' str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "password", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - } - ; - -certificate_clause - : CERTIFICATE - { - MMS_PAR_CHK_DUP(CERTIFICATE); - if (MMS_PAR_CHK_FLAG(PASSWORD)) { - yyerror("certificate and password " - "clauses are incompatible"); - YYERROR; - } - } - '[' str_arg str_arg ']' - { - MMS_PAR_ALLOC_NODE($$.nodep, "certificate", - MMS_PN_CLAUSE); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $4.nodep); - mms_par_list_insert_tail(&$$.nodep->pn_arglist, - $5.nodep); - } - ; - -str_arg : string - | numeric_string - ; - -num_arg : number - | numeric_string - ; - -string : STRING - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_STRING); - } - ; - -number : NUMERIC - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, - MMS_PN_NUMERIC | MMS_PN_STRING); - } - ; - -numeric_string - : NUMERIC_STR - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, - MMS_PN_NUMERIC | MMS_PN_STRING); - } - ; - -opt_str_arg_list - : /* Empty */ { $$.listp = NULL; } - | str_arg_list - ; - -opt_str_arg - : /* Empty */ { $$.nodep = NULL; } - | str_arg - ; - -objectname_token - : APPLICATION | AI | BAY | CARTRIDGE | - CARTRIDGEGROUP | CARTRIDGEGROUPAPPLICATION | - CARTRIDGETYPE | CONNECTION | DM | DMBITFORMAT | - DMBITFORMATTOKEN | DMCAPABILITY | DMCAPABILITYTOKEN | - DMCAPABILITYDEFAULTTOKEN | DMCAPABILITYGROUP | - DMCAPABILITYGROUPTOKEN | DRIVE | DRIVEGROUP | - DRIVEGROUPAPPLICATION | DRIVECARTRIDGEACCESS | LM | - LIBRARY | MESSAGE | MOUNTLOGICAL | MOUNTPHYSICAL | - PARTITION | REQUEST | SESSION | SIDE | SLOT_OBJ | - SLOTCONFIG | SLOTGROUP | SLOTTYPE | STALEHANDLE | - SYSTEM | TASK | TASKCARTRIDGE | TASKDRIVE | - TASKLIBRARY | VOLUME | NOTIFY | LIBRARYLIST | - DRIVELIST | CARTRIDGELIST | DRIVECARTRIDGEERROR | - LIBRARYACCESS - ; - -true_or_false_spec - : true_or_false - { - MMS_PAR_ALLOC_NODE($$.nodep, $1.str, MMS_PN_KEYWORD); - } - ; - -true_or_false - : TRUE | FALSE - | STRING - { - if (strcmp($1.str, "true") && - strcmp($1.str, "false")) { - yyerror("unexpected STRING, expecting " - "true or false"); - YYERROR; - } - $$.str = $1.str; - } - ; - -%% - -/* - * If 'change' verify that only one object is referenced in the match - * clause and it matches the object specified in the object clause. - */ -char * -mms_mmp_validate_object(mms_par_node_t *recv) -{ - mms_par_node_t *to; - mms_par_node_t *match; - mms_par_node_t *obj_cl; - char *cur_obj; - mms_par_node_t *obj; - mms_par_node_t *work = NULL; - - mms_pn_fini(recv); - obj_cl = mms_pn_lookup(recv, "object", MMS_PN_CLAUSE, NULL); - if (obj_cl == NULL) { - return ("no object clause"); - } - obj_cl = mms_pn_lookup(obj_cl, "", MMS_PN_OBJ, NULL); - cur_obj = mms_pn_token(obj_cl); - to = mms_pn_lookup(recv, "to", MMS_PN_CLAUSE, NULL); - if (to == NULL) { - return (NULL); - } - if (match = mms_pn_lookup(to, "match", MMS_PN_CLAUSE, NULL)) { - work = NULL; - while (obj = mms_pn_lookup(match, "", MMS_PN_OBJ, &work)) { - if (strcmp(cur_obj, mms_pn_token(obj))) { - return ("object in to clause does not " - "match object in object clause"); - } - } - } - return (NULL); -} diff --git a/usr/src/lib/mms/mms/common/msg_sub.c b/usr/src/lib/mms/mms/common/msg_sub.c deleted file mode 100644 index d8464ec259..0000000000 --- a/usr/src/lib/mms/mms/common/msg_sub.c +++ /dev/null @@ -1,114 +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 <stdlib.h> -#include <strings.h> -#include <stdio.h> -#include <msg_sub.h> - -char * -mms_msg_sub(char *template, char *arg, char *text) -{ - char *buf; - char *arg_ptn; - int ptn_len; - - /* - * Set up arg pattern - $arg$ - */ - ptn_len = strlen(arg) + 2; - arg_ptn = malloc(ptn_len + 1); - if (arg_ptn == NULL) { - return (NULL); - } - (void) snprintf(arg_ptn, ptn_len + 1, "$%s$", arg); - buf = mms_text_sub(template, arg_ptn, text); - free(arg_ptn); - return (buf); -} - -char * -mms_text_sub(char *template, char *arg, char *text) -{ - int out_incr; - int out_len; - int out_off; - char *out; - int in_incr; - int in_len; - int in_off; - char *in; - int text_len = strlen(text); - int arg_len = strlen(arg); - - in = template; - in_len = strlen(in); - in_off = 0; - - out_len = strlen(in) * 2; /* get more space */ - out_off = 0; - out = malloc(out_len + 1); - if (out == NULL) { /* can't get out buffer */ - return (NULL); - } - for (in_off = 0, in_incr = 1, out_off = 0, out_incr = 1; - in_off < in_len; - in_off += in_incr, out_off += out_incr) { - in_incr = 1; - out_incr = 1; - if (strncmp(in + in_off, arg, arg_len)) { - /* not arg pattern */ - out[out_off] = in[in_off]; - } else { - /* matched pattern */ - while ((out_len - out_off) < - (in_len - in_off - arg_len + text_len)) { - /* - * If output buf cannot hold the remaining - * input and the text length, then get - * more space - */ - char *new; - int new_len; - - new_len = out_len * 2; - new = realloc(out, new_len); - if (new == NULL) { - free(out); - return (NULL); - } - out = new; - out_len = new_len; - } - (void) strlcpy(out + out_off, text, - (out_len + 1 - out_off)); - in_incr = arg_len; - out_incr = text_len; - } - } - out[out_off] = '\0'; - return (out); -} diff --git a/usr/src/lib/mms/mms/common/msg_sub.h b/usr/src/lib/mms/mms/common/msg_sub.h deleted file mode 100644 index 1aa99dbf66..0000000000 --- a/usr/src/lib/mms/mms/common/msg_sub.h +++ /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. - */ - -#ifndef __MSG_SUB_H -#define __MSG_SUB_H - - -#ifdef __cplusplus -extern "C" { -#endif - -char *mms_msg_sub(char *template, char *arg, char *text); -char *mms_text_sub(char *template, char *arg, char *text); - -#ifdef __cplusplus -} -#endif - -#endif /* __MSG_SUB_H */ diff --git a/usr/src/lib/mms/mms/common/net_cfg.c b/usr/src/lib/mms/mms/common/net_cfg.c deleted file mode 100644 index e09e35a47c..0000000000 --- a/usr/src/lib/mms/mms/common/net_cfg.c +++ /dev/null @@ -1,291 +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 <string.h> -#include <stdlib.h> -#include <errno.h> -#include <unistd.h> -#include <fcntl.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <syslog.h> -#include "mms_list.h" -#include "mms_parser.h" -#include "mms_network.h" -#include "mms_cfg.h" -#include <mms_trace.h> - -#define MMS_OK 0 -#define MMS_ERROR -1 - -static char *_SrcFile = __FILE__; - -/* - * mms_build_net_cfg() - * - * Parameters: - * net Ptr to mms_network_cfg structure that is to be populated from - * the network configuration file - * cfg Ptr to arse tree of network configuration file - * - * Globals: - * None - * - * Obtain a module's network configuration information from the parse tree. - * The information is then stored in the mms_network_cfg structure to be used - * to connect to MM - * - * Return Values: - * MMS_OK: Able to obtain all network information correctly. - * MMS_ERROR: Unable to obtain all network information. - * - */ -static int -mms_build_net_cfg(mms_network_cfg_t *net, mms_par_node_t *cfg) -{ - mms_par_node_t *root; - mms_par_node_t *elem; - mms_par_node_t *attr; - mms_par_node_t *value; - char *kw; - - /* configuration */ - MMS_PN_LOOKUP(root, cfg, kw = "mms_cfg", MMS_PN_CONFIG, NULL); - - /* network configuration */ - MMS_PN_LOOKUP(elem, root, kw = "mms_network_cfg", MMS_PN_OPTION, NULL); - - MMS_PN_LOOKUP(attr, elem, kw = "host", MMS_PN_KEYWORD, NULL); - MMS_PN_LOOKUP(value, attr, NULL, MMS_PN_STRING, NULL); - net->cli_host = strdup(mms_pn_token(value)); - - MMS_PN_LOOKUP(attr, elem, kw = "port", MMS_PN_KEYWORD, NULL); - MMS_PN_LOOKUP(value, attr, NULL, MMS_PN_STRING, NULL); - net->cli_port = strdup(mms_pn_token(value)); - - MMS_PN_LOOKUP(attr, elem, kw = "name", MMS_PN_KEYWORD, NULL); - MMS_PN_LOOKUP(value, attr, NULL, MMS_PN_STRING, NULL); - net->cli_name = strdup(mms_pn_token(value)); - - MMS_PN_LOOKUP(attr, elem, kw = "language", MMS_PN_KEYWORD, NULL); - MMS_PN_LOOKUP(value, attr, NULL, MMS_PN_STRING, NULL); - net->cli_lang = strdup(mms_pn_token(value)); - - if (attr = mms_pn_lookup(elem, kw = "version", - MMS_PN_KEYWORD, NULL)) { - MMS_PN_LOOKUP(value, attr, NULL, MMS_PN_STRING, NULL); - net->cli_vers = strdup(mms_pn_token(value)); - } - - MMS_PN_LOOKUP(attr, elem, kw = "instance", MMS_PN_KEYWORD, NULL); - MMS_PN_LOOKUP(value, attr, NULL, MMS_PN_STRING, NULL); - net->cli_inst = strdup(mms_pn_token(value)); - - MMS_PN_LOOKUP(attr, elem, kw = "password", MMS_PN_KEYWORD, NULL); - MMS_PN_LOOKUP(value, attr, NULL, MMS_PN_STRING, NULL); - net->cli_pass = strdup(mms_pn_token(value)); - - if (attr = mms_pn_lookup(elem, kw = "mm_password", - MMS_PN_KEYWORD, NULL)) { - MMS_PN_LOOKUP(value, attr, NULL, MMS_PN_STRING, NULL); - net->mm_pass = strdup(mms_pn_token(value)); - } - - if (attr = mms_pn_lookup(elem, kw = "ssl_enabled", - MMS_PN_KEYWORD, NULL)) { - MMS_PN_LOOKUP(value, attr, NULL, MMS_PN_STRING, NULL); - if (strcasecmp(mms_pn_token(value), "true") == 0) { - net->ssl_enabled = 1; - } - } - - if (attr = mms_pn_lookup(elem, kw = "ssl_cert_file", - MMS_PN_KEYWORD, NULL)) { - MMS_PN_LOOKUP(value, attr, NULL, MMS_PN_STRING, NULL); - net->ssl_cert_file = strdup(mms_pn_token(value)); - } - - if (attr = mms_pn_lookup(elem, kw = "ssl_pass", - MMS_PN_KEYWORD, NULL)) { - MMS_PN_LOOKUP(value, attr, NULL, MMS_PN_STRING, NULL); - net->ssl_pass = strdup(mms_pn_token(value)); - } - - if (attr = mms_pn_lookup(elem, kw = "ssl_pass_file", - MMS_PN_KEYWORD, NULL)) { - MMS_PN_LOOKUP(value, attr, NULL, MMS_PN_STRING, NULL); - net->ssl_pass_file = strdup(mms_pn_token(value)); - } - - if (attr = mms_pn_lookup(elem, kw = "ssl_crl_file", - MMS_PN_KEYWORD, NULL)) { - MMS_PN_LOOKUP(value, attr, NULL, MMS_PN_STRING, NULL); - net->ssl_crl_file = strdup(mms_pn_token(value)); - } - - if (attr = mms_pn_lookup(elem, kw = "ssl_peer_file", - MMS_PN_KEYWORD, NULL)) { - MMS_PN_LOOKUP(value, attr, NULL, MMS_PN_STRING, NULL); - net->ssl_peer_file = strdup(mms_pn_token(value)); - } - - if (attr = mms_pn_lookup(elem, kw = "ssl_cipher", - MMS_PN_KEYWORD, NULL)) { - MMS_PN_LOOKUP(value, attr, NULL, MMS_PN_STRING, NULL); - net->ssl_cipher = strdup(mms_pn_token(value)); - } - - return (MMS_OK); - -not_found: - mms_net_cfg_free(net); - syslog(LOG_ERR, "%s:%d mms_build_net_cfg: " - "Missing keyword - %s in config " - "file\n", MMS_HERE, kw); - return (MMS_ERROR); -} - -/* - * mms_net_cfg_read() - * - * Parameters: - * net Ptr to module's mms_network_cfg, which is a generic strcture - * used by mms_mmconnect to connect to the MM. This routine - * passes this to mms_build_net_cfg() to actually populate the - * structure - * cfgfn Path and name of the network configuration file that is to - * be parsed - * - * Globals: - * None - * - * Read network configuration for a module and then parses the contents of - * the file and then populates the mms_network_cfg structure. This structure - * is then passed to mms_mmconnect() to do the actual connect to MM on behalf - * of the module. - * - * Return Values: - * MMS_OK: If the configuration file parses cleanly. - * MMS_ERROR: If the configuration file contained errors. - * - */ -int -mms_net_cfg_read(mms_network_cfg_t *net, char *cfgfn) -{ - mms_par_node_t *cfg; - char *buf; - mms_list_t err_list; - mms_par_err_t *err; - int rc; - int fd; - struct stat statbuf; - - - (void) memset(net, 0, sizeof (mms_network_cfg_t)); - if ((fd = open(cfgfn, O_RDONLY)) < 0) { - syslog(LOG_ERR, "%s:%d mms_net_cfg_read: " - "Unable to open config file %s\n", - MMS_HERE, cfgfn); - return (MMS_ERROR); - } - - /* Allocate a buffer to read in the entire config file */ - if (fstat(fd, &statbuf)) { - syslog(LOG_ERR, "%s:%d mms_net_cfg_read: " - "Unable to stat config file %s\n", - MMS_HERE, cfgfn); - return (MMS_ERROR); - } - if ((buf = (char *)malloc(statbuf.st_size + 1)) == NULL) { - syslog(LOG_ERR, "%s:%d mms_net_cfg_read: " - "Unable to alloc buf for config file %s\n", - MMS_HERE, cfgfn); - return (MMS_ERROR); - } - - /* Read in config file */ - if ((rc = read(fd, buf, statbuf.st_size)) < 0) { - syslog(LOG_ERR, "%s:%d mms_net_cfg_read: " - "Unable to read config file %s\n", - MMS_HERE, cfgfn); - return (MMS_ERROR); - } - buf[rc] = '\0'; - - /* Parse the config file */ - if (rc = mms_config_parse(&cfg, &err_list, buf)) { - mms_list_foreach(&err_list, err) { - syslog(LOG_ERR, "mms_net_cfg_read: Parse error " - "line %d, col %d, near token \"%s\", " - "err code %d, %s", - err->pe_line, - err->pe_col, - err->pe_token, - err->pe_code, - err->pe_msg); - } - - (void) close(fd); - free(buf); - mms_pe_destroy(&err_list); - mms_pn_destroy(cfg); - return (MMS_ERROR); - } - free(buf); - mms_pe_destroy(&err_list); - (void) close(fd); - - if ((rc = mms_build_net_cfg(net, cfg)) == MMS_ERROR) { - syslog(LOG_ERR, "%s:%d mms_net_cfg_read: Error while building " - "network config structure from config file %s\n", - MMS_HERE, cfgfn); - } - - mms_pn_destroy(cfg); - return (rc); -} - -void -mms_net_cfg_free(mms_network_cfg_t *net) -{ - if (net != NULL) { - free(net->cli_host); - free(net->cli_port); - free(net->cli_name); - free(net->cli_inst); - free(net->cli_pass); - free(net->cli_lang); - free(net->cli_vers); - free(net->mm_pass); - free(net->ssl_cert_file); - free(net->ssl_pass); - free(net->ssl_pass_file); - free(net->ssl_crl_file); - free(net->ssl_peer_file); - free(net->ssl_cipher); - (void) memset(net, 0, sizeof (mms_network_cfg_t)); - } -} diff --git a/usr/src/lib/mms/mms/common/net_cfg_service.c b/usr/src/lib/mms/mms/common/net_cfg_service.c deleted file mode 100644 index df4119fee7..0000000000 --- a/usr/src/lib/mms/mms/common/net_cfg_service.c +++ /dev/null @@ -1,259 +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 <string.h> -#include <stdlib.h> -#include <errno.h> -#include <unistd.h> -#include <fcntl.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <syslog.h> -#include "mms_list.h" -#include "mms_parser.h" -#include "mms_network.h" -#include "mms_cfg.h" -#include <mms_trace.h> -#include "net_cfg_service.h" - -static char *_SrcFile = __FILE__; - -int -mms_net_cfg_service(mms_network_cfg_t *net, char *inst, char *lang, char *ver) -{ - char *value; - - /* read common service config */ - - (void) memset(net, 0, sizeof (mms_network_cfg_t)); - - if (inst == NULL || lang == NULL || ver == NULL) { - mms_trace(MMS_ERR, "net cfg service args invalid"); - return (1); - } - - net->cli_host = mms_cfg_alloc_getvar(MMS_CFG_MGR_HOST, NULL); - net->cli_port = mms_cfg_alloc_getvar(MMS_CFG_MGR_PORT, NULL); - net->cli_name = strdup("MMS"); - net->cli_inst = strdup(inst); - net->cli_lang = strdup(lang); - net->cli_vers = strdup(ver); - net->cli_pass = mms_net_cfg_read_pass_file(MMS_NET_CFG_HELLO_FILE); - net->mm_pass = mms_net_cfg_read_pass_file(MMS_NET_CFG_WELCOME_FILE); - if (value = mms_cfg_alloc_getvar(MMS_CFG_SSL_ENABLED, NULL)) { - if (strcasecmp(value, "true") == 0) { - net->ssl_enabled = 1; - } - free(value); - } - net->ssl_cert_file = mms_cfg_alloc_getvar(MMS_CFG_SSL_CERT_FILE, NULL); - net->ssl_pass_file = mms_cfg_alloc_getvar(MMS_CFG_SSL_PASS_FILE, NULL); - net->ssl_crl_file = mms_cfg_alloc_getvar(MMS_CFG_SSL_CRL_FILE, NULL); - net->ssl_peer_file = mms_cfg_alloc_getvar(MMS_CFG_SSL_PEER_FILE, NULL); - net->ssl_cipher = mms_cfg_alloc_getvar(MMS_CFG_SSL_CIPHER, NULL); - - if (net->cli_host == NULL || - net->cli_port == NULL || - net->cli_name == NULL || - net->cli_inst == NULL || - net->cli_lang == NULL || - net->cli_vers == NULL) { - mms_trace(MMS_ERR, "net cfg service incomplete"); - mms_net_cfg_free(net); - return (1); - } - - if (net->cli_pass == NULL) { - mms_trace(MMS_WARN, "net cfg service hello password"); - return (2); - } - - return (0); -} - -/* ARGSUSED1 */ -char * -mms_obfpassword(char *password, int ed) -{ - char *buf = NULL; - - if (password) { - buf = strdup(password); - /* - * Put obfuscation algorithm here. - * - * If ed is zero then encrypt else decrypt. - */ - } - return (buf); -} - -int -mms_net_cfg_write_pass_file(char *file, char *password) -{ - struct stat sbuf; - int fd = -1; - int n; - int rc = 1; - char *obfpass = NULL; - const char *newline = "\n"; - char *p; - struct iovec iov[2]; - char *tmpass = NULL; - int len; - - if (file == NULL) { - mms_trace(MMS_ERR, "net cfg write null file"); - return (1); - } - if (password == NULL) { - mms_trace(MMS_ERR, - "net cfg write file %s null password", file); - return (1); - } - if (stat(file, &sbuf) == 0) { - if ((sbuf.st_mode & ~(S_IFREG|S_IRUSR|S_IWUSR)) != 0) { - mms_trace(MMS_DEVP, "net cfg write file %s mode %x", - file, sbuf.st_mode); - return (1); - } - } - - if ((tmpass = strdup(password)) == NULL) { - mms_trace(MMS_ERR, - "net cfg write file %s alloc %s", - file, - strerror(errno)); - return (1); - } - if (p = strchr(tmpass, '\n')) { - *p = 0; - } - if ((fd = open(file, O_CREAT|O_RDWR|O_TRUNC, S_IRUSR|S_IWUSR)) < 0) { - mms_trace(MMS_DEVP, "net cfg write file %s open %s", - file, strerror(errno)); - free(tmpass); - return (1); - } - - if ((obfpass = mms_obfpassword(tmpass, 0)) == NULL) { - mms_trace(MMS_DEVP, - "net cfg write file %s password obfuscation", - file); - } else { - iov[0].iov_base = obfpass; - iov[0].iov_len = strlen(obfpass); - iov[1].iov_base = (char *)newline; - iov[1].iov_len = strlen(newline); - len = strlen(obfpass) + strlen(newline); - if ((n = writev(fd, iov, 2)) == len) { - rc = 0; - } else { - mms_trace(MMS_DEVP, - "net cfg write file %s write %s n %d len %d", - file, strerror(errno), n, len); - } - free(obfpass); - } - free(tmpass); - if (fd >= 0) - (void) close(fd); - return (rc); -} - -char * -mms_net_cfg_read_pass_file(char *file) -{ - struct stat sbuf; - int fd = -1; - char *password = NULL; - char *obfpass = NULL; - char *p; - int n; - int len; - - if (file == NULL) { - mms_trace(MMS_ERR, "net cfg read null file"); - goto out; - } - if (stat(file, &sbuf) != 0) { - mms_trace(MMS_DEVP, "net cfg read file %s stat %s", - file, strerror(errno)); - goto out; - } - len = sbuf.st_size; - - if ((sbuf.st_mode & ~(S_IFREG|S_IRUSR|S_IWUSR)) != 0) { - mms_trace(MMS_DEVP, - "net cfg read file %s mode %x", - file, - sbuf.st_mode); - goto out; - } - - if ((fd = open(file, O_RDONLY)) < 0) { - mms_trace(MMS_DEVP, - "net cfg read file %s open %s", - file, - strerror(errno)); - goto out; - } - - if ((obfpass = (char *)malloc(len + 1)) == NULL) { - mms_trace(MMS_DEVP, - "net cfg read file %s alloc %s", - file, - strerror(errno)); - goto out; - } - - if ((n = read(fd, obfpass, len)) != len) { - mms_trace(MMS_DEVP, - "net cfg read file %s read %s n %d len %d", - file, - strerror(errno), - n, - len); - goto out; - } - obfpass[len] = (char)0; - - if (p = strchr(obfpass, '\n')) { - *p = (char)0; - } - if ((password = mms_obfpassword(obfpass, 1)) == NULL) { - mms_trace(MMS_DEVP, - "net cfg read file %s password un-obfuscate", - file); - } - -out: - if (obfpass) - free(obfpass); - if (fd >= 0) - (void) close(fd); - return (password); -} diff --git a/usr/src/lib/mms/mms/common/net_cfg_service.h b/usr/src/lib/mms/mms/common/net_cfg_service.h deleted file mode 100644 index f720802a09..0000000000 --- a/usr/src/lib/mms/mms/common/net_cfg_service.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 _NET_CFG_SERVICE_H -#define _NET_CFG_SERVICE_H - - -#ifdef __cplusplus -extern "C" { -#endif - -/* password files */ -#define MMS_NET_CFG_HELLO_FILE "/etc/mms/passwd/hello" -#define MMS_NET_CFG_WELCOME_FILE "/etc/mms/passwd/welcome" -#define MMS_NET_CFG_DB_FILE "/etc/mms/passwd/db" - -char *mms_net_cfg_value(char *varname); -int mms_net_cfg_service(mms_network_cfg_t *net, - char *inst, char *lang, char *ver); -char *mms_obfpassword(char *password, int ed); -int mms_net_cfg_write_pass_file(char *file, char *password); -char *mms_net_cfg_read_pass_file(char *file); - -#ifdef __cplusplus -} -#endif - -#endif /* _NET_CFG_SERVICE_H */ diff --git a/usr/src/lib/mms/mms/common/strapp.c b/usr/src/lib/mms/mms/common/strapp.c deleted file mode 100644 index f4ab2de928..0000000000 --- a/usr/src/lib/mms/mms/common/strapp.c +++ /dev/null @@ -1,272 +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 <stdlib.h> -#include <string.h> -#include "mms_strapp.h" - -#define MMS_ESCAPE_PAR_NUM 5 -#define MMS_ESCAPE_DB_NUM 2 - -typedef struct mms_escape mms_escape_t; -struct mms_escape { - char ch; - char *sequence; -}; - -static mms_escape_t mms_escape_par[MMS_ESCAPE_PAR_NUM] = { - { '\'', "'" }, - { '"', """ }, - { '>', ">" }, - { '<', "<" }, - { '&', "&" } -}; - -static char * -mms_str_escape_sequence(char *string, mms_escape_t *mms_escape, int escape_num); - -/* - * mms_strpar_escape_sequence(string) - * - * Convert plain text to xml parser mms_escape sequence. - */ -char * -mms_strpar_escape_sequence(char *string) -{ - return (mms_str_escape_sequence(string, mms_escape_par, - MMS_ESCAPE_PAR_NUM)); -} - -char * -mms_strpar_undo_escape_sequence(char *string) -{ - int len; - char *p; - int i; - char *buf; - - if (string == NULL) { - return (NULL); - } - if ((buf = strdup(string)) == NULL) { - return (NULL); - } - for (i = 0; i < MMS_ESCAPE_PAR_NUM; i++) { - p = buf; - len = strlen(mms_escape_par[i].sequence) - 1; - while (p = strstr(p, mms_escape_par[i].sequence)) { - *p = mms_escape_par[i].ch; - p++; - (void) memmove(p, p + len, strlen(p + len) + 1); - } - } - return (buf); -} - -/* - * mms_str_escape_sequence(string) - * - * Convert plain text to mms_escape sequence. - */ -static char * -mms_str_escape_sequence(char *string, mms_escape_t *mms_escape, int escape_num) -{ - int i; - int j; - int k; - int m; - int len; - char *nstr; - int sub; - - if (!string) { - return (NULL); - } - for (i = 0, len = 0; string[i] != '\0'; i++) { - for (j = 0; j < escape_num; j++) { - if (string[i] == mms_escape[j].ch) { - len += strlen(mms_escape[j].sequence); - } - } - } - - if ((nstr = (char *)malloc(strlen(string) + len + 1)) == NULL) { - return (NULL); - } - for (i = 0, m = 0; string[i] != '\0'; i++) { - for (j = 0, sub = 0; !sub && j < escape_num; j++) { - if (string[i] == mms_escape[j].ch) { - len = strlen(mms_escape[j].sequence); - for (k = 0; k < len; k++) { - nstr[m++] = mms_escape[j].sequence[k]; - } - sub = 1; - } - } - if (!sub) { - nstr[m++] = string[i]; - } - } - nstr[m] = '\0'; - return (nstr); -} - -/* - * mms_strnew(fmt, ...) - * - * Create a new string with variable number of arguments. - */ -char * -mms_strnew(const char *fmt, ...) -{ - va_list args; - char *ptr; - - if (fmt == NULL) { - return (NULL); - } - va_start(args, fmt); - - ptr = mms_vstrapp(NULL, fmt, args); - - va_end(args); - - return (ptr); -} - -/* - * mms_strapp(str, fmt, ...) - * - * Append string with variable number of arguments. - */ -char * -mms_strapp(char *str, const char *fmt, ...) -{ - va_list args; - char *ptr; - - if (fmt == NULL) { - return (NULL); - } - va_start(args, fmt); - - ptr = mms_vstrapp(str, fmt, args); - - va_end(args); - - return (ptr); -} - -/* - * mms_vstrapp(str, fmt, args) - * - * Append string with variable argument list. - * - * Typical usage example, - * a = strdup("start of "); - * a = strapp(a, "larger string"); - * - * On error, str is freed. - */ -char * -mms_vstrapp(char *str, const char *fmt, va_list args) -{ - int count; - int offset; - char *ptr; - - if (fmt == NULL) { - if (str != NULL) - free(str); - return (NULL); - } - if ((count = vsnprintf(NULL, 0, fmt, args)) < 0) { - if (str != NULL) - free(str); - return (NULL); - } - if (str == NULL) { - if ((ptr = (char *)malloc(count + 1)) == NULL) { - return (NULL); - } - ptr[0] = '\0'; - offset = 0; - } else { - offset = strlen(str); - if ((ptr = (char *)realloc(str, offset + - count + 1)) == NULL) { - free(str); - return (NULL); - } - } - - if (vsprintf(ptr + offset, fmt, args) < 0) { - free(ptr); - return (NULL); - } - return (ptr); -} - -/* - * - * mms_strnapp(char *str, int n, char *str2) - * - * Parameters: - * str pointer to the string being appended to - * If str is not NULL, then it must point to a string which - * may be freed by free() or realloc(). - * n number of characters to append - * str2 a string of any length to append to str. - * - * Return a new string with at most n characters from str2 appended to str. - * - * Return Values: - * Address of new string. - * - * Note: new string must be freed by caller. - * - */ - -char * -mms_strnapp(char *str, int n, char *str2) -{ - char fmt[64]; - int len; - char *rc; - - if (n == 0) { - return (str); - } - - /* Construct format to get n chars */ - len = snprintf(fmt, sizeof (fmt), "%%.%ds", n); - if (len < 0 || len >= sizeof (fmt)) { - /* not enough space */ - return (NULL); - } - rc = mms_strapp(str, (const char *)fmt, str2); - return (rc); -} diff --git a/usr/src/lib/mms/mms/common/trace.c b/usr/src/lib/mms/mms/common/trace.c deleted file mode 100644 index f4bb7120d7..0000000000 --- a/usr/src/lib/mms/mms/common/trace.c +++ /dev/null @@ -1,754 +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 <stdlib.h> -#include <string.h> -#include <time.h> -#include <errno.h> -#include <syslog.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <signal.h> -#include <fcntl.h> -#include <unistd.h> -#include <sys/uio.h> -#include <pthread.h> -#include <limits.h> -#include <ctype.h> -#include "mms_strapp.h" -#include "mms_trace.h" -#include <sys/wait.h> - -#define MMS_LN_MAX 1000 /* max num of chars in a trace line before newline */ -#define MMS_LN_MIN 500 /* min num of chars for pretty line */ - -static char *_SrcFile = __FILE__; -static char mms_trace_filename[256]; -static int mms_trace_fd = -1; -static mms_trace_id_t mms_trace_id; -static mms_trace_sev_t mms_trace_sev = MMS_SEV_ERROR; -static uint64_t mms_trace_size = 0; -static uint64_t mms_trace_rot_size = 10485760; /* 10M */ -static pthread_mutex_t mms_trace_mutex; -static int mms_conf = 1; -static int mms_aborting = 0; - -static char *mms_trace_sevstr[] = { - "EMERG", "ALERT", "CRIT", "OPER", "ERROR", "WARN", "NOTICE", - "INFO", "DEBUG", "DEVP", NULL -}; - -static char *mms_trace_idstr[] = { - "MM", "LM", "DM ", "DMD", "WCR", "API", "LM_ND", "CLI", NULL -}; - -static char *mms_trace_level[] = { - "emergency", "alert", "critical", "operational", "error", - "warning", "notice", "information", "debug", "developer", NULL -}; - -static int mms_trace_sig[] = { - SIGILL, - SIGFPE, - SIGBUS, - SIGSEGV, - SIGSYS, - 0, -}; - -static void -mms_trace_setup_logadm() -{ - pid_t shpid; - char size[20]; - - (void) snprintf(size, sizeof (size), "%lldb", mms_trace_rot_size); - if ((shpid = fork()) < 0) { - mms_trace(MMS_DEBUG, - "mms_trace_setup_logadm: fork failed"); - return; - } else if (shpid == 0) { /* child */ - int fd; - fd = open(MMS_LOGADM_CONF, O_RDWR); - if (fd >= 0) { - (void) lockf(fd, F_LOCK, 1); - } - (void) execl(MMS_LOGADM, MMS_LOGADM, - "-f", MMS_LOGADM_CONF, - "-s", size, - "-w", mms_trace_filename, - mms_trace_filename, - (char *)0); - exit(1); - } - if (waitpid(shpid, NULL, 0) < 0) /* parent */ - mms_trace(MMS_DEBUG, - "mms_trace_setup_logadm: wait failed"); -} - -static void -mms_trace_signal(int sig, void (*handler)()) -{ - /* - * Setup to catch signals - */ - struct sigaction act, oact; - - (void) memset(&act, 0, sizeof (act)); - act.sa_sigaction = handler; - (void) sigemptyset(&act.sa_mask); - act.sa_flags = 0; - if (sig != SIGALRM) { - /* - * Allow alarm signal to interrupt - */ - act.sa_flags |= SA_RESTART; - } - (void) sigaction(sig, &act, &oact); -} - -/* - * Catch the signals caused by programming error here and flush - * the mms_trace buffer before aborting. - */ -static void -mms_trace_sighandler(int sig) -{ - syslog(LOG_ERR, "mms mms_trace_sighandler >>>>> Caught Signal %d, " - "Aborting <<<<<", sig); - mms_trace_flush(); - mms_aborting = 1; - mms_trace_close(); - abort(); -} - -/* - * Open mms_trace file with id prefix. - */ -/* - * function name: - * mms_trace_open - * - * Parameters: - * filename trace file name - * id id of the component - * severity severity above which will be traced - * rot_size rotation size - * sig 1 - if trace will cat abort signals - * 0 - if trace will not catch signals - * conf 1 - if dm_trace_close will remove trace entry from - * logadm.conf - * 0 - if dm_trace_close will not remove trace entry - * from logadm.conf - * - * Description: - * open a trace file - * - * Note: - * - * - */ - -int -mms_trace_open(char *filename, mms_trace_id_t id, int severity, - int64_t rot_size, int sig, int conf) -{ - int oflags = O_CREAT | O_RDWR | O_APPEND; - int i; - struct stat buf; - - /* Make sure that mms_trace_open has not already been */ - /* opened */ - - mms_conf = conf; - - if (mms_trace_get_fd() != -1) { - return (1); - } - - if (filename == NULL) { - return (1); - } - - if (severity != -1 && - (severity < MMS_SEV_EMERG || severity > MMS_SEV_DEVP)) { - return (1); - } - - if (sig != 0) { - for (i = 0; mms_trace_sig[i] != 0; i++) { - mms_trace_signal(mms_trace_sig[i], - mms_trace_sighandler); - } - } - - if (pthread_mutex_init(&mms_trace_mutex, NULL) != 0) { - return (1); - } - - if (stat(filename, &buf) != 0) { - if (errno == ENOENT || errno == ENOTDIR) { - char name[128]; - char *p; - - (void) strncpy(name, filename, sizeof (name)); - if ((p = strrchr(name, '/')) != NULL) { - *p = '\0'; - if (stat(name, &buf) != 0) - (void) mkdir(name, 0777); - } - } - } - - if (id == MMS_ID_ND) { - mms_trace_fd = STDERR_FILENO; - } else if (id >= MMS_ID_MM && id <= MMS_ID_CLI) { - if ((mms_trace_fd = open(filename, oflags, 0644)) < 0) { - return (-1); - } - } else { - return (1); - } - - mms_trace_id = id; - if (rot_size != -1) - mms_trace_rot_size = rot_size; - if (severity != -1) - (void) mms_trace_filter(severity); - - /* Save mms_trace's filename for when file rotation takes place */ - (void) strcpy(mms_trace_filename, filename); - /* Obtain initial size of mms_trace file for rotation */ - if (fstat(mms_trace_fd, &buf) == 0) - mms_trace_size = buf.st_size; - - /* - * Setup mms_logadm.conf for this file - */ - if (conf) { - mms_trace_setup_logadm(); - } - - return (0); -} - -/* - * Return mms_trace file descriptor. - */ -int -mms_trace_get_fd(void) -{ - return (mms_trace_fd); -} - -/* - * Function name: - * mms_trace_close - * - * - * Parameters: - * none - * - * - * Description: - * close a trace file. - * if mms_conf is 1 (set in mms_trace_open) then entry in logadm.conf - * for this trace file will be removed. - * If mms_trace_close is called during an abort from - * mms_trace_sighandler don't call mms_strapp, - * the malloc maydead lock if another thread aborted - * inside of malloc - * - * Note: - * - * - */ -void -mms_trace_close(void) -{ - pid_t shpid; - - if (!mms_aborting && mms_conf) { - if ((shpid = fork()) < 0) { - mms_trace(MMS_DEBUG, - "mms_trace_close: fork failed"); - (void) close(mms_trace_fd); - mms_trace_fd = -1; - return; - } else if (shpid == 0) { /* child */ - int fd; - fd = open(MMS_LOGADM_CONF, O_RDWR); - if (fd >= 0) { - (void) lockf(fd, F_LOCK, 1); - } - (void) execl(MMS_LOGADM, MMS_LOGADM, - "-f", MMS_LOGADM_CONF, - "-r", mms_trace_filename, - mms_trace_filename, - (char *)0); - exit(1); - } - if (waitpid(shpid, NULL, 0) < 0) /* parent */ - mms_trace(MMS_DEBUG, - "mms_trace_close: wait failed"); - } - (void) close(mms_trace_fd); - mms_trace_fd = -1; -} - -/* - * Set mms_trace id prefix. - */ -void -mms_trace_set_id(mms_trace_id_t id) -{ - if (id < MMS_ID_MM || id > MMS_ID_CLI) { - return; - } - mms_trace_id = id; -} - -/* - * Get mms_trace id prefix. - */ -mms_trace_id_t -mms_trace_get_id(void) -{ - return (mms_trace_id); -} - -/* - * Get mms_trace serverity setting. - */ -mms_trace_sev_t -mms_trace_get_severity(void) -{ - return (mms_trace_sev); -} - -/* - * Write variable number of args to mms_trace file. - */ -void -mms_trace(mms_trace_sev_t severity, char *file, int line, const char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - mms_trace_va(severity, file, line, fmt, args); - va_end(args); -} - -/* - * Write arg list to mms_trace file. - */ -void -mms_trace_va(mms_trace_sev_t severity, char *file, int line, - const char *fmt, va_list args) -{ - char date[100]; - time_t tm; - char *buf; - char *str; - struct iovec iov[IOV_MAX]; - int len; - int num_iov; - int off; - int i; - const char *newline = "\n"; - int oflags = O_CREAT | O_RDWR | O_APPEND; - struct tm ltime; - pid_t shpid; - char size[20]; - - if (severity < MMS_SEV_EMERG || severity > MMS_SEV_DEVP) { - return; /* invalid severity */ - } - if (severity > mms_trace_sev) { - return; /* not tracing this severity level */ - } - - if (pthread_mutex_lock(&mms_trace_mutex) != 0) - return; - - /* - * Put mms_trace info into a write buffer - */ - (void) time(&tm); - (void) localtime_r(&tm, <ime); - (void) strftime(date, 100, "%Y/%m/%d %H:%M:%S", <ime); - if ((buf = mms_strnew("%s %s %s [%d,%d] %s:%d ", date, - mms_trace_idstr[mms_trace_id], mms_trace_sevstr[severity], - getpid(), pthread_self(), file, line)) == NULL) { - (void) pthread_mutex_unlock(&mms_trace_mutex); - return; - } - - if ((str = mms_vstrapp(buf, fmt, args)) == NULL) { - free(buf); - (void) pthread_mutex_unlock(&mms_trace_mutex); - return; - } - buf = str; - len = strlen(buf); - if (buf[len - 1] == '\n') { - buf[len - 1] = '\0'; - len--; - } - num_iov = 2 * (IOV_MAX / 2); - - for (off = 0; off < len; ) { - for (i = 0; i < num_iov && off < len; - i += 2, off += MMS_LINE_SIZE) { - iov[i].iov_base = (caddr_t)buf + off; - if ((len - off) >= MMS_LINE_SIZE) { - iov[i].iov_len = MMS_LINE_SIZE; - } else { - iov[i].iov_len = len - off; - } - iov[i+1].iov_base = (caddr_t)newline; - iov[i+1].iov_len = strlen(newline); - } - (void) writev(mms_trace_fd, iov, i); - } - - mms_trace_size += len; - - free(buf); - - if (mms_trace_size > mms_trace_rot_size) { - mms_trace_flush(); - (void) close(mms_trace_fd); - if ((shpid = fork()) < 0) { - mms_trace(MMS_DEBUG, - "mms_trace_va: fork failed"); - return; - } else if (shpid == 0) { /* child */ - (void) snprintf(size, sizeof (size), "%lldb", - mms_trace_rot_size); - (void) execl(MMS_LOGADM, MMS_LOGADM, - "-f", MMS_LOGADM_CONF, - "-s", size, - mms_trace_filename, - (char *)0); - exit(1); - } - if (waitpid(shpid, NULL, 0) < 0) /* parent */ - mms_trace(MMS_DEBUG, - "mms_trace_va: wait failed"); - - mms_trace_size = 0; - mms_trace_fd = open(mms_trace_filename, oflags, 0644); - } - (void) pthread_mutex_unlock(&mms_trace_mutex); -} - -/* - * Set tracing severity level. - */ -int -mms_trace_filter(mms_trace_sev_t severity) -{ - if (severity < MMS_SEV_EMERG || severity > MMS_SEV_DEVP) { - mms_trace(MMS_ERR, "Invalid mms_trace serverity: %d", severity); - return (1); /* invalid severity */ - } - - if (severity < MMS_SEV_ERROR) - /* Cannot mask levels EMERG through OPER */ - mms_trace_sev = MMS_SEV_OPER; - else - mms_trace_sev = severity; - return (0); -} - -/* - * Set tracing severity level. - */ -int -mms_trace_str_filter(char *level) -{ - mms_trace_sev_t severity; - - if (level == NULL) { - return (1); - } else if (strcmp(level, "emergency") == 0) { - severity = MMS_SEV_EMERG; - } else if (strcmp(level, "alert") == 0) { - severity = MMS_SEV_ALERT; - } else if (strcmp(level, "critical") == 0) { - severity = MMS_SEV_CRIT; - } else if (strcmp(level, "operational") == 0) { - severity = MMS_SEV_OPER; - } else if (strcmp(level, "error") == 0) { - severity = MMS_SEV_ERROR; - } else if (strcmp(level, "warning") == 0) { - severity = MMS_SEV_WARN; - } else if (strcmp(level, "notice") == 0) { - severity = MMS_SEV_NOTICE; - } else if (strcmp(level, "information") == 0) { - severity = MMS_SEV_INFO; - } else if (strcmp(level, "debug") == 0) { - severity = MMS_SEV_DEBUG; - } else if (strcmp(level, "developer") == 0) { - severity = MMS_SEV_DEVP; - } else { - return (1); - } - return (mms_trace_filter(severity)); -} - -int -mms_trace_str2sev(char *level, mms_trace_sev_t *severity) -{ - int rc = 0; - - if (level == NULL) { - *severity = MMS_SEV_DEBUG; - rc = 1; - } else if (strcmp(level, "emergency") == 0) { - *severity = MMS_SEV_EMERG; - } else if (strcmp(level, "alert") == 0) { - *severity = MMS_SEV_ALERT; - } else if (strcmp(level, "critical") == 0) { - *severity = MMS_SEV_CRIT; - } else if (strcmp(level, "operational") == 0) { - *severity = MMS_SEV_OPER; - } else if (strcmp(level, "error") == 0) { - *severity = MMS_SEV_ERROR; - } else if (strcmp(level, "warning") == 0) { - *severity = MMS_SEV_WARN; - } else if (strcmp(level, "notice") == 0) { - *severity = MMS_SEV_NOTICE; - } else if (strcmp(level, "information") == 0) { - *severity = MMS_SEV_INFO; - } else if (strcmp(level, "debug") == 0) { - *severity = MMS_SEV_DEBUG; - } else if (strcmp(level, "developer") == 0) { - *severity = MMS_SEV_DEVP; - } else { - *severity = MMS_SEV_DEBUG; - rc = 1; - } - return (rc); -} - -char * -mms_trace_sev2str(mms_trace_sev_t severity) -{ - char *level; - - if (severity < MMS_SEV_EMERG || severity > MMS_SEV_DEVP) { - level = NULL; - } else { - level = mms_trace_level[severity]; - } - return (level); -} - -/* This routine is used to obtain the severity level for the */ -/* MMS internal message scheme. When MM sends a private command */ -/* to set or change the message levels that a LM or DM will send, */ -/* it sends it in a string. This routine converts that string into */ -/* an enumeration associated with the string. By default it sets */ -/* the the level to ERROR */ - -mms_msg_sev_t -mms_msg_get_severity(char *level) -{ - - if (level == NULL) { - mms_trace(MMS_DEBUG, - "mms_msg_get_severity: null string filter"); - return (MMS_MSG_SEV_ERROR); - } else if (strcmp(level, "emergency") == 0) { - return (MMS_MSG_SEV_EMERG); - } else if (strcmp(level, "alert") == 0) { - return (MMS_MSG_SEV_ALERT); - } else if (strcmp(level, "critical") == 0) { - return (MMS_MSG_SEV_CRIT); - } else if (strcmp(level, "error") == 0) { - return (MMS_MSG_SEV_ERROR); - } else if (strcmp(level, "warning") == 0) { - return (MMS_MSG_SEV_WARN); - } else if (strcmp(level, "notice") == 0) { - return (MMS_MSG_SEV_NOTICE); - } else if (strcmp(level, "information") == 0) { - return (MMS_MSG_SEV_INFO); - } else if (strcmp(level, "debug") == 0) { - return (MMS_MSG_SEV_DEBUG); - } else if (strcmp(level, "developer") == 0) { - return (MMS_MSG_SEV_DEVP); - } else { - mms_trace(MMS_DEBUG, - "mms_msg_get_severity, invalid string filter: " - "%s", level); - return (MMS_MSG_SEV_ERROR); - } -} - -/* - * Dump content of memory into a bufer - */ -char * -mms_trace_dump(char *buf, int inlen, char *out, int outlen) -{ - uchar_t *inbuf = (uchar_t *)buf; - int off = 0; - int off_start; - int bytes; - uchar_t *ip; - int i; - int j; - - ip = inbuf; - while ((inlen > 0) && ((outlen - off) > MMS_DUMP_LINE_SIZE)) { - off_start = off; - (void) memset(out + off, ' ', MMS_DUMP_LINE_SIZE); - bytes = inlen > MMS_CHAR_PER_LINE ? - MMS_CHAR_PER_LINE : inlen; - off += sprintf(out + off, "%5.5d ", ip - inbuf); - for (i = 0; i < bytes; ) { - for (j = 0; j < 4; j++, i++) { - off += sprintf(out + off, "%2.2x", ip[i]); - } - off += sprintf(out + off, " "); - } - out[off] = ' '; - off = off_start + MMS_CHAR_OFFSET; - for (i = 0; i < bytes; i++) { - out[off++] = isprint(ip[i]) ? ip[i] : '.'; - } - out[off++] = '\n'; - out[off] = '\0'; - - inlen -= bytes; - ip += bytes; - } - return (out); -} - -/* - * Flush the mms_trace buffer to disk - */ -void -mms_trace_flush(void) -{ - (void) fsync(mms_trace_fd); -} - -#define MMS_KILO (uint64_t)(1024LL) -#define MMS_MEGA (uint64_t)(1024LL * 1024) -#define MMS_GIGA (uint64_t)(1024LL * 1024 * 1024) -#define MMS_TERA (uint64_t)(1024LL * 1024 * 1024 * 1024) -#define MMS_PETA (uint64_t)(1024LL * 1024 * 1024 * 1024 * 1024) -#define MMS_EXA (uint64_t)(1024LL * 1024 * 1024 * 1024 * 1024 * 1024) - -/* - * Parse string to get file size. - */ -int -mms_trace_str_to_fsize( -char *string, -uint64_t *size) -{ - char *p; - int64_t value; - double conv; - double frac; - - *size = 0; - if (*string == '0' && (*(string+1) == 'x' || *(string+1) == 'X' || - isdigit(*(string+1)))) { - /* - * Do hex/octal. - */ - errno = 0; - value = strtoll(string, &p, 0); - if (*p == '\0' && errno == 0 && value >= 0) { - *size = value; - return (0); - } - goto err; - } - errno = 0; - conv = strtod(string, &p); - if (errno != 0 || p == string || conv < 0) { - goto err; - } - value = (int64_t)conv; - frac = conv - (double)value; - if (*p == 'K') { - p++; - value *= MMS_KILO; - frac *= MMS_KILO; - } else if (*p == 'M') { - p++; - value *= MMS_MEGA; - frac *= MMS_MEGA; - } else if (*p == 'G') { - p++; - value *= MMS_GIGA; - frac *= MMS_GIGA; - } else if (frac > .09) { - goto err; - } - if (*p != '\0') { - goto err; - } - *size = value + (int64_t)frac; - return (0); - -err: - if (errno == 0) { - errno = EINVAL; - } - return (-1); -} - -/* - * Set mms_trace file rotation size. - */ -int -mms_trace_set_fsize( -char *size) -{ - uint64_t value; - - if (mms_trace_str_to_fsize(size, &value) == -1) { - mms_trace(MMS_ERR, - "mms_trace_set_fsize: Invalid mms_trace size - %s\n", - size); - return (1); - } else { - mms_trace_rot_size = value; - mms_trace(MMS_DEBUG, - "mms_trace_set_fsize: Set mms_trace rotation size to " - "%s - %lld\n", size, value); - mms_trace_setup_logadm(); - return (0); - } -} diff --git a/usr/src/lib/mms/mms/i386/Makefile b/usr/src/lib/mms/mms/i386/Makefile deleted file mode 100644 index d77b753d64..0000000000 --- a/usr/src/lib/mms/mms/i386/Makefile +++ /dev/null @@ -1,26 +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. -# -# -include ../Makefile.com diff --git a/usr/src/lib/mms/mms/sparc/Makefile b/usr/src/lib/mms/mms/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/mms/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/lib/mms/pg/Makefile b/usr/src/lib/mms/pg/Makefile deleted file mode 100644 index 8fa9099aa1..0000000000 --- a/usr/src/lib/mms/pg/Makefile +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -SUBDIRS = $(MACH) - -all := TARGET = all -clean := TARGET = clean -clobber := TARGET = clobber -install := TARGET = install -lint := TARGET = lint - -.KEEP_STATE: - -all clean clobber install lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff --git a/usr/src/lib/mms/pg/Makefile.com b/usr/src/lib/mms/pg/Makefile.com deleted file mode 100644 index f7d40f9e30..0000000000 --- a/usr/src/lib/mms/pg/Makefile.com +++ /dev/null @@ -1,63 +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. -# -# - -LIBRARY = libpg.a -VERS = .1 - -OBJECTS = pg_uuid.o pg_host_ident.o - -include $(SRC)/lib/Makefile.lib -include ../Makefile.defs - -LIBS = $(DYNLIB) $(LINTLIB) - -SRCDIR = ../common - -SRCS = $(OBJECTS:%.o=$(SRCDIR)/%.c) - -LDLIBS += -lc -luuid -LDLIBS += -L$(SRC)/lib/mms/mms/$(MACH) -lmms - -CCFLAGS += $(CCVERBOSE) -CCFLAGS += $(C_BIGPICFLAGS) - -CPPFLAGS += -DMMS_OPENSSL -CPPFLAGS += -I$(SRCDIR) -I$(SRC)/common/mms/mms -CPPFLAGS += -I$(SRC)/lib/mms/mms/common -CPPFLAGS += -I/usr/postgres/8.3/include/server - -C99MODE = $(C99_ENABLE) - -.KEEP_STATE: - -all: $(LIBS) - -lint: $(LINTLIB) lintcheck - -include $(SRC)/lib/Makefile.targ -include ../Makefile.rootdirs - -install: all $(ROOTLIBDIR) $(ROOTLIBS) $(ROOTLINKS) diff --git a/usr/src/lib/mms/pg/Makefile.defs b/usr/src/lib/mms/pg/Makefile.defs deleted file mode 100644 index 0e892e3690..0000000000 --- a/usr/src/lib/mms/pg/Makefile.defs +++ /dev/null @@ -1,27 +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. -# - -ROOTLIBDIR = $(ROOT)/usr/lib/mms - diff --git a/usr/src/lib/mms/pg/Makefile.rootdirs b/usr/src/lib/mms/pg/Makefile.rootdirs deleted file mode 100644 index 5b19b1335d..0000000000 --- a/usr/src/lib/mms/pg/Makefile.rootdirs +++ /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 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# -# Define the transitive set of rules to create a common module's install dir -# within the proto area. -# - -$(ROOTLIBDIR): - $(INS.dir) - diff --git a/usr/src/lib/mms/pg/common/mapfile-vers b/usr/src/lib/mms/pg/common/mapfile-vers deleted file mode 100644 index 5dd5dfe376..0000000000 --- a/usr/src/lib/mms/pg/common/mapfile-vers +++ /dev/null @@ -1,59 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -SUNWprivate_1.1 { - global: - pg_finfo_pg_get_uuid; - pg_finfo_pg_host_ident; - pg_get_uuid; - pg_host_ident; - - pg_detoast_datum = extern; - MemoryContextAlloc = extern; - CurrentMemoryContext = extern; - Pg_magic_func = extern; - local: - *; -}; - - - - diff --git a/usr/src/lib/mms/pg/common/pg_host_ident.c b/usr/src/lib/mms/pg/common/pg_host_ident.c deleted file mode 100644 index 15ec693c91..0000000000 --- a/usr/src/lib/mms/pg/common/pg_host_ident.c +++ /dev/null @@ -1,97 +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. - */ - - -#include <postgres.h> -#include <fmgr.h> -PG_MODULE_MAGIC; -#include <string.h> -#include "mms_network.h" -#include "host_ident.h" - -/* - * Postgres server library for MMS client ip address. - */ - -PG_FUNCTION_INFO_V1(pg_host_ident); - -Datum -pg_host_ident(PG_FUNCTION_ARGS) -{ - void *pg_host_str; - void *pg_ident; - int32 len; - char host_str[MMS_HOST_IDENT_LEN+1]; - char host[MMS_HOST_IDENT_LEN+1]; - char ip[MMS_IP_IDENT_LEN+1]; - char *ident; - - /* test for null arg */ - if (PG_NARGS() != 1 || PG_ARGISNULL(0)) { - /* LINTED: end-of-loop code not reached */ - PG_RETURN_NULL(); - } - - /* get pointer to arg */ - if ((pg_host_str = (void *) PG_GETARG_TEXT_P(0)) == NULL) { - /* LINTED: end-of-loop code not reached */ - PG_RETURN_NULL(); - } - - /* check for null pointer */ - if (VARDATA(pg_host_str) == NULL) { - /* LINTED: end-of-loop code not reached */ - PG_RETURN_NULL(); - } - - /* get string length */ - len = VARSIZE(pg_host_str) - VARHDRSZ; - if (len < 1 || len >= sizeof (host_str)) { - /* LINTED: end-of-loop code not reached */ - PG_RETURN_NULL(); - } - - /* must null terminate copy of input string */ - (void) memcpy(host_str, VARDATA(pg_host_str), len); - host_str[len] = '\0'; /* must do!!! */ - - /* find ident (ip address), host_str is a host name or ip address */ - if ((ident = mms_host_ident(host_str, host, ip)) == NULL) { - /* LINTED: end-of-loop code not reached */ - PG_RETURN_NULL(); - } - - /* ident is what mm uses internally (ip address) */ - len = VARHDRSZ + strlen(ident); - if ((pg_ident = (void *) palloc(len)) == NULL) { - /* LINTED: end-of-loop code not reached */ - PG_RETURN_NULL(); - } - SET_VARSIZE(pg_ident, len); - - /* don't copy string null terminator, pg string struct has length */ - (void) memcpy(VARDATA(pg_ident), ident, strlen(ident)); - - PG_RETURN_TEXT_P(pg_ident); -} diff --git a/usr/src/lib/mms/pg/common/pg_uuid.c b/usr/src/lib/mms/pg/common/pg_uuid.c deleted file mode 100644 index e99bf3fe52..0000000000 --- a/usr/src/lib/mms/pg/common/pg_uuid.c +++ /dev/null @@ -1,71 +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. - */ - - -#include <postgres.h> -#include <fmgr.h> -#include <string.h> -#include <sys/types.h> -#include <sys/uuid.h> -#include <string.h> -#include <stdlib.h> -#include <sys/time.h> - -/* - * Postgres server library for MMS UUID. - */ - -#define UUID_POSTGRES_LEN 36 - -extern void uuid_clear(uuid_t uu); -extern void uuid_generate_random(uuid_t uu); -extern void uuid_unparse(uuid_t uu, char *out); - -PG_FUNCTION_INFO_V1(pg_get_uuid); - -Datum -pg_get_uuid(PG_FUNCTION_ARGS) -{ - void *pg_uuid; - int32 len; - uuid_t uuid; - char buf[UUID_POSTGRES_LEN+1]; - - len = VARHDRSZ + UUID_POSTGRES_LEN; - if ((pg_uuid = (void *) palloc(len)) == NULL) { - /* LINTED: end-of-loop code not reached */ - PG_RETURN_NULL(); - } - SET_VARSIZE(pg_uuid, len); - - /* cefa7a9c-1dd2-11b2-8350-880020adbeef */ - uuid_clear(uuid); - uuid_generate_random(uuid); - uuid_unparse(uuid, buf); - - /* don't copy string null terminator, pg string struct has length */ - (void) memcpy(VARDATA(pg_uuid), buf, UUID_POSTGRES_LEN); - - PG_RETURN_TEXT_P(pg_uuid); -} diff --git a/usr/src/lib/mms/pg/i386/Makefile b/usr/src/lib/mms/pg/i386/Makefile deleted file mode 100644 index d77b753d64..0000000000 --- a/usr/src/lib/mms/pg/i386/Makefile +++ /dev/null @@ -1,26 +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. -# -# -include ../Makefile.com diff --git a/usr/src/lib/mms/pg/sparc/Makefile b/usr/src/lib/mms/pg/sparc/Makefile deleted file mode 100644 index 28e580ae09..0000000000 --- a/usr/src/lib/mms/pg/sparc/Makefile +++ /dev/null @@ -1,27 +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. -# -# - -include ../Makefile.com diff --git a/usr/src/pkg/manifests/SUNWcs.mf b/usr/src/pkg/manifests/SUNWcs.mf index e1890ce8e0..2245b5c244 100644 --- a/usr/src/pkg/manifests/SUNWcs.mf +++ b/usr/src/pkg/manifests/SUNWcs.mf @@ -1,27 +1,4 @@ -# -# 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) 2010, Oracle and/or its affiliates. All rights reserved. -# set name=pkg.fmri value=pkg:/SUNWcs@$(PKGVERS) set name=pkg.description \ @@ -929,12 +906,6 @@ file path=usr/lib/help/auths/locale/C/AuditHeader.html file path=usr/lib/help/auths/locale/C/AuditRead.html file path=usr/lib/help/auths/locale/C/AuthJobsAdmin.html file path=usr/lib/help/auths/locale/C/AuthJobsUser.html -file path=usr/lib/help/auths/locale/C/AuthMMSDeviceLog.html -file path=usr/lib/help/auths/locale/C/AuthMMSDeviceState.html -file path=usr/lib/help/auths/locale/C/AuthMMSIORead.html -file path=usr/lib/help/auths/locale/C/AuthMMSIOWrite.html -file path=usr/lib/help/auths/locale/C/AuthMMSMedia.html -file path=usr/lib/help/auths/locale/C/AuthMMSRequest.html file path=usr/lib/help/auths/locale/C/AuthProfmgrAssign.html file path=usr/lib/help/auths/locale/C/AuthProfmgrDelegate.html file path=usr/lib/help/auths/locale/C/AuthProfmgrExecattrWrite.html @@ -962,7 +933,6 @@ file path=usr/lib/help/auths/locale/C/LinkSecurity.html file path=usr/lib/help/auths/locale/C/LoginEnable.html file path=usr/lib/help/auths/locale/C/LoginHeader.html file path=usr/lib/help/auths/locale/C/LoginRemote.html -file path=usr/lib/help/auths/locale/C/MMSHeader.html file path=usr/lib/help/auths/locale/C/NetworkAutoconfRead.html file path=usr/lib/help/auths/locale/C/NetworkAutoconfSelect.html file path=usr/lib/help/auths/locale/C/NetworkAutoconfWlan.html @@ -991,7 +961,6 @@ file path=usr/lib/help/auths/locale/C/SmfLocationStates.html file path=usr/lib/help/auths/locale/C/SmfMDNSStates.html file path=usr/lib/help/auths/locale/C/SmfManageHeader.html file path=usr/lib/help/auths/locale/C/SmfManageHotplug.html -file path=usr/lib/help/auths/locale/C/SmfManageMMS.html file path=usr/lib/help/auths/locale/C/SmfManageZFSSnap.html file path=usr/lib/help/auths/locale/C/SmfModifyAppl.html file path=usr/lib/help/auths/locale/C/SmfModifyDepend.html @@ -1022,7 +991,6 @@ file path=usr/lib/help/auths/locale/C/SmfValueIPsec.html file path=usr/lib/help/auths/locale/C/SmfValueIdmap.html file path=usr/lib/help/auths/locale/C/SmfValueInetd.html file path=usr/lib/help/auths/locale/C/SmfValueMDNS.html -file path=usr/lib/help/auths/locale/C/SmfValueMMS.html file path=usr/lib/help/auths/locale/C/SmfValueNADD.html file path=usr/lib/help/auths/locale/C/SmfValueNDMP.html file path=usr/lib/help/auths/locale/C/SmfValueNWAM.html @@ -1076,9 +1044,6 @@ file path=usr/lib/help/profiles/locale/C/RtInetdMngmnt.html file path=usr/lib/help/profiles/locale/C/RtKerberosClntMngmnt.html file path=usr/lib/help/profiles/locale/C/RtKerberosSrvrMngmnt.html file path=usr/lib/help/profiles/locale/C/RtLogMngmnt.html -file path=usr/lib/help/profiles/locale/C/RtMMSAdmin.html -file path=usr/lib/help/profiles/locale/C/RtMMSOper.html -file path=usr/lib/help/profiles/locale/C/RtMMSUser.html file path=usr/lib/help/profiles/locale/C/RtMailMngmnt.html file path=usr/lib/help/profiles/locale/C/RtMaintAndRepair.html file path=usr/lib/help/profiles/locale/C/RtMediaBkup.html diff --git a/usr/src/pkg/manifests/consolidation-osnet-osnet-message-files.mf b/usr/src/pkg/manifests/consolidation-osnet-osnet-message-files.mf index de6c33c804..fb3229e3e6 100644 --- a/usr/src/pkg/manifests/consolidation-osnet-osnet-message-files.mf +++ b/usr/src/pkg/manifests/consolidation-osnet-osnet-message-files.mf @@ -1,28 +1,4 @@ -# -# 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 2010 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# +# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. set name=pkg.fmri value=pkg:/consolidation/osnet/osnet-message-files@$(PKGVERS) set name=pkg.description \ @@ -81,12 +57,6 @@ file path=usr/lib/help/auths/locale/AuditHeader.html file path=usr/lib/help/auths/locale/AuditRead.html file path=usr/lib/help/auths/locale/AuthJobsAdmin.html file path=usr/lib/help/auths/locale/AuthJobsUser.html -file path=usr/lib/help/auths/locale/AuthMMSDeviceLog.html -file path=usr/lib/help/auths/locale/AuthMMSDeviceState.html -file path=usr/lib/help/auths/locale/AuthMMSIORead.html -file path=usr/lib/help/auths/locale/AuthMMSIOWrite.html -file path=usr/lib/help/auths/locale/AuthMMSMedia.html -file path=usr/lib/help/auths/locale/AuthMMSRequest.html file path=usr/lib/help/auths/locale/AuthProfmgrAssign.html file path=usr/lib/help/auths/locale/AuthProfmgrDelegate.html file path=usr/lib/help/auths/locale/AuthProfmgrExecattrWrite.html @@ -127,7 +97,6 @@ file path=usr/lib/help/auths/locale/LinkSecurity.html file path=usr/lib/help/auths/locale/LoginEnable.html file path=usr/lib/help/auths/locale/LoginHeader.html file path=usr/lib/help/auths/locale/LoginRemote.html -file path=usr/lib/help/auths/locale/MMSHeader.html file path=usr/lib/help/auths/locale/MailHeader.html file path=usr/lib/help/auths/locale/MailQueue.html file path=usr/lib/help/auths/locale/NetworkAutoconfRead.html @@ -165,7 +134,6 @@ file path=usr/lib/help/auths/locale/SmfLocationStates.html file path=usr/lib/help/auths/locale/SmfMDNSStates.html file path=usr/lib/help/auths/locale/SmfManageHeader.html file path=usr/lib/help/auths/locale/SmfManageHotplug.html -file path=usr/lib/help/auths/locale/SmfManageMMS.html file path=usr/lib/help/auths/locale/SmfManageZFSSnap.html file path=usr/lib/help/auths/locale/SmfModifyAppl.html file path=usr/lib/help/auths/locale/SmfModifyDepend.html @@ -196,7 +164,6 @@ file path=usr/lib/help/auths/locale/SmfValueIPsec.html file path=usr/lib/help/auths/locale/SmfValueIdmap.html file path=usr/lib/help/auths/locale/SmfValueInetd.html file path=usr/lib/help/auths/locale/SmfValueMDNS.html -file path=usr/lib/help/auths/locale/SmfValueMMS.html file path=usr/lib/help/auths/locale/SmfValueNADD.html file path=usr/lib/help/auths/locale/SmfValueNDMP.html file path=usr/lib/help/auths/locale/SmfValueNWAM.html @@ -254,9 +221,6 @@ file path=usr/lib/help/profiles/locale/RtInfoSec.html file path=usr/lib/help/profiles/locale/RtKerberosClntMngmnt.html file path=usr/lib/help/profiles/locale/RtKerberosSrvrMngmnt.html file path=usr/lib/help/profiles/locale/RtLogMngmnt.html -file path=usr/lib/help/profiles/locale/RtMMSAdmin.html -file path=usr/lib/help/profiles/locale/RtMMSOper.html -file path=usr/lib/help/profiles/locale/RtMMSUser.html file path=usr/lib/help/profiles/locale/RtMailMngmnt.html file path=usr/lib/help/profiles/locale/RtMaintAndRepair.html file path=usr/lib/help/profiles/locale/RtMediaBkup.html diff --git a/usr/src/pkg/manifests/storage-storage-server.mf b/usr/src/pkg/manifests/storage-storage-server.mf index 8b562255c6..142335869e 100644 --- a/usr/src/pkg/manifests/storage-storage-server.mf +++ b/usr/src/pkg/manifests/storage-storage-server.mf @@ -1,28 +1,4 @@ -# -# 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 2010 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# +# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. set name=pkg.fmri \ value=pkg:/storage/storage-server@0.1,$(PKGVERS_BUILTON)-$(PKGVERS_BRANCH) @@ -90,4 +66,3 @@ depend fmri=system/library/svm-rcm type=require depend fmri=system/management/wbem/data-management type=require depend fmri=system/storage/fibre-channel/port-utility type=require depend fmri=system/storage/luxadm type=require -depend fmri=system/storage/mms type=require diff --git a/usr/src/pkg/manifests/system-storage-mms.mf b/usr/src/pkg/manifests/system-storage-mms.mf index e487d0efcb..a16c9286ec 100644 --- a/usr/src/pkg/manifests/system-storage-mms.mf +++ b/usr/src/pkg/manifests/system-storage-mms.mf @@ -1,215 +1,9 @@ -# -# 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) 2010, Oracle and/or its affiliates. All rights reserved. -# -# Copyright 2010 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -set name=pkg.fmri value=pkg:/system/storage/mms@$(PKGVERS) +set name=pkg.fmri value=pkg:/system/storage/mms@0.5.11,5.11-0.138 +set name=pkg.obsolete value=true set name=pkg.description value="Media Management System" set name=pkg.summary value="MMS - Media Management Software" set name=info.classification value=org.opensolaris.category.2008:System/Media set name=variant.arch value=$(ARCH) set name=variant.opensolaris.zone value=global value=nonglobal -dir path=etc group=sys opensolaris.zone=global variant.opensolaris.zone=global -dir path=etc/mms group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=etc/mms/config group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=etc/mms/db opensolaris.zone=global variant.opensolaris.zone=global -dir path=etc/mms/passwd group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=etc/mms/types group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=etc/security group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=kernel group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=kernel/drv group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=kernel/drv/$(ARCH64) group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=lib opensolaris.zone=global variant.opensolaris.zone=global -dir path=lib/svc opensolaris.zone=global variant.opensolaris.zone=global -dir path=lib/svc/method opensolaris.zone=global variant.opensolaris.zone=global -dir path=usr group=sys -dir path=usr/bin -dir path=usr/include -dir path=usr/include/mms -dir path=usr/lib -dir path=usr/lib/mms -dir path=usr/lib/mms/dm -dir path=usr/lib/mms/lm -dir path=var group=sys opensolaris.zone=global variant.opensolaris.zone=global -dir path=var/log group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=var/log/mms group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=var/log/mms/api group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=var/log/mms/dm group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=var/log/mms/lm group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=var/log/mms/mm group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=var/log/mms/wcr group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=var/mms group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=var/mms/cores group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=var/mms/handle group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=var/mms/ssl group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=var/mms/ssl/ca group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=var/mms/ssl/pub group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=lib/svc/manifest group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=lib/svc/manifest/application group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -dir path=lib/svc/manifest/application/management group=sys \ - opensolaris.zone=global variant.opensolaris.zone=global -driver name=dda devlink=type=ddi_pseudo;name=dda\tdda/\N0\M0 -driver name=dmd -file path=etc/mms/config/mm_paths.xml group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -file path=etc/mms/db/mms_db group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -file path=etc/mms/types/mm_types.xml group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -file path=kernel/drv/$(ARCH64)/dda group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -file path=kernel/drv/$(ARCH64)/dmd group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -$(i386_ONLY)file path=kernel/drv/dda group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -file path=kernel/drv/dda.conf group=sys opensolaris.zone=global \ - reboot-needed=false variant.opensolaris.zone=global -$(i386_ONLY)file path=kernel/drv/dmd group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -file path=kernel/drv/dmd.conf group=sys opensolaris.zone=global \ - reboot-needed=false variant.opensolaris.zone=global -file path=lib/svc/method/mmsdb mode=0555 opensolaris.zone=global \ - variant.opensolaris.zone=global -file path=lib/svc/method/mmsmm mode=0555 opensolaris.zone=global \ - variant.opensolaris.zone=global -file path=lib/svc/method/mmswcr mode=0555 opensolaris.zone=global \ - variant.opensolaris.zone=global -file path=usr/bin/mmsadm mode=0555 -file path=usr/bin/mmsclient mode=0755 -file path=usr/bin/mmsexplorer mode=0755 -file path=usr/bin/mmsinit mode=0555 -file path=usr/bin/mmsmnt mode=4755 -file path=usr/bin/mmsssi.sh mode=0555 -file path=usr/bin/mmsssl.sh mode=0555 -file path=usr/include/mms/mms.h group=other -file path=usr/include/mms/mms_api.h group=other -file path=usr/include/mms/mms_api_msg.h group=other -file path=usr/include/mms/mms_cat.h group=other -file path=usr/include/mms/mms_dmd.h group=other -file path=usr/include/mms/mms_err.h group=other -file path=usr/include/mms/mms_list.h group=other -file path=usr/include/mms/mms_network.h group=other -file path=usr/include/mms/mms_parser.h group=other -file path=usr/include/mms/mms_strapp.h group=other -file path=usr/include/mms/mms_sym.h group=other -file path=usr/include/mms/mms_trace.h group=other -file path=usr/lib/libmms.so.1 group=other -file path=usr/lib/llib-lmms.ln group=other -file path=usr/lib/mms/dm/libHP_Ultrium_3-SCSI.so -file path=usr/lib/mms/dm/libIBM_ULTRIUM-TD1.so -file path=usr/lib/mms/dm/libIBM_ULTRIUM-TD2.so -file path=usr/lib/mms/dm/libIBM_ULTRIUM-TD3.so -file path=usr/lib/mms/dm/libIBM_ULTRIUM-TD4.so -file path=usr/lib/mms/dm/libQUANTUM_SDLT600.so -file path=usr/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX.so -file path=usr/lib/mms/dm/libSTK_9840.so -file path=usr/lib/mms/dm/libSTK_T9840B.so -file path=usr/lib/mms/dm/libSTK_T9840C.so -file path=usr/lib/mms/dm/libSTK_T9940A.so -file path=usr/lib/mms/dm/libSTK_T9940B.so -file path=usr/lib/mms/dm/libSUNW_DISK_ARCHIVING.so -file path=usr/lib/mms/dm/libdm_default.so -file path=usr/lib/mms/dm/llib-lHP_Ultrium_3-SCSI.ln -file path=usr/lib/mms/dm/llib-lIBM_ULTRIUM-TD1.ln -file path=usr/lib/mms/dm/llib-lIBM_ULTRIUM-TD2.ln -file path=usr/lib/mms/dm/llib-lIBM_ULTRIUM-TD3.ln -file path=usr/lib/mms/dm/llib-lIBM_ULTRIUM-TD4.ln -file path=usr/lib/mms/dm/llib-lQUANTUM_SDLT600.ln -file path=usr/lib/mms/dm/llib-lSEAGATE_ULTRIUM06242-XXX.ln -file path=usr/lib/mms/dm/llib-lSTK_9840.ln -file path=usr/lib/mms/dm/llib-lSTK_T9840B.ln -file path=usr/lib/mms/dm/llib-lSTK_T9840C.ln -file path=usr/lib/mms/dm/llib-lSTK_T9940A.ln -file path=usr/lib/mms/dm/llib-lSTK_T9940B.ln -file path=usr/lib/mms/dm/llib-lSUNW_DISK_ARCHIVING.ln -file path=usr/lib/mms/dm/llib-ldm_default.ln -file path=usr/lib/mms/libmmsadm.so.1 group=other -file path=usr/lib/mms/libpg.so.1 group=other -file path=usr/lib/mms/llib-lmmsadm.ln group=other -file path=usr/lib/mms/llib-lpg.ln group=other -file path=usr/lib/mms/lm/libDISK.so group=other -file path=usr/lib/mms/lm/libL180_net.so group=other -file path=usr/lib/mms/lm/libL500_net.so group=other -file path=usr/lib/mms/lm/libL700_net.so group=other -file path=usr/lib/mms/lm/libSL3000_net.so group=other -file path=usr/lib/mms/lm/libSL8500_net.so group=other -file path=usr/lib/mms/lm/llib-lDISK.ln group=other -file path=usr/lib/mms/lm/llib-lL180_net.ln group=other -file path=usr/lib/mms/lm/llib-lL500_net.ln group=other -file path=usr/lib/mms/lm/llib-lL700_net.ln group=other -file path=usr/lib/mms/lm/llib-lSL3000_net.ln group=other -file path=usr/lib/mms/lm/llib-lSL8500_net.ln group=other -file path=usr/lib/mmsdm mode=0555 -file path=usr/lib/mmslm mode=0555 -file path=var/log/mms/mms_logadm.conf group=sys opensolaris.zone=global \ - original_name=SUNWmms:var/log/mms/mms_logadm.conf preserve=true \ - variant.opensolaris.zone=global -file path=var/mms/ssl/ca/mms_openssl.cnf group=sys opensolaris.zone=global \ - variant.opensolaris.zone=global -file path=lib/svc/manifest/application/management/mms.xml group=sys mode=0444 \ - opensolaris.zone=global variant.opensolaris.zone=global -legacy pkg=SUNWmmsr arch=$(ARCH) category=system desc="Media Management System" \ - hotline="Please contact your local service provider" \ - name="MMS - Media Management Software (root)" \ - vendor="Sun Microsystems, Inc." version=11.11,REV=2009.11.11 -legacy pkg=SUNWmmsu arch=$(ARCH) category=system desc="Media Management System" \ - hotline="Please contact your local service provider" \ - name="MMS - Media Management Software (usr)" \ - vendor="Sun Microsystems, Inc." version=11.11,REV=2009.11.11 -license cr_Sun license=cr_Sun -license lic_CDDL license=lic_CDDL -link path=usr/lib/libmms.so target=libmms.so.1 -link path=usr/lib/mms/dm/libHP_Ultrium_1-SCSI.so target=libIBM_ULTRIUM-TD1.so -link path=usr/lib/mms/dm/libHP_Ultrium_2-SCSI.so target=libIBM_ULTRIUM-TD2.so -link path=usr/lib/mms/dm/libHP_Ultrium_4-SCSI.so target=libIBM_ULTRIUM-TD4.so -link path=usr/lib/mms/dm/libIBM_ULT3580-TD1.so target=libIBM_ULTRIUM-TD1.so -link path=usr/lib/mms/dm/libIBM_ULT3580-TD2.so target=libIBM_ULTRIUM-TD2.so -link path=usr/lib/mms/dm/libIBM_ULT3580-TD3.so target=libIBM_ULTRIUM-TD3.so -link path=usr/lib/mms/dm/libIBM_ULT3580-TD4.so target=libIBM_ULTRIUM-TD4.so -link path=usr/lib/mms/libmmsadm.so target=libmmsadm.so.1 -link path=usr/lib/mms/libpg.so target=libpg.so.1 -link path=usr/lib/mms/lm/libSL500_net.so target=libL500_net.so diff --git a/usr/src/uts/common/Makefile.files b/usr/src/uts/common/Makefile.files index b514153403..6d10553ad0 100644 --- a/usr/src/uts/common/Makefile.files +++ b/usr/src/uts/common/Makefile.files @@ -1,26 +1,5 @@ -# -# 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) 1991, 2010, Oracle and/or its affiliates. All rights reserved. + # # This Makefile defines all file modules for the directory uts/common # and its children. These are the source files which may be considered @@ -1813,10 +1792,6 @@ BFE_OBJS += bfe.o BRIDGE_OBJS += bridge.o -DDA_OBJS += dda.o - -DMD_OBJS += dmd.o - IDM_SHARED_OBJS += base64.o IDM_OBJS += $(IDM_SHARED_OBJS) \ diff --git a/usr/src/uts/common/Makefile.rules b/usr/src/uts/common/Makefile.rules index fa12fcd9c7..7042a7e8c3 100644 --- a/usr/src/uts/common/Makefile.rules +++ b/usr/src/uts/common/Makefile.rules @@ -1,23 +1,4 @@ -# -# 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) 1991, 2010, Oracle and/or its affiliates. All rights reserved. # # Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. @@ -902,14 +883,6 @@ $(OBJS_DIR)/%.o: $(UTSBASE)/common/io/mr_sas/%.c $(COMPILE.c) -o $@ $< $(CTFCONVERT_O) -$(OBJS_DIR)/%.o: $(UTSBASE)/common/io/mms/dda/%.c - $(COMPILE.c) -o $@ $< - $(CTFCONVERT_O) - -$(OBJS_DIR)/%.o: $(UTSBASE)/common/io/mms/dmd/%.c - $(COMPILE.c) -o $@ $< - $(CTFCONVERT_O) - $(OBJS_DIR)/%.o: $(UTSBASE)/common/io/scsi/adapters/mpt_sas/%.c $(COMPILE.c) -o $@ $< $(CTFCONVERT_O) @@ -2168,12 +2141,6 @@ $(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/mii/%.c $(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/mr_sas/%.c @($(LHEAD) $(LINT.c) $< $(LTAIL)) -$(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/mms/dda/%.c - @($(LHEAD) $(LINT.c) $< $(LTAIL)) - -$(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/mms/dmd/%.c - @($(LHEAD) $(LINT.c) $< $(LTAIL)) - $(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/scsi/adapters/mpt_sas/%.c @($(LHEAD) $(LINT.c) $< $(LTAIL)) diff --git a/usr/src/uts/common/io/mms/dda/dda.c b/usr/src/uts/common/io/mms/dda/dda.c deleted file mode 100644 index 771a6713c1..0000000000 --- a/usr/src/uts/common/io/mms/dda/dda.c +++ /dev/null @@ -1,4329 +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. - */ - - -/* - * Driver for Disk Archiving (dda) - * - * DDA emulates the st tape driver BSD mode for MMS disk archiving. - * - * A limited number of MTIO operations are implemented by DDA. - * - * USCSI commands are not implemented by DDA. - * - * Tape drive operations such as load, capacity and read block limits - * are DDA ioctl commands. - * - * DDA media is implemented as a cartridge directory containing three - * files: metadata, index and data. - * - * The metadata file contains cartridge information such as version, - * capacity, stripe alignment, direct I/O alignment, and the write - * protect tab. The user application sets the alignments when the dda - * media is created. - * - * The index file contains index records which describes the data file. - * An index record contains the data file offset, number of consecutive - * same size records and filemarks. An new index record is generated - * when a write changes record sizes or data follows a filemark. A on - * disk binary search is used for locate or space filemarks operations. - * An advisory file lock is held on the index file to prevent multiple - * loads for the same piece of dda media and to prevent a load when - * the user is changing the cartridge write protect tab. The data file - * offset is adjusted for alignment at bot, when data follows a filemark, - * or the record size changes. Stripe alignment occurs at bot or after a - * filemark. Direct I/O alignment occurs for every read or write operation - * and is applied after the stripe alignment. - * - * The data file contains user data along with holes for stripe and - * direct I/O alignment. - * - * The metadata and index file records are used in native endian format - * in memory and are stored on disk in big endian format. The data file - * is in the host's native endian format. - */ - -#include <sys/devops.h> /* used by dev_ops */ -#include <sys/conf.h> /* used by dev_ops and cb_ops */ -#include <sys/modctl.h> /* used by modlinkage, modldrv, */ - /* _init, _info, and _fini */ -#include <sys/types.h> /* used by open, close, read, write, */ - /* prop_op, and ddi_prop_op */ -#include <sys/file.h> /* used by open, close */ -#include <sys/errno.h> /* used by open, close, read, write */ -#include <sys/open.h> /* used by open, close, read, write */ -#include <sys/cred.h> /* used by open, close, read */ -#include <sys/uio.h> /* used by read */ -#include <sys/stat.h> /* defines S_IFCHR used by */ - /* ddi_create_minor_node */ -#include <sys/cmn_err.h> /* used by all entry points for */ - /* this driver */ -#include <sys/ddi.h> /* used by all entry points for */ - /* this driver also used by cb_ops, */ - /* ddi_get_instance, and ddi_prop_op */ -#include <sys/sunddi.h> /* used by all entry points for */ - /* this driver also used by cb_ops, */ - /* ddi_create_minor_node, */ - /* ddi_get_instance, and ddi_prop_op */ -#include <sys/scsi/impl/uscsi.h> /* uscsi commands */ -#include <sys/ioctl.h> -#include <sys/mtio.h> /* tape io */ -#include <sys/systeminfo.h> /* for hostid access */ -#include <sys/scsi/targets/stdef.h> -#include <sys/vfs.h> -#include <limits.h> -#include <sys/sdt.h> /* d-trace */ -#include <sys/flock.h> /* advisory non-blocking file lock */ -#include "dda.h" - -/* vnode mode is read, write, large files, allow symlinks */ -#define DDA_VNODE_MODE FREAD|FWRITE|FOFFMAX - -/* maximum block size */ -#define DDA_MAX_REC_SIZE 262144 /* maximum media block size */ - -/* early warning capacity - space */ -#define DDA_EARLY_WARN 98 /* media early warning percentage */ - -/* block number unknown */ -#define DDA_BLKNO_UNKNOWN 1000000000 - -/* file name unknown */ -#define DDA_UNKNOWN_FNAME "?" - -/* operation flags and macros */ -#define DDA_FLAG_TRUNC 0x1 /* write truncate */ -#define DDA_FLAG_FM_FWD_PEND 0x2 /* file mark forward pending */ -#define DDA_FLAG_FM_NOSKIP 0x4 /* fsr set fm forward pending */ -#define DDA_FLAG_FM_NEEDED 0x8 /* file mark needed */ -#define DDA_FLAG_EOT_EIO 0x10 /* read return code for eot */ -#define DDA_FLAG_EW 0x20 /* alternating ew write failure */ -#define DDA_FLAG_INDEX 0x40 /* index record needs file write */ - -#define DDA_GET_TRUNC(x) (x->dda_flags & DDA_FLAG_TRUNC) -#define DDA_GET_FM_FWD_PEND(x) (x->dda_flags & DDA_FLAG_FM_FWD_PEND) -#define DDA_GET_FM_NOSKIP(x) (x->dda_flags & DDA_FLAG_FM_NOSKIP) -#define DDA_GET_FM_NEEDED(x) (x->dda_flags & DDA_FLAG_FM_NEEDED) -#define DDA_GET_EOT_EIO(x) (x->dda_flags & DDA_FLAG_EOT_EIO) -#define DDA_GET_EW(x) (x->dda_flags & DDA_FLAG_EW) -#define DDA_GET_INDEX(x) (x->dda_flags & DDA_FLAG_INDEX) - -#define DDA_SET_TRUNC(x) (x->dda_flags |= DDA_FLAG_TRUNC) -#define DDA_SET_FM_FWD_PEND(x) (x->dda_flags |= DDA_FLAG_FM_FWD_PEND) -#define DDA_SET_FM_NOSKIP(x) (x->dda_flags |= DDA_FLAG_FM_NOSKIP) -#define DDA_SET_FM_NEEDED(x) (x->dda_flags |= DDA_FLAG_FM_NEEDED) -#define DDA_SET_EOT_EIO(x) (x->dda_flags |= DDA_FLAG_EOT_EIO) -#define DDA_SET_EW(x) (x->dda_flags |= DDA_FLAG_EW) -#define DDA_SET_INDEX(x) (x->dda_flags |= DDA_FLAG_INDEX) - -#define DDA_CLR_TRUNC(x) (x->dda_flags &= ~DDA_FLAG_TRUNC) -#define DDA_CLR_FM_FWD_PEND(x) (x->dda_flags &= ~(DDA_FLAG_FM_FWD_PEND | \ - DDA_FLAG_FM_NOSKIP)) -#define DDA_CLR_FM_NOSKIP(x) (x->dda_flags &= ~DDA_FLAG_FM_NOSKIP) -#define DDA_CLR_FM_NEEDED(x) (x->dda_flags &= ~DDA_FLAG_FM_NEEDED) -#define DDA_CLR_EOT_EIO(x) (x->dda_flags &= ~DDA_FLAG_EOT_EIO) -#define DDA_CLR_EW(x) (x->dda_flags &= ~DDA_FLAG_EW) -#define DDA_CLR_INDEX(x) (x->dda_flags &= ~DDA_FLAG_INDEX) - -/* metadata flag */ -#define DDA_GET_WPROTECT(x) (x->dda_metadata.dda_flags & DDA_FLAG_WPROTECT) - -/* read only tape */ -#define DDA_GET_READ_ONLY(x) ((x->dda_read_only || \ - DDA_GET_WPROTECT(x)) ? 1 : 0) - -/* alignment macros */ -#define DDA_OFF_ALIGNED(off, sz) (off & (int64_t)(sz - 1)) -#define DDA_LEN_ALIGNED(len, sz) ((size_t)len & (sz - 1)) - -/* index record calculations */ -#define DDA_IS_BOT(x) (x->dda_index_offset == 0 && \ - x->dda_pos == 0 ? 1 : 0) -#define DDA_IS_BLANK(x) (x->dda_index_offset == 0 && \ - DDA_INDEX_COUNT(x) == 0 ? 1 : 0) -#define DDA_IS_FM(x) (DDA_IS_BLANK(x) ? 0 : \ - x->dda_index.dda_fmcount && \ - x->dda_pos >= x->dda_index. \ - dda_blkcount && \ - x->dda_pos <= DDA_INDEX_COUNT(x) ? 1 : 0) -#define DDA_LBA(x) (x->dda_index.dda_lba + x->dda_pos) -#define DDA_INDEX_COUNT(x) (x->dda_index.dda_blkcount + \ - x->dda_index.dda_fmcount) - -#ifdef DEBUG -#define DDA_DEBUG(y) y -#else -#define DDA_DEBUG(y) -#endif - -#define DDA_DEBUG1(x) DDA_DEBUG(DTRACE_PROBE1 x) -#define DDA_DEBUG2(x) DDA_DEBUG(DTRACE_PROBE2 x) -#define DDA_DEBUG3(x) DDA_DEBUG(DTRACE_PROBE3 x) -#define DDA_DEBUG4(x) DDA_DEBUG(DTRACE_PROBE4 x) - -/* index record state */ -typedef struct dda_istate { - dda_index_t dda_index; - off64_t dda_index_offset; - int64_t dda_pos; - uint32_t dda_flags; -} dda_istate_t; - -/* driver operations */ -static int dda_attach(dev_info_t *dip, ddi_attach_cmd_t cmd); -static int dda_detach(dev_info_t *dip, ddi_detach_cmd_t cmd); -static int dda_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, - void **resultp); -static int dda_open(dev_t *devp, int flag, int otyp, cred_t *credp); -static int dda_close(dev_t dev, int flag, int otyp, cred_t *credp); -static int dda_read(dev_t dev, struct uio *uio, cred_t *credp); -static int dda_write(dev_t dev, struct uio *uio, cred_t *credp); -static int dda_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp, - int *rvalp); - -/* tape operations */ -static int dda_tape_op(dda_t *dda, struct mtlop *mtop); -static int dda_tape_load(dda_t *dda, char *path); -static int dda_tape_unload(dda_t *dda); -static int dda_tape_rewind(dda_t *dda); -static int dda_tape_write(dda_t *dda, struct uio *uio); -static int dda_tape_read(dda_t *dda, struct uio *uio); -static int dda_tape_wfm(dda_t *dda, int count); -static int dda_tape_eom(dda_t *dda); -static int dda_tape_fsf(dda_t *dda, int count); -static int dda_tape_bsf(dda_t *dda, int count); -static int dda_tape_fsr(dda_t *dda, int count); -static int dda_tape_bsr(dda_t *dda, int count); -static int dda_tape_locate(dda_t *dda, int64_t position); -static int dda_tape_erase(dda_t *dda); - -/* support routines */ -static void dda_set_unloaded(dda_t *dda); -static int64_t dda_get_fileno(dda_t *dda); -static int dda_get_blkno(dda_t *dda, int64_t *blkno); -static int dda_write_truncate(dda_t *dda); - -/* index record write, read, generate, save and restore */ -static int dda_write_index(dda_t *dda); -static int dda_read_index(dda_t *dda); -static void dda_gen_next_index(dda_t *dda, int32_t blksize); -static void dda_save_istate(dda_t *dda, dda_istate_t *istate); -static void dda_restore_istate(dda_t *dda, dda_istate_t *istate); - -/* data file offset */ -static off64_t dda_stripe_align(dda_t *dda); -static off64_t dda_data_offset(dda_t *dda); - -/* space */ -static int dda_tape_capacity(dda_t *dda, int64_t *space); -static int dda_ew_eom(dda_t *dda, int32_t count, int64_t *avail, int *ew); - -/* search */ -static int dda_locate_compare(dda_t *dda, int64_t lba); -static int dda_fsf_compare(dda_t *dda, int64_t fileno); -static int dda_bsf_compare(dda_t *dda, int64_t fileno); -static int dda_bsearch(dda_t *dda, - int64_t key, - int (*compare)(dda_t *, int64_t), - int *found); - -/* vnode operations */ -static int dda_vn_open(dda_t *dda, struct vnode **vpp, char *fname); -static int dda_vn_close(dda_t *dda, struct vnode **vpp); -static int dda_vn_lock(dda_t *dda, struct vnode *vp, short lock); -static int dda_vn_read(dda_t *dda, struct vnode *vp, void *buf, int len, - off64_t offset); -static int dda_vn_write(dda_t *dda, struct vnode *vp, void *buf, int len, - off64_t offset); -static int dda_vn_truncate(dda_t *dda, struct vnode *vp, off64_t offset); -static int dda_vn_sync(dda_t *dda, struct vnode *vp); -static int dda_vn_size(dda_t *dda, struct vnode *vp, off64_t *fsize); -static char *dda_vn_get_fname(dda_t *dda, struct vnode *vp); -static void dda_vn_error_skey(dda_t *dda, int err); - -/* cb_ops structure */ -static struct cb_ops dda_cb_ops = { - dda_open, - dda_close, - nodev, /* no strategy - nodev returns ENXIO */ - nodev, /* no print */ - nodev, /* no dump */ - dda_read, - dda_write, - dda_ioctl, - nodev, /* no devmap */ - nodev, /* no mmap */ - nodev, /* no segmap */ - nochpoll, /* returns ENXIO for non-pollable devices */ - ddi_prop_op, - NULL, /* streamtab struct; if not NULL, all above */ - /* fields are ignored */ - D_NEW | D_MP, /* compatibility flags: see conf.h */ - CB_REV, /* cb_ops revision number */ - nodev, /* no aread */ - nodev /* no awrite */ -}; - -/* dev_ops structure */ -static struct dev_ops dda_dev_ops = { - DEVO_REV, - 0, /* reference count */ - dda_getinfo, - nulldev, /* no identify - nulldev returns 0 */ - nulldev, /* no probe */ - dda_attach, - dda_detach, - nodev, /* no reset - nodev returns ENXIO */ - &dda_cb_ops, - (struct bus_ops *)NULL, - nodev /* no power */ -}; - -/* modldrv structure */ -#define DDA_LINKINFO "driver for disk archiving" -static char dda_linkinfo[100]; -static struct modldrv dda_md = { - &mod_driverops, - dda_linkinfo, - &dda_dev_ops -}; - -/* modlinkage structure */ -static struct modlinkage dda_ml = { - MODREV_1, - &dda_md, - NULL -}; - -/* dev_info structure, one instance per dda device */ -static void *dda_state; - -/* Loadable module configuration entry points */ - -/* - * _init - * - * Parameters: - * None - * - * Globals: - * - dda_state: Uninitialized list of DDA drives. - * - dda_linkinfo: DDA description string. - * - dda_ml: DDA module linkage structure. - * - * Initialize list of emulated tape drives. - * Create driver description reported to user. - * Export driver specification to the kernel. - * - * Return Values: - * 0 : success - * non-zero : failure - * - */ -int -_init(void) -{ - int rc; - - if ((rc = ddi_soft_state_init(&dda_state, sizeof (dda_t), 0)) != 0) { - cmn_err(CE_WARN, "_init: soft state init error %d", rc); - return (rc); - } - (void) snprintf(dda_linkinfo, sizeof (dda_linkinfo), "%s %d.%d", - DDA_LINKINFO, DDA_MAJOR_VERSION, DDA_MINOR_VERSION); - if ((rc = mod_install(&dda_ml)) != 0) { - cmn_err(CE_WARN, "_init: mod install error %d", rc); - ddi_soft_state_fini(&dda_state); - } - return (rc); -} - -/* - * _info - * - * Parameters: - * - modinfop: Opaque module information structure. - * - * Globals: - * - dda_ml: DDA module linkage structure. - * - * Report DDA module information. - * - * Return Values: - * non-zero : success - * 0 : failure - * - */ -int -_info(struct modinfo *modinfop) -{ - int rc; - - if ((rc = mod_info(&dda_ml, modinfop)) == 0) { - cmn_err(CE_WARN, "_info: mod info error %d", rc); - } - return (rc); -} - -/* - * _fini - * - * Parameters: - * - none - * - * Globals: - * - dda_ml: DDA module linkage structure. - * - dda_state: DDA drive list. - * - * Prepare to unload the DDA driver from the kernel. - * Release DDA drive list to the system. - * - * Return Values: - * 0 : success - * non-zero : failure - * - */ -int -_fini(void) -{ - int rc; - - if ((rc = mod_remove(&dda_ml)) != 0) { - return (rc); - } - ddi_soft_state_fini(&dda_state); - return (rc); -} - -/* Device configuration entry points */ - -/* - * dda_attach - * - * Parameters: - * - dip: Device information structure. - * - cmd: Attach command. - * - * Globals: - * - dda_state: Pointer to list of DDA drives. - * - * Create and initialize one DDA tape drive for each dda.conf instance. - * Create BSD no-rewind tape drive minor node. - * Assign generated serial number to the drive. - * Initialize exclusive drive access mutex. - * Set drive state to unload. - * - * Return Values: - * DDI_SUCCESS : success - * DDI_FAILURE : failure - * - */ -static int -dda_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) -{ - int instance = ddi_get_instance(dip); - dda_t *dda; - - switch (cmd) { - case DDI_ATTACH: - if (ddi_soft_state_zalloc(dda_state, instance) != DDI_SUCCESS) { - cmn_err(CE_WARN, "%d attach soft state alloc failed", - instance); - return (DDI_FAILURE); - } - - if ((dda = ddi_get_soft_state(dda_state, instance)) == NULL) { - ddi_soft_state_free(dda_state, instance); - cmn_err(CE_WARN, "%d attach get soft state failed", - instance); - return (DDI_FAILURE); - } - dda->dda_inst = -1; - - if (ddi_create_minor_node(dip, "bn", S_IFCHR, - instance, DDI_PSEUDO, 0) != DDI_SUCCESS) { - ddi_soft_state_free(dda_state, instance); - cmn_err(CE_WARN, "%d attach create minor node failed", - instance); - return (DDI_FAILURE); - } - - dda->dda_dip = dip; - dda->dda_inst = instance; - mutex_init(&dda->dda_mutex, NULL, MUTEX_DRIVER, NULL); - dda_set_unloaded(dda); - return (DDI_SUCCESS); - default: - return (DDI_FAILURE); - } -} - -/* - * dda_detach - * - * Parameters: - * - dip: Device information structure. - * - cmd: Detach command. - * - * Globals: - * - dda_state: Pointer to list of DDA drives. - * - * Get drive instance from the list of drives. - * If media is loaded in the drive then unload the media. - * Remove minor device node. - * Release exclusive access mutex. - * Release memory. - * - * Return Values: - * DDI_SUCCESS : success - * DDI_FAILURE : failure - * - */ -static int -dda_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) -{ - int instance = ddi_get_instance(dip); - dda_t *dda; - - switch (cmd) { - case DDI_DETACH: - if ((dda = ddi_get_soft_state(dda_state, instance)) == NULL) { - cmn_err(CE_WARN, "%d detach get soft state failed", - instance); - return (DDI_FAILURE); - } - if (dda->dda_loaded) { - dda->dda_cred = kcred; - (void) dda_tape_unload(dda); - } - ddi_remove_minor_node(dip, "bn"); - mutex_destroy(&dda->dda_mutex); - ddi_soft_state_free(dda_state, instance); - return (DDI_SUCCESS); - default: - return (DDI_FAILURE); - } -} - -/* - * dda_getinfo - * - * Parameters: - * - dip: Device information structure. - * - cmd: Information command. - * - arg: Device structure. - * - resultp: Pointer for information requested. - * - * Globals: - * - dda_state: List of DDA emulated tape drives. - * - * Return drive instance information to the kernel. - * - * Return Values: - * DDI_SUCCESS : success - * DDI_FAILURE : failure - * - */ -/*ARGSUSED*/ -static int -dda_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, void **resultp) -{ - int instance = getminor((dev_t)arg); - dda_t *dda; - - switch (cmd) { - case DDI_INFO_DEVT2DEVINFO: - if ((dda = ddi_get_soft_state(dda_state, - instance)) == NULL) { - cmn_err(CE_WARN, "%d getinfo get soft state failed", - instance); - *resultp = NULL; - return (DDI_FAILURE); - } - *resultp = dda->dda_dip; - return (DDI_SUCCESS); - case DDI_INFO_DEVT2INSTANCE: - *resultp = (void *)(uintptr_t)instance; - return (DDI_SUCCESS); - default: - *resultp = NULL; - return (DDI_FAILURE); - } -} - -/* Main entry points */ - -/* - * dda_open - * - * Parameters: - * - devp: Device structure. - * - flag: Device open mode. - * - otyp: Character or block device open. - * - credp: User credentials. - * - * Globals: - * - dda_state: List of DDA emulated tape drives. - * - * Verify character device open. - * Get drive structure. - * Lock drive to ensure sequential access. - * If drive is already in-use then unlock drive and return busy. - * If drive is not loaded then prevent read only or write non-blocking - * access to the drive. - * Save open process pid as the test for drive in-use. - * Set read only mode. - * Unlock drive. - * - * Return Values: - * DDI_SUCCESS : success - * DDI_FAILURE : failure - * - */ -static int -dda_open(dev_t *devp, int flag, int otyp, cred_t *credp) -{ - int instance = getminor(*devp); - dda_t *dda; - - if (otyp != OTYP_CHR) { - return (EINVAL); - } - if ((dda = ddi_get_soft_state(dda_state, instance)) == NULL) { - return (ENXIO); - } - mutex_enter(&dda->dda_mutex); - if (dda->dda_pid) { - /* - * The real tape driver does not allow a drive to be - * opened multiple times. - */ - mutex_exit(&dda->dda_mutex); - return (EBUSY); - } - if (!dda->dda_loaded) { - /* - * The real tape driver does not allow an unloaded tape - * drive to be opened in read only or blocking mode. - */ - if ((flag & FWRITE) == 0 || - ((flag & FWRITE) == FWRITE && - (flag & (FNDELAY | FNONBLOCK)) == 0)) { - mutex_exit(&dda->dda_mutex); - return (EIO); - } - } - - /* user credentials */ - dda->dda_cred = credp; - - /* set open flag */ - dda->dda_pid = ddi_get_pid(); - - /* get read only mode */ - dda->dda_read_only = (flag & FWRITE) ? 0 : 1; - DDA_DEBUG2((dda_pid, - int, dda->dda_inst, - pid_t, dda->dda_pid)); - mutex_exit(&dda->dda_mutex); - return (0); -} - -/* - * dda_open - * - * Parameters: - * - devp: Device structure. - * - flag: Device open mode. - * - otyp: Character or block device open. - * - credp: User credentials. - * - * Globals: - * - dda_state: List of DDA emulated tape drives. - * - * Verify character device close. - * Get drive structure. - * Lock drive to ensure sequential access. - * Append filemark if loaded and needed. - * Unlock drive. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_close(dev_t dev, int flag, int otyp, cred_t *credp) -{ - int instance = getminor(dev); - dda_t *dda; - int err = 0; - - if (otyp != OTYP_CHR) { - return (EINVAL); - } - if ((dda = ddi_get_soft_state(dda_state, instance)) == NULL) { - return (ENXIO); - } - mutex_enter(&dda->dda_mutex); - dda->dda_cred = credp; - DDA_DEBUG2((dda_pid, - int, dda->dda_inst, - pid_t, dda->dda_pid)); - if (DDA_GET_FM_FWD_PEND(dda)) { - DDA_CLR_FM_FWD_PEND(dda); - DDA_CLR_FM_NEEDED(dda); - } - if ((flag & FWRITE) && - DDA_GET_FM_NEEDED(dda) && - DDA_GET_READ_ONLY(dda) == 0) { - err = dda_tape_wfm(dda, 1); - } else { - dda->dda_resid = 0; - } - dda->dda_pid = 0; - /* only reset record size at bot for bsb no rewind */ - if (DDA_IS_BOT(dda)) { - dda->dda_rec_size = 0; - dda->dda_ili = 0; - } - mutex_exit(&dda->dda_mutex); - return (err); -} - -/* - * dda_read - * - * Parameters: - * - dev: Device structure. - * - uio: Vector I/O operations. - * - credp: User credentials. - * - * Globals: - * - dda_state: List of DDA emulated tape drives. - * - * Get drive structure. - * Lock drive to ensure sequential access. - * Call tape read function. - * Unlock drive. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_read(dev_t dev, struct uio *uio, cred_t *credp) -{ - int instance = getminor(dev); - dda_t *dda; - int err; - - if ((dda = ddi_get_soft_state(dda_state, instance)) == NULL) { - return (ENXIO); - } - mutex_enter(&dda->dda_mutex); - dda->dda_cred = credp; - err = dda_tape_read(dda, uio); - mutex_exit(&dda->dda_mutex); - return (err); -} - -/* - * dda_write - * - * Parameters: - * - dev: Device structure. - * - uio: Vector I/O operations. - * - credp: User credentials. - * - * Globals: - * - dda_state: List of DDA emulated tape drives. - * - * Get drive structure. - * Lock drive to ensure sequential access. - * Call tape write function. - * Unlock drive. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_write(dev_t dev, struct uio *uio, cred_t *credp) -{ - int instance = getminor(dev); - dda_t *dda; - int err; - - if ((dda = ddi_get_soft_state(dda_state, instance)) == NULL) { - return (ENXIO); - } - mutex_enter(&dda->dda_mutex); - dda->dda_cred = credp; - err = dda_tape_write(dda, uio); - mutex_exit(&dda->dda_mutex); - return (err); -} - -/* - * dda_ioctl - * - * Parameters: - * - dev: Device structure. - * - cmd: DDA or MTIO command. - * - flag: User data model. - * - credp: User credentials. - * - rvalp: Return error number. - * - * Globals: - * - dda_state: List of DDA emulated tape drives. - * - * Interface to execute DDA commands and selected MTIO commands. - * - * The DDA commands perform operations normally handled by a real tape - * drive such as load, capacity, write protect tab, read block limits, - * loaded cartridge pcl. - * - * MTIO commands support unload, motion, write filemark, erase, drive status, - * drive type, record size, and setting incorrect length indicator. - * - * Get drive structure. - * Determine command to execute. - * Lock drive to ensure sequential access. - * Call function to emulate MTIO functionality. - * Unlock drive. - * - * Return Values: - * Cartridge write protect command: - * 0 : read only - * -1 : read write - * - * All other commands: - * 0 : success - * errno : failure - * - * Note: - * DDA emulates BSD no-rewind behavior. - * - */ -/*ARGSUSED5*/ -static int -dda_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *credp, int *rvalp) -{ - int instance = getminor(dev); - dda_t *dda; - int tmp; - char *path; - int err = 0; - - - if ((dda = ddi_get_soft_state(dda_state, instance)) == NULL) { - return (ENXIO); - } - - switch (cmd) { - case DDA_CMD_LOAD: { - path = kmem_alloc(PATH_MAX, KM_SLEEP); - if (ddi_copyin((void *)arg, path, PATH_MAX, flag)) { - err = EFAULT; - } else { - mutex_enter(&dda->dda_mutex); - dda->dda_cred = credp; - err = dda_tape_load(dda, path); - mutex_exit(&dda->dda_mutex); - } - kmem_free(path, PATH_MAX); - return (err); - } - case DDA_CMD_NAME: { - mutex_enter(&dda->dda_mutex); - if (!dda->dda_loaded) { - mutex_exit(&dda->dda_mutex); - return (EIO); - } - path = kmem_alloc(PATH_MAX, KM_SLEEP); - (void) snprintf(path, PATH_MAX, "%s", dda->dda_path); - mutex_exit(&dda->dda_mutex); - if (ddi_copyout(path, (void *)arg, PATH_MAX, flag)) { - err = EFAULT; - } - kmem_free(path, PATH_MAX); - return (err); - } - case DDA_CMD_CAPACITY: { - dda_capacity_t capacity; - - mutex_enter(&dda->dda_mutex); - dda->dda_cred = credp; - if (!dda->dda_loaded) { - mutex_exit(&dda->dda_mutex); - return (EIO); - } - dda->dda_resid = 0; - capacity.dda_capacity = dda->dda_metadata.dda_capacity; - if (err = dda_tape_capacity(dda, &capacity.dda_space)) { - mutex_exit(&dda->dda_mutex); - return (err); - } - mutex_exit(&dda->dda_mutex); - if (ddi_copyout(&capacity, (void *)arg, - sizeof (dda_capacity_t), flag)) { - return (EFAULT); - } - return (0); - } - case DDA_CMD_WPROTECT: { - mutex_enter(&dda->dda_mutex); - if (!dda->dda_loaded) { - mutex_exit(&dda->dda_mutex); - return (EIO); - } - dda->dda_resid = 0; - if (DDA_GET_WPROTECT(dda) != 0) { - mutex_exit(&dda->dda_mutex); - /* write protect tab on */ - return (0); - } - mutex_exit(&dda->dda_mutex); - /* write protect tab off */ - return (-1); - } - case DDA_CMD_BLKLMT: { - dda_blklmt_t blklmt; - - blklmt.dda_blkmax = DDA_MAX_REC_SIZE; - blklmt.dda_blkmin = 1; - - mutex_enter(&dda->dda_mutex); - dda->dda_resid = 0; - mutex_exit(&dda->dda_mutex); - - if (ddi_copyout(&blklmt, (void *)arg, - sizeof (dda_blklmt_t), flag)) { - return (EFAULT); - } - return (0); - } - case USCSICMD: { - return (ENOTTY); - } - case MTIOCGETPOS: { - tapepos_t pos; - int64_t blkno; - - mutex_enter(&dda->dda_mutex); - dda->dda_cred = credp; - if (!dda->dda_loaded) { - mutex_exit(&dda->dda_mutex); - return (EIO); - } - dda->dda_resid = 0; - - bzero(&pos, sizeof (tapepos_t)); - pos.lgclblkno = DDA_LBA(dda); - pos.fileno = dda_get_fileno(dda); - (void) dda_get_blkno(dda, &blkno); - pos.blkno = (UINT32_MAX & blkno); - pos.pmode = logical; - - mutex_exit(&dda->dda_mutex); - if (ddi_copyout(&pos, (void *)arg, - sizeof (tapepos_t), flag)) { - return (EFAULT); - } - return (0); - } - case MTIOCRESTPOS: { - tapepos_t pos; - - if (ddi_copyin((void *)arg, &pos, - sizeof (tapepos_t), flag)) { - return (EFAULT); - } - mutex_enter(&dda->dda_mutex); - dda->dda_cred = credp; - if (!dda->dda_loaded) { - mutex_exit(&dda->dda_mutex); - return (EIO); - } - if (pos.pmode != logical) { - mutex_exit(&dda->dda_mutex); - return (EINVAL); - } - err = dda_tape_locate(dda, pos.lgclblkno); - mutex_exit(&dda->dda_mutex); - return (err); - } - case MTIOCLTOP: { - struct mtlop local; - int rval; - - if (ddi_copyin((void *)arg, &local, sizeof (local), flag)) { - return (EFAULT); - } - - mutex_enter(&dda->dda_mutex); - dda->dda_cred = credp; - rval = dda_tape_op(dda, &local); - mutex_exit(&dda->dda_mutex); - - if (ddi_copyout(&local, (void *)arg, sizeof (local), flag)) { - rval = EFAULT; - } - return (rval); - } - case MTIOCTOP: { -#ifdef _MULTI_DATAMODEL - /* - * For use when a 32 bit app makes a call into a - * 64 bit ioctl - */ - struct mtop32 mtop_32_for_64; -#endif /* _MULTI_DATAMODEL */ - struct mtop passed; - struct mtlop local; - int rval = 0; - -#ifdef _MULTI_DATAMODEL - switch (ddi_model_convert_from(flag & FMODELS)) { - case DDI_MODEL_ILP32: - if (ddi_copyin((void *)arg, &mtop_32_for_64, - sizeof (struct mtop32), flag)) { - return (EFAULT); - } - local.mt_op = mtop_32_for_64.mt_op; - local.mt_count = (int64_t)mtop_32_for_64.mt_count; - break; - - case DDI_MODEL_NONE: - if (ddi_copyin((void *)arg, &passed, - sizeof (passed), flag)) { - return (EFAULT); - } - local.mt_op = passed.mt_op; - /* prevent sign extension */ - local.mt_count = (UINT32_MAX & passed.mt_count); - break; - } - -#else /* ! _MULTI_DATAMODEL */ - if (ddi_copyin((void *)arg, &passed, sizeof (passed), flag)) { - return (EFAULT); - } - local.mt_op = passed.mt_op; - /* prevent sign extension */ - local.mt_count = (UINT32_MAX & passed.mt_count); -#endif /* _MULTI_DATAMODEL */ - - mutex_enter(&dda->dda_mutex); - dda->dda_cred = credp; - rval = dda_tape_op(dda, &local); - mutex_exit(&dda->dda_mutex); - -#ifdef _MULTI_DATAMODEL - switch (ddi_model_convert_from(flag & FMODELS)) { - case DDI_MODEL_ILP32: - if (((uint64_t)local.mt_count) > UINT32_MAX) { - rval = ERANGE; - break; - } - /* - * Convert 64 bit back to 32 bit before doing - * copyout. This is what the ILP32 app expects. - */ - mtop_32_for_64.mt_op = local.mt_op; - mtop_32_for_64.mt_count = (daddr32_t)local.mt_count; - - if (ddi_copyout(&mtop_32_for_64, (void *)arg, - sizeof (struct mtop32), flag)) { - rval = EFAULT; - } - break; - - case DDI_MODEL_NONE: - passed.mt_count = local.mt_count; - passed.mt_op = local.mt_op; - if (ddi_copyout(&passed, (void *)arg, - sizeof (passed), flag)) { - rval = EFAULT; - } - break; - } -#else /* ! _MULTI_DATAMODE */ - if (((uint64_t)local.mt_count) > UINT32_MAX) { - rval = ERANGE; - } else { - passed.mt_op = local.mt_op; - passed.mt_count = (daddr32_t)local.mt_count; - if (ddi_copyout(&passed, (void *)arg, - sizeof (passed), flag)) { - rval = EFAULT; - } - } -#endif /* _MULTI_DATAMODE */ - return (rval); - } - case MTIOCGET: { -#ifdef _MULTI_DATAMODEL - struct mtget32 mtg_local32; - struct mtget32 *mtget_32 = &mtg_local32; -#endif /* _MULTI_DATAMODEL */ - struct mtget mtg_local; - struct mtget *mtget = &mtg_local; - - bzero(mtget, sizeof (struct mtget)); - mutex_enter(&dda->dda_mutex); - dda->dda_cred = credp; - if (!dda->dda_loaded) { - mtget->mt_erreg = KEY_NOT_READY; - mtget->mt_resid = 0; - mtget->mt_fileno = -1; - mtget->mt_blkno = 0; - } else { - mtget->mt_erreg = dda->dda_status; - mtget->mt_resid = dda->dda_resid; - mtget->mt_fileno = dda_get_fileno(dda); - mtget->mt_blkno = dda->dda_blkno; - } - mtget->mt_type = MT_ISOTHER; - mtget->mt_flags = MTF_SCSI /* | MTF_ASF */; - mtget->mt_bf = 1; - - dda->dda_status = 0; - dda->dda_resid = 0; - tmp = sizeof (struct mtget); - - DDA_CLR_FM_NEEDED(dda); - DDA_DEBUG3((dda_cmd_status, - int, dda->dda_inst, - short, mtget->mt_erreg, - int32_t, mtget->mt_resid)); - mutex_exit(&dda->dda_mutex); - -#ifdef _MULTI_DATAMODEL - switch (ddi_model_convert_from(flag & FMODELS)) { - case DDI_MODEL_ILP32: - mtget_32->mt_erreg = mtget->mt_erreg; - mtget_32->mt_resid = mtget->mt_resid; - mtget_32->mt_dsreg = mtget->mt_dsreg; - mtget_32->mt_fileno = (daddr32_t)mtget->mt_fileno; - mtget_32->mt_blkno = (daddr32_t)mtget->mt_blkno; - mtget_32->mt_type = mtget->mt_type; - mtget_32->mt_flags = mtget->mt_flags; - mtget_32->mt_bf = mtget->mt_bf; - - if (ddi_copyout(mtget_32, (void *)arg, - sizeof (struct mtget32), flag)) { - return (EFAULT); - } - break; - case DDI_MODEL_NONE: - if (ddi_copyout(mtget, (void *)arg, tmp, flag)) { - return (EFAULT); - } - break; - } -#else /* ! _MULTI_DATAMODE */ - if (ddi_copyout(mtget, (void *)arg, tmp, flag)) { - return (EFAULT); - } -#endif /* _MULTI_DATAMODE */ - - return (0); - } - case MTIOCGETDRIVETYPE: { -#ifdef _MULTI_DATAMODEL - struct mtdrivetype_request32 mtdtrq32; -#endif /* _MULTI_DATAMODEL */ - struct mtdrivetype_request mtdtrq; - struct mtdrivetype mtdrtyp; - struct mtdrivetype *mtdt = &mtdrtyp; - -#ifdef _MULTI_DATAMODEL - switch (ddi_model_convert_from(flag & FMODELS)) { - case DDI_MODEL_ILP32: - { - if (ddi_copyin((void *)arg, &mtdtrq32, - sizeof (struct mtdrivetype_request32), flag)) { - return (EFAULT); - } - mtdtrq.size = mtdtrq32.size; - mtdtrq.mtdtp = - (struct mtdrivetype *)(uintptr_t)mtdtrq32.mtdtp; - break; - } - case DDI_MODEL_NONE: - if (ddi_copyin((void *)arg, &mtdtrq, - sizeof (struct mtdrivetype_request), flag)) { - return (EFAULT); - } - break; - } -#else /* ! _MULTI_DATAMODEL */ - if (ddi_copyin((void *)arg, &mtdtrq, - sizeof (struct mtdrivetype_request), flag)) { - return (EFAULT); - } -#endif /* _MULTI_DATAMODEL */ - - if (mtdtrq.size < 0) { - return (EINVAL); - } - bzero(mtdt, sizeof (struct mtdrivetype)); - (void) strncpy(mtdt->name, DDA_ST_NAME, ST_NAMESIZE); - (void) strncpy(mtdt->vid, DDA_VID, VIDPIDLEN); - mtdt->type = MT_ISOTHER; - mtdt->bsize = 0; - mtdt->options = ST_VARIABLE | - ST_READ_IGNORE_ILI | - ST_BSF | - ST_BSR | - ST_KNOWS_EOD | - ST_UNLOADABLE | - ST_NO_RESERVE_RELEASE; - tmp = sizeof (struct mtdrivetype); - if (mtdtrq.size < tmp) - tmp = mtdtrq.size; - if (ddi_copyout(mtdt, mtdtrq.mtdtp, tmp, flag)) { - return (EFAULT); - } - mutex_enter(&dda->dda_mutex); - DDA_CLR_FM_NEEDED(dda); - mutex_exit(&dda->dda_mutex); - return (0); - } - case MTIOCREADIGNOREILI: { - int set_ili; - - if (ddi_copyin((void *)arg, &set_ili, - sizeof (set_ili), flag)) { - return (EFAULT); - } - - mutex_enter(&dda->dda_mutex); - if (!dda->dda_loaded) { - mutex_exit(&dda->dda_mutex); - return (EIO); - } - if (dda->dda_rec_size) { - mutex_exit(&dda->dda_mutex); - return (ENOTTY); - } - if (set_ili != 0 && set_ili != 1) { - mutex_exit(&dda->dda_mutex); - return (EINVAL); - } - dda->dda_ili = set_ili; - DDA_DEBUG2((dda_cmd_ili, - int, dda->dda_inst, - int, dda->dda_ili)); - DDA_CLR_FM_NEEDED(dda); - mutex_exit(&dda->dda_mutex); - return (0); - } - - } /* switch end */ - - return (ENOTTY); -} - -/* tape operations */ - -/* - * dda_tape_op - * - * Parameters: - * - dda: DDA tape drive. - * - mtop: Magnetic tape operation structure. - * - * Perform the MTIO command by calling the appropriate DDA function. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_tape_op(dda_t *dda, struct mtlop *mtop) -{ - int err; - - switch (mtop->mt_op) { - case MTTELL: - if (!dda->dda_loaded) { - return (EIO); - } - mtop->mt_count = DDA_LBA(dda); - return (0); - case MTSEEK: { - int64_t lba; - - if (!dda->dda_loaded) { - return (EIO); - } - if (err = dda_tape_locate(dda, mtop->mt_count)) { - lba = DDA_LBA(dda); - } - if (err && mtop->mt_count != lba) { - /* turn seek into tell command */ - mtop->mt_op = MTTELL; - mtop->mt_count = lba; - } - return (err); - } - case MTWEOF: - if (mtop->mt_count < 0) { - return (EINVAL); - } - err = dda_tape_wfm(dda, mtop->mt_count); - return (err); - case MTFSF: - err = dda_tape_fsf(dda, mtop->mt_count); - return (err); - case MTBSF: - err = dda_tape_bsf(dda, mtop->mt_count); - return (err); - case MTFSR: - err = dda_tape_fsr(dda, mtop->mt_count); - return (err); - case MTBSR: - err = dda_tape_bsr(dda, mtop->mt_count); - return (err); - case MTRETEN: - case MTREW: - err = dda_tape_rewind(dda); - return (err); - case MTNOP: - DDA_DEBUG3((dda_cmd_nop, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int64_t, dda_get_fileno(dda))); - return (0); - case MTERASE: - err = dda_tape_erase(dda); - return (err); - case MTEOM: - err = dda_tape_eom(dda); - return (err); - case MTOFFL: - err = dda_tape_unload(dda); - return (err); - case MTSRSZ: - if (mtop->mt_count < 0) { - return (EINVAL); - } - if (mtop->mt_count > DDA_MAX_REC_SIZE) { - return (EINVAL); - } - if (!dda->dda_loaded) { - return (EIO); - } - dda->dda_rec_size = mtop->mt_count; - - if (dda->dda_rec_size) { - dda->dda_ili = 0; - } - - DDA_DEBUG3((dda_cmd_srsz, - int, dda->dda_inst, - int32_t, dda->dda_rec_size, - int, dda->dda_ili)); - DDA_CLR_FM_NEEDED(dda); - return (0); - case MTGRSZ: - if (!dda->dda_loaded) { - return (EIO); - } - mtop->mt_count = dda->dda_rec_size; - DDA_DEBUG3((dda_cmd_grsz, - int, dda->dda_inst, - int32_t, dda->dda_rec_size, - int, dda->dda_ili)); - return (0); - } - return (ENOTTY); -} - -/* - * dda_tape_load - * - * Parameters: - * - dda: DDA tape drive. - * - path: DDA media directory. - * - * If the drive is already loaded and the path is different then - * reject the load command and return. - * If the drive is already loaded and the path is the same then - * accept the load command and return. - * If not loaded open the DDA media files. - * If write protect tab is set read only. - * Calculate data file offset to early warning. - * Set unit attention status. - * Set truncate need flag since the media is at BOT. - * DDA media is now loaded and ready for access. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_tape_load(dda_t *dda, char *path) -{ - char *fname; - int err; - short status; - - - dda->dda_status = 0; - dda->dda_resid = 0; - if (dda->dda_loaded) { - if (strcmp(dda->dda_path, path) != 0) { - cmn_err(CE_CONT, - "%d loaded already %s", - dda->dda_inst, dda->dda_path); - - DDA_DEBUG2((dda_cmd_loaded_already, - int, dda->dda_inst, - char *, dda->dda_path)); - - dda->dda_status = KEY_ILLEGAL_REQUEST; - return (EIO); - } - cmn_err(CE_CONT, - "%d load resume %s", - dda->dda_inst, dda->dda_path); - - DDA_DEBUG2((dda_cmd_load_resume, - int, dda->dda_inst, - char *, dda->dda_path)); - - return (0); - } - - fname = kmem_alloc(PATH_MAX, KM_SLEEP); - - /* reset media data, the drive data is not reset */ - bzero(dda, offsetof(dda_t, dda_inst)); - (void) snprintf(dda->dda_path, PATH_MAX, "%s", path); - - (void) snprintf(fname, PATH_MAX, "%s/%s", dda->dda_path, - DDA_METADATA_FNAME); - if (err = dda_vn_open(dda, &dda->dda_metadata_vp, fname)) { - goto load_error; - } - if (err = dda_vn_lock(dda, dda->dda_metadata_vp, F_WRLCK)) { - goto load_error; - } - if (err = dda_vn_read(dda, dda->dda_metadata_vp, &dda->dda_metadata, - sizeof (dda_metadata_t), 0)) { - goto load_error; - } - DDA_BE_METADATA(dda->dda_metadata, dda->dda_metadata); - - (void) snprintf(fname, PATH_MAX, "%s/%s", dda->dda_path, - DDA_INDEX_FNAME); - if (err = dda_vn_open(dda, &dda->dda_index_vp, fname)) { - goto load_error; - } - if (err = dda_vn_size(dda, dda->dda_index_vp, &dda->dda_index_fsize)) { - goto load_error; - } - if (err = dda_read_index(dda)) { - goto load_error; - } - - (void) snprintf(fname, PATH_MAX, "%s/%s", dda->dda_path, - DDA_DATA_FNAME); - if (err = dda_vn_open(dda, &dda->dda_data_vp, fname)) { - goto load_error; - } - if (err = dda_vn_size(dda, dda->dda_data_vp, &dda->dda_data_fsize)) { - goto load_error; - } - - /* non-floating point early warning to eom percentage calculation */ - dda->dda_early_warn = - (dda->dda_metadata.dda_capacity / 100) * DDA_EARLY_WARN; - if (dda->dda_early_warn < DDA_MAX_REC_SIZE) { - dda->dda_early_warn = DDA_MAX_REC_SIZE; - if (dda->dda_early_warn > dda->dda_metadata.dda_capacity) { - dda->dda_early_warn = dda->dda_metadata.dda_capacity; - } - } - - /* set media loaded */ - dda->dda_status = KEY_UNIT_ATTENTION; - dda->dda_loaded = 1; - DDA_SET_TRUNC(dda); - - cmn_err(CE_CONT, "%d loaded %s", - dda->dda_inst, dda->dda_path); - - DDA_DEBUG2((dda_cmd_load, - int, dda->dda_inst, - char *, path)); - - kmem_free(fname, PATH_MAX); - return (0); - -load_error: - cmn_err(CE_WARN, "%d load %s error %d", - dda->dda_inst, dda->dda_path, err); - - DDA_DEBUG3((dda_cmd_load_err, - int, dda->dda_inst, - char *, path, - int, err)); - - /* cleanup */ - status = dda->dda_status; - if (dda->dda_index_vp) { - (void) dda_vn_close(dda, &dda->dda_index_vp); - } - if (dda->dda_data_vp) { - (void) dda_vn_close(dda, &dda->dda_data_vp); - } - if (dda->dda_metadata_vp) { - (void) dda_vn_lock(dda, dda->dda_metadata_vp, F_UNLCK); - (void) dda_vn_close(dda, &dda->dda_metadata_vp); - } - dda_set_unloaded(dda); - dda->dda_status = status; - kmem_free(fname, PATH_MAX); - return (err); -} - -/* - * dda_tape_unload - * - * Parameters: - * - dda: DDA tape drive. - * - * Write filemark if needed to emulate st bsd mode. - * Unload media from the drive. - * Report first error encounter. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_tape_unload(dda_t *dda) -{ - int rc; - int err = 0; - short status; - - - /* - * Close all files, report first error - */ - - if (!dda->dda_loaded) { - return (EIO); - } - - dda->dda_status = 0; - dda->dda_resid = 0; - - if (err = dda_write_index(dda)) { - status = dda->dda_status; - } - - if (DDA_GET_FM_NEEDED(dda)) { - if (rc = dda_tape_wfm(dda, 1)) { - if (err == 0) { - err = rc; - status = dda->dda_status; - } - } - } - - if (rc = dda_vn_close(dda, &dda->dda_index_vp)) { - if (err == 0) { - err = rc; - status = dda->dda_status; - } - } - - if (rc = dda_vn_close(dda, &dda->dda_data_vp)) { - if (err == 0) { - err = rc; - status = dda->dda_status; - } - } - - (void) dda_vn_lock(dda, dda->dda_metadata_vp, F_UNLCK); - if (rc = dda_vn_close(dda, &dda->dda_metadata_vp)) { - if (err == 0) { - err = rc; - status = dda->dda_status; - } - } - - dda->dda_status = status; - - if (err == 0) { - cmn_err(CE_CONT, "%d unloaded %s", - dda->dda_inst, dda->dda_path); - - DDA_DEBUG2((dda_cmd_unload, - int, dda->dda_inst, - char *, dda->dda_path)); - } else { - cmn_err(CE_WARN, "%d unloaded %s with error %d", - dda->dda_inst, dda->dda_path, err); - - DDA_DEBUG3((dda_cmd_unload_err, - int, dda->dda_inst, - char *, dda->dda_path, - int, err)); - } - - dda_set_unloaded(dda); - return (err); -} - -/* support routines */ - -/* - * dda_set_unloaded - * - * Parameters: - * - dda: DDA tape drive. - * - * Set DDA drive unloaded. - * Zero DDA media structure members. - * Set fileno to -1 for status. - * - * Return Values: - * None - * - */ -static void -dda_set_unloaded(dda_t *dda) -{ - bzero(dda, offsetof(dda_t, dda_inst)); - dda->dda_index.dda_fileno = -1; - dda->dda_loaded = 0; -} - -/* - * dda_get_fileno - * - * Parameters: - * - dda: DDA tape drive. - * - * Get DDA media fileno based on st bsd behavior. - * - * Return Values: - * fileno : filemark number - * - */ -static int64_t -dda_get_fileno(dda_t *dda) -{ - int64_t fileno; - - fileno = dda->dda_index.dda_fileno; - if (dda->dda_pos > dda->dda_index.dda_blkcount) { - fileno += (dda->dda_pos - dda->dda_index.dda_blkcount); - } - - if (DDA_GET_FM_FWD_PEND(dda)) { - if (DDA_GET_FM_NOSKIP(dda)) { - fileno--; - } - } - - return (fileno); -} - -/* - * dda_get_blkno - * - * Parameters: - * - dda: DDA tape drive. - * - * Get DDA media blkno. - * If positioned at filemark then the blkno is 0. - * Otherwise backup until bot or filemark is encountered. - * - * Return Values: - * fileno : filemark number - * - */ -static int -dda_get_blkno(dda_t *dda, int64_t *blkno) -{ - dda_istate_t istate; - int err = 0; - - if (dda->dda_pos > dda->dda_index.dda_blkcount) { - *blkno = 0; - return (0); - } - dda_save_istate(dda, &istate); - *blkno = dda->dda_pos; - dda->dda_index_offset -= sizeof (dda_index_t); - while (dda->dda_index_offset >= 0) { - if (err = dda_read_index(dda)) { - break; - } - if (dda->dda_index.dda_fmcount) { - break; - } - *blkno += dda->dda_index.dda_blkcount; - dda->dda_index_offset -= sizeof (dda_index_t); - } - dda_restore_istate(dda, &istate); - return (err); -} - -/* - * dda_write_truncate - * - * Parameters: - * - dda: DDA tape drive. - * - * Truncate DDA media at the current position. - * If at bot then stripe align the data file offset. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_write_truncate(dda_t *dda) -{ - int err; - - dda->dda_flags = 0; - - if (DDA_IS_BOT(dda)) { - bzero(&dda->dda_index, sizeof (dda_index_t)); - DDA_SET_INDEX(dda); - } - - if (dda->dda_pos != DDA_INDEX_COUNT(dda)) { - DDA_SET_INDEX(dda); - if (dda->dda_pos <= dda->dda_index.dda_blkcount) { - dda->dda_index.dda_fmcount = 0; - dda->dda_index.dda_blkcount = dda->dda_pos; - } else { - dda->dda_index.dda_fmcount = - dda->dda_pos - dda->dda_index.dda_blkcount; - } - - if (DDA_INDEX_COUNT(dda) == 0) { - dda->dda_index_offset -= sizeof (dda_index_t); - if (dda->dda_index_offset < 0) { - bzero(&dda->dda_index, sizeof (dda_index_t)); - dda->dda_index_offset = 0; - dda->dda_pos = 0; - } else { - if (err = dda_read_index(dda)) { - return (err); - } - dda->dda_pos = DDA_INDEX_COUNT(dda); - } - } - } - - if (err = dda_write_index(dda)) { - dda->dda_status = KEY_MEDIUM_ERROR; - return (err); - } - - dda->dda_index_fsize = dda->dda_index_offset + sizeof (dda_index_t); - if (err = dda_vn_truncate(dda, dda->dda_index_vp, - dda->dda_index_fsize)) { - return (err); - } - - dda->dda_data_fsize = dda_data_offset(dda); - if (err = dda_vn_truncate(dda, dda->dda_data_vp, - dda->dda_data_fsize)) { - return (err); - } - - if (DDA_IS_BOT(dda)) { - dda->dda_index.dda_offset += dda_stripe_align(dda); - } - - return (0); -} - -/* - * dda_tape_erase - * - * Parameters: - * - dda: DDA tape drive. - * - * Erase DDA media from the current position. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_tape_erase(dda_t *dda) -{ - int err; - - - if (!dda->dda_loaded) { - return (EIO); - } - - dda->dda_status = 0; - dda->dda_resid = 0; - - if (DDA_GET_READ_ONLY(dda)) { - dda->dda_status = KEY_WRITE_PROTECT; - return (EACCES); - } - - /* - * Erase from current logical position - */ - DDA_DEBUG2((dda_cmd_erase, - int, dda->dda_inst, - int64_t, DDA_LBA(dda))); - - if (err = dda_write_truncate(dda)) { - DDA_DEBUG2((dda_cmd_erase_err, - int, dda->dda_inst, - int, err)); - } - return (err); -} - -/* - * dda_sync - * - * Parameters: - * - dda: DDA tape drive. - * - * Flush DDA media files to disk. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_sync(dda_t *dda) -{ - int err; - int rc; - short status; - - /* - * Sync index and data files, report first error - */ - - err = dda_vn_sync(dda, dda->dda_index_vp); - status = dda->dda_status; - - if (rc = dda_vn_sync(dda, dda->dda_data_vp)) { - if (err == 0) { - status = dda->dda_status; - err = rc; - } - } - - dda->dda_status = status; - return (err); -} - -/* - * dda_tape_wfm - * - * Parameters: - * - dda: DDA tape drive. - * - count: Number of filemarks to write. - * - * If zero filemarks then flush media to disk and return. - * Truncate DDA media if needed. - * If at physical end of media and no filemarks can be - * written then set status and return. - * Write the number of filemarks requested. - * Update position on media. - * Set residual for the number of filemarks not written. - * Flush DDA media to disk. - * - * Return Values: - * 0 : success - * errno : failure - * - * Note: - * A filemark is counted as 1 byte of used tape space. - */ -static int -dda_tape_wfm(dda_t *dda, int count) -{ - int err; - int64_t avail; - int ew; - - if (!dda->dda_loaded) { - return (EIO); - } - dda->dda_status = 0; - dda->dda_resid = count; - - if (DDA_GET_READ_ONLY(dda)) { - dda->dda_status = KEY_WRITE_PROTECT; - return (EACCES); - } - - DDA_DEBUG3((dda_cmd_wfm, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int, count)); - - if (count == 0) { - if (err = dda_write_index(dda)) { - return (err); - } - err = dda_sync(dda); - return (err); - } - - if (DDA_GET_TRUNC(dda) && (err = dda_write_truncate(dda))) { - return (err); - } - - if (err = dda_ew_eom(dda, count, &avail, &ew)) { - return (err); - } - - if (avail == 0) { - /* - * Physical end of media. - */ - DDA_DEBUG2((dda_cmd_wfm_eom, - int, dda->dda_inst, - int64_t, DDA_LBA(dda))); - dda->dda_status = SUN_KEY_EOT; - return (EIO); - } - - DDA_SET_INDEX(dda); - dda->dda_index.dda_fmcount += avail; - if (err = dda_write_index(dda)) { - dda->dda_index.dda_fmcount -= avail; - return (err); - } - - dda->dda_resid -= avail; - dda->dda_pos += avail; - dda->dda_blkno = 0; - - if (err = dda_sync(dda)) { - return (err); - } - - DDA_CLR_FM_NEEDED(dda); - - return (0); -} - -/* - * dda_tape_write - * - * Parameters: - * - dda: DDA tape drive. - * - uio: Vector I/O operations. - * - * DDA write supports all write lengths allowed by the kernel. - * - * A variable length write may span two index records when the - * length is not modulus max record size. - * - * A fixed length write requires the data length to be a multiple - * the record size. - * - * If read only media then set write protect status and return. - * If zero length write then return. - * Calculate number of blocks to write based on the record size. - * Truncate media if needed. - * Get early warning and physical end of media. - * Adjust length to write in blocks based on tape space remaining. - * If positioned past early warning then alternating write failures - * occur. - * Get data file offset. - * Write the data to the data file. - * If write error then set status and return errno. - * If write returns residual then adjust counts and truncate - * incomplete blocks. - * Update index record with new media position. - * If write crosses into early warning then set status. - * Write complete. - * - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_tape_write(dda_t *dda, struct uio *uio) -{ - int err; - int32_t len; - int32_t total; - int32_t blksize; - int32_t blkcount; - int64_t avail; - int ew; - int rc; - off64_t data_offset; - int32_t blks; - int64_t offset; - dda_istate_t istate; - int32_t partial = 0; - - if (!dda->dda_loaded) { - return (EIO); - } - dda->dda_status = 0; - dda->dda_resid = 0; - - if (DDA_GET_READ_ONLY(dda)) { - dda->dda_status = KEY_WRITE_PROTECT; - dda->dda_resid = uio->uio_resid; - return (EACCES); - } - - if ((total = uio->uio_resid) == 0) { - if (err = dda_write_index(dda)) { - return (err); - } - return (0); - } - len = total; - - dda_save_istate(dda, &istate); - - if (dda->dda_rec_size == 0) { - /* variable block(s) */ - if (len > DDA_MAX_REC_SIZE) { - /* write may span this index record and next */ - blksize = DDA_MAX_REC_SIZE; - blkcount = len / DDA_MAX_REC_SIZE; - partial = len - (blksize * blkcount); - } else { - /* single block write */ - blksize = len; - blkcount = 1; - } - dda->dda_resid = len; - } else { - /* fixed block(s) */ - if ((len % dda->dda_rec_size) != 0) { - return (EINVAL); - } - blksize = dda->dda_rec_size; - blkcount = (len / dda->dda_rec_size); - dda->dda_resid = blkcount; - } - - DDA_DEBUG4((dda_cmd_write, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int32_t, uio->uio_resid, - int32_t, blkcount)); - - if (DDA_GET_TRUNC(dda) && (err = dda_write_truncate(dda))) { - return (err); - } - - if (err = dda_ew_eom(dda, len, &avail, &ew)) { - return (err); - } - - if (ew) { - /* - * Logical end of media, alternating - * zero byte writes after early warning. - */ - DDA_DEBUG2((dda_cmd_write_ew, - int, dda->dda_inst, - int, DDA_GET_EW(dda))); - if (DDA_GET_EW(dda)) { - DDA_CLR_EW(dda); - dda->dda_status = SUN_KEY_EOT; - if (avail < blksize) { - /* - * Physical end of media hit. - */ - return (EIO); - } - return (0); - } - - /* - * Next early warning write is zero bytes. - */ - DDA_SET_EW(dda); - } - - if (avail < len) { - /* at least one block */ - if (avail < blksize) { - /* - * Physical end of media hit. - */ - DDA_DEBUG2((dda_cmd_write_eom, - int, dda->dda_inst, - int64_t, DDA_LBA(dda))); - dda->dda_status = SUN_KEY_EOT; - return (EIO); - } - - /* adjust counts */ - blkcount = avail / blksize; - len = blkcount * blksize; - if (dda->dda_rec_size == 0) { - partial = 0; - dda->dda_resid = (total - len); - } else { - dda->dda_resid = (total - len) / blksize; - } - } - - if (dda->dda_pos > dda->dda_index.dda_blkcount && - dda->dda_index.dda_fmcount) { - dda_gen_next_index(dda, blksize); - dda->dda_index.dda_offset += dda_stripe_align(dda); - } - - if (blksize != dda->dda_index.dda_blksize) { - if (DDA_IS_BOT(dda)) { - dda->dda_index.dda_blksize = blksize; - } else { - if (err = dda_write_index(dda)) { - goto write_error; - } - dda_gen_next_index(dda, blksize); - } - } - - /* write data */ - data_offset = dda_data_offset(dda); - uio->uio_loffset = data_offset; - uio->uio_resid = len; - (void) VOP_RWLOCK(dda->dda_data_vp, V_WRITELOCK_TRUE, NULL); - err = VOP_WRITE(dda->dda_data_vp, uio, 0, dda->dda_cred, NULL); - VOP_RWUNLOCK(dda->dda_data_vp, V_WRITELOCK_TRUE, NULL); - - if (err) { - DDA_DEBUG4((dda_cmd_write_vn_err, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - off64_t, data_offset, - int, err)); - dda_vn_error_skey(dda, err); - goto write_error; - } - - if (uio->uio_resid) { - if (dda->dda_rec_size == 0) { - partial = 0; - } - - /* remove blocks from data */ - - blks = uio->uio_resid / blksize; - if (uio->uio_resid - (blks * blksize)) { - blks++; - } - blkcount -= blks; - if (blkcount == 0) { - goto write_error; - } - - len = blkcount * blksize; - offset = data_offset + len; - - if (err = dda_vn_truncate(dda, dda->dda_data_vp, offset)) { - goto write_error; - } - } - - /* update index record block count */ - DDA_SET_INDEX(dda); - dda->dda_index.dda_blkcount += blkcount; - dda->dda_pos += blkcount; - dda->dda_blkno += blkcount; - - if (partial) { - if (err = dda_write_index(dda)) { - goto write_error; - } - dda_save_istate(dda, &istate); - dda_gen_next_index(dda, partial); - - /* update new index record with block */ - DDA_SET_INDEX(dda); - dda->dda_index.dda_blkcount = 1; - dda->dda_pos++; - dda->dda_blkno++; - } - - if (total == len) { - dda->dda_resid = 0; - } else { - uio->uio_resid = total - len; - if (dda->dda_rec_size == 0) { - dda->dda_resid = (total - len); - } else { - dda->dda_resid = (total - len) / blksize; - } - - DDA_DEBUG4((dda_cmd_write_done, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int32_t, blkcount, - int32_t, uio->uio_resid)); - } - - if (ew) { - DDA_DEBUG2((dda_cmd_write_ew, - int, dda->dda_inst, - int64_t, DDA_LBA(dda))); - dda->dda_status = SUN_KEY_EOT; - } - - DDA_SET_FM_NEEDED(dda); - - dda->dda_data_fsize += total - uio->uio_resid; - - return (err); - -write_error: - /* no blocks written */ - uio->uio_resid = total; - if (dda->dda_rec_size == 0) { - dda->dda_resid = total; - } else { - dda->dda_resid = total / blksize; - } - dda_restore_istate(dda, &istate); - if (DDA_IS_BOT(dda)) { - dda->dda_index.dda_blksize = 0; - } - DDA_SET_TRUNC(dda); - if (rc = dda_write_truncate(dda)) { - if (err == 0) { - err = rc; - } - } - DDA_DEBUG3((dda_cmd_write_err, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int, err)); - if (err) { - /* original error */ - return (err); - } - return (EIO); -} - -/* - * dda_tape_read - * - * Parameters: - * - dda: DDA tape drive. - * - uio: Vector I/O operations. - * - * DDA read supports all read lengths allowed by the kernel. - * - * A variable length read may span two index records. - * - * The DDA variable length read supports the ILI (incorrect length - * indicator). - * - * A fixed length read requires the data length to be a multiple of - * the record size. - * - * If zero length read then return success. - * Calculate the number of blocks to read based on the record size. - * Get early warning and physical end of media. - * Adjust length (blocks) to read based on tape space remaining. - * Read the data from the data file. - * If a read error occurred or residual from dda's adjusted read length - * then set status and return. - * Update the index record with new media position. - * Read complete. - * - * - * Return Values: - * 0 : success - * errno : failure - * - */ -int -dda_tape_read(dda_t *dda, struct uio *uio) -{ - int32_t len; - int32_t total; - int32_t blksize; - int32_t blkcount; - int err; - off64_t fsize; - dda_istate_t istate; - off64_t data_offset; - int overflow = 0; - int noskip; - int partial = 0; - off64_t offset; - dda_index_t index; - - if (!dda->dda_loaded) { - return (EIO); - } - dda->dda_status = 0; - dda->dda_resid = 0; - DDA_SET_TRUNC(dda); - DDA_CLR_FM_NEEDED(dda); - DDA_CLR_EW(dda); - - if ((total = uio->uio_resid) == 0) { - if (err = dda_write_index(dda)) { - return (err); - } - return (0); - } - len = total; - - dda_save_istate(dda, &istate); - - if (dda->dda_rec_size == 0) { - /* variable */ - if (len > DDA_MAX_REC_SIZE) { - /* read may span this index record and next */ - blksize = DDA_MAX_REC_SIZE; - blkcount = len / DDA_MAX_REC_SIZE; - if (len - (blksize * blkcount)) { - /* actual partial blksize determined below */ - partial = 1; - } - } else { - /* single block read */ - blksize = len; - blkcount = 1; - } - dda->dda_resid = len; - } else { - /* fixed */ - if (dda->dda_ili) { - cmn_err(CE_WARN, "%d Incorrect Length Indicator Set", - dda->dda_inst); - return (EINVAL); - } - if ((len % dda->dda_rec_size) != 0) { - cmn_err(CE_WARN, "%d read: not modulo %d block size", - dda->dda_inst, dda->dda_rec_size); - return (EINVAL); - } - blksize = dda->dda_rec_size; - blkcount = (len / dda->dda_rec_size); - dda->dda_resid = blkcount; - } - - if (err = dda_write_index(dda)) { - return (err); - } - - DDA_DEBUG4((dda_cmd_read, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int32_t, uio->uio_resid, - int32_t, blkcount)); - - if (DDA_GET_FM_FWD_PEND(dda)) { - noskip = DDA_GET_FM_NOSKIP(dda); - DDA_CLR_FM_FWD_PEND(dda); - if (noskip) { - DDA_DEBUG1((dda_cmd_read_ffpns, - int, dda->dda_inst)); - - dda->dda_status = SUN_KEY_EOF; - dda->dda_blkno = 0; - return (0); - } - - DDA_DEBUG1((dda_cmd_read_ffpc, - int, dda->dda_inst)); - } - - fsize = dda->dda_index_fsize - sizeof (dda_index_t); - - if (dda->dda_pos >= DDA_INDEX_COUNT(dda)) { - dda->dda_index_offset += sizeof (dda_index_t); - if (dda->dda_index_offset > fsize) { - - DDA_DEBUG3((dda_cmd_read_eot, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int, DDA_GET_EOT_EIO(dda))); - - dda->dda_index_offset -= sizeof (dda_index_t); - dda->dda_status = SUN_KEY_EOT; - if (DDA_GET_EOT_EIO(dda) == 0) { - DDA_SET_EOT_EIO(dda); - dda->dda_resid = len; - return (EIO); - } - return (0); - } - if (err = dda_read_index(dda)) { - dda_restore_istate(dda, &istate); - return (err); - } - } - - DDA_CLR_EOT_EIO(dda); - - if (DDA_IS_FM(dda)) { - DDA_DEBUG2((dda_cmd_read_fm, - int, dda->dda_inst, - int64_t, DDA_LBA(dda))); - - DDA_SET_FM_FWD_PEND(dda); - dda->dda_pos++; - dda->dda_status = SUN_KEY_EOF; - dda->dda_blkno = 0; - return (0); - } - - if (blksize != dda->dda_index.dda_blksize) { - if (blksize < dda->dda_index.dda_blksize) { - len = blksize; - if (dda->dda_ili == 0) { - overflow = 1; - } - } else { - len = dda->dda_index.dda_blksize; - } - blkcount = 1; - blksize = len; - partial = 0; - - DDA_DEBUG4((dda_cmd_read_blksz, - int, dda->dda_inst, - int64_t, blksize, - int64_t, blkcount, - int, overflow)); - } - - if (dda->dda_pos + blkcount + partial > dda->dda_index.dda_blkcount) { - if (partial) { - /* get partial from next index record */ - offset = dda->dda_index_offset + sizeof (dda_index_t); - if (offset > fsize) { - partial = 0; - } else if (dda_vn_read(dda, dda->dda_index_vp, - &index, sizeof (dda_index_t), offset)) { - partial = 0; - } else { - DDA_BE_INDEX(index, index); - if (index.dda_blkcount == 0) { - partial = 0; - } - } - } - - blkcount = dda->dda_index.dda_blkcount - dda->dda_pos; - if (blkcount == 0) { - if (dda->dda_rec_size == 0) { - dda->dda_resid = total; - } else { - dda->dda_resid = total / blksize; - } - DDA_DEBUG1((dda_cmd_read_noblks, - int, dda->dda_inst)); - return (0); - } - - len = blkcount * blksize; - - if (partial) { - len += index.dda_blksize; - } - - DDA_DEBUG4((dda_cmd_read_numblks, - int, dda->dda_inst, - int32_t, len, - int32_t, blksize, - int32_t, blkcount)); - - } else if (partial) { - /* current index record contains partial */ - len += dda->dda_index.dda_blksize; - } - - if (len > total) { - len = total; - if (dda->dda_ili == 0) { - overflow = 1; - } - } - - DDA_DEBUG2((dda_cmd_read_partial, - int, dda->dda_inst, - int32_t, partial)); - - data_offset = dda_data_offset(dda); - uio->uio_loffset = data_offset; - uio->uio_resid = len; - (void) VOP_RWLOCK(dda->dda_data_vp, V_WRITELOCK_FALSE, NULL); - err = VOP_READ(dda->dda_data_vp, uio, 0, dda->dda_cred, NULL); - VOP_RWUNLOCK(dda->dda_data_vp, V_WRITELOCK_FALSE, NULL); - - /* - * If a read error occurred or residual from dda adjusted length - * then don't return any data. - */ - - if (err) { - DDA_DEBUG4((dda_cmd_read_vn_err, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - off64_t, data_offset, - int, err)); - - dda_restore_istate(dda, &istate); - uio->uio_resid = total; - dda_vn_error_skey(dda, err); - if (dda->dda_rec_size == 0) { - dda->dda_resid = total; - } else { - dda->dda_resid = total / blksize; - } - return (err); - } - - if (uio->uio_resid) { - DDA_DEBUG2((dda_cmd_read_resid, - int, dda->dda_inst, - int32_t, uio->uio_resid)); - - uio->uio_resid = total; - if (dda->dda_rec_size == 0) { - dda->dda_resid = total; - } else { - dda->dda_resid = total / blksize; - } - dda_restore_istate(dda, &istate); - return (EIO); - } - - - /* - * Successful read, adjust index record and counters. - */ - - dda->dda_pos += blkcount; - - if (total == len) { - dda->dda_blkno += blkcount; - dda->dda_resid = 0; - } else { - uio->uio_resid = total - len; - if (dda->dda_rec_size == 0) { - dda->dda_resid = uio->uio_resid; - } else { - dda->dda_resid = uio->uio_resid / blksize; - } - dda->dda_blkno += uio->uio_resid / blksize; - } - - if (partial) { - dda->dda_pos = 1; - dda->dda_blkno++; - dda->dda_index = index; - dda->dda_index_offset += sizeof (dda_index_t); - } - - DDA_DEBUG3((dda_cmd_read_short, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int32_t, dda->dda_resid)); - - if (overflow) { - DDA_DEBUG2((dda_cmd_read_overflow, - int, dda->dda_inst, - int64_t, DDA_LBA(dda))); - dda->dda_resid = 0; - err = ENOMEM; - } - - return (err); -} - -/* - * dda_tape_locate - * - * Parameters: - * - dda: DDA tape drive. - * - position: Locate to LBA. - * - * Locate to LBA requested. - * - * Return Values: - * 0 : success - * errno : failure, positioned at bot or eom - * - */ -static int -dda_tape_locate(dda_t *dda, off64_t position) -{ - int err; - int found; - int64_t lba; - dda_istate_t istate; - int rc; - - - if (!dda->dda_loaded) { - return (EIO); - } - - dda->dda_status = 0; - dda->dda_resid = 0; - - if (err = dda_write_index(dda)) { - return (err); - } - - dda->dda_blkno = 0; - dda->dda_resid = 0; - dda->dda_flags = 0; - DDA_SET_TRUNC(dda); - lba = DDA_LBA(dda); - - DDA_DEBUG3((dda_cmd_locate, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - off64_t, position)); - - dda_save_istate(dda, &istate); - if (err = dda_bsearch(dda, position, dda_locate_compare, &found)) { - DDA_DEBUG2((dda_cmd_locate_err, - int, dda->dda_inst, - int, err)); - dda_restore_istate(dda, &istate); - return (err); - } - - if (!found) { - /* - * Locate unsuccessful, - * position based on direction of search - */ - if (position < lba) { - if (err = dda_tape_rewind(dda)) { - return (err); - } - dda->dda_status = SUN_KEY_BOT; - dda->dda_resid = 0; - } else { - if (err = dda_tape_eom(dda)) { - return (err); - } - dda->dda_status = KEY_BLANK_CHECK; - dda->dda_resid = 0; - } - err = EIO; - } - if (rc = dda_get_blkno(dda, &dda->dda_blkno)) { - err = rc; - } - - DDA_DEBUG4((dda_cmd_locate_done, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int64_t, dda_get_fileno(dda), - int64_t, dda->dda_blkno)); - - return (err); -} - -/* - * dda_tape_fsr - * - * Parameters: - * - dda: DDA tape drive. - * - count: Number of records to forward space. - * - * Forward space records the requested count. - * Set truncate needed for write that may follow. - * Clear filemark forward pending. - * Clear alternating write success at early warning. - * If filemark is hit during fsr then cross the filemark but report - * logical position in front of the filemark to the user. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_tape_fsr(dda_t *dda, int count) -{ - int err; - off64_t fsize; - dda_istate_t istate; - int fm; - int64_t blks; - - - if (!dda->dda_loaded) { - return (EIO); - } - - dda->dda_status = 0; - dda->dda_resid = count; - - if (err = dda_write_index(dda)) { - return (err); - } - - DDA_SET_TRUNC(dda); - DDA_CLR_FM_NEEDED(dda); - DDA_CLR_EW(dda); - - DDA_DEBUG4((dda_cmd_fsr, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int64_t, dda_get_fileno(dda), - int, count)); - - fsize = dda->dda_index_fsize - sizeof (dda_index_t); - - while (dda->dda_resid) { - dda_save_istate(dda, &istate); - - if (DDA_GET_FM_FWD_PEND(dda)) { - dda->dda_status = SUN_KEY_EOF; - return (EIO); - } - - if (dda->dda_pos >= DDA_INDEX_COUNT(dda)) { - dda->dda_index_offset += sizeof (dda_index_t); - if (dda->dda_index_offset > fsize) { - dda_restore_istate(dda, &istate); - dda->dda_status = KEY_BLANK_CHECK; - err = EIO; - break; - } - if (err = dda_read_index(dda)) { - dda_restore_istate(dda, &istate); - DDA_DEBUG2((dda_cmd_fsr_err, - int, dda->dda_inst, - int, err)); - return (err); - } - } - - DDA_DEBUG4((dda_cmd_fsr_where, - int, dda->dda_inst, - int64_t, dda->dda_pos, - int64_t, dda->dda_index.dda_blkcount, - int64_t, dda->dda_index.dda_fmcount)); - - fm = DDA_IS_FM(dda); - if (fm) { - blks = 1; - } else { - blks = dda->dda_index.dda_blkcount - dda->dda_pos; - if (dda->dda_resid <= blks) { - blks = dda->dda_resid; - } - } - - DDA_DEBUG2((dda_cmd_fsr_blks, - int, dda->dda_inst, - int64_t, blks)); - - dda->dda_pos += blks; - dda->dda_blkno += blks; - - if (fm) { - DDA_DEBUG1((dda_cmd_fsr_fm, - int, dda->dda_inst)); - DDA_SET_FM_FWD_PEND(dda); - DDA_SET_FM_NOSKIP(dda); - dda->dda_blkno--; - dda->dda_status = SUN_KEY_EOF; - err = EIO; - break; - } - - dda->dda_resid -= blks; - } - - DDA_DEBUG4((dda_cmd_fsr_done, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int64_t, dda_get_fileno(dda), - int32_t, dda->dda_resid)); - - return (err); -} - -/* - * dda_tape_bsr - * - * Parameters: - * - dda: DDA tape drive. - * - count: Number of records to backward space. - * - * Backspace records the requested count. - * Set truncate needed for write that may follow. - * Clear filemark forward pending. - * Clear alternating write success at early warning. - * If filemark is hit during bsr then do not cross the filemark. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_tape_bsr(dda_t *dda, int count) -{ - int err = 0; - dda_istate_t istate; - int64_t blks; - - - if (!dda->dda_loaded) { - return (EIO); - } - - dda->dda_status = 0; - dda->dda_resid = count; - - if (err = dda_write_index(dda)) { - return (err); - } - - DDA_SET_TRUNC(dda); - DDA_CLR_FM_NEEDED(dda); - DDA_CLR_EW(dda); - - DDA_DEBUG4((dda_cmd_bsr, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int64_t, dda_get_fileno(dda), - int, count)); - - while (dda->dda_resid) { - dda_save_istate(dda, &istate); - - if (DDA_GET_FM_FWD_PEND(dda)) { - DDA_CLR_FM_FWD_PEND(dda); - dda->dda_pos--; - } - - if (dda->dda_pos <= 0) { - dda->dda_index_offset -= sizeof (dda_index_t); - if (dda->dda_index_offset < 0) { - dda_restore_istate(dda, &istate); - dda->dda_status = SUN_KEY_BOT; - err = EIO; - break; - } - if (err = dda_read_index(dda)) { - dda_restore_istate(dda, &istate); - DDA_DEBUG2((dda_cmd_bsr_err, - int, dda->dda_inst, - int, err)); - return (err); - } - dda->dda_pos = DDA_INDEX_COUNT(dda); - } - - DDA_DEBUG4((dda_cmd_bsr_where, - int, dda->dda_inst, - int64_t, dda->dda_pos, - int64_t, dda->dda_index.dda_blkcount, - int64_t, dda->dda_index.dda_fmcount)); - - blks = 0; - if (dda->dda_pos <= dda->dda_index.dda_blkcount) { - blks = dda->dda_pos; - if (dda->dda_resid <= blks) { - blks = dda->dda_resid; - } - } - - DDA_DEBUG2((dda_cmd_bsr_blks, - int, dda->dda_inst, - int64_t, blks)); - - dda->dda_pos -= blks; - dda->dda_blkno -= blks; - - if (DDA_IS_FM(dda)) { - DDA_DEBUG3((dda_cmd_bsr_fm, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int64_t, dda_get_fileno(dda))); - - dda->dda_blkno = 0; - dda->dda_status = SUN_KEY_EOF; - err = EIO; - break; - } - - dda->dda_resid -= blks; - } - - DDA_DEBUG4((dda_cmd_bsr_done, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int64_t, dda_get_fileno(dda), - int32_t, dda->dda_resid)); - - return (err); -} - -/* - * dda_tape_fsf - * - * Parameters: - * - dda: DDA tape drive. - * - count: Number of filemarks to forward space. - * - * Forward space filemarks. - * Set truncate needed for write that may follow. - * Clear filemark forward pending. - * Clear alternating write success at early warning. - * If filemark forward pending then decrement the count. - * Binary search to the filemark. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_tape_fsf(dda_t *dda, int count) -{ - int err; - int found; - dda_istate_t istate; - int64_t fileno; - - - if (!dda->dda_loaded) { - return (EIO); - } - - dda->dda_status = 0; - dda->dda_resid = count; - - if (err = dda_write_index(dda)) { - return (err); - } - - dda->dda_blkno = 0; - DDA_SET_TRUNC(dda); - DDA_CLR_FM_NEEDED(dda); - DDA_CLR_EOT_EIO(dda); - DDA_CLR_EW(dda); - - DDA_DEBUG4((dda_cmd_fsf, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int64_t, dda_get_fileno(dda), - int, count)); - - if (DDA_GET_FM_FWD_PEND(dda)) { - DDA_CLR_FM_FWD_PEND(dda); - count--; - - DDA_DEBUG4((dda_cmd_fsf_pend, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int64_t, dda_get_fileno(dda), - int, count)); - } - - dda_save_istate(dda, &istate); - fileno = dda_get_fileno(dda) + count; - - if (fileno == 0) { - err = dda_tape_rewind(dda); - goto fsf_done; - } - - if (err = dda_bsearch(dda, fileno, dda_fsf_compare, &found)) { - DDA_DEBUG2((dda_cmd_fsf_err, - int, dda->dda_inst, - int, err)); - dda_restore_istate(dda, &istate); - return (err); - } - - if (found) { - /* - * Forward space file successful - */ - dda->dda_resid = 0; - } else { - /* - * Forward space file unsuccessful, - * position based on direction of search - */ - if (count < 0) { - if (err = dda_tape_rewind(dda)) { - return (err); - } - dda->dda_status = SUN_KEY_BOT; - dda->dda_resid = dda_get_fileno(dda) - fileno; - } else { - if (err = dda_tape_eom(dda)) { - return (err); - } - if (err = dda_get_blkno(dda, &dda->dda_blkno)) { - return (err); - } - dda->dda_status = KEY_BLANK_CHECK; - dda->dda_resid = fileno - dda_get_fileno(dda); - } - err = EIO; - } - -fsf_done: - DDA_DEBUG4((dda_cmd_fsf_done, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int64_t, dda_get_fileno(dda), - int32_t, dda->dda_resid)); - - return (err); -} - -/* - * dda_tape_bsf - * - * Parameters: - * - dda: DDA tape drive. - * - count: Number of filemarks to backward space. - * - * Backward space filemarks. - * Zero flags. - * Set truncate needed for write that may follow. - * Binary search to filemark. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_tape_bsf(dda_t *dda, int count) -{ - int err; - int found; - dda_istate_t istate; - int64_t fileno; - int rc; - - - if (!dda->dda_loaded) { - return (EIO); - } - - dda->dda_status = 0; - dda->dda_resid = count; - - if (err = dda_write_index(dda)) { - return (err); - } - - dda->dda_flags = 0; - dda->dda_blkno = DDA_BLKNO_UNKNOWN; - DDA_SET_TRUNC(dda); - fileno = dda_get_fileno(dda) - count; - - DDA_DEBUG4((dda_cmd_bsf, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int64_t, dda_get_fileno(dda), - int, count)); - - dda_save_istate(dda, &istate); - if (err = dda_bsearch(dda, fileno, dda_bsf_compare, &found)) { - DDA_DEBUG2((dda_cmd_bsf_err, - int, dda->dda_inst, - int, err)); - dda_restore_istate(dda, &istate); - return (err); - } - - if (found) { - /* - * Backward space file successful - */ - dda->dda_resid = 0; - } else { - /* - * Backward space file unsuccessful, - * position based on direction of search - */ - if (count < 0) { - if (err = dda_tape_eom(dda)) { - return (err); - } - if (rc = dda_get_blkno(dda, &dda->dda_blkno)) { - err = rc; - } - dda->dda_status = KEY_BLANK_CHECK; - dda->dda_resid = fileno - dda_get_fileno(dda); - } else { - if (err = dda_tape_rewind(dda)) { - return (err); - } - dda->dda_status = SUN_KEY_BOT; - dda->dda_resid = dda_get_fileno(dda) - fileno; - } - err = EIO; - } - - DDA_DEBUG4((dda_cmd_bsf_done, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int64_t, dda_get_fileno(dda), - int32_t, dda->dda_resid)); - - return (err); -} - -/* - * dda_tape_eom - * - * Parameters: - * - dda: DDA tape drive. - * - * Position to end of media. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_tape_eom(dda_t *dda) -{ - off64_t fsize; - int err; - - - if (!dda->dda_loaded) { - return (EIO); - } - - dda->dda_status = 0; - dda->dda_resid = 0; - - if (err = dda_write_index(dda)) { - return (err); - } - - dda->dda_flags = 0; - dda->dda_blkno = 0; - - fsize = dda->dda_index_fsize - sizeof (dda_index_t); - if (fsize < 0) { - DDA_DEBUG2((dda_cmd_eom_err, - int, dda->dda_inst, - int, err)); - dda->dda_status = KEY_MEDIUM_ERROR; - return (EIO); - } - if (dda->dda_index_offset != fsize) { - dda->dda_index_offset = fsize; - if (err = dda_read_index(dda)) { - DDA_DEBUG2((dda_cmd_eom_err, - int, dda->dda_inst, - int, err)); - return (err); - } - } - dda->dda_pos = DDA_INDEX_COUNT(dda); - - DDA_DEBUG4((dda_cmd_eom, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - int64_t, dda_get_fileno(dda), - int64_t, dda->dda_blkno)); - - return (0); -} - -/* - * dda_tape_rewind - * - * Parameters: - * - dda: DDA tape drive. - * - * Position to beginning of media. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_tape_rewind(dda_t *dda) -{ - int err = 0; - - - if (!dda->dda_loaded) { - return (EIO); - } - - dda->dda_status = 0; - dda->dda_resid = 0; - - if (err = dda_write_index(dda)) { - return (err); - } - - if (DDA_GET_FM_NEEDED(dda)) { - if (err = dda_tape_wfm(dda, 1)) { - return (err); - } - } - - dda->dda_flags = 0; - dda->dda_blkno = 0; - DDA_SET_TRUNC(dda); - - dda->dda_index_offset = 0; - if (err = dda_read_index(dda)) { - DDA_DEBUG2((dda_cmd_rewind_err, - int, dda->dda_inst, - int, err)); - return (err); - } - - DDA_DEBUG2((dda_cmd_rewind, - int, dda->dda_inst, - int64_t, DDA_LBA(dda))); - - return (0); -} - -/* index operations */ - -/* - * dda_write_index - * - * Parameters: - * - dda: DDA tape drive. - * - * Write an index record at the index file position. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_write_index(dda_t *dda) -{ - int err; - dda_index_t index; - - if (DDA_GET_INDEX(dda)) { - DDA_CLR_INDEX(dda); - DDA_BE_INDEX(dda->dda_index, index); - if (err = dda_vn_write(dda, dda->dda_index_vp, &index, - sizeof (dda_index_t), dda->dda_index_offset)) { - return (err); - } - dda->dda_index_fsize = dda->dda_index_offset + - sizeof (dda_index_t); - - DDA_DEBUG4((dda_write_index, - int, dda->dda_inst, - int64_t, dda->dda_index.dda_lba, - int64_t, dda->dda_index.dda_fileno, - off64_t, dda->dda_index_offset)); - } - return (0); -} - -/* - * dda_read_index - * - * Parameters: - * - dda: DDA tape drive. - * - * Read an index record from the index file position. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_read_index(dda_t *dda) -{ - int err; - dda_index_t index; - - DDA_CLR_INDEX(dda); - dda->dda_pos = 0; - if (err = dda_vn_read(dda, dda->dda_index_vp, &index, - sizeof (dda_index_t), dda->dda_index_offset)) { - return (err); - } - DDA_BE_INDEX(index, dda->dda_index); - - DDA_DEBUG4((dda_read_index, - int, dda->dda_inst, - int64_t, dda->dda_index.dda_lba, - int64_t, dda->dda_index.dda_fileno, - off64_t, dda->dda_index_offset)); - - return (0); -} - -/* - * dda_gen_next_index - * - * Parameters: - * - dda: DDA tape drive. - * - blksize: Record size for index record. - * - * Generate the next index record with starting positions from the - * end of previous index record. - * Function is called after a change in record size or when data - * follows a filemark. - * - * Return Values: - * None - * - */ -static void -dda_gen_next_index(dda_t *dda, int32_t blksize) -{ - DDA_CLR_INDEX(dda); - dda->dda_index.dda_offset = dda_data_offset(dda); - dda->dda_index.dda_lba += DDA_INDEX_COUNT(dda); - dda->dda_index.dda_fileno += dda->dda_index.dda_fmcount; - dda->dda_index.dda_fmcount = 0; - dda->dda_index.dda_blkcount = 0; - dda->dda_index.dda_blksize = blksize; - dda->dda_index_offset += sizeof (dda_index_t); - dda->dda_pos = 0; - - DDA_DEBUG3((dda_gen_next_index, - int, dda->dda_inst, - int64_t, dda->dda_index.dda_lba, - int64_t, dda->dda_index.dda_fileno)); - -} - -/* - * dda_save_istate - * - * Parameters: - * - dda: DDA tape drive. - * - istate: Index record and index file offset. - * - * Save current index record and position. - * - * Return Values: - * None - * - */ -static void -dda_save_istate(dda_t *dda, dda_istate_t *istate) -{ - istate->dda_index_offset = dda->dda_index_offset; - istate->dda_index = dda->dda_index; - istate->dda_pos = dda->dda_pos; - istate->dda_flags = dda->dda_flags; -} - -/* - * dda_restore_istate - * - * Parameters: - * - dda: DDA tape drive. - * - istate: Index record and index file offset. - * - * Restore saved index record and position. - * - * Return Values: - * None - * - */ -static void -dda_restore_istate(dda_t *dda, dda_istate_t *istate) -{ - dda->dda_index_offset = istate->dda_index_offset; - dda->dda_index = istate->dda_index; - dda->dda_pos = istate->dda_pos; - if (istate->dda_flags & DDA_FLAG_INDEX) { - DDA_SET_INDEX(dda); - } -} - -/* alignment */ - -/* - * dda_stripe_align - * - * Parameters: - * - dda: DDA tape drive. - * - * Align data file offset following after a filemark. - * - * Return Values: - * Aligned data file offset. - * - */ -static off64_t -dda_stripe_align(dda_t *dda) -{ - off64_t amount = 0; - - DDA_DEBUG1((dda_stripe_align_enter, - int, dda->dda_inst)); - - /* - * Called at bot write or when write data follows a file mark. - */ - if (dda->dda_metadata.dda_stripe > 0) { - /* - * Start tape file on stripe boundary - */ - amount = dda->dda_index.dda_offset % - dda->dda_metadata.dda_stripe; - - DDA_DEBUG3((dda_stripe_align_amount, - int, dda->dda_inst, - int32_t, dda->dda_metadata.dda_stripe, - off64_t, amount)); - - if (amount) { - /* - * Stripe adjustment needed. - */ - amount = dda->dda_metadata.dda_stripe - amount; - - DDA_DEBUG3((dda_stripe_align, - int, dda->dda_inst, - int32_t, dda->dda_metadata.dda_stripe, - off64_t, amount)); - } - } - return (amount); -} - -/* - * dda_data_offset - * - * Parameters: - * - dda: DDA tape drive. - * - * Generate data file offset using the index record and - * metadata direct I/O alignment. - * - * Return Values: - * Data file offset. - * - */ -static off64_t -dda_data_offset(dda_t *dda) -{ - off64_t offset; - off64_t amount; - int32_t sector = dda->dda_metadata.dda_sector; - - offset = dda->dda_index.dda_offset; - - DDA_DEBUG2((dda_data_offset_start, - int, dda->dda_inst, - off64_t, offset)); - - if (dda->dda_pos <= dda->dda_index.dda_blkcount) { - - offset += (dda->dda_pos * dda->dda_index.dda_blksize); - - DDA_DEBUG2((dda_data_offset_le, - int, dda->dda_inst, - off64_t, offset)); - - } else { - - offset += (dda->dda_index.dda_blkcount * - dda->dda_index.dda_blksize); - - DDA_DEBUG2((dda_data_offset_gt, - int, dda->dda_inst, - off64_t, offset)); - - } - - if (dda->dda_metadata.dda_sector > 0 && - DDA_LEN_ALIGNED(dda->dda_index.dda_blksize, sector) == 0) { - - /* adjust for direct I/O */ - - amount = DDA_OFF_ALIGNED(offset, sector); - - if (amount) { - - /* bytes needed for sector alignment */ - - amount = sector - amount; - } - - offset += amount; - - DDA_DEBUG3((dda_data_offset_align, - int, dda->dda_inst, - off64_t, offset, - off64_t, amount)); - } - - DDA_DEBUG3((dda_data_offset, - int, dda->dda_inst, - int64_t, DDA_LBA(dda), - off64_t, offset)); - - return (offset); -} - -/* space */ - -/* - * dda_tape_capacity - * - * Parameters: - * - dda: DDA tape drive. - * - space: Amount of space remaining to eom. - * - * The amount of available space remaining to eom is from the last - * data or fm on tape to phyical eom. The position on media does not - * change the space remaining calculation. Filemarks count as 1 byte - * of used capacity. The size of the three media files (metadata, - * index, and data) are also subtracted from the capacity. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_tape_capacity(dda_t *dda, int64_t *space) -{ - int err; - dda_index_t last_index; - off64_t last_index_offset; - off64_t last_index_fileno; - off64_t last_index_fmcount; - - - /* get offset of last index file record */ - last_index_offset = dda->dda_index_fsize - sizeof (dda_index_t); - if (last_index_offset < 0) { - dda->dda_status = KEY_MEDIUM_ERROR; - return (EIO); - } - - /* get total number of filemarks on tape */ - if (dda->dda_index_offset >= last_index_offset) { - /* current or next index record is the last index record */ - last_index_fileno = dda->dda_index.dda_fileno; - last_index_fmcount = dda->dda_index.dda_fmcount; - } else { - /* read last index record */ - if (err = dda_vn_read(dda, dda->dda_index_vp, &last_index, - sizeof (dda_index_t), last_index_offset)) { - return (err); - } - DDA_BE_INDEX(last_index, last_index); - last_index_fileno = last_index.dda_fileno; - last_index_fmcount = last_index.dda_fmcount; - } - - *space = dda->dda_metadata.dda_capacity - /* max cart size minus */ - dda->dda_data_fsize - /* data file size */ - sizeof (dda_metadata_t) - /* metadata file size */ - dda->dda_index_fsize - /* index file size */ - last_index_fileno - /* total num of prev fms */ - last_index_fmcount; /* remaining number of fms */ - - if (*space < 0) { - *space = 0; - } - - DDA_DEBUG3((dda_capacity, - int, dda->dda_inst, - int64_t, dda->dda_metadata.dda_capacity, - int64_t, *space)); - - return (0); -} - -/* - * dda_ew_eom - * - * Parameters: - * - dda: DDA tape drive. - * - count: Bytes to write. - * - avail: Bytes available on media. - * - ew: Early warning. - * - * On return avail contains the number of bytes that can be written - * to the media. The ew flag is set if the write is past early warning. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_ew_eom(dda_t *dda, int32_t count, int64_t *avail, int *ew) -{ - int64_t space; - int err; - int64_t used; - - if (err = dda_tape_capacity(dda, &space)) { - return (err); - } - - used = dda->dda_metadata.dda_capacity - space; - - if (used + count >= dda->dda_early_warn) { - *ew = 1; - } else { - *ew = 0; - } - if (used + count > dda->dda_metadata.dda_capacity) { - *avail = space; - } else { - *avail = count; - } - - DDA_DEBUG4((dda_ew_eom, - int, dda->dda_inst, - int32_t, count, - int64_t, *avail, - int, *ew)); - - return (0); -} - -/* search */ - -/* - * dda_locate_compare - * - * Parameters: - * - dda: DDA tape drive. - * - lba: Locate to LBA. - * - * Locate LBA binary search compare function. - * - * Return Values: - * 0 : found - * 1 : forward - * -1 : backward - * - */ -static int -dda_locate_compare(dda_t *dda, int64_t lba) -{ - int64_t last; - - last = dda->dda_index.dda_lba + DDA_INDEX_COUNT(dda); - - if (lba >= dda->dda_index.dda_lba && lba <= last) { - - dda->dda_pos = lba - dda->dda_index.dda_lba; - - return (0); - } - - if (lba < dda->dda_index.dda_lba) { - return (-1); - } - - return (1); -} - -/* - * dda_fsf_compare - * - * Parameters: - * - dda: DDA tape drive. - * - fileno: Locate file number. - * - * Forward space file binary search compare function. - * - * Return Values: - * 0 : found - * 1 : forward - * -1 : backward - * - */ -static int -dda_fsf_compare(dda_t *dda, int64_t fileno) -{ - int64_t last; - - if (dda->dda_index.dda_fmcount) { - - last = dda->dda_index.dda_fileno + dda->dda_index.dda_fmcount; - - if (fileno > dda->dda_index.dda_fileno && fileno <= last) { - - dda->dda_pos = dda->dda_index.dda_blkcount + - fileno - dda->dda_index.dda_fileno; - - return (0); - } - } - - if (fileno <= dda->dda_index.dda_fileno) { - return (-1); - } - - return (1); -} - -/* - * dda_bsf_compare - * - * Parameters: - * - dda: DDA tape drive. - * - fileno: Locate file number. - * - * Backward space file binary search compare function. - * - * Return Values: - * 0 : found - * 1 : forward - * -1 : backward - * - */ -static int -dda_bsf_compare(dda_t *dda, int64_t fileno) -{ - int64_t last; - - if (dda->dda_index.dda_fmcount) { - - last = dda->dda_index.dda_fileno + dda->dda_index.dda_fmcount; - - if (fileno >= dda->dda_index.dda_fileno && fileno < last) { - - dda->dda_pos = dda->dda_index.dda_blkcount + - fileno - dda->dda_index.dda_fileno; - - return (0); - } - } - - if (fileno < dda->dda_index.dda_fileno) { - return (-1); - } - - return (1); -} - -/* - * dda_bsearch - * - * Parameters: - * - dda: DDA tape drive. - * - key: LBA or file number. - * - compare: Binary search comparison function. - * - found: Search successful. - * - * Binary search index file records for LBA or fileno. - * - * Return Values: - * 0 : success - * errno : fs failure - * - */ -static int -dda_bsearch(dda_t *dda, - int64_t key, - int (*compare)(dda_t *, int64_t), - int *found) -{ - int err; - int res; - off64_t nel, width, base, two_width, last; - - /* - * Index file binary search for lba or fileno - */ - - DDA_DEBUG2((dda_bsearch, - int, dda->dda_inst, - int64_t, key)); - - *found = 0; - - /* bsearch(3C) */ - width = sizeof (dda_index_t); - two_width = width + width; - - base = 0; - nel = dda->dda_index_fsize / sizeof (dda_index_t); - last = base + width * (nel - 1); - - while (last >= base) { - - dda->dda_index_offset = - base + width * ((last - base) / two_width); - - if (err = dda_read_index(dda)) { - return (err); - } - - res = compare(dda, key); - - if (res == 0) { - *found = 1; - return (0); - } - - if (res < 0) { - last = dda->dda_index_offset - width; - } else { - base = dda->dda_index_offset + width; - } - } - - return (0); -} - -/* vnode operations */ - -/* - * dda_vn_open - * - * Parameters: - * - dda: DDA tape drive. - * - vpp: Pointer to a vnode file pointer. - * - fname: Filename to open. - * - * Open a dda media file from the kernel. - * Ensure the dda user has permission to open the file. - * On error convert the file open error into a sense key. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_vn_open(dda_t *dda, struct vnode **vpp, char *fname) -{ - int err; - - if (err = vn_open(fname, UIO_SYSSPACE, DDA_VNODE_MODE, 0, vpp, 0, 0)) { - DDA_DEBUG3((dda_vn_open_err, - int, dda->dda_inst, - char *, fname, - int, err)); - *vpp = NULL; - dda_vn_error_skey(dda, err); - return (err); - } - - err = VOP_ACCESS(*vpp, DDA_VNODE_MODE, 0, dda->dda_cred, NULL); - if (err) { - DDA_DEBUG3((dda_vn_open_access, - int, dda->dda_inst, - char *, fname, - int, err)); - (void) VOP_CLOSE(*vpp, DDA_VNODE_MODE, 1, (offset_t)0, - dda->dda_cred, NULL); - VN_RELE(*vpp); - *vpp = NULL; - dda_vn_error_skey(dda, err); - } - return (err); -} - -/* - * dda_vn_close - * - * Parameters: - * - dda: DDA tape drive. - * - vpp: Pointer to a vnode file pointer. - * - * Close dda media file from the kernel. - * On error convert the file close error into a sense key. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_vn_close(dda_t *dda, struct vnode **vpp) -{ - int err; - - if (*vpp == NULL) { - DDA_DEBUG1((dda_vn_close_null, - int, dda->dda_inst)); - dda->dda_status = KEY_MEDIUM_ERROR; - return (EIO); - } - - err = VOP_CLOSE(*vpp, DDA_VNODE_MODE, 1, (offset_t)0, - dda->dda_cred, NULL); - if (err) { - DDA_DEBUG3((dda_vn_close_err, - int, dda->dda_inst, - char *, dda_vn_get_fname(dda, *vpp), - int, err)); - dda_vn_error_skey(dda, err); - } - VN_RELE(*vpp); - *vpp = NULL; - return (err); -} - -/* - * dda_vn_lock - * - * Parameters: - * - dda: DDA tape drive. - * - vp: Vnode pointer to open file. - * - cmd: File lock or unlock command. - * - * Set or unset a file lock on the entire file. - * The file lock is held by the driver while the media is loaded. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_vn_lock(dda_t *dda, struct vnode *vp, short cmd) -{ - flock64_t flk; - int err; - - if (vp == NULL) { - DDA_DEBUG1((dda_vn_lock_null, - int, dda->dda_inst)); - dda->dda_status = KEY_MEDIUM_ERROR; - return (EIO); - } - - /* lock or unlock entire file */ - bzero(&flk, sizeof (flock64_t)); - flk.l_type = cmd; - - /* non-blocking file lock */ - err = VOP_FRLOCK(vp, F_SETLK, &flk, FREAD | FWRITE, - 0, NULL, dda->dda_cred, NULL); - - if (cmd == F_UNLCK && vn_has_flocks(vp)) { - cleanlocks(vp, IGN_PID, 0); - } - - if (err) { - DDA_DEBUG4((dda_vn_lock_err, - int, dda->dda_inst, - char *, dda_vn_get_fname(dda, vp), - int, cmd, - int, err)); - dda_vn_error_skey(dda, err); - } - - return (err); -} - -/* - * dda_vn_read - * - * Parameters: - * - dda: DDA tape drive. - * - vp: Vnode file pointer. - * - buf: File read buffer. - * - len: Length of read buffer. - * - offset: File offset to begin reading from. - * - * From the kernel read the requested buffer length from the file. - * On error convert the file read error into a sense key. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_vn_read(dda_t *dda, struct vnode *vp, void *buf, int len, off64_t offset) -{ - int err; - struct iovec iov; - struct uio uio; - - if (vp == NULL) { - DDA_DEBUG1((dda_vn_read_null, - int, dda->dda_inst)); - dda->dda_status = KEY_MEDIUM_ERROR; - return (EIO); - } - - iov.iov_base = (caddr_t)buf; - iov.iov_len = len; - - uio.uio_iov = &iov; - uio.uio_iovcnt = 1; - uio.uio_segflg = UIO_SYSSPACE; - uio.uio_loffset = offset; - uio.uio_resid = len; - uio.uio_fmode = FREAD; - uio.uio_llimit = MAXOFFSET_T; - - (void) VOP_RWLOCK(vp, V_WRITELOCK_FALSE, NULL); - err = VOP_READ(vp, &uio, 0, dda->dda_cred, NULL); - VOP_RWUNLOCK(vp, V_WRITELOCK_FALSE, NULL); - - if (err) { - DDA_DEBUG4((dda_vn_read_err, - int, dda->dda_inst, - char *, dda_vn_get_fname(dda, vp), - off64_t, offset, - int, err)); - dda_vn_error_skey(dda, err); - return (err); - } - - if (uio.uio_resid != 0) { - DDA_DEBUG4((dda_vn_read_resid, - int, dda->dda_inst, - char *, dda_vn_get_fname(dda, vp), - off64_t, offset, - int32_t, uio.uio_resid)); - dda->dda_status = KEY_MEDIUM_ERROR; - return (EIO); - } - return (0); -} - -/* - * dda_vn_write - * - * Parameters: - * - dda: DDA tape drive. - * - vp: Vnode file pointer. - * - buf: File write buffer. - * - len: Length of write buffer. - * - offset: File offset to begin writing. - * - * From the kernel write the requested buffer length to the file. - * On error convert the file write error into a sense key. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_vn_write(dda_t *dda, struct vnode *vp, void *buf, int len, off64_t offset) -{ - int err; - struct iovec iov; - struct uio uio; - - if (vp == NULL) { - DDA_DEBUG1((dda_vn_write_null, - int, dda->dda_inst)); - dda->dda_status = KEY_MEDIUM_ERROR; - return (EIO); - } - - iov.iov_base = (caddr_t)buf; - iov.iov_len = len; - - uio.uio_iov = &iov; - uio.uio_iovcnt = 1; - uio.uio_segflg = UIO_SYSSPACE; - uio.uio_loffset = offset; - uio.uio_resid = len; - uio.uio_fmode = FWRITE; - uio.uio_llimit = MAXOFFSET_T; - - (void) VOP_RWLOCK(vp, V_WRITELOCK_TRUE, NULL); - err = VOP_WRITE(vp, &uio, FWRITE|FTRUNC, dda->dda_cred, NULL); - VOP_RWUNLOCK(vp, V_WRITELOCK_TRUE, NULL); - - if (err) { - DDA_DEBUG4((dda_vn_write_err, - int, dda->dda_inst, - char *, dda_vn_get_fname(dda, vp), - off64_t, offset, - int, err)); - dda_vn_error_skey(dda, err); - return (err); - } - - if (uio.uio_resid != 0) { - DDA_DEBUG4((dda_vn_write_resid, - int, dda->dda_inst, - char *, dda_vn_get_fname(dda, vp), - off64_t, offset, - int32_t, uio.uio_resid)); - dda->dda_status = KEY_MEDIUM_ERROR; - return (EIO); - } - return (0); -} - -/* - * dda_vn_truncate - * - * Parameters: - * - dda: DDA tape drive. - * - vp: Vnode file pointer. - * - offset: Truncate file at offset. - * - * Truncate the file. - * On error convert the file truncate error into a sense key. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_vn_truncate(dda_t *dda, struct vnode *vp, off64_t offset) -{ - int err; - struct vattr vattr; - - if (vp == NULL) { - DDA_DEBUG1((dda_vn_truncate_null, - int, dda->dda_inst)); - dda->dda_status = KEY_MEDIUM_ERROR; - return (EIO); - } - - vattr.va_size = offset; - vattr.va_mask = AT_SIZE; - err = VOP_SETATTR(vp, &vattr, 0, dda->dda_cred, NULL); - if (err) { - DDA_DEBUG4((dda_vn_truncate_err, - int, dda->dda_inst, - char *, dda_vn_get_fname(dda, vp), - off64_t, offset, - int, err)); - dda_vn_error_skey(dda, err); - } - return (err); -} - -/* - * dda_vn_sync - * - * Parameters: - * - dda: DDA tape drive. - * - vp: Vnode file pointer. - * - * Flush file to disk. - * On error convert the file flush error into a sense key. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_vn_sync(dda_t *dda, struct vnode *vp) -{ - int err; - - if (vp == NULL) { - DDA_DEBUG1((dda_vn_sync_null, - int, dda->dda_inst)); - dda->dda_status = KEY_MEDIUM_ERROR; - return (EIO); - } - - err = VOP_FSYNC(vp, FSYNC, dda->dda_cred, NULL); - if (err) { - DDA_DEBUG3((dda_vn_sync_err, - int, dda->dda_inst, - char *, dda_vn_get_fname(dda, vp), - int, err)); - dda_vn_error_skey(dda, err); - } - return (err); -} - -/* - * dda_vn_size - * - * Parameters: - * - dda: DDA tape drive. - * - vp: Vnode file pointer. - * - fsize: File size. - * - * Get dda media file size. - * On error convert the file size error into a sense key. - * - * Return Values: - * 0 : success - * errno : failure - * - */ -static int -dda_vn_size(dda_t *dda, struct vnode *vp, off64_t *fsize) -{ - int err; - struct vattr vattr; - - if (vp == NULL) { - DDA_DEBUG1((dda_vn_size_null, - int, dda->dda_inst)); - dda->dda_status = KEY_MEDIUM_ERROR; - return (EIO); - } - - vattr.va_mask = AT_SIZE; - err = VOP_GETATTR(vp, &vattr, 0, dda->dda_cred, NULL); - if (err) { - DDA_DEBUG3((dda_vn_size_err, - int, dda->dda_inst, - char *, dda_vn_get_fname(dda, vp), - int, err)); - dda_vn_error_skey(dda, err); - } else { - *fsize = (off64_t)vattr.va_size; - } - return (err); -} - -/* - * dda_vn_get_fname - * - * Parameters: - * - dda: DDA tape drive. - * - vp: Vnode file pointer. - * - * Get dda media filename from the vnode pointer for tracing. - * - * Return Values: - * filename - * - */ -static char * -dda_vn_get_fname(dda_t *dda, struct vnode *vp) -{ - char *fname; - - if (vp == dda->dda_metadata_vp) { - fname = DDA_METADATA_FNAME; - } else if (vp == dda->dda_index_vp) { - fname = DDA_INDEX_FNAME; - } else if (vp == dda->dda_data_vp) { - fname = DDA_DATA_FNAME; - } else { - fname = DDA_UNKNOWN_FNAME; - } - return (fname); -} - -/* - * dda_vn_error_skey - * - * Parameters: - * - dda: DDA tape drive. - * - int: errno - * - * Convert filesystem or kernel errno into tape drive sense key. - * - * Return Values: - * None - * - */ -static void -dda_vn_error_skey(dda_t *dda, int err) -{ - switch (err) { - case 0: /* no error */ - dda->dda_status = KEY_NO_SENSE; - break; - case EINVAL: /* invalid arg */ - dda->dda_status = KEY_ILLEGAL_REQUEST; - break; - case EFBIG: /* file too large */ - case ENOSPC: /* no space */ - dda->dda_status = SUN_KEY_EOT; - break; - case EACCES: /* permission denied */ - case EROFS: /* read only fs */ - dda->dda_status = KEY_WRITE_PROTECT; - break; - case EISDIR: /* is directory */ - case ENOENT: /* no such file or directory */ - dda->dda_status = KEY_MEDIUM_ERROR; - break; - /* ESTALE: stale nfs file handle */ - /* EMFILE: too many open files */ - /* EMLINK: too many links */ - /* EAGAIN: resource temporarily unavailable */ - /* ENOMEM: not enough core */ - /* ENOLCK: no record locks available */ - default: - dda->dda_status = KEY_RECOVERABLE_ERROR; - break; - } -} diff --git a/usr/src/uts/common/io/mms/dda/dda.conf b/usr/src/uts/common/io/mms/dda/dda.conf deleted file mode 100644 index 4d59c6fa15..0000000000 --- a/usr/src/uts/common/io/mms/dda/dda.conf +++ /dev/null @@ -1,47 +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. -# - - -# One instance per dda tape drive. - -name="dda" parent="pseudo" instance=0; -name="dda" parent="pseudo" instance=1; -name="dda" parent="pseudo" instance=2; -name="dda" parent="pseudo" instance=3; -name="dda" parent="pseudo" instance=4; -name="dda" parent="pseudo" instance=5; -name="dda" parent="pseudo" instance=6; -name="dda" parent="pseudo" instance=7; -name="dda" parent="pseudo" instance=8; -name="dda" parent="pseudo" instance=9; -name="dda" parent="pseudo" instance=10; -name="dda" parent="pseudo" instance=11; -name="dda" parent="pseudo" instance=12; -name="dda" parent="pseudo" instance=13; -name="dda" parent="pseudo" instance=14; -name="dda" parent="pseudo" instance=15; -name="dda" parent="pseudo" instance=16; -name="dda" parent="pseudo" instance=17; -name="dda" parent="pseudo" instance=18; -name="dda" parent="pseudo" instance=19; diff --git a/usr/src/uts/common/io/mms/dda/dda.h b/usr/src/uts/common/io/mms/dda/dda.h deleted file mode 100644 index 0cc0bfba73..0000000000 --- a/usr/src/uts/common/io/mms/dda/dda.h +++ /dev/null @@ -1,194 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License (the "License"). - * You may not use this file except in compliance with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#ifndef _DDA_H -#define _DDA_H - - -#ifdef __cplusplus -extern "C" { -#endif - -#include <sys/byteorder.h> - -/* - * Driver for Disk Archiving (dda) - */ - -/* Begin: 32-bit align copyin() structs for amd64 only due to 32-bit x86 ABI */ -#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 -#pragma pack(4) -#endif - -/* version for cartridge and dda */ -#define DDA_MAJOR_VERSION 1 /* dda driver major version */ -#define DDA_MINOR_VERSION 2 /* dda driver minor version */ - -/* cartridge file names */ -#define DDA_METADATA_FNAME "metadata" /* metadata file name */ -#define DDA_INDEX_FNAME "index" /* index file name */ -#define DDA_DATA_FNAME "data" /* data file name */ - -/* inquiry and mt config data */ -#define DDA_VENDOR "SUNW " -#define DDA_PRODUCT "DISK_ARCHIVING " -#define DDA_VID DDA_VENDOR DDA_PRODUCT -#define DDA_ST_NAME "SUNW MMS disk archiving" - -/* - * DM ioctls: - * cmd arg - * --- --- - * DDA_CMD_LOAD char path[PATH_MAX] - * Returns 0 if cartridge path is successfully loaded, - * else non-zero. - * DDA_CMD_NAME char path[PATH_MAX] - * Returns 0 and loaded cartridge path, else non-zero. - * DDA_CMD_CAPACITY dda_capacity_t *capacity - * If loaded returns 0 along with the cartridge capacity - * and space remaining, else non-zero. - * DDA_CMD_WROTECT NULL - * Returns 0 if WP flag on, else non-zero. - * DDA_CMD_BLKLMT dda_blklmt_t *blklmt - * Returns 0 and the cartridge maximum and minimum block - * size, else non-zero. - */ -#define DDA_IOC (('D' << 24) | ('D' << 16) | ('A' << 8)) -#define DDA_CMD_LOAD (DDA_IOC | 1) /* load cartridge */ -#define DDA_CMD_NAME (DDA_IOC | 2) /* get cartridge name */ -#define DDA_CMD_CAPACITY (DDA_IOC | 3) /* get tape capacity/space */ -#define DDA_CMD_WPROTECT (DDA_IOC | 4) /* get cartridge WP flag */ -#define DDA_CMD_BLKLMT (DDA_IOC | 5) /* get block limits */ - -/* cartridge capacity */ -typedef struct dda_capacity { - int64_t dda_capacity; /* tape capacity in bytes */ - int64_t dda_space; /* unused tape bytes remaining to eom */ -} dda_capacity_t; - -/* read block limits */ -typedef struct dda_blklmt { - int32_t dda_blkmax; /* maximum block length */ - int32_t dda_blkmin; /* minimum block length */ -} dda_blklmt_t; - -/* versioning */ -typedef struct dda_version { - int32_t dda_major; /* dda drive/media major version */ - int32_t dda_minor; /* dda drive/media minor version */ -} dda_version_t; - -/* metadata flags */ -#define DDA_FLAG_WPROTECT 0x1 /* cartridge write protect tab */ - -/* metadata file contents */ -typedef struct dda_metadata { - dda_version_t dda_version; /* dda media version */ - int64_t dda_capacity; /* tape capacity in bytes */ - int32_t dda_sector; /* sector alignment */ - int32_t dda_stripe; /* raid 5 stripe alignment */ - int32_t dda_flags; /* cartridge flags */ - int32_t dda_pad; /* padding */ -} dda_metadata_t; - -/* index file record */ -typedef struct dda_index { - off64_t dda_offset; /* data file offset */ - int32_t dda_blksize; /* data block size */ - int32_t dda_pad; /* padding */ - int64_t dda_blkcount; /* data block count */ - int64_t dda_fmcount; /* file marks following data blocks */ - int64_t dda_fileno; /* file mark number */ - int64_t dda_lba; /* logical block address */ -} dda_index_t; - -/* convert metadata file record between big endian and native byte order */ -#define DDA_BE_METADATA(a, b) { \ - b.dda_version.dda_major = BE_32(a.dda_version.dda_major); \ - b.dda_version.dda_minor = BE_32(a.dda_version.dda_minor); \ - b.dda_capacity = BE_64(a.dda_capacity); \ - b.dda_sector = BE_32(a.dda_sector); \ - b.dda_stripe = BE_32(a.dda_stripe); \ - b.dda_flags = BE_32(a.dda_flags); \ - b.dda_pad = BE_32(a.dda_pad); \ -} - -/* convert index file record between big endian and native byte order */ -#define DDA_BE_INDEX(a, b) { \ - b.dda_offset = BE_64(a.dda_offset); \ - b.dda_blksize = BE_32(a.dda_blksize); \ - b.dda_pad = BE_32(a.dda_pad); \ - b.dda_blkcount = BE_64(a.dda_blkcount); \ - b.dda_fmcount = BE_64(a.dda_fmcount); \ - b.dda_fileno = BE_64(a.dda_fileno); \ - b.dda_lba = BE_64(a.dda_lba); \ -} - -/* End: 32-bit align copyin() structs for amd64 only due to 32-bit x86 ABI */ -#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 -#pragma pack() -#endif - -#ifdef _KERNEL - -/* emulated tape drive data structure */ -typedef struct dda { - char dda_path[PATH_MAX]; /* cartridge path */ - short dda_status; /* sense key */ - int32_t dda_resid; /* residual */ - int64_t dda_blkno; /* block number */ - off64_t dda_early_warn; /* early warning */ - uint32_t dda_flags; /* operation flags */ - - struct vnode *dda_metadata_vp; /* metadata file */ - dda_metadata_t dda_metadata; /* metatdata file data */ - - struct vnode *dda_index_vp; /* index file */ - off64_t dda_index_fsize; /* index file size */ - off64_t dda_index_offset; /* index file offset */ - dda_index_t dda_index; /* index file record */ - int64_t dda_pos; /* index record current block */ - - struct vnode *dda_data_vp; /* data file */ - off64_t dda_data_fsize; /* data file size */ - - int dda_inst; /* driver instance (drive number) */ - dev_info_t *dda_dip; /* driver instance info */ - kmutex_t dda_mutex; /* serialize drive access */ - int dda_loaded; /* media loaded */ - pid_t dda_pid; /* process opened by */ - cred_t *dda_cred; /* user credentials */ - int dda_read_only; /* opened read only */ - int32_t dda_rec_size; /* variable or fixed blocks */ - int dda_ili; /* incorrect length indicator */ -} dda_t; - -#endif /* _KERNEL */ - - -#ifdef __cplusplus -} -#endif - -#endif /* _DDA_H */ diff --git a/usr/src/uts/common/io/mms/dmd/dmd.c b/usr/src/uts/common/io/mms/dmd/dmd.c deleted file mode 100644 index 2b6db211b7..0000000000 --- a/usr/src/uts/common/io/mms/dmd/dmd.c +++ /dev/null @@ -1,3465 +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. - */ - - -#include <sys/devops.h> /* used by dev_ops */ -#include <sys/conf.h> /* used by dev_ops and cb_ops */ -#include <sys/modctl.h> /* used by modlinkage, modldrv, */ - /* _init, _info, and _fini */ -#include <sys/types.h> /* used by open, close, read, write, */ - /* prop_op, and ddi_prop_op */ -#include <sys/file.h> /* used by open, close */ -#include <sys/errno.h> /* used by open, close, read, write */ -#include <sys/open.h> /* used by open, close, read, write */ -#include <sys/cred.h> /* used by open, close, read */ -#include <sys/uio.h> /* used by read */ -#include <sys/stat.h> /* defines S_IFCHR used by */ - /* ddi_create_minor_node */ -#include <sys/cmn_err.h> /* used by all entry points for */ - /* this driver */ -#include <sys/mkdev.h> -#include <sys/ddi.h> /* used by all entry points for */ - /* this driver also used by cb_ops, */ - /* ddi_get_instance, and ddi_prop_op */ -#include <sys/sunddi.h> /* used by all entry points for */ - /* this driver also used by cb_ops, */ - /* ddi_create_minor_node, */ - /* ddi_get_instance, and ddi_prop_op */ -#include <sys/sunldi.h> -#include <sys/scsi/impl/uscsi.h> -#include <sys/signal.h> -#include <sys/kmem.h> -#include <sys/ksynch.h> -#include <sys/int_types.h> -#include <sys/scsi/scsi_ctl.h> -#include <sys/scsi/scsi_pkt.h> -#include <sys/scsi/generic/sense.h> -#include <sys/scsi/generic/status.h> -#include <sys/scsi/generic/commands.h> -#include <sys/scsi/targets/stdef.h> -#include <sys/mtio.h> -#include <mms_dmd.h> -#include <dmd_impl.h> - -typedef struct dmd_sym { - char *dmd_sym; - int dmd_code; -} dmd_sym_t; - -static dmd_sym_t dmd_scsi_cmd_tab[] = { - "test unit ready", SCMD_TEST_UNIT_READY, - "request sense", SCMD_REQUEST_SENSE, - "read", SCMD_READ, - "write", SCMD_WRITE, - "inquiry", SCMD_INQUIRY, - "mode select", SCMD_MODE_SELECT, - "reserve", SCMD_RESERVE, - "release", SCMD_RELEASE, - "mode sense", SCMD_MODE_SENSE, - "rewind", SCMD_REWIND, - "read block limit", SCMD_READ_BLKLIM, - "write tapemark", SCMD_WRITE_FILE_MARK, - "space", SCMD_SPACE, - "erase", SCMD_ERASE, - "mode sense", SCMD_MODE_SENSE, - "load", SCMD_LOAD, - "persistent reserve in", SCMD_PRIN, - "persistent reserve out", SCMD_PROUT, - "locate", SCMD_LOCATE, - "read position", SCMD_READ_POSITION, - "report density", SCMD_REPORT_DENSITIES, - "log select", SCMD_LOG_SELECT_G1, - "log sense", SCMD_LOG_SENSE_G1, - NULL, 0, -}; - -static dmd_sym_t dmd_mtop_tab[] = { - "MTSEEK", MTSEEK, - "MTTELL", MTTELL, - "MTWEOF", MTWEOF, - "MTFSF", MTFSF, - "MTBSF", MTBSF, - "MTFSR", MTFSR, - "MTBSR", MTBSR, - "MTREW", MTREW, - "MTOFFL", MTOFFL, - "MTNOP", MTNOP, - "MTRETEN", MTRETEN, - "MTERASE", MTERASE, - "MTEOM", MTEOM, - "MTNBSF", MTNBSF, - "MTSRSZ", MTSRSZ, - "MTGRSZ", MTGRSZ, - "MTLOAD", MTLOAD, - NULL, 0, /* Must be last entry */ -}; - -static dmd_sym_t dmd_ioctl_tab[] = { - "MTIOCTOP", MTIOCTOP, - "MTIOCGET", MTIOCGET, - "MTIOCGETDRIVETYPE", MTIOCGETDRIVETYPE, - "MTIOCPERSISTENT", MTIOCPERSISTENT, - "MTIOCPERSISTENTSTATUS", MTIOCPERSISTENTSTATUS, - "MTIOCLRERR", MTIOCLRERR, - "MTIOCGUARANTEEDORDER", MTIOCGUARANTEEDORDER, - "MTIOCRESERVE", MTIOCRESERVE, - "MTIOCRELEASE", MTIOCRELEASE, - "MTIOCFORCERESERVE", MTIOCFORCERESERVE, - "MTIOCGETERROR", MTIOCGETERROR, - "MTIOCSTATE", MTIOCSTATE, - "MTIOCREADIGNOREILI", MTIOCREADIGNOREILI, - "MTIOCREADIGNOREEOFS", MTIOCREADIGNOREEOFS, - "MTIOCSHORTFMK", MTIOCSHORTFMK, - "MTIOCGETPOS", MTIOCGETPOS, - "MTIOCRESTPOS", MTIOCRESTPOS, - "MTIOCLTOP", MTIOCLTOP, - NULL, 0, -}; - -/* - * dmd.conf - * name="dmd" parent="pseudo" ; - */ - -static void *dmd_soft_statep; -static dmd_wcr_t *dmd_wcr_p; -static dmd_stat_t *dmd_stat_p; -static major_t dmd_major; -static int dmd_next_ord = DMD_FIRST_DEV_ORDINAL; - -/* - * To turn dmd_debug messages on, set dmd_debug to 1 by doing: - * echo 'dmd_debug/W 1' | mdb -kw - * or add the following to /etc/system and reboot: - * set dmd:dmd_debug=1 - */ -int dmd_debug = 0; -/* - * State variables - */ -static int dmd_state = DMD_NOT_READY; /* Initialized to */ - /* NOT_READY. Set to */ - /* READY after the */ - /* watcher device is */ - /* opened */ -static kmutex_t dmd_state_mutex; -static int dmd_busy = 0; -static kmutex_t dmd_busy_mutex; -static kmutex_t dmd_sync_mutex; /* Synchronize DM's */ - -static int dmd_attach(dev_info_t *dip, ddi_attach_cmd_t cmd); -static int dmd_detach(dev_info_t *dip, ddi_detach_cmd_t cmd); -static int dmd_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, - void **resultp); -static int dmd_prop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, - int flags, char *name, caddr_t valuep, int *lengthp); -static int dmd_open(dev_t *devp, int flags, int otyp, cred_t *cred); -static int dmd_close(dev_t dev, int flags, int otyp, cred_t *cred); -static int dmd_read(dev_t dev, struct uio *uiop, cred_t *credp); -static int dmd_read_drm(dmd_drm_t *, struct uio *, cred_t *); -static int dmd_read_tdv(dmd_tdv_t *, struct uio *, cred_t *); -static int dmd_write(dev_t dev, struct uio *uiop, cred_t *credp); -static int dmd_write_drm(dmd_drm_t *, struct uio *, cred_t *); -static int dmd_write_tdv(dmd_tdv_t *, struct uio *, cred_t *); -static int dmd_open_wcr(dmd_wcr_t *ss); -static int dmd_open_stat(dmd_stat_t *ss); -static int dmd_open_drm(dmd_drm_t *ss, dev_t *devp, int flags, int otyp, - cred_t *cred); -static int dmd_open_tdv(dmd_tdv_t *ss, dev_t *devp, int flags, int otyp, - cred_t *cred); -static int dmd_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp, - int *rvalp); -static int dmd_ioctl_wcr(dmd_wcr_t *ss, int cmd, intptr_t arg); -static int dmd_ioctl_stat(dmd_stat_t *ss, int cmd, intptr_t arg, int mode); -static int dmd_ioctl_drm(dmd_drm_t *ss, int cmd, intptr_t arg, - int mode, cred_t *credp, int *rvalp); -static int dmd_ioctl_tdv(dmd_tdv_t *ss, int cmd, intptr_t arg, - int mode, int *rvalp); -static int dmd_close_wcr(dmd_wcr_t *ss); -static int dmd_close_stat(dmd_stat_t *ss); -static int dmd_close_drm(dmd_drm_t *ss, dev_t dev, cred_t *cred); -static int dmd_close_tdv(dmd_tdv_t *ss, dev_t dev); -static int dmd_ldi_open(dmd_drm_t *ss, cred_t *cred); -static int dmd_ldi_close(dmd_drm_t *ss, cred_t *cred); -static int dmd_create_dev(dmd_wcr_t *wcr, char *devpfx, int inst, - dmd_soft_state_t **rss, dev_info_t **rdip); -static int dmd_bind_dev(dmd_drm_t *drm, drm_target_t *targ, cred_t *credp); -static int dmd_signal_drm(dmd_drm_t *drm); -static int dmd_mtioclrerr(dmd_tdv_t *tdv); -static int dmd_mtioctop(dmd_tdv_t *tdv, intptr_t arg, int mode, struct mtop *); -static int dmd_mtiocltop(dmd_tdv_t *tdv, intptr_t arg, - int mode, struct mtlop *); -static int dmd_chk_allowed_cmd(dmd_tdv_t *tdv, int cmd, - intptr_t arg, int mode, int *rvalp); -static int dmd_get_disallowed(dmd_drm_t *drm, intptr_t arg, uchar_t *mask, - int mode); -static int dmd_mtiocget(dmd_tdv_t *tdv, intptr_t arg, int mode); -static int dmd_mtgetpos(dmd_tdv_t *tdv, intptr_t arg, int mode); -static int dmd_mtrestpos(dmd_tdv_t *tdv, intptr_t arg, int mode); -static int dmd_blk_limit(dmd_tdv_t *tdv, intptr_t arg, int mode); -static int dmd_locate(dmd_tdv_t *tdv, intptr_t arg, int mode); -static int dmd_get_pos(dmd_tdv_t *tdv, intptr_t arg, int mode); -static int dmd_get_capacity(dmd_tdv_t *tdv, intptr_t arg, int mode); -static int dmd_upt_capacity(dmd_tdv_t *tdv); -static int dmd_set_density(dmd_tdv_t *tdv, intptr_t arg); -static int dmd_get_density(dmd_tdv_t *tdv, intptr_t arg, - int mode); -static int dmd_stat_info(dmd_stat_t *stat, intptr_t arg, int mode); -static void dmd_stat_info_wcr(dmd_wcr_t *wcr, dmd_stat_dev_t *dp); -static void dmd_stat_info_drm(dmd_drm_t *drm, dmd_stat_dev_t *dp); -static void dmd_stat_info_tdv(dmd_tdv_t *tdv, dmd_stat_dev_t *dp); -static int dmd_probe_device(dmd_drm_t *drm, drm_probe_dev_t *ino); -static void dmd_cleanup_rsv(dmd_drm_t *drm); - - - -/* cb_ops structure */ -static struct cb_ops dmd_cb_ops = { - dmd_open, - dmd_close, - nodev, /* no strategy - nodev returns ENXIO */ - nodev, /* no print */ - nodev, /* no dump */ - dmd_read, - dmd_write, - dmd_ioctl, /* no ioctl */ - nodev, /* no devmap */ - nodev, /* no mmap */ - nodev, /* no segmap */ - nochpoll, /* returns ENXIO for non-pollable devices */ - dmd_prop_op, - NULL, /* streamtab struct; if not NULL, all above */ - /* fields are ignored */ - D_NEW | D_MP, /* compatibility flags: see conf.h */ - CB_REV, /* cb_ops revision number */ - nodev, /* no aread */ - nodev /* no awrite */ -}; - -/* dev_ops structure */ -static struct dev_ops dmd_dev_ops = { - DEVO_REV, - 0, /* reference count */ - dmd_getinfo, - nulldev, /* no identify - nulldev returns 0 */ - nulldev, /* no probe */ - dmd_attach, - dmd_detach, - nodev, /* no reset - nodev returns ENXIO */ - &dmd_cb_ops, - (struct bus_ops *)NULL, - nodev /* no power */ -}; - -/* modldrv structure */ -static struct modldrv md = { - &mod_driverops, /* Type of module. This is a driver. */ - "MMS Drive Manager Driver (dmd)", /* Name of the module. */ - &dmd_dev_ops -}; - -/* modlinkage structure */ -static struct modlinkage ml = { - MODREV_1, - &md, - NULL -}; - -/* dev_info structure */ -dev_info_t *dmd_dip; /* keep track of one instance */ - -struct dev_ops *dev_ops; -dev_t st_dev; - -static pid_t dmd_stat_opens[DMD_MAX_STAT]; - - - -minor_t -dmd_inst_to_minor(int inst) -{ - /* - * wcr and stat device - */ - if (inst <= 1) { - return (inst); - } - - /* - * Drive manager device - */ - if ((inst & 1) == 0) { - return (inst / 2 + 1); - } - - /* - * Target device - */ - return (inst / 2 + 1 + 0x100); -} - -int -dmd_minor_to_inst(minor_t minor) -{ - minor = getminor(minor); - - /* - * Watcher device - */ - if (minor == 0) { - return (0); - } - - /* - * Stat device - */ - if (minor == 1) { - return (1); - } - - /* - * Drive manager device - */ - if (minor <= 0xff) { - return (((minor & 0xff) - 1) * 2); - } - - /* - * Target device - */ - return (((minor & 0xff) - 1) * 2 + 1); -} - -static char * -dmd_lookup(dmd_sym_t *tab, int code) -{ - dmd_sym_t *sp; - - for (sp = tab; sp->dmd_sym != NULL; sp++) { - if (sp->dmd_code == code) { - return (sp->dmd_sym); - } - } - return ("UNKNOWN"); -} - -static int -dmd_get_uscsicmd(int *cmd, intptr_t arg, int flag) -{ - char scsi_cmd; - struct uscsi_cmd us; -#ifdef _MULTI_DATAMODEL - /* - * For use when a 32 bit app makes a call into a - * 64 bit ioctl - */ - struct uscsi_cmd32 us32; -#endif /* _MULTI_DATAMODEL */ - -#ifdef _MULTI_DATAMODEL - switch (ddi_model_convert_from(flag & FMODELS)) { - case DDI_MODEL_ILP32: - if (ddi_copyin((void *)arg, &us32, - sizeof (struct uscsi_cmd32), flag)) { - return (EFAULT); - } - uscsi_cmd32touscsi_cmd((&us32), (&us)); - break; - case DDI_MODEL_NONE: - if (ddi_copyin((void *)arg, &us, - sizeof (struct uscsi_cmd), flag)) { - return (EFAULT); - } - break; - } - -#else /* ! _MULTI_DATAMODEL */ - if (ddi_copyin((void *)arg, &us, sizeof (struct uscsi_cmd), flag)) { - return (EFAULT); - } -#endif /* _MULTI_DATAMODEL */ - - /* - * Copy the command code from scsi_cmd - */ - if (ddi_copyin((void *)us.uscsi_cdb, &scsi_cmd, 1, flag)) { - return (EFAULT); - } - *cmd = scsi_cmd; - - return (0); -} - -static int -dmd_get_mtop(struct mtop *mtop, intptr_t arg, int flag) -{ -#ifdef _MULTI_DATAMODEL - /* - * For use when a 32 bit app makes a call into a - * 64 bit ioctl - */ - struct mtop32 mtop_32_for_64; -#endif /* _MULTI_DATAMODEL */ - -#ifdef _MULTI_DATAMODEL - switch (ddi_model_convert_from(flag & FMODELS)) { - case DDI_MODEL_ILP32: - if (ddi_copyin((void *)arg, &mtop_32_for_64, - sizeof (struct mtop32), flag)) { - return (EFAULT); - } - mtop->mt_op = mtop_32_for_64.mt_op; - mtop->mt_count = (daddr_t)mtop_32_for_64.mt_count; - break; - case DDI_MODEL_NONE: - if (ddi_copyin((void *)arg, mtop, sizeof (struct mtop), flag)) { - return (EFAULT); - } - break; - } - -#else /* ! _MULTI_DATAMODEL */ - if (ddi_copyin((void *)arg, mtop, sizeof (struct mtop), flag)) { - return (EFAULT); - } -#endif /* _MULTI_DATAMODEL */ - return (0); -} - -static int -dmd_get_mtlop(struct mtlop *mtlop, intptr_t arg, int flag) -{ -#ifdef _MULTI_DATAMODEL - /* - * For use when a 32 bit app makes a call into a - * 64 bit ioctl - */ - struct mtlop mtlop_32_for_64; -#endif /* _MULTI_DATAMODEL */ - -#ifdef _MULTI_DATAMODEL - switch (ddi_model_convert_from(flag & FMODELS)) { - case DDI_MODEL_ILP32: - if (ddi_copyin((void *)arg, &mtlop_32_for_64, - sizeof (struct mtlop), flag)) { - return (EFAULT); - } - mtlop->mt_op = mtlop_32_for_64.mt_op; - mtlop->mt_count = (daddr_t)mtlop_32_for_64.mt_count; - break; - case DDI_MODEL_NONE: - if (ddi_copyin((void *)arg, mtlop, sizeof (struct mtlop), - flag)) { - return (EFAULT); - } - break; - } - -#else /* ! _MULTI_DATAMODEL */ - if (ddi_copyin((void *)arg, mtlop, sizeof (struct mtlop), flag)) { - return (EFAULT); - } -#endif /* _MULTI_DATAMODEL */ - return (0); -} - -static int -dmd_return_mtop(struct mtop *mtop, intptr_t arg, int flag) -{ -#ifdef _MULTI_DATAMODEL - /* - * For use when a 32 bit app makes a call into a - * 64 bit ioctl - */ - struct mtop32 mtop_32_for_64; -#endif /* _MULTI_DATAMODEL */ - -#ifdef _MULTI_DATAMODEL - switch (ddi_model_convert_from(flag & FMODELS)) { - case DDI_MODEL_ILP32: - mtop_32_for_64.mt_op = mtop->mt_op; - mtop_32_for_64.mt_count = mtop->mt_count; - if (ddi_copyout(&mtop_32_for_64, (void *)arg, - sizeof (struct mtop32), flag)) { - return (EFAULT); - } - break; - case DDI_MODEL_NONE: - if (ddi_copyout(mtop, (void *)arg, sizeof (struct mtop), - flag)) { - return (EFAULT); - } - break; - } - -#else /* ! _MULTI_DATAMODEL */ - if (ddi_copyout(mtop, (void *)arg, sizeof (struct mtop), flag)) { - return (EFAULT); - } -#endif /* _MULTI_DATAMODEL */ - return (0); -} - -static int -dmd_return_mtlop(struct mtlop *mtlop, intptr_t arg, int flag) -{ - if (ddi_copyout(mtlop, (void *)arg, sizeof (struct mtlop), flag)) { - return (EFAULT); - } - return (0); -} - -/* Loadable module configuration entry points */ - -int -_init(void) -{ - int rc = 0; - - DMD_DEBUG((CE_CONT, "_init: enter")); - if (rc = ddi_soft_state_init(&dmd_soft_statep, - sizeof (dmd_soft_state_t), 0)) { - cmn_err(CE_WARN, "_init: soft state init error %d", rc); - return (rc); - } - - if ((rc = mod_install(&ml)) != 0) { - cmn_err(CE_WARN, "_init: mod install error %d", rc); - ddi_soft_state_fini(&dmd_soft_statep); - } - - mutex_init(&dmd_state_mutex, NULL, MUTEX_DRIVER, NULL); - mutex_init(&dmd_sync_mutex, NULL, MUTEX_DRIVER, NULL); - dmd_busy = 0; - - return (rc); -} - -int -_info(struct modinfo *modinfop) -{ - int rc; - - DMD_DEBUG((CE_CONT, "_info: enter\n")); - if ((rc = mod_info(&ml, modinfop)) == 0) { - cmn_err(CE_WARN, "_info: mod info error %d", rc); - } - return (rc); -} - -int -_fini(void) -{ - int rc = 0; - - DMD_DEBUG((CE_CONT, "_fini: enter\n")); - if ((rc = mod_remove(&ml)) != 0) { - return (rc); - } - - ddi_soft_state_fini(&dmd_soft_statep); - - return (rc); -} - -/* Device autoconfiguration entry points */ - -static int -dmd_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) -{ - int inst; - int rc = 0; - int i; - - inst = ddi_get_instance(dip); - DMD_DEBUG((CE_CONT, "dmd_attach: instance = %d", inst)); - - /* - * Only work on instance 0. Ignore all other instances. - */ - if (inst != 0) { - DMD_DEBUG((CE_NOTE, "dmd_attach: instance is not 0\n")); - return (DDI_FAILURE); - } - dmd_major = ddi_driver_major(dip); - - switch (cmd) { - case DDI_ATTACH: - /* - * Create the watcher device - */ - rc = dmd_create_dev(dmd_wcr_p, DMD_WCR_NAME, 0, - (dmd_soft_state_t **)(&dmd_wcr_p), &dip); - if (rc) { - return (DDI_FAILURE); - } - dmd_wcr_p->wcr_inst = 0; - dmd_wcr_p->wcr_dip = dip; - - /* - * Create the stat device - instance 1 - */ - rc = dmd_create_dev(dmd_wcr_p, DMD_STAT_NAME, 1, - (dmd_soft_state_t **)(&dmd_stat_p), &dip); - if (rc) { - ddi_soft_state_free(dmd_soft_statep, 0); - ddi_remove_minor_node(dip, NULL); - return (DDI_FAILURE); - } - dmd_stat_p->stat_inst = 1; - dmd_stat_p->stat_dip = dip; - - for (i = 0; i < DMD_MAX_STAT; i++) { - dmd_stat_opens[i] = (pid_t)(-1); - } - - return (DDI_SUCCESS); - default: - DMD_DEBUG((CE_NOTE, "dmd_attach: attach failed, inst = %d", - inst)); - return (DDI_FAILURE); - } -} - -static int -dmd_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) -{ - int inst; - dmd_wcr_t *wcr; - dmd_stat_t *stat; - - inst = ddi_get_instance(dip); - DMD_DEBUG((CE_CONT, "dmd_detach: inst = %d", inst)); - switch (cmd) { - case DDI_DETACH: - /* - * Free the watcher device - */ - wcr = (dmd_wcr_t *)ddi_get_soft_state(dmd_soft_statep, inst); - if (wcr == NULL) { - cmn_err(CE_WARN, "dmd_detach: " - "can't get state struct of watcher device\n"); - return (DDI_FAILURE); - } - if (wcr->wcr_proc_ref) { - proc_unref(wcr->wcr_proc_ref); - wcr->wcr_proc_ref = NULL; - } - ddi_soft_state_free(dmd_soft_statep, inst); - - /* - * Free the stat device - */ - inst++; - stat = (dmd_stat_t *)ddi_get_soft_state(dmd_soft_statep, inst); - if (stat == NULL) { - cmn_err(CE_WARN, "dmd_detach: " - "can't get state struct of stat device\n"); - return (DDI_FAILURE); - } - ddi_soft_state_free(dmd_soft_statep, inst); - - ddi_remove_minor_node(dip, NULL); - return (DDI_SUCCESS); - default: - cmn_err(CE_WARN, "dmd_detach: failed"); - return (DDI_FAILURE); - } -} - -static int -/* LINTED: dip not used */ -dmd_getinfo(dev_info_t *dip, ddi_info_cmd_t cmd, void *arg, - void **resultp) -{ - dmd_soft_state_t *ss; - minor_t minor = getminor((dev_t)arg); - int inst = dmd_minor_to_inst(minor); - - DMD_DEBUG((CE_CONT, "dmd_getinfo: enter\n")); - switch (cmd) { - case DDI_INFO_DEVT2DEVINFO: - ss = ddi_get_soft_state(dmd_soft_statep, inst); - if (ss != NULL) { - if (DMD_WCR(inst)) { - *resultp = ss->ss_wcr.wcr_dip; - } else if (DMD_STAT(inst)) { - *resultp = ss->ss_stat.stat_dip; - } else if (DMD_DRM(inst)) { - *resultp = ss->ss_drm.drm_dip; - } else { - *resultp = ss->ss_tdv.tdv_dip; - } - return (DDI_SUCCESS); - } else { - *resultp = NULL; - cmn_err(CE_WARN, "dmd_getinfo: failed"); - return (DDI_FAILURE); - } - case DDI_INFO_DEVT2INSTANCE: - *resultp = (void *)(uintptr_t)inst; - return (DDI_SUCCESS); - default: - cmn_err(CE_WARN, "dmd_getinfo: failed"); - return (DDI_FAILURE); - } -} - -static int -dmd_prop_op(dev_t dev, dev_info_t *dip, ddi_prop_op_t prop_op, - int flags, char *name, caddr_t valuep, int *lengthp) -{ - DMD_DEBUG((CE_CONT, "dmd_prop_op: enter\n")); - return (ddi_prop_op(dev, dip, prop_op, flags, name, valuep, lengthp)); -} - -/* User context entry points */ - -static int -dmd_open(dev_t *devp, int flags, int otyp, cred_t *cred) -{ - int rc = 0; - dmd_soft_state_t *ss; - minor_t minor = getminor(*devp); - int inst = dmd_minor_to_inst(minor); - pid_t pid = ddi_get_pid(); - dmd_wcr_t *wcr; - dmd_drm_t *drm; - dmd_tdv_t *tdv; - dmd_stat_t *stat; - - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_open, dev = %x\n", inst, pid, minor)); - ss = ddi_get_soft_state(dmd_soft_statep, inst); - if (ss == NULL) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_open: Can't get state", - inst, pid)); - return (ENXIO); - } - - if (DMD_WCR(inst)) { - if (dmd_state != DMD_NOT_READY) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_open: driver is busy", - inst, pid)); - return (ENXIO); - } - wcr = &ss->ss_wcr; - wcr->wcr_cur_pid = pid; - wcr->wcr_inst = inst; - rc = dmd_open_wcr(&ss->ss_wcr); - if (rc == 0) { - dmd_state = DMD_READY; - dmd_busy = 0; - } - } else { - /* - * Do not allow new opens if the driver is not ready. - */ - if (!DMD_STAT(inst) && dmd_state != DMD_READY) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_open: " - "driver not ready", - inst, pid)); - return (ENXIO); - } - DMD_BUSY(); - if (DMD_STAT(inst)) { /* drive manager open */ - stat = &ss->ss_stat; - stat->stat_cur_pid = pid; - stat->stat_inst = inst; - rc = dmd_open_stat(stat); - } else if (DMD_DRM(inst)) { /* drive manager open */ - drm = &ss->ss_drm; - drm->drm_cur_pid = pid; - drm->drm_inst = inst; - rc = dmd_open_drm(drm, devp, flags, otyp, cred); - } else { /* an app open */ - tdv = &ss->ss_tdv; - tdv->tdv_cur_pid = pid; - tdv->tdv_inst = inst; - rc = dmd_open_tdv(tdv, devp, flags, otyp, cred); - } - DMD_UNBUSY(); - } - return (rc); -} - -static int -dmd_open_wcr(dmd_wcr_t *wcr) -{ - pid_t pid = wcr->wcr_cur_pid; - int inst = wcr->wcr_inst; - - /* - * Process wcr open - */ - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_open_wcr: " - "Opening watcher device\n", inst, pid)); - mutex_enter(&dmd_wcr_p->wcr_mutex); - if (dmd_wcr_p->wcr_pid) { /* wcr already opened */ - DMD_DEBUG((CE_NOTE, - "[%d:%d] dmd_open_wcr: watcher already opened " - "by process %d", inst, pid, dmd_wcr_p->wcr_pid)); - mutex_exit(&dmd_wcr_p->wcr_mutex); - return (EBUSY); - } - - dmd_wcr_p->wcr_pid = pid; /* save wcr pid */ - dmd_wcr_p->wcr_proc_ref = proc_ref(); - mutex_exit(&dmd_wcr_p->wcr_mutex); - return (0); -} - -static int -dmd_open_stat(dmd_stat_t *stat) -{ - int i; - pid_t pid = stat->stat_cur_pid; - int inst = stat->stat_inst; - - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_open_stat: " - "Opening stat device\n", inst, pid)); - - /* Add openpid to pid table */ - for (i = 0; i < DMD_MAX_STAT; i++) { - if (dmd_stat_opens[i] == (pid_t)(-1)) { /* a closed entry */ - dmd_stat_opens[i] = pid; - break; - } - } - if (i == DMD_MAX_STAT) { /* too many opened */ - return (EBUSY); - } - return (0); -} - -static int -dmd_open_drm(dmd_drm_t *drm, dev_t *devp, int flags, int otyp, cred_t *cred) -{ - minor_t minor = getminor(*devp); - int rc = 0; - pid_t pid = drm->drm_cur_pid; - int inst = drm->drm_inst; - - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_open_drm: " - "Opening DM device, minor = %d\n", inst, pid, minor)); - - /* - * Check to see if there is a watcher. - * If no watcher, error - */ - mutex_enter(&dmd_wcr_p->wcr_mutex); - if (dmd_wcr_p->wcr_cur_pid == 0) { - /* No watcher */ - DMD_DEBUG((CE_NOTE, - "[%d:%d] dmd_open_drm: No watcher", inst, pid)); - mutex_exit(&dmd_wcr_p->wcr_mutex); - return (ENXIO); - } - - DRM_BUSY(drm); - mutex_enter(&drm->drm_shr_mutex); - if ((drm->drm_flags & DRM_DEV_ADDED) == 0) { - rc = ENXIO; - goto done; - } - if (drm->drm_shr_pid) { - /* - * Only one process can open a drive manager - */ - DMD_DEBUG((CE_NOTE, - "[%d:%d] dmd_open_drm: dm %d already opened by process %d", - getminor(*devp), inst, pid, drm->drm_shr_pid)); - rc = EBUSY; - goto done; - } - drm->drm_shr_pid = pid; - drm->drm_shr_oflags = flags; - drm->drm_shr_cred = cred; - drm->drm_shr_otyp = otyp; - drm->drm_shr_proc_ref = proc_ref(); - if (drm->drm_shr_tdv_pid == 0) { - /* tdv not opened by app */ - drm->drm_shr_flags &= ~DRM_SHR_WAIT_TDV_CLOSE; - } - DMD_INC_OPENS(); - if (drm->drm_shr_flags & DRM_SHR_WAIT_TDV_CLOSE) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_open_drm: " - "waiting for tdv close from pid %d", - inst, pid, drm->drm_shr_tdv_pid)); - } -done: - DRM_UNBUSY(drm); - mutex_exit(&drm->drm_shr_mutex); - mutex_exit(&dmd_wcr_p->wcr_mutex); - return (rc); -} - -static int -dmd_open_tdv(dmd_tdv_t *tdv, dev_t *devp, int flags, int otyp, cred_t *cred) -{ - dmd_drm_t *drm = tdv->tdv_drm; - drm_open_t *open_req = &drm->drm_shr_req.drm_open_req; - minor_t minor = getminor(*devp); - int rc = 0; - uid_t uid = crgetuid(cred); - int inst = tdv->tdv_inst; - pid_t pid = tdv->tdv_cur_pid; - - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_open_tdv: " - "Opening target device, dev = %lx\n", - inst, pid, *devp)); - - if (minor != tdv->tdv_minor) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_open_tdv: " - "Mismatched dev: tdv_minor %x, " - "request minor %x", inst, pid, - tdv->tdv_minor, minor)); - return (ENXIO); - } - TDV_BUSY(tdv); - - /* - * Must have been bound to to a target device to open - */ - if ((tdv->tdv_flags & TDV_BOUND) == 0) { - TDV_UNBUSY(tdv); - return (ENXIO); - } - if (drm->drm_shr_tdv_pid != 0) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_open_tdv: " - "target dev already opened " - "by process %d, dev %lx", inst, pid, - drm->drm_shr_tdv_pid, *devp)); - TDV_UNBUSY(tdv); - return (EBUSY); - } - /* - * Init file I/O counts - */ - tdv->tdv_rdbytes = 0; - tdv->tdv_wrbytes = 0; - tdv->tdv_blkcnt = 0; - - mutex_enter(&drm->drm_shr_mutex); - if (drm->drm_shr_lhdl == NULL) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_open_tdv: " - "target device is not opened", inst, pid)); - TDV_UNBUSY(tdv); - mutex_exit(&drm->drm_shr_mutex); - return (ENXIO); - } - - /* - * Signal the drive manager - */ - (void) memset(&drm->drm_shr_req, 0, sizeof (drm_request_t)); - drm->drm_shr_req.drm_req_type = DRM_REQ_OPEN; - drm->drm_shr_req.drm_req_pid = pid; - drm->drm_shr_req.drm_req_uid = uid; - open_req->drm_open_flags = flags; - open_req->drm_open_type = otyp; - open_req->drm_open_minor = minor; - if (rc = dmd_signal_drm(drm)) { - /* - * Signal failed, assume open success and - * tell drive manager to close - */ - DMD_INC_OPENS(); /* increase open count */ - DMD_DEBUG((CE_NOTE, - "[%d:%d] dmd_open_tdv: signal failed, signal for " - "abnormal close", inst, pid)); - drm->drm_shr_flags |= DRM_SHR_OPEN_FAILED; - TDV_UNBUSY(tdv); - (void) dmd_close_tdv(tdv, *devp); - mutex_exit(&drm->drm_shr_mutex); - return (rc); - } - rc = drm->drm_shr_rep.drm_rep_rc; - drm->drm_shr_tdv_pid = 0; - if (rc == 0) { - /* Open success */ - drm->drm_shr_tdv_pid = pid; - tdv->tdv_uid = uid; - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_open_tdv: opened by %d", - inst, pid, drm->drm_shr_tdv_pid)); - DMD_INC_OPENS(); /* increase open count */ - } - TDV_UNBUSY(tdv); - mutex_exit(&drm->drm_shr_mutex); - return (rc); -} - -static int -/* LINTED: need all arguments */ -dmd_close(dev_t dev, int flags, int otyp, cred_t *cred) -{ - int rc = 0; - dmd_soft_state_t *ss; - minor_t minor = getminor(dev); - int inst = dmd_minor_to_inst(minor); - pid_t pid = ddi_get_pid(); - dmd_wcr_t *wcr; - dmd_drm_t *drm; - dmd_tdv_t *tdv; - dmd_stat_t *stat; - - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_close: Entering dmd_close, " - "minor = %x\n", - inst, pid, minor)); - - ss = ddi_get_soft_state(dmd_soft_statep, inst); - if (ss == NULL) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_close: Can't get state", - inst, pid)); - return (ENXIO); - } - - if (DMD_WCR(inst)) { - wcr = &ss->ss_wcr; - wcr->wcr_cur_pid = pid; - wcr->wcr_inst = inst; - rc = dmd_close_wcr(wcr); - if (rc == 0) { - dmd_state = DMD_NOT_READY; - } - } else { - DMD_BUSY(); - if (DMD_STAT(inst)) { - stat = &ss->ss_stat; - stat->stat_cur_pid = pid; - stat->stat_inst = inst; - rc = dmd_close_stat(stat); - } else if (DMD_DRM(inst)) { - drm = &ss->ss_drm; - drm->drm_cur_pid = pid; - drm->drm_inst = inst; - rc = dmd_close_drm(drm, dev, cred); - } else { - tdv = &ss->ss_tdv; - tdv->tdv_cur_pid = pid; - tdv->tdv_inst = inst; - rc = dmd_close_tdv(tdv, dev); - } - DMD_UNBUSY(); - } - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_close: rc = %d, minor = %d\n", - inst, pid, rc, minor)); - return (0); -} - -static int -dmd_close_wcr(dmd_wcr_t *wcr) -{ - dmd_drm_t *drm; - int inst = wcr->wcr_inst; - pid_t pid = wcr->wcr_cur_pid; - int i; - dmd_soft_state_t *ss; - - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_close_wcr: enter\n", inst, pid)); - mutex_enter(&wcr->wcr_mutex); - - for (i = DMD_FIRST_DEV_ORDINAL; i < dmd_next_ord; i++) { - ss = ddi_get_soft_state(dmd_soft_statep, i * 2); - if (ss == NULL) { - continue; - } - drm = &ss->ss_drm; - mutex_enter(&drm->drm_mutex); - if (drm->drm_shr_pid) { - /* - * Signal drive manager - */ - if (drm->drm_shr_proc_ref != NULL) { - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_close_wcr: " - "sending SIGTERM to dm process %d\n", - inst, pid, drm->drm_shr_pid)); - (void) proc_signal(drm->drm_shr_proc_ref, - SIGTERM); - } - } - mutex_exit(&drm->drm_mutex); - } - - wcr->wcr_pid = 0; - mutex_exit(&wcr->wcr_mutex); - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_close_wcr: close done\n", inst, pid)); - return (0); -} - -static int -dmd_close_stat(dmd_stat_t *stat) -{ - pid_t pid = stat->stat_cur_pid; - int inst = stat->stat_inst; - int i; - - DMD_DEBUG((CE_NOTE, "[%d:%d] Closing stat device", inst, pid)); - for (i = 0; i < DMD_MAX_STAT; i++) { - if (dmd_stat_opens[i] == pid) { - dmd_stat_opens[i] = (pid_t)(-1); - break; - } - } - return (0); -} - -static int -dmd_close_drm(dmd_drm_t *drm, dev_t dev, cred_t *cred) -{ - int inst = drm->drm_inst; - pid_t pid = drm->drm_cur_pid; - - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_close_drm: " - "Closing DM device, minor = %d, tdv_pid = %d\n", - inst, pid, getminor(dev), drm->drm_shr_tdv_pid)); - DRM_BUSY(drm); - - /* - * Resume any outstanding request sent to DM - */ - mutex_enter(&drm->drm_shr_mutex); - if (drm->drm_shr_flags & DRM_SHR_WAIT_RESUME) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_close_drm: " - "canceling DM requests", inst, pid)); - drm->drm_shr_flags &= - ~(DRM_SHR_WAIT_RESUME | DRM_SHR_REQ_VALID); - (void) memset(&drm->drm_shr_rep, 0, sizeof (drm_reply_t)); - drm->drm_shr_rep.drm_rep_rc = ENXIO; - cv_broadcast(&drm->drm_shr_res_cv); - } - DMD_DEC_OPENS(); - if (drm->drm_shr_proc_ref) { - proc_unref(drm->drm_shr_proc_ref); - drm->drm_shr_proc_ref = NULL; - } - dmd_cleanup_rsv(drm); - /* - * Close connection to target driver - */ - (void) dmd_ldi_close(drm, cred); - drm->drm_shr_pid = 0; /* DM is gone */ - if (drm->drm_shr_tdv_pid != 0) { - drm->drm_shr_flags |= DRM_SHR_WAIT_TDV_CLOSE; - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_close_drm: " - "tdv still opened by %d\n", - inst, pid, drm->drm_shr_tdv_pid)); - } - mutex_exit(&drm->drm_shr_mutex); - - DRM_UNBUSY(drm); - return (0); -} - -static void -dmd_cleanup_rsv(dmd_drm_t *drm) -{ - int rval; - struct uscsi_cmd *sc = &drm->drm_uscsi; - int rc = 0; - static uchar_t preempt_cmd[] = - { 0x5f, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 24, 0x00 }; - static uchar_t reg_cmd[] = - { 0x5f, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 24, 0x00 }; - dmd_tdv_t *tdv = drm->drm_tdv; - int inst = tdv->tdv_inst; - pid_t pid = drm->drm_cur_pid; - - /* - * Register the key - */ - (void) memset(sc, 0, sizeof (struct uscsi_cmd)); - (void) memset(drm->drm_prsv_buf, 0, sizeof (drm->drm_prsv_buf)); - (void) memcpy(drm->drm_prsv_buf + 8, drm->drm_prsv_key, 8); - - /* - * register PRSV key - */ - /* LINTED: Null effect */ - sc->uscsi_flags |= (USCSI_WRITE); - sc->uscsi_cdb = (char *)reg_cmd; - sc->uscsi_cdblen = sizeof (reg_cmd); - sc->uscsi_bufaddr = drm->drm_prsv_buf; - sc->uscsi_buflen = sizeof (drm->drm_prsv_buf); - - (void) memset(drm->drm_prsv_buf, 0, 24); - rc = ldi_ioctl(drm->drm_shr_lhdl, USCSICMD, (intptr_t)sc, - FKIOCTL | DATAMODEL_NATIVE, drm->drm_ioctl_credp, &rval); - if (rc != 0) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_cleanup_rsv: " - "PRSV register returns %d", - inst, pid, rc)); - } - - /* - * Preempt to remove key - */ - (void) memset(sc, 0, sizeof (struct uscsi_cmd)); - (void) memset(drm->drm_prsv_buf, 0, sizeof (drm->drm_prsv_buf)); - (void) memcpy(drm->drm_prsv_buf, drm->drm_prsv_key, 8); - (void) memcpy(drm->drm_prsv_buf + 8, drm->drm_prsv_key, 8); - - /* LINTED: Null effect */ - sc->uscsi_flags |= (USCSI_WRITE); - sc->uscsi_cdb = (char *)preempt_cmd; - sc->uscsi_cdblen = sizeof (preempt_cmd); - sc->uscsi_bufaddr = drm->drm_prsv_buf; - sc->uscsi_buflen = sizeof (drm->drm_prsv_buf); - - rc = ldi_ioctl(drm->drm_shr_lhdl, USCSICMD, (intptr_t)sc, - FKIOCTL | DATAMODEL_NATIVE, drm->drm_ioctl_credp, &rval); - if (rc != 0) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_cleanup_rsv: " - "PRSV preempt returns %d", - inst, pid, rc)); - } - /* - * Tell st driver to resume reserve/release on open/close. - */ - rc = ldi_ioctl(drm->drm_shr_lhdl, MTIOCRELEASE, NULL, - FKIOCTL | DATAMODEL_NATIVE, drm->drm_ioctl_credp, &rval); - if (rc != 0) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_cleanup_rsv: " - "MTIOCRELEASE error: %d", - inst, pid, rc)); - } -} - -static int -dmd_close_tdv(dmd_tdv_t *tdv, dev_t dev) -{ - dmd_drm_t *drm = tdv->tdv_drm; - minor_t minor = getminor(dev); - int inst = tdv->tdv_inst; - pid_t pid = tdv->tdv_cur_pid; - int xmutex = 0; /* don't do mutex_exit */ - - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_close_tdv: " - "Closing target device, minor = %x\n", - inst, pid, minor)); - TDV_BUSY(tdv); - /* - * Use tryenter because this may be called dmd_open_tdv if the - * open request failed. - */ - if (mutex_tryenter(&drm->drm_shr_mutex) != 0) { - /* got the mutex */ - xmutex = 1; /* do mutex_exit */ - } - - /* - * If no handle to target driver, then we have no associated DM - */ - if (drm->drm_shr_flags & DRM_SHR_WAIT_TDV_CLOSE) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_close_tdv: " - "No assocated DM", inst, pid)); - /* - * Tell current DM to get ready - */ - if (drm->drm_shr_pid != 0) { - DMD_DEBUG((CE_NOTE, "[%d:%d] signaling DM %d", - inst, pid, drm->drm_shr_pid)); - if (proc_signal(drm->drm_shr_proc_ref, SIGUSR2)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_close_tdv :" - "Can't signal DM %d", - inst, pid, drm->drm_shr_pid)); - } - } - drm->drm_shr_flags &= ~DRM_SHR_WAIT_TDV_CLOSE; - } else { - (void) memset(&drm->drm_shr_req, 0, sizeof (drm_request_t)); - drm->drm_shr_req.drm_req_type = DRM_REQ_CLOSE; - (void) dmd_signal_drm(drm); - } - tdv->tdv_flags &= ~(TDV_FATAL | TDV_MOVED); - drm->drm_shr_tdv_pid = 0; - drm->drm_shr_flags &= ~DRM_SHR_WAIT_TDV_CLOSE; - DMD_DEC_OPENS(); - if (xmutex) { - mutex_exit(&drm->drm_shr_mutex); - } - TDV_UNBUSY(tdv); - return (0); -} - -static int -dmd_read(dev_t dev, struct uio *uiop, cred_t *credp) -{ - int rc = 0; - dmd_soft_state_t *ss; - dmd_drm_t *drm; - dmd_tdv_t *tdv; - minor_t minor = getminor(dev); - int inst = dmd_minor_to_inst(minor); - pid_t pid = ddi_get_pid(); - - /* - * Only drive managers and target drives can do read/write. - */ - if (DMD_WCR(inst) || DMD_STAT(inst)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_read: " - "read not supported for watcher and stat devices", - inst, pid)); - return (ENOTSUP); - } - ss = ddi_get_soft_state(dmd_soft_statep, inst); - if (ss == NULL) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_read: " - "Can't get state, minor %d", - inst, pid, minor)); - return (ENXIO); - } - DMD_BUSY(); - if (DMD_DRM(inst)) { - drm = &ss->ss_drm; - drm->drm_cur_pid = pid; - drm->drm_inst = inst; - rc = dmd_read_drm(drm, uiop, credp); - } else { - /* - * tdv read - */ - tdv = &ss->ss_tdv; - tdv->tdv_cur_pid = pid; - tdv->tdv_inst = inst; - rc = dmd_read_tdv(tdv, uiop, credp); - } - DMD_UNBUSY(); - return (rc); -} - -static int -dmd_read_drm(dmd_drm_t *drm, struct uio *uiop, cred_t *credp) -{ - int rc = 0; - int inst = drm->drm_inst; - pid_t pid = drm->drm_cur_pid; - - DRM_BUSY(drm); - if (drm->drm_shr_pid != ddi_get_pid()) { - /* - * Only allow the process which opened the device - */ - DRM_UNBUSY(drm); - DMD_UNBUSY(); - return (EACCES); - } - rc = ldi_read(drm->drm_shr_lhdl, uiop, credp); - if (rc != 0) { - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_read_drm: " - "read returns %d", inst, pid, rc)); - } - DRM_UNBUSY(drm); - return (rc); -} - -static int -dmd_read_tdv(dmd_tdv_t *tdv, struct uio *uiop, cred_t *credp) -{ - int rc = 0; - dmd_drm_t *drm = tdv->tdv_drm; - int inst = tdv->tdv_inst; - pid_t pid = tdv->tdv_cur_pid; - int64_t iovlen; - int64_t resid; - int reqtype = 0; - - TDV_BUSY(tdv); - - mutex_enter(&drm->drm_shr_mutex); - if (drm->drm_shr_flags & DRM_SHR_WAIT_TDV_CLOSE) { - /* waiting for me to close */ - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_read_tdv: " - "no associated DM", inst, pid)); - rc = ENXIO; - goto done; - } - - if (drm->drm_shr_flags & DRM_SHR_WAIT_RESUME) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_read_tdv: " - "Waiting for resume", inst, pid)); - rc = EBUSY; - goto done; - } - - /* - * Check for MMS mode - */ - if ((tdv->tdv_flags & TDV_MMS_MODE) == 0) { - /* - * Not in MMS mode, no processing by drive manager - */ - mutex_exit(&drm->drm_shr_mutex); - rc = ldi_read(drm->drm_shr_lhdl, uiop, credp); - mutex_enter(&drm->drm_shr_mutex); - } else if (tdv->tdv_flags & TDV_FATAL) { - /* Fatal error, no movement cmds */ - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_read_tdv: " - "FATAL set, Returning EIO", inst, pid)); - rc = EIO; - goto done; - } else { - /* - * For fixed mode, I/O size must be multiple - * of max blksize. - * For variable mode, I/O size must be <= max blksize. - */ - iovlen = uiop->uio_iov->iov_len; - if (iovlen > drm->drm_shr_max_blksize) { - if (drm->drm_shr_flags & DRM_SHR_FIXED) { - if (iovlen % drm->drm_shr_max_blksize) { - DMD_DEBUG((CE_NOTE, - "[%d:%d] dmd_read_tdv: " - "read size (%lld) " - "not multiple of " - "max size (%d)", - inst, pid, - (long long)iovlen, - drm->drm_shr_max_blksize)); - rc = EINVAL; - goto done; - } - } else { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_read_tdv: " - "read size (%lld) " - "greater than max size (%d)", - inst, pid, (long long)iovlen, - drm->drm_shr_max_blksize)); - rc = EINVAL; - goto done; - } - } - /* - * In MMS mode, need drive manager processing - */ - if (tdv->tdv_flags & TDV_NOTIFY_READ) { - /* Notify read only works once */ - tdv->tdv_flags &= ~TDV_NOTIFY_READ; - (void) memset(&drm->drm_shr_req, 0, - sizeof (drm_request_t)); - drm->drm_shr_req.drm_req_type = DRM_REQ_READ; - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_read_tdv: " - "Signal for READ\n", inst, pid)); - rc = dmd_signal_drm(drm); - if (rc == 0) { - rc = drm->drm_shr_rep.drm_rep_rc; - } - } - if (rc == 0) { - mutex_exit(&drm->drm_shr_mutex); - rc = ldi_read(drm->drm_shr_lhdl, uiop, credp); - mutex_enter(&drm->drm_shr_mutex); - tdv->tdv_flags |= TDV_MOVED; - resid = uiop->uio_resid; - if (resid > 0) { - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_read_tdv: " - "Read returns: " - "len = %lld, resid = %lld, rc = %d\n", - inst, pid, - (long long)iovlen, (long long)resid, rc)); - } - /* - * Count number of bytes/blks read - */ - tdv->tdv_rdbytes += (iovlen - uiop->uio_resid); - if (drm->drm_shr_flags & DRM_SHR_FIXED) { - tdv->tdv_blkcnt += - ((iovlen - uiop->uio_resid) / - drm->drm_shr_max_blksize); - } else if (iovlen - uiop->uio_resid) { - /* Read a block */ - tdv->tdv_blkcnt++; - } - /* - * Signal drive manager if in MMS mode - */ - if (rc == 0 && - uiop->uio_resid == iovlen) { - /* - * If ldi_read returns 0 and did not - * read any bytes, then we must have - * read a tapemark. - */ - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_read_tdv: " - "Signal for READ_TM\n", inst, pid)); - reqtype = DRM_REQ_READ_TM; - } else if (rc != 0) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_read_tdv: " - "Signal for READ_ERR", inst, pid)); - reqtype = DRM_REQ_READ_ERR; - } - if (reqtype != 0) { - /* Notify DM */ - (void) memset(&drm->drm_shr_req, 0, - sizeof (drm_request_t)); - drm->drm_shr_req.drm_err_req.drm_errno = rc; - drm->drm_shr_req.drm_err_req.drm_resid = - uiop->uio_resid; - /* Read new status */ - drm->drm_shr_req.drm_req_type = reqtype; - rc = dmd_signal_drm(drm); - if (rc == 0) { - rc = drm->drm_shr_rep.drm_rep_rc; - } - } - } - } -done: - mutex_exit(&drm->drm_shr_mutex); - if (rc != 0) { - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_read_tdv: " - "read returns %d", inst, pid, rc)); - } - TDV_UNBUSY(tdv); - return (rc); -} - -static int -dmd_write(dev_t dev, struct uio *uiop, cred_t *credp) -{ - int rc = 0; - dmd_soft_state_t *ss; - dmd_drm_t *drm; - dmd_tdv_t *tdv; - minor_t minor = getminor(dev); - int inst = dmd_minor_to_inst(minor); - pid_t pid = ddi_get_pid(); - - if (DMD_WCR(inst) || DMD_STAT(inst)) { - return (ENOTSUP); - } - ss = ddi_get_soft_state(dmd_soft_statep, inst); - if (ss == NULL) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_write: Can't get state", - inst, pid)); - return (ENXIO); - } - DMD_BUSY(); - if (DMD_DRM(inst)) { - drm = &ss->ss_drm; - drm->drm_cur_pid = pid; - drm->drm_inst = inst; - rc = dmd_write_drm(drm, uiop, credp); - } else { - tdv = &ss->ss_tdv; - tdv->tdv_cur_pid = pid; - tdv->tdv_inst = inst; - rc = dmd_write_tdv(tdv, uiop, credp); - } - DMD_UNBUSY(); - return (rc); -} - -static int -dmd_write_drm(dmd_drm_t *drm, struct uio *uiop, cred_t *credp) -{ - int rc = 0; - int inst = drm->drm_inst; - pid_t pid = drm->drm_cur_pid; - - DRM_BUSY(drm); - mutex_enter(&drm->drm_shr_mutex); - if (drm->drm_shr_pid != drm->drm_busy) { - /* - * Only allow the process which opened the device - */ - mutex_exit(&drm->drm_shr_mutex); - DRM_UNBUSY(drm); - return (EACCES); - } - mutex_exit(&drm->drm_shr_mutex); - rc = ldi_write(drm->drm_shr_lhdl, uiop, credp); - if (rc != 0) { - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_write_drm: " - "read returns %d", inst, pid, rc)); - } - DRM_UNBUSY(drm); - return (rc); -} - -static int -dmd_write_tdv(dmd_tdv_t *tdv, struct uio *uiop, cred_t *credp) -{ - int rc = 0; - dmd_drm_t *drm = tdv->tdv_drm; - int inst = tdv->tdv_inst; - pid_t pid = tdv->tdv_cur_pid; - int reqtype; - int64_t iovlen; - int64_t resid; - - TDV_BUSY(tdv); - mutex_enter(&drm->drm_shr_mutex); - - if (drm->drm_shr_flags & DRM_SHR_WAIT_TDV_CLOSE) { - /* waiting for me to close */ - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_write_tdv: " - "no associated DM", inst, pid)); - rc = ENXIO; - goto done; - } - - if (drm->drm_shr_flags & DRM_SHR_WAIT_RESUME) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_write_tdv: " - "Waiting for resume", inst, pid)); - rc = EBUSY; - goto done; - } - - /* - * Check for MMS mode - */ - if ((tdv->tdv_flags & TDV_MMS_MODE) == 0) { - /* - * Not in MMS mode, no processing by drive manager - */ - mutex_exit(&drm->drm_shr_mutex); - rc = ldi_write(drm->drm_shr_lhdl, uiop, credp); - mutex_enter(&drm->drm_shr_mutex); - } else if (tdv->tdv_flags & TDV_FATAL) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_write_tdv: " - "FATAL set, Returning EIO", inst, pid)); - rc = EIO; - goto done; - } else { - /* - * For fixed mode, I/O size must be multiple - * of max blksize. - * For variable mode, I/O size must be <= max blksize. - */ - iovlen = uiop->uio_iov->iov_len; - if (iovlen > drm->drm_shr_max_blksize) { - if (drm->drm_shr_flags & DRM_SHR_FIXED) { - if (iovlen % drm->drm_shr_max_blksize) { - DMD_DEBUG((CE_NOTE, - "[%d:%d] dmd_write_tdv: " - "write size (%lld) " - "not multiple of " - "max size (%d)", inst, pid, - (long long)iovlen, - drm->drm_shr_max_blksize)); - rc = EINVAL; - goto done; - } - } else { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_write_tdv: " - "write size (%lld) " - "greater than max size (%d)", inst, pid, - (long long)iovlen, - drm->drm_shr_max_blksize)); - rc = EINVAL; - goto done; - } - } - /* - * MMS mode, need drive manager processing - */ - if (tdv->tdv_flags & TDV_NOTIFY_WRITE) { - /* Notify write only works once */ - tdv->tdv_flags &= ~TDV_NOTIFY_WRITE; - (void) memset(&drm->drm_shr_req, 0, - sizeof (drm_request_t)); - /* Read new status */ - drm->drm_shr_req.drm_req_type = DRM_REQ_WRITE; - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_write_tdv: " - "Signal for WRITE\n", inst, pid)); - rc = dmd_signal_drm(drm); - if (rc == 0) { - rc = drm->drm_shr_rep.drm_rep_rc; - } - } - if (rc == 0) { - mutex_exit(&drm->drm_shr_mutex); - rc = ldi_write(drm->drm_shr_lhdl, uiop, credp); - mutex_enter(&drm->drm_shr_mutex); - tdv->tdv_flags |= TDV_MOVED; - resid = uiop->uio_resid; - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_write_tdv: " - "Write returns: " - "len = %lld, resid = %lld, rc = %d\n", inst, pid, - (long long)iovlen, (long long)resid, rc)); - /* - * Count number of blks/bytes written - */ - tdv->tdv_wrbytes += (iovlen - uiop->uio_resid); - if (drm->drm_shr_flags & DRM_SHR_FIXED) { - tdv->tdv_blkcnt += - ((iovlen - uiop->uio_resid) / - drm->drm_shr_max_blksize); - } else { - tdv->tdv_blkcnt++; - } - reqtype = 0; - if (rc == 0 && - uiop->uio_resid == iovlen) { - /* - * ldi_write returns 0 and did not write - * any bytes. - */ - DMD_DEBUG((CE_NOTE, "[%d:%d] Signal for WRITE0", - inst, pid)); - reqtype = DRM_REQ_WRITE0; - } else if (rc != 0) { - DMD_DEBUG((CE_NOTE, - "[%d:%d] dmd_write_tdv: " - "Signal for WRITE_ERR", inst, pid)); - reqtype = DRM_REQ_WRITE_ERR; - } - if (reqtype != 0) { - /* Notify DM */ - (void) memset(&drm->drm_shr_req, 0, - sizeof (drm_request_t)); - drm->drm_shr_req.drm_err_req.drm_errno = rc; - drm->drm_shr_req.drm_err_req.drm_resid = - uiop->uio_resid; - /* Read new status */ - drm->drm_shr_req.drm_req_type = reqtype; - rc = dmd_signal_drm(drm); - if (rc == 0) { - rc = drm->drm_shr_rep.drm_rep_rc; - } - } - } - } -done: - mutex_exit(&drm->drm_shr_mutex); - if (rc != 0) { - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_write_tdv: " - "read returns %d", inst, pid, rc)); - } - TDV_UNBUSY(tdv); - return (rc); -} - -static int -dmd_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp, int *rvalp) -{ - dmd_soft_state_t *ss; - int rc = 0; - int minor = getminor(dev); - int inst = dmd_minor_to_inst(minor); - pid_t pid = ddi_get_pid(); - dmd_wcr_t *wcr; - dmd_drm_t *drm; - dmd_tdv_t *tdv; - dmd_stat_t *stat; - - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl: minor = 0x%x\n", - inst, pid, minor)); - - ss = ddi_get_soft_state(dmd_soft_statep, inst); - if (ss == NULL) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl: " - "Can't get state", inst, pid)); - return (ENXIO); - } - - if (DMD_WCR(inst)) { - wcr = &ss->ss_wcr; - wcr->wcr_cur_pid = pid; - wcr->wcr_inst = inst; - rc = dmd_ioctl_wcr(wcr, cmd, arg); - } else { - DMD_BUSY(); - if (DMD_STAT(inst)) { - stat = &ss->ss_stat; - stat->stat_cur_pid = pid; - stat->stat_inst = inst; - rc = dmd_ioctl_stat(stat, cmd, arg, mode); - } else if (DMD_DRM(inst)) { - drm = &ss->ss_drm; - drm->drm_cur_pid = pid; - drm->drm_inst = inst; - rc = dmd_ioctl_drm(drm, cmd, arg, mode, - credp, rvalp); - } else { - tdv = &ss->ss_tdv; - tdv->tdv_cur_pid = pid; - tdv->tdv_inst = inst; - rc = dmd_ioctl_tdv(tdv, cmd, arg, mode, rvalp); - } - DMD_UNBUSY(); - } - - return (rc); -} - -static int -dmd_ioctl_wcr(dmd_wcr_t *wcr, int cmd, intptr_t arg) -{ - int newinst; /* for the new device */ - dev_info_t *dip; - char devname[20]; - int rc = 0; - dmd_drm_t *drm; - dmd_tdv_t *tdv; - dmd_soft_state_t *ss; - int ord = (int)arg; - int inst = wcr->wcr_inst; - pid_t pid = wcr->wcr_cur_pid; - - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_wcr: entered\n", inst, pid)); - if (wcr->wcr_pid != ddi_get_pid()) { - /* - * Only allow the process which opened the device - */ - return (EACCES); - } - switch (cmd) { - case WCR_ADD_DEV: - /* - * Configure a drive manager and its target device - * arg - ordinal of device. - */ - - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_wcr: WCR_ADD_DEV\n", - inst, pid)); - newinst = 2 * ord; - /* - * Validate the ordinal - */ - if (ord < DMD_FIRST_DEV_ORDINAL || ord > dmd_next_ord) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_wcr: " - "WCR_ADD_DEV, " - "invalid device ordinal %d", inst, pid, ord)); - rc = EINVAL; - goto done; - } else if (ord < dmd_next_ord) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_wcr: " - "WCR_ADD_DEV, " - "device ordinal %d already added", inst, pid, ord)); - ss = ddi_get_soft_state(dmd_soft_statep, newinst); - if (ss == NULL) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_wcr: " - "Can't get state structure, inst = %d", - inst, pid, newinst)); - rc = ENXIO; - goto done; - } - drm = &ss->ss_drm; - /* - * Ensure that the device is not bound - */ - if ((drm->drm_flags & DRM_DEV_ADDED) == 0) { - rc = EEXIST; - goto done; - } - drm->drm_flags |= DRM_DEV_ADDED; - rc = 0; - goto done; - } - /* - * Dm and target devices have their own soft state. - */ - dip = NULL; - (void) DRM_DEVNAME(ord, devname); - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_wcr: " - "Creating device %s", newinst, pid, devname)); - if (rc = dmd_create_dev(wcr, devname, newinst, - (dmd_soft_state_t **)&drm, &dip)) { - goto done; - } - drm->drm_inst = newinst; - drm->drm_dip = dip; - /* - * Create the target device soft state - */ - dip = NULL; - if (rc = dmd_create_dev(wcr, NULL, newinst + 1, - (dmd_soft_state_t **)&tdv, &dip)) { - ddi_soft_state_free(dmd_soft_statep, newinst); - ddi_remove_minor_node(dip, devname); - goto done; - } - tdv->tdv_inst = newinst + 1; - tdv->tdv_dip = dip; - - tdv->tdv_drm = drm; - drm->drm_tdv = tdv; - dmd_next_ord++; - - drm->drm_flags |= DRM_DEV_ADDED; - break; - -default: - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_wcr: " - "invalid ioctl command: 0x%x", inst, pid, cmd)); - rc = EINVAL; - goto done; - } -done: - if (rc != 0) { - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_wcr: " - "ioctl returns %d", inst, pid, rc)); - } - return (rc); -} - -static int -dmd_create_dev(dmd_wcr_t *wcr, char *devname, int inst, dmd_soft_state_t **rss, - dev_info_t **rdip) -{ - dmd_soft_state_t *ss; - dev_info_t *dip = *rdip; - minor_t minor = dmd_inst_to_minor(inst); - pid_t pid; - - *rss = NULL; - if (wcr == NULL) { - pid = (pid_t)(-1); - } else { - pid = wcr->wcr_cur_pid; - } - - if (ddi_soft_state_zalloc(dmd_soft_statep, inst) != DDI_SUCCESS) { - cmn_err(CE_WARN, "[%d:%d] dmd_create_dev: " - "Unable to allocate dmd_soft_statep", inst, pid); - return (ENOMEM); - } - - ss = ddi_get_soft_state(dmd_soft_statep, inst); - if (ss == NULL) { - cmn_err(CE_WARN, "[%d:%d] dmd_create_dev: " - "Can't get state structure", inst, pid); - ddi_soft_state_free(dmd_soft_statep, inst); - return (ENXIO); - } - (void) memset(ss, 0, sizeof (dmd_soft_state_t)); - if (DMD_WCR(inst)) { - mutex_init(&ss->ss_wcr.wcr_mutex, NULL, MUTEX_DRIVER, NULL); - } else if (DMD_STAT(inst)) { - mutex_init(&ss->ss_stat.stat_mutex, NULL, MUTEX_DRIVER, NULL); - } else if (DMD_DRM(inst)) { - mutex_init(&ss->ss_drm.drm_mutex, NULL, MUTEX_DRIVER, NULL); - cv_init(&ss->ss_drm.drm_busy_cv, NULL, CV_DRIVER, NULL); - } else { - mutex_init(&ss->ss_tdv.tdv_mutex, NULL, MUTEX_DRIVER, NULL); - cv_init(&ss->ss_tdv.tdv_busy_cv, NULL, CV_DRIVER, NULL); - } - if (dip == NULL) { - dip = ddi_find_devinfo(ddi_major_to_name(dmd_major), 0, 0); - if (dip == NULL) { - cmn_err(CE_WARN, "[%d:%d] dmd_create_dev: " - "no watcher info", inst, pid); - ddi_soft_state_free(dmd_soft_statep, inst); - return (ENXIO); - } - ddi_release_devi(dip); - } - - /* - * If not target device, create the device - */ - if (devname != NULL) { - if (ddi_create_minor_node(dip, devname, S_IFCHR, minor, - DDI_PSEUDO, 0) != DDI_SUCCESS) { - cmn_err(CE_WARN, "[%d:%d] dmd_create_dev: " - "Can't create minor node %d", - inst, pid, minor); - ddi_soft_state_free(dmd_soft_statep, inst); - return (ENXIO); - } - } - *rss = ss; - if (*rdip == NULL) - *rdip = dip; - return (0); -} - -static int -dmd_ioctl_stat(dmd_stat_t *stat, int cmd, intptr_t arg, int mode) -{ - int rc = 0; - int num; - int inst = stat->stat_inst; - pid_t pid = stat->stat_cur_pid; - - switch (cmd) { - case DMD_STAT_NDEV: - DMD_DEBUG((CE_CONT, - "[%d:%d] dmd_ioctl_stat: ioctl DMD_STAT_NDEV\n", - inst, pid)); - /* - * Return number of devices. arg must be (uint32_t *) - */ - num = 2 * dmd_next_ord; - if (ddi_copyout(&num, (void *)arg, sizeof (uint32_t), - mode)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_stat: " - "copyout error", inst, pid)); - rc = EFAULT; - goto done; - } - break; - - case DMD_STAT_INFO: - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_stat: " - "ioctl DMD_STAT_INFO\n", - inst, pid)); - if ((rc = dmd_stat_info(stat, arg, mode)) != 0) { - goto done; - } - break; - - case DMD_STAT_CLEAR: - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_stat: " - "ioctl DMD_STAT_CLEAR\n", - inst, pid)); - break; - } -done: - if (rc != 0) { - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_stat: " - "ioctl returns %d", inst, pid, rc)); - } - return (rc); -} - -static int -dmd_stat_info(dmd_stat_t *stat, intptr_t arg, int mode) -{ - dmd_stat_dev_t di; - dmd_stat_info_t ii; - dmd_stat_dev_t *dp; - dmd_stat_info_t *ip; - dmd_stat_dev_t *udp; - char *cp; - dmd_wcr_t *wcr; - dmd_drm_t *drm; - dmd_tdv_t *tdv; - int num; - dmd_soft_state_t *ss; - int inst = stat->stat_inst; - pid_t pid = stat->stat_cur_pid; - - ip = ⅈ - dp = &di; - if (ddi_copyin((void *)arg, ip, sizeof (dmd_stat_info_t), mode)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_stat_info: " - "copyin error", inst, pid)); - return (EFAULT); - } - - num = ip->stat_num; - if (ip->stat_num > (dmd_next_ord * 2)) { - num = dmd_next_ord * 2; - } - ip->stat_num = num; - ip->stat_dmd_busy = dmd_busy; - - if (ddi_copyout(ip, (void *)arg, sizeof (dmd_stat_info_t), mode)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_stat_info: " - "copyout error", inst, pid)); - return (EFAULT); - } - - cp = (char *)arg + ((char *)(ip->stat_dev) - (char *)ip); - udp = (dmd_stat_dev_t *)cp; - - for (inst = 0; inst < num; inst++) { - (void) memset(dp, 0, sizeof (dmd_stat_dev_t)); - ss = ddi_get_soft_state(dmd_soft_statep, inst); - if (ss == NULL) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_stat: " - "Can't get state", inst, pid)); - return (ENXIO); - } - - dp->stat_inst = inst; - if (DMD_WCR(inst)) { - wcr = &ss->ss_wcr; - wcr->wcr_cur_pid = pid; - wcr->wcr_inst = inst; - dmd_stat_info_wcr(wcr, dp); - } else if (DMD_DRM(inst)) { - drm = &ss->ss_drm; - drm->drm_cur_pid = pid; - drm->drm_inst = inst; - dmd_stat_info_drm(drm, dp); - } else if (DMD_TDV(inst)) { - tdv = &ss->ss_tdv; - tdv->tdv_cur_pid = pid; - tdv->tdv_inst = inst; - dmd_stat_info_tdv(tdv, dp); - } else { - dp->stat_flags |= STAT_STAT; - } - - if (ddi_copyout(dp, udp + inst, sizeof (dmd_stat_dev_t), - mode)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_stat_info: " - "copyout error", inst, pid)); - return (EFAULT); - } - } - - return (0); -} - -static void -dmd_stat_info_wcr(dmd_wcr_t *wcr, dmd_stat_dev_t *dp) -{ - dp->stat_flags |= STAT_WCR; - if (wcr->wcr_pid) { /* watcher opened */ - dp->stat_flags |= STAT_OPENED; - dp->stat_pid = wcr->wcr_pid; - } -} - -static void -dmd_stat_info_drm(dmd_drm_t *drm, dmd_stat_dev_t *dp) -{ - dp->stat_flags |= STAT_DRM; - if (drm->drm_shr_pid) { /* DM opened */ - dp->stat_flags |= STAT_OPENED; - dp->stat_pid = drm->drm_shr_pid; - } - if (drm->drm_shr_lhdl) { /* LDI opened */ - dp->stat_flags |= STAT_LDI_OPENED; - } - if (drm->drm_shr_flags & DRM_SHR_WAIT_RESUME) { - dp->stat_flags |= STAT_WAIT_RESUME; - } - dp->stat_targ_major = getmajor(drm->drm_targ_dev); - dp->stat_targ_minor = getminor(drm->drm_targ_dev); - dp->stat_busy_pid = drm->drm_busy; -} - -static void -dmd_stat_info_tdv(dmd_tdv_t *tdv, dmd_stat_dev_t *dp) -{ - dmd_drm_t *drm = tdv->tdv_drm; - - dp->stat_flags |= STAT_TDV; - if (drm->drm_shr_tdv_pid) { /* target opened */ - dp->stat_flags |= STAT_OPENED; - dp->stat_pid = drm->drm_shr_tdv_pid; - } - dp->stat_targ_minor = tdv->tdv_minor; - dp->stat_busy_pid = tdv->tdv_busy; -} - -static int -dmd_ioctl_drm(dmd_drm_t *drm, int cmd, intptr_t arg, - int mode, cred_t *credp, int *rvalp) -{ - int rc = 0; - dmd_tdv_t *tdv = drm->drm_tdv; - drm_target_t targ; - drm_blksize_t blksize; - struct mtop mtop; - struct mtlop mtlop; - char tmp[10]; - int scsicmd; - char *cp; - int inst = drm->drm_inst; - pid_t pid = drm->drm_cur_pid; - drm_probe_dev_t ino; - - DRM_BUSY(drm); - /* - * Save ioctl mode for later use - */ - drm->drm_ioctl_mode = mode; - drm->drm_ioctl_credp = credp; - mutex_enter(&drm->drm_shr_mutex); - - if (drm->drm_shr_pid != ddi_get_pid()) { - /* - * Only allow the process which opened the device - */ - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_drm: DM pid = %d ", - inst, pid, drm->drm_shr_pid)); - rc = EACCES; - goto done; - } - switch (cmd) { - case DRM_BIND_DEV : - /* - * Bind a real dev to target dev - */ - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: " - "DRM_BIND_DEV ioctl\n", - inst, pid)); - /* - * Error if waiting for tdv to close - */ - if (drm->drm_shr_flags & DRM_SHR_WAIT_TDV_CLOSE) { - DMD_DEBUG((CE_NOTE, - "[%d:%d] dmd_ioctl_drm: waiting for tdv close", - inst, pid)); - rc = EMFILE; - goto done; - } - /* - * Proceed if target dev is not busy - */ - if (drm->drm_shr_lhdl) { - /* already bound */ - rc = EBUSY; - goto done; - } - - if (ddi_copyin((void *)arg, &targ, sizeof (drm_target_t), 0)) { - DMD_DEBUG((CE_NOTE, - "[%d:%d] dmd_ioctl_drm: copyin error", - inst, pid)); - rc = EFAULT; - goto done; - } - rc = dmd_bind_dev(drm, &targ, credp); - break; - case DRM_REBIND_DEV : - /* - * Rebind a target dev - */ - DMD_DEBUG((CE_CONT, - "[%d:%d] dmd_ioctl_drm: DRM_REBIND_DEV ioctl\n", - inst, pid)); - /* - * Error if waiting for tdv to close - */ - if (drm->drm_shr_flags & DRM_SHR_WAIT_TDV_CLOSE) { - DMD_DEBUG((CE_NOTE, - "[%d:%d] dmd_ioctl_drm: waiting for pid %d " - "to close", - inst, pid, drm->drm_shr_tdv_pid)); - rc = EMFILE; - goto done; - } - /* - * Proceed if target dev is bound - */ - if (drm->drm_shr_lhdl == NULL) { - /* Not bound */ - DMD_DEBUG((CE_NOTE, - "[%d:%d] dmd_ioctl_drm: " - "no handle to target device", - inst, pid)); - rc = ENXIO; - goto done; - } - - if (ddi_copyin((void *)arg, &targ, sizeof (drm_target_t), 0)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_drm: " - "copyin error", - inst, pid)); - rc = EFAULT; - goto done; - } - (void) dmd_ldi_close(drm, credp); - rc = dmd_bind_dev(drm, &targ, credp); - break; - case DRM_REQUEST : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: " - "DRM_REQUEST ioctl\n", inst, pid)); - if ((drm->drm_shr_flags & DRM_SHR_REQ_VALID) == 0) { - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: " - "no request\n", inst, pid)); - rc = ENOMSG; - goto done; - } - if (rc = ddi_copyout(&drm->drm_shr_req, (void *)arg, - sizeof (drm_request_t), mode)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_drm: " - "copyout error", - inst, pid)); - rc = EFAULT; - goto done; - } - drm->drm_shr_flags &= ~DRM_SHR_REQ_VALID; - cv_broadcast(&drm->drm_shr_res_cv); - break; - - case DRM_RESUME : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: DRM_RESUME ioctl\n", - inst, pid)); - if (drm->drm_shr_flags & DRM_SHR_WAIT_RESUME) { - drm->drm_shr_flags &= ~DRM_SHR_WAIT_RESUME; - if (ddi_copyin((void *)arg, &drm->drm_shr_rep, - sizeof (drm_reply_t), 0)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_drm: " - "copyin error", inst, pid)); - rc = EFAULT; - goto done; - } - cv_broadcast(&drm->drm_shr_res_cv); - } - break; - - case DRM_MMS_MODE : - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_drm: DRM_MMS_MODE ioctl", - inst, pid)); - /* Set/unset MMS mode */ - if (drm->drm_shr_tdv_pid != 0) { - /* Can't set MMS mode after file is opened by user */ - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_drm: " - "can't set mms mode, file opened", inst, pid)); - rc = EACCES; - goto done; - } - - if ((int)arg > 0) { - tdv->tdv_flags |= TDV_MMS_MODE; - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: " - "MMS mode is ON\n", inst, pid)); - } else { - tdv->tdv_flags &= ~TDV_MMS_MODE; - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: " - "MMS mode is OFF\n", inst, pid)); - } - break; - - case DRM_BLKSIZE : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: " - "DRM_BLKSIZE ioctl\n", - inst, pid)); - if (ddi_copyin((void *)arg, &blksize, - sizeof (drm_blksize_t), 0)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_drm: " - "copyin error", inst, pid)); - rc = EFAULT; - goto done; - } - if (blksize.drm_fixed) { - drm->drm_shr_flags |= DRM_SHR_FIXED; - } else { - drm->drm_shr_flags &= ~DRM_SHR_FIXED; - } - drm->drm_shr_max_blksize = (uint32_t)blksize.drm_blksize; - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: " - "max blksize = %lld\n", - inst, pid, (long long)blksize.drm_blksize)); - break; - - case DRM_TARG_MINOR : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: " - "DRM_BLKSIZE ioctl\n", - inst, pid)); - tdv->tdv_minor = (minor_t)arg; - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: " - "target minor = %x\n", - inst, pid, tdv->tdv_minor)); - break; - - case DRM_DM_READY : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: " - "DRM_DM_READY ioctl: %s\n", - inst, pid, arg != 0 ? "DM ready" : "DM not ready")); - if (arg != 0) { - drm->drm_flags |= DRM_READY; - } else { - drm->drm_flags &= ~DRM_READY; - } - break; - - case DRM_PROBE_DEV : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: " - "DRM_PROBE_DEV ioctl\n", - inst, pid)); - if (ddi_copyin((void *)arg, &ino, - sizeof (drm_probe_dev_t), 0)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_drm: " - "copyin error", inst, pid)); - rc = EFAULT; - goto done; - } - rc = dmd_probe_device(drm, &ino); - break; - - case USCSICMD : - if (rc = dmd_get_uscsicmd(&scsicmd, arg, mode)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_drm: " - "USCSICMD error", inst, pid)); - return (rc); - } - if ((cp = dmd_lookup(dmd_scsi_cmd_tab, scsicmd)) == NULL) { - (void) snprintf(tmp, sizeof (tmp), "0x%x", scsicmd); - cp = tmp; - } - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: USCSICMD, %s\n", - inst, pid, cp)); - mutex_exit(&drm->drm_shr_mutex); - rc = ldi_ioctl(drm->drm_shr_lhdl, cmd, arg, mode, credp, rvalp); - mutex_enter(&drm->drm_shr_mutex); - if (rc != 0) { - DMD_DEBUG((CE_CONT, "[%d:%d] ldi_ioctl_drm: " - "returns %d\n", inst, pid, rc)); - } - break; - - case DRM_PRSV_KEY : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: " - "DRM_PRSV_KEY ioctl\n", - inst, pid)); - if (ddi_copyin((char *)arg, drm->drm_prsv_key, 8, 0)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_drm: " - "copyin error", inst, pid)); - rc = EFAULT; - goto done; - } - break; - - case DRM_DISALLOWED_CMDS : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: " - "DRM_DISALLOWED_CMDS " - "ioctl\n", inst, pid)); - rc = dmd_get_disallowed(drm, arg, tdv->tdv_disallowed_cmds, - mode); - break; - - case DRM_DISALLOWED_IOCTLS : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: " - "DRM_DISALLOWED_IOCTLS " - "ioctl\n", inst, pid)); - rc = dmd_get_disallowed(drm, arg, tdv->tdv_disallowed_ioctls, - mode); - break; - - case DRM_TDV_PID : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: DRM_TDV_PID " - "ioctl\n", inst, pid)); - if (rc = ddi_copyout(&drm->drm_shr_tdv_pid, (void *)arg, - sizeof (uint32_t), mode)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_drm: " - "copyout error", inst, pid)); - rc = EFAULT; - goto done; - } - break; - - default: - if (cmd == MTIOCTOP) { - if ((rc = dmd_get_mtop(&mtop, arg, mode)) != 0) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_drm: " - "can't get mtop", inst, pid)); - goto done; - } - cp = dmd_lookup(dmd_mtop_tab, mtop.mt_op); - if (cp == NULL) { - (void) snprintf(tmp, sizeof (tmp), - "0x%2x", mtop.mt_op); - cp = tmp; - } - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: " - "ioctl MTIOCTOP, %s\n", inst, pid, cp)); - } else if (cmd == MTIOCLTOP) { - if ((rc = dmd_get_mtlop(&mtlop, arg, mode)) != 0) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_drm: " - "can't get mtlop", inst, pid)); - goto done; - } - cp = dmd_lookup(dmd_mtop_tab, mtop.mt_op); - if (cp == NULL) { - (void) snprintf(tmp, sizeof (tmp), - "0x%2x", mtlop.mt_op); - cp = tmp; - } - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: " - "ioctl MTIOCLTOP, %s\n", inst, pid, cp)); - } else { - cp = dmd_lookup(dmd_ioctl_tab, cmd); - if (strcmp(cp, "UNKNOWN") == 0) { - (void) snprintf(tmp, sizeof (tmp), - "UNKNOWN 0x%2x", cmd); - cp = tmp; - } - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm:ioctl %s\n", - inst, pid, cp)); - } - mutex_exit(&drm->drm_shr_mutex); - rc = ldi_ioctl(drm->drm_shr_lhdl, cmd, arg, mode, credp, rvalp); - mutex_enter(&drm->drm_shr_mutex); - DMD_DEBUG((CE_CONT, "[%d:%d] ldi_ioctl returns %d, rval %d\n", - inst, pid, rc, *rvalp)); - - break; - } - -done: - mutex_exit(&drm->drm_shr_mutex); - if (rc != 0) { - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_drm: " - "ioctl returns %d", inst, pid, rc)); - } - DRM_UNBUSY(drm); - return (rc); -} - -static int -dmd_ioctl_tdv(dmd_tdv_t *tdv, int cmd, intptr_t arg, int mode, int *rvalp) -{ - int inst = tdv->tdv_inst; - pid_t pid = tdv->tdv_cur_pid; - dmd_drm_t *drm = tdv->tdv_drm; - int rc = 0; - struct mtop mtop; - struct mtlop mtlop; - char tmp[10]; - char *cp; - - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: enter\n", inst, pid)); - TDV_BUSY(tdv); - mutex_enter(&drm->drm_shr_mutex); - - if (drm->drm_shr_flags & DRM_SHR_WAIT_RESUME) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_tdv: " - "Waiting for resume", inst, pid)); - rc = EBUSY; - goto done; - } - - switch (cmd) { - /* - * Check for supported ioctl for both MMS and RAW modes - */ - case MMS_BLK_LIMIT : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: MMS_BLK_LIMIT\n", - inst, pid)); - rc = dmd_blk_limit(tdv, arg, mode); - break; - case MMS_GET_POS : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: MMS_GET_POS\n", - inst, pid)); - rc = dmd_get_pos(tdv, arg, mode); - break; - case MMS_LOCATE : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: MMS_LOCATE\n", - inst, pid)); - rc = dmd_locate(tdv, arg, mode); - break; - case MMS_GET_CAPACITY : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: MMS_GET_CAPACITY\n", - inst, pid)); - rc = dmd_get_capacity(tdv, arg, mode); - break; - case MMS_UPDATE_CAPACITY : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: " - "MMS_UPDATE_CAPACITY\n", inst, pid)); - rc = dmd_upt_capacity(tdv); - break; - case MMS_GET_DENSITY : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: MMS_GET_DENSITY\n", - inst, pid)); - rc = dmd_get_density(tdv, arg, mode); - break; - case MMS_SET_DENSITY : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: MMS_SET_DENSITY\n", - inst, pid)); - rc = dmd_set_density(tdv, arg); - break; - - case USCSICMD : - /* - * Only some SCSI commands allowed by the DM are supported. - */ - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: USCSICMD ioctl\n", - inst, pid)); - rc = dmd_chk_allowed_cmd(tdv, cmd, arg, mode, rvalp); - break; - - default : - if (cmd == MTIOCTOP) { - if ((rc = dmd_get_mtop(&mtop, arg, mode)) != 0) { - goto done; - } - cp = dmd_lookup(dmd_mtop_tab, mtop.mt_op); - if (cp == NULL) { - (void) snprintf(tmp, sizeof (tmp), - "0x%2x", mtop.mt_op); - cp = tmp; - } - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: " - "ioctl MTIOCTOP, %s\n", inst, pid, cp)); - } else if (cmd == MTIOCLTOP) { - if ((rc = dmd_get_mtlop(&mtlop, arg, mode)) != 0) { - goto done; - } - cp = dmd_lookup(dmd_mtop_tab, mtop.mt_op); - if (cp == NULL) { - (void) snprintf(tmp, sizeof (tmp), - "0x%2x", mtop.mt_op); - cp = tmp; - } - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: " - "ioctl MTIOCLTOP, %s\n", inst, pid, cp)); - } else { - cp = dmd_lookup(dmd_ioctl_tab, cmd); - if (cp == NULL) { - (void) snprintf(tmp, sizeof (tmp), - "0x%2x", cmd); - cp = tmp; - } - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: ioctl %s\n", - inst, pid, cp)); - } - - /* - * Only forward allowed ioctl to target driver - */ - if (DMD_MASK_SET(tdv->tdv_disallowed_ioctls, cmd - MTIOC)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ioctl_tdv: " - "ioctl %s not allowed " - "in raw mode", inst, pid, cp)); - rc = EACCES; - goto done; - } - - if ((tdv->tdv_flags & TDV_MMS_MODE) == 0) { - /* - * Not in MMS mode, pass to target driver - */ - mutex_exit(&drm->drm_shr_mutex); - rc = ldi_ioctl(drm->drm_shr_lhdl, cmd, arg, - mode, /* drm->drm_ioctl_mode, */ - drm->drm_ioctl_credp, - rvalp); - mutex_enter(&drm->drm_shr_mutex); - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: " - "ldi_ioctl %s " - "returns %d\n", inst, pid, cp, rc)); - break; - } else { - /* - * In MMS mode, notify drive manager - */ - switch (cmd) { - case MTIOCTOP : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: " - "MTIOCTOP\n", inst, pid)); - rc = dmd_mtioctop(tdv, arg, mode, &mtop); - break; - case MTIOCLTOP : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: " - "MTIOCLTOP\n", inst, pid)); - rc = dmd_mtiocltop(tdv, arg, mode, &mtlop); - break; - case MTIOCGET : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: " - "MTIOCGET\n", inst, pid)); - rc = dmd_mtiocget(tdv, arg, mode); - break; - case MTIOCGETPOS : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: " - "MTIOCGETPOS\n", inst, pid)); - rc = dmd_mtgetpos(tdv, arg, mode); - break; - case MTIOCRESTPOS : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: " - "MTIOCRESTPOS\n", inst, pid)); - rc = dmd_mtrestpos(tdv, arg, mode); - break; - case MTIOCLRERR : - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: " - "MTIOCLRERR\n", inst, pid)); - rc = dmd_mtioclrerr(tdv); - break; - - default: - mutex_exit(&drm->drm_shr_mutex); - rc = ldi_ioctl(drm->drm_shr_lhdl, cmd, arg, - mode, /* drm->drm_ioctl_mode, */ - drm->drm_ioctl_credp, - rvalp); - mutex_enter(&drm->drm_shr_mutex); - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: " - "ldi_ioctl %s returns %d\n", - inst, pid, cp, rc)); - break; - } - } - } -done: - TDV_UNBUSY(tdv); - if (rc != 0) { - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ioctl_tdv: " - "ioctl returns %d", inst, pid, rc)); - } - mutex_exit(&drm->drm_shr_mutex); - return (rc); -} - -static int -dmd_get_disallowed(dmd_drm_t *drm, intptr_t arg, uchar_t *mask, int mode) -{ - int inst = drm->drm_inst; - pid_t pid = drm->drm_cur_pid; - - if (ddi_copyin((void *)arg, mask, DMD_DISALLOWED_MASK_SIZE, mode)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_get_disallowed: " - "copyin error", inst, pid)); - return (EFAULT); - } - - return (0); -} - -static int -dmd_chk_allowed_cmd(dmd_tdv_t *tdv, int cmd, intptr_t arg, - int mode, int *rvalp) -{ - dmd_drm_t *drm = tdv->tdv_drm; - int scsi_cmd; - int rc = 0; - char *cp; - char tmp[10]; - int inst = tdv->tdv_inst; - pid_t pid = tdv->tdv_cur_pid; - - if ((rc = dmd_get_uscsicmd(&scsi_cmd, arg, mode)) != 0) { - return (rc); - } - if ((cp = dmd_lookup(dmd_scsi_cmd_tab, scsi_cmd)) == NULL) { - (void) snprintf(tmp, sizeof (tmp), "0x%x", scsi_cmd); - cp = tmp; - } - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_chk_allowed_cmd: " - "USCSI command is %s\n", inst, pid, cp)); - - /* - * Only cmds that are allowed are forwarded to ST - */ - if (DMD_MASK_NOT_SET(tdv->tdv_disallowed_cmds, scsi_cmd)) { - mutex_exit(&drm->drm_shr_mutex); - rc = ldi_ioctl(drm->drm_shr_lhdl, cmd, arg, - mode, /* drm->drm_ioctl_mode, */ - drm->drm_ioctl_credp, - rvalp); - mutex_enter(&drm->drm_shr_mutex); - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_chk_allowed_cmd: " - "ldi_ioctl returns %d\n", inst, pid, rc)); - } else { - /* Command not allowed */ - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_chk_allowed_cmd: " - "USCSI command not allowed: %s", inst, pid, cp)); - rc = EACCES; - } - - return (rc); -} - -static int -dmd_probe_device(dmd_drm_t *drm, drm_probe_dev_t *ino) -{ - int i; - dmd_soft_state_t *ss; - dmd_drm_t *dm; - - mutex_enter(&dmd_sync_mutex); /* get exclusive control */ - if (ino->drm_dev == 0) { - /* Unset ino */ - drm->drm_probe_dev = 0; - } else { - /* - * Set ino - make sure no other DM has set the same ino. - * If another DM has set the same ino, then return EBUSY. - */ - for (i = DMD_FIRST_DEV_ORDINAL; i < dmd_next_ord; i++) { - ss = ddi_get_soft_state(dmd_soft_statep, i * 2); - if (ss == NULL) { - continue; - } - dm = &ss->ss_drm; - if (dm == drm) { /* myself */ - continue; - } - if (dm->drm_shr_pid) { - /* Only check opened DM's */ - if (dm->drm_probe_dev == ino->drm_dev) { - mutex_exit(&dmd_sync_mutex); - return (EBUSY); - } - } - } - /* - * No other DM has set the same ino - */ - drm->drm_probe_dev = ino->drm_dev; - } - mutex_exit(&dmd_sync_mutex); - return (0); -} - -static int -dmd_mtioctop(dmd_tdv_t *tdv, intptr_t arg, int mode, struct mtop *mtop) -{ - dmd_drm_t *drm = tdv->tdv_drm; - int rc = 0; - int inst = drm->drm_inst; - pid_t pid = drm->drm_cur_pid; - - (void) memset(&drm->drm_shr_req, 0, sizeof (drm_request_t)); - drm->drm_shr_req.drm_req_type = DRM_REQ_MTIOCTOP; - drm->drm_shr_req.drm_mtop_req.drm_op = mtop->mt_op; - drm->drm_shr_req.drm_mtop_req.drm_count = mtop->mt_count; - - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_mtioctop: Signal for MTIOCTOP\n", - inst, pid)); - rc = dmd_signal_drm(drm); - mtop->mt_op = drm->drm_shr_rep.drm_mtop_rep.drm_op; - mtop->mt_count = drm->drm_shr_rep.drm_mtop_rep.drm_count; - rc = dmd_return_mtop(mtop, arg, mode); - if (rc == 0) { - rc = drm->drm_shr_rep.drm_rep_rc; - } - return (rc); -} - -static int -dmd_mtiocltop(dmd_tdv_t *tdv, intptr_t arg, int mode, struct mtlop *mtlop) -{ - dmd_drm_t *drm = tdv->tdv_drm; - int rc = 0; - int inst = drm->drm_inst; - pid_t pid = drm->drm_cur_pid; - - (void) memset(&drm->drm_shr_req, 0, sizeof (drm_request_t)); - drm->drm_shr_req.drm_req_type = DRM_REQ_MTIOCLTOP; - drm->drm_shr_req.drm_mtop_req.drm_op = mtlop->mt_op; - drm->drm_shr_req.drm_mtop_req.drm_count = mtlop->mt_count; - - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_mtiocltop: Signal for MTIOCLTOP\n", - inst, pid)); - rc = dmd_signal_drm(drm); - mtlop->mt_op = drm->drm_shr_rep.drm_mtop_rep.drm_op; - mtlop->mt_count = drm->drm_shr_rep.drm_mtop_rep.drm_count; - rc = dmd_return_mtlop(mtlop, arg, mode); - if (rc == 0) { - rc = drm->drm_shr_rep.drm_rep_rc; - } - return (rc); -} - -static int -dmd_mtiocget(dmd_tdv_t *tdv, intptr_t arg, int mode) -{ - dmd_drm_t *drm = tdv->tdv_drm; - int rc = 0; - int inst = tdv->tdv_inst; - pid_t pid = tdv->tdv_cur_pid; -#ifdef _MULTI_DATAMODEL - /* - * For use when a 32 bit app makes a call into a - * 64 bit ioctl - */ - struct mtget32 mtg_local32; - struct mtget32 *mtget_32 = &mtg_local32; -#endif /* _MULTI_DATAMODEL */ - struct mtget mtget_local; - struct mtget *mtget = &mtget_local; - - (void) memset(&drm->drm_shr_req, 0, sizeof (drm_request_t)); - drm->drm_shr_req.drm_req_type = DRM_REQ_MTGET; - - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_mtiocget: Signal for MTIOCGET\n", - inst, pid)); - rc = dmd_signal_drm(drm); - if (rc == 0) { - rc = drm->drm_shr_rep.drm_rep_rc; - } - - if (rc != 0) { - return (rc); - } - - mtget->mt_erreg = drm->drm_shr_rep.drm_mtget_rep.drm_erreg; - mtget->mt_resid = drm->drm_shr_rep.drm_mtget_rep.drm_resid; - mtget->mt_dsreg = drm->drm_shr_rep.drm_mtget_rep.drm_dsreg; - mtget->mt_fileno = drm->drm_shr_rep.drm_mtget_rep.drm_fileno; - mtget->mt_blkno = drm->drm_shr_rep.drm_mtget_rep.drm_blkno; - mtget->mt_type = drm->drm_shr_rep.drm_mtget_rep.drm_type; - mtget->mt_flags = drm->drm_shr_rep.drm_mtget_rep.drm_mt_flags; - mtget->mt_bf = drm->drm_shr_rep.drm_mtget_rep.drm_mt_bf; - - if (drm->drm_shr_rep.drm_mtget_rep.drm_blkno_dir) { - mtget->mt_blkno |= DRM_BLKNO_DIR_MASK; - } - -#ifdef _MULTI_DATAMODEL - - switch (ddi_model_convert_from(mode & FMODELS)) { - case DDI_MODEL_ILP32: - /* - * Convert 64 bit back to 32 bit before doing - * copyout. This is what the ILP32 app expects. - */ - mtget_32->mt_erreg = mtget->mt_erreg; - mtget_32->mt_resid = mtget->mt_resid; - mtget_32->mt_dsreg = mtget->mt_dsreg; - mtget_32->mt_fileno = mtget->mt_fileno; - mtget_32->mt_blkno = mtget->mt_blkno; - mtget_32->mt_type = mtget->mt_type; - mtget_32->mt_flags = mtget->mt_flags; - mtget_32->mt_bf = mtget->mt_bf; - - if (drm->drm_shr_rep.drm_mtget_rep.drm_blkno_dir) { - mtget_32->mt_blkno |= 0x80000000; - } - - if (ddi_copyout(mtget_32, (void *)arg, - sizeof (struct mtget32), mode)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_mtiocget: " - "copyout error", inst, pid)); - rc = EFAULT; - } - break; - - case DDI_MODEL_NONE: - if (ddi_copyout(mtget, (void *)arg, - sizeof (struct mtget), mode)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_mtiocget: " - "copyout error", inst, pid)); - rc = EFAULT; - } - break; - } -#else /* ! _MULTI_DATAMODE */ - if (ddi_copyout(mtget, (void *)arg, sizeof (struct mtget), mode)) { - rc = EFAULT; - } -#endif /* _MULTI_DATAMODE */ - - return (rc); -} - -static int -dmd_mtgetpos(dmd_tdv_t *tdv, intptr_t arg, int mode) -{ - dmd_drm_t *drm = tdv->tdv_drm; - int rc = 0; - int inst = tdv->tdv_inst; - pid_t pid = tdv->tdv_cur_pid; - - (void) memset(&drm->drm_shr_req, 0, sizeof (drm_request_t)); - drm->drm_shr_req.drm_req_type = DRM_REQ_MTGETPOS; - - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_mtgetpos: Signal for MTIOCGETPOS\n", - inst, pid)); - rc = dmd_signal_drm(drm); - if (rc == 0) { - rc = drm->drm_shr_rep.drm_rep_rc; - } - - if (rc != 0) { - return (rc); - } - - if (ddi_copyout(&drm->drm_shr_rep.drm_mtpos_rep, - (void *)arg, sizeof (tapepos_t), mode)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_mtgetpos: " - "copyout error", inst, pid)); - rc = EFAULT; - } - - return (rc); -} - -static int -dmd_mtrestpos(dmd_tdv_t *tdv, intptr_t arg, int mode) -{ - dmd_drm_t *drm = tdv->tdv_drm; - int rc = 0; - int inst = tdv->tdv_inst; - pid_t pid = tdv->tdv_cur_pid; - - (void) memset(&drm->drm_shr_req, 0, sizeof (drm_request_t)); - drm->drm_shr_req.drm_req_type = DRM_REQ_MTRESTPOS; - - if (ddi_copyin((void *)arg, &drm->drm_shr_req.drm_mtpos_req, - sizeof (tapepos_t), mode)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_mtrestpos: " - "copyin error", inst, pid)); - rc = EFAULT; - } - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_mtrestpos: Signal for MTIOCRESTPOS\n", - inst, pid)); - rc = dmd_signal_drm(drm); - if (rc == 0) { - rc = drm->drm_shr_rep.drm_rep_rc; - } - - if (rc != 0) { - return (rc); - } - - return (rc); -} - -static int -dmd_get_pos(dmd_tdv_t *tdv, intptr_t arg, int mode) -{ - dmd_drm_t *drm = tdv->tdv_drm; - int rc = 0; - int inst = tdv->tdv_inst; - pid_t pid = tdv->tdv_cur_pid; - - (void) memset(&drm->drm_shr_req, 0, sizeof (drm_request_t)); - drm->drm_shr_req.drm_req_type = DRM_REQ_GET_POS; - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_get_pos: Signal for DRM_REQ_GET_POS\n", - inst, pid)); - rc = dmd_signal_drm(drm); - if (rc == 0) { - rc = drm->drm_shr_rep.drm_rep_rc; - } - - if (rc != 0) { - return (rc); - } - - if (ddi_copyout(&drm->drm_shr_rep.drm_pos_rep, (mms_pos_t *)arg, - sizeof (mms_pos_t), mode)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_get_pos: " - "copyout error", inst, pid)); - rc = EFAULT; - } - - return (rc); -} - -static int -dmd_locate(dmd_tdv_t *tdv, intptr_t arg, int mode) -{ - dmd_drm_t *drm = tdv->tdv_drm; - int rc = 0; - int inst = tdv->tdv_inst; - pid_t pid = tdv->tdv_cur_pid; - - (void) memset(&drm->drm_shr_req, 0, sizeof (drm_request_t)); - drm->drm_shr_req.drm_req_type = DRM_REQ_LOCATE; - - if (ddi_copyin((mms_pos_t *)arg, &drm->drm_shr_req.drm_pos_req, - sizeof (mms_pos_t), mode)) { - return (EFAULT); - } - - DMD_DEBUG((CE_NOTE, "[%d:%d] Signal for DRM_REQ_LOCATE", inst, pid)); - rc = dmd_signal_drm(drm); - if (rc == 0) { - rc = drm->drm_shr_rep.drm_rep_rc; - } - - return (rc); -} - -static int -dmd_get_capacity(dmd_tdv_t *tdv, intptr_t arg, int mode) -{ - dmd_drm_t *drm = tdv->tdv_drm; - int rc = 0; - int inst = tdv->tdv_inst; - pid_t pid = tdv->tdv_cur_pid; - - (void) memset(&drm->drm_shr_req, 0, sizeof (drm_request_t)); - drm->drm_shr_req.drm_req_type = DRM_REQ_GET_CAPACITY; - - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_get_capacity: " - "Signal for DRM_REQ_GET_CAPACITY\n", inst, pid)); - rc = dmd_signal_drm(drm); - if (rc == 0) { - rc = drm->drm_shr_rep.drm_rep_rc; - } - - if (rc != 0) { - return (rc); - } - - if (ddi_copyout(&drm->drm_shr_rep.drm_cap_rep, - (mms_capacity_t *)arg, sizeof (mms_capacity_t), mode)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_get_capacity: " - "copyout error", inst, pid)); - rc = EFAULT; - } - - return (rc); -} - -static int -dmd_upt_capacity(dmd_tdv_t *tdv) -{ - dmd_drm_t *drm = tdv->tdv_drm; - int rc = 0; - int inst = tdv->tdv_inst; - pid_t pid = tdv->tdv_cur_pid; - - (void) memset(&drm->drm_shr_req, 0, sizeof (drm_request_t)); - drm->drm_shr_req.drm_req_type = DRM_REQ_UPT_CAPACITY; - - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_upt_capacity: " - "Signal for DRM_REQ_UPT_CAPACITY", inst, pid)); - rc = dmd_signal_drm(drm); - if (rc == 0) { - rc = drm->drm_shr_rep.drm_rep_rc; - } - - return (rc); -} - -static int -dmd_get_density(dmd_tdv_t *tdv, intptr_t arg, - int mode) -{ - dmd_drm_t *drm = tdv->tdv_drm; - int rc = 0; - mms_density_t den; - int inst = tdv->tdv_inst; - pid_t pid = tdv->tdv_cur_pid; - - (void) memset(&drm->drm_shr_req, 0, sizeof (drm_request_t)); - drm->drm_shr_req.drm_req_type = DRM_REQ_GET_DENSITY; - - DMD_DEBUG((CE_NOTE, "[%d:%d] Signal for DRM_REQ_GET_DENSITY", - inst, pid)); - rc = dmd_signal_drm(drm); - if (rc == 0) { - rc = drm->drm_shr_rep.drm_rep_rc; - den.mms_den = drm->drm_shr_rep.drm_den_rep; - if (ddi_copyout(&den, (mms_density_t *)arg, - sizeof (mms_density_t), mode)) { - rc = EFAULT; - } - } - - return (rc); -} - -static int -dmd_set_density(dmd_tdv_t *tdv, intptr_t arg) -{ - dmd_drm_t *drm = tdv->tdv_drm; - int rc = 0; - mms_density_t den; - int inst = tdv->tdv_inst; - pid_t pid = tdv->tdv_cur_pid; - - if (ddi_copyin((void *)arg, &den, sizeof (mms_density_t), 0)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_set_density: " - "copyin error", inst, pid)); - return (EFAULT); - } - - (void) memset(&drm->drm_shr_req, 0, sizeof (drm_request_t)); - drm->drm_shr_req.drm_req_type = DRM_REQ_SET_DENSITY; - drm->drm_shr_req.drm_den_req = den.mms_den; - - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_set_density: " - "Signal for DRM_REQ_SET_DENSITY (0x%llx)\n", inst, pid, - (long long)drm->drm_shr_req.drm_den_req)); - rc = dmd_signal_drm(drm); - if (rc == 0) { - rc = drm->drm_shr_rep.drm_rep_rc; - } - - return (rc); -} - - - - - -static int -dmd_blk_limit(dmd_tdv_t *tdv, intptr_t arg, int mode) -{ - dmd_drm_t *drm = tdv->tdv_drm; - int rc = 0; - int inst = tdv->tdv_inst; - pid_t pid = tdv->tdv_cur_pid; - - (void) memset(&drm->drm_shr_req, 0, sizeof (drm_request_t)); - drm->drm_shr_req.drm_req_type = DRM_REQ_BLK_LIMIT; - - DMD_DEBUG((CE_CONT, "[%d:%d] Signal for DRM_REQ_BLK_LIMIT\n", - inst, pid)); - rc = dmd_signal_drm(drm); - if (rc == 0) { - rc = drm->drm_shr_rep.drm_rep_rc; - } - - if (rc != 0) { - return (rc); - } - - if (ddi_copyout(&drm->drm_shr_rep.drm_blk_limit_rep, - (mms_blk_limit_t *)arg, sizeof (mms_blk_limit_t), mode)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_blk_limit: " - "copyout error", inst, pid)); - rc = EFAULT; - } - - return (rc); -} - -static int -dmd_mtioclrerr(dmd_tdv_t *tdv) -{ - dmd_drm_t *drm = tdv->tdv_drm; - int rc = 0; - int inst = tdv->tdv_inst; - pid_t pid = tdv->tdv_cur_pid; - - (void) memset(&drm->drm_shr_req, 0, sizeof (drm_request_t)); - drm->drm_shr_req.drm_req_type = DRM_REQ_CLRERR; - - DMD_DEBUG((CE_CONT, "[%d:%d] Signal for DRM_REQ_CLRERR\n", inst, pid)); - rc = dmd_signal_drm(drm); - if (rc == 0) { - rc = drm->drm_shr_rep.drm_rep_rc; - } - return (rc); -} - -/* - * Some utility functions - */ - -static int -dmd_ldi_open(dmd_drm_t *drm, cred_t *cred) -{ - /* - * Do layer open of the target device - */ - int rc = 0; - int inst = drm->drm_inst; - pid_t pid = drm->drm_cur_pid; - - if (drm->drm_shr_lhdl == NULL) { - rc = ldi_ident_from_dev(drm->drm_targ_dev, &drm->drm_shr_li); - if (rc) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ldi_open: " - "can't get ldi ident, " - "target = (%d, %d)", inst, pid, - getmajor(drm->drm_targ_dev), - getminor(drm->drm_targ_dev))); - goto out; - } - mutex_exit(&drm->drm_shr_mutex); - rc = ldi_open_by_dev(&drm->drm_targ_dev, drm->drm_shr_otyp, - drm->drm_shr_oflags, cred, &drm->drm_shr_lhdl, - drm->drm_shr_li); - mutex_enter(&drm->drm_shr_mutex); - if (rc) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ldi_open: " - "can't ldi open, " - "target = (%d, %d)", inst, pid, - getmajor(drm->drm_targ_dev), - getminor(drm->drm_targ_dev))); - ldi_ident_release(drm->drm_shr_li); - goto out; - } - DMD_INC_OPENS(); - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ldi_open: " - "(%d:%d) opened\n", inst, pid, - getmajor(drm->drm_targ_dev), - getminor(drm->drm_targ_dev))); - } else { - rc = EBUSY; - } -out: - return (rc); -} - -static int -dmd_ldi_close(dmd_drm_t *drm, cred_t *cred) -{ - int rc = 0; - int inst = drm->drm_inst; - pid_t pid = drm->drm_cur_pid; - - if (drm->drm_shr_lhdl != NULL) { - if (rc = ldi_close(drm->drm_shr_lhdl, FREAD | FWRITE, cred)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_ldi_close: " - "ldi close error: " - "rc = %d: will continue to release ldi", - inst, pid, rc)); - } - DMD_DEC_OPENS(); - ldi_ident_release(drm->drm_shr_li); - drm->drm_shr_lhdl = NULL; - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_ldi_close: " - "(%d:%d) closed\n", inst, pid, - getmajor(drm->drm_targ_dev), - getminor(drm->drm_targ_dev))); - drm->drm_targ_dev = (dev_t)0; - } - - return (rc); -} - -static int -dmd_bind_dev(dmd_drm_t *drm, drm_target_t *targ, cred_t *credp) -{ - dmd_tdv_t *tdv = drm->drm_tdv; - int minor; - int rc = 0; - int inst = drm->drm_inst; - pid_t pid = drm->drm_cur_pid; - - minor = targ->drm_targ_minor; - if (drm->drm_targ_dev != 0) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_bind_dev: already ldi opened, " - "(%lld,%d)", inst, pid, - (long long)targ->drm_targ_major, minor)); - return (EBUSY); - } - - drm->drm_targ_dev = makedevice((major_t)targ->drm_targ_major, minor); - drm->drm_shr_oflags = targ->drm_targ_oflags; - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_bind_dev: bound dev (%lld,%d)\n", - inst, pid, - (long long)targ->drm_targ_major, minor)); - rc = dmd_ldi_open(drm, credp); - if (rc) { - drm->drm_targ_dev = 0; - return (rc); - } - /* - * Target dev is ready - */ - tdv = drm->drm_tdv; - tdv->tdv_flags |= TDV_BOUND; - return (0); -} - -/* - * Signal drive manager and wait for resume - */ -static int -dmd_signal_drm(dmd_drm_t *drm) -{ - dmd_tdv_t *tdv = drm->drm_tdv; - drm_reply_t *rep = &drm->drm_shr_rep; - int inst = drm->drm_inst; - pid_t pid = drm->drm_cur_pid; - clock_t to; - int rc = 0; - - /* - * Must hold drm->drm_shr_mutex on entry - */ - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_signal_drm: Signalling drm\n", - inst, pid)); - if (drm->drm_shr_pid == 0) { - DMD_DEBUG((CE_NOTE, "[%d:%d] No drive manager", inst, pid)); - return (ENXIO); - } - - if (drm->drm_shr_flags & DRM_SHR_WAIT_RESUME) { - /* Only one outstanding request allowed */ - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_signal_drm: " - "Has outstanding request", inst, pid)); - return (EBUSY); - } - - if (tdv->tdv_flags & TDV_MOVED) { - drm->drm_shr_req.drm_req_flags |= DRM_REQ_MOVED; - } - if (tdv->tdv_flags & TDV_NOTIFY_READ) { - drm->drm_shr_req.drm_req_flags |= DRM_REQ_NOTIFY_READ; - } - if (tdv->tdv_flags & TDV_NOTIFY_WRITE) { - drm->drm_shr_req.drm_req_flags |= DRM_REQ_NOTIFY_WRITE; - } - - drm->drm_shr_req.drm_req_rdbytes = tdv->tdv_rdbytes; - drm->drm_shr_req.drm_req_wrbytes = tdv->tdv_wrbytes; - drm->drm_shr_req.drm_req_blkcnt = tdv->tdv_blkcnt; - - DMD_DEBUG((CE_NOTE, "[%d:%d] Set DRM_SHR_WAIT_RESUME", inst, pid)); - drm->drm_shr_flags |= (DRM_SHR_WAIT_RESUME | DRM_SHR_REQ_VALID); - if (proc_signal(drm->drm_shr_proc_ref, SIGUSR1)) { - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_signal_drm: " - "Can't signal drive manager %d", - inst, pid, drm->drm_shr_pid)); - drm->drm_shr_flags &= - ~(DRM_SHR_WAIT_RESUME | DRM_SHR_REQ_VALID); - return (ENXIO); - } - /* - * Wait for DM to get request - */ - DMD_DEBUG((CE_CONT, "[%d:%d] Waiting for drive manager " - "to get request\n", inst, pid)); - - /* Seconds to wait for DM */ - to = drv_usectohz(DMD_WAIT_DM_GET_SEC * 1000000); - - while ((drm->drm_shr_flags & DRM_SHR_REQ_VALID) && - (drm->drm_shr_flags & DRM_SHR_WAIT_RESUME)) { - rc = cv_reltimedwait(&drm->drm_shr_res_cv, - &drm->drm_shr_mutex, to, TR_CLOCK_TICK); - if (rc == -1) { - /* timedout */ - DMD_DEBUG((CE_NOTE, "[%d:%d] dmd_signal_drm: " - "Timedout waiting for DM " - "to get request", inst, pid)); - drm->drm_shr_flags &= - ~(DRM_SHR_WAIT_RESUME | DRM_SHR_REQ_VALID); - return (ETIMEDOUT); - } - } - - /* - * Wait for resume - */ - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_signal_drm: " - "Waiting for drive manager to resume\n", - inst, pid)); - drm->drm_shr_flags &= ~DRM_SHR_REQ_VALID; - while (drm->drm_shr_flags & DRM_SHR_WAIT_RESUME) { - cv_wait(&drm->drm_shr_res_cv, &drm->drm_shr_mutex); - } - - /* Request resumed */ - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_signal_drm: " - "Resumed, rc = %lld\n", inst, pid, (long long)rep->drm_rep_rc)); - tdv->tdv_flags &= ~TDV_MOVED; - tdv->tdv_flags &= ~TDV_EOF; - - if (rep->drm_rep_flags & DRM_REP_FATAL) { - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_signal_drm: " - "Setting TDV_FATAL\n", inst, pid)); - tdv->tdv_flags |= TDV_FATAL; - } - if (rep->drm_rep_flags & DRM_REP_EOF) { - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_signal_drm: " - "Setting TDV_EOF\n", inst, pid)); - tdv->tdv_flags |= TDV_EOF; - } - - tdv->tdv_flags &= ~(TDV_NOTIFY_WRITE | TDV_NOTIFY_READ); - if (rep->drm_rep_flags & DRM_REP_NOTIFY_WRITE) { - tdv->tdv_flags |= TDV_NOTIFY_WRITE; - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_signal_drm: " - "Setting TDV_NOTIFY_WRITE\n", inst, pid)); - } - if (rep->drm_rep_flags & DRM_REP_NOTIFY_READ) { - tdv->tdv_flags |= TDV_NOTIFY_READ; - DMD_DEBUG((CE_CONT, "[%d:%d] dmd_signal_drm: " - "Setting TDV_NOTIFY_READ\n", inst, pid)); - } - - tdv->tdv_rdbytes = 0; - tdv->tdv_wrbytes = 0; - tdv->tdv_blkcnt = 0; - - return (0); -} diff --git a/usr/src/uts/common/io/mms/dmd/dmd.conf b/usr/src/uts/common/io/mms/dmd/dmd.conf deleted file mode 100644 index f7940855c5..0000000000 --- a/usr/src/uts/common/io/mms/dmd/dmd.conf +++ /dev/null @@ -1,27 +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. -# - - - -name="dmd" parent="pseudo" instance=0; diff --git a/usr/src/uts/common/io/mms/dmd/dmd_impl.h b/usr/src/uts/common/io/mms/dmd/dmd_impl.h deleted file mode 100644 index 6499c2bb4e..0000000000 --- a/usr/src/uts/common/io/mms/dmd/dmd_impl.h +++ /dev/null @@ -1,505 +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 __DMD_IMPL_H -#define __DMD_IMPL_H - - -#include <sys/scsi/targets/stdef.h> - -#ifdef __cplusplus -extern "C" { -#endif - -#include <mms_dmd.h> - -/* Begin: 32-bit align copyin() structs for amd64 only due to 32-bit x86 ABI */ -#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 -#pragma pack(8) -#endif - -#define DMD_DISALLOWED_MASK_SIZE (256 / 8) /* num of bytes for masks */ - -#define DMD_SET_MASK(mask, flag) \ - ((mask)[(flag) / 8] |= (1 << ((flag) % 8))) -#define DMD_UNSET_MASK(mask, flag) \ - ((mask)[(flag) / 8] &= ~(1 << ((flag) % 8))) -#define DMD_MASK_SET(mask, flag) \ - ((mask)[(flag) / 8] & (1 << ((flag) % 8))) -#define DMD_MASK_NOT_SET(mask, flag) (! DMD_MASK_SET(mask, flag)) -#define DMD_DEBUG(x) { if (dmd_debug) cmn_err x; } - -#define DMD_WAIT_DM_GET_SEC 30 /* seconds to wait for DM */ - -typedef struct drm_blksize { - uint64_t drm_fixed; /* 1 - fixed; 0 - variable */ - uint64_t drm_blksize; -} drm_blksize_t; - -typedef struct drm_target { - uint64_t drm_targ_oflags; - uint64_t drm_targ_major; - uint64_t drm_targ_minor; -} drm_target_t; - -typedef struct drm_open { - uint64_t drm_open_flags; - uint64_t drm_open_type; - uint64_t drm_open_minor; -} drm_open_t; - -typedef struct drm_err { - uint64_t drm_errno; - int64_t drm_resid; -} drm_err_t; - -typedef struct drm_mtop { - /* - * This is the fixed length (32 and 64 bits) version of - * struct mtop used by the st driver. - */ - uint64_t drm_op; - int64_t drm_count; -} drm_mtop_t; - -typedef struct drm_request { - uint64_t drm_req_rdbytes; - uint64_t drm_req_wrbytes; - uint64_t drm_req_blkcnt; - uint64_t drm_req_type; - uint64_t drm_req_flags; - uint64_t drm_req_pid; - uint64_t drm_req_uid; - union { - uint64_t drm_den; - drm_open_t drm_open; - drm_err_t drm_err; - drm_mtop_t drm_mtop; - mms_pos_t drm_pos; - tapepos_t drm_mtpos; /* define in stdef.h */ - } drm_req_u; -} drm_request_t; - -#define drm_den_req drm_req_u.drm_den -#define drm_open_req drm_req_u.drm_open -#define drm_err_req drm_req_u.drm_err -#define drm_mtop_req drm_req_u.drm_mtop -#define drm_pos_req drm_req_u.drm_pos -#define drm_mtpos_req drm_req_u.drm_mtpos - -#define DRM_REQ_NEW_STAT 0x01 /* Read new status */ -#define DRM_REQ_MOVED 0x02 /* tape moved */ -#define DRM_REQ_NOTIFY_READ 0x04 /* Notify read in effect */ -#define DRM_REQ_NOTIFY_WRITE 0x08 /* Notify write in effect */ - -#define DRM_REQ_NONE 0 /* No request to drm */ -#define DRM_REQ_OPEN 1 -#define DRM_REQ_CLOSE 3 -#define DRM_REQ_WRITE 4 -#define DRM_REQ_READ 5 -#define DRM_REQ_READ_TM 6 -#define DRM_REQ_READ_ERR 7 -#define DRM_REQ_WRITEERR 8 -#define DRM_REQ_MTIOCTOP 9 -#define DRM_REQ_MTGET 10 -#define DRM_REQ_WRITE0 11 -#define DRM_REQ_WRITE_ERR 12 -#define DRM_REQ_CLRERR 13 -#define DRM_REQ_BLK_LIMIT 14 -#define DRM_REQ_GET_POS 15 -#define DRM_REQ_LOCATE 16 -#define DRM_REQ_MOUNT_OPT 17 -#define DRM_REQ_GET_CAPACITY 18 -#define DRM_REQ_UPT_CAPACITY 19 -#define DRM_REQ_GET_DENSITY 20 -#define DRM_REQ_SET_DENSITY 21 -#define DRM_REQ_MTGETPOS 22 -#define DRM_REQ_MTRESTPOS 23 -#define DRM_REQ_MTIOCLTOP 24 - - -typedef struct drm_mtget { - /* - * This is the fixed length (32 and 64 bits) version of - * struct mtget used by the st driver. - */ - int64_t drm_type; /* type of magtape device */ - /* the following two registers are grossly device dependent */ - int64_t drm_dsreg; /* ``drive status'' register */ - int64_t drm_erreg; /* ``error'' register */ - /* optional error info. */ - uint64_t drm_resid; /* residual count */ - uint64_t drm_fileno; /* file number of current position */ - uint64_t drm_blkno; /* block number of current position */ - uint64_t drm_blkno_dir; /* direction */ - uint64_t drm_mt_flags; - int64_t drm_mt_bf; /* optimum blocking factor */ -} drm_mtget_t; - -#define DRM_BLKNO_DIR_MASK ((uint64_t)1 << (sizeof (daddr_t) * 8 - 1)) - -typedef struct drm_reply { - uint64_t drm_rep_flags; - uint64_t drm_rep_rc; - union { - uint64_t drm_den; - drm_mtget_t drm_mtget; - drm_mtop_t drm_mtop; - mms_blk_limit_t drm_blk_limit; - mms_pos_t drm_pos; - mms_capacity_t drm_cap; - tapepos_t drm_mtpos; /* define in stdef.h */ - } drm_rep_u; -} drm_reply_t; - -#define drm_den_rep drm_rep_u.drm_den -#define drm_mtget_rep drm_rep_u.drm_mtget -#define drm_mtop_rep drm_rep_u.drm_mtop -#define drm_blk_limit_rep drm_rep_u.drm_blk_limit -#define drm_pos_rep drm_rep_u.drm_pos -#define drm_mtpos_rep drm_rep_u.drm_mtpos -#define drm_cap_rep drm_rep_u.drm_cap - -#define DRM_REP_NOTIFY_WRITE 0x01 -#define DRM_REP_NOTIFY_READ 0x02 -#define DRM_REP_EOF 0x04 -#define DRM_REP_FATAL 0x08 - - -/* - * IOCTL to the watcher - */ -#define WCR_IOC (('W' << 24) | ('C' << 16) | ('R' << 8)) -#define WCR_ADD_DEV (WCR_IOC | 1) /* Add a new device */ - -/* - * IOCTL to the drive manager - */ - -#if defined(_SYSCALL32) - -typedef struct drm_allowed_cmds32 { - uint64_t drm_num; /* number of allowed cmds */ - caddr32_t drm_cmds; /* pointer to cmd array */ -} drm_allowed_cmds32_t; - -#define dmd_allowed_cmds_to_allowed_cmds32(ac, ac32) { \ - (ac32)->drm_num = (ac)->drm_num; \ - (ac32)->drm_cmds = (caddr32_t)(uintptr_t)(ac)->drm_cmds; \ - } - -#define dmd_allowed_cmds32_to_allowed_cmds(ac32, ac) { \ - (ac)->drm_num = (ac32)->drm_num; \ - (ac)->drm_cmds = (caddr_t)(uintptr_t)(ac32)->drm_cmds; \ - } - -#endif /* _SYSCALL32 */ - -#define DRM_IOC (('D' << 24) | ('R' << 16) | ('M' << 8)) -typedef enum drm_cmd { - DRM_BIND_DEV = DRM_IOC + 1, /* Bind pseudo to real dev */ - DRM_REQUEST, /* Get request from driver */ - DRM_RESUME, /* Resume the user */ - DRM_MMS_MODE, /* Set/unset MMS mode */ - DRM_BLKSIZE, /* Set max blksize */ - DRM_TARG_MINOR, /* Set target minor */ - DRM_DM_READY, /* Rebind a device */ - DRM_REBIND_DEV, /* Rebind a device */ - DRM_PRSV_KEY, /* Set prsv key */ - DRM_DISALLOWED_CMDS, /* Set disallowed scsi cmds */ - DRM_DISALLOWED_IOCTLS, /* Set disallowed scsi ioctls */ - DRM_PROBE_DEV, /* Probing this device */ - DRM_TDV_PID /* Get tdv's pid */ -} drm_cmd_t; - - - -/* - * Struct for DRM_SET_INO - */ -typedef struct drm_probe_dev { - uint64_t drm_dev; -} drm_probe_dev_t; - - - -#define DMD_FIRST_DM_MINOR 2 -#define DMD_NOT_READY 0 -#define DMD_READY 1 - -#define DMD_STATE(s) (dmd_state == (s)) - -#define DMD_FIRST_DEV_ORDINAL 1 - - -#define DRM_DEVNAME(ordinal, devname) \ - sprintf(devname, "%d%s", ordinal, DMD_DRM_NAME) - -#define DRM_MINOR_MASK 0xff - -#define DMD_WCR_NAME "watcher" -#define DMD_STAT_NAME "stat" -#define DMD_DRM_NAME "drm" -#define DMD_TDV_NAME "tdv" - -#define DMD_WCR(inst) (inst == 0) -#define DMD_STAT(inst) (inst == 1) -#define DMD_DRM(inst) (inst >= 2 && (inst & 1) == 0) -#define DMD_TDV(inst) (inst > 2 && (inst & 1) == 1) - -#define DMD_MAX_STAT 20 /* Max stat opens */ - -typedef struct dmd_stat_dev { - uint64_t stat_flags; - uint64_t stat_pid; /* pid if opened */ - uint64_t stat_inst; /* instance */ - uint64_t stat_targ_major; /* major of target */ - uint64_t stat_targ_minor; /* minor of target */ - uint64_t stat_busy_pid; /* pid using this */ - uint64_t stat_targ_drv; /* target driver */ -} dmd_stat_dev_t; - -/* - * stat_flags - */ -#define STAT_OPENED 0x01 -#define STAT_LDI_OPENED 0x02 -#define STAT_WCR 0x04 -#define STAT_DRM 0x08 -#define STAT_TDV 0x10 -#define STAT_STAT 0x20 -#define STAT_WAIT_RESUME 0x40 - - - -typedef struct dmd_stat_info { - uint64_t stat_num; /* number of devs */ - uint64_t stat_dmd_busy; - dmd_stat_dev_t stat_dev[1]; /* device status arr */ - /* - * When using DMD_STAT_INFO ioctl to get info, the amount of - * memory for the array must be large enough to hold the number - * of devices specified in stat_num. - * malloc(sizeof(dmd_stat_info_t) + - * (stat_num - 1) * sizeof(dmd_stat_dev_t)); - */ -} dmd_stat_info_t; -/* - * DMD stat ioctl - */ -#define DMD_STAT_INFO 1 /* get device info */ -#define DMD_STAT_CLEAR 2 /* clear all devs */ -#define DMD_STAT_NDEV 3 /* return num of dev */ - -/* End: 32-bit align copyin() structs for amd64 only due to 32-bit x86 ABI */ -#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 -#pragma pack() -#endif - -#ifdef _KERNEL - -typedef struct dmd_wcr { - uint32_t wcr_flags; - int wcr_inst; - dev_info_t *wcr_dip; /* dev_info pointer */ - pid_t wcr_pid; /* pid of process that opens */ - void *wcr_proc_ref; /* proc_ref for dm signal */ - kmutex_t wcr_mutex; - pid_t wcr_cur_pid; -} dmd_wcr_t; - -typedef struct dmd_stat { - uint32_t stat_flags; - int stat_inst; - dev_info_t *stat_dip; /* dev_info pointer */ - void *stat_proc_ref; /* proc_ref for dm signal */ - kmutex_t stat_mutex; - int stat_opens; /* num of dev's opened */ - kcondvar_t stat_opens0_cv; /* wait opens 0 */ - pid_t stat_pid; - pid_t stat_cur_pid; -} dmd_stat_t; - -typedef struct drm_share { - /* - * Data share with tdv - */ - uint32_t drm_share_flgs; - pid_t drm_share_pid; /* pid of process that opens */ - ldi_ident_t drm_share_li; /* layered driver ident */ - ldi_handle_t drm_share_lhdl; /* layered driver handle */ - void *drm_share_proc_ref; /* proc_ref for dm signal */ - kcondvar_t drm_share_res_cv; /* wait for drm resume */ - int drm_share_oflags; /* Open flags */ - cred_t *drm_share_cred; - int drm_share_otyp; /* Open types */ - drm_request_t drm_share_request; /* request to drive mgr */ - drm_reply_t drm_share_reply; /* reply from drm */ - kmutex_t drm_share_mutex; - uint32_t drm_share_max_blksize; /* max blocksize */ - pid_t drm_share_tdv_pid; /* pid of tdv */ -} drm_share_t; - -#define DRM_SHR_WAIT_RESUME 0x01 /* waiting for resume */ -#define DRM_SHR_REQ_VALID 0x02 /* request is valid */ -#define DRM_SHR_OPEN_FAILED 0x04 /* Tell DM - open failed */ -#define DRM_SHR_FIXED 0x08 /* fixed format read/write */ -#define DRM_SHR_WAIT_TDV_CLOSE 0x10 /* wait for tdv to close */ - -typedef struct dmd_drm { - uint32_t drm_flags; - int drm_inst; - dev_info_t *drm_dip; /* dev_info pointer */ - struct dmd_tdv *drm_tdv; /* target's state */ - dev_t drm_targ_dev; /* target's dev_t */ - pid_t drm_busy; /* device is busy */ - kcondvar_t drm_busy_cv; /* wait for not busy */ - kmutex_t drm_mutex; - drm_share_t drm_share; /* data share with tdv */ - int drm_ioctl_mode; - cred_t *drm_ioctl_credp; - pid_t drm_cur_pid; - uint64_t drm_probe_dev; /* dev being probed */ - /* must hold drm_sync_mutex */ - /* to change this field */ - struct uscsi_cmd drm_uscsi; - char drm_prsv_buf[24]; - char drm_prsv_key[8]; -} dmd_drm_t; - -#define DRM_READY 0x02 -#define DRM_DEV_ADDED 0x04 - -#define drm_shr_flags drm_share.drm_share_flgs -#define drm_shr_mutex drm_share.drm_share_mutex -#define drm_shr_pid drm_share.drm_share_pid -#define drm_shr_li drm_share.drm_share_li -#define drm_shr_lhdl drm_share.drm_share_lhdl -#define drm_shr_proc_ref drm_share.drm_share_proc_ref -#define drm_shr_res_cv drm_share.drm_share_res_cv -#define drm_shr_oflags drm_share.drm_share_oflags -#define drm_shr_cred drm_share.drm_share_cred -#define drm_shr_otyp drm_share.drm_share_otyp -#define drm_shr_req drm_share.drm_share_request -#define drm_shr_rep drm_share.drm_share_reply -#define drm_shr_max_blksize drm_share.drm_share_max_blksize -#define drm_shr_tdv_pid drm_share.drm_share_tdv_pid - - -typedef struct dmd_tdv { - uint32_t tdv_flags; - uint64_t tdv_rdbytes; /* Bytes read */ - uint64_t tdv_wrbytes; /* Bytes written */ - uint64_t tdv_blkcnt; /* blks written/read */ - int tdv_inst; - minor_t tdv_minor; /* target device minor */ - dev_info_t *tdv_dip; /* dev_info pointer */ - dmd_drm_t *tdv_drm; /* dm's state */ - uid_t tdv_uid; /* user's uid */ - uint64_t tdv_max_blksize; /* max blksize */ - pid_t tdv_busy; /* device is busy */ - kcondvar_t tdv_busy_cv; /* wait for not busy */ - kmutex_t tdv_mutex; - pid_t tdv_cur_pid; - uchar_t tdv_disallowed_cmds[DMD_DISALLOWED_MASK_SIZE]; - uchar_t tdv_disallowed_ioctls[DMD_DISALLOWED_MASK_SIZE]; -} dmd_tdv_t; - -#define TDV_BOUND 0x0002 -#define TDV_NOTIFY_WRITE 0x0004 -#define TDV_NOTIFY_READ 0x0008 -#define TDV_MMS_MODE 0x0010 -#define TDV_EOF 0x0020 -#define TDV_MOVED 0x0040 /* Tape moved since last */ - /* signaled DRM */ -#define TDV_FATAL 0x0080 /* Fatal, no movement cmd */ - -typedef union dmd_soft_state { - dmd_wcr_t ss_wcr; - dmd_stat_t ss_stat; - dmd_drm_t ss_drm; - dmd_tdv_t ss_tdv; -} dmd_soft_state_t; - - -#define DMD_BUSY() { \ - mutex_enter(&dmd_busy_mutex); \ - dmd_busy++; \ - mutex_exit(&dmd_busy_mutex); \ - } - -#define DMD_UNBUSY() { \ - mutex_enter(&dmd_busy_mutex); \ - dmd_busy--; \ - mutex_exit(&dmd_busy_mutex); \ - } - -#define DMD_INC_OPENS() DMD_BUSY() -#define DMD_DEC_OPENS() DMD_UNBUSY() - -#define DRM_BUSY(drm) { \ - mutex_enter(&(drm)->drm_mutex); \ - while ((drm)->drm_busy) { /* dev is busy */ \ - cmn_err(CE_NOTE, "DRM_BUSY: cv_wait for busy"); \ - cv_wait(&(drm)->drm_busy_cv, &(drm)->drm_mutex); \ - cmn_err(CE_NOTE, "back from cv_wait busy"); \ - } \ - (drm)->drm_busy = ddi_get_pid(); \ - mutex_exit(&(drm)->drm_mutex); \ - } - -#define DRM_UNBUSY(drm) { \ - mutex_enter(&(drm)->drm_mutex); \ - (drm)->drm_busy = 0; \ - cv_broadcast(&(drm)->drm_busy_cv); \ - mutex_exit(&(drm)->drm_mutex); \ - } - -#define TDV_BUSY(tdv) { \ - mutex_enter(&(tdv)->tdv_mutex); \ - while ((tdv)->tdv_busy) { /* dev is busy */ \ - cmn_err(CE_NOTE, "TDV_BUSY: cv_wait for busy"); \ - cv_wait(&(tdv)->tdv_busy_cv, &(tdv)->tdv_mutex); \ - cmn_err(CE_NOTE, "back from cv_wait busy"); \ - } \ - (tdv)->tdv_busy = ddi_get_pid(); \ - mutex_exit(&(tdv)->tdv_mutex); \ - } - -#define TDV_UNBUSY(tdv) { \ - mutex_enter(&(tdv)->tdv_mutex); \ - (tdv)->tdv_busy = 0; \ - cv_broadcast(&(tdv)->tdv_busy_cv); \ - mutex_exit(&(tdv)->tdv_mutex); \ - } - - -#endif /* _KERNEL */ - -#ifdef __cplusplus -} -#endif - -#endif /* __DMD_IMPL_H */ diff --git a/usr/src/uts/intel/Makefile.intel.shared b/usr/src/uts/intel/Makefile.intel.shared index 3c7e4def72..f6609e9e0e 100644 --- a/usr/src/uts/intel/Makefile.intel.shared +++ b/usr/src/uts/intel/Makefile.intel.shared @@ -1,27 +1,4 @@ -# -# 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) 2005, 2010, Oracle and/or its affiliates. All rights reserved. -# # # This makefile contains the common definitions for all intel @@ -230,11 +207,9 @@ DRV_KMODS += cpunex DRV_KMODS += crypto DRV_KMODS += cryptoadm DRV_KMODS += dca -DRV_KMODS += dda DRV_KMODS += devinfo DRV_KMODS += dld DRV_KMODS += dlpistub -DRV_KMODS += dmd DRV_KMODS_32 += dnet DRV_KMODS += dump DRV_KMODS += ecpp diff --git a/usr/src/uts/intel/dda/Makefile b/usr/src/uts/intel/dda/Makefile deleted file mode 100644 index 9437f38cd8..0000000000 --- a/usr/src/uts/intel/dda/Makefile +++ /dev/null @@ -1,87 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -#pragma ident "@(#)Makefile 1.2 08/06/30 SMI" - -# -# Path to the base of the uts directory tree (usually /usr/src/uts). -# -UTSBASE = ../.. - -# -# Define the module and object file sets. -# -MODULE = dda -OBJECTS = $(DDA_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(DDA_OBJS:%.o=$(LINTS_DIR)/%.ln) -ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) -CONF_SRCDIR = $(UTSBASE)/common/io/mms/dda - -# -# Include common rules. -# -include $(UTSBASE)/intel/Makefile.intel - -# -# Define targets -# -ALL_TARGET = $(BINARY) $(SRC_CONFILE) -LINT_TARGET = $(MODULE).lint -INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE) - -# -# Overrides -# -LINTTAGS += -erroff=E_BAD_PTR_CAST_ALIGN -LINTTAGS += -erroff=E_PTRDIFF_OVERFLOW - -CPPFLAGS += -I. -I$(SRC)/head - -# -# Default build targets. -# -.KEEP_STATE: - -def: $(DEF_DEPS) - -all: $(ALL_DEPS) - -clean: $(CLEAN_DEPS) - -clobber: $(CLOBBER_DEPS) - -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - -install: $(INSTALL_DEPS) - -# -# Include common targets. -# -include $(UTSBASE)/intel/Makefile.targ diff --git a/usr/src/uts/intel/dmd/Makefile b/usr/src/uts/intel/dmd/Makefile deleted file mode 100644 index 3dcdac25ac..0000000000 --- a/usr/src/uts/intel/dmd/Makefile +++ /dev/null @@ -1,87 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -#pragma ident "@(#)Makefile 1.2 08/06/30 SMI" - -# -# Path to the base of the uts directory tree (usually /usr/src/uts). -# -UTSBASE = ../.. - -# -# Define the module and object file sets. -# -MODULE = dmd -OBJECTS = $(DMD_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(DMD_OBJS:%.o=$(LINTS_DIR)/%.ln) -ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) -CONF_SRCDIR = $(UTSBASE)/common/io/mms/dmd - -# -# Include common rules. -# -include $(UTSBASE)/intel/Makefile.intel - -# -# Define targets -# -ALL_TARGET = $(BINARY) $(SRC_CONFILE) -LINT_TARGET = $(MODULE).lint -INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE) - -# -# Overrides -# -LINTTAGS += -erroff=E_BAD_PTR_CAST_ALIGN -LINTTAGS += -erroff=E_PTRDIFF_OVERFLOW - -CPPFLAGS += -I. -I$(SRC)/head -I$(SRC)/common/mms/mms -I$(SRC)/uts/common/io/mms/dmd - -# -# Default build targets. -# -.KEEP_STATE: - -def: $(DEF_DEPS) - -all: $(ALL_DEPS) - -clean: $(CLEAN_DEPS) - -clobber: $(CLOBBER_DEPS) - -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - -install: $(INSTALL_DEPS) - -# -# Include common targets. -# -include $(UTSBASE)/intel/Makefile.targ diff --git a/usr/src/uts/sparc/Makefile.sparc.shared b/usr/src/uts/sparc/Makefile.sparc.shared index ada0e7d643..3f45f2e703 100644 --- a/usr/src/uts/sparc/Makefile.sparc.shared +++ b/usr/src/uts/sparc/Makefile.sparc.shared @@ -1,26 +1,6 @@ -# -# 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) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + + # # This makefile contains the common definitions for all sparc # implementation architecture independent modules. @@ -299,8 +279,6 @@ DRV_KMODS += fcsm DRV_KMODS += fp DRV_KMODS += qlc DRV_KMODS += qlge -DRV_KMODS += dda -DRV_KMODS += dmd DRV_KMODS += stmf DRV_KMODS += stmf_sbd DRV_KMODS += fct diff --git a/usr/src/uts/sparc/dda/Makefile b/usr/src/uts/sparc/dda/Makefile deleted file mode 100644 index 3140283813..0000000000 --- a/usr/src/uts/sparc/dda/Makefile +++ /dev/null @@ -1,86 +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. -# - - -# -# Path to the base of the uts directory tree (usually /usr/src/uts). -# -UTSBASE = ../.. - -# -# Define the module and object file sets. -# -MODULE = dda -OBJECTS = $(DDA_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(DDA_OBJS:%.o=$(LINTS_DIR)/%.ln) -ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) -CONF_SRCDIR = $(UTSBASE)/common/io/mms/dda - -# -# Include common rules. -# -include $(UTSBASE)/sparc/Makefile.sparc - -# -# Define targets -# -ALL_TARGET = $(BINARY) $(SRC_CONFILE) -LINT_TARGET = $(MODULE).lint -INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE) - -# -# Overrides -# -LINTTAGS += -erroff=E_BAD_PTR_CAST_ALIGN -LINTTAGS += -erroff=E_PTRDIFF_OVERFLOW - -CPPFLAGS += -I. -I$(SRC)/head - -# -# Default build targets. -# -.KEEP_STATE: - -def: $(DEF_DEPS) - -all: $(ALL_DEPS) - -clean: $(CLEAN_DEPS) - -clobber: $(CLOBBER_DEPS) - -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - -install: $(INSTALL_DEPS) - -# -# Include common targets. -# -include $(UTSBASE)/sparc/Makefile.targ diff --git a/usr/src/uts/sparc/dmd/Makefile b/usr/src/uts/sparc/dmd/Makefile deleted file mode 100644 index 8d361e0264..0000000000 --- a/usr/src/uts/sparc/dmd/Makefile +++ /dev/null @@ -1,86 +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. -# - - -# -# Path to the base of the uts directory tree (usually /usr/src/uts). -# -UTSBASE = ../.. - -# -# Define the module and object file sets. -# -MODULE = dmd -OBJECTS = $(DMD_OBJS:%=$(OBJS_DIR)/%) -LINTS = $(DMD_OBJS:%.o=$(LINTS_DIR)/%.ln) -ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) -CONF_SRCDIR = $(UTSBASE)/common/io/mms/dmd - -# -# Include common rules. -# -include $(UTSBASE)/sparc/Makefile.sparc - -# -# Define targets -# -ALL_TARGET = $(BINARY) $(SRC_CONFILE) -LINT_TARGET = $(MODULE).lint -INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE) - -# -# Overrides -# -LINTTAGS += -erroff=E_BAD_PTR_CAST_ALIGN -LINTTAGS += -erroff=E_PTRDIFF_OVERFLOW - -CPPFLAGS += -I. -I$(SRC)/head -I$(SRC)/common/mms/mms -I$(SRC)/uts/common/io/mms/dmd - -# -# Default build targets. -# -.KEEP_STATE: - -def: $(DEF_DEPS) - -all: $(ALL_DEPS) - -clean: $(CLEAN_DEPS) - -clobber: $(CLOBBER_DEPS) - -lint: $(LINT_DEPS) - -modlintlib: $(MODLINTLIB_DEPS) - -clean.lint: $(CLEAN_LINT_DEPS) - -install: $(INSTALL_DEPS) - -# -# Include common targets. -# -include $(UTSBASE)/sparc/Makefile.targ |