lm_disk.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 "lm_disk.h"
#include <lm.h>
/*
* 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 */
{
int rc;
"lm_activate: lm_library_config failed, rc %d", rc);
return (LM_ERROR);
}
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
{
int rc;
int lmpl_tid;
char *kw;
char msg_str[256];
char text_str[256];
char cfg_str[1024];
mms_pn_token(side));
"to generate config command for mount");
return (LM_ERROR);
}
"encountered while processing lmpl config command");
return (LM_ERROR);
} else if (rc != LMPL_FINAL_OK) {
"a successful response");
return (LM_ERROR);
}
"config command");
NULL);
msg_str);
return (LM_OK);
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
{
int rc;
int lmpl_tid;
char *kw;
char msg_str[256];
char text_str[256];
char cfg_str[1024];
"lm_unmount: lm_obtain_task_id failed trying "
"to generate config command for unmount");
return (LM_ERROR);
}
"encountered while processing lmpl config command");
return (LM_ERROR);
} else if (rc != LMPL_FINAL_OK) {
"a successful response");
return (LM_ERROR);
}
"config command");
NULL);
msg_str);
return (LM_OK);
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 */
{
char msg_str[256];
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 */
{
char msg_str[256];
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
{
int i;
int rc;
int lmpl_tid;
char *kw;
char *config_buf = NULL;
char msg_str[512];
char cfg_str[512];
char cmd_str[1024];
/* See if scan is for cartridge(s) */
!= NULL) {
}
}
/* Generate list of cartridges to scan for */
/* Obtain slot-name */
"lm_scan: No pcl string found "
"in text clause of cartridge scan");
return (LM_ERROR);
}
if (i == MAX_CONFIG_CARTS) {
"to scan exceeded the max allowed of "
"%d, skipping cartridge %s",
} else {
if (i != 0)
"lm_scan: scan for cartridge "
!= LM_OK) {
"lm_scan: Unable to "
"get a task id for show slot "
"occupied command");
return (LM_ERROR);
}
mms_pn_token(pcl));
"processing error encountered "
"while processing LMPL show "
"slot occupied command");
return (LM_ERROR);
} else if (rc != LMPL_FINAL_OK) {
"did not receive a successful "
"response, unable to get pcl "
"%s's occupied state",
mms_pn_token(pcl));
return (LM_ERROR);
}
resp_clause = NULL;
"clause found in show occupied for "
return (LM_ERROR);
}
"lm_scan: No occupied "
"string found in show occupied for "
return (LM_ERROR);
}
"lm_scan: pcl %s occupied is "
mms_pn_token(occ));
"false");
else
"true");
cfg_str);
mms_pn_token(pcl));
}
}
"id for config slot command");
return (LM_ERROR);
}
if (config_buf != NULL)
config_buf = NULL;
"config task[\"%d\"] scope[partial] %s",
config_ele, 0)) == LM_ERROR) {
"error encountered while processing lmpl "
"config slot command");
return (LM_ERROR);
} else if (rc != LMPL_FINAL_OK) {
"success response for lmpl config slot "
"command");
ret_msg);
return (LM_ERROR);
}
"for scan config slot command");
NULL);
"lm_scan: scan for cartridges from %s to %s",
"supported on a DiskArchiving library, sending error "
"response for scan command");
return (LM_ERROR);
}
}
/* Setup to send partial config for drives */
"lm_scan: No drive name string "
"found in text clause of drive scan");
return (LM_ERROR);
}
if (i == MAX_CONFIG_DRIVES) {
"to scan exceeded the max allowed of "
"%d, skipping drive %s",
} else {
if (i != 0)
if (lm_obtain_task_id(&lmpl_tid,
"lm_scan: Unable to get a task id "
"for config drive command");
return (LM_ERROR);
}
"processing error encountered "
"while processing LMPL show cmd");
return (LM_ERROR);
} else if (rc != LMPL_FINAL_OK) {
"did not receive a successful "
"response, unable to get drive "
"%s's drive name",
return (LM_ERROR);
}
resp_clause = NULL;
"clause found in show pcl for "
return (LM_ERROR);
}
"string found in show pcl for "
return (LM_ERROR);
}
"lm_scan: drive %s pcl is %s",
"false", "true");
} else {
"true");
}
cfg_str);
}
}
"for config drive command");
return (LM_ERROR);
}
if (config_buf != NULL)
config_buf = NULL;
"config task[\"%d\"] scope[partial] %s",
== LM_ERROR) {
"error encountered while processing lmpl "
"config drive command");
return (LM_ERROR);
} else if (rc != LMPL_FINAL_OK) {
"success response for lmpl config drive "
"command");
ret_msg);
return (LM_ERROR);
}
"for scan config drive command");
} else {
"to MM. Unable to set state to not ready");
}
return (LM_ERROR);
}
"lm_scan: rescan of entire library completed");
"to MM. Unable to set state to ready");
return (LM_ERROR);
}
NULL);
}
return (LM_OK);
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 */
{
"full reset of an DISK library");
}
"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 */
{
char msg_str[256];
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 */
{
char msg_str[256];
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 */
{
char msg_str[256];
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 */
{
char msg_str[512];
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 */
{
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 */
{
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
{
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;
/* Configure bays and slot groups */
"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 */
cmd_str);
"processing error encountered while processing "
"full config command");
return (LM_ERROR);
} else if (rc != LMPL_FINAL_OK) {
"lm_library_config: Error encountered while "
"sending full config command");
return (LM_ERROR);
}
"full creation config command");
/* Obtain the number of cartridges in library */
"lm_library_config: Unable to get a task id "
"for show command to obtain number of cartridges in "
"disk library");
return (LM_ERROR);
}
"libary:\n%s", cmd_str);
"processing error encountered while processing "
"show command to get number of cartridges in library");
return (LM_ERROR);
} else if (rc != LMPL_FINAL_OK) {
"lm_library_config: Error encountered while "
"sending show command to get number of cartridges in "
"disk library");
return (LM_ERROR);
}
if (num_carts == 0)
goto skip_carts;
if (num_carts > MAX_CONFIG_CARTS)
else
"for slot spec definitions, errno - %s",
return (LM_ERROR);
}
/* Create slot configs for each cartridge */
"lm_library_config: Unable to get a task id "
"for show command to obtain list of cartridges");
return (LM_ERROR);
}
"processing error encountered while processing "
"for show command to obtain list of cartridges");
return (LM_ERROR);
} else if (rc != LMPL_FINAL_OK) {
"lm_library_config: Error encountered while "
"sending show command to obtain list of cartridges in "
"disk library");
return (LM_ERROR);
}
do {
rsp_cnt = 0;
do {
"lm_lib_config:, Validating a "
"text clause");
return (LM_ERROR);
}
return (LM_ERROR);
}
"lm_lib_config: cartridge pcl "
mms_pn_token(occ));
"false");
else
"true");
"spec - %s", cfg_str);
rsp_cnt++;
} else {
}
}
"lm_library_config: Unable to get a "
"task id for config slot command");
return (LM_ERROR);
}
"lm_lib_config: SLOT_SPEC:\n%s", slot_spec);
== LM_ERROR) {
"processing error encountered while processing "
"lmpl config slot command");
return (LM_ERROR);
} else if (rc != LMPL_FINAL_OK) {
"lm_activate: Error encountered while "
"sending lmpl config slot command");
return (LM_ERROR);
}
"for slot creation config command");
"lm_library_config: Unable to get a task id "
"for show command to obtain number of drives in "
"library");
return (LM_ERROR);
}
"disk libary:\n%s", cmd_str);
"processing error encountered while processing "
"show command to get number of drives in library");
return (LM_ERROR);
} else if (rc != LMPL_FINAL_OK) {
"lm_library_config: Error encountered while "
"sending show command to get number of drives in library");
return (LM_ERROR);
}
"- %d", num_drives);
/* If no drives to process return */
if (num_drives == 0)
return (LM_OK);
if (num_drives > MAX_CONFIG_DRIVES)
else
"for drive spec definitions, errno - %s",
return (LM_ERROR);
}
"lm_library_config: Unable to get a task id "
"for show command to obtain list of drives");
return (LM_ERROR);
}
"processing error encountered while processing "
"for show command to obtain list of drives");
return (LM_ERROR);
} else if (rc != LMPL_FINAL_OK) {
"lm_library_config: Error encountered while "
"sending show command to obtain list of drives in "
"disk library");
return (LM_ERROR);
}
do {
(void) strcpy(drive_spec,
"config task[\"%d\"] scope[partial] ");
rsp_cnt = 0;
do {
"Validating a text clause");
return (LM_ERROR);
}
return (LM_ERROR);
}
"false", "true");
"Drive spec - %s", cfg_str);
} else {
"true");
"Drive spec - %s", cfg_str);
}
rsp_cnt++;
} else {
}
}
"lm_lib_config: Unable to get a task id "
"for config drive command");
return (LM_ERROR);
}
drive_spec = fmt;
== LM_ERROR) {
"processing error encountered while processing "
"lmpl config drive command");
return (LM_ERROR);
} else if (rc != LMPL_FINAL_OK) {
"lm_lib_config: Error encountered while "
"sending lmpl config drive command");
return (LM_ERROR);
}
"for drive creation config command");
return (LM_OK);
return (LM_ERROR);
}