summaryrefslogtreecommitdiff
path: root/scsi_hpux.c
diff options
context:
space:
mode:
authorCarsten Leonhardt <leo@debian.org>2019-02-27 23:12:40 +0100
committerCarsten Leonhardt <leo@debian.org>2019-02-27 23:12:40 +0100
commitb698d55dd1b2625d218f042cf1bb47b3f8df9518 (patch)
treefd1ed179b369a43c141cbbff07230f125074cb28 /scsi_hpux.c
parent9526a10abd8bdbd5db202407f499cc0629dd836d (diff)
Import Upstream version 1.3.11
Diffstat (limited to 'scsi_hpux.c')
-rw-r--r--scsi_hpux.c156
1 files changed, 83 insertions, 73 deletions
diff --git a/scsi_hpux.c b/scsi_hpux.c
index 66a07b9..cc46a03 100644
--- a/scsi_hpux.c
+++ b/scsi_hpux.c
@@ -1,5 +1,5 @@
/* Copyright 1997, 1998 Leonard Zubkoff <lnz@dandelion.com>
- Changes copyright 2000 Eric Green <eric@estinc.com>
+ Changes copyright 2000 Eric Green <eric@badtux.org>
This program is free software; you may redistribute and/or modify it under
the terms of the GNU General Public License Version 2 as published by the
@@ -10,19 +10,20 @@
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for complete details.
-struct sctl_io {
- unsigned flags; // IN: SCTL_READ
- unsigned cdb_length; // IN
- unsigned char cdb[16]; // IN
- void *data; // IN
- unsigned data_length; // IN
- unsigned max_msecs; // IN: milli-seconds before abort
- unsigned data_xfer; // OUT
- unsigned cdb_status; // OUT: SCSI status
- unsigned char sense[256]; // OUT
- unsigned sense_status; // OUT: SCSI status
- unsigned sense_xfer; // OUT: bytes of sense data received
- unsigned reserved[16]; // IN: Must be zero; OUT: undefined
+struct sctl_io
+{
+ unsigned flags; // IN: SCTL_READ
+ unsigned cdb_length; // IN
+ unsigned char cdb[16]; // IN
+ void *data; // IN
+ unsigned data_length; // IN
+ unsigned max_msecs; // IN: milli-seconds before abort
+ unsigned data_xfer; // OUT
+ unsigned cdb_status; // OUT: SCSI status
+ unsigned char sense[256]; // OUT
+ unsigned sense_status; // OUT: SCSI status
+ unsigned sense_xfer; // OUT: bytes of sense data received
+ unsigned reserved[16]; // IN: Must be zero; OUT: undefined
};
*/
@@ -43,81 +44,90 @@ struct sctl_io {
DEVICE_TYPE SCSI_OpenDevice(char *DeviceName)
{
- int DeviceFD = open(DeviceName, O_RDWR | O_NDELAY);
- if (DeviceFD < 0)
- FatalError("cannot open SCSI device '%s' - %m\n", DeviceName);
- return (DEVICE_TYPE) DeviceFD;
+ int DeviceFD = open(DeviceName, O_RDWR | O_NDELAY);
+
+ if (DeviceFD < 0)
+ FatalError("cannot open SCSI device '%s' - %m\n", DeviceName);
+
+ return (DEVICE_TYPE) DeviceFD;
}
-void SCSI_CloseDevice(char *DeviceName,
- DEVICE_TYPE DeviceFD)
+void SCSI_CloseDevice(char *DeviceName, DEVICE_TYPE DeviceFD)
{
- if (close(DeviceFD) < 0)
- FatalError("cannot close SCSI device '%s' - %m\n", DeviceName);
+ if (close(DeviceFD) < 0)
+ FatalError("cannot close SCSI device '%s' - %m\n", DeviceName);
}
#define MTX_HZ 1000
#define DEFAULT_HZ (5*60*MTX_HZ)
-static int sctl_io_timeout=DEFAULT_HZ; /* default timeout is 5 minutes. */
+static int sctl_io_timeout=DEFAULT_HZ; /* default timeout is 5 minutes. */
-void SCSI_Set_Timeout(int to) {
- sctl_io_timeout=to*60*MTX_HZ;
+void SCSI_Set_Timeout(int to)
+{
+ sctl_io_timeout=to*60*MTX_HZ;
}
-void SCSI_Default_Timeout(void) {
- sctl_io_timeout=DEFAULT_HZ;
+void SCSI_Default_Timeout(void)
+{
+ sctl_io_timeout=DEFAULT_HZ;
}
int SCSI_ExecuteCommand(DEVICE_TYPE DeviceFD,
- Direction_T Direction,
- CDB_T *CDB,
- int CDB_Length,
- void *DataBuffer,
- int DataBufferLength,
- RequestSense_T *RequestSense)
+ Direction_T Direction,
+ CDB_T *CDB,
+ int CDB_Length,
+ void *DataBuffer,
+ int DataBufferLength,
+ RequestSense_T *RequestSense)
{
- int ioctl_result;
- struct sctl_io Command;
-
- int i;
-
- memset(&Command, 0, sizeof(struct sctl_io));
- memset(RequestSense, 0, sizeof(RequestSense_T));
-
- switch (Direction) {
- case Input:
- if (DataBufferLength > 0)
- memset(DataBuffer, 0, DataBufferLength);
- Command.flags = SCTL_READ | SCTL_INIT_SDTR;
- break;
- case Output:
- Command.flags = SCTL_INIT_WDTR | SCTL_INIT_SDTR;
- break;
- }
-
- Command.max_msecs = sctl_io_timeout; /* Set timeout to <n> minutes. */
- memcpy(Command.cdb, CDB, CDB_Length);
- Command.cdb_length = CDB_Length;
- Command.data = DataBuffer;
- Command.data_length = DataBufferLength;
- ioctl_result=ioctl(DeviceFD, SIOC_IO, &Command);
- SCSI_Default_Timeout(); /* change the default back to 5 minutes */
- if (ioctl_result < 0) {
- perror("mtx");
- return ioctl_result;
- }
-
- if (Command.sense_xfer > sizeof(RequestSense_T)) {
- Command.sense_xfer=sizeof(RequestSense_T);
- }
-
- if (Command.sense_xfer) {
- memcpy(RequestSense, Command.sense, Command.sense_xfer);
- }
-
- return Command.sense_status;
+ int ioctl_result;
+ struct sctl_io Command;
+
+ int i;
+
+ memset(&Command, 0, sizeof(struct sctl_io));
+ memset(RequestSense, 0, sizeof(RequestSense_T));
+
+ switch (Direction)
+ {
+ case Input:
+ if (DataBufferLength > 0)
+ memset(DataBuffer, 0, DataBufferLength);
+ Command.flags = SCTL_READ | SCTL_INIT_SDTR;
+ break;
+
+ case Output:
+ Command.flags = SCTL_INIT_WDTR | SCTL_INIT_SDTR;
+ break;
+ }
+
+ Command.max_msecs = sctl_io_timeout; /* Set timeout to <n> minutes. */
+ memcpy(Command.cdb, CDB, CDB_Length);
+ Command.cdb_length = CDB_Length;
+ Command.data = DataBuffer;
+ Command.data_length = DataBufferLength;
+ ioctl_result=ioctl(DeviceFD, SIOC_IO, &Command);
+ SCSI_Default_Timeout(); /* change the default back to 5 minutes */
+
+ if (ioctl_result < 0)
+ {
+ perror("mtx");
+ return ioctl_result;
+ }
+
+ if (Command.sense_xfer > sizeof(RequestSense_T))
+ {
+ Command.sense_xfer=sizeof(RequestSense_T);
+ }
+
+ if (Command.sense_xfer)
+ {
+ memcpy(RequestSense, Command.sense, Command.sense_xfer);
+ }
+
+ return Command.sense_status;
}