aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--README2
-rw-r--r--debian/changelog2
-rw-r--r--include/sg_pt.h3
-rw-r--r--lib/sg_pt_common.c2
-rw-r--r--lib/sg_pt_freebsd.c111
-rw-r--r--lib/sg_pt_linux.c90
-rw-r--r--lib/sg_pt_osf1.c97
-rw-r--r--lib/sg_pt_solaris.c100
-rw-r--r--lib/sg_pt_win32.c106
-rw-r--r--sg3_utils.spec2
11 files changed, 320 insertions, 198 deletions
diff --git a/ChangeLog b/ChangeLog
index 226fc8c8..8b87ac60 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,7 @@ Each utility has its own version number, date of last change and
some description at the top of its ".c" file. All utilities in the main
directory have their own "man" pages. There is also a sg3_utils man page.
-Changelog for sg3_utils-1.27 [20090202] [svn: r206]
+Changelog for sg3_utils-1.27 [20090203] [svn: r207]
- sg_inq: sync version descriptors with spc4r17
- sg_map26: fix for lk 2.6.26 when CONFIG_SYSFS_DEPRECATED_V2
is not defined
@@ -20,6 +20,7 @@ Changelog for sg3_utils-1.27 [20090202] [svn: r206]
- sg3_utils.spec: correction to configure call
- sg_pt: add scsi_pt_open_device_flags() call to public interface
- add scsi_pt_version() call
+ - clear os_err at start of do_scsi_pt()
- sg_cmds: add sg_cmds_open_device_flags() call previous entry
- autotools infrastructure: changes after upgrade to Ubuntu 8.10
diff --git a/README b/README
index f2bed387..a1e8939e 100644
--- a/README
+++ b/README
@@ -321,4 +321,4 @@ See http://sg.danny.cz/sg/tools.html
Doug Gilbert
-2nd February 2009
+3rd February 2009
diff --git a/debian/changelog b/debian/changelog
index 44320326..4df4a69f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ sg3-utils (1.27-0.1) unstable; urgency=low
* New upstream version
- -- Doug Gilbert <dgilbert@interlog.com> Mon, 02 Feb 2009 23:00:00 -0500
+ -- Doug Gilbert <dgilbert@interlog.com> Tue, 03 Feb 2009 19:30:00 -0500
sg3-utils (1.26-0.1) unstable; urgency=low
diff --git a/include/sg_pt.h b/include/sg_pt.h
index f3bd0251..3852db40 100644
--- a/include/sg_pt.h
+++ b/include/sg_pt.h
@@ -92,7 +92,8 @@ extern void set_scsi_pt_task_attr(struct sg_pt_base * objp, int attribute,
#define SCSI_PT_DO_TIMEOUT 2
/* If OS error prior to or during command submission then returns negated
* error value (e.g. Unix '-errno'). This includes interrupted system calls
- * (e.g. by a signal) in which case -EINTR would be returned.
+ * (e.g. by a signal) in which case -EINTR would be returned. Note that
+ * system call errors also can be fetched with get_scsi_pt_os_err().
* Return 0 if okay (i.e. at the very least: command sent). Positive
* return values are errors (see SCSI_PT_DO_* defines). */
extern int do_scsi_pt(struct sg_pt_base * objp, int fd, int timeout_secs,
diff --git a/lib/sg_pt_common.c b/lib/sg_pt_common.c
index e4538167..1d09f99e 100644
--- a/lib/sg_pt_common.c
+++ b/lib/sg_pt_common.c
@@ -32,7 +32,7 @@
#include "sg_pt.h"
-static const char * scsi_pt_version_str = "2.01 20090201";
+static const char * scsi_pt_version_str = "2.02 20090203";
const char *
scsi_pt_version()
diff --git a/lib/sg_pt_freebsd.c b/lib/sg_pt_freebsd.c
index c7ba5156..67ee3f4f 100644
--- a/lib/sg_pt_freebsd.c
+++ b/lib/sg_pt_freebsd.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005-2008 Douglas Gilbert.
+ * Copyright (c) 2005-2009 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
*
*/
-/* version 1.08 20081129 */
+/* sg_pt_freebsd version 1.09 20090203 */
#include <stdio.h>
#include <stdlib.h>
@@ -91,9 +91,8 @@ struct sg_pt_base {
/* Returns >= 0 if successful. If error in Unix returns negated errno. */
-int scsi_pt_open_device(const char * device_name,
- int read_only,
- int verbose)
+int
+scsi_pt_open_device(const char * device_name, int read_only, int verbose)
{
int oflags = 0 /* O_NONBLOCK*/ ;
@@ -101,12 +100,12 @@ int scsi_pt_open_device(const char * device_name,
return scsi_pt_open_flags(device_name, oflags, verbose);
}
-/* Similar to scsi_pt_open_device() but takes Unix style open flags OR-ed */
-/* together. The 'flags' argument is ignored in FreeBSD. */
-/* Returns >= 0 if successful, otherwise returns negated errno. */
-int scsi_pt_open_flags(const char * device_name,
- int flags __attribute__ ((unused)),
- int verbose)
+/* Similar to scsi_pt_open_device() but takes Unix style open flags OR-ed
+ * together. The 'flags' argument is ignored in FreeBSD.
+ * Returns >= 0 if successful, otherwise returns negated errno. */
+int
+scsi_pt_open_flags(const char * device_name,
+ int flags __attribute__ ((unused)), int verbose)
{
struct freebsd_dev_channel *fdchan;
struct cam_device* cam_dev;
@@ -162,7 +161,8 @@ int scsi_pt_open_flags(const char * device_name,
}
/* Returns 0 if successful. If error in Unix returns negated errno. */
-int scsi_pt_close_device(int device_fd)
+int
+scsi_pt_close_device(int device_fd)
{
struct freebsd_dev_channel *fdchan;
int fd = device_fd - FREEBSD_FDOFFSET;
@@ -185,7 +185,8 @@ int scsi_pt_close_device(int device_fd)
return 0;
}
-struct sg_pt_base * construct_scsi_pt_obj()
+struct sg_pt_base *
+construct_scsi_pt_obj()
{
struct sg_pt_freebsd_scsi * ptp;
@@ -198,7 +199,8 @@ struct sg_pt_base * construct_scsi_pt_obj()
return (struct sg_pt_base *)ptp;
}
-void destruct_scsi_pt_obj(struct sg_pt_base * vp)
+void
+destruct_scsi_pt_obj(struct sg_pt_base * vp)
{
struct sg_pt_freebsd_scsi * ptp = &vp->impl;
@@ -209,8 +211,8 @@ void destruct_scsi_pt_obj(struct sg_pt_base * vp)
}
}
-void set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb,
- int cdb_len)
+void
+set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb, int cdb_len)
{
struct sg_pt_freebsd_scsi * ptp = &vp->impl;
@@ -220,8 +222,9 @@ void set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb,
ptp->cdb_len = cdb_len;
}
-void set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense,
- int max_sense_len)
+void
+set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense,
+ int max_sense_len)
{
struct sg_pt_freebsd_scsi * ptp = &vp->impl;
@@ -232,8 +235,10 @@ void set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense,
ptp->sense_len = max_sense_len;
}
-void set_scsi_pt_data_in(struct sg_pt_base * vp, /* from device */
- unsigned char * dxferp, int dxfer_len)
+/* Setup for data transfer from device */
+void
+set_scsi_pt_data_in(struct sg_pt_base * vp, unsigned char * dxferp,
+ int dxfer_len)
{
struct sg_pt_freebsd_scsi * ptp = &vp->impl;
@@ -246,8 +251,10 @@ void set_scsi_pt_data_in(struct sg_pt_base * vp, /* from device */
}
}
-void set_scsi_pt_data_out(struct sg_pt_base * vp, /* to device */
- const unsigned char * dxferp, int dxfer_len)
+/* Setup for data transfer toward device */
+void
+set_scsi_pt_data_out(struct sg_pt_base * vp, const unsigned char * dxferp,
+ int dxfer_len)
{
struct sg_pt_freebsd_scsi * ptp = &vp->impl;
@@ -260,38 +267,44 @@ void set_scsi_pt_data_out(struct sg_pt_base * vp, /* to device */
}
}
-void set_scsi_pt_packet_id(struct sg_pt_base * vp __attribute__ ((unused)),
- int pack_id __attribute__ ((unused)))
+void
+set_scsi_pt_packet_id(struct sg_pt_base * vp __attribute__ ((unused)),
+ int pack_id __attribute__ ((unused)))
{
}
-void set_scsi_pt_tag(struct sg_pt_base * vp,
- uint64_t tag __attribute__ ((unused)))
+void
+set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag __attribute__ ((unused)))
{
struct sg_pt_freebsd_scsi * ptp = &vp->impl;
++ptp->in_err;
}
-void set_scsi_pt_task_management(struct sg_pt_base * vp,
- int tmf_code __attribute__ ((unused)))
+void
+set_scsi_pt_task_management(struct sg_pt_base * vp,
+ int tmf_code __attribute__ ((unused)))
{
struct sg_pt_freebsd_scsi * ptp = &vp->impl;
++ptp->in_err;
}
-void set_scsi_pt_task_attr(struct sg_pt_base * vp,
- int attrib __attribute__ ((unused)),
- int priority __attribute__ ((unused)))
+void
+set_scsi_pt_task_attr(struct sg_pt_base * vp,
+ int attrib __attribute__ ((unused)),
+ int priority __attribute__ ((unused)))
{
struct sg_pt_freebsd_scsi * ptp = &vp->impl;
++ptp->in_err;
}
-int do_scsi_pt(struct sg_pt_base * vp, int device_fd, int time_secs,
- int verbose)
+/* Executes SCSI command (or at least forwards it to lower layers).
+ * Clears os_err field prior to active call (whose result may set it
+ * again). */
+int
+do_scsi_pt(struct sg_pt_base * vp, int device_fd, int time_secs, int verbose)
{
int fd = device_fd - FREEBSD_FDOFFSET;
struct sg_pt_freebsd_scsi * ptp = &vp->impl;
@@ -301,6 +314,7 @@ int do_scsi_pt(struct sg_pt_base * vp, int device_fd, int time_secs,
if (NULL == sg_warnings_strm)
sg_warnings_strm = stderr;
+ ptp->os_err = 0;
if (ptp->in_err) {
if (verbose)
fprintf(sg_warnings_strm, "Replicated or unused set_scsi_pt...\n");
@@ -389,7 +403,8 @@ int do_scsi_pt(struct sg_pt_base * vp, int device_fd, int time_secs,
return 0;
}
-int get_scsi_pt_result_category(const struct sg_pt_base * vp)
+int
+get_scsi_pt_result_category(const struct sg_pt_base * vp)
{
const struct sg_pt_freebsd_scsi * ptp = &vp->impl;
@@ -406,21 +421,24 @@ int get_scsi_pt_result_category(const struct sg_pt_base * vp)
return SCSI_PT_RESULT_GOOD;
}
-int get_scsi_pt_resid(const struct sg_pt_base * vp)
+int
+get_scsi_pt_resid(const struct sg_pt_base * vp)
{
const struct sg_pt_freebsd_scsi * ptp = &vp->impl;
return ptp->resid;
}
-int get_scsi_pt_status_response(const struct sg_pt_base * vp)
+int
+get_scsi_pt_status_response(const struct sg_pt_base * vp)
{
const struct sg_pt_freebsd_scsi * ptp = &vp->impl;
return ptp->scsi_status;
}
-int get_scsi_pt_sense_len(const struct sg_pt_base * vp)
+int
+get_scsi_pt_sense_len(const struct sg_pt_base * vp)
{
const struct sg_pt_freebsd_scsi * ptp = &vp->impl;
int len;
@@ -429,30 +447,33 @@ int get_scsi_pt_sense_len(const struct sg_pt_base * vp)
return (len > 0) ? len : 0;
}
-int get_scsi_pt_duration_ms(const struct sg_pt_base * vp __attribute__ ((unused)))
+int
+get_scsi_pt_duration_ms(const struct sg_pt_base * vp __attribute__ ((unused)))
{
// const struct sg_pt_freebsd_scsi * ptp = &vp->impl;
return -1;
}
-int get_scsi_pt_transport_err(const struct sg_pt_base * vp)
+int
+get_scsi_pt_transport_err(const struct sg_pt_base * vp)
{
const struct sg_pt_freebsd_scsi * ptp = &vp->impl;
return ptp->transport_err;
}
-int get_scsi_pt_os_err(const struct sg_pt_base * vp)
+int
+get_scsi_pt_os_err(const struct sg_pt_base * vp)
{
const struct sg_pt_freebsd_scsi * ptp = &vp->impl;
return ptp->os_err;
}
-
-char * get_scsi_pt_transport_err_str(const struct sg_pt_base * vp,
- int max_b_len, char * b)
+char *
+get_scsi_pt_transport_err_str(const struct sg_pt_base * vp, int max_b_len,
+ char * b)
{
const struct sg_pt_freebsd_scsi * ptp = &vp->impl;
@@ -476,8 +497,8 @@ char * get_scsi_pt_transport_err_str(const struct sg_pt_base * vp,
return b;
}
-char * get_scsi_pt_os_err_str(const struct sg_pt_base * vp,
- int max_b_len, char * b)
+char *
+get_scsi_pt_os_err_str(const struct sg_pt_base * vp, int max_b_len, char * b)
{
const struct sg_pt_freebsd_scsi * ptp = &vp->impl;
const char * cp;
diff --git a/lib/sg_pt_linux.c b/lib/sg_pt_linux.c
index 16cab825..96d80f53 100644
--- a/lib/sg_pt_linux.c
+++ b/lib/sg_pt_linux.c
@@ -27,7 +27,7 @@
*
*/
-/* version 1.09 20090202 */
+/* sg_pt_linux version 1.10 20090203 */
#include <stdio.h>
#include <stdlib.h>
@@ -59,8 +59,8 @@ struct sg_pt_base {
/* Returns >= 0 if successful. If error in Unix returns negated errno. */
-int scsi_pt_open_device(const char * device_name, int read_only,
- int verbose)
+int
+scsi_pt_open_device(const char * device_name, int read_only, int verbose)
{
int oflags = O_NONBLOCK;
@@ -71,7 +71,8 @@ int scsi_pt_open_device(const char * device_name, int read_only,
/* Similar to scsi_pt_open_device() but takes Unix style open flags OR-ed */
/* together. The 'flags' argument is advisory and may be ignored. */
/* Returns >= 0 if successful, otherwise returns negated errno. */
-int scsi_pt_open_flags(const char * device_name, int flags, int verbose)
+int
+scsi_pt_open_flags(const char * device_name, int flags, int verbose)
{
int fd;
@@ -88,7 +89,8 @@ int scsi_pt_open_flags(const char * device_name, int flags, int verbose)
}
/* Returns 0 if successful. If error in Unix returns negated errno. */
-int scsi_pt_close_device(int device_fd)
+int
+scsi_pt_close_device(int device_fd)
{
int res;
@@ -99,7 +101,8 @@ int scsi_pt_close_device(int device_fd)
}
-struct sg_pt_base * construct_scsi_pt_obj()
+struct sg_pt_base *
+construct_scsi_pt_obj()
{
struct sg_pt_linux_scsi * ptp;
@@ -113,7 +116,8 @@ struct sg_pt_base * construct_scsi_pt_obj()
return (struct sg_pt_base *)ptp;
}
-void destruct_scsi_pt_obj(struct sg_pt_base * vp)
+void
+destruct_scsi_pt_obj(struct sg_pt_base * vp)
{
struct sg_pt_linux_scsi * ptp = &vp->impl;
@@ -121,8 +125,9 @@ void destruct_scsi_pt_obj(struct sg_pt_base * vp)
free(ptp);
}
-void set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb,
- int cdb_len)
+void
+set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb,
+ int cdb_len)
{
struct sg_pt_linux_scsi * ptp = &vp->impl;
@@ -132,8 +137,9 @@ void set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb,
ptp->io_hdr.cmd_len = cdb_len;
}
-void set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense,
- int max_sense_len)
+void
+set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense,
+ int max_sense_len)
{
struct sg_pt_linux_scsi * ptp = &vp->impl;
@@ -144,8 +150,10 @@ void set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense,
ptp->io_hdr.mx_sb_len = max_sense_len;
}
-void set_scsi_pt_data_in(struct sg_pt_base * vp, /* from device */
- unsigned char * dxferp, int dxfer_len)
+/* Setup for data transfer from device */
+void
+set_scsi_pt_data_in(struct sg_pt_base * vp, unsigned char * dxferp,
+ int dxfer_len)
{
struct sg_pt_linux_scsi * ptp = &vp->impl;
@@ -158,8 +166,10 @@ void set_scsi_pt_data_in(struct sg_pt_base * vp, /* from device */
}
}
-void set_scsi_pt_data_out(struct sg_pt_base * vp, /* to device */
- const unsigned char * dxferp, int dxfer_len)
+/* Setup for data transfer toward device */
+void
+set_scsi_pt_data_out(struct sg_pt_base * vp, const unsigned char * dxferp,
+ int dxfer_len)
{
struct sg_pt_linux_scsi * ptp = &vp->impl;
@@ -172,14 +182,16 @@ void set_scsi_pt_data_out(struct sg_pt_base * vp, /* to device */
}
}
-void set_scsi_pt_packet_id(struct sg_pt_base * vp, int pack_id)
+void
+set_scsi_pt_packet_id(struct sg_pt_base * vp, int pack_id)
{
struct sg_pt_linux_scsi * ptp = &vp->impl;
ptp->io_hdr.pack_id = pack_id;
}
-void set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag)
+void
+set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag)
{
struct sg_pt_linux_scsi * ptp = &vp->impl;
@@ -188,7 +200,8 @@ void set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag)
}
/* Note that task management function codes are transport specific */
-void set_scsi_pt_task_management(struct sg_pt_base * vp, int tmf_code)
+void
+set_scsi_pt_task_management(struct sg_pt_base * vp, int tmf_code)
{
struct sg_pt_linux_scsi * ptp = &vp->impl;
@@ -196,8 +209,8 @@ void set_scsi_pt_task_management(struct sg_pt_base * vp, int tmf_code)
tmf_code = tmf_code; /* dummy to silence compiler */
}
-void set_scsi_pt_task_attr(struct sg_pt_base * vp, int attribute,
- int priority)
+void
+set_scsi_pt_task_attr(struct sg_pt_base * vp, int attribute, int priority)
{
struct sg_pt_linux_scsi * ptp = &vp->impl;
@@ -206,12 +219,17 @@ void set_scsi_pt_task_attr(struct sg_pt_base * vp, int attribute,
priority = priority; /* dummy to silence compiler */
}
-int do_scsi_pt(struct sg_pt_base * vp, int fd, int time_secs, int verbose)
+/* Executes SCSI command (or at least forwards it to lower layers).
+ * Clears os_err field prior to active call (whose result may set it
+ * again). */
+int
+do_scsi_pt(struct sg_pt_base * vp, int fd, int time_secs, int verbose)
{
struct sg_pt_linux_scsi * ptp = &vp->impl;
if (NULL == sg_warnings_strm)
sg_warnings_strm = stderr;
+ ptp->os_err = 0;
if (ptp->in_err) {
if (verbose)
fprintf(sg_warnings_strm, "Replicated or unused set_scsi_pt... "
@@ -257,7 +275,8 @@ int do_scsi_pt(struct sg_pt_base * vp, int fd, int time_secs, int verbose)
#define SG_LIB_SUGGEST_MASK SUGGEST_MASK
#define SG_LIB_DRIVER_SENSE DRIVER_SENSE
-int get_scsi_pt_result_category(const struct sg_pt_base * vp)
+int
+get_scsi_pt_result_category(const struct sg_pt_base * vp)
{
const struct sg_pt_linux_scsi * ptp = &vp->impl;
int dr_st = ptp->io_hdr.driver_status & SG_LIB_DRIVER_MASK;
@@ -279,42 +298,48 @@ int get_scsi_pt_result_category(const struct sg_pt_base * vp)
return SCSI_PT_RESULT_GOOD;
}
-int get_scsi_pt_resid(const struct sg_pt_base * vp)
+int
+get_scsi_pt_resid(const struct sg_pt_base * vp)
{
const struct sg_pt_linux_scsi * ptp = &vp->impl;
return ptp->io_hdr.resid;
}
-int get_scsi_pt_status_response(const struct sg_pt_base * vp)
+int
+get_scsi_pt_status_response(const struct sg_pt_base * vp)
{
const struct sg_pt_linux_scsi * ptp = &vp->impl;
return ptp->io_hdr.status;
}
-int get_scsi_pt_sense_len(const struct sg_pt_base * vp)
+int
+get_scsi_pt_sense_len(const struct sg_pt_base * vp)
{
const struct sg_pt_linux_scsi * ptp = &vp->impl;
return ptp->io_hdr.sb_len_wr;
}
-int get_scsi_pt_duration_ms(const struct sg_pt_base * vp)
+int
+get_scsi_pt_duration_ms(const struct sg_pt_base * vp)
{
const struct sg_pt_linux_scsi * ptp = &vp->impl;
return ptp->io_hdr.duration;
}
-int get_scsi_pt_transport_err(const struct sg_pt_base * vp)
+int
+get_scsi_pt_transport_err(const struct sg_pt_base * vp)
{
const struct sg_pt_linux_scsi * ptp = &vp->impl;
return (ptp->io_hdr.host_status << 8) + ptp->io_hdr.driver_status;
}
-int get_scsi_pt_os_err(const struct sg_pt_base * vp)
+int
+get_scsi_pt_os_err(const struct sg_pt_base * vp)
{
const struct sg_pt_linux_scsi * ptp = &vp->impl;
@@ -350,8 +375,9 @@ static const char * linux_driver_suggests[] = {
(int)(sizeof(linux_driver_suggests) / sizeof(linux_driver_suggests[0]))
-char * get_scsi_pt_transport_err_str(const struct sg_pt_base * vp,
- int max_b_len, char * b)
+char *
+get_scsi_pt_transport_err_str(const struct sg_pt_base * vp, int max_b_len,
+ char * b)
{
const struct sg_pt_linux_scsi * ptp = &vp->impl;
int ds = ptp->io_hdr.driver_status;
@@ -391,8 +417,8 @@ char * get_scsi_pt_transport_err_str(const struct sg_pt_base * vp,
return b;
}
-char * get_scsi_pt_os_err_str(const struct sg_pt_base * vp,
- int max_b_len, char * b)
+char *
+get_scsi_pt_os_err_str(const struct sg_pt_base * vp, int max_b_len, char * b)
{
const struct sg_pt_linux_scsi * ptp = &vp->impl;
const char * cp;
diff --git a/lib/sg_pt_osf1.c b/lib/sg_pt_osf1.c
index 4718da06..2c0e5151 100644
--- a/lib/sg_pt_osf1.c
+++ b/lib/sg_pt_osf1.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005-2008 Douglas Gilbert.
+ * Copyright (c) 2005-2009 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -87,9 +87,8 @@ struct sg_pt_base {
/* Returns >= 0 if successful. If error in Unix returns negated errno. */
-int scsi_pt_open_device(const char * device_name,
- int read_only,
- int verbose)
+int
+scsi_pt_open_device(const char * device_name, int read_only, int verbose)
{
int oflags = 0 /* O_NONBLOCK*/ ;
@@ -97,10 +96,11 @@ int scsi_pt_open_device(const char * device_name,
return scsi_pt_open_flags(device_name, oflags, verbose);
}
-/* Similar to scsi_pt_open_device() but takes Unix style open flags OR-ed */
-/* together. The 'flags' argument is ignored in OSF-1. */
-/* Returns >= 0 if successful, otherwise returns negated errno. */
-int scsi_pt_open_flags(const char * device_name, int flags, int verbose)
+/* Similar to scsi_pt_open_device() but takes Unix style open flags OR-ed
+ * together. The 'flags' argument is ignored in OSF-1.
+ * Returns >= 0 if successful, otherwise returns negated errno. */
+int
+scsi_pt_open_flags(const char * device_name, int flags, int verbose)
{
struct osf1_dev_channel *fdchan;
int fd, k;
@@ -155,7 +155,8 @@ int scsi_pt_open_flags(const char * device_name, int flags, int verbose)
}
/* Returns 0 if successful. If error in Unix returns negated errno. */
-int scsi_pt_close_device(int device_fd)
+int
+scsi_pt_close_device(int device_fd)
{
struct osf1_dev_channel *fdchan;
int i;
@@ -185,7 +186,8 @@ int scsi_pt_close_device(int device_fd)
return 0;
}
-struct sg_pt_base * construct_scsi_pt_obj()
+struct sg_pt_base *
+construct_scsi_pt_obj()
{
struct sg_pt_osf1_scsi * ptp;
@@ -197,7 +199,8 @@ struct sg_pt_base * construct_scsi_pt_obj()
return (struct sg_pt_base *)ptp;
}
-void destruct_scsi_pt_obj(struct sg_pt_base * vp)
+void
+destruct_scsi_pt_obj(struct sg_pt_base * vp)
{
struct sg_pt_osf1_scsi * ptp = &vp->impl;
@@ -205,8 +208,9 @@ void destruct_scsi_pt_obj(struct sg_pt_base * vp)
free(ptp);
}
-void set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb,
- int cdb_len)
+void
+set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb,
+ int cdb_len)
{
struct sg_pt_osf1_scsi * ptp = &vp->impl;
@@ -216,8 +220,9 @@ void set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb,
ptp->cdb_len = cdb_len;
}
-void set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense,
- int max_sense_len)
+void
+set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense,
+ int max_sense_len)
{
struct sg_pt_osf1_scsi * ptp = &vp->impl;
@@ -228,8 +233,10 @@ void set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense,
ptp->sense_len = max_sense_len;
}
-void set_scsi_pt_data_in(struct sg_pt_base * vp, /* from device */
- unsigned char * dxferp, int dxfer_len)
+/* from device */
+void
+set_scsi_pt_data_in(struct sg_pt_base * vp, unsigned char * dxferp,
+ int dxfer_len)
{
struct sg_pt_osf1_scsi * ptp = &vp->impl;
@@ -242,8 +249,10 @@ void set_scsi_pt_data_in(struct sg_pt_base * vp, /* from device */
}
}
-void set_scsi_pt_data_out(struct sg_pt_base * vp, /* to device */
- const unsigned char * dxferp, int dxfer_len)
+/* to device */
+void
+set_scsi_pt_data_out(struct sg_pt_base * vp, const unsigned char * dxferp,
+ int dxfer_len)
{
struct sg_pt_osf1_scsi * ptp = &vp->impl;
@@ -256,32 +265,37 @@ void set_scsi_pt_data_out(struct sg_pt_base * vp, /* to device */
}
}
-void set_scsi_pt_packet_id(struct sg_pt_base * vp, int pack_id)
+void
+set_scsi_pt_packet_id(struct sg_pt_base * vp, int pack_id)
{
}
-void set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag)
+void
+set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag)
{
struct sg_pt_osf1_scsi * ptp = &vp->impl;
++ptp->in_err;
}
-void set_scsi_pt_task_management(struct sg_pt_base * vp, int tmf_code)
+void
+set_scsi_pt_task_management(struct sg_pt_base * vp, int tmf_code)
{
struct sg_pt_osf1_scsi * ptp = &vp->impl;
++ptp->in_err;
}
-void set_scsi_pt_task_attr(struct sg_pt_base * vp, int attrib, int priority)
+void
+set_scsi_pt_task_attr(struct sg_pt_base * vp, int attrib, int priority)
{
struct sg_pt_osf1_scsi * ptp = &vp->impl;
++ptp->in_err;
}
-static int release_sim(struct sg_pt_base *vp, int device_fd, int verbose) {
+static int
+release_sim(struct sg_pt_base *vp, int device_fd, int verbose) {
struct sg_pt_osf1_scsi * ptp = &vp->impl;
struct osf1_dev_channel *fdchan = devicetable[device_fd];
UAGT_CAM_CCB uagt;
@@ -312,7 +326,8 @@ static int release_sim(struct sg_pt_base *vp, int device_fd, int verbose) {
return retval;
}
-int do_scsi_pt(struct sg_pt_base * vp, int device_fd, int time_secs, int verbose)
+int
+do_scsi_pt(struct sg_pt_base * vp, int device_fd, int time_secs, int verbose)
{
struct sg_pt_osf1_scsi * ptp = &vp->impl;
struct osf1_dev_channel *fdchan;
@@ -324,6 +339,7 @@ int do_scsi_pt(struct sg_pt_base * vp, int device_fd, int time_secs, int verbose
if (NULL == sg_warnings_strm)
sg_warnings_strm = stderr;
+ ptp->os_err = 0;
if (ptp->in_err) {
if (verbose)
fprintf(sg_warnings_strm, "Replicated or unused set_scsi_pt...\n");
@@ -354,7 +370,6 @@ int do_scsi_pt(struct sg_pt_base * vp, int device_fd, int time_secs, int verbose
return SCSI_PT_DO_BAD_PARAMS;
}
-
bzero(&uagt, sizeof(uagt));
bzero(&ccb, sizeof(ccb));
@@ -400,7 +415,8 @@ int do_scsi_pt(struct sg_pt_base * vp, int device_fd, int time_secs, int verbose
return 0;
}
-int get_scsi_pt_result_category(const struct sg_pt_base * vp)
+int
+get_scsi_pt_result_category(const struct sg_pt_base * vp)
{
const struct sg_pt_osf1_scsi * ptp = &vp->impl;
@@ -417,21 +433,24 @@ int get_scsi_pt_result_category(const struct sg_pt_base * vp)
return SCSI_PT_RESULT_GOOD;
}
-int get_scsi_pt_resid(const struct sg_pt_base * vp)
+int
+get_scsi_pt_resid(const struct sg_pt_base * vp)
{
const struct sg_pt_osf1_scsi * ptp = &vp->impl;
return ptp->resid;
}
-int get_scsi_pt_status_response(const struct sg_pt_base * vp)
+int
+get_scsi_pt_status_response(const struct sg_pt_base * vp)
{
const struct sg_pt_osf1_scsi * ptp = &vp->impl;
return ptp->scsi_status;
}
-int get_scsi_pt_sense_len(const struct sg_pt_base * vp)
+int
+get_scsi_pt_sense_len(const struct sg_pt_base * vp)
{
const struct sg_pt_osf1_scsi * ptp = &vp->impl;
int len;
@@ -440,29 +459,33 @@ int get_scsi_pt_sense_len(const struct sg_pt_base * vp)
return (len > 0) ? len : 0;
}
-int get_scsi_pt_duration_ms(const struct sg_pt_base * vp)
+int
+get_scsi_pt_duration_ms(const struct sg_pt_base * vp)
{
// const struct sg_pt_osf1_scsi * ptp = &vp->impl;
return -1;
}
-int get_scsi_pt_transport_err(const struct sg_pt_base * vp)
+int
+get_scsi_pt_transport_err(const struct sg_pt_base * vp)
{
const struct sg_pt_osf1_scsi * ptp = &vp->impl;
return ptp->transport_err;
}
-int get_scsi_pt_os_err(const struct sg_pt_base * vp)
+int
+get_scsi_pt_os_err(const struct sg_pt_base * vp)
{
const struct sg_pt_osf1_scsi * ptp = &vp->impl;
return ptp->os_err;
}
-
-char * get_scsi_pt_transport_err_str(const struct sg_pt_base * vp, int max_b_len, char * b)
+char *
+get_scsi_pt_transport_err_str(const struct sg_pt_base * vp, int max_b_len,
+ char * b)
{
const struct sg_pt_osf1_scsi * ptp = &vp->impl;
@@ -476,8 +499,8 @@ char * get_scsi_pt_transport_err_str(const struct sg_pt_base * vp, int max_b_len
return b;
}
-char * get_scsi_pt_os_err_str(const struct sg_pt_base * vp,
- int max_b_len, char * b)
+char *
+get_scsi_pt_os_err_str(const struct sg_pt_base * vp, int max_b_len, char * b)
{
const struct sg_pt_osf1_scsi * ptp = &vp->impl;
const char * cp;
diff --git a/lib/sg_pt_solaris.c b/lib/sg_pt_solaris.c
index 549cb91d..b3cc2abd 100644
--- a/lib/sg_pt_solaris.c
+++ b/lib/sg_pt_solaris.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007-2008 Douglas Gilbert.
+ * Copyright (c) 2007-2009 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
*
*/
-/* version 1.01 20081129 */
+/* sg_pt_solaris version 1.02 20090203 */
#include <stdio.h>
#include <stdlib.h>
@@ -63,9 +63,8 @@ struct sg_pt_base {
/* Returns >= 0 if successful. If error in Unix returns negated errno. */
-int scsi_pt_open_device(const char * device_name,
- int read_only,
- int verbose)
+int
+scsi_pt_open_device(const char * device_name, int read_only, int verbose)
{
int oflags = 0 /* O_NONBLOCK*/ ;
@@ -73,10 +72,11 @@ int scsi_pt_open_device(const char * device_name,
return scsi_pt_open_flags(device_name, oflags, verbose);
}
-/* Similar to scsi_pt_open_device() but takes Unix style open flags OR-ed */
-/* together. The 'flags' argument is ignored in Solaris. */
-/* Returns >= 0 if successful, otherwise returns negated errno. */
-int scsi_pt_open_flags(const char * device_name, int flags_arg, int verbose)
+/* Similar to scsi_pt_open_device() but takes Unix style open flags OR-ed
+ * together. The 'flags' argument is ignored in Solaris.
+ * Returns >= 0 if successful, otherwise returns negated errno. */
+int
+scsi_pt_open_flags(const char * device_name, int flags_arg, int verbose)
{
int oflags = O_NONBLOCK | O_RDWR;
int fd;
@@ -92,7 +92,8 @@ int scsi_pt_open_flags(const char * device_name, int flags_arg, int verbose)
}
/* Returns 0 if successful. If error in Unix returns negated errno. */
-int scsi_pt_close_device(int device_fd)
+int
+scsi_pt_close_device(int device_fd)
{
int res;
@@ -102,8 +103,8 @@ int scsi_pt_close_device(int device_fd)
return res;
}
-
-struct sg_pt_base * construct_scsi_pt_obj()
+struct sg_pt_base *
+construct_scsi_pt_obj()
{
struct sg_pt_solaris_scsi * ptp;
@@ -118,7 +119,8 @@ struct sg_pt_base * construct_scsi_pt_obj()
return (struct sg_pt_base *)ptp;
}
-void destruct_scsi_pt_obj(struct sg_pt_base * vp)
+void
+destruct_scsi_pt_obj(struct sg_pt_base * vp)
{
struct sg_pt_solaris_scsi * ptp = &vp->impl;
@@ -126,8 +128,9 @@ void destruct_scsi_pt_obj(struct sg_pt_base * vp)
free(ptp);
}
-void set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb,
- int cdb_len)
+void
+set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb,
+ int cdb_len)
{
struct sg_pt_solaris_scsi * ptp = &vp->impl;
@@ -137,8 +140,9 @@ void set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb,
ptp->uscsi.uscsi_cdblen = cdb_len;
}
-void set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense,
- int max_sense_len)
+void
+set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense,
+ int max_sense_len)
{
struct sg_pt_solaris_scsi * ptp = &vp->impl;
@@ -150,8 +154,10 @@ void set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense,
ptp->max_sense_len = max_sense_len;
}
-void set_scsi_pt_data_in(struct sg_pt_base * vp, /* from device */
- unsigned char * dxferp, int dxfer_len)
+/* from device */
+void
+set_scsi_pt_data_in(struct sg_pt_base * vp, unsigned char * dxferp,
+ int dxfer_len)
{
struct sg_pt_solaris_scsi * ptp = &vp->impl;
@@ -164,8 +170,10 @@ void set_scsi_pt_data_in(struct sg_pt_base * vp, /* from device */
}
}
-void set_scsi_pt_data_out(struct sg_pt_base * vp, /* to device */
- const unsigned char * dxferp, int dxfer_len)
+/* to device */
+void
+set_scsi_pt_data_out(struct sg_pt_base * vp, const unsigned char * dxferp,
+ int dxfer_len)
{
struct sg_pt_solaris_scsi * ptp = &vp->impl;
@@ -178,7 +186,8 @@ void set_scsi_pt_data_out(struct sg_pt_base * vp, /* to device */
}
}
-void set_scsi_pt_packet_id(struct sg_pt_base * vp, int pack_id)
+void
+set_scsi_pt_packet_id(struct sg_pt_base * vp, int pack_id)
{
// struct sg_pt_solaris_scsi * ptp = &vp->impl;
@@ -186,7 +195,8 @@ void set_scsi_pt_packet_id(struct sg_pt_base * vp, int pack_id)
pack_id = pack_id; /* ignore and suppress warning */
}
-void set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag)
+void
+set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag)
{
// struct sg_pt_solaris_scsi * ptp = &vp->impl;
@@ -195,7 +205,8 @@ void set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag)
}
/* Note that task management function codes are transport specific */
-void set_scsi_pt_task_management(struct sg_pt_base * vp, int tmf_code)
+void
+set_scsi_pt_task_management(struct sg_pt_base * vp, int tmf_code)
{
struct sg_pt_solaris_scsi * ptp = &vp->impl;
@@ -203,8 +214,8 @@ void set_scsi_pt_task_management(struct sg_pt_base * vp, int tmf_code)
tmf_code = tmf_code; /* dummy to silence compiler */
}
-void set_scsi_pt_task_attr(struct sg_pt_base * vp, int attribute,
- int priority)
+void
+set_scsi_pt_task_attr(struct sg_pt_base * vp, int attribute, int priority)
{
struct sg_pt_solaris_scsi * ptp = &vp->impl;
@@ -213,10 +224,15 @@ void set_scsi_pt_task_attr(struct sg_pt_base * vp, int attribute,
priority = priority; /* dummy to silence compiler */
}
-int do_scsi_pt(struct sg_pt_base * vp, int fd, int time_secs, int verbose)
+/* Executes SCSI command (or at least forwards it to lower layers).
+ * Clears os_err field prior to active call (whose result may set it
+ * again). */
+int
+do_scsi_pt(struct sg_pt_base * vp, int fd, int time_secs, int verbose)
{
struct sg_pt_solaris_scsi * ptp = &vp->impl;
+ ptp->os_err = 0;
if (ptp->in_err) {
if (verbose)
fprintf(stderr, "Replicated or unused set_scsi_pt... "
@@ -245,7 +261,8 @@ int do_scsi_pt(struct sg_pt_base * vp, int fd, int time_secs, int verbose)
return 0;
}
-int get_scsi_pt_result_category(const struct sg_pt_base * vp)
+int
+get_scsi_pt_result_category(const struct sg_pt_base * vp)
{
const struct sg_pt_solaris_scsi * ptp = &vp->impl;
int scsi_st = ptp->uscsi.uscsi_status;
@@ -261,21 +278,24 @@ int get_scsi_pt_result_category(const struct sg_pt_base * vp)
return SCSI_PT_RESULT_GOOD;
}
-int get_scsi_pt_resid(const struct sg_pt_base * vp)
+int
+get_scsi_pt_resid(const struct sg_pt_base * vp)
{
const struct sg_pt_solaris_scsi * ptp = &vp->impl;
return ptp->uscsi.uscsi_resid;
}
-int get_scsi_pt_status_response(const struct sg_pt_base * vp)
+int
+get_scsi_pt_status_response(const struct sg_pt_base * vp)
{
const struct sg_pt_solaris_scsi * ptp = &vp->impl;
return ptp->uscsi.uscsi_status;
}
-int get_scsi_pt_sense_len(const struct sg_pt_base * vp)
+int
+get_scsi_pt_sense_len(const struct sg_pt_base * vp)
{
const struct sg_pt_solaris_scsi * ptp = &vp->impl;
int res;
@@ -287,7 +307,8 @@ int get_scsi_pt_sense_len(const struct sg_pt_base * vp)
return 0;
}
-int get_scsi_pt_duration_ms(const struct sg_pt_base * vp)
+int
+get_scsi_pt_duration_ms(const struct sg_pt_base * vp)
{
// const struct sg_pt_solaris_scsi * ptp = &vp->impl;
@@ -295,7 +316,8 @@ int get_scsi_pt_duration_ms(const struct sg_pt_base * vp)
return -1; /* not available */
}
-int get_scsi_pt_transport_err(const struct sg_pt_base * vp)
+int
+get_scsi_pt_transport_err(const struct sg_pt_base * vp)
{
// const struct sg_pt_solaris_scsi * ptp = &vp->impl;
@@ -303,15 +325,17 @@ int get_scsi_pt_transport_err(const struct sg_pt_base * vp)
return 0;
}
-int get_scsi_pt_os_err(const struct sg_pt_base * vp)
+int
+get_scsi_pt_os_err(const struct sg_pt_base * vp)
{
const struct sg_pt_solaris_scsi * ptp = &vp->impl;
return ptp->os_err;
}
-char * get_scsi_pt_transport_err_str(const struct sg_pt_base * vp,
- int max_b_len, char * b)
+char *
+get_scsi_pt_transport_err_str(const struct sg_pt_base * vp, int max_b_len,
+ char * b)
{
// const struct sg_pt_solaris_scsi * ptp = &vp->impl;
@@ -322,8 +346,8 @@ char * get_scsi_pt_transport_err_str(const struct sg_pt_base * vp,
return b;
}
-char * get_scsi_pt_os_err_str(const struct sg_pt_base * vp,
- int max_b_len, char * b)
+char *
+get_scsi_pt_os_err_str(const struct sg_pt_base * vp, int max_b_len, char * b)
{
const struct sg_pt_solaris_scsi * ptp = &vp->impl;
const char * cp;
diff --git a/lib/sg_pt_win32.c b/lib/sg_pt_win32.c
index e5fdb518..a04dd533 100644
--- a/lib/sg_pt_win32.c
+++ b/lib/sg_pt_win32.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2008 Douglas Gilbert.
+ * Copyright (c) 2006-2009 Douglas Gilbert.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
*
*/
-/* version 1.06 20081215 */
+/* sg_pt_win32 version 1.07 20090203 */
#include <stdio.h>
#include <stdlib.h>
@@ -90,11 +90,12 @@ struct sg_pt_base {
/* Returns >= 0 if successful. If error in Unix returns negated errno. */
-int scsi_pt_open_device(const char * device_name, int read_only, int verbose)
+int
+scsi_pt_open_device(const char * device_name, int read_only, int verbose)
{
int oflags = 0 /* O_NONBLOCK*/ ;
- oflags |= (read_only ? 0 : 0); /* was ... ? O_RDONLY : O_RDWR) */
+ oflags |= (read_only ? 0 : 0); /* was ... ? O_RDONLY : O_RDWR) */
return scsi_pt_open_flags(device_name, oflags, verbose);
}
@@ -110,9 +111,10 @@ int scsi_pt_open_device(const char * device_name, int read_only, int verbose)
* is a lot of keystrokes, "PD" is accepted and converted to the longer
* form.
*/
-int scsi_pt_open_flags(const char * device_name,
- int flags __attribute__ ((unused)),
- int verbose)
+int
+scsi_pt_open_flags(const char * device_name,
+ int flags __attribute__ ((unused)),
+ int verbose)
{
int len, k, adapter_num, bus, target, lun, off, got_scsi_name;
int index, num, got_pd_name, pd_num;
@@ -200,7 +202,8 @@ int scsi_pt_open_flags(const char * device_name,
/* Returns 0 if successful. If error in Unix returns negated errno. */
-int scsi_pt_close_device(int device_fd)
+int
+scsi_pt_close_device(int device_fd)
{
struct sg_pt_handle * shp;
int index;
@@ -219,7 +222,8 @@ int scsi_pt_close_device(int device_fd)
return 0;
}
-struct sg_pt_base * construct_scsi_pt_obj()
+struct sg_pt_base *
+construct_scsi_pt_obj()
{
struct sg_pt_win32_scsi * psp;
@@ -235,7 +239,8 @@ struct sg_pt_base * construct_scsi_pt_obj()
return (struct sg_pt_base *)psp;
}
-void destruct_scsi_pt_obj(struct sg_pt_base * vp)
+void
+destruct_scsi_pt_obj(struct sg_pt_base * vp)
{
struct sg_pt_win32_scsi * psp = &vp->impl;
@@ -244,8 +249,9 @@ void destruct_scsi_pt_obj(struct sg_pt_base * vp)
}
}
-void set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb,
- int cdb_len)
+void
+set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb,
+ int cdb_len)
{
struct sg_pt_win32_scsi * psp = &vp->impl;
@@ -259,8 +265,9 @@ void set_scsi_pt_cdb(struct sg_pt_base * vp, const unsigned char * cdb,
psp->swb.spt.CdbLength = cdb_len;
}
-void set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense,
- int sense_len)
+void
+set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense,
+ int sense_len)
{
struct sg_pt_win32_scsi * psp = &vp->impl;
@@ -271,8 +278,10 @@ void set_scsi_pt_sense(struct sg_pt_base * vp, unsigned char * sense,
psp->sense_len = sense_len;
}
-void set_scsi_pt_data_in(struct sg_pt_base * vp, /* from device */
- unsigned char * dxferp, int dxfer_len)
+/* from device */
+void
+set_scsi_pt_data_in(struct sg_pt_base * vp, unsigned char * dxferp,
+ int dxfer_len)
{
struct sg_pt_win32_scsi * psp = &vp->impl;
@@ -285,8 +294,10 @@ void set_scsi_pt_data_in(struct sg_pt_base * vp, /* from device */
}
}
-void set_scsi_pt_data_out(struct sg_pt_base * vp, /* to device */
- const unsigned char * dxferp, int dxfer_len)
+/* to device */
+void
+set_scsi_pt_data_out(struct sg_pt_base * vp, const unsigned char * dxferp,
+ int dxfer_len)
{
struct sg_pt_win32_scsi * psp = &vp->impl;
@@ -299,38 +310,44 @@ void set_scsi_pt_data_out(struct sg_pt_base * vp, /* to device */
}
}
-void set_scsi_pt_packet_id(struct sg_pt_base * vp __attribute__ ((unused)),
- int pack_id __attribute__ ((unused)))
+void
+set_scsi_pt_packet_id(struct sg_pt_base * vp __attribute__ ((unused)),
+ int pack_id __attribute__ ((unused)))
{
}
-void set_scsi_pt_tag(struct sg_pt_base * vp,
- uint64_t tag __attribute__ ((unused)))
+void
+set_scsi_pt_tag(struct sg_pt_base * vp, uint64_t tag __attribute__ ((unused)))
{
struct sg_pt_win32_scsi * psp = &vp->impl;
++psp->in_err;
}
-void set_scsi_pt_task_management(struct sg_pt_base * vp,
- int tmf_code __attribute__ ((unused)))
+void
+set_scsi_pt_task_management(struct sg_pt_base * vp,
+ int tmf_code __attribute__ ((unused)))
{
struct sg_pt_win32_scsi * psp = &vp->impl;
++psp->in_err;
}
-void set_scsi_pt_task_attr(struct sg_pt_base * vp,
- int attrib __attribute__ ((unused)),
- int priority __attribute__ ((unused)))
+void
+set_scsi_pt_task_attr(struct sg_pt_base * vp,
+ int attrib __attribute__ ((unused)),
+ int priority __attribute__ ((unused)))
{
struct sg_pt_win32_scsi * psp = &vp->impl;
++psp->in_err;
}
-int do_scsi_pt(struct sg_pt_base * vp, int device_fd, int time_secs,
- int verbose)
+/* Executes SCSI command (or at least forwards it to lower layers).
+ * Clears os_err field prior to active call (whose result may set it
+ * again). */
+int
+do_scsi_pt(struct sg_pt_base * vp, int device_fd, int time_secs, int verbose)
{
int index = device_fd - WIN32_FDOFFSET;
struct sg_pt_win32_scsi * psp = &vp->impl;
@@ -340,6 +357,7 @@ int do_scsi_pt(struct sg_pt_base * vp, int device_fd, int time_secs,
if (NULL == sg_warnings_strm)
sg_warnings_strm = stderr;
+ psp->os_err = 0;
if (psp->in_err) {
if (verbose)
fprintf(sg_warnings_strm, "Replicated or unused set_scsi_pt...\n");
@@ -452,7 +470,8 @@ int do_scsi_pt(struct sg_pt_base * vp, int device_fd, int time_secs,
return 0;
}
-int get_scsi_pt_result_category(const struct sg_pt_base * vp)
+int
+get_scsi_pt_result_category(const struct sg_pt_base * vp)
{
const struct sg_pt_win32_scsi * psp = &vp->impl;
@@ -469,21 +488,24 @@ int get_scsi_pt_result_category(const struct sg_pt_base * vp)
return SCSI_PT_RESULT_GOOD;
}
-int get_scsi_pt_resid(const struct sg_pt_base * vp)
+int
+get_scsi_pt_resid(const struct sg_pt_base * vp)
{
const struct sg_pt_win32_scsi * psp = &vp->impl;
return psp->resid;
}
-int get_scsi_pt_status_response(const struct sg_pt_base * vp)
+int
+get_scsi_pt_status_response(const struct sg_pt_base * vp)
{
const struct sg_pt_win32_scsi * psp = &vp->impl;
return psp->scsi_status;
}
-int get_scsi_pt_sense_len(const struct sg_pt_base * vp)
+int
+get_scsi_pt_sense_len(const struct sg_pt_base * vp)
{
const struct sg_pt_win32_scsi * psp = &vp->impl;
int len;
@@ -492,21 +514,24 @@ int get_scsi_pt_sense_len(const struct sg_pt_base * vp)
return (len > 0) ? len : 0;
}
-int get_scsi_pt_duration_ms(const struct sg_pt_base * vp __attribute__ ((unused)))
+int
+get_scsi_pt_duration_ms(const struct sg_pt_base * vp __attribute__ ((unused)))
{
// const struct sg_pt_freebsd_scsi * psp = &vp->impl;
return -1;
}
-int get_scsi_pt_transport_err(const struct sg_pt_base * vp)
+int
+get_scsi_pt_transport_err(const struct sg_pt_base * vp)
{
const struct sg_pt_win32_scsi * psp = &vp->impl;
return psp->transport_err;
}
-int get_scsi_pt_os_err(const struct sg_pt_base * vp)
+int
+get_scsi_pt_os_err(const struct sg_pt_base * vp)
{
const struct sg_pt_win32_scsi * psp = &vp->impl;
@@ -514,8 +539,9 @@ int get_scsi_pt_os_err(const struct sg_pt_base * vp)
}
-char * get_scsi_pt_transport_err_str(const struct sg_pt_base * vp,
- int max_b_len, char * b)
+char *
+get_scsi_pt_transport_err_str(const struct sg_pt_base * vp, int max_b_len,
+ char * b)
{
struct sg_pt_win32_scsi * psp = (struct sg_pt_win32_scsi *)&vp->impl;
LPVOID lpMsgBuf;
@@ -549,8 +575,8 @@ char * get_scsi_pt_transport_err_str(const struct sg_pt_base * vp,
return b;
}
-char * get_scsi_pt_os_err_str(const struct sg_pt_base * vp,
- int max_b_len, char * b)
+char *
+get_scsi_pt_os_err_str(const struct sg_pt_base * vp, int max_b_len, char * b)
{
const struct sg_pt_win32_scsi * psp = &vp->impl;
const char * cp;
diff --git a/sg3_utils.spec b/sg3_utils.spec
index 67453420..b759d863 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -79,7 +79,7 @@ fi
%{_libdir}/*.la
%changelog
-* Mon Feb 02 2009 - dgilbert at interlog dot com
+* Tue Feb 03 2009 - dgilbert at interlog dot com
- sg_dd: add flock, of2= and posix_fadvise support with nocache flag
* sg3_utils-1.27