* file named AUTHORS, in the root directory of this distribution.
*/
/*
- * $Id: scsi-solaris.c,v 1.25 2005/10/15 13:20:47 martinea Exp $
+ * $Id: scsi-solaris.c,v 1.26 2006/05/25 01:47:10 johnfranks Exp $
*
* Interface to execute SCSI commands on an Sun Workstation
*
*/
-#include <amanda.h>
-
-#ifdef HAVE_SOLARIS_LIKE_SCSI
-/*
-#ifdef HAVE_STDIO_H
-*/
-#include <stdio.h>
-/*
-#endif
-*/
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
+#include "amanda.h"
#include <sys/scsi/impl/uscsi.h>
#include <scsi-defs.h>
#include <sys/mtio.h>
-void SCSI_OS_Version()
+void SCSI_OS_Version(void)
{
#ifndef lint
- static char rcsid[] = "$Id: scsi-solaris.c,v 1.25 2005/10/15 13:20:47 martinea Exp $";
+ static char rcsid[] = "$Id: scsi-solaris.c,v 1.26 2006/05/25 01:47:10 johnfranks Exp $";
DebugPrint(DEBUG_INFO, SECTION_INFO, "scsi-os-layer: %s\n",rcsid);
#endif
}
pDev[ip].devopen = 1;
pDev[ip].inquiry = (SCSIInquiry_T *)malloc(INQUIRY_SIZE);
- if (SCSI_Inquiry(ip, pDev[ip].inquiry, INQUIRY_SIZE) == 0)
+ if (SCSI_Inquiry(ip, pDev[ip].inquiry, (unsigned char)INQUIRY_SIZE) == 0)
{
if (pDev[ip].inquiry->type == TYPE_TAPE || pDev[ip].inquiry->type == TYPE_CHANGER)
{
free(pDev[ip].inquiry);
return(0);
}
- } else {
- free(pDev[ip].inquiry);
- pDev[ip].inquiry = NULL;
- return(1);
}
- return(1);
+ free(pDev[ip].inquiry);
+ pDev[ip].inquiry = NULL;
+ return(1);
} else {
- dbprintf(("SCSI_OpenDevice %s failed\n", pDev[ip].dev));
+ dbprintf(_("SCSI_OpenDevice %s failed\n"), pDev[ip].dev);
return(0);
}
} else {
int SCSI_ExecuteCommand(int DeviceFD,
Direction_T Direction,
CDB_T CDB,
- int CDB_Length,
+ size_t CDB_Length,
void *DataBuffer,
- int DataBufferLength,
- char *pRequestSense,
- int RequestSenseLength)
+ size_t DataBufferLength,
+ RequestSense_T *RequestSense,
+ size_t RequestSenseLength)
{
extern OpenFiles_T *pDev;
extern FILE * debug_file;
int ret = 0;
int retries = 1;
- extern int errno;
struct uscsi_cmd Command;
-#if 0
- ExtendedRequestSense_T pExtendedRequestSense;
-#endif
static int depth = 0;
+ /* Basic sanity checks */
+ assert(CDB_Length <= UCHAR_MAX);
+ assert(RequestSenseLength <= UCHAR_MAX);
+
+ /* Clear buffer for cases where sense is not returned */
+ memset(RequestSense, 0, RequestSenseLength);
+
if (pDev[DeviceFD].avail == 0)
{
return(SCSI_ERROR);
SCSI_CloseDevice(DeviceFD);
return SCSI_ERROR;
}
- memset(&Command, 0, sizeof(struct uscsi_cmd));
- memset(pRequestSense, 0, RequestSenseLength);
+ memset(&Command, 0, SIZEOF(struct uscsi_cmd));
+ memset(RequestSense, 0, RequestSenseLength);
switch (Direction)
{
case Input:
/* Set timeout to 5 minutes. */
Command.uscsi_timeout = 300;
Command.uscsi_cdb = (caddr_t) CDB;
- Command.uscsi_cdblen = CDB_Length;
+ Command.uscsi_cdblen = (u_char)CDB_Length;
if (DataBufferLength > 0)
{
| USCSI_WRITE | USCSI_RQENABLE;
}
- Command.uscsi_rqbuf = (caddr_t) pRequestSense;
- Command.uscsi_rqlen = RequestSenseLength;
+ Command.uscsi_rqbuf = (caddr_t)RequestSense;
+ Command.uscsi_rqlen = (u_char)RequestSenseLength;
DecodeSCSI(CDB, "SCSI_ExecuteCommand : ");
while (retries > 0)
{
ret = Command.uscsi_status;
break;
}
- dbprintf(("ioctl on %d failed, errno %d, ret %d\n",pDev[DeviceFD].fd, errno, ret));
+ dbprintf(_("ioctl on %d failed, errno %s, ret %d\n"),
+ pDev[DeviceFD].fd, strerror(errno), ret);
#if 0
RequestSense(DeviceFD, &pExtendedRequestSense, 0);
#endif
- DecodeSense((RequestSense_T *)pRequestSense,
- "SCSI_ExecuteCommand:", debug_file);
+ DecodeSense(RequestSense, "SCSI_ExecuteCommand:", debug_file);
retries--;
}
--depth;
SCSI_CloseDevice(DeviceFD);
- switch (ret)
- {
- default:
- DebugPrint(DEBUG_INFO, SECTION_SCSI,"ioctl ret (%d)\n",ret);
- return(SCSI_OK);
- break;
- }
+ DebugPrint(DEBUG_INFO, SECTION_SCSI,_("ioctl ret (%d)\n"),ret);
+ return(SCSI_OK);
}
/*
if (ioctl(pDev[DeviceFD].fd , MTIOCTOP, &mtop) != 0)
{
- dbprintf(("Tape_Ioctl error ioctl %d\n",errno));
+ dbprintf(_("Tape_Ioctl error ioctl %s\n"), strerror(errno));
SCSI_CloseDevice(DeviceFD);
return(-1);
}
struct mtget mtget;
int ret = -1;
+ memset(&mtget, 0, SIZEOF(mtget));
if (pDev[DeviceFD].devopen == 0)
if (SCSI_OpenDevice(DeviceFD) == 0)
return(-1);
if (ioctl(pDev[DeviceFD].fd , MTIOCGET, &mtget) != 0)
{
- dbprintf(("Tape_Status error ioctl %d\n",errno));
+ dbprintf(_("Tape_Status error ioctl %s\n"), strerror(errno));
SCSI_CloseDevice(DeviceFD);
return(-1);
}
* 0x2 is no tape online
*/
- DebugPrint(DEBUG_INFO, SECTION_TAPE, "ioctl result for mt_dsreg (%d)\n", mtget.mt_dsreg);
- DebugPrint(DEBUG_INFO, SECTION_TAPE, "ioctl result for mt_erreg (%d)\n", mtget.mt_erreg);
+ DebugPrint(DEBUG_INFO, SECTION_TAPE, _("ioctl result for mt_dsreg (%d)\n"), mtget.mt_dsreg);
+ DebugPrint(DEBUG_INFO, SECTION_TAPE, _("ioctl result for mt_erreg (%d)\n"), mtget.mt_erreg);
if (mtget.mt_erreg == 0)
{
int ScanBus(int print)
{
+ (void)print; /* Quiet unused parameter warning */
return(-1);
}
-#endif
/*
* Local variables:
* indent-tabs-mode: nil