mm_dmp_sql.c revision d1d2228c6cf3ec632d28262810ab7902932a5d33
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <pthread.h>
#include <syslog.h>
#include <mms_list.h>
#include <mms_parser.h>
#include <mms_par_impl.h>
#include <libpq-fe.h>
#include <mms_trace.h>
#include <mms_strapp.h>
#include "mm_db.h"
#include "mm.h"
#include "mm_util.h"
#include "mm_commands.h"
#include "mm_sql.h"
#include "mm_sql_impl.h"
#define INS_DMCAPABILITYGROUP "INSERT INTO \"DMCAPABILITYGROUP\" "\
"(\"DriveName\", \"DMName\", "\
"\"DMCapabilityGroupName\", \"DMCapabilityGroupDefaultName\", "\
"\"DMCapabilityGroupType\") "\
"VALUES ('%s', '%s', '%s', '%s' , '%s');"
#define INS_DMCAPABILITYGROUPTOKEN "INSERT INTO \"DMCAPABILITYGROUPTOKEN\" "\
"(\"DriveName\", \"DMName\", "\
"\"DMCapabilityGroupName\", \"DMCapabilityToken\") "\
"VALUES ('%s', '%s', '%s', '%s'); "
#define INS_DMCAPABILITY "INSERT INTO \"DMCAPABILITY\" (\"DriveName\", "\
"\"DMName\", "\
"\"DMCapabilityName\") "\
"VALUES ('%s', '%s', '%s'); "
#define INS_DMCAPABILITYTOKEN "INSERT INTO \"DMCAPABILITYTOKEN\" "\
"(\"DriveName\", "\
"\"DMName\", \"DMCapabilityName\", \"DMCapabilityToken\") "\
"VALUES ('%s', '%s', '%s', '%s'); "
#define INS_DMBITFORMAT "INSERT INTO \"DMBITFORMAT\" "\
"(\"DriveName\", \"DMName\", \"DMBitFormatName\", "\
"\"DMBitFormatDefaultToken\") "\
"VALUES('%s', '%s', '%s', '%s');"
#define INS_DMBITFORMATTOKEN "INSERT INTO \"DMBITFORMATTOKEN\" "\
"(\"DriveName\", "\
"\"DMName\", \"DMBitFormatName\", "\
"\"DMCapabilityToken\") "\
"VALUES('%s', '%s', '%s', '%s');"
#define INS_BITFORMATDEFAULTTOKEN "UPDATE \"DMBITFORMAT\" SET "\
"\"DMBitFormatDefaultToken\" = '%s' WHERE "\
"( \"DriveName\" = '%s' AND \"DMName\" = '%s' AND "\
"\"DMBitFormatName\" = '%s');"
#define INS_ATTR "UPDATE \"DMCAPABILITY\" SET \"%s\" = '%s' WHERE "\
"( \"DriveName\" = '%s' AND \"DMName\" = '%s' AND "\
"\"DMCapabilityName\" = '%s');"
#define DEL_DMCAPABILITYGROUPTOKEN "DELETE FROM \"DMCAPABILITYGROUPTOKEN\" "\
"WHERE ((\"DMCAPABILITYGROUPTOKEN\".\"DriveName\" = '%s') AND "\
"(\"DMCAPABILITYGROUPTOKEN\".\"DMName\" = '%s'));"
#define DEL_DMCAPABILITYGROUP "DELETE FROM \"DMCAPABILITYGROUP\" "\
"WHERE ((\"DMCAPABILITYGROUP\".\"DriveName\" = '%s') AND "\
"(\"DMCAPABILITYGROUP\".\"DMName\" = '%s'));"
#define DEL_DMCAPABILITYTOKEN "DELETE FROM \"DMCAPABILITYTOKEN\" "\
"WHERE ((\"DMCAPABILITYTOKEN\".\"DriveName\" = '%s') "\
"AND (\"DMCAPABILITYTOKEN\".\"DMName\" = '%s'));"
#define DEL_DMCAPABILITY "DELETE FROM \"DMCAPABILITY\" WHERE "\
"((\"DMCAPABILITY\".\"DriveName\" = '%s') AND "\
"(\"DMCAPABILITY\".\"DMName\" = '%s'));"
#define DEL_DMBITFORMATTOKEN "DELETE FROM \"DMBITFORMATTOKEN\" WHERE "\
"((\"DMBITFORMATTOKEN\".\"DriveName\" = '%s') AND "\
"(\"DMBITFORMATTOKEN\".\"DMName\" = '%s'));"
#define DEL_DMBITFORMAT "DELETE FROM \"DMBITFORMAT\" WHERE "\
"((\"DMBITFORMAT\".\"DriveName\" = '%s') AND "\
"(\"DMBITFORMAT\".\"DMName\" = '%s'));"
int
/* Check if DM has a STALEHANDLE */
/* Clear drive if the session for */
/* stale handle is no longer connected */
char *CartridgeID = NULL;
"select \"CartridgeID\" from \"STALEHANDLE\" "
"where \"DMName\" = '%s' and"
"\"DriveName\" = '%s';",
"db error in mm_dmp_has_stalehandle");
return (0);
}
/* DM has a stale handle */
"%s %s, has STALEHANDLE for cart %s",
/* Check if mounting session is still connected */
"select \"SESSION\".\"ApplicationName\","
"\"SESSION\".\"AIName\" "
" from \"SESSION\",\"MOUNTPHYSICAL\" "
"where \"SESSION\".\"SessionID\" = "
"\"MOUNTPHYSICAL\".\"SessionID\" and "
"\"MOUNTPHYSICAL\".\"CartridgeID\" = '%s';",
CartridgeID) != MM_DB_DATA) {
"db error in mm_dmp_has_stalehandle");
return (0);
}
"%s %s session still active, "
"skip clear and reserve DM, %s %s %s",
/* Add activate command */
MM_DMP_RESERVE) == NULL) {
"mm_dmp_clear_at_enable: "
"error adding dmp reserve");
}
return (0);
}
"no active client session "
"found, clear drive, %s %s",
return (1);
}
"no STALEHANDLE found, %s %s",
return (0);
}
int
int least_sig = num_cap_groups;
/* Ok */
return (0);
}
if (least_sig == 1) {
return (1);
}
least_sig --;
}
int
int rc;
/*
* Determine if activate disable can be sent
* return 1 for fail, 0 for success
*/
"select \"DM\".\"DMStateHard\","
"\"DM\".\"DMStateSoft\","
"\"DRIVE\".\"DriveBroken\","
"\"DRIVE\".\"DriveStateSoft\","
"\"DRIVE\".\"DriveDisabled\", "
"\"DRIVE\".\"DriveOnline\" "
"from \"DM\",\"DRIVE\" where "
"\"DM\".\"DriveName\" = "
"\"DRIVE\".\"DriveName\" and "
"\"DM\".\"DMName\" = '%s';",
dmname);
if ((rc != MM_DB_DATA) ||
"skip DM disable");
return (1);
}
" DMStateHard = %s",
" DMStateSoft = %s",
" DriveBroken = %s",
" DriveStateSoft = %s",
" DriveDisabled = %s",
" DriveOnline = %s",
"ready") != 0) {
"DMStateHard != ready, skip disable");
return (1);
}
"ready") != 0) {
"DMStateSoft != ready, skip disable");
return (1);
}
"f") != 0) {
"DriveBroken != f, skip disable");
return (1);
}
"ready") != 0) {
"DriveStateSoft != f, skip disable");
return (1);
}
"false") != 0) {
"DriveDisabled != false, skip disable");
return (1);
}
"f") != 0) {
"DriveOnline != f, skip disable");
return (1);
}
/* Allocate and add an activate command to the queue */
/*
* Build an activate disable command
*/
"Unable to malloc mm_command_t: %s",
return (1);
}
return (1);
}
/*
* Activate dm is inprogress.
*/
return (0);
}
/* Allocate and add an activate command to the queue */
/*
* Build an activate enable command
*/
"Unable to malloc mm_command_t: %s",
return (NULL);
}
return (NULL);
}
/*
* Activate dm is inprogress.
*/
return (cmd);
}
int rc;
/*
* Determine if activate enable can be sent
* return NULL for fail, pointer to the enable command for success
*/
"select \"DM\".\"DMStateHard\","
"\"DM\".\"DMStateSoft\","
"\"DRIVE\".\"DriveBroken\","
"\"DRIVE\".\"DriveStateSoft\","
"\"DRIVE\".\"DriveDisabled\", "
"\"DRIVE\".\"DriveOnline\" "
"from \"DM\",\"DRIVE\" where "
"\"DM\".\"DriveName\" = "
"\"DRIVE\".\"DriveName\" and "
"\"DM\".\"DMName\" = '%s';",
dmname);
if ((rc != MM_DB_DATA) ||
"skip DM enable");
return (NULL);
}
" DMStateHard = %s",
" DMStateSoft = %s",
" DriveBroken = %s",
" DriveStateSoft = %s",
" DriveDisabled = %s",
" DriveOnline = %s",
"ready") != 0) {
"DMStateHard != ready, skip enable");
return (NULL);
}
"present") != 0) {
"DMStateSoft != present, skip enable");
return (NULL);
}
"f") != 0) {
"DriveBroken != f, skip enable");
return (NULL);
}
"unavailable") == 0) {
"DriveStateSoft == unavailable, "
"wait on DM activate");
return (NULL);
}
"ready") != 0) {
"DriveStateSoft != ready");
}
"false") != 0) {
"DriveDisabled != false, skip enable");
return (NULL);
}
"t") != 0) {
"DriveOnline != t, skip enable");
return (NULL);
}
"unable to malloc dm enable cmd");
return (NULL);
}
/*
* Activate dm is inprogress.
*/
return (cmd);
}
/*
* This function deletes the config for a DM
* who's wka is mm_wka
* db should be the calling thread's
* database pointer
*/
void
"delete from "\
"\"DMSHAPEPRIORITY\" " \
"where \"DMName\" = '%s'",
!= MM_DB_OK) {
"Error removing "\
"DMSHAPEPRIORITY");
}
"delete from "\
"\"DMDENSITYPRIORITY\" " \
"where \"DMName\" = '%s'",
!= MM_DB_OK) {
"Error removing "\
"DMDENSITYPRIORITY");
}
"delete from "\
"\"DMMOUNTPOINT\" " \
"where \"DMName\" = '%s'",
!= MM_DB_OK) {
"Error removing "\
"DMMOUNTPOINT");
}
"delete from "\
"\"DMCAPABILITYGROUP\" " \
"where \"DMName\" = '%s'",
!= MM_DB_OK) {
"Error removing "\
"DMCAPABILITYGROUP");
}
"delete from "\
"\"DMCAPABILITY\" " \
"where \"DMName\" = '%s'",
!= MM_DB_OK) {
"Error removing DMCAPABILITY");
}
"delete from "\
"\"DMBITFORMAT\" " \
"where \"DMName\" = '%s'",
!= MM_DB_OK) {
"Error removing DMBITFORMAT");
}
"delete from "\
"\"DMBITFORMATTOKEN\" " \
"where \"DMName\" = '%s'",
!= MM_DB_OK) {
"Error removing "\
"DMBITFORMATTOKEN");
}
}
int
{
int scope_full;
int go;
int count;
char *group_name;
char *group_type;
char *default_cap_token;
char *group_cap_token[512];
char *cap_name;
char *cap_list_cap_token[512];
char *attr_name;
char *attr_value;
char *bit_name;
char *default_bit_token;
char *bit_cap_token[512];
int shape_count = 1;
int density_count = 1;
int i;
/*
* buf = mms_strapp(buf, DMP_PRIVATE_BLOCKSIZE,
* mount_info->cmi_blocksize);
*/
/* Response for DM debug Config Command */
/*
* Error In Debug Config
* return MMS_ERROR response and
* delete config from DataBase
*/
"MMS_ERROR");
/*
* cmd->cmd_remove = 1;
* mm_sql_db_err_rsp_new(cmd, db);
* mm_send_text(mm_wka->mm_wka_conn, cmd->cmd_buf);
*/
goto not_found;
} else {
/* Config is MMS_OK */
return (MM_DISPATCH_AGAIN);
}
}
/* Begin Parsing Config Command */
scope_full = 1;
scope_full = 0;
} else {
NULL);
goto error;
}
/*
* If scope is 'full' then remove all existing config entries
* in db for the current dm and drive
*/
if (scope_full) {
/* Remove DMBITFORMATTOKEN from db */
"DMBITFORMATTOKEN");
goto error;
}
/* Remove DMBITFORMAT from db */
"DMBITFORMAT");
goto error;
}
/* Revomve DMCAPABILITYGROUPTOKEN from db */
"DMCAPABILITYGROUPTOKEN");
goto error;
}
/* Revomve DMCAPABILITYGROUP from db */
"DMCAPABILITYGROUP");
goto error;
}
/* Revomve DMCAPABILITYTOKEN from db */
"DMCAPABILITYTOKEN");
goto error;
}
/* Revomve DMCAPABILITY from db */
"DMCAPABILITY");
goto error;
}
}
/* Get Group Config */
/* mms_trace(MMS_DEVP, "group"); */
MMS_PN_CLAUSE, &work);
MMS_PN_CLAUSE, &work)) {
int i;
/* Insert DMCAPABILITYGROUP into db */
group_type) != MM_DB_OK) {
"Error adding cap group "
"%s %s %s %s %s",
goto error;
}
/* Get the Other Group Cap Tokens */
count = 0;
go = 1;
while (go) {
go = 0;
} else {
count ++;
}
}
/* Insert DMCAPABILITYGROUPTOKEN into db */
/* Insert the default token */
default_cap_token) != MM_DB_OK) {
"Error adding cap group token"
"%s %s %s %s",
goto error;
}
/* Insert the other tokens */
for (i = 0; i < count; i++) {
group_cap_token[i]) != MM_DB_OK) {
"Error adding cap group token"
"%s %s %s %s",
group_cap_token[i]);
goto error;
}
}
}
/* Capabilities */
MMS_PN_CLAUSE, &work);
MMS_PN_CLAUSE, &work)) {
/* Insert DMCAPABILITY into db */
"Error adding cap "
"%s %s %s",
goto error;
}
/* Get the tokens in the CapList */
}
count = 0;
go = 1;
while (go) {
&cap_list_work)) == NULL) {
go = 0;
} else {
count ++;
}
}
/* Insert DMCAPABILITYTOKEN into db */
for (i = 0; i < count; i++) {
cap_list_cap_token[i]) != MM_DB_OK) {
"Error adding cap "
"%s %s %s %s",
cap_list_cap_token[i]);
goto error;
}
}
MMS_PN_CLAUSE, &cap_list_work)) {
MMS_PN_STRING, &item);
MMS_PN_STRING, &item);
!= MM_DB_OK) {
"Error creating new attribute");
goto error;
}
}
}
"config");
goto error;
}
}
MMS_PN_CLAUSE, &work);
MMS_PN_CLAUSE, &work)) {
MMS_PN_STRING, &item);
MMS_PN_STRING, &item);
/* Insert DMBITFORMAT into db */
/* Get the remaining tokens */
count = 0;
go = 1;
while (go) {
go = 0;
} else {
count ++;
}
}
/* Insert DMBITFORMATTOKEN into db */
/* Insert the default token */
/* Insert the rest */
for (i = 0; i < count; i++) {
bit_cap_token[i]);
"BitToken %d: %s", i, bit_cap_token[i]);
}
}
/* Add the send_buf */
"config");
goto error;
}
/* Cartridge Shape and Density Priority */
/* Shape priority */
"shapepriority",
"DM config is missing the shapepriority clause");
} else {
"insert into \"DMSHAPEPRIORITY\" "
"(\"DMName\", \"DMShapePriority\", "
"\"DMShapeName\") "
"values('%s', '%d', '%s');",
"shapepriority");
goto error;
}
if (shape_count == 1) {
/* set DriveShapeName */
"update \"DRIVE\" "
"set \"DriveShapeName\" = '%s'"
" where \"DriveName\" = '%s'",
"DriveShapeName");
goto error;
}
}
shape_count ++;
}
}
/* Density priority */
"densitypriority",
"DM config is missing the densitypriority clause");
} else {
"insert into \"DMDENSITYPRIORITY\" "
"(\"DMName\", \"DMDensityPriority\", "
"\"DMDensityName\") "
"values('%s', '%d', '%s');",
"densitypriority");
goto error;
}
density_count ++;
}
}
/* Mount Points */
"mountpoint",
"DM config is missing the mountpoint clause");
} else {
"insert into \"DMMOUNTPOINT\" "
"(\"DMName\", \"DMMountPoint\") "
"values('%s', '%s');",
"mountpoint");
goto error;
}
}
}
/* Done Parsing */
return (MM_DISPATCH_AGAIN);
goto error;
NULL);
goto error;
"DMStateSoft",
"not ready", "DMName",
DMName);
return (MM_CMD_ERROR);
}
#define DMP_SEND_ATTACH "attach task [\"%s\"] " \
"modename [\"%s\"];"
int
{
int bufsize = 0;
/* send the attach to DM */
return (MM_CMD_ERROR);
}
buf);
return (MM_ACCEPT_NEEDED);
/* revieved accept */
return (MM_CMD_ERROR);
}
return (MM_DISPATCH_DEPEND);
/* recieved success */
return (MM_CMD_ERROR);
}
/* Get text */
MMS_PN_CLAUSE, &work);
} else {
}
} else {
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
return (MM_DEPEND_DONE);
} else {
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
return (MM_CMD_ERROR);
}
#define DMP_SEND_IDENTIFY "identify task [\"%s\"] type [\"none\"];"
int
{
int bufsize = 0;
/* send the load to DM */
buf);
return (MM_ACCEPT_NEEDED);
/* revieved accept */
return (MM_CMD_ERROR);
}
return (MM_DISPATCH_DEPEND);
/* recieved success */
return (MM_CMD_ERROR);
}
/* Get text */
MMS_PN_CLAUSE, &work);
} else {
}
} else {
return (MM_CMD_ERROR);
}
return (MM_DEPEND_DONE);
} else {
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
return (MM_CMD_ERROR);
}
#define DMP_SEND_ACT "activate task[\"%s\"] enable;"
int
{
/* set "DMStateSoft" to notready */
"DMStateSoft",
"not ready", "DMName",
DMName);
return (MM_ACCEPT_NEEDED);
}
return (MM_CMD_ERROR);
}
return (MM_NO_DISPATCH);
}
"DM_E_ENABLED")) {
/* DM has aleady been enabled */
"%s %s already enabled",
"DMStateSoft",
"ready", "DMName",
DMName);
/* Add a DMUP event */
/* Check if this DM has any handles */
"check if %s has any STALEHANDLE",
DMName);
if (mm_dmp_clear_at_enable(mm_wka)) {
/* DM has a stale handle */
/* The client session is */
/* not connected */
/* Need to clear the drive */
"Adding clear drive for %s %s",
db,
NULL,
"mm_dmp_activate_cmd_func: "
"unable to add a "
"clear drive cmd");
}
}
} else {
"DM activate command error");
return (MM_CMD_ERROR);
}
}
/* Set the correct DMSoftState */
"%s %s enabled",
"DMStateSoft",
"ready", "DMName",
DMName);
/* Add a DMUP event */
if (mm_dmp_clear_at_enable(mm_wka)) {
/* DM has a stale handle */
/* The client session is not connected */
/* Need to clear the drive */
"Adding clear drive for %s %s",
db,
NULL,
"mm_dmp_activate_cmd_func: "
"unable to add a clear drive cmd");
}
}
"%s %s disabled",
"DMStateSoft",
"present", "DMName",
DMName);
/* Add a DMDOWN event */
"%s reserved %s",
"DMStateSoft",
"reserved", "DMName",
DMName);
"%s released %s",
"DMStateSoft",
"ready", "DMName",
DMName);
"update \"DRIVE\" set "
"\"DMName\" = DEFAULT "
"where \"DMName\" = '%s';",
"Error udating DRIVE.DMName");
}
} else {
"Unknown type - %s",
cmd->cmd_textcmd);
return (MM_CMD_ERROR);
}
if (mm_has_depend(cmd)) {
return (MM_DEPEND_DONE);
}
return (MM_CMD_DONE);
}
return (MM_CMD_ERROR);
}
#define DMP_PRIVATE "private task['%s'] " \
"set['cap' '%s' " \
"'filename' '%s' " \
"'volumeid' '%s' " \
"'CartridgePCL' '%s' " \
"'VolumeName' '%s' "
#define DMP_PRIVATE_PRIVILEGE "'privileged' '%s' "
#define DMP_PRIVATE_BLOCKSIZE "'blocksize' '%s' "
#define DMP_PRIVATE_FSEQ "'filesequence' '%s'"
#define DMP_PRIVATE_USER "'user' '%s'"
#define DMP_PRIVATE_RETENTION "'retention' '%s'"
#define DMP_RESERVE_DRIVE "select \"ReserveDrive\" "\
"from \"DRIVE\" where \"DriveName\" = '%s';"
#define DMP_DEFAULT_FILENAME "select \"VolumeName\" "\
"from \"VOLUME\" where "\
"\"CartridgeID\" = '%s';"
#define DMP_DEFAULT_VOLID "select \"CartridgePCL\" "\
"from \"CARTRIDGE\" where " \
"\"CartridgeID\" = '%s';"
int
{
int bufsize = 0;
char *cap_tokens = NULL;
int rc;
int a_mode = 0;
char *VolumeName = NULL;
/* Send a DM mount information */
} else {
}
a_mode = 1;
mode,
if (cap_tokens != NULL) {
/* mode is ok */
break;
}
}
if (!a_mode) {
NULL,
}
if (cap_tokens == NULL) {
"couldn't create capability token string,"
" verify DM connected/configured");
return (MM_CMD_ERROR);
}
/* quert DRIVE for reserve drive */
if (rc != MM_DB_DATA) {
return (MM_CMD_ERROR);
}
/*
* file name not specified use default
* 1st 17 chars of VolumeName
*/
if (rc != MM_DB_DATA) {
return (MM_CMD_ERROR);
}
}
if (rc != MM_DB_DATA) {
return (MM_CMD_ERROR);
}
/*
* volumeid not specifed use default
* CartridgePCL
*/
}
/* ***************************** */
strlen(cap_tokens) +
0, 0)) +
task,
0, 0),
/* if we were passed a blocksize, include it */
}
/* if we were passed a retention, include it */
}
"false");
} else {
"true");
}
/* Always include the default blocksize */
/* find default blocksize for this drive */
"select \"DefaultBlocksize\" "
"from \"DRIVE\" where "
"\"DriveName\" = '%s';",
if (rc != MM_DB_DATA) {
return (MM_CMD_ERROR);
}
}
}
/*
* mms_trace(MMS_DEVP, "send buf is '%s' to
* fd %d ", buf, mm_wka->mm_wka_conn->mms_fd);
*/
buf);
/* ***************************** */
return (MM_ACCEPT_NEEDED);
}
return (MM_CMD_ERROR);
}
return (MM_DISPATCH_DEPEND);
}
return (MM_CMD_ERROR);
}
return (MM_DEPEND_DONE);
}
return (MM_CMD_ERROR);
}
#define DMP_SEND_LOAD "load task[\"%s\"];"
int
{
int bufsize = 0;
/* send the load to DM */
buf);
return (MM_ACCEPT_NEEDED);
/* revieved accept */
return (MM_CMD_ERROR);
}
/* set "DriveStateHard" to loading */
"DriveStateHard",
"loading", "DriveName",
return (MM_DISPATCH_DEPEND);
/* recieved success */
return (MM_CMD_ERROR);
}
/* set "DriveStateHard" to loaded */
"DriveStateHard",
"loaded", "DriveName",
return (MM_DEPEND_DONE);
} else {
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
}
int
{
int go;
int name;
"DMStateSoft",
"not ready", "DMName",
DMName);
"DMStateHard",
"broken", "DMName",
DMName);
"DMStateSoft",
"not ready", "DMName",
DMName);
"DMStateSoft",
"disconnected", "DMName",
DMName);
} else {
/* Drive is READY! */
"DMStateSoft",
"ready", "DMName",
DMName);
return (MM_CMD_DONE);
}
MMS_PN_CLAUSE, &work);
MMS_PN_CLAUSE, &work);
MMS_PN_STRING, &work);
MMS_PN_STRING, &work);
MMS_PN_STRING, &work);
} else {
}
MMS_PN_CLAUSE, &work);
go = 1;
name = 0;
while (go) {
go = 0;
} else {
if (name == 0) {
/* got name */
name = 1;
"Name -> %s",
} else {
name = 0;
" Value -> %s",
}
}
}
if (name == 1) {
/* got name and are missing a value */
"in argument clause");
goto not_found;
}
} else {
}
MMS_PN_STRING, &work);
MMS_PN_STRING, &work);
}
} else {
}
return (MM_CMD_DONE);
return (MM_CMD_ERROR);
NULL);
return (MM_CMD_ERROR);
}
#define DMP_SEND_UNLOAD "unload task [\"%s\"];"
int
{
int bufsize = 0;
int go;
int name;
/* send the unload to DM */
/* Set DriveStateHard to UNLOADING */
"DRIVE", "DriveStateHard",
"unloading", "DriveName",
buf);
return (MM_ACCEPT_NEEDED);
/* revieved accept */
return (MM_CMD_ERROR);
}
return (MM_DISPATCH_DEPEND);
/* recieved success */
return (MM_CMD_ERROR);
}
MMS_PN_CLAUSE, &work);
go = 1;
name = 0;
while (go) {
go = 0;
} else {
if (name == 0) {
/* got name */
name = 1;
"Name -> %s",
} else {
name = 0;
" Value -> %s",
}
}
}
if (name == 1) {
/* got name and are missing a value */
"in text clause");
goto not_found;
}
} else {
}
return (MM_DEPEND_DONE);
} else {
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
return (MM_CMD_ERROR);
}
#define DMP_SEND_DETACH "detach task [\"%s\"] "\
"drivehandle [\"%s\"] stale [\"%s\"];"
int
{
int bufsize = 0;
int rc;
int stale = 0;
/* send the detach to DM */
/* Get the handle from MOUNTLOGICAL */
"from \"MOUNTLOGICAL\" where "\
"\"DriveName\" = '%s' and \"DMName\" = '%s';",
if (rc != MM_DB_DATA) {
return (MM_CMD_ERROR);
}
/* NO handle found */
"No MOUNTLOGICAL handle found...");
/* No MOUNLOGICAL handle, check for STALEHANDLE */
"select \"MountLogicalHandle\" "
"from \"STALEHANDLE\" where "
"\"DriveName\" = '%s' "
"and \"DMName\" = '%s';",
if (rc != MM_DB_DATA) {
"Exec returned with no Data");
return (MM_CMD_ERROR);
}
/* NO handle found */
"MOUNTLOGICAL found, skipping detach");
return (MM_DEPEND_DONE);
} else {
stale = 1;
}
}
if (stale) {
} else {
}
buf);
return (MM_ACCEPT_NEEDED);
/* revieved accept */
return (MM_CMD_ERROR);
}
return (MM_DISPATCH_DEPEND);
/* recieved success */
return (MM_CMD_ERROR);
}
return (MM_DEPEND_DONE);
} else {
return (MM_CMD_ERROR);
}
return (MM_CMD_ERROR);
return (MM_CMD_ERROR);
}
{
int recover = 0;
switch (type) {
case MM_DMP_RESERVE:
break;
case MM_DMP_PRIV:
break;
case MM_DMP_LOAD:
break;
case MM_DMP_ATTACH:
break;
case MM_DMP_IDENTIFY:
break;
case MM_DMP_DETACH:
break;
case MM_DMP_UNLOAD:
break;
case MM_DMP_RELEASE:
break;
}
/* Set cmd->wka_ptr to point to the dm's wka */
if (!recover) {
dm_name) == 0) {
/* Found the wka of dm */
break;
}
}
dm_name) != 0)) {
/* bad wka */
return (NULL);
}
} else {
}
"Unable to malloc mm_command_t: %s",
return (NULL);
}
return (NULL);
}
switch (type) {
case MM_DMP_RESERVE:
break;
case MM_DMP_PRIV:
break;
case MM_DMP_LOAD:
break;
case MM_DMP_ATTACH:
break;
case MM_DMP_IDENTIFY:
break;
case MM_DMP_DETACH:
break;
case MM_DMP_UNLOAD:
break;
case MM_DMP_RELEASE:
break;
}
return (cmd);
}
int
{
char *taskid;
/* is this a command we know how to cancel */
"request") == 0) {
}
break;
}
}
/* command not found */
return (MM_CMD_ERROR);
}
/* cancel command */
"from \"REQUEST\" where \"RequestID\" = '%s';",
cmd_reqid) != MM_DB_DATA ||
return (MM_CMD_ERROR);
}
"responded") == 0) {
return (MM_CMD_ERROR);
}
/* remove the request */
return (MM_CMD_ERROR);
}
} else {
return (MM_CMD_ERROR);
}
/* send cancelled command's final-command response */
/* send cancelled command response */
&cmd_p->cmd_bufsize,
break;
}
}
/* same command not found or error sending cancelled response */
return (MM_CMD_ERROR);
}
return (MM_CMD_DONE);
NULL);
return (MM_CMD_ERROR);
return (MM_CMD_ERROR);
}
int
{
"dmp reset, state %d, %s",
cmd->cmd_textcmd);
"Issuing reset for %s %s",
conn->cci_client);
return (MM_ACCEPT_NEEDED);
return (MM_NO_DISPATCH);
} else {
return (MM_CMD_ERROR);
}
return (MM_DEPEND_DONE);
}
}
return (MM_CMD_ERROR);
}
int
{
"dmp exit, state %d, %s",
cmd->cmd_textcmd);
"Issuing exit for %s %s",
conn->cci_client);
return (MM_ACCEPT_NEEDED);
return (MM_NO_DISPATCH);
} else {
return (MM_CMD_ERROR);
}
return (MM_DEPEND_DONE);
}
}
return (MM_CMD_ERROR);
}