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-bsd.c
diff --git
a/changer-src/scsi-bsd.c
b/changer-src/scsi-bsd.c
index bd010667520414e007f6e1216eea7865ea2d3d26..bff9495212da01eb1d4c9fc35e5a77c854532c8c 100644
(file)
--- a/
changer-src/scsi-bsd.c
+++ b/
changer-src/scsi-bsd.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-bsd.c,v 1.1
7 2005/10/15 13:20:47 martinea
Exp $
+ * $Id: scsi-bsd.c,v 1.1
8 2006/05/25 01:47:07 johnfranks
Exp $
*
* Interface to execute SCSI commands on an BSD System (FreeBSD)
*
*
* Interface to execute SCSI commands on an BSD System (FreeBSD)
*
@@
-32,26
+32,7
@@
*/
*/
-#include <amanda.h>
-
-#ifdef HAVE_BSD_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/scsiio.h>
#include <sys/mtio.h>
#include <sys/scsiio.h>
#include <sys/mtio.h>
@@
-61,7
+42,7
@@
void SCSI_OS_Version()
{
#ifndef lint
void SCSI_OS_Version()
{
#ifndef lint
- static char rcsid[] = "$Id: scsi-bsd.c,v 1.1
7 2005/10/15 13:20:47 martinea
Exp $";
+ static char rcsid[] = "$Id: scsi-bsd.c,v 1.1
8 2006/05/25 01:47:07 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
}
@@
-163,11
+144,11
@@
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
*pRequestSense,
-
in
t RequestSenseLength)
+
size_
t DataBufferLength,
+
RequestSense_T
*pRequestSense,
+
size_
t RequestSenseLength)
{
extern OpenFiles_T *pDev;
ExtendedRequestSense_T ExtendedRequestSense;
{
extern OpenFiles_T *pDev;
ExtendedRequestSense_T ExtendedRequestSense;
@@
-176,14
+157,21
@@
int SCSI_ExecuteCommand(int DeviceFD,
int retries = 5;
extern int errno;
int retries = 5;
extern int errno;
+ /* Basic sanity checks */
+ assert(CDB_Length <= UCHAR_MAX);
+ assert(RequestSenseLength <= UCHAR_MAX);
+
+ /* Clear buffer for cases where sense is not returned */
+ memset(pRequestSense, 0, RequestSenseLength);
+
if (pDev[DeviceFD].avail == 0)
{
return(SCSI_ERROR);
}
if (pDev[DeviceFD].avail == 0)
{
return(SCSI_ERROR);
}
- memset(&ds, 0,
sizeof
(scsireq_t));
+ memset(&ds, 0,
SIZEOF
(scsireq_t));
memset(pRequestSense, 0, RequestSenseLength);
memset(pRequestSense, 0, RequestSenseLength);
- memset(&ExtendedRequestSense, 0 ,
sizeof
(ExtendedRequestSense_T));
+ memset(&ExtendedRequestSense, 0 ,
SIZEOF
(ExtendedRequestSense_T));
ds.flags = SCCMD_ESCAPE;
/* Timeout */
ds.flags = SCCMD_ESCAPE;
/* Timeout */
@@
-224,20
+212,21
@@
int SCSI_ExecuteCommand(int DeviceFD,
memcpy(pRequestSense, ds.sense, RequestSenseLength);
if (Result < 0)
{
memcpy(pRequestSense, ds.sense, RequestSenseLength);
if (Result < 0)
{
- dbprintf(
("errno : %d\n",
errno));
+ dbprintf(
"errno : %s\n",strerror(
errno));
return (SCSI_ERROR);
}
return (SCSI_ERROR);
}
- dbprintf(
("SCSI_ExecuteCommand(BSD) %02X STATUS(%02X) \n", CDB[0], ds.retsts)
);
+ dbprintf(
"SCSI_ExecuteCommand(BSD) %02X STATUS(%02X) \n", CDB[0], ds.retsts
);
switch (ds.retsts)
{
case SCCMD_BUSY: /* BUSY */
break;
switch (ds.retsts)
{
case SCCMD_BUSY: /* BUSY */
break;
+
case SCCMD_OK: /* GOOD */
return(SCSI_OK);
case SCCMD_OK: /* GOOD */
return(SCSI_OK);
- break;
+
case SCCMD_SENSE: /* CHECK CONDITION */
return(SCSI_SENSE);
case SCCMD_SENSE: /* CHECK CONDITION */
return(SCSI_SENSE);
- break;
+
default:
continue;
}
default:
continue;
}
@@
-271,7
+260,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);
}
@@
-296,7
+285,6
@@
int ScanBus(int print)
return(-1);
}
return(-1);
}
-#endif
/*
* Local variables:
* indent-tabs-mode: nil
/*
* Local variables:
* indent-tabs-mode: nil