/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* s_generic.c :
* This file contains generic SCSI related functions for scsi plug-in
* for libsm.so.
*/
#include <unistd.h>
#include <smserver.h>
#include <dirent.h>
#include <fcntl.h>
#include <strings.h>
#include "../../../library/common/l_defines.h"
{
DPRINTF("get_media_info called.\n");
/* Check for valid handle */
DPRINTF("Null Handle\n");
return (-1);
}
DPRINTF("Invalid signature in handle.\n");
"Signature expected=0x%x, found=0x%x\n",
return (-1);
}
if (ret_val < 0) {
perror("door_call");
return (-1);
}
return (-1);
}
return (0);
}
{
/* Check for valid handle */
DPRINTF("Null Handle\n");
return (-1);
}
DPRINTF("Invalid signature in handle.\n");
return (-1);
}
if (vendor_name == NULL) {
if (!errno)
return (-1);
}
if (product_name == NULL) {
if (!errno)
return (-1);
}
if (fw_version == NULL) {
if (!errno)
return (-1);
}
if (ret_val < 0) {
perror("door_call");
return (-1);
}
return (-1);
}
#ifdef DEBUG
#endif /* DEBUG */
return (0);
}
{
/* Check for valid handle */
DPRINTF("Null Handle\n");
return (-1);
}
DPRINTF("Invalid signature in handle.\n");
return (-1);
}
return (0);
}
{
/* Check for valid handle */
DPRINTF("Null Handle\n");
return (-1);
}
DPRINTF("Invalid signature in handle.\n");
return (-1);
}
if (ret_val < 0) {
perror("door_call");
goto error;
}
"Error in raw write. errnum = 0x%x blk_num = 0x%x(%d)\n",
goto error;
}
return (retraw_write->nbytes);
return (-1);
}
{
/* Check for valid handle */
DPRINTF("Null Handle\n");
return (size_t)(-1);
}
DPRINTF("Invalid signature in handle.\n");
return (size_t)(-1);
}
/*
* Check if another thread is doing an IO with same handle.
* In that case ww block here.
*/
if (ret_val < 0) {
perror("door_call");
goto error;
}
/*
* free(rbuf);
*/
"Error in raw read. errnum = 0x%x blk_num = 0x%x(%d)\n",
goto error;
}
return (bytes_read);
return (size_t)(-1);
}
{
/* Check for valid handle */
DPRINTF("Null Handle\n");
return (size_t)(-1);
}
DPRINTF("Invalid signature in handle.\n");
return (size_t)(-1);
}
if (ret_val < 0) {
perror("door_call");
return (size_t)(-1);
}
#ifdef lint
#endif
return (size_t)(-1);
}
return (0);
}
{
/* Check for valid handle */
DPRINTF("Null Handle\n");
return (-1);
}
DPRINTF("Invalid signature in handle.\n");
return (-1);
}
if (ret_val < 0) {
perror("door_call");
return (-1);
}
return (-1);
}
sizeof (smwp_state_t));
return (0);
}
/* Check for valid handle */
DPRINTF("Null Handle\n");
return (-1);
}
DPRINTF("Invalid signature in handle.\n");
return (-1);
}
if (ret_val < 0) {
perror("door_call");
return (-1);
}
return (-1);
}
return (0);
}
{
/* Check for valid handle */
DPRINTF("Null Handle\n");
return (-1);
}
DPRINTF("Invalid signature in handle.\n");
return (-1);
}
if (ret_val < 0) {
perror("door_call");
return (-1);
}
"Error in reassign_block. block = 0x%x errnum = 0x%x \n",
return (-1);
}
return (0);
}
/* ARGSUSED1 */
{
/* Check for valid handle */
DPRINTF("Null Handle\n");
return (-1);
}
DPRINTF("Invalid signature in handle.\n");
return (-1);
}
}
{
if ((ctype == DKC_SCSI_CCS) ||
if (mtype == 0)
return (0);
}
return (-1);
}
_m_version_no(void)
{
return (SM_SCSI_VERSION_1);
}
{
#ifdef lint
#endif
/* Check for valid handle */
DPRINTF("Null Handle\n");
return (-1);
}
DPRINTF("Invalid signature in handle.\n");
return (-1);
}
if (ret_val < 0) {
perror("door_call");
return (-1);
}
return (-1);
}
return (retcheck_format_status->percent_complete);
}
{
/* Check for valid handle */
DPRINTF("Null Handle\n");
return (-1);
}
DPRINTF("Invalid signature in handle.\n");
return (-1);
}
/*
* We will be validating the user supplied buffer lengths and
* buffer pointers.
*/
DPRINTF("Invalid cdblen specified.\n");
return (-1);
}
DPRINTF("Invalid rqlen specified.\n");
return (-1);
}
DPRINTF("cdb buffer is NULL.\n");
return (-1);
}
DPRINTF("bufaddr is NULL.\n");
return (-1);
}
DPRINTF("rqbuf is NULL.\n");
return (-1);
}
/*
* Check if another thread is doing an IO with same handle.
* In that case we block here.
*/
if (ret_val != 0) {
DPRINTF("remap of shared buf failed.\n");
goto error;
}
/*
* The uscsi_buflen has been validated in the call to
* remap_shared_buf() done earlier.
*/
/* Check for write */
}
if (ret_val < 0) {
perror("door_call");
goto error;
}
goto error;
}
}
if (errno) {
goto error;
}
/*
* Invalid resid value. return error.
*/
goto error;
}
}
#ifdef DEBUG
DPRINTF2("Error in uscsi_cmd: retval=0x%x uscsi_status=0x%x\n",
#endif
return (retuscsi_cmd->uscsi_retval);
return (-1);
}
{
char *fbuf;
return (0);
/* extend the file and re-map */
if (ret_val != 0) {
handle->sm_bufsize = 0;
return (errno);
}
if (file_size == -1) {
return (errno);
}
handle->sm_bufsize = 0;
} else {
/* create a new file and mapping */
if (fd == -1) {
return (errno);
}
if (ret_val == -1) {
return (errno);
}
file_size = 0;
}
/* Need to start at the beginning of the file when enlarging */
if (ret == -1) {
return (errno);
}
while (file_size < shared_bufsize) {
return (errno);
}
}
MAP_SHARED, fd, 0);
if (fbuf == (char *)-1) {
perror("mmap failed");
return (errno);
}
if (ret_val < 0) {
perror("door_call");
return (-1);
}
DPRINTF1("Error in set shfd. errnum = 0x%x\n",
return (errno);
}
DPRINTF("Returned successful from remap shared buf routine.\n");
return (0);
}