X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=changer-src%2Fscsi-solaris.c;h=33cf87546af01d8e81919fd36615d052c43f2662;hb=fd48f3e498442f0cbff5f3606c7c403d0566150e;hp=c20003fc733d153db79d1d097a5b05a675609796;hpb=1194fb66aa28d9929c3f2bef3cc6c1c3f40a60a4;p=debian%2Famanda diff --git a/changer-src/scsi-solaris.c b/changer-src/scsi-solaris.c index c20003f..33cf875 100644 --- a/changer-src/scsi-solaris.c +++ b/changer-src/scsi-solaris.c @@ -24,7 +24,7 @@ * 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 * @@ -32,35 +32,17 @@ */ -#include - -#ifdef HAVE_SOLARIS_LIKE_SCSI -/* -#ifdef HAVE_STDIO_H -*/ -#include -/* -#endif -*/ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#ifdef HAVE_FCNTL_H -#include -#endif +#include "amanda.h" #include #include #include -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 } @@ -82,7 +64,7 @@ int SCSI_OpenDevice(int ip) 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) { @@ -111,14 +93,12 @@ int SCSI_OpenDevice(int ip) 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 { @@ -147,23 +127,26 @@ int SCSI_CloseDevice(int DeviceFD) 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); @@ -175,8 +158,8 @@ int SCSI_ExecuteCommand(int DeviceFD, 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: @@ -196,7 +179,7 @@ int SCSI_ExecuteCommand(int DeviceFD, /* 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) { @@ -211,8 +194,8 @@ int SCSI_ExecuteCommand(int DeviceFD, | 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) { @@ -228,24 +211,19 @@ int SCSI_ExecuteCommand(int DeviceFD, 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); } /* @@ -274,7 +252,7 @@ int Tape_Ioctl( int DeviceFD, int command) 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); } @@ -289,13 +267,14 @@ int Tape_Status( int DeviceFD) 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); } @@ -306,8 +285,8 @@ int Tape_Status( int DeviceFD) * 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) { @@ -326,10 +305,10 @@ int Tape_Status( int DeviceFD) int ScanBus(int print) { + (void)print; /* Quiet unused parameter warning */ return(-1); } -#endif /* * Local variables: * indent-tabs-mode: nil