projects
/
debian
/
amanda
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Imported Upstream version 3.1.0
[debian/amanda]
/
changer-src
/
scsi-solaris.c
diff --git
a/changer-src/scsi-solaris.c
b/changer-src/scsi-solaris.c
index c20003fc733d153db79d1d097a5b05a675609796..33cf87546af01d8e81919fd36615d052c43f2662 100644
(file)
--- 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.
*/
/*
* file named AUTHORS, in the root directory of this distribution.
*/
/*
- * $Id: scsi-solaris.c,v 1.2
5 2005/10/15 13:20:47 martinea
Exp $
+ * $Id: scsi-solaris.c,v 1.2
6 2006/05/25 01:47:10 johnfranks
Exp $
*
* Interface to execute SCSI commands on an Sun Workstation
*
*
* Interface to execute SCSI commands on an Sun Workstation
*
@@
-32,35
+32,17
@@
*/
*/
-#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>
#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
{
#ifndef lint
- static char rcsid[] = "$Id: scsi-solaris.c,v 1.2
5 2005/10/15 13:20:47 martinea
Exp $";
+ static char rcsid[] = "$Id: scsi-solaris.c,v 1.2
6 2006/05/25 01:47:10 johnfranks
Exp $";
DebugPrint(DEBUG_INFO, SECTION_INFO, "scsi-os-layer: %s\n",rcsid);
#endif
}
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);
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)
{
{
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);
}
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 {
} else {
- dbprintf(
("SCSI_OpenDevice %s failed\n", pDev[ip].dev)
);
+ dbprintf(
_("SCSI_OpenDevice %s failed\n"), pDev[ip].dev
);
return(0);
}
} else {
return(0);
}
} else {
@@
-147,23
+127,26
@@
int SCSI_CloseDevice(int DeviceFD)
int SCSI_ExecuteCommand(int DeviceFD,
Direction_T Direction,
CDB_T CDB,
int SCSI_ExecuteCommand(int DeviceFD,
Direction_T Direction,
CDB_T CDB,
-
in
t CDB_Length,
+
size_
t CDB_Length,
void *DataBuffer,
void *DataBuffer,
-
in
t DataBufferLength,
-
char *p
RequestSense,
-
in
t 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 OpenFiles_T *pDev;
extern FILE * debug_file;
int ret = 0;
int retries = 1;
- extern int errno;
struct uscsi_cmd Command;
struct uscsi_cmd Command;
-#if 0
- ExtendedRequestSense_T pExtendedRequestSense;
-#endif
static int depth = 0;
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);
if (pDev[DeviceFD].avail == 0)
{
return(SCSI_ERROR);
@@
-175,8
+158,8
@@
int SCSI_ExecuteCommand(int DeviceFD,
SCSI_CloseDevice(DeviceFD);
return SCSI_ERROR;
}
SCSI_CloseDevice(DeviceFD);
return SCSI_ERROR;
}
- memset(&Command, 0,
sizeof
(struct uscsi_cmd));
- memset(
p
RequestSense, 0, RequestSenseLength);
+ memset(&Command, 0,
SIZEOF
(struct uscsi_cmd));
+ memset(RequestSense, 0, RequestSenseLength);
switch (Direction)
{
case Input:
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;
/* 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)
{
if (DataBufferLength > 0)
{
@@
-211,8
+194,8
@@
int SCSI_ExecuteCommand(int DeviceFD,
| USCSI_WRITE | USCSI_RQENABLE;
}
| USCSI_WRITE | USCSI_RQENABLE;
}
- Command.uscsi_rqbuf = (caddr_t)
p
RequestSense;
- Command.uscsi_rqlen = RequestSenseLength;
+ Command.uscsi_rqbuf = (caddr_t)RequestSense;
+ Command.uscsi_rqlen =
(u_char)
RequestSenseLength;
DecodeSCSI(CDB, "SCSI_ExecuteCommand : ");
while (retries > 0)
{
DecodeSCSI(CDB, "SCSI_ExecuteCommand : ");
while (retries > 0)
{
@@
-228,24
+211,19
@@
int SCSI_ExecuteCommand(int DeviceFD,
ret = Command.uscsi_status;
break;
}
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
#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);
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)
{
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);
}
SCSI_CloseDevice(DeviceFD);
return(-1);
}
@@
-289,13
+267,14
@@
int Tape_Status( int DeviceFD)
struct mtget mtget;
int ret = -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)
{
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);
}
SCSI_CloseDevice(DeviceFD);
return(-1);
}
@@
-306,8
+285,8
@@
int Tape_Status( int DeviceFD)
* 0x2 is no tape online
*/
* 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)
{
if (mtget.mt_erreg == 0)
{
@@
-326,10
+305,10
@@
int Tape_Status( int DeviceFD)
int ScanBus(int print)
{
int ScanBus(int print)
{
+ (void)print; /* Quiet unused parameter warning */
return(-1);
}
return(-1);
}
-#endif
/*
* Local variables:
* indent-tabs-mode: nil
/*
* Local variables:
* indent-tabs-mode: nil