summaryrefslogtreecommitdiff
path: root/usr/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib')
-rw-r--r--usr/src/lib/Makefile25
-rw-r--r--usr/src/lib/libsecdb/auth_attr.txt35
-rw-r--r--usr/src/lib/libsecdb/exec_attr.txt28
-rw-r--r--usr/src/lib/libsecdb/help/auths/AuthMMSDeviceLog.html37
-rw-r--r--usr/src/lib/libsecdb/help/auths/AuthMMSDeviceState.html37
-rw-r--r--usr/src/lib/libsecdb/help/auths/AuthMMSIORead.html37
-rw-r--r--usr/src/lib/libsecdb/help/auths/AuthMMSIOWrite.html37
-rw-r--r--usr/src/lib/libsecdb/help/auths/AuthMMSMedia.html37
-rw-r--r--usr/src/lib/libsecdb/help/auths/AuthMMSRequest.html37
-rw-r--r--usr/src/lib/libsecdb/help/auths/MMSHeader.html34
-rw-r--r--usr/src/lib/libsecdb/help/auths/Makefile35
-rw-r--r--usr/src/lib/libsecdb/help/auths/SmfManageMMS.html37
-rw-r--r--usr/src/lib/libsecdb/help/auths/SmfValueMMS.html37
-rw-r--r--usr/src/lib/libsecdb/help/profiles/Makefile31
-rw-r--r--usr/src/lib/libsecdb/help/profiles/RtMMSAdmin.html37
-rw-r--r--usr/src/lib/libsecdb/help/profiles/RtMMSOper.html37
-rw-r--r--usr/src/lib/libsecdb/help/profiles/RtMMSUser.html37
-rw-r--r--usr/src/lib/libsecdb/prof_attr.txt29
-rw-r--r--usr/src/lib/mms/Makefile58
-rw-r--r--usr/src/lib/mms/dm/Makefile59
-rw-r--r--usr/src/lib/mms/dm/Makefile.defs32
-rw-r--r--usr/src/lib/mms/dm/Makefile.rootdirs40
-rw-r--r--usr/src/lib/mms/dm/libDISK_ARCHIVING/Makefile42
-rw-r--r--usr/src/lib/mms/dm/libDISK_ARCHIVING/Makefile.com58
-rw-r--r--usr/src/lib/mms/dm/libDISK_ARCHIVING/common/dm_SUNW_DISK_ARCHIVING.c542
-rw-r--r--usr/src/lib/mms/dm/libDISK_ARCHIVING/common/mapfile-vers104
-rw-r--r--usr/src/lib/mms/dm/libDISK_ARCHIVING/i386/Makefile27
-rw-r--r--usr/src/lib/mms/dm/libDISK_ARCHIVING/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/Makefile42
-rw-r--r--usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/Makefile.com66
-rw-r--r--usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/common/dm_HP_Ultrium_3-SCSI.c120
-rw-r--r--usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/common/mapfile-vers66
-rw-r--r--usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/i386/Makefile27
-rw-r--r--usr/src/lib/mms/dm/libHP_Ultrium_3-SCSI/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/Makefile42
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/Makefile.com70
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/common/dm_IBM_ULTRIUM-TD1.c134
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/common/mapfile-vers66
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/i386/Makefile27
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD1/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/Makefile42
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/Makefile.com70
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/common/dm_IBM_ULTRIUM-TD2.c136
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/common/mapfile-vers67
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/i386/Makefile25
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD2/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/Makefile42
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/Makefile.com68
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/common/dm_IBM_ULTRIUM-TD3.c125
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/common/mapfile-vers66
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/i386/Makefile26
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD3/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/Makefile42
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/Makefile.com68
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/common/dm_IBM_ULTRIUM-TD4.c124
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/common/mapfile-vers66
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/i386/Makefile26
-rw-r--r--usr/src/lib/mms/dm/libIBM_ULTRIUM-TD4/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/dm/libQUANTUM_SDLT600/Makefile42
-rw-r--r--usr/src/lib/mms/dm/libQUANTUM_SDLT600/Makefile.com59
-rw-r--r--usr/src/lib/mms/dm/libQUANTUM_SDLT600/common/dm_QUANTUM_SDLT600.c211
-rw-r--r--usr/src/lib/mms/dm/libQUANTUM_SDLT600/common/mapfile-vers68
-rw-r--r--usr/src/lib/mms/dm/libQUANTUM_SDLT600/i386/Makefile26
-rw-r--r--usr/src/lib/mms/dm/libQUANTUM_SDLT600/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/Makefile42
-rw-r--r--usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/Makefile.com66
-rw-r--r--usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/common/dm_SEAGATE_ULTRIUM06242-XXX.c119
-rw-r--r--usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/common/mapfile-vers65
-rw-r--r--usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/i386/Makefile26
-rw-r--r--usr/src/lib/mms/dm/libSEAGATE_ULTRIUM06242-XXX/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/dm/libSTK_9840/Makefile42
-rw-r--r--usr/src/lib/mms/dm/libSTK_9840/Makefile.com68
-rw-r--r--usr/src/lib/mms/dm/libSTK_9840/common/dm_STK_9840.c118
-rw-r--r--usr/src/lib/mms/dm/libSTK_9840/common/mapfile-vers69
-rw-r--r--usr/src/lib/mms/dm/libSTK_9840/i386/Makefile26
-rw-r--r--usr/src/lib/mms/dm/libSTK_9840/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9840B/Makefile42
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9840B/Makefile.com68
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9840B/common/dm_STK_T9840B.c118
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9840B/common/mapfile-vers68
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9840B/i386/Makefile26
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9840B/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9840C/Makefile42
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9840C/Makefile.com68
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9840C/common/dm_STK_T9840C.c125
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9840C/common/mapfile-vers68
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9840C/i386/Makefile26
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9840C/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9940A/Makefile42
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9940A/Makefile.com68
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9940A/common/dm_STK_T9940A.c118
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9940A/common/mapfile-vers68
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9940A/i386/Makefile26
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9940A/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9940B/Makefile42
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9940B/Makefile.com68
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9940B/common/dm_STK_T9940B.c118
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9940B/common/mapfile-vers68
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9940B/i386/Makefile28
-rw-r--r--usr/src/lib/mms/dm/libSTK_T9940B/sparc/Makefile29
-rw-r--r--usr/src/lib/mms/dm/libcommon/dm_9x40_common.c144
-rw-r--r--usr/src/lib/mms/dm/libcommon/dm_HP_LTO_common.c114
-rw-r--r--usr/src/lib/mms/dm/libcommon/dm_IBM_LTO_common.c86
-rw-r--r--usr/src/lib/mms/dm/libcommon/dm_SEAGATELTO_common.c86
-rw-r--r--usr/src/lib/mms/dm/libdefault/Makefile42
-rw-r--r--usr/src/lib/mms/dm/libdefault/Makefile.com62
-rw-r--r--usr/src/lib/mms/dm/libdefault/common/dm_default.c2227
-rw-r--r--usr/src/lib/mms/dm/libdefault/common/mapfile-vers132
-rw-r--r--usr/src/lib/mms/dm/libdefault/i386/Makefile26
-rw-r--r--usr/src/lib/mms/dm/libdefault/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/lm/Makefile52
-rw-r--r--usr/src/lib/mms/lm/Makefile.defs33
-rw-r--r--usr/src/lib/mms/lm/Makefile.rootdirs40
-rw-r--r--usr/src/lib/mms/lm/libcommon/lm_acs.h167
-rw-r--r--usr/src/lib/mms/lm/libcommon/lm_acs_common.c2448
-rw-r--r--usr/src/lib/mms/lm/libcommon/lm_acs_display.c749
-rw-r--r--usr/src/lib/mms/lm/libcommon/lm_comm.c231
-rw-r--r--usr/src/lib/mms/lm/libcommon/lm_lcom.c3349
-rw-r--r--usr/src/lib/mms/lm/libdisk/Makefile42
-rw-r--r--usr/src/lib/mms/lm/libdisk/Makefile.com58
-rw-r--r--usr/src/lib/mms/lm/libdisk/common/lm_disk.c1639
-rw-r--r--usr/src/lib/mms/lm/libdisk/common/lm_disk.h136
-rw-r--r--usr/src/lib/mms/lm/libdisk/common/mapfile-vers71
-rw-r--r--usr/src/lib/mms/lm/libdisk/i386/Makefile26
-rw-r--r--usr/src/lib/mms/lm/libdisk/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/lm/libl180/Makefile42
-rw-r--r--usr/src/lib/mms/lm/libl180/Makefile.com69
-rw-r--r--usr/src/lib/mms/lm/libl180/common/lm_l180.c73
-rw-r--r--usr/src/lib/mms/lm/libl180/common/mapfile-vers93
-rw-r--r--usr/src/lib/mms/lm/libl180/i386/Makefile26
-rw-r--r--usr/src/lib/mms/lm/libl180/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/lm/libl500/Makefile42
-rw-r--r--usr/src/lib/mms/lm/libl500/Makefile.com71
-rw-r--r--usr/src/lib/mms/lm/libl500/common/lm_l500.c146
-rw-r--r--usr/src/lib/mms/lm/libl500/common/mapfile-vers93
-rw-r--r--usr/src/lib/mms/lm/libl500/i386/Makefile26
-rw-r--r--usr/src/lib/mms/lm/libl500/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/lm/libl700/Makefile42
-rw-r--r--usr/src/lib/mms/lm/libl700/Makefile.com70
-rw-r--r--usr/src/lib/mms/lm/libl700/common/lm_l700.c188
-rw-r--r--usr/src/lib/mms/lm/libl700/common/mapfile-vers93
-rw-r--r--usr/src/lib/mms/lm/libl700/i386/Makefile26
-rw-r--r--usr/src/lib/mms/lm/libl700/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/lm/libsl3000/Makefile42
-rw-r--r--usr/src/lib/mms/lm/libsl3000/Makefile.com70
-rw-r--r--usr/src/lib/mms/lm/libsl3000/common/lm_sl3000.c146
-rw-r--r--usr/src/lib/mms/lm/libsl3000/common/mapfile-vers79
-rw-r--r--usr/src/lib/mms/lm/libsl3000/i386/Makefile26
-rw-r--r--usr/src/lib/mms/lm/libsl3000/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/lm/libsl8500/Makefile42
-rw-r--r--usr/src/lib/mms/lm/libsl8500/Makefile.com70
-rw-r--r--usr/src/lib/mms/lm/libsl8500/common/lm_sl8500.c146
-rw-r--r--usr/src/lib/mms/lm/libsl8500/common/mapfile-vers93
-rw-r--r--usr/src/lib/mms/lm/libsl8500/i386/Makefile26
-rw-r--r--usr/src/lib/mms/lm/libsl8500/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/mgmt/Makefile48
-rw-r--r--usr/src/lib/mms/mgmt/Makefile.com75
-rw-r--r--usr/src/lib/mms/mgmt/Makefile.defs28
-rw-r--r--usr/src/lib/mms/mgmt/Makefile.rootdirs33
-rw-r--r--usr/src/lib/mms/mgmt/common/mapfile-vers109
-rw-r--r--usr/src/lib/mms/mgmt/common/mgmt_acsls.c839
-rw-r--r--usr/src/lib/mms/mgmt/common/mgmt_acsls.h181
-rw-r--r--usr/src/lib/mms/mgmt/common/mgmt_dsk.c1214
-rw-r--r--usr/src/lib/mms/mgmt/common/mgmt_lib.c2969
-rw-r--r--usr/src/lib/mms/mgmt/common/mgmt_library.h346
-rw-r--r--usr/src/lib/mms/mgmt/common/mgmt_media.c2820
-rw-r--r--usr/src/lib/mms/mgmt/common/mgmt_media.h52
-rw-r--r--usr/src/lib/mms/mgmt/common/mgmt_mm.c1786
-rw-r--r--usr/src/lib/mms/mgmt/common/mgmt_mmp.c1166
-rw-r--r--usr/src/lib/mms/mgmt/common/mgmt_mmsdb.c1571
-rw-r--r--usr/src/lib/mms/mgmt/common/mgmt_probe.c238
-rw-r--r--usr/src/lib/mms/mgmt/common/mgmt_sym.h80
-rw-r--r--usr/src/lib/mms/mgmt/common/mgmt_util.c1914
-rw-r--r--usr/src/lib/mms/mgmt/common/mgmt_util.h257
-rw-r--r--usr/src/lib/mms/mgmt/common/mmp_defs.h78
-rw-r--r--usr/src/lib/mms/mgmt/common/mms_mgmt.h391
-rw-r--r--usr/src/lib/mms/mgmt/i386/Makefile26
-rw-r--r--usr/src/lib/mms/mgmt/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/mms/Makefile89
-rw-r--r--usr/src/lib/mms/mms/Makefile.com121
-rw-r--r--usr/src/lib/mms/mms/common/cfg_lex.l203
-rw-r--r--usr/src/lib/mms/mms/common/cfg_parse.c106
-rw-r--r--usr/src/lib/mms/mms/common/cfg_yacc.y222
-rw-r--r--usr/src/lib/mms/mms/common/connect.c460
-rw-r--r--usr/src/lib/mms/mms/common/host_ident.c219
-rw-r--r--usr/src/lib/mms/mms/common/host_ident.h49
-rw-r--r--usr/src/lib/mms/mms/common/mapfile-vers158
-rw-r--r--usr/src/lib/mms/mms/common/mgmt_mms.h75
-rw-r--r--usr/src/lib/mms/mms/common/mms_api.c1337
-rw-r--r--usr/src/lib/mms/mms/common/mms_cat.c372
-rw-r--r--usr/src/lib/mms/mms/common/mms_cfg.c478
-rw-r--r--usr/src/lib/mms/mms/common/mms_cfg.h83
-rw-r--r--usr/src/lib/mms/mms/common/mms_client.c1521
-rw-r--r--usr/src/lib/mms/mms/common/mms_cores.c170
-rw-r--r--usr/src/lib/mms/mms/common/mms_cores.h53
-rw-r--r--usr/src/lib/mms/mms/common/mms_list.c204
-rw-r--r--usr/src/lib/mms/mms/common/mms_logadm.conf28
-rw-r--r--usr/src/lib/mms/mms/common/mms_mgmt.c642
-rw-r--r--usr/src/lib/mms/mms/common/mms_par_impl.h155
-rw-r--r--usr/src/lib/mms/mms/common/mms_par_util.c982
-rw-r--r--usr/src/lib/mms/mms/common/mms_rw.c260
-rw-r--r--usr/src/lib/mms/mms/common/mms_scsi.c237
-rw-r--r--usr/src/lib/mms/mms/common/mms_scsi.h72
-rw-r--r--usr/src/lib/mms/mms/common/mms_sock.c386
-rw-r--r--usr/src/lib/mms/mms/common/mms_sock.h71
-rw-r--r--usr/src/lib/mms/mms/common/mms_ssl.c1894
-rw-r--r--usr/src/lib/mms/mms/common/mms_sym.c583
-rw-r--r--usr/src/lib/mms/mms/common/mmsp_common.c353
-rw-r--r--usr/src/lib/mms/mms/common/mmsp_lex.l251
-rw-r--r--usr/src/lib/mms/mms/common/mmsp_yacc.y8216
-rw-r--r--usr/src/lib/mms/mms/common/msg_sub.c114
-rw-r--r--usr/src/lib/mms/mms/common/msg_sub.h40
-rw-r--r--usr/src/lib/mms/mms/common/net_cfg.c291
-rw-r--r--usr/src/lib/mms/mms/common/net_cfg_service.c259
-rw-r--r--usr/src/lib/mms/mms/common/net_cfg_service.h49
-rw-r--r--usr/src/lib/mms/mms/common/strapp.c272
-rw-r--r--usr/src/lib/mms/mms/common/trace.c754
-rw-r--r--usr/src/lib/mms/mms/i386/Makefile26
-rw-r--r--usr/src/lib/mms/mms/sparc/Makefile27
-rw-r--r--usr/src/lib/mms/pg/Makefile42
-rw-r--r--usr/src/lib/mms/pg/Makefile.com63
-rw-r--r--usr/src/lib/mms/pg/Makefile.defs27
-rw-r--r--usr/src/lib/mms/pg/Makefile.rootdirs33
-rw-r--r--usr/src/lib/mms/pg/common/mapfile-vers59
-rw-r--r--usr/src/lib/mms/pg/common/pg_host_ident.c97
-rw-r--r--usr/src/lib/mms/pg/common/pg_uuid.c71
-rw-r--r--usr/src/lib/mms/pg/i386/Makefile26
-rw-r--r--usr/src/lib/mms/pg/sparc/Makefile27
228 files changed, 11 insertions, 58489 deletions
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, &ltype);
- 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, &ltype);
- 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[] = {
- "\"", "&quot" MMS_SEMICOLON, 6,
- "'", "&apos" MMS_SEMICOLON, 6,
- ">", "&gt" MMS_SEMICOLON, 4,
- "<", "&lt" MMS_SEMICOLON, 4,
- "&", "&amp" 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] = {
- { '\'', "&apos;" },
- { '"', "&quot;" },
- { '>', "&gt;" },
- { '<', "&lt;" },
- { '&', "&amp;" }
-};
-
-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, &ltime);
- (void) strftime(date, 100, "%Y/%m/%d %H:%M:%S", &ltime);
- 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