projects
/
debian
/
amanda
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
clean up the common package
[debian/amanda]
/
changer-src
/
scsi-irix.c
diff --git
a/changer-src/scsi-irix.c
b/changer-src/scsi-irix.c
index b747884d54f7d6d26d8842f9be00505e2a9b91d3..412a648ec2dccb72935858d429e118562933a6a3 100644
(file)
--- a/
changer-src/scsi-irix.c
+++ b/
changer-src/scsi-irix.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-irix.c,v 1.2
2 2005/10/15 13:20:47 martinea
Exp $
+ * $Id: scsi-irix.c,v 1.2
3 2006/05/25 01:47:08 johnfranks
Exp $
*
* Interface to execute SCSI commands on an SGI Workstation
*
*
* Interface to execute SCSI commands on an SGI Workstation
*
@@
-32,26
+32,7
@@
*/
*/
-#include <amanda.h>
-
-#ifdef HAVE_IRIX_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.h>
#include <sys/dsreq.h>
#include <sys/scsi.h>
#include <sys/dsreq.h>
@@
-62,7
+43,7
@@
void SCSI_OS_Version()
{
#ifndef lint
void SCSI_OS_Version()
{
#ifndef lint
- static char rcsid[] = "$Id: scsi-irix.c,v 1.2
2 2005/10/15 13:20:47 martinea
Exp $";
+ static char rcsid[] = "$Id: scsi-irix.c,v 1.2
3 2006/05/25 01:47:08 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
}
@@
-116,23
+97,13
@@
int SCSI_OpenDevice(int ip)
pDev[ip].avail = 0;
return(0);
}
pDev[ip].avail = 0;
return(0);
}
- } else { /* inquiry failed */
- close(DeviceFD);
- free(pDev[ip].inquiry);
- pDev[ip].inquiry = NULL;
- pDev[ip].avail = 0;
- return(0);
}
}
-
- /*
- * Open ok, but no SCSI communication available
- */
-
- free(pDev[ip].inquiry);
- pDev[ip].inquiry = NULL;
- close(DeviceFD);
- pDev[ip].avail = 0;
- return(0);
+ /* inquiry failed or no SCSI communication available */
+ close(DeviceFD);
+ free(pDev[ip].inquiry);
+ pDev[ip].inquiry = NULL;
+ pDev[ip].avail = 0;
+ return(0);
}
} else {
if ((DeviceFD = open(pDev[ip].dev, O_RDWR | O_EXCL)) >= 0)
}
} else {
if ((DeviceFD = open(pDev[ip].dev, O_RDWR | O_EXCL)) >= 0)
@@
-165,11
+136,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;
@@
-177,14
+148,21
@@
int SCSI_ExecuteCommand(int DeviceFD,
int Result;
int retries = 5;
int Result;
int retries = 5;
+ /* 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
(struct dsreq));
+ memset(&ds, 0,
SIZEOF
(struct dsreq));
memset(pRequestSense, 0, RequestSenseLength);
memset(pRequestSense, 0, RequestSenseLength);
- memset(&ExtendedRequestSense, 0 ,
sizeof
(ExtendedRequestSense_T));
+ memset(&ExtendedRequestSense, 0 ,
SIZEOF
(ExtendedRequestSense_T));
ds.ds_flags = DSRQ_SENSE|DSRQ_TRACE|DSRQ_PRINT;
/* Timeout */
ds.ds_flags = DSRQ_SENSE|DSRQ_TRACE|DSRQ_PRINT;
/* Timeout */
@@
-214,9
+192,9
@@
int SCSI_ExecuteCommand(int DeviceFD,
{
if (SCSI_OpenDevice(DeviceFD) == 0)
{
{
if (SCSI_OpenDevice(DeviceFD) == 0)
{
- dbprintf(
("SCSI_ExecuteCommand could not open %s: %s\n"
,
+ dbprintf(
_("SCSI_ExecuteCommand could not open %s: %s\n")
,
pDev[DeviceFD].dev,
pDev[DeviceFD].dev,
- strerror(errno))
)
;
+ strerror(errno));
sleep(1); /* Give device a little time befor retry */
continue;
}
sleep(1); /* Give device a little time befor retry */
continue;
}
@@
-231,40
+209,33
@@
int SCSI_ExecuteCommand(int DeviceFD,
return (SCSI_ERROR);
}
DecodeSCSI(CDB, "SCSI_ExecuteCommand : ");
return (SCSI_ERROR);
}
DecodeSCSI(CDB, "SCSI_ExecuteCommand : ");
- dbprintf(
("\t\t\tSTATUS(%02X) RET(%02X)\n", STATUS(&ds), RET(&ds)
));
+ dbprintf(
_("\t\t\tSTATUS(%02X) RET(%02X)\n"), STATUS(&ds), RET(&ds
));
switch (STATUS(&ds))
{
case ST_BUSY: /* BUSY */
break;
switch (STATUS(&ds))
{
case ST_BUSY: /* BUSY */
break;
+
case STA_RESERV: /* RESERV CONFLICT */
if (retries > 0)
sleep(2);
continue;
case STA_RESERV: /* RESERV CONFLICT */
if (retries > 0)
sleep(2);
continue;
+
case ST_GOOD: /* GOOD 0x00 */
switch (RET(&ds))
{
case DSRT_SENSE:
return(SCSI_SENSE);
case ST_GOOD: /* GOOD 0x00 */
switch (RET(&ds))
{
case DSRT_SENSE:
return(SCSI_SENSE);
- break;
- case DSRT_SHORT:
- return(SCSI_OK);
- break;
- case DSRT_OK:
- default:
- return(SCSI_OK);
}
}
+ return(SCSI_OK);
+
case ST_CHECK: /* CHECK CONDITION 0x02 */
switch (RET(&ds))
{
case DSRT_SENSE:
return(SCSI_SENSE);
case ST_CHECK: /* CHECK CONDITION 0x02 */
switch (RET(&ds))
{
case DSRT_SENSE:
return(SCSI_SENSE);
- break;
- default:
- return(SCSI_CHECK);
- break;
}
return(SCSI_CHECK);
}
return(SCSI_CHECK);
- break;
+
case ST_COND_MET: /* INTERM/GOOD 0x10 */
default:
continue;
case ST_COND_MET: /* INTERM/GOOD 0x10 */
default:
continue;
@@
-313,7
+284,7
@@
int Tape_Status( int DeviceFD)
if (ioctl(pDev[DeviceFD].fd , MTIOCGET, &mtget) != 0)
{
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);
}
@@
-354,7
+325,7
@@
int ScanBus(int print)
if ((dir = opendir("/dev/scsi")) == NULL)
{
if ((dir = opendir("/dev/scsi")) == NULL)
{
- dbprintf(
("Can not read /dev/scsi: %s", strerror(errno)
));
+ dbprintf(
_("Can not read /dev/scsi: %s"), strerror(errno
));
return 0;
}
return 0;
}
@@
-364,7
+335,7
@@
int ScanBus(int print)
{
pDev[count].dev = malloc(10);
pDev[count].inqdone = 0;
{
pDev[count].dev = malloc(10);
pDev[count].inqdone = 0;
- sprintf(pDev[count].dev,"/dev/scsi/%s", dirent->d_name);
+
g_
sprintf(pDev[count].dev,"/dev/scsi/%s", dirent->d_name);
if (OpenDevice(count,pDev[count].dev, "Scan", NULL ))
{
SCSI_CloseDevice(count);
if (OpenDevice(count,pDev[count].dev, "Scan", NULL ))
{
SCSI_CloseDevice(count);
@@
-372,48
+343,48
@@
int ScanBus(int print)
if (print)
{
if (print)
{
-
printf("name /dev/scsi/%s "
, dirent->d_name);
+
g_printf(_("name /dev/scsi/%s ")
, dirent->d_name);
switch (pDev[count].inquiry->type)
{
case TYPE_DISK:
switch (pDev[count].inquiry->type)
{
case TYPE_DISK:
-
printf("Disk"
);
+
g_printf(_("Disk")
);
break;
case TYPE_TAPE:
break;
case TYPE_TAPE:
-
printf("Tape"
);
+
g_printf(_("Tape")
);
break;
case TYPE_PRINTER:
break;
case TYPE_PRINTER:
-
printf("Printer"
);
+
g_printf(_("Printer")
);
break;
case TYPE_PROCESSOR:
break;
case TYPE_PROCESSOR:
-
printf("Processor"
);
+
g_printf(_("Processor")
);
break;
case TYPE_WORM:
break;
case TYPE_WORM:
-
printf("Worm"
);
+
g_printf(_("Worm")
);
break;
case TYPE_CDROM:
break;
case TYPE_CDROM:
-
printf("Cdrom"
);
+
g_printf(_("Cdrom")
);
break;
case TYPE_SCANNER:
break;
case TYPE_SCANNER:
-
printf("Scanner"
);
+
g_printf(_("Scanner")
);
break;
case TYPE_OPTICAL:
break;
case TYPE_OPTICAL:
-
printf("Optical"
);
+
g_printf(_("Optical")
);
break;
case TYPE_CHANGER:
break;
case TYPE_CHANGER:
-
printf("Changer"
);
+
g_printf(_("Changer")
);
break;
case TYPE_COMM:
break;
case TYPE_COMM:
-
printf("Comm"
);
+
g_printf(_("Comm")
);
break;
default:
break;
default:
-
printf("unknown %d"
,pDev[count].inquiry->type);
+
g_printf(_("unknown %d")
,pDev[count].inquiry->type);
break;
}
break;
}
- printf("\n");
+
g_
printf("\n");
}
count++;
}
count++;
-
printf("Count %d\n"
,count);
+
g_printf(_("Count %d\n")
,count);
} else {
free(pDev[count].dev);
pDev[count].dev=NULL;
} else {
free(pDev[count].dev);
pDev[count].dev=NULL;
@@
-423,7
+394,6
@@
int ScanBus(int print)
return 0;
}
return 0;
}
-#endif
/*
* Local variables:
* indent-tabs-mode: nil
/*
* Local variables:
* indent-tabs-mode: nil